From 8c31f1bb38d8a8f435543c57783410e01e55f2da Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 1 Jan 2022 12:33:57 -0800 Subject: [PATCH] softjit: Fix regcache error when clearing. Happens for non-through clears. --- GPU/Software/DrawPixelX86.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/GPU/Software/DrawPixelX86.cpp b/GPU/Software/DrawPixelX86.cpp index 346b7ca1a2..583ab14f29 100644 --- a/GPU/Software/DrawPixelX86.cpp +++ b/GPU/Software/DrawPixelX86.cpp @@ -1472,12 +1472,14 @@ bool PixelJitCache::Jit_WriteColor(const PixelFuncID &id) { } if (id.clearMode) { + bool drawingDone = false; if (!id.ColorClear() && !id.StencilClear()) - return true; + drawingDone = true; if (!id.ColorClear() && id.FBFormat() == GE_FORMAT_565) - return true; + drawingDone = true; - if (!id.ColorClear()) { + bool success = true; + if (!id.ColorClear() && !drawingDone) { // Let's reuse Jit_WriteStencilOnly for this path. X64Reg alphaReg; if (regCache_.Has(RegCache::GEN_SRC_ALPHA)) { @@ -1487,10 +1489,17 @@ bool PixelJitCache::Jit_WriteColor(const PixelFuncID &id) { MOVD_xmm(R(alphaReg), argColorReg); SHR(32, R(alphaReg), Imm8(24)); } - - bool success = Jit_WriteStencilOnly(id, alphaReg); + success = Jit_WriteStencilOnly(id, alphaReg); regCache_.Release(alphaReg, RegCache::GEN_SRC_ALPHA); + + drawingDone = true; + } + + if (drawingDone) { regCache_.Unlock(argColorReg, RegCache::VEC_ARG_COLOR); + regCache_.ForceRelease(RegCache::VEC_ARG_COLOR); + regCache_.Unlock(colorOff, RegCache::GEN_COLOR_OFF); + regCache_.ForceRelease(RegCache::GEN_COLOR_OFF); return success; }