diff --git a/src/core/settings.h b/src/core/settings.h index 15b6913420..cb5979e6fe 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -430,6 +430,7 @@ struct Values { float resolution_factor; int aspect_ratio; + int max_anisotropy; bool use_frame_limit; u16 frame_limit; bool use_disk_shader_cache; diff --git a/src/video_core/renderer_opengl/gl_sampler_cache.cpp b/src/video_core/renderer_opengl/gl_sampler_cache.cpp index 3ded5ecea2..5c174879a8 100644 --- a/src/video_core/renderer_opengl/gl_sampler_cache.cpp +++ b/src/video_core/renderer_opengl/gl_sampler_cache.cpp @@ -38,7 +38,7 @@ OGLSampler SamplerCacheOpenGL::CreateSampler(const Tegra::Texture::TSCEntry& tsc glSamplerParameterf(sampler_id, GL_TEXTURE_MAX_ANISOTROPY, tsc.GetMaxAnisotropy()); } else if (GLAD_GL_EXT_texture_filter_anisotropic) { glSamplerParameterf(sampler_id, GL_TEXTURE_MAX_ANISOTROPY_EXT, tsc.GetMaxAnisotropy()); - } else if (tsc.GetMaxAnisotropy() != 1) { + } else { LOG_WARNING(Render_OpenGL, "Anisotropy not supported by host GPU driver"); } diff --git a/src/video_core/textures/texture.h b/src/video_core/textures/texture.h index 8e82c67487..07098c70d9 100644 --- a/src/video_core/textures/texture.h +++ b/src/video_core/textures/texture.h @@ -8,6 +8,7 @@ #include "common/assert.h" #include "common/bit_field.h" #include "common/common_types.h" +#include "core/settings.h" namespace Tegra::Texture { @@ -294,6 +295,14 @@ enum class TextureMipmapFilter : u32 { Linear = 3, }; +enum class Anisotropy { + Default, + Filter2x, + Filter4x, + Filter8x, + Filter16x, +}; + struct TSCEntry { union { struct { @@ -328,7 +337,20 @@ struct TSCEntry { }; float GetMaxAnisotropy() const { - return static_cast(1U << max_anisotropy); + switch (static_cast(Settings::values.max_anisotropy)) { + case Anisotropy::Default: + return static_cast(1U << max_anisotropy); + case Anisotropy::Filter2x: + return static_cast(2U << max_anisotropy); + case Anisotropy::Filter4x: + return static_cast(4U << max_anisotropy); + case Anisotropy::Filter8x: + return static_cast(8U << max_anisotropy); + case Anisotropy::Filter16x: + return static_cast(16U << max_anisotropy); + default: + return static_cast(1U << max_anisotropy); + } } float GetMinLod() const { diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index b841e63fa4..d34b47b3f3 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -42,6 +42,9 @@ add_executable(yuzu configuration/configure_graphics.cpp configuration/configure_graphics.h configuration/configure_graphics.ui + configuration/configure_graphics_advanced.cpp + configuration/configure_graphics_advanced.h + configuration/configure_graphics_advanced.ui configuration/configure_hotkeys.cpp configuration/configure_hotkeys.h configuration/configure_hotkeys.ui diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index d0f574147b..c388606287 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -631,6 +631,7 @@ void Config::ReadRendererValues() { Settings::values.resolution_factor = ReadSetting(QStringLiteral("resolution_factor"), 1.0).toFloat(); Settings::values.aspect_ratio = ReadSetting(QStringLiteral("aspect_ratio"), 0).toInt(); + Settings::values.max_anisotropy = ReadSetting(QStringLiteral("max_anisotropy"), 0).toInt(); Settings::values.use_frame_limit = ReadSetting(QStringLiteral("use_frame_limit"), true).toBool(); Settings::values.frame_limit = ReadSetting(QStringLiteral("frame_limit"), 100).toInt(); @@ -1067,6 +1068,7 @@ void Config::SaveRendererValues() { WriteSetting(QStringLiteral("resolution_factor"), static_cast(Settings::values.resolution_factor), 1.0); WriteSetting(QStringLiteral("aspect_ratio"), Settings::values.aspect_ratio, 0); + WriteSetting(QStringLiteral("max_anisotropy"), Settings::values.max_anisotropy, 0); WriteSetting(QStringLiteral("use_frame_limit"), Settings::values.use_frame_limit, true); WriteSetting(QStringLiteral("frame_limit"), Settings::values.frame_limit, 100); WriteSetting(QStringLiteral("use_disk_shader_cache"), Settings::values.use_disk_shader_cache, diff --git a/src/yuzu/configuration/configure.ui b/src/yuzu/configuration/configure.ui index 67b990f1af..9aec1bd09f 100644 --- a/src/yuzu/configuration/configure.ui +++ b/src/yuzu/configuration/configure.ui @@ -83,6 +83,11 @@ Graphics + + + GraphicsAdvanced + + Audio @@ -159,6 +164,12 @@
configuration/configure_graphics.h
1 + + ConfigureGraphicsAdvanced + QWidget +
configuration/configure_graphics_advanced.h
+ 1 +
ConfigureWeb QWidget diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index db3b193529..df4473b461 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp @@ -41,6 +41,7 @@ void ConfigureDialog::ApplyConfiguration() { ui->inputTab->ApplyConfiguration(); ui->hotkeysTab->ApplyConfiguration(registry); ui->graphicsTab->ApplyConfiguration(); + ui->graphicsAdvancedTab->ApplyConfiguration(); ui->audioTab->ApplyConfiguration(); ui->debugTab->ApplyConfiguration(); ui->webTab->ApplyConfiguration(); @@ -76,7 +77,7 @@ void ConfigureDialog::PopulateSelectionList() { const std::array>, 5> items{ {{tr("General"), {ui->generalTab, ui->webTab, ui->debugTab, ui->uiTab}}, {tr("System"), {ui->systemTab, ui->profileManagerTab, ui->serviceTab, ui->filesystemTab}}, - {tr("Graphics"), {ui->graphicsTab}}, + {tr("Graphics"), {ui->graphicsTab, ui->graphicsAdvancedTab}}, {tr("Audio"), {ui->audioTab}}, {tr("Controls"), {ui->inputTab, ui->hotkeysTab}}}, }; @@ -105,6 +106,7 @@ void ConfigureDialog::UpdateVisibleTabs() { {ui->inputTab, tr("Input")}, {ui->hotkeysTab, tr("Hotkeys")}, {ui->graphicsTab, tr("Graphics")}, + {ui->graphicsAdvancedTab, tr("Advanced")}, {ui->audioTab, tr("Audio")}, {ui->debugTab, tr("Debug")}, {ui->webTab, tr("Web")}, diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index fe64c7d813..a821c7b3cf 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -100,13 +100,8 @@ void ConfigureGraphics::SetConfiguration() { ui->aspect_ratio_combobox->setCurrentIndex(Settings::values.aspect_ratio); ui->use_disk_shader_cache->setEnabled(runtime_lock); ui->use_disk_shader_cache->setChecked(Settings::values.use_disk_shader_cache); - ui->use_accurate_gpu_emulation->setChecked(Settings::values.use_accurate_gpu_emulation); ui->use_asynchronous_gpu_emulation->setEnabled(runtime_lock); ui->use_asynchronous_gpu_emulation->setChecked(Settings::values.use_asynchronous_gpu_emulation); - ui->use_vsync->setEnabled(runtime_lock); - ui->use_vsync->setChecked(Settings::values.use_vsync); - ui->force_30fps_mode->setEnabled(runtime_lock); - ui->force_30fps_mode->setChecked(Settings::values.force_30fps_mode); UpdateBackgroundColorButton(QColor::fromRgbF(Settings::values.bg_red, Settings::values.bg_green, Settings::values.bg_blue)); UpdateDeviceComboBox(); @@ -119,11 +114,8 @@ void ConfigureGraphics::ApplyConfiguration() { ToResolutionFactor(static_cast(ui->resolution_factor_combobox->currentIndex())); Settings::values.aspect_ratio = ui->aspect_ratio_combobox->currentIndex(); Settings::values.use_disk_shader_cache = ui->use_disk_shader_cache->isChecked(); - Settings::values.use_accurate_gpu_emulation = ui->use_accurate_gpu_emulation->isChecked(); Settings::values.use_asynchronous_gpu_emulation = ui->use_asynchronous_gpu_emulation->isChecked(); - Settings::values.use_vsync = ui->use_vsync->isChecked(); - Settings::values.force_30fps_mode = ui->force_30fps_mode->isChecked(); Settings::values.bg_red = static_cast(bg_color.redF()); Settings::values.bg_green = static_cast(bg_color.greenF()); Settings::values.bg_blue = static_cast(bg_color.blueF()); diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui index 9acc7dd937..c816d6108a 100644 --- a/src/yuzu/configuration/configure_graphics.ui +++ b/src/yuzu/configuration/configure_graphics.ui @@ -84,30 +84,6 @@
- - - - VSync prevents the screen from tearing, but some graphics cards have lower performance with VSync enabled. Keep it enabled if you don't notice a performance difference. - - - Use VSync (OpenGL only) - - - - - - - Use accurate GPU emulation (slow) - - - - - - - Force 30 FPS mode - - - diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp new file mode 100644 index 0000000000..b9f429f840 --- /dev/null +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp @@ -0,0 +1,48 @@ +// Copyright 2020 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/core.h" +#include "core/settings.h" +#include "ui_configure_graphics_advanced.h" +#include "yuzu/configuration/configure_graphics_advanced.h" + +ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(QWidget* parent) + : QWidget(parent), ui(new Ui::ConfigureGraphicsAdvanced) { + + ui->setupUi(this); + + SetConfiguration(); +} + +ConfigureGraphicsAdvanced::~ConfigureGraphicsAdvanced() = default; + +void ConfigureGraphicsAdvanced::SetConfiguration() { + const bool runtime_lock = !Core::System::GetInstance().IsPoweredOn(); + ui->use_accurate_gpu_emulation->setChecked(Settings::values.use_accurate_gpu_emulation); + ui->use_vsync->setEnabled(runtime_lock); + ui->use_vsync->setChecked(Settings::values.use_vsync); + ui->force_30fps_mode->setEnabled(runtime_lock); + ui->force_30fps_mode->setChecked(Settings::values.force_30fps_mode); + ui->anisotropic_filtering_combobox->setEnabled(runtime_lock); + ui->anisotropic_filtering_combobox->setCurrentIndex(Settings::values.max_anisotropy); +} + +void ConfigureGraphicsAdvanced::ApplyConfiguration() { + Settings::values.use_accurate_gpu_emulation = ui->use_accurate_gpu_emulation->isChecked(); + Settings::values.use_vsync = ui->use_vsync->isChecked(); + Settings::values.force_30fps_mode = ui->force_30fps_mode->isChecked(); + Settings::values.max_anisotropy = ui->anisotropic_filtering_combobox->currentIndex(); +} + +void ConfigureGraphicsAdvanced::changeEvent(QEvent* event) { + if (event->type() == QEvent::LanguageChange) { + RetranslateUI(); + } + + QWidget::changeEvent(event); +} + +void ConfigureGraphicsAdvanced::RetranslateUI() { + ui->retranslateUi(this); +} diff --git a/src/yuzu/configuration/configure_graphics_advanced.h b/src/yuzu/configuration/configure_graphics_advanced.h new file mode 100644 index 0000000000..bbc9d43551 --- /dev/null +++ b/src/yuzu/configuration/configure_graphics_advanced.h @@ -0,0 +1,30 @@ +// Copyright 2020 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +namespace Ui { +class ConfigureGraphicsAdvanced; +} + +class ConfigureGraphicsAdvanced : public QWidget { + Q_OBJECT + +public: + explicit ConfigureGraphicsAdvanced(QWidget* parent = nullptr); + ~ConfigureGraphicsAdvanced() override; + + void ApplyConfiguration(); + +private: + void changeEvent(QEvent* event) override; + void RetranslateUI(); + + void SetConfiguration(); + + std::unique_ptr ui; +}; diff --git a/src/yuzu/configuration/configure_graphics_advanced.ui b/src/yuzu/configuration/configure_graphics_advanced.ui new file mode 100644 index 0000000000..42eec278ed --- /dev/null +++ b/src/yuzu/configuration/configure_graphics_advanced.ui @@ -0,0 +1,111 @@ + + + ConfigureGraphicsAdvanced + + + + 0 + 0 + 400 + 321 + + + + Form + + + + + + + + Advanced Graphics Settings + + + + + + Use accurate GPU emulation (slow) + + + + + + + VSync prevents the screen from tearing, but some graphics cards have lower performance with VSync enabled. Keep it enabled if you don't notice a performance difference. + + + Use VSync (OpenGL only) + + + + + + + Force 30 FPS mode + + + + + + + + + Anisotropic Filtering: + + + + + + + + Default + + + + + 2x + + + + + 4x + + + + + 8x + + + + + 16x + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index b77c12bafb..907abaa51f 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp @@ -381,6 +381,8 @@ void Config::ReadValues() { static_cast(sdl2_config->GetReal("Renderer", "resolution_factor", 1.0)); Settings::values.aspect_ratio = static_cast(sdl2_config->GetInteger("Renderer", "aspect_ratio", 0)); + Settings::values.max_anisotropy = + static_cast(sdl2_config->GetInteger("Renderer", "max_anisotropy", 0)); Settings::values.use_frame_limit = sdl2_config->GetBoolean("Renderer", "use_frame_limit", true); Settings::values.frame_limit = static_cast(sdl2_config->GetInteger("Renderer", "frame_limit", 100)); diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index df74738581..67c5de1da5 100644 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h @@ -126,6 +126,10 @@ resolution_factor = # 0: Default (16:9), 1: Force 4:3, 2: Force 21:9, 3: Stretch to Window aspect_ratio = +# Anisotropic filtering +# 0: Default, 1: 2x, 2: 4x, 3: 8x, 4: 16x +max_anisotropy = + # Whether to enable V-Sync (caps the framerate at 60FPS) or not. # 0 (default): Off, 1: On use_vsync = diff --git a/src/yuzu_tester/config.cpp b/src/yuzu_tester/config.cpp index 0ac93b62a6..ee2591c8fb 100644 --- a/src/yuzu_tester/config.cpp +++ b/src/yuzu_tester/config.cpp @@ -120,6 +120,8 @@ void Config::ReadValues() { static_cast(sdl2_config->GetReal("Renderer", "resolution_factor", 1.0)); Settings::values.aspect_ratio = static_cast(sdl2_config->GetInteger("Renderer", "aspect_ratio", 0)); + Settings::values.max_anisotropy = + static_cast(sdl2_config->GetInteger("Renderer", "max_anisotropy", 0)); Settings::values.use_frame_limit = false; Settings::values.frame_limit = 100; Settings::values.use_disk_shader_cache = diff --git a/src/yuzu_tester/default_ini.h b/src/yuzu_tester/default_ini.h index 8d93f7b88a..ca203b64db 100644 --- a/src/yuzu_tester/default_ini.h +++ b/src/yuzu_tester/default_ini.h @@ -30,6 +30,10 @@ resolution_factor = # 0: Default (16:9), 1: Force 4:3, 2: Force 21:9, 3: Stretch to Window aspect_ratio = +# Anisotropic filtering +# 0: Default, 1: 2x, 2: 4x, 3: 8x, 4: 16x +max_anisotropy = + # Whether to enable V-Sync (caps the framerate at 60FPS) or not. # 0 (default): Off, 1: On use_vsync =