From 5b315b7bb4a30044af66c1a34e0d686aaa7692d0 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Tue, 3 Jan 2017 17:10:22 +1000 Subject: [PATCH] FifoPlayer: Reload initial state when looping back to first frame This should ensure that when playing with loop enabled, the first frame is in the same state each time. There is potentially still issues when the start frame is set to something other than zero, but I'm not sure how we could work around this without capturing the entire state on each frame. --- Source/Core/Core/FifoPlayer/FifoPlayer.cpp | 12 ++++++++++-- Source/Core/Core/FifoPlayer/FifoPlayer.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp index e8dbad863d..346743ed4a 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp @@ -122,7 +122,12 @@ int FifoPlayer::AdvanceFrame() if (m_FrameRangeStart >= m_FrameRangeEnd) return CPU::CPU_STEPPING; + // When looping, reload the contents of all the BP/CP/CF registers. + // This ensures that each time the first frame is played back, the state of the + // GPU is the same for each playback loop. m_CurrentFrame = m_FrameRangeStart; + LoadRegisters(); + FlushWGP(); } if (m_FrameWrittenCb) @@ -414,7 +419,12 @@ void FifoPlayer::LoadMemory() PowerPC::IBATUpdated(); SetupFifo(); + LoadRegisters(); + FlushWGP(); +} +void FifoPlayer::LoadRegisters() +{ const u32* regs = m_File->GetBPMem(); for (int i = 0; i < FifoDataFile::BP_MEM_SIZE; ++i) { @@ -448,8 +458,6 @@ void FifoPlayer::LoadMemory() regs = m_File->GetXFRegs(); for (int i = 0; i < FifoDataFile::XF_REGS_SIZE; ++i) LoadXFReg(i, regs[i]); - - FlushWGP(); } void FifoPlayer::WriteCP(u32 address, u16 value) diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.h b/Source/Core/Core/FifoPlayer/FifoPlayer.h index e1c285ff43..819c62dda0 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlayer.h +++ b/Source/Core/Core/FifoPlayer/FifoPlayer.h @@ -110,6 +110,7 @@ private: void SetupFifo(); void LoadMemory(); + void LoadRegisters(); void WriteCP(u32 address, u16 value); void WritePI(u32 address, u32 value);