diff options
| author | Stenzek <stenzek@gmail.com> | 2018-03-01 18:03:24 +1000 |
|---|---|---|
| committer | Stenzek <stenzek@gmail.com> | 2018-03-10 15:56:45 +1000 |
| commit | 9fa24700b69b98b2569f4bd1353482cbfb1ec2d7 (patch) | |
| tree | 124457d7aceb32d5aea6447bb5bda08fe7875225 /Source/Core/VideoCommon | |
| parent | 590307b94c5865c0a75a18e9a593d251ce38407a (diff) | |
VideoConfig: Collapse ubershader configuration fields to a single value
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/ShaderCache.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VertexManagerBase.cpp | 27 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VideoConfig.cpp | 16 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VideoConfig.h | 31 |
4 files changed, 24 insertions, 52 deletions
diff --git a/Source/Core/VideoCommon/ShaderCache.cpp b/Source/Core/VideoCommon/ShaderCache.cpp index 1e4a0ef741..43a31dfd6b 100644 --- a/Source/Core/VideoCommon/ShaderCache.cpp +++ b/Source/Core/VideoCommon/ShaderCache.cpp @@ -38,7 +38,7 @@ bool ShaderCache::Initialize() } // Queue ubershader precompiling if required. - if (g_ActiveConfig.CanPrecompileUberShaders()) + if (g_ActiveConfig.UsingUberShaders()) PrecompileUberShaders(); // Compile all known UIDs. diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index f32ac72b0a..b54b8060b9 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -566,27 +566,24 @@ void VertexManagerBase::UpdatePipelineObject() m_current_pipeline_object = nullptr; m_pipeline_config_changed = false; - // Try for specialized shaders. - if (!g_ActiveConfig.bDisableSpecializedShaders) + if (g_ActiveConfig.iUberShaderMode == UberShaderMode::Disabled) + { + // Ubershaders disabled? Block and compile the specialized shader. + m_current_pipeline_object = g_shader_cache->GetPipelineForUid(m_current_pipeline_config); + return; + } + else if (g_ActiveConfig.iUberShaderMode == UberShaderMode::Hybrid) { // Can we background compile shaders? If so, get the pipeline asynchronously. - if (g_ActiveConfig.bBackgroundShaderCompiling) - { - auto res = g_shader_cache->GetPipelineForUidAsync(m_current_pipeline_config); - if (res) - { - // Specialized shaders are ready. - m_current_pipeline_object = *res; - return; - } - } - else + auto res = g_shader_cache->GetPipelineForUidAsync(m_current_pipeline_config); + if (res) { - m_current_pipeline_object = g_shader_cache->GetPipelineForUid(m_current_pipeline_config); + // Specialized shaders are ready, prefer these. + m_current_pipeline_object = *res; return; } } - // Fallback to ubershaders. + // Exclusive ubershader mode, or hybrid and shaders are still compiling. m_current_pipeline_object = g_shader_cache->GetUberPipelineForUid(m_current_uber_pipeline_config); } diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index d8c0dfaa6c..c14a00757a 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -102,9 +102,7 @@ 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); + iUberShaderMode = static_cast<UberShaderMode>(Config::Get(Config::GFX_UBERSHADER_MODE)); iShaderCompilerThreads = Config::Get(Config::GFX_SHADER_COMPILER_THREADS); iShaderPrecompilerThreads = Config::Get(Config::GFX_SHADER_PRECOMPILER_THREADS); @@ -206,15 +204,3 @@ u32 VideoConfig::GetShaderPrecompilerThreads() const 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; -} diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index 7839cb0e8f..2b69919528 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -42,6 +42,13 @@ enum class StereoMode : int Nvidia3DVision }; +enum class UberShaderMode : int +{ + Disabled, + Hybrid, + Exclusive +}; + struct ProjectionHackConfig final { bool m_enable; @@ -161,25 +168,8 @@ struct VideoConfig final // Currently only supported with Vulkan. int iCommandBufferExecuteInterval; - // The following options determine the ubershader mode: - // No ubershaders: - // - bBackgroundShaderCompiling = false - // - bDisableSpecializedShaders = false - // Hybrid/background compiling: - // - bBackgroundShaderCompiling = true - // - bDisableSpecializedShaders = false - // Ubershaders only: - // - bBackgroundShaderCompiling = false - // - bDisableSpecializedShaders = true - - // Enable background shader compiling, use ubershaders while waiting. - bool bBackgroundShaderCompiling; - - // Use ubershaders only, don't compile specialized shaders. - bool bDisableSpecializedShaders; - - // Precompile ubershader variants at boot/config reload time. - bool bPrecompileUberShaders; + // Shader compilation settings. + UberShaderMode iUberShaderMode; // Number of shader compiler threads. // 0 disables background compilation. @@ -247,10 +237,9 @@ struct VideoConfig final return backend_info.bSupportsGPUTextureDecoding && bEnableGPUTextureDecoding; } bool UseVertexRounding() const { return bVertexRounding && iEFBScale != 1; } + bool UsingUberShaders() const { return iUberShaderMode != UberShaderMode::Disabled; } u32 GetShaderCompilerThreads() const; u32 GetShaderPrecompilerThreads() const; - bool CanPrecompileUberShaders() const; - bool CanBackgroundCompileShaders() const; }; extern VideoConfig g_Config; |
