mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
VideoConfig: Add config options for ubershaders
This commit is contained in:
@ -77,6 +77,18 @@ const ConfigInfo<bool> GFX_BACKEND_MULTITHREADING{
|
||||
const ConfigInfo<int> GFX_COMMAND_BUFFER_EXECUTE_INTERVAL{
|
||||
{System::GFX, "Settings", "CommandBufferExecuteInterval"}, 100};
|
||||
const ConfigInfo<bool> GFX_SHADER_CACHE{{System::GFX, "Settings", "ShaderCache"}, true};
|
||||
const ConfigInfo<bool> GFX_BACKGROUND_SHADER_COMPILING{
|
||||
{System::GFX, "Settings", "BackgroundShaderCompiling"}, false};
|
||||
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{
|
||||
{System::GFX, "Settings", "ShaderCompilerThreads"}, 1};
|
||||
const ConfigInfo<bool> GFX_FORCE_VERTEX_UBER_SHADERS{
|
||||
{System::GFX, "Settings", "ForceVertexUberShaders"}, false};
|
||||
const ConfigInfo<bool> GFX_FORCE_PIXEL_UBER_SHADERS{
|
||||
{System::GFX, "Settings", "ForcePixelUberShaders"}, false};
|
||||
|
||||
const ConfigInfo<bool> GFX_SW_ZCOMPLOC{{System::GFX, "Settings", "SWZComploc"}, true};
|
||||
const ConfigInfo<bool> GFX_SW_ZFREEZE{{System::GFX, "Settings", "SWZFreeze"}, true};
|
||||
|
@ -59,6 +59,12 @@ extern const ConfigInfo<bool> GFX_ENABLE_VALIDATION_LAYER;
|
||||
extern const ConfigInfo<bool> GFX_BACKEND_MULTITHREADING;
|
||||
extern const ConfigInfo<int> GFX_COMMAND_BUFFER_EXECUTE_INTERVAL;
|
||||
extern const ConfigInfo<bool> GFX_SHADER_CACHE;
|
||||
extern const ConfigInfo<bool> GFX_BACKGROUND_SHADER_COMPILING;
|
||||
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<bool> GFX_FORCE_VERTEX_UBER_SHADERS;
|
||||
extern const ConfigInfo<bool> GFX_FORCE_PIXEL_UBER_SHADERS;
|
||||
|
||||
extern const ConfigInfo<bool> GFX_SW_ZCOMPLOC;
|
||||
extern const ConfigInfo<bool> GFX_SW_ZFREEZE;
|
||||
|
@ -43,6 +43,10 @@ bool IsSettingSaveable(const Config::ConfigLocation& config_location)
|
||||
Config::GFX_DISABLE_FOG.location, Config::GFX_BORDERLESS_FULLSCREEN.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_BACKGROUND_SHADER_COMPILING.location,
|
||||
Config::GFX_DISABLE_SPECIALIZED_SHADERS.location,
|
||||
Config::GFX_PRECOMPILE_UBER_SHADERS.location, Config::GFX_SHADER_COMPILER_THREADS.location,
|
||||
Config::GFX_FORCE_VERTEX_UBER_SHADERS.location, Config::GFX_FORCE_PIXEL_UBER_SHADERS.location,
|
||||
|
||||
Config::GFX_SW_ZCOMPLOC.location, Config::GFX_SW_ZFREEZE.location,
|
||||
Config::GFX_SW_DUMP_OBJECTS.location, Config::GFX_SW_DUMP_TEV_STAGES.location,
|
||||
|
@ -308,6 +308,14 @@ static wxString gpu_texture_decoding_desc =
|
||||
wxTRANSLATE("Enables texture decoding using the GPU instead of the CPU. This may result in "
|
||||
"performance gains in some scenarios, or on systems where the CPU is the "
|
||||
"bottleneck.\n\nIf unsure, leave this unchecked.");
|
||||
static wxString ubershader_desc =
|
||||
wxTRANSLATE("Disabled: Ubershaders are never used. Stuttering will occur during shader "
|
||||
"compilation, but GPU demands are low. Recommended for low-end hardware.\n\n"
|
||||
"Hybrid: Ubershaders will be used to prevent stuttering during shader "
|
||||
"compilation, but traditional shaders will be used when they will not cause "
|
||||
"stuttering. Balances performance and smoothness.\n\n"
|
||||
"Exclusive: Ubershaders will always be used. Only recommended for high-end "
|
||||
"systems.");
|
||||
|
||||
VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title)
|
||||
: wxDialog(parent, wxID_ANY, wxString::Format(_("Dolphin %s Graphics Configuration"),
|
||||
@ -561,6 +569,29 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title)
|
||||
row += 1;
|
||||
}
|
||||
|
||||
// ubershaders
|
||||
{
|
||||
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),
|
||||
wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
|
||||
szr_enh->Add(choice_mode, wxGBPosition(row, 1), span2, wxALIGN_CENTER_VERTICAL);
|
||||
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
|
||||
if (vconfig.backend_info.bSupportsPostProcessing)
|
||||
{
|
||||
@ -1326,3 +1357,13 @@ void VideoConfigDiag::OnAAChanged(wxCommandEvent& ev)
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -140,6 +140,7 @@ protected:
|
||||
void PopulatePostProcessingShaders();
|
||||
void PopulateAAList();
|
||||
void OnAAChanged(wxCommandEvent& ev);
|
||||
void OnUberShaderModeChanged(wxCommandEvent& ev);
|
||||
|
||||
wxChoice* choice_backend;
|
||||
wxChoice* choice_adapter;
|
||||
|
@ -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,12 @@ 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);
|
||||
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 +195,31 @@ bool VideoConfig::IsVSync()
|
||||
{
|
||||
return bVSync && !Core::GetIsThrottlerTempDisabled();
|
||||
}
|
||||
|
||||
u32 VideoConfig::GetShaderCompilerThreads() const
|
||||
{
|
||||
if (iShaderCompilerThreads >= 0)
|
||||
return static_cast<u32>(iShaderCompilerThreads);
|
||||
|
||||
// Automatic number. We use clamp(cpus - 3, 1, 4).
|
||||
return static_cast<u32>(std::min(std::max(cpu_info.num_cores - 3, 1), 4));
|
||||
}
|
||||
|
||||
bool VideoConfig::CanUseUberShaders() const
|
||||
{
|
||||
// Ubershaders are currently incompatible with per-pixel lighting.
|
||||
return !bEnablePixelLighting;
|
||||
}
|
||||
|
||||
bool VideoConfig::CanPrecompileUberShaders() const
|
||||
{
|
||||
// We don't want to precompile ubershaders if they're never going to be used.
|
||||
return bPrecompileUberShaders && (bBackgroundShaderCompiling || bDisableSpecializedShaders) &&
|
||||
CanUseUberShaders();
|
||||
}
|
||||
|
||||
bool VideoConfig::CanBackgroundCompileShaders() const
|
||||
{
|
||||
// We require precompiled ubershaders to background compile shaders.
|
||||
return bBackgroundShaderCompiling && bPrecompileUberShaders && CanUseUberShaders();
|
||||
}
|
||||
|
@ -168,6 +168,35 @@ 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;
|
||||
|
||||
// Number of shader compiler threads.
|
||||
// 0 disables background compilation.
|
||||
// -1 uses an automatic number based on the CPU threads.
|
||||
int iShaderCompilerThreads;
|
||||
|
||||
// Temporary toggling of ubershaders, for debugging
|
||||
bool bForceVertexUberShaders;
|
||||
bool bForcePixelUberShaders;
|
||||
|
||||
// Static config per API
|
||||
// TODO: Move this out of VideoConfig
|
||||
struct
|
||||
@ -226,6 +255,10 @@ struct VideoConfig final
|
||||
return backend_info.bSupportsGPUTextureDecoding && bEnableGPUTextureDecoding;
|
||||
}
|
||||
bool UseVertexRounding() const { return bVertexRounding && iEFBScale != SCALE_1X; }
|
||||
u32 GetShaderCompilerThreads() const;
|
||||
bool CanUseUberShaders() const;
|
||||
bool CanPrecompileUberShaders() const;
|
||||
bool CanBackgroundCompileShaders() const;
|
||||
};
|
||||
|
||||
extern VideoConfig g_Config;
|
||||
|
Reference in New Issue
Block a user