mirror of https://github.com/PCSX2/pcsx2.git
Fixed a bug in the cpu mhz detection introduced in the prev revision, and improved the algo to be much quicker and generally more accurate than before (and with luck AMDs will agree!)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1087 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
41079415fa
commit
e81fbc728d
|
@ -182,49 +182,39 @@ static char* bool_to_char( bool testcond )
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
s64 CPUSpeedHz( unsigned int time )
|
s64 CPUSpeedHz( int time )
|
||||||
{
|
{
|
||||||
s64 timeStart,
|
int timeStart,
|
||||||
timeStop;
|
timeStop;
|
||||||
s64 startTick,
|
s64 startTick,
|
||||||
endTick;
|
endTick;
|
||||||
s64 overhead;
|
|
||||||
|
|
||||||
if( ! cpucaps.hasTimeStampCounter )
|
if( ! cpucaps.hasTimeStampCounter )
|
||||||
{
|
{
|
||||||
return 0; //check if function is supported
|
return 0; //check if function is supported
|
||||||
}
|
}
|
||||||
|
|
||||||
overhead = GetCPUTick() - GetCPUTick();
|
// Align the cpu execution to a timeGetTime boundary.
|
||||||
|
// Without this the result could be skewed by up to several milliseconds.
|
||||||
|
|
||||||
timeStart = timeGetTime( );
|
do { timeStart = timeGetTime( );
|
||||||
while( timeGetTime( ) == timeStart )
|
} while( timeGetTime( ) == timeStart );
|
||||||
{
|
|
||||||
timeStart = timeGetTime( );
|
|
||||||
}
|
|
||||||
|
|
||||||
for(;;)
|
do
|
||||||
{
|
{
|
||||||
timeStop = timeGetTime( );
|
timeStop = timeGetTime( );
|
||||||
if ( ( timeStop - timeStart ) > 1 )
|
|
||||||
{
|
|
||||||
startTick = GetCPUTick( );
|
startTick = GetCPUTick( );
|
||||||
break;
|
} while( ( timeStop - timeStart ) < 1 );
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
timeStart = timeStop;
|
timeStart = timeStop;
|
||||||
for(;;)
|
do
|
||||||
{
|
{
|
||||||
timeStop = timeGetTime();
|
timeStop = timeGetTime();
|
||||||
if ( ( timeStop - timeStart ) > time )
|
|
||||||
{
|
|
||||||
endTick = GetCPUTick();
|
endTick = GetCPUTick();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
while( ( timeStop - timeStart ) < time );
|
||||||
|
|
||||||
return (s64)( ( endTick - startTick ) + ( overhead ) );
|
return (s64)( endTick - startTick );
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
|
@ -377,7 +367,7 @@ void cpudetectInit()
|
||||||
cpucaps.hasStreamingSIMD4ExtensionsA = ( cpuinfo.x86EFlags2 >> 6 ) & 1; //INSERTQ / EXTRQ / MOVNT
|
cpucaps.hasStreamingSIMD4ExtensionsA = ( cpuinfo.x86EFlags2 >> 6 ) & 1; //INSERTQ / EXTRQ / MOVNT
|
||||||
|
|
||||||
|
|
||||||
cpuinfo.cpuspeed = (u32)(CPUSpeedHz( 600 ) / 1000000);
|
cpuinfo.cpuspeed = (u32)(CPUSpeedHz( 400 ) / 400000 );
|
||||||
|
|
||||||
// --> SSE3 / SSSE3 / SSE4.1 / SSE 4.2 detection <--
|
// --> SSE3 / SSSE3 / SSE4.1 / SSE 4.2 detection <--
|
||||||
|
|
||||||
|
@ -416,26 +406,26 @@ void cpudetectInit()
|
||||||
// We take the instruction test result over cpuid since (in theory) it should be a
|
// We take the instruction test result over cpuid since (in theory) it should be a
|
||||||
// more reliable gauge of the cpu's actual ability.
|
// more reliable gauge of the cpu's actual ability.
|
||||||
|
|
||||||
if( sse3_result != cpucaps.hasStreamingSIMD3Extensions )
|
if( sse3_result != !!cpucaps.hasStreamingSIMD3Extensions )
|
||||||
{
|
{
|
||||||
Console::Notice( "SSE3 Detection Inconsistency: cpuid=%s, test_result=%s",
|
Console::Notice( "SSE3 Detection Inconsistency: cpuid=%s, test_result=%s",
|
||||||
params bool_to_char( cpucaps.hasStreamingSIMD3Extensions ), bool_to_char( sse3_result ) );
|
params bool_to_char( !!cpucaps.hasStreamingSIMD3Extensions ), bool_to_char( sse3_result ) );
|
||||||
|
|
||||||
cpucaps.hasStreamingSIMD3Extensions = sse3_result;
|
cpucaps.hasStreamingSIMD3Extensions = sse3_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ssse3_result != cpucaps.hasSupplementalStreamingSIMD3Extensions )
|
if( ssse3_result != !!cpucaps.hasSupplementalStreamingSIMD3Extensions )
|
||||||
{
|
{
|
||||||
Console::Notice( "SSSE3 Detection Inconsistency: cpuid=%s, test_result=%s",
|
Console::Notice( "SSSE3 Detection Inconsistency: cpuid=%s, test_result=%s",
|
||||||
params bool_to_char( cpucaps.hasSupplementalStreamingSIMD3Extensions ), bool_to_char( ssse3_result ) );
|
params bool_to_char( !!cpucaps.hasSupplementalStreamingSIMD3Extensions ), bool_to_char( ssse3_result ) );
|
||||||
|
|
||||||
cpucaps.hasSupplementalStreamingSIMD3Extensions = ssse3_result;
|
cpucaps.hasSupplementalStreamingSIMD3Extensions = ssse3_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( sse41_result != cpucaps.hasStreamingSIMD4Extensions )
|
if( sse41_result != !!cpucaps.hasStreamingSIMD4Extensions )
|
||||||
{
|
{
|
||||||
Console::Notice( "SSE4 Detection Inconsistency: cpuid=%s, test_result=%s",
|
Console::Notice( "SSE4 Detection Inconsistency: cpuid=%s, test_result=%s",
|
||||||
params bool_to_char( cpucaps.hasStreamingSIMD4Extensions ), bool_to_char( sse41_result ) );
|
params bool_to_char( !!cpucaps.hasStreamingSIMD4Extensions ), bool_to_char( sse41_result ) );
|
||||||
|
|
||||||
cpucaps.hasStreamingSIMD4Extensions = sse41_result;
|
cpucaps.hasStreamingSIMD4Extensions = sse41_result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue