From 6a6d449a1d4c72319a3844c8aca92dcc405e4212 Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Thu, 16 May 2024 14:39:39 -0700 Subject: [PATCH] anv/sparse: fix reporting of VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT This calculation was wrong for both compressed formats and multi-sampled images. As a result, we misreported the image as having a single miptail. No Vulkan or GL CTS tests were tripping on this bug. I found this while looking for tile size calculations after fixing a similar bug elsewhere in the code. The calculation should now match what we have in anv_sparse_bind_image_memory(), which is widely tested. Reviewed-by: Lionel Landwerlin Signed-off-by: Paulo Zanoni Part-of: --- src/intel/vulkan/anv_sparse.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/intel/vulkan/anv_sparse.c b/src/intel/vulkan/anv_sparse.c index a3d23a09141..b5e58830439 100644 --- a/src/intel/vulkan/anv_sparse.c +++ b/src/intel/vulkan/anv_sparse.c @@ -931,8 +931,12 @@ anv_sparse_calc_image_format_properties(struct anv_physical_device *pdevice, assert(is_standard || is_known_nonstandard_format); assert(!(is_standard && is_known_nonstandard_format)); - uint32_t block_size = granularity.width * granularity.height * - granularity.depth * Bpb; + VkExtent3D block_shape_el = vk_extent3d_px_to_el(granularity, isl_layout); + uint32_t block_size = block_shape_el.width * Bpb * + block_shape_el.height * + block_shape_el.depth * vk_samples; + assert(block_size == 64 * 1024 || block_size == 4096); + bool wrong_block_size = block_size != ANV_SPARSE_BLOCK_SIZE; return (VkSparseImageFormatProperties) {