x86/microVU: Reference StateEnd instead of inlining state

This commit is contained in:
Stenzek 2023-05-14 17:20:51 +10:00 committed by refractionpcsx2
parent 2f985b479e
commit 5eacfe1afb
2 changed files with 16 additions and 36 deletions

View File

@ -390,12 +390,11 @@ void normBranch(mV, microFlagCycles& mFC)
{
DevCon.Warning("M-Bit on normal branch, report if broken");
u32 tempPC = iPC;
u32* cpS = (u32*)&mVUregs;
u32* lpS = (u32*)&mVU.prog.lpState;
for (size_t i = 0; i < (sizeof(microRegInfo) - 4) / 4; i++, lpS++, cpS++)
{
xMOV(ptr32[lpS], cpS[0]);
}
memcpy(&mVUpBlock->pStateEnd, &mVUregs, sizeof(microRegInfo));
xLoadFarAddr(rax, &mVUpBlock->pStateEnd);
xCALL((void*)mVU.copyPLState);
mVUsetupBranch(mVU, mFC);
mVUendProgram(mVU, &mFC, 3);
iPC = branchAddr(mVU) / 4;
@ -486,12 +485,11 @@ void condBranch(mV, microFlagCycles& mFC, int JMPcc)
if (mVUup.mBit)
{
u32 tempPC = iPC;
u32* cpS = (u32*)&mVUregs;
u32* lpS = (u32*)&mVU.prog.lpState;
for (size_t i = 0; i < (sizeof(microRegInfo) - 4) / 4; i++, lpS++, cpS++)
{
xMOV(ptr32[lpS], cpS[0]);
}
memcpy(&mVUpBlock->pStateEnd, &mVUregs, sizeof(microRegInfo));
xLoadFarAddr(rax, &mVUpBlock->pStateEnd);
xCALL((void*)mVU.copyPLState);
mVUendProgram(mVU, &mFC, 3);
xCMP(ptr16[&mVU.branch], 0);
xForwardJump32 dJMP((JccComparisonType)JMPcc);
@ -554,15 +552,16 @@ void condBranch(mV, microFlagCycles& mFC, int JMPcc)
{
s32* ajmp = xJcc32((JccComparisonType)JMPcc);
u32 bPC = iPC; // mVUcompile can modify iPC, mVUpBlock, and mVUregs so back them up
microBlock* pBlock = mVUpBlock;
memcpy(&pBlock->pStateEnd, &mVUregs, sizeof(microRegInfo));
microRegInfo regBackup;
memcpy(&regBackup, &mVUregs, sizeof(microRegInfo));
incPC2(1); // Get PC for branch not-taken
mVUcompile(mVU, xPC, (uptr)&mVUregs);
iPC = bPC;
incPC(-3); // Go back to branch opcode (to get branch imm addr)
uptr jumpAddr = (uptr)mVUblockFetch(mVU, branchAddr(mVU), (uptr)&pBlock->pStateEnd);
uptr jumpAddr = (uptr)mVUblockFetch(mVU, branchAddr(mVU), (uptr)&regBackup);
*ajmp = (jumpAddr - ((uptr)ajmp + 4));
}
}

View File

@ -472,32 +472,13 @@ void mVUtestCycles(microVU& mVU, microFlagCycles& mFC)
xForwardJNS32 skip;
u8* writeback = x86Ptr;
xLoadFarAddr(rax, x86Ptr);
xFastCall((void*)mVU.copyPLState);
xLoadFarAddr(rax, &mVUpBlock->pState);
xCALL((void*)mVU.copyPLState);
if (EmuConfig.Gamefixes.VUSyncHack || EmuConfig.Gamefixes.FullVU0SyncHack)
xMOV(ptr32[&mVU.regs().nextBlockCycles], mVUcycles);
mVUendProgram(mVU, &mFC, 0);
{
if(x86caps.hasAVX2)
xAlignPtr(32);
else
xAlignPtr(16);
u8* curx86Ptr = x86Ptr;
x86SetPtr(writeback);
xLoadFarAddr(rax, curx86Ptr);
x86SetPtr(curx86Ptr);
static_assert((sizeof(microRegInfo) % 4) == 0);
const u32* lpPtr = reinterpret_cast<const u32*>(&mVU.prog.lpState);
const u32* lpEnd = lpPtr + (sizeof(microRegInfo) / 4);
while (lpPtr != lpEnd)
xWrite32(*(lpPtr++));
}
skip.SetTarget();
xSUB(ptr32[&mVU.cycles], mVUcycles);