VERY experimental Nintendo Switch 2 emulator
C++
video_core: Fallback to default anisotropy instead to 1x anisotropy
Wollnashorneff77dae59e5
diff --git a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp b/src/video_core/renderer_opengl/gl_graphics_pipeline.cppindex 0fa0fc594c..58e4e1919f 100644--- a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp+++ b/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp@@ -488,7 +488,7 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {const bool use_fallback_sampler{sampler.HasAddedAnisotropy() &&!image_view.SupportsAnisotropy()};gl_samplers[sampler_binding++] =- use_fallback_sampler ? sampler.HandleWithoutAnisotropy() : sampler.Handle();+ use_fallback_sampler ? sampler.HandleWithDefaultAnisotropy() : sampler.Handle();}}for (const auto& desc : info.image_descriptors) {diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cppindex 7ff54003f3..3b446be074 100644--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp@@ -1306,8 +1306,10 @@ Sampler::Sampler(TextureCacheRuntime& runtime, const TSCEntry& config) {};sampler = create_sampler(max_anisotropy);- if (Settings::values.max_anisotropy.GetValue() > 0 && max_anisotropy > 1.0f) {- sampler_without_anisotropy = create_sampler(1.0f);++ const f32 max_anisotropy_default = static_cast<f32>(1U << config.max_anisotropy);+ if (max_anisotropy > max_anisotropy_default) {+ sampler_default_anisotropy = create_sampler(max_anisotropy_default);}}diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.hindex 82756fca79..3676eaaa96 100644--- a/src/video_core/renderer_opengl/gl_texture_cache.h+++ b/src/video_core/renderer_opengl/gl_texture_cache.h@@ -313,17 +313,17 @@ public:return sampler.handle;}- [[nodiscard]] GLuint HandleWithoutAnisotropy() const noexcept {- return sampler_without_anisotropy.handle;+ [[nodiscard]] GLuint HandleWithDefaultAnisotropy() const noexcept {+ return sampler_default_anisotropy.handle;}[[nodiscard]] bool HasAddedAnisotropy() const noexcept {- return static_cast<bool>(sampler_without_anisotropy.handle);+ return static_cast<bool>(sampler_default_anisotropy.handle);}private:OGLSampler sampler;- OGLSampler sampler_without_anisotropy;+ OGLSampler sampler_default_anisotropy;};class Framebuffer {diff --git a/src/video_core/renderer_vulkan/pipeline_helper.h b/src/video_core/renderer_vulkan/pipeline_helper.hindex 1632a6f266..0a9dce9375 100644--- a/src/video_core/renderer_vulkan/pipeline_helper.h+++ b/src/video_core/renderer_vulkan/pipeline_helper.h@@ -192,7 +192,7 @@ inline void PushImageDescriptors(TextureCache& texture_cache,const Sampler& sampler{**(samplers++)};const bool use_fallback_sampler{sampler.HasAddedAnisotropy() &&!image_view.SupportsAnisotropy()};- const VkSampler vk_sampler{use_fallback_sampler ? sampler.HandleWithoutAnisotropy()+ const VkSampler vk_sampler{use_fallback_sampler ? sampler.HandleWithDefaultAnisotropy(): sampler.Handle()};guest_descriptor_queue.AddSampledImage(vk_image_view, vk_sampler);rescaling.PushTexture(texture_cache.IsRescaling(image_view));diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cppindex 8ec1813355..f025f618b4 100644--- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp+++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp@@ -1827,8 +1827,10 @@ Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& t};sampler = create_sampler(max_anisotropy);- if (Settings::values.max_anisotropy.GetValue() > 0 && max_anisotropy > 1.0f) {- sampler_without_anisotropy = create_sampler(1.0f);++ const f32 max_anisotropy_default = static_cast<f32>(1U << tsc.max_anisotropy);+ if (max_anisotropy > max_anisotropy_default) {+ sampler_default_anisotropy = create_sampler(max_anisotropy_default);}}diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.hindex ee0d0480d0..f14525dcb0 100644--- a/src/video_core/renderer_vulkan/vk_texture_cache.h+++ b/src/video_core/renderer_vulkan/vk_texture_cache.h@@ -279,17 +279,17 @@ public:return *sampler;}- [[nodiscard]] VkSampler HandleWithoutAnisotropy() const noexcept {- return *sampler_without_anisotropy;+ [[nodiscard]] VkSampler HandleWithDefaultAnisotropy() const noexcept {+ return *sampler_default_anisotropy;}[[nodiscard]] bool HasAddedAnisotropy() const noexcept {- return static_cast<bool>(sampler_without_anisotropy);+ return static_cast<bool>(sampler_default_anisotropy);}private:vk::Sampler sampler;- vk::Sampler sampler_without_anisotropy;+ vk::Sampler sampler_default_anisotropy;};class Framebuffer {diff --git a/src/video_core/textures/texture.cpp b/src/video_core/textures/texture.cppindex cb24d03992..63ebdfa827 100644--- a/src/video_core/textures/texture.cpp+++ b/src/video_core/textures/texture.cpp@@ -68,8 +68,8 @@ float TSCEntry::MaxAnisotropy() const noexcept {const bool has_regular_lods = min_lod_clamp == 0 && max_lod_clamp >= 256;const bool is_bilinear_filter = min_filter == TextureFilter::Linear &&reduction_filter == SamplerReduction::WeightedAverage;- if (max_anisotropy == 0 && (depth_compare_enabled.Value() || !has_regular_lods ||- !is_bilinear_filter || !is_suitable_mipmap_filter)) {+ if (max_anisotropy == 0 && (depth_compare_enabled || !has_regular_lods || !is_bilinear_filter ||+ !is_suitable_mipmap_filter)) {return 1.0f;}const auto anisotropic_settings = Settings::values.max_anisotropy.GetValue();