diff --git a/pcsx2/x86/microVU.h b/pcsx2/x86/microVU.h index d5ab781448..5063a70dfd 100644 --- a/pcsx2/x86/microVU.h +++ b/pcsx2/x86/microVU.h @@ -209,7 +209,11 @@ struct microVU __aligned16 u32 macFlag [4]; // 4 instances of mac flag (used in execution) __aligned16 u32 clipFlag[4]; // 4 instances of clip flag (used in execution) __aligned16 u32 xmmCTemp[4]; // Backup used in mVUclamp2() +#ifdef __M_X86_64 + __aligned16 u32 xmmBackup[16][4]; // Backup for xmm0~xmm15 +#else __aligned16 u32 xmmBackup[8][4]; // Backup for xmm0~xmm7 +#endif u32 index; // VU Index (VU0 or VU1) u32 cop2; // VU is in COP2 mode? (No/Yes) diff --git a/pcsx2/x86/microVU_IR.h b/pcsx2/x86/microVU_IR.h index 7fbeb651ea..5970abd005 100644 --- a/pcsx2/x86/microVU_IR.h +++ b/pcsx2/x86/microVU_IR.h @@ -224,7 +224,11 @@ struct microMapXMM class microRegAlloc { protected: - static const int xmmTotal = 7; // Don't allocate PQ? +#ifdef __M_X86_64 + static const int xmmTotal = 15; // PQ register is reserved +#else + static const int xmmTotal = 7; // PQ register is reserved +#endif microMapXMM xmmMap[xmmTotal]; int counter; // Current allocation count int index; // VU0 or VU1 @@ -287,6 +291,10 @@ public: counter = 0; } + int getXmmCount() + { + return xmmTotal + 1; + } // Flushes all allocated registers (i.e. writes-back to memory all modified registers). // If clearState is 0, then it keeps cached reg data valid // If clearState is 1, then it invalidates all cached reg data after write-back diff --git a/pcsx2/x86/microVU_Misc.h b/pcsx2/x86/microVU_Misc.h index 85f2e0be9e..3ff25f4c78 100644 --- a/pcsx2/x86/microVU_Misc.h +++ b/pcsx2/x86/microVU_Misc.h @@ -141,7 +141,12 @@ static const char branchSTR[16][8] = { #define xmmT5 xmm4 // Used for regAlloc #define xmmT6 xmm5 // Used for regAlloc #define xmmT7 xmm6 // Used for regAlloc +#ifdef __M_X86_64 +#define xmmPQ xmm15 // Holds the Value and Backup Values of P and Q regs +#else #define xmmPQ xmm7 // Holds the Value and Backup Values of P and Q regs +#endif + #define gprT1 eax // eax - Temp Reg #define gprT2 ecx // ecx - Temp Reg diff --git a/pcsx2/x86/microVU_Misc.inl b/pcsx2/x86/microVU_Misc.inl index 120e8147d3..d43ee826b2 100644 --- a/pcsx2/x86/microVU_Misc.inl +++ b/pcsx2/x86/microVU_Misc.inl @@ -149,7 +149,7 @@ __fi void mVUbackupRegs(microVU& mVU, bool toMemory = false, bool onlyNeeded = f { if (toMemory) { - for (int i = 0; i < 8; i++) + for (int i = 0; i < mVU.regAlloc->getXmmCount(); i++) { if (!onlyNeeded || mVU.regAlloc->checkCachedReg(i) || xmmPQ.Id == i) xMOVAPS(ptr128[&mVU.xmmBackup[i][0]], xmm(i)); @@ -167,7 +167,7 @@ __fi void mVUrestoreRegs(microVU& mVU, bool fromMemory = false, bool onlyNeeded { if (fromMemory) { - for (int i = 0; i < 8; i++) + for (int i = 0; i < mVU.regAlloc->getXmmCount(); i++) { if (!onlyNeeded || mVU.regAlloc->checkCachedReg(i) || xmmPQ.Id == i) xMOVAPS(xmm(i), ptr128[&mVU.xmmBackup[i][0]]); @@ -197,13 +197,13 @@ public: _mVUt void __fc mVUprintRegs() { microVU& mVU = mVUx; - for (int i = 0; i < 8; i++) + for (int i = 0; i < mVU.regAlloc->getXmmCount(); i++) { Console.WriteLn("xmm%d = [0x%08x,0x%08x,0x%08x,0x%08x]", i, mVU.xmmBackup[i][0], mVU.xmmBackup[i][1], mVU.xmmBackup[i][2], mVU.xmmBackup[i][3]); } - for (int i = 0; i < 8; i++) + for (int i = 0; i < mVU.regAlloc->getXmmCount(); i++) { Console.WriteLn("xmm%d = [%f,%f,%f,%f]", i, (float&)mVU.xmmBackup[i][0], (float&)mVU.xmmBackup[i][1],