diff options
author | gdkchan <gab.dark.100@gmail.com> | 2018-10-13 23:54:14 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-13 23:54:14 -0300 |
commit | 72317d777734155881081d5989aabd80146e1197 (patch) | |
tree | f8f570f6b7561c9853fcb7427101067773d69215 /Ryujinx.Graphics/Texture/ImageUtils.cs | |
parent | 894459fcd7797b1e38f2448797d83856d11b6e23 (diff) |
Add support for saturation on some shader instructions, fix ReadTexture alignment and add ColorMask support (#451)
* Add support for saturation on some shader instructions, fix ReadTexture alignment
* Add ColorMask support, other tweaks
Diffstat (limited to 'Ryujinx.Graphics/Texture/ImageUtils.cs')
-rw-r--r-- | Ryujinx.Graphics/Texture/ImageUtils.cs | 17 |
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; |