From 5bb45dc7ba9285a735754a683520e7af60166c87 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sat, 5 Oct 2024 15:05:24 -0700 Subject: [PATCH] vulkan: Respect maximum sampler LOD bias. (#1254) --- src/video_core/renderer_vulkan/vk_instance.h | 5 +++++ src/video_core/texture_cache/sampler.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/video_core/renderer_vulkan/vk_instance.h b/src/video_core/renderer_vulkan/vk_instance.h index e019ffba39c..2d03b156500 100644 --- a/src/video_core/renderer_vulkan/vk_instance.h +++ b/src/video_core/renderer_vulkan/vk_instance.h @@ -222,6 +222,11 @@ class Instance { return properties.limits.maxTexelBufferElements; } + /// Returns the maximum sampler LOD bias. + float MaxSamplerLodBias() const { + return properties.limits.maxSamplerLodBias; + } + /// Returns the maximum number of push descriptors. u32 MaxPushDescriptors() const { return push_descriptor_props.maxPushDescriptors; diff --git a/src/video_core/texture_cache/sampler.cpp b/src/video_core/texture_cache/sampler.cpp index ed567b9ee69..179dd664691 100644 --- a/src/video_core/texture_cache/sampler.cpp +++ b/src/video_core/texture_cache/sampler.cpp @@ -16,7 +16,7 @@ Sampler::Sampler(const Vulkan::Instance& instance, const AmdGpu::Sampler& sample .addressModeU = LiverpoolToVK::ClampMode(sampler.clamp_x), .addressModeV = LiverpoolToVK::ClampMode(sampler.clamp_y), .addressModeW = LiverpoolToVK::ClampMode(sampler.clamp_z), - .mipLodBias = sampler.LodBias(), + .mipLodBias = std::min(sampler.LodBias(), instance.MaxSamplerLodBias()), .compareEnable = sampler.depth_compare_func != AmdGpu::DepthCompare::Never, .compareOp = LiverpoolToVK::DepthCompare(sampler.depth_compare_func), .minLod = sampler.MinLod(),