From adcce24b18d82ea4f6a751b38805c3f650a4c420 Mon Sep 17 00:00:00 2001 From: blattersturm Date: Sun, 16 Jul 2023 17:42:27 +0200 Subject: [PATCH] fix(server): better SSSE3 check On older Windows versions and CPUs without AVX this check would fail if SSSE3 was supported fine, and as x86-64-v2 isn't a hard requirement yet this was a regression. See #2091. --- code/server/launcher/src/Main.cpp | 17 ++++++++++++++++- vendor/cpu_features | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/code/server/launcher/src/Main.cpp b/code/server/launcher/src/Main.cpp index e47f09f1cf..663731a939 100644 --- a/code/server/launcher/src/Main.cpp +++ b/code/server/launcher/src/Main.cpp @@ -32,7 +32,22 @@ int main(int argc, char* argv[]) #ifdef CPU_FEATURES_ARCH_X86 auto x86info = cpu_features::GetX86Info(); - if (!x86info.features.popcnt || !x86info.features.ssse3) + + bool ssse3 = x86info.features.ssse3; + + // manually check for SSSE3 on Windows (PF_SSSE3_INSTRUCTIONS_AVAILABLE used by cpu_features does not exist below Vibranium + // and the code path in cpu_features for CPUs w/o AVX support - such as Westmere - depends on such) +#ifdef _WIN32 + if (!ssse3) + { + int cpuid[4] = { 0 }; + __cpuid(cpuid, 1); // leaf 1, field 2 contains 'Feature Information' + + ssse3 = (cpuid[2] >> 9) & 1; // bit 9 is SSSE3 + } +#endif + + if (!x86info.features.popcnt || !ssse3) { std::string errorMessage = fmt::sprintf( "The Cfx.re Platform Server requires support for x86-64-v2 instructions (such as POPCNT).\n" diff --git a/vendor/cpu_features b/vendor/cpu_features index 4e191a4cc8..de1b9e6fe7 160000 --- a/vendor/cpu_features +++ b/vendor/cpu_features @@ -1 +1 @@ -Subproject commit 4e191a4cc872263c60eb473550e2b7d2965690f9 +Subproject commit de1b9e6fe722a706cef801be67d3fd67cb533f1c