VideoConfig: Collapse ubershader configuration fields to a single value

This commit is contained in:
Stenzek
2018-03-01 18:03:24 +10:00
parent 590307b94c
commit 9fa24700b6
11 changed files with 42 additions and 112 deletions

View File

@ -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.

View File

@ -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)
{
auto res = g_shader_cache->GetPipelineForUidAsync(m_current_pipeline_config);
if (res)
{
// Specialized shaders are ready.
m_current_pipeline_object = *res;
return;
}
}
else
{
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);
}

View File

@ -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;
}

View File

@ -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;