From 59dffe0a9bf49a87ffcbd9cdda38176706c362b9 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Wed, 23 Jun 2021 02:08:49 +0000 Subject: [PATCH] Vulkan: Ensure fences are properly tracked if vkQueueSubmit fails Bug: chromium:1216929 Change-Id: I58fa8df4d539b58b47246bb2cde18c4ede46f5ca Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/53740 Reviewed-by: Corentin Wallez Reviewed-by: Jiawei Shao Auto-Submit: Austin Eng Commit-Queue: Jiawei Shao --- src/dawn_native/vulkan/DeviceVk.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dawn_native/vulkan/DeviceVk.cpp b/src/dawn_native/vulkan/DeviceVk.cpp index 64f79e13b5..8f94b169af 100644 --- a/src/dawn_native/vulkan/DeviceVk.cpp +++ b/src/dawn_native/vulkan/DeviceVk.cpp @@ -259,7 +259,13 @@ namespace dawn_native { namespace vulkan { VkFence fence = VK_NULL_HANDLE; DAWN_TRY_ASSIGN(fence, GetUnusedFence()); - DAWN_TRY(CheckVkSuccess(fn.QueueSubmit(mQueue, 1, &submitInfo, fence), "vkQueueSubmit")); + DAWN_TRY_WITH_CLEANUP( + CheckVkSuccess(fn.QueueSubmit(mQueue, 1, &submitInfo, fence), "vkQueueSubmit"), { + // If submitting to the queue fails, move the fence back into the unused fence + // list, as if it were never acquired. Not doing so would leak the fence since + // it would be neither in the unused list nor in the in-flight list. + mUnusedFences.push_back(fence); + }); // Enqueue the semaphores before incrementing the serial, so that they can be deleted as // soon as the current submission is finished.