From 6d748f5b2c7541ffbc45e55e36d16a7154e4bb14 Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Thu, 25 Jan 2024 16:00:09 -0800 Subject: [PATCH] anv/sparse: reject all sample flags that non-sparse doesn't support We call anv_get_image_format_properties() from anv_GetPhysicalDeviceSparseImageFormatProperties2() because we want to reject all images that we don't support for the non-sparse case. That function does not take sample counts as its input, it outputs a list of possible sample counts. In this patch we check the sample counts it outputs: if what the user is querying isn't even supported by non-sparse, reject it right away. That saves us from having to code in anv_sparse_image_check_support() cases that are coded elsewhere. Examples include: 1D images and compressed formats. This change affects a number of dEQP tests, including: - dEQP-VK.api.info.sparse_image_format_properties2.1d.optimal.r4g4b4a4_unorm_pack16 - dEQP-VK.api.info.sparse_image_format_properties2.2d.optimal.bc2_srgb_block Without this patch, and with sparse multi-sampling enabled, this would hit the following assertion: anv_formats.c:1903: anv_GetPhysicalDeviceSparseImageFormatProperties2: Assertion `false' failed. Reviewed-by: Lionel Landwerlin Signed-off-by: Paulo Zanoni Part-of: --- src/intel/vulkan/anv_formats.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c index 3dd9e6599a6..ebd76667e5f 100644 --- a/src/intel/vulkan/anv_formats.c +++ b/src/intel/vulkan/anv_formats.c @@ -1840,6 +1840,10 @@ void anv_GetPhysicalDeviceSparseImageFormatProperties2( &img_info, &img_props) != VK_SUCCESS) return; + if ((pFormatInfo->samples & + img_props.imageFormatProperties.sampleCounts) == 0) + return; + if (anv_sparse_image_check_support(physical_device, VK_IMAGE_CREATE_SPARSE_BINDING_BIT | VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT,