gsdx: properly check SSE support

1/ Check all "levels"
2/ requires AVX for 64 bits
This commit is contained in:
Gregory Hainaut 2016-11-18 17:59:58 +01:00
parent 8b4da69861
commit 82d12691e1
1 changed files with 30 additions and 26 deletions

View File

@ -203,38 +203,42 @@ bool GSUtil::HasCompatibleBits(uint32 spsm, uint32 dpsm)
bool GSUtil::CheckSSE() bool GSUtil::CheckSSE()
{ {
bool status = true;
Xbyak::util::Cpu cpu; Xbyak::util::Cpu cpu;
struct ISA {
Xbyak::util::Cpu::Type type; Xbyak::util::Cpu::Type type;
const char* instruction_set = ""; const char* name;
};
#if _M_SSE >= 0x501 ISA checks[] = {
type = Xbyak::util::Cpu::tAVX2; {Xbyak::util::Cpu::tSSE2, "SSE2"},
instruction_set = "AVX2"; #if _M_SSE >= 0x301 || defined(_M_AMD64)
#elif _M_SSE >= 0x500 {Xbyak::util::Cpu::tSSSE3, "SSSE3"},
type = Xbyak::util::Cpu::tAVX;
instruction_set = "AVX";
#elif _M_SSE >= 0x402
type = Xbyak::util::Cpu::tSSE42;
instruction_set = "SSE4.2";
#elif _M_SSE >= 0x401
type = Xbyak::util::Cpu::tSSE41;
instruction_set = "SSE4.1";
#elif _M_SSE >= 0x301
type = Xbyak::util::Cpu::tSSSE3;
instruction_set = "SSSE3";
#elif _M_SSE >= 0x200
type = Xbyak::util::Cpu::tSSE2;
instruction_set = "SSE2";
#endif #endif
#if _M_SSE >= 0x401 || defined(_M_AMD64)
{Xbyak::util::Cpu::tSSE41, "SSE41"},
#endif
#if _M_SSE >= 0x402 || defined(_M_AMD64)
{Xbyak::util::Cpu::tSSE42, "SSE42"},
#endif
#if _M_SSE >= 0x500 || defined(_M_AMD64)
{Xbyak::util::Cpu::tAVX, "AVX1"},
#endif
#if _M_SSE >= 0x501
{Xbyak::util::Cpu::tAVX2, "AVX2"},
#endif
};
if(!cpu.has(type)) for (size_t i = 0; i < countof(checks); i++) {
{ if(!cpu.has(checks[i].type)) {
fprintf(stderr, "This CPU does not support %s\n", instruction_set); fprintf(stderr, "This CPU does not support %s\n", checks[i].name);
return false; status = false;
}
} }
return true; return status;
} }
#define OCL_PROGRAM_VERSION 3 #define OCL_PROGRAM_VERSION 3