From ed090af4dc5844e71e302e7df7e6fef0ccc0e59c Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Wed, 21 Sep 2022 01:20:40 +0300 Subject: [PATCH] anv: clear descriptorsets if AllocateDescriptorSets fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lionel Landwerlin Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7285 Cc: mesa-stable Reviewed-by: Tapani Pälli Part-of: (cherry picked from commit 369c12e5be3b0d009688082319c8386265056e17) --- .pick_status.json | 2 +- src/intel/vulkan/anv_descriptor_set.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index d404fc70535..f67ee65dbeb 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2893,7 +2893,7 @@ "description": "anv: clear descriptorsets if AllocateDescriptorSets fails", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c index c8fe93a9fbd..b2ecf0d447f 100644 --- a/src/intel/vulkan/anv_descriptor_set.c +++ b/src/intel/vulkan/anv_descriptor_set.c @@ -1305,9 +1305,20 @@ VkResult anv_AllocateDescriptorSets( pDescriptorSets[i] = anv_descriptor_set_to_handle(set); } - if (result != VK_SUCCESS) + if (result != VK_SUCCESS) { anv_FreeDescriptorSets(_device, pAllocateInfo->descriptorPool, i, pDescriptorSets); + /* The Vulkan 1.3.228 spec, section 14.2.3. Allocation of Descriptor Sets: + * + * "If the creation of any of those descriptor sets fails, then the + * implementation must destroy all successfully created descriptor + * set objects from this command, set all entries of the + * pDescriptorSets array to VK_NULL_HANDLE and return the error." + */ + for (i = 0; i < pAllocateInfo->descriptorSetCount; i++) + pDescriptorSets[i] = VK_NULL_HANDLE; + + } return result; }