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

@ -180,13 +180,16 @@ void DolphinAnalytics::MakeBaseBuilder()
static const char* GetUbershaderMode(const VideoConfig& video_config) static const char* GetUbershaderMode(const VideoConfig& video_config)
{ {
if (video_config.bDisableSpecializedShaders) switch (video_config.iUberShaderMode)
{
case UberShaderMode::Exclusive:
return "exclusive"; return "exclusive";
case UberShaderMode::Hybrid:
if (video_config.bBackgroundShaderCompiling)
return "hybrid"; return "hybrid";
case UberShaderMode::Disabled:
return "disabled"; default:
return "disabled";
}
} }
void DolphinAnalytics::MakePerGameBuilder() void DolphinAnalytics::MakePerGameBuilder()

View File

@ -76,12 +76,8 @@ const ConfigInfo<bool> GFX_BACKEND_MULTITHREADING{
const ConfigInfo<int> GFX_COMMAND_BUFFER_EXECUTE_INTERVAL{ const ConfigInfo<int> GFX_COMMAND_BUFFER_EXECUTE_INTERVAL{
{System::GFX, "Settings", "CommandBufferExecuteInterval"}, 100}; {System::GFX, "Settings", "CommandBufferExecuteInterval"}, 100};
const ConfigInfo<bool> GFX_SHADER_CACHE{{System::GFX, "Settings", "ShaderCache"}, true}; const ConfigInfo<bool> GFX_SHADER_CACHE{{System::GFX, "Settings", "ShaderCache"}, true};
const ConfigInfo<bool> GFX_BACKGROUND_SHADER_COMPILING{ const ConfigInfo<int> GFX_UBERSHADER_MODE{{System::GFX, "Settings", "UberShaderMode"},
{System::GFX, "Settings", "BackgroundShaderCompiling"}, false}; static_cast<int>(UberShaderMode::Disabled)};
const ConfigInfo<bool> GFX_DISABLE_SPECIALIZED_SHADERS{
{System::GFX, "Settings", "DisableSpecializedShaders"}, false};
const ConfigInfo<bool> GFX_PRECOMPILE_UBER_SHADERS{
{System::GFX, "Settings", "PrecompileUberShaders"}, true};
const ConfigInfo<int> GFX_SHADER_COMPILER_THREADS{ const ConfigInfo<int> GFX_SHADER_COMPILER_THREADS{
{System::GFX, "Settings", "ShaderCompilerThreads"}, 1}; {System::GFX, "Settings", "ShaderCompilerThreads"}, 1};
const ConfigInfo<int> GFX_SHADER_PRECOMPILER_THREADS{ const ConfigInfo<int> GFX_SHADER_PRECOMPILER_THREADS{

View File

@ -59,9 +59,7 @@ extern const ConfigInfo<bool> GFX_ENABLE_VALIDATION_LAYER;
extern const ConfigInfo<bool> GFX_BACKEND_MULTITHREADING; extern const ConfigInfo<bool> GFX_BACKEND_MULTITHREADING;
extern const ConfigInfo<int> GFX_COMMAND_BUFFER_EXECUTE_INTERVAL; extern const ConfigInfo<int> GFX_COMMAND_BUFFER_EXECUTE_INTERVAL;
extern const ConfigInfo<bool> GFX_SHADER_CACHE; extern const ConfigInfo<bool> GFX_SHADER_CACHE;
extern const ConfigInfo<bool> GFX_BACKGROUND_SHADER_COMPILING; extern const ConfigInfo<int> GFX_UBERSHADER_MODE;
extern const ConfigInfo<bool> GFX_DISABLE_SPECIALIZED_SHADERS;
extern const ConfigInfo<bool> GFX_PRECOMPILE_UBER_SHADERS;
extern const ConfigInfo<int> GFX_SHADER_COMPILER_THREADS; extern const ConfigInfo<int> GFX_SHADER_COMPILER_THREADS;
extern const ConfigInfo<int> GFX_SHADER_PRECOMPILER_THREADS; extern const ConfigInfo<int> GFX_SHADER_PRECOMPILER_THREADS;

View File

@ -46,9 +46,7 @@ bool IsSettingSaveable(const Config::ConfigLocation& config_location)
Config::GFX_DISABLE_FOG.location, Config::GFX_BORDERLESS_FULLSCREEN.location, Config::GFX_DISABLE_FOG.location, Config::GFX_BORDERLESS_FULLSCREEN.location,
Config::GFX_ENABLE_VALIDATION_LAYER.location, Config::GFX_BACKEND_MULTITHREADING.location, Config::GFX_ENABLE_VALIDATION_LAYER.location, Config::GFX_BACKEND_MULTITHREADING.location,
Config::GFX_COMMAND_BUFFER_EXECUTE_INTERVAL.location, Config::GFX_SHADER_CACHE.location, Config::GFX_COMMAND_BUFFER_EXECUTE_INTERVAL.location, Config::GFX_SHADER_CACHE.location,
Config::GFX_BACKGROUND_SHADER_COMPILING.location, Config::GFX_UBERSHADER_MODE.location, Config::GFX_SHADER_COMPILER_THREADS.location,
Config::GFX_DISABLE_SPECIALIZED_SHADERS.location,
Config::GFX_PRECOMPILE_UBER_SHADERS.location, Config::GFX_SHADER_COMPILER_THREADS.location,
Config::GFX_SHADER_PRECOMPILER_THREADS.location, Config::GFX_SHADER_PRECOMPILER_THREADS.location,
Config::GFX_SW_ZCOMPLOC.location, Config::GFX_SW_ZFREEZE.location, Config::GFX_SW_ZCOMPLOC.location, Config::GFX_SW_ZFREEZE.location,

View File

@ -63,9 +63,8 @@ void EnhancementsWidget::CreateWidgets()
m_af_combo = new GraphicsChoice({tr("1x"), tr("2x"), tr("4x"), tr("8x"), tr("16x")}, m_af_combo = new GraphicsChoice({tr("1x"), tr("2x"), tr("4x"), tr("8x"), tr("16x")},
Config::GFX_ENHANCE_MAX_ANISOTROPY); Config::GFX_ENHANCE_MAX_ANISOTROPY);
m_ubershader_combo = new QComboBox; m_ubershader_combo = new GraphicsChoice({tr("Disabled"), tr("Hybrid"), tr("Exclusive")},
for (const auto& option : {tr("Disabled"), tr("Hybrid"), tr("Exclusive")}) Config::GFX_UBERSHADER_MODE);
m_ubershader_combo->addItem(option);
m_pp_effect = new QComboBox(); m_pp_effect = new QComboBox();
m_configure_pp_effect = new QPushButton(tr("Configure")); m_configure_pp_effect = new QPushButton(tr("Configure"));
@ -131,9 +130,6 @@ void EnhancementsWidget::ConnectWidgets()
{ {
connect(m_aa_combo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), connect(m_aa_combo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
[this](int) { SaveSettings(); }); [this](int) { SaveSettings(); });
connect(m_ubershader_combo,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
[this](int) { SaveSettings(); });
connect(m_pp_effect, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), connect(m_pp_effect, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
[this](int) { SaveSettings(); }); [this](int) { SaveSettings(); });
connect(m_3d_mode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), connect(m_3d_mode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
@ -156,13 +152,6 @@ void EnhancementsWidget::LoadSettings()
QString::fromStdString(std::to_string(aa_selection) + "x " + (ssaa ? "SSAA" : "MSAA"))); QString::fromStdString(std::to_string(aa_selection) + "x " + (ssaa ? "SSAA" : "MSAA")));
m_aa_combo->setEnabled(m_aa_combo->count() > 1); m_aa_combo->setEnabled(m_aa_combo->count() > 1);
if (Config::GetBase(Config::GFX_DISABLE_SPECIALIZED_SHADERS))
m_ubershader_combo->setCurrentIndex(2);
else if (Config::GetBase(Config::GFX_BACKGROUND_SHADER_COMPILING))
m_ubershader_combo->setCurrentIndex(1);
else
m_ubershader_combo->setCurrentIndex(0);
// Post Processing Shader // Post Processing Shader
std::vector<std::string> shaders = std::vector<std::string> shaders =
g_Config.stereo_mode == StereoMode::Anaglyph ? g_Config.stereo_mode == StereoMode::Anaglyph ?
@ -220,10 +209,6 @@ void EnhancementsWidget::SaveSettings()
Config::SetBaseOrCurrent(Config::GFX_SSAA, is_ssaa); Config::SetBaseOrCurrent(Config::GFX_SSAA, is_ssaa);
int us_value = m_ubershader_combo->currentIndex();
Config::SetBaseOrCurrent(Config::GFX_BACKGROUND_SHADER_COMPILING, us_value == 1);
Config::SetBaseOrCurrent(Config::GFX_DISABLE_SPECIALIZED_SHADERS, us_value == 2);
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_POST_SHADER, Config::SetBaseOrCurrent(Config::GFX_ENHANCE_POST_SHADER,
m_pp_effect->currentText().toStdString()); m_pp_effect->currentText().toStdString());

View File

@ -534,24 +534,13 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title)
// ubershaders // ubershaders
{ {
const std::array<wxString, 3> mode_choices = {{_("Disabled"), _("Hybrid"), _("Exclusive")}}; const std::array<wxString, 3> mode_choices = {{_("Disabled"), _("Hybrid"), _("Exclusive")}};
wxChoice* const choice_mode =
new wxChoice(page_enh, wxID_ANY, wxDefaultPosition, wxDefaultSize,
static_cast<int>(mode_choices.size()), mode_choices.data());
RegisterControl(choice_mode, wxGetTranslation(ubershader_desc));
szr_enh->Add(new wxStaticText(page_enh, wxID_ANY, _("Ubershaders:")), wxGBPosition(row, 0), szr_enh->Add(new wxStaticText(page_enh, wxID_ANY, _("Ubershaders:")), wxGBPosition(row, 0),
wxDefaultSpan, wxALIGN_CENTER_VERTICAL); wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
szr_enh->Add(choice_mode, wxGBPosition(row, 1), span2, wxALIGN_CENTER_VERTICAL); szr_enh->Add(CreateChoice(page_enh, Config::GFX_UBERSHADER_MODE,
wxGetTranslation(ubershader_desc), mode_choices.size(),
mode_choices.data()),
wxGBPosition(row, 1), span2, wxALIGN_CENTER_VERTICAL);
row += 1; row += 1;
// Determine ubershader mode
choice_mode->Bind(wxEVT_CHOICE, &VideoConfigDiag::OnUberShaderModeChanged, this);
if (Config::GetBase(Config::GFX_DISABLE_SPECIALIZED_SHADERS))
choice_mode->SetSelection(2);
else if (Config::GetBase(Config::GFX_BACKGROUND_SHADER_COMPILING))
choice_mode->SetSelection(1);
else
choice_mode->SetSelection(0);
} }
// postproc shader // postproc shader
@ -1290,13 +1279,3 @@ void VideoConfigDiag::OnAAChanged(wxCommandEvent& ev)
Config::SetBaseOrCurrent(Config::GFX_MSAA, vconfig.backend_info.AAModes[mode]); Config::SetBaseOrCurrent(Config::GFX_MSAA, vconfig.backend_info.AAModes[mode]);
} }
void VideoConfigDiag::OnUberShaderModeChanged(wxCommandEvent& ev)
{
// 0: No ubershaders
// 1: Hybrid ubershaders
// 2: Only ubershaders
int mode = ev.GetInt();
Config::SetBaseOrCurrent(Config::GFX_BACKGROUND_SHADER_COMPILING, mode == 1);
Config::SetBaseOrCurrent(Config::GFX_DISABLE_SPECIALIZED_SHADERS, mode == 2);
}

View File

@ -139,7 +139,6 @@ protected:
void PopulatePostProcessingShaders(); void PopulatePostProcessingShaders();
void PopulateAAList(); void PopulateAAList();
void OnAAChanged(wxCommandEvent& ev); void OnAAChanged(wxCommandEvent& ev);
void OnUberShaderModeChanged(wxCommandEvent& ev);
wxChoice* choice_backend; wxChoice* choice_backend;
wxChoice* choice_adapter; wxChoice* choice_adapter;

View File

@ -38,7 +38,7 @@ bool ShaderCache::Initialize()
} }
// Queue ubershader precompiling if required. // Queue ubershader precompiling if required.
if (g_ActiveConfig.CanPrecompileUberShaders()) if (g_ActiveConfig.UsingUberShaders())
PrecompileUberShaders(); PrecompileUberShaders();
// Compile all known UIDs. // Compile all known UIDs.

View File

@ -566,27 +566,24 @@ void VertexManagerBase::UpdatePipelineObject()
m_current_pipeline_object = nullptr; m_current_pipeline_object = nullptr;
m_pipeline_config_changed = false; m_pipeline_config_changed = false;
// Try for specialized shaders. if (g_ActiveConfig.iUberShaderMode == UberShaderMode::Disabled)
if (!g_ActiveConfig.bDisableSpecializedShaders) {
// 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. // 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); // Specialized shaders are ready, prefer these.
if (res) m_current_pipeline_object = *res;
{
// Specialized shaders are ready.
m_current_pipeline_object = *res;
return;
}
}
else
{
m_current_pipeline_object = g_shader_cache->GetPipelineForUid(m_current_pipeline_config);
return; 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); 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); bBackendMultithreading = Config::Get(Config::GFX_BACKEND_MULTITHREADING);
iCommandBufferExecuteInterval = Config::Get(Config::GFX_COMMAND_BUFFER_EXECUTE_INTERVAL); iCommandBufferExecuteInterval = Config::Get(Config::GFX_COMMAND_BUFFER_EXECUTE_INTERVAL);
bShaderCache = Config::Get(Config::GFX_SHADER_CACHE); bShaderCache = Config::Get(Config::GFX_SHADER_CACHE);
bBackgroundShaderCompiling = Config::Get(Config::GFX_BACKGROUND_SHADER_COMPILING); iUberShaderMode = static_cast<UberShaderMode>(Config::Get(Config::GFX_UBERSHADER_MODE));
bDisableSpecializedShaders = Config::Get(Config::GFX_DISABLE_SPECIALIZED_SHADERS);
bPrecompileUberShaders = Config::Get(Config::GFX_PRECOMPILE_UBER_SHADERS);
iShaderCompilerThreads = Config::Get(Config::GFX_SHADER_COMPILER_THREADS); iShaderCompilerThreads = Config::Get(Config::GFX_SHADER_COMPILER_THREADS);
iShaderPrecompilerThreads = Config::Get(Config::GFX_SHADER_PRECOMPILER_THREADS); iShaderPrecompilerThreads = Config::Get(Config::GFX_SHADER_PRECOMPILER_THREADS);
@ -206,15 +204,3 @@ u32 VideoConfig::GetShaderPrecompilerThreads() const
else else
return GetNumAutoShaderCompilerThreads(); 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 Nvidia3DVision
}; };
enum class UberShaderMode : int
{
Disabled,
Hybrid,
Exclusive
};
struct ProjectionHackConfig final struct ProjectionHackConfig final
{ {
bool m_enable; bool m_enable;
@ -161,25 +168,8 @@ struct VideoConfig final
// Currently only supported with Vulkan. // Currently only supported with Vulkan.
int iCommandBufferExecuteInterval; int iCommandBufferExecuteInterval;
// The following options determine the ubershader mode: // Shader compilation settings.
// No ubershaders: UberShaderMode iUberShaderMode;
// - 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;
// Number of shader compiler threads. // Number of shader compiler threads.
// 0 disables background compilation. // 0 disables background compilation.
@ -247,10 +237,9 @@ struct VideoConfig final
return backend_info.bSupportsGPUTextureDecoding && bEnableGPUTextureDecoding; return backend_info.bSupportsGPUTextureDecoding && bEnableGPUTextureDecoding;
} }
bool UseVertexRounding() const { return bVertexRounding && iEFBScale != 1; } bool UseVertexRounding() const { return bVertexRounding && iEFBScale != 1; }
bool UsingUberShaders() const { return iUberShaderMode != UberShaderMode::Disabled; }
u32 GetShaderCompilerThreads() const; u32 GetShaderCompilerThreads() const;
u32 GetShaderPrecompilerThreads() const; u32 GetShaderPrecompilerThreads() const;
bool CanPrecompileUberShaders() const;
bool CanBackgroundCompileShaders() const;
}; };
extern VideoConfig g_Config; extern VideoConfig g_Config;