From 1cca5e8b32dbabba762d4cf5413e876f9a70e129 Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Thu, 18 Jan 2024 17:31:39 -0800 Subject: [PATCH] anv/sparse: fail the right way in anv_GetDeviceImageSparseMemoryRequirements() If an application tries to call vkGetDeviceImageSparseMemoryRequirements() for an image that's not supported by Sparse, then anv_image_init_from_create_info() will fail and we will either hit the assertion in case of a debug build or just pretend everything works in case of a release build. Properly return no properties to signal the image is not supported. The spec is not clear in specifying that this is what should be done in this case, but this behavior should match the other query-properties-from-sparse-images-we-didn't-create-yet functions such as vkGetPhysicalDeviceSparseImageFormatProperties(). No known application outside my computer is tripping on this failure. I discovered it when writing my own micro test cases for MSAA sparse. Reviewed-by: Lionel Landwerlin Signed-off-by: Paulo Zanoni Part-of: --- src/intel/vulkan/anv_image.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 7cf5568efa9..b6724544525 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -2254,11 +2254,13 @@ void anv_GetDeviceImageSparseMemoryRequirements( * without having to actually create the image, maybe by reworking ISL to * separate creation from parameter computing. */ - - ASSERTED VkResult result = + VkResult result = anv_image_init_from_create_info(device, &image, pInfo->pCreateInfo, true /* no_private_binding_alloc */); - assert(result == VK_SUCCESS); + if (result != VK_SUCCESS) { + *pSparseMemoryRequirementCount = 0; + return; + } /* The spec says: * "planeAspect is a VkImageAspectFlagBits value specifying the aspect