panvk: disable round_to_nearest_even for NEAREST-filtered samplers

As described in the comment, enabling the round_to_nearest_even results
in the upper 2^-9 of the texel i being sampled at i+1. This appears to
be allowed by the spec, but triggers a CTS bug[1]. Changing this behavior
is not necessary (we could fix the CTS), but is desirable regardless
because of the precision improvement.

[1]: https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/5547

Signed-off-by: Benjamin Lee <benjamin.lee@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32985>
This commit is contained in:
Benjamin Lee 2025-01-10 21:36:00 -08:00 committed by Marge Bot
parent 4e58029dc0
commit b3d1130d5d
3 changed files with 18 additions and 8 deletions

View file

@ -2643,10 +2643,6 @@ dEQP-VK.compute.pipeline.indirect_dispatch.upload_buffer.multiple_groups_multipl
dEQP-VK.compute.pipeline.indirect_dispatch.upload_buffer.single_invocation,Crash
dEQP-VK.compute.pipeline.indirect_dispatch.upload_buffer.small_offset,Crash
# Filtering of 3D depth-stencil textures fails unless we set SAMPLER:round_to_nearest_even=false
dEQP-VK.texture.filtering.3d.formats.d24_unorm_s8_uint_stencil.d24_unorm_s8_uint_stencil_nearest,Fail
dEQP-VK.texture.filtering.3d.formats.d32_sfloat_s8_uint_stencil.d32_sfloat_s8_uint_stencil_nearest,Fail
# CTS bug, see https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/5296
dEQP-VK.api.device_init.create_device_unsupported_features.protected_memory_features,Fail

View file

@ -258,10 +258,6 @@ spec@ext_image_dma_buf_import@ext_image_dma_buf_import-refcount-multithread,Cras
# physical device and device needs more robustness in allocation handling
# Filtering of 3D depth-stencil textures fails unless we set SAMPLER:round_to_nearest_even=false
dEQP-VK.texture.filtering.3d.formats.d24_unorm_s8_uint_stencil.d24_unorm_s8_uint_stencil_nearest,Fail
dEQP-VK.texture.filtering.3d.formats.d32_sfloat_s8_uint_stencil.d32_sfloat_s8_uint_stencil_nearest,Fail
# CTS bug, see https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/5296
dEQP-VK.api.device_init.create_device_unsupported_features.protected_memory_features,Fail

View file

@ -113,6 +113,24 @@ panvk_per_arch(CreateSampler)(VkDevice _device,
cfg.normalized_coordinates = !pCreateInfo->unnormalizedCoordinates;
cfg.clamp_integer_array_indices = false;
/* Normalized float texture coordinates are rounded to fixed-point
* before rounding to integer coordinates. When round_to_nearest_even is
* enabled with VK_FILTER_NEAREST, the upper 2^-9 float coordinates in
* each texel are rounded up to the next texel.
*
* The Vulkan 1.4.304 spec seems to allow both rounding modes for all
* filters, but a CTS bug[1] causes test failures when round-to-nearest
* is used with VK_FILTER_NEAREST.
*
* Regardless, disabling round_to_nearest_even for NEAREST filters
* is a desirable precision improvement.
*
* [1]: https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/5547
*/
if (pCreateInfo->minFilter == VK_FILTER_NEAREST &&
pCreateInfo->magFilter == VK_FILTER_NEAREST)
cfg.round_to_nearest_even = false;
cfg.lod_bias = pCreateInfo->mipLodBias;
cfg.minimum_lod = pCreateInfo->minLod;
cfg.maximum_lod = pCreateInfo->maxLod;