Gave the frame limiter some smarts so it can sleep the EEcore a bit if there's nothing to do for a while.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2033 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-10-18 17:12:02 +00:00
parent 950c99f886
commit 54f1409090
1 changed files with 13 additions and 2 deletions

View File

@ -322,11 +322,22 @@ static __forceinline void frameLimit()
m_iStart = uExpectedEnd;
while( sDeltaTime < 0 )
// Shortcut for cases where no waiting is needed (they're running slow already,
// so don't bog 'em down with extra math...)
if( sDeltaTime >= 0 ) return;
// If we're way ahead then we can afford to sleep the thread a bit.
s32 msec = (int)((sDeltaTime*-1000) / (s64)GetTickFrequency());
if( msec > 2 ) Threading::Sleep( msec - 2 );
//
while( true )
{
Timeslice();
iEnd = GetCPUTicks();
sDeltaTime = iEnd - uExpectedEnd;
if( sDeltaTime >= 0 ) break;
Timeslice();
}
}