diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2018-04-10 16:50:32 -0300 |
|---|---|---|
| committer | gdkchan <gab.dark.100@gmail.com> | 2018-04-10 16:50:32 -0300 |
| commit | feb2680a6ce1512c08980ee55c1c8215b8b5c3e4 (patch) | |
| tree | b41d2c8558ece834b2c1c5c9afba0afe226e0553 /Ryujinx.Graphics/Gpu/TextureReader.cs | |
| parent | e9cfdef0982824b673c60b362524408a263946df (diff) | |
[GPU] Add more shader instructions, add support for rgb565 textures
Diffstat (limited to 'Ryujinx.Graphics/Gpu/TextureReader.cs')
| -rw-r--r-- | Ryujinx.Graphics/Gpu/TextureReader.cs | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/Ryujinx.Graphics/Gpu/TextureReader.cs b/Ryujinx.Graphics/Gpu/TextureReader.cs index 60285aed..715578b5 100644 --- a/Ryujinx.Graphics/Gpu/TextureReader.cs +++ b/Ryujinx.Graphics/Gpu/TextureReader.cs @@ -12,6 +12,7 @@ namespace Ryujinx.Graphics.Gpu { case GalTextureFormat.A8B8G8R8: return Read4Bpp (Memory, Texture); case GalTextureFormat.A1B5G5R5: return Read2Bpp (Memory, Texture); + case GalTextureFormat.B5G6R5: return Read2Bpp (Memory, Texture); case GalTextureFormat.BC1: return Read8Bpt4x4 (Memory, Texture); case GalTextureFormat.BC2: return Read16Bpt4x4(Memory, Texture); case GalTextureFormat.BC3: return Read16Bpt4x4(Memory, Texture); @@ -20,14 +21,14 @@ namespace Ryujinx.Graphics.Gpu throw new NotImplementedException(Texture.Format.ToString()); } - private unsafe static byte[] Read4Bpp(AMemory Memory, Texture Texture) + private unsafe static byte[] Read2Bpp(AMemory Memory, Texture Texture) { int Width = Texture.Width; int Height = Texture.Height; - byte[] Output = new byte[Width * Height * 4]; + byte[] Output = new byte[Width * Height * 2]; - ISwizzle Swizzle = GetSwizzle(Texture, 4); + ISwizzle Swizzle = GetSwizzle(Texture, Width, 2); fixed (byte* BuffPtr = Output) { @@ -38,25 +39,25 @@ namespace Ryujinx.Graphics.Gpu { long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y); - int Pixel = Memory.ReadInt32Unchecked(Texture.Position + Offset); + short Pixel = Memory.ReadInt16Unchecked(Texture.Position + Offset); - *(int*)(BuffPtr + OutOffs) = Pixel; + *(short*)(BuffPtr + OutOffs) = Pixel; - OutOffs += 4; + OutOffs += 2; } } return Output; } - private unsafe static byte[] Read2Bpp(AMemory Memory, Texture Texture) + private unsafe static byte[] Read4Bpp(AMemory Memory, Texture Texture) { int Width = Texture.Width; int Height = Texture.Height; - byte[] Output = new byte[Width * Height * 2]; + byte[] Output = new byte[Width * Height * 4]; - ISwizzle Swizzle = GetSwizzle(Texture, 2); + ISwizzle Swizzle = GetSwizzle(Texture, Width, 4); fixed (byte* BuffPtr = Output) { @@ -67,11 +68,11 @@ namespace Ryujinx.Graphics.Gpu { long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y); - short Pixel = Memory.ReadInt16Unchecked(Texture.Position + Offset); + int Pixel = Memory.ReadInt32Unchecked(Texture.Position + Offset); - *(short*)(BuffPtr + OutOffs) = Pixel; + *(int*)(BuffPtr + OutOffs) = Pixel; - OutOffs += 2; + OutOffs += 4; } } @@ -85,7 +86,7 @@ namespace Ryujinx.Graphics.Gpu byte[] Output = new byte[Width * Height * 8]; - ISwizzle Swizzle = GetSwizzle(Texture, 8); + ISwizzle Swizzle = GetSwizzle(Texture, Width, 8); fixed (byte* BuffPtr = Output) { @@ -114,7 +115,7 @@ namespace Ryujinx.Graphics.Gpu byte[] Output = new byte[Width * Height * 16]; - ISwizzle Swizzle = GetSwizzle(Texture, 16); + ISwizzle Swizzle = GetSwizzle(Texture, Width, 16); fixed (byte* BuffPtr = Output) { @@ -138,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu return Output; } - private static ISwizzle GetSwizzle(Texture Texture, int Bpp) + private static ISwizzle GetSwizzle(Texture Texture, int Width, int Bpp) { switch (Texture.Swizzle) { @@ -148,7 +149,7 @@ namespace Ryujinx.Graphics.Gpu case TextureSwizzle.BlockLinear: case TextureSwizzle.BlockLinearColorKey: - return new BlockLinearSwizzle(Texture.Width, Bpp, Texture.BlockHeight); + return new BlockLinearSwizzle(Width, Bpp, Texture.BlockHeight); } throw new NotImplementedException(Texture.Swizzle.ToString()); |
