diff --git a/pcsx2/GS.h b/pcsx2/GS.h index d5eb2a542d..a30654e3fe 100644 --- a/pcsx2/GS.h +++ b/pcsx2/GS.h @@ -174,7 +174,7 @@ protected: // Counts the number of vsync frames queued in the MTGS ringbuffer. This is used to // throttle the number of frames allowed to be rendered ahead of time for games that // run very fast and have little or no ringbuffer overhead (typically opening menus) - volatile u32 m_QueuedFrames; + volatile s32 m_QueuedFrames; // Protection lock for the frame queue counter -- needed because we can't safely // AtomicExchange from two threads. diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index b8f8b061dd..c77eb10817 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -442,6 +442,13 @@ void mtgsThreadObject::PostVsyncEnd( bool updategs ) { while( m_QueuedFrames > 8 ) { + if( m_WritePos == volatize( m_RingPos ) ) + { + // MTGS ringbuffer is empty, but we still have queued frames in the counter? Ouch! + Console::Error( "MTGS > Queued framecount mismatch = %d", params m_QueuedFrames ); + m_QueuedFrames = 0; + break; + } Sleep( 2 ); // Sleep off quite a bit of time, since we're obviously *waaay* ahead. SpinWait(); } @@ -560,7 +567,7 @@ int mtgsThreadObject::Callback() gsFrameSkip( !tag.data[1] ); m_lock_FrameQueueCounter.Lock(); - m_QueuedFrames--; + AtomicDecrement( m_QueuedFrames ); jASSUME( m_QueuedFrames >= 0 ); m_lock_FrameQueueCounter.Unlock();