MTGS: Only pause when the queue is empty

Prevents other threads from freezing waiting for the queue to empty when it never will
This commit is contained in:
TellowKrinkle 2021-06-06 19:15:26 -05:00 committed by refractionpcsx2
parent 0f917c24a5
commit 4116aed738
1 changed files with 5 additions and 3 deletions

View File

@ -486,9 +486,9 @@ void SysMtgsThread::ExecuteTaskInThread()
if (m_VsyncSignalListener.exchange(false)) if (m_VsyncSignalListener.exchange(false))
m_sem_Vsync.Post(); m_sem_Vsync.Post();
busy.Release(); // Do not StateCheckInThread() here
StateCheckInThread(); // Otherwise we could pause while there's still data in the queue
busy.Acquire(); // Which could make the MTVU thread wait forever for it to empty
} }
break; break;
@ -619,6 +619,8 @@ void SysMtgsThread::OnResumeInThread(bool isSuspended)
void SysMtgsThread::OnCleanupInThread() void SysMtgsThread::OnCleanupInThread()
{ {
CloseGS(); CloseGS();
// Unblock any threads in WaitGS in case MTGS gets cancelled while still processing work
m_ReadPos.store(m_WritePos.load(std::memory_order_acquire), std::memory_order_relaxed);
_parent::OnCleanupInThread(); _parent::OnCleanupInThread();
} }