mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-26 02:23:05 +00:00
Update TextureReader.cs
This commit is contained in:
parent
76d9e2763a
commit
3d1c082a58
1 changed files with 31 additions and 1 deletions
|
@ -11,6 +11,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
switch (Texture.Format)
|
switch (Texture.Format)
|
||||||
{
|
{
|
||||||
case GalTextureFormat.A8B8G8R8: return Read4Bpp (Memory, Texture);
|
case GalTextureFormat.A8B8G8R8: return Read4Bpp (Memory, Texture);
|
||||||
|
case GalTextureFormat.A1B5G5R5: return Read2Bpp (Memory, Texture);
|
||||||
case GalTextureFormat.BC1: return Read8Bpt4x4 (Memory, Texture);
|
case GalTextureFormat.BC1: return Read8Bpt4x4 (Memory, Texture);
|
||||||
case GalTextureFormat.BC2: return Read16Bpt4x4(Memory, Texture);
|
case GalTextureFormat.BC2: return Read16Bpt4x4(Memory, Texture);
|
||||||
case GalTextureFormat.BC3: return Read16Bpt4x4(Memory, Texture);
|
case GalTextureFormat.BC3: return Read16Bpt4x4(Memory, Texture);
|
||||||
|
@ -48,6 +49,35 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
return Output;
|
return Output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private unsafe static byte[] Read2Bpp(AMemory Memory, Texture Texture)
|
||||||
|
{
|
||||||
|
int Width = Texture.Width;
|
||||||
|
int Height = Texture.Height;
|
||||||
|
|
||||||
|
byte[] Output = new byte[Width * Height * 2];
|
||||||
|
|
||||||
|
ISwizzle Swizzle = GetSwizzle(Texture.Swizzle, Width, 2, Texture.BlockHeight);
|
||||||
|
|
||||||
|
fixed (byte* BuffPtr = Output)
|
||||||
|
{
|
||||||
|
long OutOffs = 0;
|
||||||
|
|
||||||
|
for (int Y = 0; Y < Height; Y++)
|
||||||
|
for (int X = 0; X < Width; X++)
|
||||||
|
{
|
||||||
|
long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
|
||||||
|
|
||||||
|
short Pixel = Memory.ReadInt16Unchecked(Texture.Position + Offset);
|
||||||
|
|
||||||
|
*(short*)(BuffPtr + OutOffs) = Pixel;
|
||||||
|
|
||||||
|
OutOffs += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Output;
|
||||||
|
}
|
||||||
|
|
||||||
private unsafe static byte[] Read8Bpt4x4(AMemory Memory, Texture Texture)
|
private unsafe static byte[] Read8Bpt4x4(AMemory Memory, Texture Texture)
|
||||||
{
|
{
|
||||||
int Width = (Texture.Width + 3) / 4;
|
int Width = (Texture.Width + 3) / 4;
|
||||||
|
@ -124,4 +154,4 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
throw new NotImplementedException(Swizzle.ToString());
|
throw new NotImplementedException(Swizzle.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue