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
This commit is contained in:
Jeroen Bakker
2024-01-11 11:12:35 +01:00
parent a94146b82c
commit 72d6ca3aff

View File

@@ -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 */