summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VideoConfig.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2022-01-04 10:15:12 -0500
committerGitHub <noreply@github.com>2022-01-04 10:15:12 -0500
commit9a914d33d52e5a5305bc68777170273b2cf2fdd5 (patch)
tree789490a92406567880fb90d1d58fcbb5f476a300 /Source/Core/VideoCommon/VideoConfig.cpp
parenta026ef30d248f8bcdfaea565415766056d65877f (diff)
parentf43122cd8abbd74c00ec7701bf21892c77f0f967 (diff)
Merge pull request #9414 from DevJPM/master
Fix CPU Core Count detection and Enable Parallel Shader Compilation
Diffstat (limited to 'Source/Core/VideoCommon/VideoConfig.cpp')
-rw-r--r--Source/Core/VideoCommon/VideoConfig.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp
index a5c9834dc8..a835625691 100644
--- a/Source/Core/VideoCommon/VideoConfig.cpp
+++ b/Source/Core/VideoCommon/VideoConfig.cpp
@@ -12,6 +12,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"
@@ -177,6 +178,14 @@ static u32 GetNumAutoShaderCompilerThreads()
return static_cast<u32>(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<u32>(std::max(cpu_info.num_cores - 2, 1));
+}
+
u32 VideoConfig::GetShaderCompilerThreads() const
{
if (!backend_info.bSupportsBackgroundCompiling)
@@ -197,8 +206,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<u32>(iShaderPrecompilerThreads);
+ else if (multiThreadingWorking)
+ return GetNumAutoShaderPreCompilerThreads();
else
- return GetNumAutoShaderCompilerThreads();
+ return 1;
}