mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #16456 from hrydgard/soft-gpu-range-checks
SoftGPU: Range check block copies.
This commit is contained in:
commit
f4385e1bea
2 changed files with 27 additions and 4 deletions
|
@ -3073,11 +3073,11 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) {
|
|||
u32 dstLastAddr = dstBasePtr + ((dstY + height - 1) * dstStride + (dstX + width - 1)) * bpp;
|
||||
|
||||
if (!Memory::IsValidAddress(srcLastAddr)) {
|
||||
ERROR_LOG_REPORT(G3D, "Bottom-right corner of source of block transfer is at an invalid address: %08x", srcLastAddr);
|
||||
ERROR_LOG_N_TIMES(bad_xfer_src, 5, G3D, "Bottom-right corner of source of %dx%d src=(%d, %d) block transfer from buffer at %08x is at an invalid address: %08x. Skipping.", width, height, srcX, srcY, srcBasePtr, srcLastAddr);
|
||||
return;
|
||||
}
|
||||
if (!Memory::IsValidAddress(dstLastAddr)) {
|
||||
ERROR_LOG_REPORT(G3D, "Bottom-right corner of destination of block transfer is at an invalid address: %08x", srcLastAddr);
|
||||
ERROR_LOG_N_TIMES(bad_xfer_src, 5, G3D, "Bottom-right corner of destination of %dx%d dst=(%d, %d) block transfer to buffer at %08x is at an invalid address: %08x. Skipping.", width, height, dstX, dstY, dstBasePtr, srcLastAddr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -807,15 +807,38 @@ void SoftGPU::Execute_BlockTransferStart(u32 op, u32 diff) {
|
|||
u32 srcLineStartAddr = srcBasePtr + (srcY * srcStride + srcX) * bpp;
|
||||
u32 dstLineStartAddr = dstBasePtr + (dstY * dstStride + dstX) * bpp;
|
||||
|
||||
u32 bytesToCopy = width * height * bpp;
|
||||
|
||||
if (!Memory::IsValidRange(srcLineStartAddr, bytesToCopy)) {
|
||||
// What should we do here? Memset zeroes to the dest instead?
|
||||
return;
|
||||
}
|
||||
if (!Memory::IsValidRange(dstLineStartAddr, bytesToCopy)) {
|
||||
// What should we do here? Just not do the write, or partial write if
|
||||
// some part is in-range?
|
||||
return;
|
||||
}
|
||||
|
||||
const u8 *srcp = Memory::GetPointer(srcLineStartAddr);
|
||||
u8 *dstp = Memory::GetPointerWrite(dstLineStartAddr);
|
||||
memcpy(dstp, srcp, width * height * bpp);
|
||||
GPURecord::NotifyMemcpy(dstLineStartAddr, srcLineStartAddr, width * height * bpp);
|
||||
memcpy(dstp, srcp, bytesToCopy);
|
||||
GPURecord::NotifyMemcpy(dstLineStartAddr, srcLineStartAddr, bytesToCopy);
|
||||
} else {
|
||||
for (int y = 0; y < height; y++) {
|
||||
u32 srcLineStartAddr = srcBasePtr + ((y + srcY) * srcStride + srcX) * bpp;
|
||||
u32 dstLineStartAddr = dstBasePtr + ((y + dstY) * dstStride + dstX) * bpp;
|
||||
|
||||
u32 bytesToCopy = width * bpp;
|
||||
if (!Memory::IsValidRange(srcLineStartAddr, bytesToCopy)) {
|
||||
// What should we do here? Due to the y loop, in this case we might have
|
||||
// performed a partial copy. Probably fine.
|
||||
break;
|
||||
}
|
||||
if (!Memory::IsValidRange(dstLineStartAddr, bytesToCopy)) {
|
||||
// What should we do here? Due to the y loop, in this case we might have
|
||||
// performed a partial copy. Probably fine.
|
||||
break;
|
||||
}
|
||||
const u8 *srcp = Memory::GetPointer(srcLineStartAddr);
|
||||
u8 *dstp = Memory::GetPointerWrite(dstLineStartAddr);
|
||||
memcpy(dstp, srcp, width * bpp);
|
||||
|
|
Loading…
Add table
Reference in a new issue