1
0
mirror of https://github.com/microsoft/DirectXMath synced 2024-09-19 14:49:54 +00:00

Add AVX2 processor support tests

This commit is contained in:
Chuck Walbourn 2016-06-18 17:07:28 -07:00
parent 55851275ba
commit 292d176ff4

View File

@ -1983,15 +1983,25 @@ inline bool XMVerifyCPUSupport()
#if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
int CPUInfo[4] = { -1 };
__cpuid(CPUInfo, 0);
#ifdef __AVX2__
if (CPUInfo[0] < 7)
return false;
#else
if (CPUInfo[0] < 1)
return false;
#endif
__cpuid(CPUInfo, 1);
#ifdef _XM_F16C_INTRINSICS_
#ifdef __AVX2__
// The compiler can emit FMA3 instructions even without explicit intrinsics use
if ((CPUInfo[2] & 0x38081001) != 0x38081001)
return false; // No F16C/AVX/OSXSAVE/SSE4.1/FMA3/SSE3 support
#elif defined(_XM_F16C_INTRINSICS_)
if ((CPUInfo[2] & 0x38080001) != 0x38080001)
return false; // No F16C/AVX/OSXSAVE/SSE4.1/SSE3 support
#elif defined(_XM_AVX_INTRINSICS_)
#elif defined(__AVX__) || defined(_XM_AVX_INTRINSICS_)
if ((CPUInfo[2] & 0x18080001) != 0x18080001)
return false; // No AVX/OSXSAVE/SSE4.1/SSE3 support
#elif defined(_XM_SSE4_INTRINSICS_)
@ -2006,6 +2016,12 @@ inline bool XMVerifyCPUSupport()
if ((CPUInfo[3] & 0x6000000) != 0x6000000)
return false; // No SSE2/SSE support
#ifdef __AVX2__
__cpuidex(CPUInfo, 7, 0);
if (!(CPUInfo[1] & 0x20))
return false; // No AVX2 support
#endif
return true;
#elif defined(_XM_ARM_NEON_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_)
// ARM-NEON support is required for the Windows on ARM platform