Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions WickedEngine/Utility/cpuinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class CPUInfo {
inline bool haveSSE3() const { return mIsSSE3; }
inline bool haveSSE41() const { return mIsSSE41; }
inline bool haveSSE42() const { return mIsSSE42; }
inline bool haveF16C() const { return mIsF16C; }
inline bool haveFMA3() const { return mIsFMA3; }
inline bool haveAVX() const { return mIsAVX; }
inline bool haveAVX2() const { return mIsAVX2; }
inline bool haveAVX512F() const { return mIsAVX512F; }
Expand All @@ -57,7 +59,9 @@ class CPUInfo {
static constexpr uint32_t SSE42_POS = 0x00100000;
static constexpr uint32_t AVX_POS = 0x10000000;
static constexpr uint32_t AVX2_POS = 0x00000020;
static constexpr uint32_t FMA3_POS = 1u << 12;
static constexpr uint32_t AVX512F_POS = 1u << 15; // Bit 16
static constexpr uint32_t F16C_POS = 1u << 29;
static constexpr uint32_t LVL_NUM = 0x000000FF;
static constexpr uint32_t LVL_TYPE = 0x0000FF00;
static constexpr uint32_t LVL_CORES = 0x0000FFFF;
Expand All @@ -77,6 +81,8 @@ class CPUInfo {
bool mIsAVX = false;
bool mIsAVX2 = false;
bool mIsAVX512F = false;
bool mIsF16C = false;
bool mIsFMA3 = false;
};

CPUInfo::CPUInfo()
Expand All @@ -97,6 +103,8 @@ CPUInfo::CPUInfo()
mIsSSE41 = cpuID1.ECX() & SSE41_POS;
mIsSSE42 = cpuID1.ECX() & SSE41_POS;
mIsAVX = cpuID1.ECX() & AVX_POS;
mIsF16C = cpuID1.ECX() & F16C_POS;
mIsFMA3 = cpuID1.ECX() & FMA3_POS;
// Get AVX2 instructions availability
CPUID cpuID7(7, 0);
mIsAVX2 = cpuID7.EBX() & AVX2_POS;
Expand Down
14 changes: 14 additions & 0 deletions WickedEngine/wiInitializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ namespace wi::initializer
{
cpustring.push_back("AVX; ");
}
if (cpuinfo.haveFMA3())
{
cpustring.push_back("FMA3; ");
}
if (cpuinfo.haveF16C())
{
cpustring.push_back("F16C; ");
}
if (cpuinfo.haveAVX2())
{
cpustring.push_back("AVX 2; ");
Expand All @@ -98,6 +106,12 @@ namespace wi::initializer
#ifdef _XM_AVX_INTRINSICS_
cpustring.push_back("AVX; ");
#endif // _XM_AVX_INTRINSICS_
#ifdef _XM_FMA3_INTRINSICS_
cpustring.push_back("FMA3; ");
#endif // _XM_FMA3_INTRINSICS_
#ifdef _XM_F16C_INTRINSICS_
cpustring.push_back("F16C; ");
#endif // _XM_F16C_INTRINSICS_
#ifdef _XM_AVX2_INTRINSICS_
cpustring.push_back("AVX 2; ");
#endif // _XM_AVX2_INTRINSICS_
Expand Down