Add support for half float attributes and fix texture pitch alignment
This commit is contained in:
parent
02e55c0eb1
commit
c20a11e687
3 changed files with 44 additions and 6 deletions
|
@ -25,6 +25,19 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
{ GalVertexAttribSize._11_11_10, 3 }
|
||||
};
|
||||
|
||||
private static Dictionary<GalVertexAttribSize, VertexAttribPointerType> FloatAttribTypes =
|
||||
new Dictionary<GalVertexAttribSize, VertexAttribPointerType>()
|
||||
{
|
||||
{ GalVertexAttribSize._32_32_32_32, VertexAttribPointerType.Float },
|
||||
{ GalVertexAttribSize._32_32_32, VertexAttribPointerType.Float },
|
||||
{ GalVertexAttribSize._16_16_16_16, VertexAttribPointerType.HalfFloat },
|
||||
{ GalVertexAttribSize._32_32, VertexAttribPointerType.Float },
|
||||
{ GalVertexAttribSize._16_16_16, VertexAttribPointerType.HalfFloat },
|
||||
{ GalVertexAttribSize._16_16, VertexAttribPointerType.HalfFloat },
|
||||
{ GalVertexAttribSize._32, VertexAttribPointerType.Float },
|
||||
{ GalVertexAttribSize._16, VertexAttribPointerType.HalfFloat }
|
||||
};
|
||||
|
||||
private static Dictionary<GalVertexAttribSize, VertexAttribPointerType> SignedAttribTypes =
|
||||
new Dictionary<GalVertexAttribSize, VertexAttribPointerType>()
|
||||
{
|
||||
|
@ -371,21 +384,25 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
|
||||
if (Attrib.Type == GalVertexAttribType.Float)
|
||||
{
|
||||
Type = VertexAttribPointerType.Float;
|
||||
Type = GetType(FloatAttribTypes, Attrib);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Unsigned)
|
||||
{
|
||||
Type = UnsignedAttribTypes[Attrib.Size];
|
||||
Type = GetType(UnsignedAttribTypes, Attrib);
|
||||
}
|
||||
else
|
||||
{
|
||||
Type = SignedAttribTypes[Attrib.Size];
|
||||
Type = GetType(SignedAttribTypes, Attrib);
|
||||
}
|
||||
}
|
||||
|
||||
int Size = AttribElements[Attrib.Size];
|
||||
if (!AttribElements.TryGetValue(Attrib.Size, out int Size))
|
||||
{
|
||||
throw new InvalidOperationException("Invalid attribute size \"" + Attrib.Size + "\"!");
|
||||
}
|
||||
|
||||
int Offset = Attrib.Offset;
|
||||
|
||||
if (Binding.Stride != 0)
|
||||
|
@ -425,6 +442,16 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
}
|
||||
}
|
||||
|
||||
private static VertexAttribPointerType GetType(Dictionary<GalVertexAttribSize, VertexAttribPointerType> Dict, GalVertexAttrib Attrib)
|
||||
{
|
||||
if (!Dict.TryGetValue(Attrib.Size, out VertexAttribPointerType Type))
|
||||
{
|
||||
throw new NotImplementedException("Unsupported size \"" + Attrib.Size + "\" on type \"" + Attrib.Type + "\"!");
|
||||
}
|
||||
|
||||
return Type;
|
||||
}
|
||||
|
||||
private unsafe static void SetConstAttrib(GalVertexAttrib Attrib)
|
||||
{
|
||||
if (Attrib.Size == GalVertexAttribSize._10_10_10_2 ||
|
||||
|
|
|
@ -289,7 +289,11 @@ namespace Ryujinx.Graphics.Texture
|
|||
{
|
||||
ImageDescriptor Desc = GetImageDescriptor(Format);
|
||||
|
||||
return Desc.BytesPerPixel * DivRoundUp(Width, Desc.BlockWidth);
|
||||
int Pitch = Desc.BytesPerPixel * DivRoundUp(Width, Desc.BlockWidth);
|
||||
|
||||
Pitch = (Pitch + 0x1f) & ~0x1f;
|
||||
|
||||
return Pitch;
|
||||
}
|
||||
|
||||
public static int GetBlockWidth(GalImageFormat Format)
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Texture
|
|||
int Width = (Tic[4] & 0xffff) + 1;
|
||||
int Height = (Tic[5] & 0xffff) + 1;
|
||||
|
||||
return new GalImage(
|
||||
GalImage Image = new GalImage(
|
||||
Width,
|
||||
Height,
|
||||
TileWidth,
|
||||
|
@ -51,6 +51,13 @@ namespace Ryujinx.Graphics.Texture
|
|||
YSource,
|
||||
ZSource,
|
||||
WSource);
|
||||
|
||||
if (Layout == GalMemoryLayout.Pitch)
|
||||
{
|
||||
Image.Pitch = (Tic[3] & 0xffff) << 5;
|
||||
}
|
||||
|
||||
return Image;
|
||||
}
|
||||
|
||||
public static GalTextureSampler MakeSampler(NvGpu Gpu, NvGpuVmm Vmm, long TscPosition)
|
||||
|
|
Loading…
Add table
Reference in a new issue