softjit: Throw away regs allocated in conditionals.

If this happens, the register no longer has a deterministic value.
This commit is contained in:
Unknown W. Brackets committed 2021-12-11 00:06:14 -08:00
1 parent 5907897c36
commit d35ef352c3
1 file changed
+18
+18
View File
@@ -676,6 +676,9 @@ bool PixelJitCache::Jit_StencilTest(const PixelFuncID &id, RegCache::Reg stencil
return true;
}
bool hadGStateReg = regCache_.Has(RegCache::GEN_GSTATE);
bool hadColorOffReg = regCache_.Has(RegCache::GEN_COLOR_OFF);
bool success = true;
if (stencilReg != INVALID_REG && (!hasFixedResult || !fixedResult)) {
// This is the fail path.
@@ -685,6 +688,12 @@ bool PixelJitCache::Jit_StencilTest(const PixelFuncID &id, RegCache::Reg stencil
Discard();
}
// If we allocated either gstate or colorOff in the conditional, forget.
if (!hadGStateReg && regCache_.Has(RegCache::GEN_GSTATE))
regCache_.Change(RegCache::GEN_GSTATE, RegCache::GEN_INVALID);
if (!hadColorOffReg && regCache_.Has(RegCache::GEN_COLOR_OFF))
regCache_.Change(RegCache::GEN_COLOR_OFF, RegCache::GEN_INVALID);
if (!hasFixedResult)
SetJumpTarget(toPass);
return success;
@@ -741,11 +750,20 @@ bool PixelJitCache::Jit_DepthTestForStencil(const PixelFuncID &id, RegCache::Reg
break;
}
bool hadGStateReg = regCache_.Has(RegCache::GEN_GSTATE);
bool hadColorOffReg = regCache_.Has(RegCache::GEN_COLOR_OFF);
bool success = true;
success = success && Jit_ApplyStencilOp(id, id.ZFail(), stencilReg);
success = success && Jit_WriteStencilOnly(id, stencilReg);
Discard();
// If we allocated either gstate or colorOff in the conditional, forget.
if (!hadGStateReg && regCache_.Has(RegCache::GEN_GSTATE))
regCache_.Change(RegCache::GEN_GSTATE, RegCache::GEN_INVALID);
if (!hadColorOffReg && regCache_.Has(RegCache::GEN_COLOR_OFF))
regCache_.Change(RegCache::GEN_COLOR_OFF, RegCache::GEN_INVALID);
SetJumpTarget(skip);
// Like in Jit_DepthTest(), at this point we may not need this reg anymore.