From 72d6ca3aff4332f546fefca7601ccca4a9dfd42d Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 11 Jan 2024 11:12:35 +0100 Subject: [PATCH] Vulkan: Fix Anisotropic Filtering Validation Error When anisotropic filtering is enabled on a sampler its value must be between 1 and 16. In blender it is possible to set a value lower than 1. 0 actually means that anisotropic filtering is disabled in Blender. This would trigger a validation error in Vulkan. Pull Request: https://projects.blender.org/blender/blender/pulls/117018 --- source/blender/gpu/vulkan/vk_sampler.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/blender/gpu/vulkan/vk_sampler.cc b/source/blender/gpu/vulkan/vk_sampler.cc index 79813a62ada..f861d149d8e 100644 --- a/source/blender/gpu/vulkan/vk_sampler.cc +++ b/source/blender/gpu/vulkan/vk_sampler.cc @@ -38,11 +38,12 @@ void VKSampler::create(const GPUSamplerState &sampler_state) if (sampler_state.filtering & GPU_SAMPLER_FILTERING_MIPMAP) { sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR; } - if (device.physical_device_features_get().samplerAnisotropy == VK_TRUE && - sampler_state.filtering & GPU_SAMPLER_FILTERING_ANISOTROPIC) + if ((sampler_state.filtering & GPU_SAMPLER_FILTERING_ANISOTROPIC) && + (U.anisotropic_filter > 1) && + (device.physical_device_features_get().samplerAnisotropy == VK_TRUE)) { sampler_info.anisotropyEnable = VK_TRUE; - sampler_info.maxAnisotropy = min_ff(1.0f, U.anisotropic_filter); + sampler_info.maxAnisotropy = U.anisotropic_filter; } /* Extend */