From 2e0ce86c9ef82b92f98695e8ab49e5485e796513 Mon Sep 17 00:00:00 2001 From: tywald Date: Fri, 6 Nov 2020 19:07:59 +0100 Subject: [PATCH] Band-aid solution for 'Disk Shader Cache' (#5188) * Enable 'Accurate Multiplication' by default. * Move 'Disk Shader Cache' to the 'Advanced' tab * Prevent enabling 'Disk Shader Cache' when 'Enable Hardware Shader' or 'Accurate Multiplication' is disabled. * Do not load 'Disk Shader Cache' when 'Accurate Multiplication' is disabled. * Add a tooltip for 'Disk Shader Cache'. --- src/citra/config.cpp | 2 +- src/citra/default_ini.h | 2 +- src/citra_qt/configuration/config.cpp | 12 ++++++------ .../configuration/configure_enhancements.cpp | 6 ------ .../configuration/configure_enhancements.ui | 7 ------- .../configuration/configure_graphics.cpp | 17 +++++++++++++++++ .../configuration/configure_graphics.ui | 10 ++++++++++ .../renderer_opengl/gl_shader_disk_cache.cpp | 4 ++-- 8 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/citra/config.cpp b/src/citra/config.cpp index ff1068169c..5ee624c67c 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -119,7 +119,7 @@ void Config::ReadValues() { sdl2_config->GetBoolean("Renderer", "separable_shader", false); #endif Settings::values.shaders_accurate_mul = - sdl2_config->GetBoolean("Renderer", "shaders_accurate_mul", false); + sdl2_config->GetBoolean("Renderer", "shaders_accurate_mul", true); Settings::values.use_shader_jit = sdl2_config->GetBoolean("Renderer", "use_shader_jit", true); Settings::values.resolution_factor = static_cast(sdl2_config->GetInteger("Renderer", "resolution_factor", 1)); diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index 77dd08a78c..537ecf99bb 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h @@ -115,7 +115,7 @@ use_hw_shader = separable_shader = # Whether to use accurate multiplication in hardware shaders -# 0: Off (Default. Faster, but causes issues in some games) 1: On (Slower, but correct) +# 0: Off (Faster, but causes issues in some games) 1: On (Default. Slower, but correct) shaders_accurate_mul = # Whether to use the Just-In-Time (JIT) compiler for shader emulation diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 820786e82b..8901c47c2d 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -284,8 +284,6 @@ void Config::ReadUtilityValues() { ReadSetting(QStringLiteral("custom_textures"), false).toBool(); Settings::values.preload_textures = ReadSetting(QStringLiteral("preload_textures"), false).toBool(); - Settings::values.use_disk_shader_cache = - ReadSetting(QStringLiteral("use_disk_shader_cache"), true).toBool(); qt_config->endGroup(); } @@ -478,8 +476,10 @@ void Config::ReadRendererValues() { ReadSetting(QStringLiteral("separable_shader"), false).toBool(); #endif Settings::values.shaders_accurate_mul = - ReadSetting(QStringLiteral("shaders_accurate_mul"), false).toBool(); + ReadSetting(QStringLiteral("shaders_accurate_mul"), true).toBool(); Settings::values.use_shader_jit = ReadSetting(QStringLiteral("use_shader_jit"), true).toBool(); + Settings::values.use_disk_shader_cache = + ReadSetting(QStringLiteral("use_disk_shader_cache"), true).toBool(); Settings::values.use_vsync_new = ReadSetting(QStringLiteral("use_vsync_new"), true).toBool(); Settings::values.resolution_factor = static_cast(ReadSetting(QStringLiteral("resolution_factor"), 1).toInt()); @@ -834,8 +834,6 @@ void Config::SaveUtilityValues() { WriteSetting(QStringLiteral("dump_textures"), Settings::values.dump_textures, false); WriteSetting(QStringLiteral("custom_textures"), Settings::values.custom_textures, false); WriteSetting(QStringLiteral("preload_textures"), Settings::values.preload_textures, false); - WriteSetting(QStringLiteral("use_disk_shader_cache"), Settings::values.use_disk_shader_cache, - true); qt_config->endGroup(); } @@ -981,8 +979,10 @@ void Config::SaveRendererValues() { WriteSetting(QStringLiteral("use_separable_shader"), Settings::values.separable_shader, false); #endif WriteSetting(QStringLiteral("shaders_accurate_mul"), Settings::values.shaders_accurate_mul, - false); + true); WriteSetting(QStringLiteral("use_shader_jit"), Settings::values.use_shader_jit, true); + WriteSetting(QStringLiteral("use_disk_shader_cache"), Settings::values.use_disk_shader_cache, + true); WriteSetting(QStringLiteral("use_vsync_new"), Settings::values.use_vsync_new, true); WriteSetting(QStringLiteral("resolution_factor"), Settings::values.resolution_factor, 1); WriteSetting(QStringLiteral("frame_limit"), Settings::values.frame_limit, 100); diff --git a/src/citra_qt/configuration/configure_enhancements.cpp b/src/citra_qt/configuration/configure_enhancements.cpp index 7af72ea773..59c089afbe 100644 --- a/src/citra_qt/configuration/configure_enhancements.cpp +++ b/src/citra_qt/configuration/configure_enhancements.cpp @@ -47,8 +47,6 @@ ConfigureEnhancements::ConfigureEnhancements(QWidget* parent) if (!ui->toggle_preload_textures->isEnabled()) ui->toggle_preload_textures->setChecked(false); }); - - ui->toggle_disk_shader_cache->setEnabled(Settings::values.use_hw_shader); } void ConfigureEnhancements::SetConfiguration() { @@ -66,8 +64,6 @@ void ConfigureEnhancements::SetConfiguration() { } ui->layout_combobox->setCurrentIndex(static_cast(Settings::values.layout_option)); ui->swap_screen->setChecked(Settings::values.swap_screen); - ui->toggle_disk_shader_cache->setChecked(Settings::values.use_hw_shader && - Settings::values.use_disk_shader_cache); ui->upright_screen->setChecked(Settings::values.upright_screen); ui->toggle_dump_textures->setChecked(Settings::values.dump_textures); ui->toggle_custom_textures->setChecked(Settings::values.custom_textures); @@ -117,8 +113,6 @@ void ConfigureEnhancements::ApplyConfiguration() { Settings::values.layout_option = static_cast(ui->layout_combobox->currentIndex()); Settings::values.swap_screen = ui->swap_screen->isChecked(); - Settings::values.use_disk_shader_cache = - Settings::values.use_hw_shader && ui->toggle_disk_shader_cache->isChecked(); Settings::values.upright_screen = ui->upright_screen->isChecked(); Settings::values.dump_textures = ui->toggle_dump_textures->isChecked(); Settings::values.custom_textures = ui->toggle_custom_textures->isChecked(); diff --git a/src/citra_qt/configuration/configure_enhancements.ui b/src/citra_qt/configuration/configure_enhancements.ui index 909a98643c..b56b590042 100644 --- a/src/citra_qt/configuration/configure_enhancements.ui +++ b/src/citra_qt/configuration/configure_enhancements.ui @@ -290,13 +290,6 @@ Utility - - - - Use Disk Shader Cache - - - diff --git a/src/citra_qt/configuration/configure_graphics.cpp b/src/citra_qt/configuration/configure_graphics.cpp index bc15113336..44290f7831 100644 --- a/src/citra_qt/configuration/configure_graphics.cpp +++ b/src/citra_qt/configuration/configure_graphics.cpp @@ -27,6 +27,21 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent) ui->hw_shader_group->setEnabled(ui->toggle_hw_shader->isChecked()); connect(ui->toggle_hw_shader, &QCheckBox::toggled, ui->hw_shader_group, &QWidget::setEnabled); + + ui->toggle_disk_shader_cache->setEnabled(ui->toggle_hw_shader->isChecked() && + ui->toggle_accurate_mul->isChecked()); + connect(ui->toggle_hw_shader, &QCheckBox::toggled, this, [this] { + ui->toggle_disk_shader_cache->setEnabled(ui->toggle_hw_shader->isChecked() && + ui->toggle_accurate_mul->isChecked()); + if (!ui->toggle_disk_shader_cache->isEnabled()) + ui->toggle_disk_shader_cache->setChecked(false); + }); + + connect(ui->toggle_accurate_mul, &QCheckBox::toggled, this, [this] { + ui->toggle_disk_shader_cache->setEnabled(ui->toggle_accurate_mul->isChecked()); + if (!ui->toggle_disk_shader_cache->isEnabled()) + ui->toggle_disk_shader_cache->setChecked(false); + }); #ifdef __APPLE__ connect(ui->toggle_hw_shader, &QCheckBox::stateChanged, this, [this](int state) { if (state == Qt::Checked) { @@ -58,6 +73,7 @@ void ConfigureGraphics::SetConfiguration() { ui->toggle_separable_shader->setChecked(Settings::values.separable_shader); ui->toggle_accurate_mul->setChecked(Settings::values.shaders_accurate_mul); ui->toggle_shader_jit->setChecked(Settings::values.use_shader_jit); + ui->toggle_disk_shader_cache->setChecked(Settings::values.use_disk_shader_cache); ui->toggle_vsync_new->setChecked(Settings::values.use_vsync_new); } @@ -67,6 +83,7 @@ void ConfigureGraphics::ApplyConfiguration() { Settings::values.separable_shader = ui->toggle_separable_shader->isChecked(); Settings::values.shaders_accurate_mul = ui->toggle_accurate_mul->isChecked(); Settings::values.use_shader_jit = ui->toggle_shader_jit->isChecked(); + Settings::values.use_disk_shader_cache = ui->toggle_disk_shader_cache->isChecked(); Settings::values.use_vsync_new = ui->toggle_vsync_new->isChecked(); } diff --git a/src/citra_qt/configuration/configure_graphics.ui b/src/citra_qt/configuration/configure_graphics.ui index f3d1694273..c9eb552a12 100644 --- a/src/citra_qt/configuration/configure_graphics.ui +++ b/src/citra_qt/configuration/configure_graphics.ui @@ -118,6 +118,16 @@ Advanced + + + + <html><head/><body><p>Reduce stuttering by storing and loading generated shaders to disk.</p><p>It cannot be used without Enable Hardware Shader or Accurate Multiplication.</p></body></html> + + + Use Disk Shader Cache + + + diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp index 432421160b..2eca1b4a8a 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp @@ -106,8 +106,8 @@ ShaderDiskCache::ShaderDiskCache(bool separable) : separable{separable} {} std::optional> ShaderDiskCache::LoadTransferable() { const bool has_title_id = GetProgramID() != 0; - if (!Settings::values.use_hw_shader || !Settings::values.use_disk_shader_cache || - !has_title_id) { + if (!Settings::values.use_hw_shader || !Settings::values.shaders_accurate_mul || + !Settings::values.use_disk_shader_cache || !has_title_id) { return std::nullopt; } tried_to_load = true;