Core: Add option to force linear texture filtering.

This commit is contained in:
Admiral H. Curtiss 2022-11-14 06:01:19 +01:00
parent abf08b5869
commit 8a3b8a925e
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
12 changed files with 90 additions and 39 deletions

View File

@ -107,8 +107,8 @@ const Info<bool> GFX_MODS_ENABLE{{System::GFX, "Settings", "EnableMods"}, false}
// Graphics.Enhancements
const Info<bool> GFX_ENHANCE_FORCE_FILTERING{{System::GFX, "Enhancements", "ForceFiltering"},
false};
const Info<TextureFilteringMode> GFX_ENHANCE_FORCE_TEXTURE_FILTERING{
{System::GFX, "Enhancements", "ForceTextureFiltering"}, TextureFilteringMode::Default};
const Info<int> GFX_ENHANCE_MAX_ANISOTROPY{{System::GFX, "Enhancements", "MaxAnisotropy"}, 0};
const Info<std::string> GFX_ENHANCE_POST_SHADER{
{System::GFX, "Enhancements", "PostProcessingShader"}, ""};

View File

@ -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<bool> GFX_MODS_ENABLE;
// Graphics.Enhancements
extern const Info<bool> GFX_ENHANCE_FORCE_FILTERING;
extern const Info<TextureFilteringMode> GFX_ENHANCE_FORCE_TEXTURE_FILTERING;
extern const Info<int> GFX_ENHANCE_MAX_ANISOTROPY; // NOTE - this is x in (1 << x)
extern const Info<std::string> GFX_ENHANCE_POST_SHADER;
extern const Info<bool> GFX_ENHANCE_FORCE_TRUE_COLOR;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -7,6 +7,7 @@
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
@ -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<const char*, 3> 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<int>(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.<br><br>Has no impact on performance and causes "
"few graphical issues.<br><br><dolphin_emphasis>If unsure, leave this "
"checked.</dolphin_emphasis>");
static const char TR_FORCE_TEXTURE_FILTERING_DESCRIPTION[] =
QT_TR_NOOP("Filters all textures, including any that the game explicitly set as "
"unfiltered.<br><br>May improve quality of certain textures in some games, but "
"will cause issues in others.<br><br><dolphin_emphasis>If unsure, leave this "
"unchecked.</dolphin_emphasis>");
static const char TR_FORCE_TEXTURE_FILTERING_DESCRIPTION[] = QT_TR_NOOP(
"Override the texture scaling filter selected by the game.<br><br>Any option "
"except 'Default' will alter the look of the game's textures and may cause "
"issues.<br><br><dolphin_emphasis>If unsure, leave this on 'Default'.</dolphin_emphasis>");
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\".<br><br>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));

View File

@ -3,10 +3,13 @@
#pragma once
#include <array>
#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<GraphicsRadioInt*, 3> m_force_texture_filtering;
GraphicsBool* m_widescreen_hack;
GraphicsBool* m_disable_fog;
GraphicsBool* m_force_24bit_color;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;