2009-07-03 00:49:40 +00:00
|
|
|
/* Cpudetection lib
|
2010-05-03 14:08:02 +00:00
|
|
|
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
2009-10-05 11:05:11 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
2009-07-03 00:49:40 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
2009-07-03 20:12:33 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
2009-07-03 00:49:40 +00:00
|
|
|
*/
|
2009-10-05 11:05:11 +00:00
|
|
|
|
2009-07-03 00:49:40 +00:00
|
|
|
#include "PrecompiledHeader.h"
|
2009-11-16 13:54:32 +00:00
|
|
|
#include "cpudetect_internal.h"
|
2009-10-07 19:20:11 +00:00
|
|
|
#include "internal.h"
|
|
|
|
|
2009-07-03 00:49:40 +00:00
|
|
|
using namespace x86Emitter;
|
|
|
|
|
2009-10-05 02:15:49 +00:00
|
|
|
__aligned16 x86CPU_INFO x86caps;
|
2009-07-03 00:49:40 +00:00
|
|
|
|
|
|
|
#ifdef __LINUX__
|
|
|
|
# include <sys/time.h>
|
|
|
|
# include <errno.h>
|
|
|
|
#endif
|
|
|
|
|
2009-11-16 14:08:53 +00:00
|
|
|
static const char* bool_to_char( bool testcond )
|
2009-07-03 00:49:40 +00:00
|
|
|
{
|
2009-11-16 13:54:32 +00:00
|
|
|
return testcond ? "true" : "false";
|
2009-07-03 00:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static s64 CPUSpeedHz( u64 time )
|
|
|
|
{
|
|
|
|
u64 timeStart, timeStop;
|
2009-12-20 01:28:23 +00:00
|
|
|
s64 startCycle, endCycle;
|
2009-07-03 00:49:40 +00:00
|
|
|
|
2009-07-29 14:00:00 +00:00
|
|
|
if( ! x86caps.hasTimeStampCounter )
|
2009-11-16 13:54:32 +00:00
|
|
|
return 0;
|
2009-07-03 00:49:40 +00:00
|
|
|
|
2009-11-16 13:54:32 +00:00
|
|
|
SingleCoreAffinity affinity_lock;
|
2009-07-03 00:49:40 +00:00
|
|
|
|
|
|
|
// Align the cpu execution to a cpuTick boundary.
|
|
|
|
|
|
|
|
do { timeStart = GetCPUTicks();
|
|
|
|
} while( GetCPUTicks() == timeStart );
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2009-11-16 13:54:32 +00:00
|
|
|
timeStop = GetCPUTicks();
|
2009-12-20 01:28:23 +00:00
|
|
|
startCycle = __rdtsc();
|
2009-07-03 00:49:40 +00:00
|
|
|
} while( ( timeStop - timeStart ) == 0 );
|
|
|
|
|
|
|
|
timeStart = timeStop;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
timeStop = GetCPUTicks();
|
2009-12-20 01:28:23 +00:00
|
|
|
endCycle = __rdtsc();
|
2009-07-03 00:49:40 +00:00
|
|
|
}
|
|
|
|
while( ( timeStop - timeStart ) < time );
|
|
|
|
|
2009-12-20 01:28:23 +00:00
|
|
|
s64 cycleCount = endCycle - startCycle;
|
|
|
|
s64 timeCount = timeStop - timeStart;
|
|
|
|
s64 overrun = timeCount - time;
|
|
|
|
if( !overrun ) return cycleCount;
|
|
|
|
|
|
|
|
// interference could cause us to overshoot the target time, compensate:
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-12-20 01:28:23 +00:00
|
|
|
double cyclesPerTick = (double)cycleCount / (double)timeCount;
|
|
|
|
double newCycleCount = (double)cycleCount - (cyclesPerTick * overrun);
|
|
|
|
|
|
|
|
return (s64)newCycleCount;
|
2009-07-03 00:49:40 +00:00
|
|
|
}
|
|
|
|
|
2009-12-08 02:38:13 +00:00
|
|
|
// Recompiled code buffer for SSE and MXCSR feature testing.
|
|
|
|
static __pagealigned u8 recSSE[__pagesize];
|
|
|
|
|
|
|
|
// Warning! We've had problems with the MXCSR detection code causing stack corruption in
|
|
|
|
// MSVC PGO builds. The problem was fixed when I moved the MXCSR code to this function, and
|
|
|
|
// moved the recSSE[] array to a global static (it was local to cpudetectInit). Commented
|
|
|
|
// here in case the nutty crash ever re-surfaces. >_<
|
|
|
|
|
|
|
|
void EstablishMXCSRmask()
|
|
|
|
{
|
|
|
|
if( !x86caps.hasStreamingSIMDExtensions ) return;
|
|
|
|
|
|
|
|
MXCSR_Mask.bitmask = 0xFFBF; // MMX/SSE default
|
|
|
|
|
|
|
|
if( x86caps.hasStreamingSIMD2Extensions )
|
|
|
|
{
|
|
|
|
// This is generally safe assumption, but FXSAVE is the "correct" way to
|
|
|
|
// detect MXCSR masking features of the cpu, so we use it's result below
|
|
|
|
// and override this.
|
|
|
|
|
|
|
|
MXCSR_Mask.bitmask = 0xFFFF; // SSE2 features added
|
|
|
|
}
|
|
|
|
|
2009-12-24 22:22:34 +00:00
|
|
|
if( !CanEmitShit() ) return;
|
|
|
|
|
2009-12-08 02:38:13 +00:00
|
|
|
// the fxsave buffer must be 16-byte aligned to avoid GPF. I just save it to an
|
|
|
|
// unused portion of recSSE, since it has plenty of room to spare.
|
|
|
|
|
|
|
|
xSetPtr( recSSE );
|
|
|
|
xFXSAVE( recSSE + 1024 );
|
|
|
|
xRET();
|
|
|
|
|
|
|
|
CallAddress( recSSE );
|
|
|
|
|
|
|
|
u32 result = (u32&)recSSE[1024+28]; // bytes 28->32 are the MXCSR_Mask.
|
|
|
|
if( result != 0 )
|
|
|
|
MXCSR_Mask.bitmask = result;
|
|
|
|
}
|
|
|
|
|
2009-07-03 20:12:33 +00:00
|
|
|
void cpudetectInit()
|
2009-07-03 00:49:40 +00:00
|
|
|
{
|
2009-12-08 02:38:13 +00:00
|
|
|
s32 regs[ 4 ];
|
2009-12-07 22:43:16 +00:00
|
|
|
u32 cmds;
|
|
|
|
//AMD 64 STUFF
|
|
|
|
u32 x86_64_8BITBRANDID;
|
|
|
|
u32 x86_64_12BITBRANDID;
|
|
|
|
|
|
|
|
memzero( x86caps.VendorName );
|
|
|
|
x86caps.FamilyID = 0;
|
|
|
|
x86caps.Model = 0;
|
|
|
|
x86caps.TypeID = 0;
|
|
|
|
x86caps.StepID = 0;
|
|
|
|
x86caps.Flags = 0;
|
|
|
|
x86caps.EFlags = 0;
|
|
|
|
|
2009-12-08 02:38:13 +00:00
|
|
|
__cpuid( regs, 0 );
|
2009-12-07 22:43:16 +00:00
|
|
|
|
|
|
|
cmds = regs[ 0 ];
|
|
|
|
((u32*)x86caps.VendorName)[ 0 ] = regs[ 1 ];
|
|
|
|
((u32*)x86caps.VendorName)[ 1 ] = regs[ 3 ];
|
|
|
|
((u32*)x86caps.VendorName)[ 2 ] = regs[ 2 ];
|
|
|
|
|
|
|
|
u32 LogicalCoresPerPhysicalCPU = 0;
|
|
|
|
u32 PhysicalCoresPerPhysicalCPU = 1;
|
|
|
|
|
|
|
|
if ( cmds >= 0x00000001 )
|
|
|
|
{
|
2009-12-08 02:38:13 +00:00
|
|
|
__cpuid( regs, 0x00000001 );
|
2009-12-07 22:43:16 +00:00
|
|
|
|
|
|
|
x86caps.StepID = regs[ 0 ] & 0xf;
|
|
|
|
x86caps.Model = (regs[ 0 ] >> 4) & 0xf;
|
|
|
|
x86caps.FamilyID = (regs[ 0 ] >> 8) & 0xf;
|
|
|
|
x86caps.TypeID = (regs[ 0 ] >> 12) & 0x3;
|
|
|
|
x86_64_8BITBRANDID = regs[ 1 ] & 0xff;
|
|
|
|
x86caps.Flags = regs[ 3 ];
|
|
|
|
x86caps.Flags2 = regs[ 2 ];
|
|
|
|
|
|
|
|
LogicalCoresPerPhysicalCPU = ( regs[1] >> 16 ) & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
// detect multicore for Intel cpu
|
|
|
|
|
|
|
|
if ((cmds >= 0x00000004) && !strcmp("GenuineIntel",x86caps.VendorName))
|
|
|
|
{
|
2009-12-08 02:38:13 +00:00
|
|
|
__cpuid( regs, 0x00000004 );
|
2009-12-07 22:43:16 +00:00
|
|
|
PhysicalCoresPerPhysicalCPU += ( regs[0] >> 26) & 0x3f;
|
|
|
|
}
|
|
|
|
|
2009-12-08 02:38:13 +00:00
|
|
|
__cpuid( regs, 0x80000000 );
|
2009-12-07 22:43:16 +00:00
|
|
|
cmds = regs[ 0 ];
|
|
|
|
if ( cmds >= 0x80000001 )
|
|
|
|
{
|
2009-12-08 02:38:13 +00:00
|
|
|
__cpuid( regs, 0x80000001 );
|
2009-12-07 22:43:16 +00:00
|
|
|
|
|
|
|
x86_64_12BITBRANDID = regs[1] & 0xfff;
|
|
|
|
x86caps.EFlags2 = regs[ 2 ];
|
|
|
|
x86caps.EFlags = regs[ 3 ];
|
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-12-07 22:43:16 +00:00
|
|
|
// detect multicore for AMD cpu
|
|
|
|
|
|
|
|
if ((cmds >= 0x80000008) && !strcmp("AuthenticAMD",x86caps.VendorName))
|
|
|
|
{
|
2009-12-08 02:38:13 +00:00
|
|
|
__cpuid( regs, 0x80000008 );
|
2009-12-07 22:43:16 +00:00
|
|
|
PhysicalCoresPerPhysicalCPU += ( regs[2] ) & 0xff;
|
|
|
|
}
|
2009-07-03 20:12:33 +00:00
|
|
|
|
2009-07-29 14:00:00 +00:00
|
|
|
switch(x86caps.TypeID)
|
2009-07-03 00:49:40 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2009-07-29 14:00:00 +00:00
|
|
|
strcpy( x86caps.TypeName, "Standard OEM");
|
2009-07-03 00:49:40 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2009-07-29 14:00:00 +00:00
|
|
|
strcpy( x86caps.TypeName, "Overdrive");
|
2009-07-03 00:49:40 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2009-07-29 14:00:00 +00:00
|
|
|
strcpy( x86caps.TypeName, "Dual");
|
2009-07-03 00:49:40 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2009-07-29 14:00:00 +00:00
|
|
|
strcpy( x86caps.TypeName, "Reserved");
|
2009-07-03 00:49:40 +00:00
|
|
|
break;
|
|
|
|
default:
|
2009-07-29 14:00:00 +00:00
|
|
|
strcpy( x86caps.TypeName, "Unknown");
|
2009-07-03 00:49:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-11-02 07:00:59 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
// vendor identification, currently unneeded.
|
|
|
|
// It's really not recommended that we base much (if anything) on CPU vendor names.
|
|
|
|
// But the code is left in as an ifdef, for possible future reference.
|
|
|
|
|
|
|
|
int cputype=0; // Cpu type
|
|
|
|
static const char* Vendor_Intel = "GenuineIntel";
|
|
|
|
static const char* Vendor_AMD = "AuthenticAMD";
|
|
|
|
|
|
|
|
if( memcmp( x86caps.VendorName, Vendor_Intel, 12 ) == 0 ) { cputype = 0; } else
|
|
|
|
if( memcmp( x86caps.VendorName, Vendor_AMD, 12 ) == 0 ) { cputype = 1; }
|
|
|
|
|
|
|
|
if ( x86caps.VendorName[ 0 ] == 'G' ) { cputype = 0; }
|
|
|
|
if ( x86caps.VendorName[ 0 ] == 'A' ) { cputype = 1; }
|
|
|
|
#endif
|
2009-07-03 20:12:33 +00:00
|
|
|
|
2009-09-23 12:53:32 +00:00
|
|
|
memzero( x86caps.FamilyName );
|
2009-12-08 02:38:13 +00:00
|
|
|
__cpuid( (int*)x86caps.FamilyName, 0x80000002);
|
|
|
|
__cpuid( (int*)(x86caps.FamilyName+16), 0x80000003);
|
|
|
|
__cpuid( (int*)(x86caps.FamilyName+32), 0x80000004);
|
2009-07-03 00:49:40 +00:00
|
|
|
|
|
|
|
//capabilities
|
2009-07-29 14:00:00 +00:00
|
|
|
x86caps.hasFloatingPointUnit = ( x86caps.Flags >> 0 ) & 1;
|
|
|
|
x86caps.hasVirtual8086ModeEnhancements = ( x86caps.Flags >> 1 ) & 1;
|
|
|
|
x86caps.hasDebuggingExtensions = ( x86caps.Flags >> 2 ) & 1;
|
|
|
|
x86caps.hasPageSizeExtensions = ( x86caps.Flags >> 3 ) & 1;
|
|
|
|
x86caps.hasTimeStampCounter = ( x86caps.Flags >> 4 ) & 1;
|
|
|
|
x86caps.hasModelSpecificRegisters = ( x86caps.Flags >> 5 ) & 1;
|
|
|
|
x86caps.hasPhysicalAddressExtension = ( x86caps.Flags >> 6 ) & 1;
|
|
|
|
x86caps.hasMachineCheckArchitecture = ( x86caps.Flags >> 7 ) & 1;
|
|
|
|
x86caps.hasCOMPXCHG8BInstruction = ( x86caps.Flags >> 8 ) & 1;
|
|
|
|
x86caps.hasAdvancedProgrammableInterruptController = ( x86caps.Flags >> 9 ) & 1;
|
|
|
|
x86caps.hasSEPFastSystemCall = ( x86caps.Flags >> 11 ) & 1;
|
|
|
|
x86caps.hasMemoryTypeRangeRegisters = ( x86caps.Flags >> 12 ) & 1;
|
|
|
|
x86caps.hasPTEGlobalFlag = ( x86caps.Flags >> 13 ) & 1;
|
|
|
|
x86caps.hasMachineCheckArchitecture = ( x86caps.Flags >> 14 ) & 1;
|
|
|
|
x86caps.hasConditionalMoveAndCompareInstructions = ( x86caps.Flags >> 15 ) & 1;
|
|
|
|
x86caps.hasFGPageAttributeTable = ( x86caps.Flags >> 16 ) & 1;
|
|
|
|
x86caps.has36bitPageSizeExtension = ( x86caps.Flags >> 17 ) & 1;
|
|
|
|
x86caps.hasProcessorSerialNumber = ( x86caps.Flags >> 18 ) & 1;
|
|
|
|
x86caps.hasCFLUSHInstruction = ( x86caps.Flags >> 19 ) & 1;
|
|
|
|
x86caps.hasDebugStore = ( x86caps.Flags >> 21 ) & 1;
|
|
|
|
x86caps.hasACPIThermalMonitorAndClockControl = ( x86caps.Flags >> 22 ) & 1;
|
|
|
|
x86caps.hasMultimediaExtensions = ( x86caps.Flags >> 23 ) & 1; //mmx
|
|
|
|
x86caps.hasFastStreamingSIMDExtensionsSaveRestore = ( x86caps.Flags >> 24 ) & 1;
|
|
|
|
x86caps.hasStreamingSIMDExtensions = ( x86caps.Flags >> 25 ) & 1; //sse
|
|
|
|
x86caps.hasStreamingSIMD2Extensions = ( x86caps.Flags >> 26 ) & 1; //sse2
|
|
|
|
x86caps.hasSelfSnoop = ( x86caps.Flags >> 27 ) & 1;
|
|
|
|
x86caps.hasMultiThreading = ( x86caps.Flags >> 28 ) & 1;
|
|
|
|
x86caps.hasThermalMonitor = ( x86caps.Flags >> 29 ) & 1;
|
|
|
|
x86caps.hasIntel64BitArchitecture = ( x86caps.Flags >> 30 ) & 1;
|
2009-07-03 20:12:33 +00:00
|
|
|
|
2009-07-03 00:49:40 +00:00
|
|
|
//that is only for AMDs
|
2009-07-29 14:00:00 +00:00
|
|
|
x86caps.hasMultimediaExtensionsExt = ( x86caps.EFlags >> 22 ) & 1; //mmx2
|
|
|
|
x86caps.hasAMD64BitArchitecture = ( x86caps.EFlags >> 29 ) & 1; //64bit cpu
|
|
|
|
x86caps.has3DNOWInstructionExtensionsExt = ( x86caps.EFlags >> 30 ) & 1; //3dnow+
|
|
|
|
x86caps.has3DNOWInstructionExtensions = ( x86caps.EFlags >> 31 ) & 1; //3dnow
|
|
|
|
x86caps.hasStreamingSIMD4ExtensionsA = ( x86caps.EFlags2 >> 6 ) & 1; //INSERTQ / EXTRQ / MOVNT
|
2009-07-03 00:49:40 +00:00
|
|
|
|
|
|
|
InitCPUTicks();
|
|
|
|
u64 span = GetTickFrequency();
|
|
|
|
|
|
|
|
if( (span % 1000) < 400 ) // helps minimize rounding errors
|
2009-07-29 14:00:00 +00:00
|
|
|
x86caps.Speed = (u32)( CPUSpeedHz( span / 1000 ) / 1000 );
|
2009-07-03 00:49:40 +00:00
|
|
|
else
|
2009-07-29 14:00:00 +00:00
|
|
|
x86caps.Speed = (u32)( CPUSpeedHz( span / 500 ) / 2000 );
|
2009-07-03 00:49:40 +00:00
|
|
|
|
|
|
|
// --> SSE3 / SSSE3 / SSE4.1 / SSE 4.2 detection <--
|
|
|
|
|
2009-07-29 14:00:00 +00:00
|
|
|
x86caps.hasStreamingSIMD3Extensions = ( x86caps.Flags2 >> 0 ) & 1; //sse3
|
|
|
|
x86caps.hasSupplementalStreamingSIMD3Extensions = ( x86caps.Flags2 >> 9 ) & 1; //ssse3
|
|
|
|
x86caps.hasStreamingSIMD4Extensions = ( x86caps.Flags2 >> 19 ) & 1; //sse4.1
|
|
|
|
x86caps.hasStreamingSIMD4Extensions2 = ( x86caps.Flags2 >> 20 ) & 1; //sse4.2
|
2009-07-03 00:49:40 +00:00
|
|
|
|
2009-11-02 07:00:59 +00:00
|
|
|
HostSys::MemProtectStatic( recSSE, Protect_ReadWrite, true );
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-07-03 00:49:40 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
2009-11-16 13:54:32 +00:00
|
|
|
// SIMD Instruction Support Detection (Second Pass)
|
2009-07-03 00:49:40 +00:00
|
|
|
//
|
|
|
|
|
2009-11-16 13:54:32 +00:00
|
|
|
if( CanTestInstructionSets() )
|
2009-07-03 00:49:40 +00:00
|
|
|
{
|
|
|
|
xSetPtr( recSSE );
|
2009-12-07 22:43:16 +00:00
|
|
|
xMOVDQU( ptr[ecx], xmm1 );
|
2009-07-03 00:49:40 +00:00
|
|
|
xMOVSLDUP( xmm1, xmm0 );
|
2009-12-07 22:43:16 +00:00
|
|
|
xMOVDQU( xmm1, ptr[ecx] );
|
2009-07-03 00:49:40 +00:00
|
|
|
xRET();
|
|
|
|
|
|
|
|
u8* funcSSSE3 = xGetPtr();
|
2009-12-07 22:43:16 +00:00
|
|
|
xMOVDQU( ptr[ecx], xmm1 );
|
|
|
|
xPABS.W( xmm1, xmm0 );
|
|
|
|
xMOVDQU( xmm1, ptr[ecx] );
|
2009-07-03 00:49:40 +00:00
|
|
|
xRET();
|
|
|
|
|
|
|
|
u8* funcSSE41 = xGetPtr();
|
2009-12-07 22:43:16 +00:00
|
|
|
xMOVDQU( ptr[ecx], xmm1 );
|
2009-07-03 00:49:40 +00:00
|
|
|
xBLEND.VPD( xmm1, xmm0 );
|
2009-12-07 22:43:16 +00:00
|
|
|
xMOVDQU( xmm1, ptr[ecx] );
|
2009-07-03 00:49:40 +00:00
|
|
|
xRET();
|
2009-07-03 20:12:33 +00:00
|
|
|
|
2009-07-03 00:49:40 +00:00
|
|
|
bool sse3_result = _test_instruction( recSSE ); // sse3
|
|
|
|
bool ssse3_result = _test_instruction( funcSSSE3 );
|
|
|
|
bool sse41_result = _test_instruction( funcSSE41 );
|
|
|
|
|
|
|
|
// Test for and log any irregularities here.
|
|
|
|
// We take the instruction test result over cpuid since (in theory) it should be a
|
|
|
|
// more reliable gauge of the cpu's actual ability. But since a difference in bit
|
|
|
|
// and actual ability may represent a cmos/bios problem, we report it to the user.
|
|
|
|
|
2009-07-29 14:00:00 +00:00
|
|
|
if( sse3_result != !!x86caps.hasStreamingSIMD3Extensions )
|
2009-07-03 00:49:40 +00:00
|
|
|
{
|
2009-10-29 13:32:40 +00:00
|
|
|
Console.Warning( "SSE3 Detection Inconsistency: cpuid=%s, test_result=%s",
|
2009-09-08 05:37:40 +00:00
|
|
|
bool_to_char( !!x86caps.hasStreamingSIMD3Extensions ), bool_to_char( sse3_result ) );
|
2009-07-03 20:12:33 +00:00
|
|
|
|
2009-07-29 14:00:00 +00:00
|
|
|
x86caps.hasStreamingSIMD3Extensions = sse3_result;
|
2009-07-03 00:49:40 +00:00
|
|
|
}
|
|
|
|
|
2009-07-29 14:00:00 +00:00
|
|
|
if( ssse3_result != !!x86caps.hasSupplementalStreamingSIMD3Extensions )
|
2009-07-03 00:49:40 +00:00
|
|
|
{
|
2009-10-29 13:32:40 +00:00
|
|
|
Console.Warning( "SSSE3 Detection Inconsistency: cpuid=%s, test_result=%s",
|
2009-09-08 05:37:40 +00:00
|
|
|
bool_to_char( !!x86caps.hasSupplementalStreamingSIMD3Extensions ), bool_to_char( ssse3_result ) );
|
2009-07-03 00:49:40 +00:00
|
|
|
|
2009-07-29 14:00:00 +00:00
|
|
|
x86caps.hasSupplementalStreamingSIMD3Extensions = ssse3_result;
|
2009-07-03 00:49:40 +00:00
|
|
|
}
|
|
|
|
|
2009-07-29 14:00:00 +00:00
|
|
|
if( sse41_result != !!x86caps.hasStreamingSIMD4Extensions )
|
2009-07-03 00:49:40 +00:00
|
|
|
{
|
2009-10-29 13:32:40 +00:00
|
|
|
Console.Warning( "SSE4 Detection Inconsistency: cpuid=%s, test_result=%s",
|
2009-09-08 05:37:40 +00:00
|
|
|
bool_to_char( !!x86caps.hasStreamingSIMD4Extensions ), bool_to_char( sse41_result ) );
|
2009-07-03 00:49:40 +00:00
|
|
|
|
2009-07-29 14:00:00 +00:00
|
|
|
x86caps.hasStreamingSIMD4Extensions = sse41_result;
|
2009-07-03 00:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2009-11-02 16:26:35 +00:00
|
|
|
|
2009-11-02 07:00:59 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Establish MXCSR Mask...
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-12-08 02:38:13 +00:00
|
|
|
// HACK! For some reason the "proper" fxsave code below causes some kind of stackframe
|
|
|
|
// corruption in MSVC PGO builds. The culprit appears to be execution of FXSAVE itself,
|
|
|
|
// since only by not executing FXSAVE is the crash avoided. (note: crash happens later
|
|
|
|
// in SysDetect). Using a #pragma optimize("",off) also fixes it.
|
|
|
|
//
|
|
|
|
// Workaround: We assume the MXCSR mask from the settings of the CPU. SSE2 CPUs have
|
|
|
|
// a full mask available. SSE and earlier CPUs have a few bits reserved (must be zero).
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-12-08 02:38:13 +00:00
|
|
|
EstablishMXCSRmask();
|
2009-07-03 00:49:40 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Core Counting!
|
|
|
|
|
2009-07-29 14:00:00 +00:00
|
|
|
if( !x86caps.hasMultiThreading || LogicalCoresPerPhysicalCPU == 0 )
|
2009-07-03 00:49:40 +00:00
|
|
|
LogicalCoresPerPhysicalCPU = 1;
|
|
|
|
|
2009-07-29 14:00:00 +00:00
|
|
|
// This will assign values into x86caps.LogicalCores and PhysicalCores
|
2009-11-16 13:54:32 +00:00
|
|
|
CountLogicalCores( LogicalCoresPerPhysicalCPU, PhysicalCoresPerPhysicalCPU );
|
2009-07-03 00:49:40 +00:00
|
|
|
}
|
|
|
|
|