summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2021-10-30 01:52:11 +0200
committerGravatar Fernando Sahmkow2021-11-16 22:11:33 +0100
commit5230378709470da56927e85c50d0524f9ce3f81b (patch)
tree6f17ba41ea5a1f60ecea9fff4bf2b25b441c0392
parentTexture Cache: revert Image changes. (diff)
downloadyuzu-5230378709470da56927e85c50d0524f9ce3f81b.tar.gz
yuzu-5230378709470da56927e85c50d0524f9ce3f81b.tar.xz
yuzu-5230378709470da56927e85c50d0524f9ce3f81b.zip
TextureCache: Make a better Anisotropic setter.
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp9
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.cpp9
-rw-r--r--src/video_core/textures/texture.cpp19
-rw-r--r--src/yuzu/configuration/configure_graphics_advanced.ui8
4 files changed, 21 insertions, 24 deletions
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index 00610ea2c..c2668fee6 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -1201,7 +1201,14 @@ 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 glSamplerParameterf(handle, GL_TEXTURE_MAX_ANISOTROPY, config.MaxAnisotropy()); 1204 const f32 setting_anisotropic =
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 } else { 1212 } else {
1206 LOG_WARNING(Render_OpenGL, "GL_ARB_texture_filter_anisotropic is required"); 1213 LOG_WARNING(Render_OpenGL, "GL_ARB_texture_filter_anisotropic is required");
1207 } 1214 }
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
index 1c0741250..7db561ca0 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
@@ -1448,7 +1448,14 @@ 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 float max_anisotropy = std::clamp(tsc.MaxAnisotropy(), 1.0f, 16.0f); 1451 const f32 setting_anisotropic =
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 sampler = device.GetLogical().CreateSampler(VkSamplerCreateInfo{ 1459 sampler = device.GetLogical().CreateSampler(VkSamplerCreateInfo{
1453 .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, 1460 .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
1454 .pNext = pnext, 1461 .pNext = pnext,
diff --git a/src/video_core/textures/texture.cpp b/src/video_core/textures/texture.cpp
index a552543ed..b2d5bb03e 100644
--- a/src/video_core/textures/texture.cpp
+++ b/src/video_core/textures/texture.cpp
@@ -6,7 +6,6 @@
6#include <array> 6#include <array>
7 7
8#include "common/cityhash.h" 8#include "common/cityhash.h"
9#include "common/settings.h"
10#include "video_core/textures/texture.h" 9#include "video_core/textures/texture.h"
11 10
12using Tegra::Texture::TICEntry; 11using Tegra::Texture::TICEntry;
@@ -51,22 +50,6 @@ constexpr std::array<float, 256> SRGB_CONVERSION_LUT = {
51 0.917104f, 0.929242f, 0.941493f, 0.953859f, 0.966338f, 1.000000f, 1.000000f, 1.000000f, 50 0.917104f, 0.929242f, 0.941493f, 0.953859f, 0.966338f, 1.000000f, 1.000000f, 1.000000f,
52}; 51};
53 52
54unsigned SettingsMinimumAnisotropy() noexcept {
55 switch (static_cast<Anisotropy>(Settings::values.max_anisotropy.GetValue())) {
56 default:
57 case Anisotropy::Default:
58 return 1U;
59 case Anisotropy::Filter2x:
60 return 2U;
61 case Anisotropy::Filter4x:
62 return 4U;
63 case Anisotropy::Filter8x:
64 return 8U;
65 case Anisotropy::Filter16x:
66 return 16U;
67 }
68}
69
70} // Anonymous namespace 53} // Anonymous namespace
71 54
72std::array<float, 4> TSCEntry::BorderColor() const noexcept { 55std::array<float, 4> TSCEntry::BorderColor() const noexcept {
@@ -78,7 +61,7 @@ std::array<float, 4> TSCEntry::BorderColor() const noexcept {
78} 61}
79 62
80float TSCEntry::MaxAnisotropy() const noexcept { 63float TSCEntry::MaxAnisotropy() const noexcept {
81 return static_cast<float>(std::max(1U << max_anisotropy, SettingsMinimumAnisotropy())); 64 return static_cast<float>(1U << max_anisotropy);
82} 65}
83 66
84} // namespace Tegra::Texture 67} // namespace Tegra::Texture
diff --git a/src/yuzu/configuration/configure_graphics_advanced.ui b/src/yuzu/configuration/configure_graphics_advanced.ui
index d06b45f17..cbbcd45a0 100644
--- a/src/yuzu/configuration/configure_graphics_advanced.ui
+++ b/src/yuzu/configuration/configure_graphics_advanced.ui
@@ -130,22 +130,22 @@
130 </item> 130 </item>
131 <item> 131 <item>
132 <property name="text"> 132 <property name="text">
133 <string>2x (WILL BREAK THINGS)</string> 133 <string>2x</string>
134 </property> 134 </property>
135 </item> 135 </item>
136 <item> 136 <item>
137 <property name="text"> 137 <property name="text">
138 <string>4x (WILL BREAK THINGS)</string> 138 <string>4x</string>
139 </property> 139 </property>
140 </item> 140 </item>
141 <item> 141 <item>
142 <property name="text"> 142 <property name="text">
143 <string>8x (WILL BREAK THINGS)</string> 143 <string>8x</string>
144 </property> 144 </property>
145 </item> 145 </item>
146 <item> 146 <item>
147 <property name="text"> 147 <property name="text">
148 <string>16x (WILL BREAK THINGS)</string> 148 <string>16x</string>
149 </property> 149 </property>
150 </item> 150 </item>
151 </widget> 151 </widget>