softjit: Make it an error to unlock a temp.

Also fix some register usage in logic ops.
This commit is contained in:
Unknown W. Brackets 2021-11-28 18:09:44 -08:00
parent 75a918f96f
commit 4aa5bee14c
2 changed files with 6 additions and 5 deletions

View File

@ -595,7 +595,7 @@ bool PixelJitCache::Jit_StencilAndDepthTest(const PixelFuncID &id) {
bool success = true;
success = success && Jit_StencilTest(id, stencilReg, maskedReg);
if (maskedReg != stencilReg)
regCache_.Unlock(maskedReg, RegCache::GEN_TEMP0);
regCache_.Release(maskedReg, RegCache::GEN_TEMP0);
// Next up, the depth test.
if (stencilReg == INVALID_REG) {
@ -1664,7 +1664,7 @@ bool PixelJitCache::Jit_WriteColor(const PixelFuncID &id) {
bool PixelJitCache::Jit_ApplyLogicOp(const PixelFuncID &id, RegCache::Reg colorReg, RegCache::Reg maskReg) {
X64Reg gstateReg = GetGState();
X64Reg logicOpReg = regCache_.Alloc(RegCache::GEN_TEMP3);
X64Reg logicOpReg = regCache_.Alloc(RegCache::GEN_TEMP4);
MOVZX(32, 8, logicOpReg, MDisp(gstateReg, offsetof(GPUgstate, lop)));
AND(8, R(logicOpReg), Imm8(0x0F));
regCache_.Unlock(gstateReg, RegCache::GEN_GSTATE);
@ -1675,7 +1675,7 @@ bool PixelJitCache::Jit_ApplyLogicOp(const PixelFuncID &id, RegCache::Reg colorR
// Should already be allocated.
X64Reg colorOff = regCache_.Find(RegCache::GEN_COLOR_OFF);
X64Reg temp1Reg = regCache_.Find(RegCache::GEN_TEMP1);
X64Reg temp1Reg = regCache_.Alloc(RegCache::GEN_TEMP5);
// We'll use these in several cases, so prepare.
int bits = id.fbFormat == GE_FORMAT_8888 ? 32 : 16;
@ -1995,8 +1995,8 @@ bool PixelJitCache::Jit_ApplyLogicOp(const PixelFuncID &id, RegCache::Reg colorR
SetJumpTarget(fixup);
regCache_.Unlock(colorOff, RegCache::GEN_COLOR_OFF);
regCache_.Unlock(temp1Reg, RegCache::GEN_TEMP1);
regCache_.Unlock(logicOpReg, RegCache::GEN_TEMP3);
regCache_.Release(logicOpReg, RegCache::GEN_TEMP4);
regCache_.Release(temp1Reg, RegCache::GEN_TEMP5);
if (stencilReg != INVALID_REG)
regCache_.Unlock(stencilReg, RegCache::GEN_STENCIL);

View File

@ -205,6 +205,7 @@ void RegCache::Release(Reg &r, Purpose p) {
}
void RegCache::Unlock(Reg &r, Purpose p) {
_assert_msg_((p & FLAG_TEMP) == 0, "softjit Unlock() temp reg (%04X)", p);
RegStatus *status = FindReg(r, p);
if (status) {
_assert_msg_(status->locked > 0, "softjit Unlock() reg that isn't locked (%04X)", p);