| 75 | }; |
| 76 | |
| 77 | static void detectCpuFeatures(Platform::SystemInfo_struct::Processor &processor) |
| 78 | { |
| 79 | S32 cpuInfo[4]; |
| 80 | __cpuid(cpuInfo, 1); |
| 81 | U32 eax = cpuInfo[0]; // eax |
| 82 | U32 edx = cpuInfo[3]; // edx |
| 83 | U32 ecx = cpuInfo[2]; // ecx |
| 84 | |
| 85 | processor.properties |= (edx & BIT_MMX) ? CPU_PROP_MMX : 0; |
| 86 | processor.properties |= (edx & BIT_SSE) ? CPU_PROP_SSE : 0; |
| 87 | processor.properties |= (edx & BIT_SSE2) ? CPU_PROP_SSE2 : 0; |
| 88 | processor.properties |= (ecx & BIT_SSE3) ? CPU_PROP_SSE3 : 0; |
| 89 | processor.properties |= (ecx & BIT_SSE3ex) ? CPU_PROP_SSE3ex : 0; |
| 90 | processor.properties |= (ecx & BIT_SSE4_1) ? CPU_PROP_SSE4_1 : 0; |
| 91 | processor.properties |= (ecx & BIT_SSE4_2) ? CPU_PROP_SSE4_2 : 0; |
| 92 | |
| 93 | // AVX detection requires that xsaverestore is supported |
| 94 | if (ecx & BIT_XSAVE_RESTORE && ecx & BIT_AVX) |
| 95 | { |
| 96 | bool supportsAVX = _xgetbv(_XCR_XFEATURE_ENABLED_MASK) & 0x6; |
| 97 | if (supportsAVX) |
| 98 | { |
| 99 | processor.properties |= CPU_PROP_AVX; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | if (processor.isMultiCore) |
| 104 | processor.properties |= CPU_PROP_MP; |
| 105 | |
| 106 | #ifdef TORQUE_CPU_X64 |
| 107 | processor.properties |= CPU_PROP_64bit; |
| 108 | #endif |
| 109 | } |
| 110 | |
| 111 | void Processor::init() |
| 112 | { |