CMake: Add DISABLE_SSE4 option

NOT recommended. Only if you ABSOLUTELY need it.

The SSE2/legacy build will be a separate download option, and
warn you if you try to run it on a CPU that supports SSE4.
This commit is contained in:
Stenzek 2024-09-23 19:20:14 +10:00
parent d67b826033
commit bfc914aaa9
No known key found for this signature in database
5 changed files with 23 additions and 13 deletions

View File

@ -5,6 +5,7 @@ option(BUILD_NOGUI_FRONTEND "Build the NoGUI frontend" OFF)
option(BUILD_QT_FRONTEND "Build the Qt frontend" ON)
option(BUILD_REGTEST "Build regression test runner" OFF)
option(BUILD_TESTS "Build unit tests" OFF)
option(DISABLE_SSE4 "Build with SSE4 instructions disabled, reduces performance" OFF)
if(LINUX OR BSD)
option(ENABLE_X11 "Support X11 window system" ON)

View File

@ -38,8 +38,7 @@ It does **not** use the LSB subdirectories of bin, share, etc, so you should dis
endif()
if(NOT IS_SUPPORTED_COMPILER)
message(WARNING "
*************** UNSUPPORTED CONFIGURATION ***************
message(WARNING "*************** UNSUPPORTED CONFIGURATION ***************
You are not compiling DuckStation with a supported compiler.
It may not even build successfully.
DuckStation only supports the Clang and MSVC compilers.
@ -48,11 +47,18 @@ No support will be provided, continue at your own risk.
endif()
if(WIN32)
message(WARNING "
*************** UNSUPPORTED CONFIGURATION ***************
message(WARNING "*************** UNSUPPORTED CONFIGURATION ***************
You are compiling DuckStation with CMake on Windows.
It may not even build successfully.
DuckStation only supports MSBuild on Windows.
No support will be provided, continue at your own risk.
*********************************************************")
endif()
if(CPU_ARCH_X64 AND DISABLE_SSE4)
message(WARNING "*********************** WARNING ***********************
SSE4 instructions are disabled. This will result in
reduced performance. You should not enable this option
unless you have a pre-2008 CPU.
*******************************************************")
endif()

View File

@ -69,7 +69,7 @@ function(detect_architecture)
CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS "Building x86_64 binaries.")
set(CPU_ARCH_X64 TRUE PARENT_SCOPE)
if(NOT MSVC OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(NOT MSVC OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT DISABLE_SSE4)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1" PARENT_SCOPE)
endif()

View File

@ -357,17 +357,19 @@ bool System::Internal::PerformEarlyHardwareChecks(Error* error)
#ifdef CPU_ARCH_SSE41
if (!cpuinfo_has_x86_sse4_1())
{
Error::SetStringFmt(error, "Your CPU does not support the SSE4.1 instruction set, which is required for this "
"version of DuckStation.\nPlease download and switch to the legacy SSE2 version.\nYou "
"can download this from https://www.duckstation.org/ under \"Other Platforms\".");
Error::SetStringFmt(
error, "<h3>Your CPU does not support the SSE4.1 instruction set.</h3><p>SSE4.1 is required for this version of "
"DuckStation. Please download and switch to the legacy SSE2 version.</p><p>You can download this from <a "
"href=\"https://www.duckstation.org/\">www.duckstation.org</a> under \"Other Platforms\".");
return false;
}
#else
if (cpuinfo_has_x86_sse4_1())
{
Error::SetStringFmt(error, "You are running the legacy SSE2 DuckStation executable on a CPU that supports the "
"SSE4.1 instruction set.\nPlease download and switch the regular, non-SSE2 "
"version.\nYou can download this from https://www.duckstation.org/.");
Error::SetStringFmt(
error, "You are running the <strong>legacy SSE2 DuckStation executable</strong> on a CPU that supports the "
"SSE4.1 instruction set.\nPlease download and switch to the regular, non-SSE2 version.\nYou can download "
"this from <a href=\"https://www.duckstation.org/\">www.duckstation.org</a>.");
}
#endif
#endif

View File

@ -2550,13 +2550,14 @@ int main(int argc, char* argv[])
CrashHandler::Install(&Bus::CleanupMemoryMap);
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
QtHost::RegisterTypes();
QApplication app(argc, argv);
if (!QtHost::PerformEarlyHardwareChecks())
return EXIT_FAILURE;
// Type registration has to happen after hardware checks, clang emits ptest instructions otherwise.
QtHost::RegisterTypes();
std::shared_ptr<SystemBootParameters> autoboot;
if (!QtHost::ParseCommandLineParametersAndInitializeConfig(app, autoboot))
return EXIT_FAILURE;