diff --git a/Core/MemMap.h b/Core/MemMap.h index c53a75f4a4..e447620b78 100644 --- a/Core/MemMap.h +++ b/Core/MemMap.h @@ -337,6 +337,7 @@ inline u32 ValidSize(const u32 address, const u32 requested_size) { return requested_size; } +// NOTE: If size == 0, any address will be accepted. This may not be ideal for all cases. inline bool IsValidRange(const u32 address, const u32 size) { return ValidSize(address, size) == size; } diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 08ad845e05..1710f50c36 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -1675,11 +1675,12 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) { if ((dstBasePtr & 0x04800000) == 0x04800000) dstBasePtr &= ~0x00800000; - // Use height less one to account for width, which can be greater or less than stride. + // Use height less one to account for width, which can be greater or less than stride, and then add it on for the last line. + // NOTE: The sizes are only used for validity checks and memory info tracking. const uint32_t src = srcBasePtr + (srcY * srcStride + srcX) * bpp; - const uint32_t srcSize = (height - 1) * (srcStride + width) * bpp; const uint32_t dst = dstBasePtr + (dstY * dstStride + dstX) * bpp; - const uint32_t dstSize = (height - 1) * (dstStride + width) * bpp; + const uint32_t srcSize = ((height - 1) * srcStride) + width * bpp; + const uint32_t dstSize = ((height - 1) * dstStride) + width * bpp; bool srcDstOverlap = src + srcSize > dst && dst + dstSize > src; bool srcValid = Memory::IsValidRange(src, srcSize);