From a7a33dc41414defe56f870704db770b596ca2e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 24 Jun 2025 17:16:59 +0200 Subject: [PATCH] Fix potential sign issue in Accessible() (though I don't quite get how it's failing). --- Common/x64Emitter.h | 5 ++++- GPU/Software/SoftGpu.cpp | 14 ++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Common/x64Emitter.h b/Common/x64Emitter.h index 832ed767cb..8d9b31b200 100644 --- a/Common/x64Emitter.h +++ b/Common/x64Emitter.h @@ -281,7 +281,10 @@ inline OpArg MRegSum(X64Reg base, X64Reg offset) template inline bool Accessible(const T *t1, const T *t2) { ptrdiff_t diff = (const uint8_t *)t1 - (const uint8_t *)t2; - return diff > -0x7FFFFFE0 && diff < 0x7FFFFFE0; + if (diff < 0) { + diff = -diff; + } + return diff < (ptrdiff_t)0x7FFFFFE0; } template diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 6b98f99c52..b95f80b21f 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -1028,12 +1028,7 @@ void SoftGPU::Execute_FramebufPtr(u32 op, u32 diff) { // We assume fb.data won't change while we're drawing. if (diff) { drawEngine_->transformUnit.Flush(this, "framebuf"); - if (gstate.getFrameBufAddress() != 0) { - _dbg_assert_msg_(Memory::IsValidAddress(gstate.getFrameBufAddress()), "Invalid framebuffer address %08x", gstate.getFrameBufAddress()); - fb.data = Memory::GetPointerWriteUnchecked(gstate.getFrameBufAddress()); - } else { - fb.data = nullptr; - } + fb.data = Memory::GetPointerWriteUnchecked(gstate.getFrameBufAddress()); } } @@ -1054,12 +1049,7 @@ void SoftGPU::Execute_ZbufPtr(u32 op, u32 diff) { drawEngine_->transformUnit.Flush(this, "depthbuf"); // For the pointer, ignore memory mirrors. This also gives some buffer for draws that go outside. // TODO: Confirm how wrapping is handled in drawing. Adjust if we ever handle VRAM mirrors more accurately. - if (gstate.getDepthBufAddress() != 0) { - _dbg_assert_msg_(Memory::IsValidAddress(gstate.getDepthBufAddress()), "Invalid depthbuffer address %08x", gstate.getDepthBufAddress()); - depthbuf.data = Memory::GetPointerWriteUnchecked(gstate.getDepthBufAddress() & 0x041FFFF0); - } else { - depthbuf.data = nullptr; - } + depthbuf.data = Memory::GetPointerWrite(gstate.getDepthBufAddress() & 0x041FFFF0); } }