From 61cfd8696ee010758c48d02eac13d3dffc3501a7 Mon Sep 17 00:00:00 2001 From: DevJPM Date: Sat, 2 Jan 2021 13:47:18 +0100 Subject: Fix CPU Core Count detection and Enable Parallel Shader Compilation This does this following things: - Default to the runtime automatic number of threads for pre-compiling shaders - Adds a distinct automatic thread count computation for pre-compilation (which has less other things going on and should scale better beyond 4 cores) - Removes the unused logical_core_count field from the CPU detection - Changes the semantics of num_cores from maximaum addressable number of cores to actually available CPU cores (which is also how it was actually used) - Updates the computation of the HTT flag now that AMD no longer lies about it for its Zen processors - Background shader compilation is *not* enabled by default --- Source/Core/VideoCommon/VideoConfig.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/VideoConfig.cpp') diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index 88ec126c7c..9cdf1256f7 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -176,6 +176,14 @@ static u32 GetNumAutoShaderCompilerThreads() return static_cast(std::min(std::max(cpu_info.num_cores - 3, 1), 4)); } +static u32 GetNumAutoShaderPreCompilerThreads() +{ + // Automatic number. We use clamp(cpus - 2, 1, infty) here. + // We chose this because we don't want to limit our speed-up + // and at the same time leave two logical cores for the dolphin UI and the rest of the OS. + return static_cast(std::max(cpu_info.num_cores - 2, 1)); +} + u32 VideoConfig::GetShaderCompilerThreads() const { if (!backend_info.bSupportsBackgroundCompiling) @@ -199,5 +207,5 @@ u32 VideoConfig::GetShaderPrecompilerThreads() const if (iShaderPrecompilerThreads >= 0) return static_cast(iShaderPrecompilerThreads); else - return GetNumAutoShaderCompilerThreads(); + return GetNumAutoShaderPreCompilerThreads(); } -- cgit v1.2.3 From 613c4563c288b5b73b2f1defb23ad645cef97bee Mon Sep 17 00:00:00 2001 From: DevJPM Date: Thu, 3 Jun 2021 16:03:37 +0200 Subject: VideoCommon: Gate Multi-Threaded Shader Pre-Compilation behind a bug entry --- Source/Core/VideoCommon/VideoConfig.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/VideoConfig.cpp') diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index 9cdf1256f7..5e833a4244 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -10,6 +10,7 @@ #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/Movie.h" +#include "VideoCommon/DriverDetails.h" #include "VideoCommon/OnScreenDisplay.h" #include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoConfig.h" @@ -204,8 +205,17 @@ u32 VideoConfig::GetShaderPrecompilerThreads() const if (!backend_info.bSupportsBackgroundCompiling) return 0; + const bool bugDatabaseSupported = + backend_info.api_type == APIType::OpenGL || backend_info.api_type == APIType::Vulkan; + // DirectX has always worked in our tests in PR#9414 + const bool multiThreadingWorking = + !bugDatabaseSupported || + !DriverDetails::HasBug(DriverDetails::BUG_BROKEN_MULTITHREADED_SHADER_PRECOMPILATION); + if (iShaderPrecompilerThreads >= 0) return static_cast(iShaderPrecompilerThreads); - else + else if (multiThreadingWorking) return GetNumAutoShaderPreCompilerThreads(); + else + return 1; } -- cgit v1.2.3