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;