aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Texture
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics/Texture')
-rw-r--r--Ryujinx.Graphics/Texture/ImageUtils.cs17
1 files changed, 11 insertions, 6 deletions
diff --git a/Ryujinx.Graphics/Texture/ImageUtils.cs b/Ryujinx.Graphics/Texture/ImageUtils.cs
index 1b043245..e1f370cd 100644
--- a/Ryujinx.Graphics/Texture/ImageUtils.cs
+++ b/Ryujinx.Graphics/Texture/ImageUtils.cs
@@ -235,18 +235,23 @@ namespace Ryujinx.Graphics.Texture
int BytesPerPixel = Desc.BytesPerPixel;
- int OutOffs = 0;
+ //Note: Each row of the texture needs to be aligned to 4 bytes.
+ int Pitch = (Width * BytesPerPixel + 3) & ~3;
- byte[] Data = new byte[Width * Height * BytesPerPixel];
+ byte[] Data = new byte[Height * Pitch];
for (int Y = 0; Y < Height; Y++)
- for (int X = 0; X < Width; X++)
{
- long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
+ int OutOffs = Y * Pitch;
+
+ for (int X = 0; X < Width; X++)
+ {
+ long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
- CpuMemory.ReadBytes(Position + Offset, Data, OutOffs, BytesPerPixel);
+ CpuMemory.ReadBytes(Position + Offset, Data, OutOffs, BytesPerPixel);
- OutOffs += BytesPerPixel;
+ OutOffs += BytesPerPixel;
+ }
}
return Data;