diff --git a/Ryujinx.Graphics/Gpu/LinearSwizzle.cs b/Ryujinx.Graphics/Gpu/LinearSwizzle.cs index 01f09f8160..c7a6b304e8 100644 --- a/Ryujinx.Graphics/Gpu/LinearSwizzle.cs +++ b/Ryujinx.Graphics/Gpu/LinearSwizzle.cs @@ -2,19 +2,18 @@ namespace Ryujinx.Graphics.Gpu { class LinearSwizzle : ISwizzle { + private int Pitch; private int Bpp; - private int Stride; - public LinearSwizzle(int Width, int Bpp) + public LinearSwizzle(int Pitch, int Bpp) { - this.Bpp = Bpp; - - Stride = Width * Bpp; + this.Pitch = Pitch; + this.Bpp = Bpp; } public int GetSwizzleOffset(int X, int Y) { - return X * Bpp + Y * Stride; + return X * Bpp + Y * Pitch; } } } \ No newline at end of file diff --git a/Ryujinx.Graphics/Gpu/Texture.cs b/Ryujinx.Graphics/Gpu/Texture.cs index c8d4e5274d..831c664d4f 100644 --- a/Ryujinx.Graphics/Gpu/Texture.cs +++ b/Ryujinx.Graphics/Gpu/Texture.cs @@ -8,6 +8,7 @@ namespace Ryujinx.Graphics.Gpu public int Width { get; private set; } public int Height { get; private set; } + public int Pitch { get; private set; } public int BlockHeight { get; private set; } @@ -19,6 +20,7 @@ namespace Ryujinx.Graphics.Gpu long Position, int Width, int Height, + int Pitch, int BlockHeight, TextureSwizzle Swizzle, GalTextureFormat Format) @@ -26,6 +28,7 @@ namespace Ryujinx.Graphics.Gpu this.Position = Position; this.Width = Width; this.Height = Height; + this.Pitch = Pitch; this.BlockHeight = BlockHeight; this.Swizzle = Swizzle; this.Format = Format; diff --git a/Ryujinx.Graphics/Gpu/TextureFactory.cs b/Ryujinx.Graphics/Gpu/TextureFactory.cs index 0a0497f3fd..7f8580d987 100644 --- a/Ryujinx.Graphics/Gpu/TextureFactory.cs +++ b/Ryujinx.Graphics/Gpu/TextureFactory.cs @@ -20,6 +20,8 @@ namespace Ryujinx.Graphics.Gpu TextureSwizzle Swizzle = (TextureSwizzle)((Tic[2] >> 21) & 7); + int Pitch = (Tic[3] & 0xffff) << 5; + int BlockHeightLog2 = (Tic[3] >> 3) & 7; int BlockHeight = 1 << BlockHeightLog2; @@ -31,6 +33,7 @@ namespace Ryujinx.Graphics.Gpu TextureAddress, Width, Height, + Pitch, BlockHeight, Swizzle, Format); diff --git a/Ryujinx.Graphics/Gpu/TextureReader.cs b/Ryujinx.Graphics/Gpu/TextureReader.cs index ce66e991d6..63dd27977c 100644 --- a/Ryujinx.Graphics/Gpu/TextureReader.cs +++ b/Ryujinx.Graphics/Gpu/TextureReader.cs @@ -26,7 +26,7 @@ namespace Ryujinx.Graphics.Gpu byte[] Output = new byte[Width * Height * 4]; - ISwizzle Swizzle = GetSwizzle(Texture.Swizzle, Width, 4, Texture.BlockHeight); + ISwizzle Swizzle = GetSwizzle(Texture, 4); fixed (byte* BuffPtr = Output) { @@ -55,7 +55,7 @@ namespace Ryujinx.Graphics.Gpu byte[] Output = new byte[Width * Height * 8]; - ISwizzle Swizzle = GetSwizzle(Texture.Swizzle, Width, 8, Texture.BlockHeight); + ISwizzle Swizzle = GetSwizzle(Texture, 8); fixed (byte* BuffPtr = Output) { @@ -84,7 +84,7 @@ namespace Ryujinx.Graphics.Gpu byte[] Output = new byte[Width * Height * 16]; - ISwizzle Swizzle = GetSwizzle(Texture.Swizzle, Width, 16, Texture.BlockHeight); + ISwizzle Swizzle = GetSwizzle(Texture, 16); fixed (byte* BuffPtr = Output) { @@ -108,20 +108,20 @@ namespace Ryujinx.Graphics.Gpu return Output; } - private static ISwizzle GetSwizzle(TextureSwizzle Swizzle, int Width, int Bpp, int BlockHeight) + private static ISwizzle GetSwizzle(Texture Texture, int Bpp) { - switch (Swizzle) + switch (Texture.Swizzle) { case TextureSwizzle.Pitch: case TextureSwizzle.PitchColorKey: - return new LinearSwizzle(Width, Bpp); + return new LinearSwizzle(Texture.Pitch, Bpp); case TextureSwizzle.BlockLinear: case TextureSwizzle.BlockLinearColorKey: - return new BlockLinearSwizzle(Width, Bpp, BlockHeight); + return new BlockLinearSwizzle(Texture.Width, Bpp, Texture.BlockHeight); } - throw new NotImplementedException(Swizzle.ToString()); + throw new NotImplementedException(Texture.Swizzle.ToString()); } } } \ No newline at end of file