anv/sparse: properly reject sample counts we don't support

Yes, I understand that this looks like the kind of check that the
applications should be doing instead of us, but if we don't that, dEQP
will have failures. If we claim support for any multi-sampled sparse
feature, dEQP will try to create multi-sampled sparse images with all
possible sample counts, including the ones supported by non-sparse but
not supported by sparse (x8 and x16 on Tile64 platforms) and also the
ones not supported at all, like x32 and x64.

This change affects a number of dEQP tests, including:
  - dEQP-VK.api.info.sparse_image_format_properties2.2d.optimal.r32g32_sfloat

Without this patch, and with sparse multi-sampling enabled, this would
hit the following assertion:
  anv_sparse.c:866: anv_sparse_calc_image_format_properties: Assertion `is_standard || is_known_nonstandard_format' failed.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27306>
This commit is contained in:
Paulo Zanoni 2024-01-25 15:53:02 -08:00 committed by Marge Bot
parent af725a2ccc
commit 620f1d1a7a
1 changed files with 10 additions and 2 deletions

View File

@ -1188,8 +1188,16 @@ anv_sparse_image_check_support(struct anv_physical_device *pdevice,
if (tiling == VK_IMAGE_TILING_LINEAR)
return VK_ERROR_FORMAT_NOT_SUPPORTED;
/* TODO: not supported yet. */
if (samples != VK_SAMPLE_COUNT_1_BIT)
if ((samples & VK_SAMPLE_COUNT_2_BIT &&
!pdevice->vk.supported_features.sparseResidency2Samples) ||
(samples & VK_SAMPLE_COUNT_4_BIT &&
!pdevice->vk.supported_features.sparseResidency4Samples) ||
(samples & VK_SAMPLE_COUNT_8_BIT &&
!pdevice->vk.supported_features.sparseResidency8Samples) ||
(samples & VK_SAMPLE_COUNT_16_BIT &&
!pdevice->vk.supported_features.sparseResidency16Samples) ||
samples & VK_SAMPLE_COUNT_32_BIT ||
samples & VK_SAMPLE_COUNT_64_BIT)
return VK_ERROR_FEATURE_NOT_PRESENT;
/* While the Vulkan spec allows us to support depth/stencil sparse images