From 2b47122b443318cf41ab9c4751d0c07036fac8c6 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Tue, 24 Nov 2009 16:08:59 +0000 Subject: [PATCH] MTGS sync bugfix, and remove some console spam caused by a last sectond addition to my prev commit. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2245 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/MTGS.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index e52e0e5b3e..2c6eda0592 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -320,12 +320,6 @@ void SysMtgsThread::ExecuteTaskInThread() case GS_RINGTYPE_RESTART: MTGS_LOG( "(MTGS Packet Read) ringtype=Restart" ); m_RingPos = 0; - - // It's the EEcore's job to make sure the writepos is set to 0 only AFTER the - // readpos has moved past. Otherwise the ringbuffer execution will stop on - // the readpos==writepos condition. >_< - - pxAssertDev( m_RingPos != m_WritePos, "MTGS Synchronization Error -- Premature stoppage detected on ringbuffer restart." ); continue; case GS_RINGTYPE_VSYNC: @@ -704,6 +698,7 @@ int SysMtgsThread::PrepDataPacket( GIF_PATH pathidx, const u8* srcdata, u32 size // buffer (it's a lot easier than trying to wrap the packet around the end of the // buffer). + Console.WriteLn( "MTGS > Ringbuffer Got Filled!"); RestartRingbuffer( size ); writepos = m_WritePos; } @@ -714,7 +709,7 @@ int SysMtgsThread::PrepDataPacket( GIF_PATH pathidx, const u8* srcdata, u32 size // base of the ringbuffer (otherwise the buffer will stop when the writepos is // wrapped around to zero later-on in SendDataPacket). - //Console.WriteLn( "MTGS > Perfect Fit!"); + Console.WriteLn( "MTGS > Perfect Fit!"); uint readpos = volatize(m_RingPos); if( readpos > writepos ) @@ -775,25 +770,27 @@ void SysMtgsThread::RestartRingbuffer( uint packsize ) if( m_WritePos == 0 ) return; const uint thefuture = 0; + //Console.WriteLn( Color_Magenta, "**** Ringbuffer Restart!!" ); // Always kick the MTGS into action for a ringbuffer restart. SetEvent(); uint readpos = volatize(m_RingPos); - - if( readpos > m_WritePos ) + + if( (readpos > m_WritePos) || (readpos == thefuture) ) { // We have to be careful not to leapfrog our read-position, which would happen if // it's greater than the current write position (since wrapping writepos to 0 would // be the act of skipping PAST readpos). Stall until it loops around to the // beginning of the buffer. - m_SignalRingPosition = (readpos - m_WritePos) + packsize; + m_SignalRingPosition = (readpos - m_WritePos) + packsize + 1; do { SetEvent(); AtomicExchange( m_SignalRingEnable, 1 ); m_sem_OnRingReset.WaitWithoutYield(); - } while( volatize(m_RingPos) > m_WritePos ); + readpos = volatize(m_RingPos); + } while( (readpos > m_WritePos) || (readpos == thefuture) ); } PacketTagType& tag = (PacketTagType&)RingBuffer[m_WritePos];