diff --git a/pcsx2/GS/MultiISA.cpp b/pcsx2/GS/MultiISA.cpp index 6101915ed7..48e1281d0b 100644 --- a/pcsx2/GS/MultiISA.cpp +++ b/pcsx2/GS/MultiISA.cpp @@ -18,6 +18,11 @@ static ProcessorFeatures::VectorISA getCurrentISA() // For debugging if (const char* over = getenv("OVERRIDE_VECTOR_ISA")) { + if (strcasecmp(over, "avx512f") == 0) + { + fprintf(stderr, "Vector ISA Override: AVX512F\n"); + return ProcessorFeatures::VectorISA::AVX512F; + } if (strcasecmp(over, "avx2") == 0) { fprintf(stderr, "Vector ISA Override: AVX2\n"); @@ -35,12 +40,13 @@ static ProcessorFeatures::VectorISA getCurrentISA() } } - if (cpuinfo_has_x86_avx2() && cpuinfo_has_x86_bmi() && cpuinfo_has_x86_bmi2()) - return ProcessorFeatures::VectorISA::AVX2; - else if (cpuinfo_has_x86_avx()) - return ProcessorFeatures::VectorISA::AVX; - else + if (!cpuinfo_has_x86_avx()) return ProcessorFeatures::VectorISA::SSE4; + if (!cpuinfo_has_x86_avx2()) + return ProcessorFeatures::VectorISA::AVX; + if (!cpuinfo_has_x86_avx512f()) + return ProcessorFeatures::VectorISA::AVX2; + return ProcessorFeatures::VectorISA::AVX512F; } #endif @@ -53,11 +59,17 @@ static ProcessorFeatures getProcessorFeatures() #if defined(_M_X86) features.vectorISA = getCurrentISA(); features.hasFMA = cpuinfo_has_x86_fma3(); + features.hasBMI2 = cpuinfo_has_x86_bmi() && cpuinfo_has_x86_bmi2(); if (const char* over = getenv("OVERRIDE_FMA")) { features.hasFMA = over[0] == 'Y' || over[0] == 'y' || over[0] == '1'; fprintf(stderr, "Processor FMA override: %s\n", features.hasFMA ? "Supported" : "Unsupported"); } + if (const char* over = getenv("OVERRIDE_BMI2")) + { + features.hasBMI2 = over[0] == 'Y' || over[0] == 'y' || over[0] == '1'; + fprintf(stderr, "Processor BMI2 override: %s\n", features.hasBMI2 ? "Supported" : "Unsupported"); + } features.hasSlowGather = false; if (const char* over = getenv("OVERRIDE_SLOW_GATHER")) // Easy override for comparing on vs off { diff --git a/pcsx2/GS/MultiISA.h b/pcsx2/GS/MultiISA.h index 58d50348ec..42ec56dbef 100644 --- a/pcsx2/GS/MultiISA.h +++ b/pcsx2/GS/MultiISA.h @@ -4,7 +4,6 @@ #pragma once #include "common/Pcsx2Defs.h" -#include "common/VectorIntrin.h" // For multiple-isa compilation #ifdef MULTI_ISA_UNSHARED_COMPILATION @@ -45,9 +44,10 @@ struct ProcessorFeatures { #ifdef _M_X86 - enum class VectorISA { SSE4, AVX, AVX2 }; + enum class VectorISA { SSE4, AVX, AVX2, AVX512F }; VectorISA vectorISA; bool hasFMA; + bool hasBMI2; bool hasSlowGather; #endif }; diff --git a/pcsx2/SPU2/defs.h b/pcsx2/SPU2/defs.h index 711acccd91..c08d612460 100644 --- a/pcsx2/SPU2/defs.h +++ b/pcsx2/SPU2/defs.h @@ -7,6 +7,7 @@ #include #include +#include // -------------------------------------------------------------------------------------- // SPU2 Register Table LUT diff --git a/pcsx2/VMManager.cpp b/pcsx2/VMManager.cpp index f35f0a63cb..9896d20bbe 100644 --- a/pcsx2/VMManager.cpp +++ b/pcsx2/VMManager.cpp @@ -2527,11 +2527,11 @@ void VMManager::LogCPUCapabilities() #ifdef _M_X86 std::string extensions; - if (cpuinfo_has_x86_avx()) + if (g_cpu.vectorISA >= ProcessorFeatures::VectorISA::AVX) extensions += "AVX "; - if (cpuinfo_has_x86_avx2()) + if (g_cpu.vectorISA >= ProcessorFeatures::VectorISA::AVX2) extensions += "AVX2 "; - if (cpuinfo_has_x86_avx512f()) + if (g_cpu.vectorISA >= ProcessorFeatures::VectorISA::AVX512F) extensions += "AVX512F "; #ifdef _M_ARM64 if (cpuinfo_has_arm_neon()) diff --git a/pcsx2/x86/R5900_Profiler.h b/pcsx2/x86/R5900_Profiler.h index 59776fb7c9..cacf2a156f 100644 --- a/pcsx2/x86/R5900_Profiler.h +++ b/pcsx2/x86/R5900_Profiler.h @@ -215,6 +215,9 @@ static const char eeOpcodeName[][16] = { #ifdef eeProfileProg #include #include +#include "common/emitter/x86emitter.h" +#include "common/Console.h" +#include "GS/MultiISA.h" using namespace x86Emitter; @@ -368,7 +371,7 @@ struct eeProfiler void EmitMem() { // Compact the 4GB virtual address to a 512KB virtual address - if (x86caps.hasBMI2) + if (g_cpu.hasBMI2) { xPEXT(ebx, ecx, ptr[&memMask]); xADD(ptr32[(rbx * 4) + memStats], 1); @@ -377,7 +380,7 @@ struct eeProfiler void EmitConstMem(u32 add) { - if (x86caps.hasBMI2) + if (g_cpu.hasBMI2) { u32 a = _pext_u32(add, memMask); xADD(ptr32[a + memStats], 1); diff --git a/pcsx2/x86/microVU_Execute.inl b/pcsx2/x86/microVU_Execute.inl index 30be7648a1..7181b4d555 100644 --- a/pcsx2/x86/microVU_Execute.inl +++ b/pcsx2/x86/microVU_Execute.inl @@ -4,7 +4,7 @@ #pragma once #include "Config.h" -#include "cpuinfo.h" +#include "GS/MultiISA.h" //------------------------------------------------------------------ // Dispatcher Functions @@ -207,7 +207,7 @@ static void mVUGenerateCopyPipelineState(mV) { mVU.copyPLState = xGetAlignedCallTarget(); - if (cpuinfo_has_x86_avx()) + if (g_cpu.vectorISA >= ProcessorFeatures::VectorISA::AVX) { xVMOVAPS(ymm0, ptr[rax]); xVMOVAPS(ymm1, ptr[rax + 32u]); @@ -252,7 +252,7 @@ static void mVUGenerateCompareState(mV) { mVU.compareStateF = xGetAlignedCallTarget(); - if (!cpuinfo_has_x86_avx2()) + if (g_cpu.vectorISA < ProcessorFeatures::VectorISA::AVX2) { xMOVAPS (xmm0, ptr32[arg1reg]); xPCMP.EQD(xmm0, ptr32[arg2reg]);