aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gpu
diff options
context:
space:
mode:
authorLDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com>2018-04-08 23:08:36 +0200
committergdkchan <gab.dark.100@gmail.com>2018-04-08 18:08:36 -0300
commite9cfdef0982824b673c60b362524408a263946df (patch)
treeddbcdbc4ebf6be77eba2f8512e1dfc9e38e02ca4 /Ryujinx.Graphics/Gpu
parentecf02f525f6505cf4576e750772ee6295a29e39e (diff)
Add A1B5G5R5 texture format. (#76)
* Update GalTextureFormat.cs * Update TextureReader.cs
Diffstat (limited to 'Ryujinx.Graphics/Gpu')
-rw-r--r--Ryujinx.Graphics/Gpu/TextureReader.cs32
1 files changed, 31 insertions, 1 deletions
diff --git a/Ryujinx.Graphics/Gpu/TextureReader.cs b/Ryujinx.Graphics/Gpu/TextureReader.cs
index 63dd2797..60285aed 100644
--- a/Ryujinx.Graphics/Gpu/TextureReader.cs
+++ b/Ryujinx.Graphics/Gpu/TextureReader.cs
@@ -11,6 +11,7 @@ namespace Ryujinx.Graphics.Gpu
switch (Texture.Format)
{
case GalTextureFormat.A8B8G8R8: return Read4Bpp (Memory, Texture);
+ case GalTextureFormat.A1B5G5R5: 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);
@@ -48,6 +49,35 @@ namespace Ryujinx.Graphics.Gpu
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, 2);
+
+ 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)
{
int Width = (Texture.Width + 3) / 4;
@@ -124,4 +154,4 @@ namespace Ryujinx.Graphics.Gpu
throw new NotImplementedException(Texture.Swizzle.ToString());
}
}
-} \ No newline at end of file
+}