From 426fcf3afc19b6abc96c8c74668a1e4f4a11d9ec Mon Sep 17 00:00:00 2001 From: refraction Date: Fri, 29 May 2015 22:56:30 +0100 Subject: [PATCH] Reverted microVU flag hack, it did nothing it wasn't already doing. --- pcsx2/gui/Panels/SpeedhacksPanel.cpp | 2 +- pcsx2/x86/ix86-32/iR5900-32.cpp | 1 + pcsx2/x86/microVU_Analyze.inl | 10 +-- pcsx2/x86/microVU_Flags.inl | 99 ++-------------------------- pcsx2/x86/microVU_IR.h | 3 +- pcsx2/x86/microVU_Upper.inl | 2 +- 6 files changed, 13 insertions(+), 104 deletions(-) diff --git a/pcsx2/gui/Panels/SpeedhacksPanel.cpp b/pcsx2/gui/Panels/SpeedhacksPanel.cpp index 1abace3913..2526401242 100644 --- a/pcsx2/gui/Panels/SpeedhacksPanel.cpp +++ b/pcsx2/gui/Panels/SpeedhacksPanel.cpp @@ -150,7 +150,7 @@ Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow* parent ) m_check_vuThread = new pxCheckBox( vuHacksPanel, _("MTVU (Multi-Threaded microVU1)"), _("Good Speedup and High Compatibility; may cause hanging... [Recommended if 3+ cores]") ); - m_check_vuFlagHack->SetToolTip( pxEt( L"Updates Mac and Status Flags only on blocks which will read them, instead of all the time. This is safe most of the time, and Super VU does something similar by default." + m_check_vuFlagHack->SetToolTip( pxEt( L"Updates Status Flags only on blocks which will read them, instead of all the time. This is safe most of the time, and Super VU does something similar by default." ) ); m_check_vuThread->SetToolTip( pxEt( L"Runs VU1 on its own thread (microVU1-only). Generally a speedup on CPUs with 3 or more cores. This is safe for most games, but a few games are incompatible and may hang. In the case of GS limited games, it may be a slowdown (especially on dual core CPUs)." diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index f1546e20b8..18c84f7c2d 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -1555,6 +1555,7 @@ void recompileNextInstruction(int delayslot) DevCon.Warning("Possible old value used in COP2 code"); for (u32 i = s_pCurBlockEx->startpc; i < s_nEndBlock; i += 4) { + disasm = ""; disR5900Fasm(disasm, memRead32(i), i,false); DevCon.Warning("%s%08X %s", i == pc - 4 ? "*" : i == p ? "=" : " ", memRead32(i), disasm.c_str()); } diff --git a/pcsx2/x86/microVU_Analyze.inl b/pcsx2/x86/microVU_Analyze.inl index d47b77309c..c3375d817d 100644 --- a/pcsx2/x86/microVU_Analyze.inl +++ b/pcsx2/x86/microVU_Analyze.inl @@ -291,7 +291,7 @@ __ri void flagSet(mV, bool setMacFlag) { for (int i = mVUcount, j = 0; i > 0; i--, j++) { j += mVUstall; incPC2(-2); - if (sFLAG.doFlag && (j >= 3) && sFLAG.skipWrite != 1) { + if (sFLAG.doFlag && (j >= 3)) { if (setMacFlag) { mFLAG.doFlag = 1; } else { sFLAG.doNonSticky = 1; } break; @@ -301,7 +301,7 @@ __ri void flagSet(mV, bool setMacFlag) { } __ri void mVUanalyzeSflag(mV, int It) { - mVUlow.readFlags = 1; + mVUlow.readFlags = true; analyzeVIreg2(mVU, It, mVUlow.VI_write, 1); if (!It) { mVUlow.isNOP = 1; } else { @@ -317,7 +317,7 @@ __ri void mVUanalyzeSflag(mV, int It) { __ri void mVUanalyzeFSSET(mV) { mVUlow.isFSSET = 1; - mVUlow.readFlags = 2; + mVUlow.readFlags = true; } //------------------------------------------------------------------ @@ -325,7 +325,7 @@ __ri void mVUanalyzeFSSET(mV) { //------------------------------------------------------------------ __ri void mVUanalyzeMflag(mV, int Is, int It) { - mVUlow.readFlags = 1; + mVUlow.readFlags = true; analyzeVIreg1(mVU, Is, mVUlow.VI_read[0]); analyzeVIreg2(mVU, It, mVUlow.VI_write, 1); if (!It) { mVUlow.isNOP = 1; } @@ -345,7 +345,7 @@ __ri void mVUanalyzeMflag(mV, int Is, int It) { __fi void mVUanalyzeCflag(mV, int It) { mVUinfo.swapOps = 1; - mVUlow.readFlags = 2; + mVUlow.readFlags = true; if (mVUcount < 4) { if (!(mVUpBlock->pState.needExactMatch & 4)) // The only time this should happen is on the first program block DevCon.WriteLn(Color_Green, "microVU%d: pState's cFlag Info was expected to be set [%04x]", getIndex, xPC); diff --git a/pcsx2/x86/microVU_Flags.inl b/pcsx2/x86/microVU_Flags.inl index fd4fbd3fb8..26b731cda7 100644 --- a/pcsx2/x86/microVU_Flags.inl +++ b/pcsx2/x86/microVU_Flags.inl @@ -31,7 +31,7 @@ __fi void mVUstatusFlagOp(mV) { int i = mVUcount; bool runLoop = true; - if (sFLAG.doFlag && sFLAG.skipWrite != 1) { + if (sFLAG.doFlag) { sFLAG.doNonSticky = true; } else { @@ -41,7 +41,7 @@ __fi void mVUstatusFlagOp(mV) { runLoop = false; break; } - else if (sFLAG.doFlag && sFLAG.skipWrite != 1) { + else if (sFLAG.doFlag) { sFLAG.doNonSticky = true; break; } @@ -92,7 +92,7 @@ void sortFullFlag(int* fFlag, int* bFlag) { } } -#define sFlagCond ((sFLAG.doFlag && sFLAG.skipWrite != 1) || mVUlow.isFSSET || mVUinfo.doDivFlag ) +#define sFlagCond (sFLAG.doFlag || mVUlow.isFSSET || mVUinfo.doDivFlag ) #define sHackCond (mVUsFlagHack && !sFLAG.doNonSticky) // Note: Flag handling is 'very' complex, it requires full knowledge of how microVU recs work, so don't touch! @@ -121,98 +121,7 @@ __fi void mVUsetFlags(mV, microFlagCycles& mFC) { } incPC2(-2); } - - if (mVUsFlagHack){ - bool flagReadFound = false; - bool updateCalcFound = false; - int flagReadptr = 0; - incPC2((aCount * 2)); - int instanceCycles = 0; - - // Go through checking flags if they need to be written back or not, ignoring the last 4ish of course - for (int i = mVUcount; i > 0; i--) { - if (sFLAG.doFlag) { - if (writeProtect && (mVUcount - i) <= aCount) { //Don't actually clear any of the last ops in the block, just check for reads - //DevCon.Warning("aCnt %d, mVUcnt %d mVUcnt-i %d", aCount, mVUcount, (mVUcount - i)); - sFLAG.skipWrite = 2; - } - - if (flagReadFound) { - if (instanceCycles >= 4) { - if (mVUinfo.uOp.VF_write.reg != 0) { //Keep going because this is a mac/status calculation op only - if (updateCalcFound == false) - sFLAG.skipWrite = 2; - //DevCon.Warning("Flag read mac found at %d and %d cycles, rolling back to %d", i, instanceCycles, i + (flagReadptr - 1) * 2); - flagReadFound = false; - updateCalcFound = false; - instanceCycles = 0; - //Roll back in case there was other flag reads - - incPC2((flagReadptr - 1) * 2); - i += flagReadptr - 1; - flagReadptr = 0; - } - else { - //DevCon.Warning("Calculation found!"); - updateCalcFound = true; - sFLAG.skipWrite = 2; - } - } - //else DevCon.Warning("waiting On %d cycles, flagptr %d pos %d", instanceCycles, flagReadptr, i); - //Else do nothing, we will come back to this one - } - else { - if (sFLAG.skipWrite != 2) { //Kill only non-write protected flag updates - - sFLAG.skipWrite = 1; - //DevCon.Warning("ignoring at %d", i); - } - //else DevCon.Warning("Write protected at %d", i); - } - } - - - - if (flagReadFound) { - if (i == 1) { - //Nothing found by the end of the block - flagReadFound = false; - - //Roll back in case there was other flag reads - if (flagReadptr > 0) { - incPC2((flagReadptr)* 2); - i += flagReadptr - 1; - flagReadptr = 0; - } - } - else { //Relevant flag update instructions not yet found, keep checking the stalls to get the right one - if (flagReadptr > 0){ - //DevCon.Warning("adding cycles Swap ops %d", mVUinfo.swapOps); - instanceCycles += mVUstall; - if (mVUstall == 0) - instanceCycles += 1; - - } - flagReadptr++; - } - } - if (mVUlow.readFlags == 1 && !flagReadFound) { - flagReadFound = true; - flagReadptr = 0; - instanceCycles = 0; - //DevCon.Warning("Found Flag on %d Stall = %d swapops = %d", i, mVUstall, mVUinfo.swapOps); - - if (mVUinfo.swapOps) - instanceCycles += mVUstall; - - instanceCycles += 1; - //DevCon.Warning("%d cycles on flag read", instanceCycles); - flagReadptr++; - } - incPC2(-2); - } - } - + // Status/Mac Flags Setup Code int xS = 0, xM = 0, xC = 0; u32 ff0=0, ff1=0, ffOn=0, fInfo=0; diff --git a/pcsx2/x86/microVU_IR.h b/pcsx2/x86/microVU_IR.h index 134f0b4f27..02dbf3d6c5 100644 --- a/pcsx2/x86/microVU_IR.h +++ b/pcsx2/x86/microVU_IR.h @@ -133,7 +133,7 @@ struct microLowerOp { bool backupVI; // Backup VI reg to memory if modified before branch (branch uses old VI value unless opcode is ILW or ILWR) bool memReadIs; // Read Is (VI reg) from memory (used by branches) bool memReadIt; // Read If (VI reg) from memory (used by branches) - u8 readFlags; // Current Instruction reads Status, Mac, or Clip flags + bool readFlags; // Current Instruction reads Status, Mac, or Clip flags }; struct microFlagInst { @@ -142,7 +142,6 @@ struct microFlagInst { u8 write; // Points to the instance that should be written to (s-stage write) u8 lastWrite; // Points to the instance that was last written to (most up-to-date flag) u8 read; // Points to the instance that should be read by a lower instruction (t-stage read) - u8 skipWrite; // Makes sure the flags dont written (MAC Flag hack) }; struct microFlagCycles { diff --git a/pcsx2/x86/microVU_Upper.inl b/pcsx2/x86/microVU_Upper.inl index 0479739965..7b323d663b 100644 --- a/pcsx2/x86/microVU_Upper.inl +++ b/pcsx2/x86/microVU_Upper.inl @@ -31,7 +31,7 @@ static void mVUupdateFlags(mV, const xmm& reg, const xmm& regT1in = xEmptyReg, c static const u16 flipMask[16] = {0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15}; //SysPrintf("Status = %d; Mac = %d\n", sFLAG.doFlag, mFLAG.doFlag); - if ((!sFLAG.doFlag && !mFLAG.doFlag) || sFLAG.skipWrite == 1) { return; } + if (!sFLAG.doFlag && !mFLAG.doFlag) { return; } const xmm& regT1 = regT1b ? mVU.regAlloc->allocReg() : regT1in;