From 8a3b8a925ee57c6538142758328416471aae42fa Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Mon, 14 Nov 2022 06:01:19 +0100 Subject: [PATCH 1/3] Core: Add option to force linear texture filtering. --- Source/Core/Core/Config/GraphicsSettings.cpp | 4 +- Source/Core/Core/Config/GraphicsSettings.h | 3 +- .../ConfigLoaders/NetPlayConfigLoader.cpp | 2 +- Source/Core/Core/NetPlayClient.cpp | 2 +- Source/Core/Core/NetPlayProto.h | 3 +- Source/Core/Core/NetPlayServer.cpp | 4 +- .../Config/Graphics/EnhancementsWidget.cpp | 83 +++++++++++++------ .../Config/Graphics/EnhancementsWidget.h | 5 +- Source/Core/VideoCommon/RenderBase.cpp | 4 +- Source/Core/VideoCommon/TextureCacheBase.cpp | 8 +- Source/Core/VideoCommon/VideoConfig.cpp | 2 +- Source/Core/VideoCommon/VideoConfig.h | 9 +- 12 files changed, 90 insertions(+), 39 deletions(-) diff --git a/Source/Core/Core/Config/GraphicsSettings.cpp b/Source/Core/Core/Config/GraphicsSettings.cpp index 3d99d06be4..5db6e93830 100644 --- a/Source/Core/Core/Config/GraphicsSettings.cpp +++ b/Source/Core/Core/Config/GraphicsSettings.cpp @@ -107,8 +107,8 @@ const Info GFX_MODS_ENABLE{{System::GFX, "Settings", "EnableMods"}, false} // Graphics.Enhancements -const Info GFX_ENHANCE_FORCE_FILTERING{{System::GFX, "Enhancements", "ForceFiltering"}, - false}; +const Info GFX_ENHANCE_FORCE_TEXTURE_FILTERING{ + {System::GFX, "Enhancements", "ForceTextureFiltering"}, TextureFilteringMode::Default}; const Info GFX_ENHANCE_MAX_ANISOTROPY{{System::GFX, "Enhancements", "MaxAnisotropy"}, 0}; const Info GFX_ENHANCE_POST_SHADER{ {System::GFX, "Enhancements", "PostProcessingShader"}, ""}; diff --git a/Source/Core/Core/Config/GraphicsSettings.h b/Source/Core/Core/Config/GraphicsSettings.h index cd75b068a4..601ae56263 100644 --- a/Source/Core/Core/Config/GraphicsSettings.h +++ b/Source/Core/Core/Config/GraphicsSettings.h @@ -10,6 +10,7 @@ enum class AspectMode : int; enum class ShaderCompilationMode : int; enum class StereoMode : int; +enum class TextureFilteringMode : int; enum class TriState : int; namespace Config @@ -92,7 +93,7 @@ extern const Info GFX_MODS_ENABLE; // Graphics.Enhancements -extern const Info GFX_ENHANCE_FORCE_FILTERING; +extern const Info GFX_ENHANCE_FORCE_TEXTURE_FILTERING; extern const Info GFX_ENHANCE_MAX_ANISOTROPY; // NOTE - this is x in (1 << x) extern const Info GFX_ENHANCE_POST_SHADER; extern const Info GFX_ENHANCE_FORCE_TRUE_COLOR; diff --git a/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp index 1c7584203f..75b1bda454 100644 --- a/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp @@ -104,7 +104,7 @@ public: layer->Set(Config::GFX_FAST_DEPTH_CALC, m_settings.fast_depth_calc); layer->Set(Config::GFX_ENABLE_PIXEL_LIGHTING, m_settings.enable_pixel_lighting); layer->Set(Config::GFX_WIDESCREEN_HACK, m_settings.widescreen_hack); - layer->Set(Config::GFX_ENHANCE_FORCE_FILTERING, m_settings.force_filtering); + layer->Set(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, m_settings.force_texture_filtering); layer->Set(Config::GFX_ENHANCE_MAX_ANISOTROPY, m_settings.max_anisotropy); layer->Set(Config::GFX_ENHANCE_FORCE_TRUE_COLOR, m_settings.force_true_color); layer->Set(Config::GFX_ENHANCE_DISABLE_COPY_FILTER, m_settings.disable_copy_filter); diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index 23f7e9fba3..3208caee36 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -872,7 +872,7 @@ void NetPlayClient::OnStartGame(sf::Packet& packet) packet >> m_net_settings.fast_depth_calc; packet >> m_net_settings.enable_pixel_lighting; packet >> m_net_settings.widescreen_hack; - packet >> m_net_settings.force_filtering; + packet >> m_net_settings.force_texture_filtering; packet >> m_net_settings.max_anisotropy; packet >> m_net_settings.force_true_color; packet >> m_net_settings.disable_copy_filter; diff --git a/Source/Core/Core/NetPlayProto.h b/Source/Core/Core/NetPlayProto.h index f7137f66d8..5d84e92c78 100644 --- a/Source/Core/Core/NetPlayProto.h +++ b/Source/Core/Core/NetPlayProto.h @@ -13,6 +13,7 @@ #include "Core/HW/EXI/EXI.h" #include "Core/HW/EXI/EXI_Device.h" #include "Core/HW/Sram.h" +#include "VideoCommon/VideoConfig.h" namespace DiscIO { @@ -82,7 +83,7 @@ struct NetSettings bool fast_depth_calc = false; bool enable_pixel_lighting = false; bool widescreen_hack = false; - bool force_filtering = false; + TextureFilteringMode force_texture_filtering = TextureFilteringMode::Default; int max_anisotropy = 0; bool force_true_color = false; bool disable_copy_filter = false; diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index 888c6325bb..7f461f83d4 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -1336,7 +1336,7 @@ bool NetPlayServer::SetupNetSettings() settings.fast_depth_calc = Config::Get(Config::GFX_FAST_DEPTH_CALC); settings.enable_pixel_lighting = Config::Get(Config::GFX_ENABLE_PIXEL_LIGHTING); settings.widescreen_hack = Config::Get(Config::GFX_WIDESCREEN_HACK); - settings.force_filtering = Config::Get(Config::GFX_ENHANCE_FORCE_FILTERING); + settings.force_texture_filtering = Config::Get(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING); settings.max_anisotropy = Config::Get(Config::GFX_ENHANCE_MAX_ANISOTROPY); settings.force_true_color = Config::Get(Config::GFX_ENHANCE_FORCE_TRUE_COLOR); settings.disable_copy_filter = Config::Get(Config::GFX_ENHANCE_DISABLE_COPY_FILTER); @@ -1539,7 +1539,7 @@ bool NetPlayServer::StartGame() spac << m_settings.fast_depth_calc; spac << m_settings.enable_pixel_lighting; spac << m_settings.widescreen_hack; - spac << m_settings.force_filtering; + spac << m_settings.force_texture_filtering; spac << m_settings.max_anisotropy; spac << m_settings.force_true_color; spac << m_settings.disable_copy_filter; diff --git a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp index db5655cb77..8af802aac6 100644 --- a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -16,6 +17,7 @@ #include "DolphinQt/Config/Graphics/GraphicsBool.h" #include "DolphinQt/Config/Graphics/GraphicsChoice.h" +#include "DolphinQt/Config/Graphics/GraphicsRadio.h" #include "DolphinQt/Config/Graphics/GraphicsSlider.h" #include "DolphinQt/Config/Graphics/GraphicsWindow.h" #include "DolphinQt/Config/Graphics/PostProcessingConfigWindow.h" @@ -81,8 +83,19 @@ void EnhancementsWidget::CreateWidgets() m_scaled_efb_copy = new GraphicsBool(tr("Scaled EFB Copy"), Config::GFX_HACK_COPY_EFB_SCALED); m_per_pixel_lighting = new GraphicsBool(tr("Per-Pixel Lighting"), Config::GFX_ENABLE_PIXEL_LIGHTING); - m_force_texture_filtering = - new GraphicsBool(tr("Force Texture Filtering"), Config::GFX_ENHANCE_FORCE_FILTERING); + + const std::array texture_filtering_modes = {{ + QT_TR_NOOP("Default"), + QT_TR_NOOP("Force Nearest"), + QT_TR_NOOP("Force Linear"), + }}; + for (size_t i = 0; i < texture_filtering_modes.size(); ++i) + { + m_force_texture_filtering[i] = + new GraphicsRadioInt(tr(texture_filtering_modes[i]), + Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, static_cast(i)); + } + m_widescreen_hack = new GraphicsBool(tr("Widescreen Hack"), Config::GFX_WIDESCREEN_HACK); m_disable_fog = new GraphicsBool(tr("Disable Fog"), Config::GFX_DISABLE_FOG); m_force_24bit_color = @@ -92,25 +105,45 @@ void EnhancementsWidget::CreateWidgets() m_arbitrary_mipmap_detection = new GraphicsBool(tr("Arbitrary Mipmap Detection"), Config::GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION); - enhancements_layout->addWidget(new QLabel(tr("Internal Resolution:")), 0, 0); - enhancements_layout->addWidget(m_ir_combo, 0, 1, 1, -1); - enhancements_layout->addWidget(new QLabel(tr("Anti-Aliasing:")), 1, 0); - enhancements_layout->addWidget(m_aa_combo, 1, 1, 1, -1); - enhancements_layout->addWidget(new QLabel(tr("Anisotropic Filtering:")), 2, 0); - enhancements_layout->addWidget(m_af_combo, 2, 1, 1, -1); + int row = 0; + enhancements_layout->addWidget(new QLabel(tr("Internal Resolution:")), row, 0); + enhancements_layout->addWidget(m_ir_combo, row, 1, 1, -1); + ++row; - enhancements_layout->addWidget(new QLabel(tr("Post-Processing Effect:")), 4, 0); - enhancements_layout->addWidget(m_pp_effect, 4, 1); - enhancements_layout->addWidget(m_configure_pp_effect, 4, 2); + enhancements_layout->addWidget(new QLabel(tr("Anti-Aliasing:")), row, 0); + enhancements_layout->addWidget(m_aa_combo, row, 1, 1, -1); + ++row; - enhancements_layout->addWidget(m_scaled_efb_copy, 5, 0); - enhancements_layout->addWidget(m_per_pixel_lighting, 5, 1); - enhancements_layout->addWidget(m_force_texture_filtering, 6, 0); - enhancements_layout->addWidget(m_widescreen_hack, 6, 1); - enhancements_layout->addWidget(m_disable_fog, 7, 0); - enhancements_layout->addWidget(m_force_24bit_color, 7, 1); - enhancements_layout->addWidget(m_disable_copy_filter, 8, 0); - enhancements_layout->addWidget(m_arbitrary_mipmap_detection, 8, 1); + enhancements_layout->addWidget(new QLabel(tr("Anisotropic Filtering:")), row, 0); + enhancements_layout->addWidget(m_af_combo, row, 1, 1, -1); + ++row; + + enhancements_layout->addWidget(new QLabel(tr("Texture Filtering:")), row, 0); + auto* force_filtering_box = new QHBoxLayout(); + for (size_t i = 0; i < texture_filtering_modes.size(); ++i) + force_filtering_box->addWidget(m_force_texture_filtering[i]); + enhancements_layout->addLayout(force_filtering_box, row, 1, 1, -1); + ++row; + + enhancements_layout->addWidget(new QLabel(tr("Post-Processing Effect:")), row, 0); + enhancements_layout->addWidget(m_pp_effect, row, 1); + enhancements_layout->addWidget(m_configure_pp_effect, row, 2); + ++row; + + enhancements_layout->addWidget(m_scaled_efb_copy, row, 0); + enhancements_layout->addWidget(m_per_pixel_lighting, row, 1, 1, -1); + ++row; + + enhancements_layout->addWidget(m_widescreen_hack, row, 0); + enhancements_layout->addWidget(m_force_24bit_color, row, 1, 1, -1); + ++row; + + enhancements_layout->addWidget(m_disable_fog, row, 0); + enhancements_layout->addWidget(m_arbitrary_mipmap_detection, row, 1, 1, -1); + ++row; + + enhancements_layout->addWidget(m_disable_copy_filter, row, 0); + ++row; // Stereoscopy auto* stereoscopy_box = new QGroupBox(tr("Stereoscopy")); @@ -352,11 +385,10 @@ void EnhancementsWidget::AddDescriptions() "quality by reducing color banding.

Has no impact on performance and causes " "few graphical issues.

If unsure, leave this " "checked."); - static const char TR_FORCE_TEXTURE_FILTERING_DESCRIPTION[] = - QT_TR_NOOP("Filters all textures, including any that the game explicitly set as " - "unfiltered.

May improve quality of certain textures in some games, but " - "will cause issues in others.

If unsure, leave this " - "unchecked."); + static const char TR_FORCE_TEXTURE_FILTERING_DESCRIPTION[] = QT_TR_NOOP( + "Override the texture scaling filter selected by the game.

Any option " + "except 'Default' will alter the look of the game's textures and may cause " + "issues.

If unsure, leave this on 'Default'."); static const char TR_DISABLE_COPY_FILTER_DESCRIPTION[] = QT_TR_NOOP( "Disables the blending of adjacent rows when copying the EFB. This is known in " "some games as \"deflickering\" or \"smoothing\".

Disabling the filter has no " @@ -394,7 +426,8 @@ void EnhancementsWidget::AddDescriptions() m_force_24bit_color->SetDescription(tr(TR_FORCE_24BIT_DESCRIPTION)); - m_force_texture_filtering->SetDescription(tr(TR_FORCE_TEXTURE_FILTERING_DESCRIPTION)); + for (size_t i = 0; i < m_force_texture_filtering.size(); ++i) + m_force_texture_filtering[i]->SetDescription(tr(TR_FORCE_TEXTURE_FILTERING_DESCRIPTION)); m_disable_copy_filter->SetDescription(tr(TR_DISABLE_COPY_FILTER_DESCRIPTION)); diff --git a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h index 6054820df1..c0bcfcff2a 100644 --- a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h +++ b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h @@ -3,10 +3,13 @@ #pragma once +#include + #include "DolphinQt/Config/Graphics/GraphicsWidget.h" class GraphicsBool; class GraphicsChoice; +class GraphicsRadioInt; class GraphicsSlider; class GraphicsWindow; class QCheckBox; @@ -39,7 +42,7 @@ private: QPushButton* m_configure_pp_effect; GraphicsBool* m_scaled_efb_copy; GraphicsBool* m_per_pixel_lighting; - GraphicsBool* m_force_texture_filtering; + std::array m_force_texture_filtering; GraphicsBool* m_widescreen_hack; GraphicsBool* m_disable_fog; GraphicsBool* m_force_24bit_color; diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 0a8cef3290..344d9059bb 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -480,7 +480,7 @@ void Renderer::CheckForConfigChanges() const u32 old_multisamples = g_ActiveConfig.iMultisamples; const int old_anisotropy = g_ActiveConfig.iMaxAnisotropy; const int old_efb_access_tile_size = g_ActiveConfig.iEFBAccessTileSize; - const bool old_force_filtering = g_ActiveConfig.bForceFiltering; + const auto old_texture_filtering_mode = g_ActiveConfig.texture_filtering_mode; const bool old_vsync = g_ActiveConfig.bVSyncActive; const bool old_bbox = g_ActiveConfig.bBBoxEnable; const u32 old_game_mod_changes = @@ -533,7 +533,7 @@ void Renderer::CheckForConfigChanges() changed_bits |= CONFIG_CHANGE_BIT_MULTISAMPLES; if (old_anisotropy != g_ActiveConfig.iMaxAnisotropy) changed_bits |= CONFIG_CHANGE_BIT_ANISOTROPY; - if (old_force_filtering != g_ActiveConfig.bForceFiltering) + if (old_texture_filtering_mode != g_ActiveConfig.texture_filtering_mode) changed_bits |= CONFIG_CHANGE_BIT_FORCE_TEXTURE_FILTERING; if (old_vsync != g_ActiveConfig.bVSyncActive) changed_bits |= CONFIG_CHANGE_BIT_VSYNC; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index f5dbb6b3fc..e6fa4f6fbe 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -1001,7 +1001,13 @@ static void SetSamplerState(u32 index, float custom_tex_scale, bool custom_tex, state.Generate(bpmem, index); // Force texture filtering config option. - if (g_ActiveConfig.bForceFiltering) + if (g_ActiveConfig.texture_filtering_mode == TextureFilteringMode::Nearest) + { + state.tm0.min_filter = FilterMode::Near; + state.tm0.mag_filter = FilterMode::Near; + state.tm0.mipmap_filter = FilterMode::Near; + } + else if (g_ActiveConfig.texture_filtering_mode == TextureFilteringMode::Linear) { state.tm0.min_filter = FilterMode::Linear; state.tm0.mag_filter = FilterMode::Linear; diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index 4e66c9d822..9769b46668 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -111,7 +111,7 @@ void VideoConfig::Refresh() iShaderCompilerThreads = Config::Get(Config::GFX_SHADER_COMPILER_THREADS); iShaderPrecompilerThreads = Config::Get(Config::GFX_SHADER_PRECOMPILER_THREADS); - bForceFiltering = Config::Get(Config::GFX_ENHANCE_FORCE_FILTERING); + texture_filtering_mode = Config::Get(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING); iMaxAnisotropy = Config::Get(Config::GFX_ENHANCE_MAX_ANISOTROPY); sPostProcessingShader = Config::Get(Config::GFX_ENHANCE_POST_SHADER); bForceTrueColor = Config::Get(Config::GFX_ENHANCE_FORCE_TRUE_COLOR); diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index 2bdf4b2835..b1b776ab80 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -45,6 +45,13 @@ enum class ShaderCompilationMode : int AsynchronousSkipRendering }; +enum class TextureFilteringMode : int +{ + Default, + Nearest, + Linear, +}; + enum class TriState : int { Off, @@ -72,7 +79,7 @@ struct VideoConfig final u32 iMultisamples = 0; bool bSSAA = false; int iEFBScale = 0; - bool bForceFiltering = false; + TextureFilteringMode texture_filtering_mode = TextureFilteringMode::Default; int iMaxAnisotropy = 0; std::string sPostProcessingShader; bool bForceTrueColor = false; From ff2cc4d02b32c99ddbecd02e4ceb6988f48847d9 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sun, 20 Nov 2022 23:25:35 +0100 Subject: [PATCH 2/3] Qt/EnhancementsWidget: Convert texture filtering option to a ComboBox. --- .../Config/Graphics/EnhancementsWidget.cpp | 27 +++++-------------- .../Config/Graphics/EnhancementsWidget.h | 3 +-- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp index 8af802aac6..55a1f2e4aa 100644 --- a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include #include @@ -77,6 +76,9 @@ void EnhancementsWidget::CreateWidgets() m_aa_combo = new ToolTipComboBox(); m_af_combo = new GraphicsChoice({tr("1x"), tr("2x"), tr("4x"), tr("8x"), tr("16x")}, Config::GFX_ENHANCE_MAX_ANISOTROPY); + m_texture_filtering_combo = + new GraphicsChoice({tr("Default"), tr("Force Nearest"), tr("Force Linear")}, + Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING); m_pp_effect = new ToolTipComboBox(); m_configure_pp_effect = new NonDefaultQPushButton(tr("Configure")); @@ -84,18 +86,6 @@ void EnhancementsWidget::CreateWidgets() m_per_pixel_lighting = new GraphicsBool(tr("Per-Pixel Lighting"), Config::GFX_ENABLE_PIXEL_LIGHTING); - const std::array texture_filtering_modes = {{ - QT_TR_NOOP("Default"), - QT_TR_NOOP("Force Nearest"), - QT_TR_NOOP("Force Linear"), - }}; - for (size_t i = 0; i < texture_filtering_modes.size(); ++i) - { - m_force_texture_filtering[i] = - new GraphicsRadioInt(tr(texture_filtering_modes[i]), - Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, static_cast(i)); - } - m_widescreen_hack = new GraphicsBool(tr("Widescreen Hack"), Config::GFX_WIDESCREEN_HACK); m_disable_fog = new GraphicsBool(tr("Disable Fog"), Config::GFX_DISABLE_FOG); m_force_24bit_color = @@ -119,10 +109,7 @@ void EnhancementsWidget::CreateWidgets() ++row; enhancements_layout->addWidget(new QLabel(tr("Texture Filtering:")), row, 0); - auto* force_filtering_box = new QHBoxLayout(); - for (size_t i = 0; i < texture_filtering_modes.size(); ++i) - force_filtering_box->addWidget(m_force_texture_filtering[i]); - enhancements_layout->addLayout(force_filtering_box, row, 1, 1, -1); + enhancements_layout->addWidget(m_texture_filtering_combo, row, 1, 1, -1); ++row; enhancements_layout->addWidget(new QLabel(tr("Post-Processing Effect:")), row, 0); @@ -413,6 +400,9 @@ void EnhancementsWidget::AddDescriptions() m_af_combo->SetTitle(tr("Anisotropic Filtering")); m_af_combo->SetDescription(tr(TR_ANISOTROPIC_FILTERING_DESCRIPTION)); + m_texture_filtering_combo->SetTitle(tr("Texture Filtering")); + m_texture_filtering_combo->SetDescription(tr(TR_FORCE_TEXTURE_FILTERING_DESCRIPTION)); + m_pp_effect->SetTitle(tr("Post-Processing Effect")); m_pp_effect->SetDescription(tr(TR_POSTPROCESSING_DESCRIPTION)); @@ -426,9 +416,6 @@ void EnhancementsWidget::AddDescriptions() m_force_24bit_color->SetDescription(tr(TR_FORCE_24BIT_DESCRIPTION)); - for (size_t i = 0; i < m_force_texture_filtering.size(); ++i) - m_force_texture_filtering[i]->SetDescription(tr(TR_FORCE_TEXTURE_FILTERING_DESCRIPTION)); - m_disable_copy_filter->SetDescription(tr(TR_DISABLE_COPY_FILTER_DESCRIPTION)); m_arbitrary_mipmap_detection->SetDescription(tr(TR_ARBITRARY_MIPMAP_DETECTION_DESCRIPTION)); diff --git a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h index c0bcfcff2a..057bcc8bf8 100644 --- a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h +++ b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h @@ -9,7 +9,6 @@ class GraphicsBool; class GraphicsChoice; -class GraphicsRadioInt; class GraphicsSlider; class GraphicsWindow; class QCheckBox; @@ -38,11 +37,11 @@ private: GraphicsChoice* m_ir_combo; ToolTipComboBox* m_aa_combo; GraphicsChoice* m_af_combo; + GraphicsChoice* m_texture_filtering_combo; ToolTipComboBox* m_pp_effect; QPushButton* m_configure_pp_effect; GraphicsBool* m_scaled_efb_copy; GraphicsBool* m_per_pixel_lighting; - std::array m_force_texture_filtering; GraphicsBool* m_widescreen_hack; GraphicsBool* m_disable_fog; GraphicsBool* m_force_24bit_color; From 1d199f466443b6aba7906b1fd4dfd95e87bfada8 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Mon, 21 Nov 2022 00:27:35 +0100 Subject: [PATCH 3/3] Qt/EnhancementsWidget: Combine texture filtering and anisotropic filtering. --- .../Config/Graphics/EnhancementsWidget.cpp | 143 +++++++++++++++--- .../Config/Graphics/EnhancementsWidget.h | 3 +- 2 files changed, 122 insertions(+), 24 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp index 55a1f2e4aa..dd1d67b04b 100644 --- a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp @@ -40,6 +40,18 @@ EnhancementsWidget::EnhancementsWidget(GraphicsWindow* parent) : m_block_save(fa [this](const QString& backend) { LoadSettings(); }); } +constexpr int TEXTURE_FILTERING_DEFAULT = 0; +constexpr int TEXTURE_FILTERING_ANISO_2X = 1; +constexpr int TEXTURE_FILTERING_ANISO_4X = 2; +constexpr int TEXTURE_FILTERING_ANISO_8X = 3; +constexpr int TEXTURE_FILTERING_ANISO_16X = 4; +constexpr int TEXTURE_FILTERING_FORCE_NEAREST = 5; +constexpr int TEXTURE_FILTERING_FORCE_LINEAR = 6; +constexpr int TEXTURE_FILTERING_FORCE_LINEAR_ANISO_2X = 7; +constexpr int TEXTURE_FILTERING_FORCE_LINEAR_ANISO_4X = 8; +constexpr int TEXTURE_FILTERING_FORCE_LINEAR_ANISO_8X = 9; +constexpr int TEXTURE_FILTERING_FORCE_LINEAR_ANISO_16X = 10; + void EnhancementsWidget::CreateWidgets() { auto* main_layout = new QVBoxLayout; @@ -74,11 +86,23 @@ void EnhancementsWidget::CreateWidgets() m_ir_combo->setMaxVisibleItems(visible_resolution_option_count); m_aa_combo = new ToolTipComboBox(); - m_af_combo = new GraphicsChoice({tr("1x"), tr("2x"), tr("4x"), tr("8x"), tr("16x")}, - Config::GFX_ENHANCE_MAX_ANISOTROPY); - m_texture_filtering_combo = - new GraphicsChoice({tr("Default"), tr("Force Nearest"), tr("Force Linear")}, - Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING); + + m_texture_filtering_combo = new ToolTipComboBox(); + m_texture_filtering_combo->addItem(tr("Default"), TEXTURE_FILTERING_DEFAULT); + m_texture_filtering_combo->addItem(tr("2x Anisotropic"), TEXTURE_FILTERING_ANISO_2X); + m_texture_filtering_combo->addItem(tr("4x Anisotropic"), TEXTURE_FILTERING_ANISO_4X); + m_texture_filtering_combo->addItem(tr("8x Anisotropic"), TEXTURE_FILTERING_ANISO_8X); + m_texture_filtering_combo->addItem(tr("16x Anisotropic"), TEXTURE_FILTERING_ANISO_16X); + m_texture_filtering_combo->addItem(tr("Force Nearest"), TEXTURE_FILTERING_FORCE_NEAREST); + m_texture_filtering_combo->addItem(tr("Force Linear"), TEXTURE_FILTERING_FORCE_LINEAR); + m_texture_filtering_combo->addItem(tr("Force Linear and 2x Anisotropic"), + TEXTURE_FILTERING_FORCE_LINEAR_ANISO_2X); + m_texture_filtering_combo->addItem(tr("Force Linear and 4x Anisotropic"), + TEXTURE_FILTERING_FORCE_LINEAR_ANISO_4X); + m_texture_filtering_combo->addItem(tr("Force Linear and 8x Anisotropic"), + TEXTURE_FILTERING_FORCE_LINEAR_ANISO_8X); + m_texture_filtering_combo->addItem(tr("Force Linear and 16x Anisotropic"), + TEXTURE_FILTERING_FORCE_LINEAR_ANISO_16X); m_pp_effect = new ToolTipComboBox(); m_configure_pp_effect = new NonDefaultQPushButton(tr("Configure")); @@ -104,10 +128,6 @@ void EnhancementsWidget::CreateWidgets() enhancements_layout->addWidget(m_aa_combo, row, 1, 1, -1); ++row; - enhancements_layout->addWidget(new QLabel(tr("Anisotropic Filtering:")), row, 0); - enhancements_layout->addWidget(m_af_combo, row, 1, 1, -1); - ++row; - enhancements_layout->addWidget(new QLabel(tr("Texture Filtering:")), row, 0); enhancements_layout->addWidget(m_texture_filtering_combo, row, 1, 1, -1); ++row; @@ -164,6 +184,8 @@ void EnhancementsWidget::ConnectWidgets() { connect(m_aa_combo, qOverload(&QComboBox::currentIndexChanged), [this](int) { SaveSettings(); }); + connect(m_texture_filtering_combo, qOverload(&QComboBox::currentIndexChanged), + [this](int) { SaveSettings(); }); connect(m_pp_effect, qOverload(&QComboBox::currentIndexChanged), [this](int) { SaveSettings(); }); connect(m_3d_mode, qOverload(&QComboBox::currentIndexChanged), [this] { @@ -238,8 +260,11 @@ void EnhancementsWidget::LoadSettings() m_block_save = true; // Anti-Aliasing - int aa_selection = Config::Get(Config::GFX_MSAA); - bool ssaa = Config::Get(Config::GFX_SSAA); + const int aa_selection = Config::Get(Config::GFX_MSAA); + const bool ssaa = Config::Get(Config::GFX_SSAA); + const int aniso = Config::Get(Config::GFX_ENHANCE_MAX_ANISOTROPY); + const TextureFilteringMode tex_filter_mode = + Config::Get(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING); m_aa_combo->clear(); for (const auto& option : VideoUtils::GetAvailableAntialiasingModes(m_msaa_modes)) @@ -249,6 +274,25 @@ void EnhancementsWidget::LoadSettings() QString::fromStdString(std::to_string(aa_selection) + "x " + (ssaa ? "SSAA" : "MSAA"))); m_aa_combo->setEnabled(m_aa_combo->count() > 1); + switch (tex_filter_mode) + { + case TextureFilteringMode::Default: + if (aniso >= 0 && aniso <= 4) + m_texture_filtering_combo->setCurrentIndex(aniso); + else + m_texture_filtering_combo->setCurrentIndex(TEXTURE_FILTERING_DEFAULT); + break; + case TextureFilteringMode::Nearest: + m_texture_filtering_combo->setCurrentIndex(TEXTURE_FILTERING_FORCE_NEAREST); + break; + case TextureFilteringMode::Linear: + if (aniso >= 0 && aniso <= 4) + m_texture_filtering_combo->setCurrentIndex(TEXTURE_FILTERING_FORCE_LINEAR + aniso); + else + m_texture_filtering_combo->setCurrentIndex(TEXTURE_FILTERING_FORCE_LINEAR); + break; + } + // Post Processing Shader LoadPPShaders(); @@ -284,6 +328,66 @@ void EnhancementsWidget::SaveSettings() Config::SetBaseOrCurrent(Config::GFX_SSAA, is_ssaa); + const int texture_filtering_selection = m_texture_filtering_combo->currentData().toInt(); + switch (texture_filtering_selection) + { + case TEXTURE_FILTERING_DEFAULT: + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 0); + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, + TextureFilteringMode::Default); + break; + case TEXTURE_FILTERING_ANISO_2X: + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 1); + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, + TextureFilteringMode::Default); + break; + case TEXTURE_FILTERING_ANISO_4X: + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 2); + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, + TextureFilteringMode::Default); + break; + case TEXTURE_FILTERING_ANISO_8X: + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 3); + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, + TextureFilteringMode::Default); + break; + case TEXTURE_FILTERING_ANISO_16X: + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 4); + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, + TextureFilteringMode::Default); + break; + case TEXTURE_FILTERING_FORCE_NEAREST: + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 0); + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, + TextureFilteringMode::Nearest); + break; + case TEXTURE_FILTERING_FORCE_LINEAR: + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 0); + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, + TextureFilteringMode::Linear); + break; + case TEXTURE_FILTERING_FORCE_LINEAR_ANISO_2X: + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 1); + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, + TextureFilteringMode::Linear); + break; + case TEXTURE_FILTERING_FORCE_LINEAR_ANISO_4X: + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 2); + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, + TextureFilteringMode::Linear); + break; + case TEXTURE_FILTERING_FORCE_LINEAR_ANISO_8X: + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 3); + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, + TextureFilteringMode::Linear); + break; + case TEXTURE_FILTERING_FORCE_LINEAR_ANISO_16X: + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 4); + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, + TextureFilteringMode::Linear); + break; + } + const bool anaglyph = g_Config.stereo_mode == StereoMode::Anaglyph; const bool passive = g_Config.stereo_mode == StereoMode::Passive; Config::SetBaseOrCurrent(Config::GFX_ENHANCE_POST_SHADER, @@ -320,10 +424,12 @@ void EnhancementsWidget::AddDescriptions() "geometry anti-aliasing and also applies anti-aliasing to lighting, shader " "effects, and textures.

If unsure, select " "None."); - static const char TR_ANISOTROPIC_FILTERING_DESCRIPTION[] = QT_TR_NOOP( - "Enables anisotropic filtering, which enhances the visual quality of textures that " - "are at oblique viewing angles.

Might cause issues in a small " - "number of games.

If unsure, select 1x."); + static const char TR_FORCE_TEXTURE_FILTERING_DESCRIPTION[] = QT_TR_NOOP( + "Adjust the texture filtering. Anisotropic filtering enhances the visual quality of textures " + "that are at oblique viewing angles. Force Nearest and Force Linear override the texture " + "scaling filter selected by the game.

Any option except 'Default' will alter the look " + "of the game's textures and might cause issues in a small number of " + "games.

If unsure, select 'Default'."); static const char TR_POSTPROCESSING_DESCRIPTION[] = QT_TR_NOOP("Applies a post-processing effect after rendering a frame.

If unsure, select (off)."); @@ -372,10 +478,6 @@ void EnhancementsWidget::AddDescriptions() "quality by reducing color banding.

Has no impact on performance and causes " "few graphical issues.

If unsure, leave this " "checked."); - static const char TR_FORCE_TEXTURE_FILTERING_DESCRIPTION[] = QT_TR_NOOP( - "Override the texture scaling filter selected by the game.

Any option " - "except 'Default' will alter the look of the game's textures and may cause " - "issues.

If unsure, leave this on 'Default'."); static const char TR_DISABLE_COPY_FILTER_DESCRIPTION[] = QT_TR_NOOP( "Disables the blending of adjacent rows when copying the EFB. This is known in " "some games as \"deflickering\" or \"smoothing\".

Disabling the filter has no " @@ -397,9 +499,6 @@ void EnhancementsWidget::AddDescriptions() m_aa_combo->SetTitle(tr("Anti-Aliasing")); m_aa_combo->SetDescription(tr(TR_ANTIALIAS_DESCRIPTION)); - m_af_combo->SetTitle(tr("Anisotropic Filtering")); - m_af_combo->SetDescription(tr(TR_ANISOTROPIC_FILTERING_DESCRIPTION)); - m_texture_filtering_combo->SetTitle(tr("Texture Filtering")); m_texture_filtering_combo->SetDescription(tr(TR_FORCE_TEXTURE_FILTERING_DESCRIPTION)); diff --git a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h index 057bcc8bf8..ecfe4a9eb8 100644 --- a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h +++ b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h @@ -36,8 +36,7 @@ private: // Enhancements GraphicsChoice* m_ir_combo; ToolTipComboBox* m_aa_combo; - GraphicsChoice* m_af_combo; - GraphicsChoice* m_texture_filtering_combo; + ToolTipComboBox* m_texture_filtering_combo; ToolTipComboBox* m_pp_effect; QPushButton* m_configure_pp_effect; GraphicsBool* m_scaled_efb_copy;