Fix base offset calculation for region copies.

This commit is contained in:
riperiperi 2020-05-24 17:27:41 +01:00
parent db2fec25c7
commit 00d0525596

View file

@ -76,6 +76,9 @@ namespace Ryujinx.Graphics.Gpu.Engine
{
fixed (byte* dstPtr = dstSpan, srcPtr = srcSpan)
{
byte* dstBase = dstPtr - dstBaseOffset; // Layout offset is relative to the base, so we need to subtract the span's offset.
byte* srcBase = srcPtr - srcBaseOffset;
for (int y = 0; y < cbp.YCount; y++)
{
srcCalculator.SetY(src.RegionY + y);
@ -83,10 +86,10 @@ namespace Ryujinx.Graphics.Gpu.Engine
for (int x = 0; x < cbp.XCount; x++)
{
int srcOffset = srcBaseOffset + srcCalculator.GetOffset(src.RegionX + x);
int dstOffset = dstBaseOffset + dstCalculator.GetOffset(dst.RegionX + x);
int srcOffset = srcCalculator.GetOffset(src.RegionX + x);
int dstOffset = dstCalculator.GetOffset(dst.RegionX + x);
*(T*)(dstPtr + dstOffset) = *(T*)(srcPtr + srcOffset);
*(T*)(dstBase + dstOffset) = *(T*)(srcBase + srcOffset);
}
}
}