diff options
| author | Anthony <Helios747@users.noreply.github.com> | 2017-07-30 01:00:16 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-30 01:00:16 -0700 |
| commit | ba57605266b9ab178963bf56e146f355d1b93cd4 (patch) | |
| tree | 0ddc89cfca6db3d343d317c18b7c07c9ab83e9c4 /Source/Core/VideoCommon/VideoConfig.cpp | |
| parent | 5bad2ee4a4129e734ff4f4d861cedc4cd573df55 (diff) | |
| parent | b154edb4fbdb327920a33b44f35f34cdf2636d6f (diff) | |
Merge pull request #5702 from stenzek/ubershaders
Ubershaders 2.0
Diffstat (limited to 'Source/Core/VideoCommon/VideoConfig.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VideoConfig.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index 355d2486b4..c277386f71 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -4,6 +4,7 @@ #include <algorithm> +#include "Common/CPUDetect.h" #include "Common/CommonTypes.h" #include "Common/StringUtil.h" #include "Core/Config/GraphicsSettings.h" @@ -93,6 +94,13 @@ void VideoConfig::Refresh() bBackendMultithreading = Config::Get(Config::GFX_BACKEND_MULTITHREADING); iCommandBufferExecuteInterval = Config::Get(Config::GFX_COMMAND_BUFFER_EXECUTE_INTERVAL); bShaderCache = Config::Get(Config::GFX_SHADER_CACHE); + bBackgroundShaderCompiling = Config::Get(Config::GFX_BACKGROUND_SHADER_COMPILING); + bDisableSpecializedShaders = Config::Get(Config::GFX_DISABLE_SPECIALIZED_SHADERS); + bPrecompileUberShaders = Config::Get(Config::GFX_PRECOMPILE_UBER_SHADERS); + iShaderCompilerThreads = Config::Get(Config::GFX_SHADER_COMPILER_THREADS); + iShaderPrecompilerThreads = Config::Get(Config::GFX_SHADER_PRECOMPILER_THREADS); + bForceVertexUberShaders = Config::Get(Config::GFX_FORCE_VERTEX_UBER_SHADERS); + bForcePixelUberShaders = Config::Get(Config::GFX_FORCE_PIXEL_UBER_SHADERS); bZComploc = Config::Get(Config::GFX_SW_ZCOMPLOC); bZFreeze = Config::Get(Config::GFX_SW_ZFREEZE); @@ -188,3 +196,37 @@ bool VideoConfig::IsVSync() { return bVSync && !Core::GetIsThrottlerTempDisabled(); } + +static u32 GetNumAutoShaderCompilerThreads() +{ + // Automatic number. We use clamp(cpus - 3, 1, 4). + return static_cast<u32>(std::min(std::max(cpu_info.num_cores - 3, 1), 4)); +} + +u32 VideoConfig::GetShaderCompilerThreads() const +{ + if (iShaderCompilerThreads >= 0) + return static_cast<u32>(iShaderCompilerThreads); + else + return GetNumAutoShaderCompilerThreads(); +} + +u32 VideoConfig::GetShaderPrecompilerThreads() const +{ + if (iShaderPrecompilerThreads >= 0) + return static_cast<u32>(iShaderPrecompilerThreads); + else + return GetNumAutoShaderCompilerThreads(); +} + +bool VideoConfig::CanPrecompileUberShaders() const +{ + // We don't want to precompile ubershaders if they're never going to be used. + return bPrecompileUberShaders && (bBackgroundShaderCompiling || bDisableSpecializedShaders); +} + +bool VideoConfig::CanBackgroundCompileShaders() const +{ + // We require precompiled ubershaders to background compile shaders. + return bBackgroundShaderCompiling && bPrecompileUberShaders; +} |
