Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10273 from Pokechu22/fifoplayer-efb-clear-wait
FifoPlayer: Wait after clearing the screen
  • Loading branch information
JMC47 committed Dec 27, 2021
2 parents 6641157 + 86f2b39 commit 1f1e78e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
31 changes: 21 additions & 10 deletions Source/Core/Core/FifoPlayer/FifoPlayer.cpp
Expand Up @@ -214,6 +214,9 @@ class FifoPlayer::CPUCore final : public CPUCoreBase
void Init() override
{
IsPlayingBackFifologWithBrokenEFBCopies = m_parent->m_File->HasBrokenEFBCopies();
// Without this call, we deadlock in initialization in dual core, as the FIFO is disabled and
// thus ClearEfb()'s call to WaitForGPUInactive() never returns
CPU::EnableStepping(false);

m_parent->m_CurrentFrame = m_parent->m_FrameRangeStart;
m_parent->LoadMemory();
Expand Down Expand Up @@ -422,13 +425,7 @@ void FifoPlayer::WriteFrame(const FifoFrameInfo& frame, const AnalyzedFrameInfo&
}

FlushWGP();

// Sleep while the GPU is active
while (!IsIdleSet() && CPU::GetState() != CPU::State::PowerDown)
{
CoreTiming::Idle();
CoreTiming::Advance();
}
WaitForGPUInactive();
}

void FifoPlayer::WriteFramePart(const FramePart& part, u32* next_mem_update,
Expand Down Expand Up @@ -571,18 +568,18 @@ void FifoPlayer::ClearEfb()
// Trigger a bogus EFB copy to clear the screen
// The target address is 0, and there shouldn't be anything there,
// but even if there is it should be loaded in by LoadTextureMemory afterwards
X10Y10 tl;
X10Y10 tl = bpmem.copyTexSrcXY;
tl.x = 0;
tl.y = 0;
LoadBPReg(BPMEM_EFB_TL, tl.hex);
X10Y10 wh;
X10Y10 wh = bpmem.copyTexSrcWH;
wh.x = EFB_WIDTH - 1;
wh.y = EFB_HEIGHT - 1;
LoadBPReg(BPMEM_EFB_WH, wh.hex);
LoadBPReg(BPMEM_MIPMAP_STRIDE, 0x140);
// The clear color and Z value have already been loaded via LoadRegisters()
LoadBPReg(BPMEM_EFB_ADDR, 0);
UPE_Copy copy;
UPE_Copy copy = bpmem.triggerEFBCopy;
copy.clamp_top = false;
copy.clamp_bottom = false;
copy.yuv = false;
Expand All @@ -603,6 +600,10 @@ void FifoPlayer::ClearEfb()
LoadBPReg(BPMEM_EFB_WH, m_File->GetBPMem()[BPMEM_EFB_WH]);
LoadBPReg(BPMEM_MIPMAP_STRIDE, m_File->GetBPMem()[BPMEM_MIPMAP_STRIDE]);
LoadBPReg(BPMEM_EFB_ADDR, m_File->GetBPMem()[BPMEM_EFB_ADDR]);
// Wait for the EFB copy to finish. That way, the EFB copy (which will be performed at a later
// time) won't clobber any memory updates.
FlushWGP();
WaitForGPUInactive();
}

void FifoPlayer::LoadMemory()
Expand Down Expand Up @@ -695,6 +696,16 @@ void FifoPlayer::FlushWGP()
GPFifo::ResetGatherPipe();
}

void FifoPlayer::WaitForGPUInactive()
{
// Sleep while the GPU is active
while (!IsIdleSet() && CPU::GetState() != CPU::State::PowerDown)
{
CoreTiming::Idle();
CoreTiming::Advance();
}
}

void FifoPlayer::LoadBPReg(u8 reg, u32 value)
{
GPFifo::Write8(0x61); // load BP reg
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/FifoPlayer/FifoPlayer.h
Expand Up @@ -159,6 +159,7 @@ class FifoPlayer
void WritePI(u32 address, u32 value);

void FlushWGP();
void WaitForGPUInactive();

void LoadBPReg(u8 reg, u32 value);
void LoadCPReg(u8 reg, u32 value);
Expand Down

0 comments on commit 1f1e78e

Please sign in to comment.