From 87dc885a4a8e5306cc54a25f06af911688e02545 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Sun, 30 Aug 2020 17:15:18 +0100 Subject: [PATCH] VU: Improved EE Cycle Skipping hack to work better with the new VU0 sync changes --- pcsx2/MTVU.cpp | 1 + pcsx2/x86/microVU_Execute.inl | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pcsx2/MTVU.cpp b/pcsx2/MTVU.cpp index 42d8e51c67..72a70cd1fc 100644 --- a/pcsx2/MTVU.cpp +++ b/pcsx2/MTVU.cpp @@ -330,6 +330,7 @@ void VU_Thread::ExecuteVU(u32 vu_addr, u32 vif_top, u32 vif_itop) KickStart(); u32 cycles = std::min(Get_vuCycles(), 3000u); cpuRegs.cycle += cycles * EmuConfig.Speedhacks.EECycleSkip; + VU0.cycle += cycles * EmuConfig.Speedhacks.EECycleSkip; } void VU_Thread::VifUnpack(vifStruct& _vif, VIFregisters& _vifRegs, u8* data, u32 size) diff --git a/pcsx2/x86/microVU_Execute.inl b/pcsx2/x86/microVU_Execute.inl index b4d0d56139..d174596471 100644 --- a/pcsx2/x86/microVU_Execute.inl +++ b/pcsx2/x86/microVU_Execute.inl @@ -167,7 +167,18 @@ _mVUt void mVUcleanUp() { mVU.regs().cycle += mVU.cycles; if (!vuIndex || !THREAD_VU1) { - cpuRegs.cycle += std::min(mVU.cycles, 3000u) * EmuConfig.Speedhacks.EECycleSkip; + u32 cycles_passed = std::min(mVU.cycles, 3000u) * EmuConfig.Speedhacks.EECycleSkip; + if (cycles_passed > 0) { + s32 vu0_offset = VU0.cycle - cpuRegs.cycle; + cpuRegs.cycle += cycles_passed; + + // VU0 needs to stay in sync with the CPU otherwise things get messy + // So we need to adjust when VU1 skips cycles also + if (!vuIndex) + VU0.cycle = cpuRegs.cycle + vu0_offset; + else + VU0.cycle += cycles_passed; + } } mVU.profiler.Print(); //static int ax = 0; ax++;