From ffd94da5f1dfc29ba8656201ae50b95add303575 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Fri, 27 Mar 2020 16:48:39 +0000 Subject: [PATCH] Vulkan: Free recording context semaphores on destroy. Previously the code ASSERTed that the semaphores didn't exist on destroy, but that's not necessarily the case. Handle destruction more correctly. Bug: dawn:269 Change-Id: If123e0e20b4ee157c70a1b8cc2f3b20a9473f55e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/17963 Reviewed-by: Austin Eng Commit-Queue: Corentin Wallez --- src/dawn_native/vulkan/DeviceVk.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/dawn_native/vulkan/DeviceVk.cpp b/src/dawn_native/vulkan/DeviceVk.cpp index e78718e386..d42719ab0a 100644 --- a/src/dawn_native/vulkan/DeviceVk.cpp +++ b/src/dawn_native/vulkan/DeviceVk.cpp @@ -777,6 +777,16 @@ namespace dawn_native { namespace vulkan { mRecordingContext.used = false; fn.DestroyCommandPool(mVkDevice, mRecordingContext.commandPool, nullptr); + for (VkSemaphore semaphore : mRecordingContext.waitSemaphores) { + fn.DestroySemaphore(mVkDevice, semaphore, nullptr); + } + mRecordingContext.waitSemaphores.clear(); + + for (VkSemaphore semaphore : mRecordingContext.signalSemaphores) { + fn.DestroySemaphore(mVkDevice, semaphore, nullptr); + } + mRecordingContext.signalSemaphores.clear(); + // Some operations might have been started since the last submit and waiting // on a serial that doesn't have a corresponding fence enqueued. Force all // operations to look as if they were completed (because they were). @@ -791,12 +801,6 @@ namespace dawn_native { namespace vulkan { } mUnusedCommands.clear(); - // TODO(jiajie.hu@intel.com): In rare cases, a DAWN_TRY() failure may leave semaphores - // untagged for deletion. But for most of the time when everything goes well, these - // assertions can be helpful in catching bugs. - ASSERT(mRecordingContext.waitSemaphores.empty()); - ASSERT(mRecordingContext.signalSemaphores.empty()); - for (VkFence fence : mUnusedFences) { fn.DestroyFence(mVkDevice, fence, nullptr); }