diff options
| author | 2021-11-16 23:07:17 +0100 | |
|---|---|---|
| committer | 2021-11-16 23:14:51 +0100 | |
| commit | 282e04bffb4962dcc1d8aee2cb0fd2a1a45c86e6 (patch) | |
| tree | 6be46996d65e1799fa45e2f2bd6b81945b97af70 /src | |
| parent | TextureCache: Make a better Anisotropic setter. (diff) | |
| download | yuzu-282e04bffb4962dcc1d8aee2cb0fd2a1a45c86e6.tar.gz yuzu-282e04bffb4962dcc1d8aee2cb0fd2a1a45c86e6.tar.xz yuzu-282e04bffb4962dcc1d8aee2cb0fd2a1a45c86e6.zip | |
TextureCache: Add automatic anisotropic filtering and refactor code.
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/settings.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/textures/texture.cpp | 15 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics_advanced.ui | 5 |
5 files changed, 22 insertions, 16 deletions
diff --git a/src/common/settings.h b/src/common/settings.h index c7610ef1c..42f8b4a7d 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -515,7 +515,7 @@ struct Values { | |||
| 515 | #endif | 515 | #endif |
| 516 | FullscreenMode::Borderless, FullscreenMode::Exclusive, "fullscreen_mode"}; | 516 | FullscreenMode::Borderless, FullscreenMode::Exclusive, "fullscreen_mode"}; |
| 517 | RangedSetting<int> aspect_ratio{0, 0, 3, "aspect_ratio"}; | 517 | RangedSetting<int> aspect_ratio{0, 0, 3, "aspect_ratio"}; |
| 518 | RangedSetting<int> max_anisotropy{0, 0, 4, "max_anisotropy"}; | 518 | RangedSetting<int> max_anisotropy{0, 0, 5, "max_anisotropy"}; |
| 519 | Setting<bool> use_speed_limit{true, "use_speed_limit"}; | 519 | Setting<bool> use_speed_limit{true, "use_speed_limit"}; |
| 520 | RangedSetting<u16> speed_limit{100, 0, 9999, "speed_limit"}; | 520 | RangedSetting<u16> speed_limit{100, 0, 9999, "speed_limit"}; |
| 521 | Setting<bool> use_disk_shader_cache{true, "use_disk_shader_cache"}; | 521 | Setting<bool> use_disk_shader_cache{true, "use_disk_shader_cache"}; |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index c2668fee6..1d3f193af 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp | |||
| @@ -1201,13 +1201,7 @@ Sampler::Sampler(TextureCacheRuntime& runtime, const TSCEntry& config) { | |||
| 1201 | glSamplerParameterfv(handle, GL_TEXTURE_BORDER_COLOR, config.BorderColor().data()); | 1201 | glSamplerParameterfv(handle, GL_TEXTURE_BORDER_COLOR, config.BorderColor().data()); |
| 1202 | 1202 | ||
| 1203 | if (GLAD_GL_ARB_texture_filter_anisotropic || GLAD_GL_EXT_texture_filter_anisotropic) { | 1203 | if (GLAD_GL_ARB_texture_filter_anisotropic || GLAD_GL_EXT_texture_filter_anisotropic) { |
| 1204 | const f32 setting_anisotropic = | 1204 | const f32 max_anisotropy = std::clamp(config.MaxAnisotropy(), 1.0f, 16.0f); |
| 1205 | static_cast<f32>(1U << Settings::values.max_anisotropy.GetValue()); | ||
| 1206 | const f32 game_anisotropic = std::clamp(config.MaxAnisotropy(), 1.0f, 16.0f); | ||
| 1207 | const bool aument_anisotropic = | ||
| 1208 | game_anisotropic > 1.0f || config.mipmap_filter == TextureMipmapFilter::Linear; | ||
| 1209 | const f32 max_anisotropy = | ||
| 1210 | aument_anisotropic ? std::max(game_anisotropic, setting_anisotropic) : game_anisotropic; | ||
| 1211 | glSamplerParameterf(handle, GL_TEXTURE_MAX_ANISOTROPY, max_anisotropy); | 1205 | glSamplerParameterf(handle, GL_TEXTURE_MAX_ANISOTROPY, max_anisotropy); |
| 1212 | } else { | 1206 | } else { |
| 1213 | LOG_WARNING(Render_OpenGL, "GL_ARB_texture_filter_anisotropic is required"); | 1207 | LOG_WARNING(Render_OpenGL, "GL_ARB_texture_filter_anisotropic is required"); |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 7db561ca0..daf26f380 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp | |||
| @@ -1448,13 +1448,7 @@ Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& t | |||
| 1448 | LOG_WARNING(Render_Vulkan, "VK_EXT_sampler_filter_minmax is required"); | 1448 | LOG_WARNING(Render_Vulkan, "VK_EXT_sampler_filter_minmax is required"); |
| 1449 | } | 1449 | } |
| 1450 | // Some games have samplers with garbage. Sanitize them here. | 1450 | // Some games have samplers with garbage. Sanitize them here. |
| 1451 | const f32 setting_anisotropic = | 1451 | const f32 max_anisotropy = std::clamp(tsc.MaxAnisotropy(), 1.0f, 16.0f); |
| 1452 | static_cast<f32>(1U << Settings::values.max_anisotropy.GetValue()); | ||
| 1453 | const f32 game_anisotropic = std::clamp(tsc.MaxAnisotropy(), 1.0f, 16.0f); | ||
| 1454 | const bool aument_anisotropic = | ||
| 1455 | game_anisotropic > 1.0f || tsc.mipmap_filter == TextureMipmapFilter::Linear; | ||
| 1456 | const f32 max_anisotropy = | ||
| 1457 | aument_anisotropic ? std::max(game_anisotropic, setting_anisotropic) : game_anisotropic; | ||
| 1458 | 1452 | ||
| 1459 | sampler = device.GetLogical().CreateSampler(VkSamplerCreateInfo{ | 1453 | sampler = device.GetLogical().CreateSampler(VkSamplerCreateInfo{ |
| 1460 | .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, | 1454 | .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, |
diff --git a/src/video_core/textures/texture.cpp b/src/video_core/textures/texture.cpp index b2d5bb03e..ba066f98f 100644 --- a/src/video_core/textures/texture.cpp +++ b/src/video_core/textures/texture.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <array> | 6 | #include <array> |
| 7 | 7 | ||
| 8 | #include "common/cityhash.h" | 8 | #include "common/cityhash.h" |
| 9 | #include "common/settings.h" | ||
| 9 | #include "video_core/textures/texture.h" | 10 | #include "video_core/textures/texture.h" |
| 10 | 11 | ||
| 11 | using Tegra::Texture::TICEntry; | 12 | using Tegra::Texture::TICEntry; |
| @@ -61,7 +62,19 @@ std::array<float, 4> TSCEntry::BorderColor() const noexcept { | |||
| 61 | } | 62 | } |
| 62 | 63 | ||
| 63 | float TSCEntry::MaxAnisotropy() const noexcept { | 64 | float TSCEntry::MaxAnisotropy() const noexcept { |
| 64 | return static_cast<float>(1U << max_anisotropy); | 65 | if (max_anisotropy == 0 && mipmap_filter != TextureMipmapFilter::Linear) { |
| 66 | return 1.0f; | ||
| 67 | } | ||
| 68 | const auto anisotropic_settings = Settings::values.max_anisotropy.GetValue(); | ||
| 69 | u32 new_max_anisotropic{}; | ||
| 70 | if (anisotropic_settings == 0) { | ||
| 71 | const auto anisotropic_based_onscale = Settings::values.resolution_info.up_scale >> | ||
| 72 | Settings::values.resolution_info.down_shift; | ||
| 73 | new_max_anisotropic = std::max(anisotropic_based_onscale + 1U, 1U); | ||
| 74 | } else { | ||
| 75 | new_max_anisotropic = Settings::values.max_anisotropy.GetValue(); | ||
| 76 | } | ||
| 77 | return static_cast<float>(1U << std::min(max_anisotropy + anisotropic_settings - 1, 31U)); | ||
| 65 | } | 78 | } |
| 66 | 79 | ||
| 67 | } // namespace Tegra::Texture | 80 | } // namespace Tegra::Texture |
diff --git a/src/yuzu/configuration/configure_graphics_advanced.ui b/src/yuzu/configuration/configure_graphics_advanced.ui index cbbcd45a0..96de0b3d1 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.ui +++ b/src/yuzu/configuration/configure_graphics_advanced.ui | |||
| @@ -125,6 +125,11 @@ | |||
| 125 | <widget class="QComboBox" name="anisotropic_filtering_combobox"> | 125 | <widget class="QComboBox" name="anisotropic_filtering_combobox"> |
| 126 | <item> | 126 | <item> |
| 127 | <property name="text"> | 127 | <property name="text"> |
| 128 | <string>Automatic</string> | ||
| 129 | </property> | ||
| 130 | </item> | ||
| 131 | <item> | ||
| 132 | <property name="text"> | ||
| 128 | <string>Default</string> | 133 | <string>Default</string> |
| 129 | </property> | 134 | </property> |
| 130 | </item> | 135 | </item> |