Vulkan: Fix release of semaphores in the recording context

This seems to be a regression introduced by CL:12022, where the
previously recorded semaphores are leaked while resetting the recording
context. The Vulkan validation layers will complain about this when
running the Linux-only image wrapping tests. Also, the semaphores are
queued for deletion with the right serial now.

Bug: dawn:19, dawn:150
Change-Id: I50fd46ca9de9199b29be2f85d5e9bd7394a10f1a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13420
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiajie Hu <jiajie.hu@intel.com>
This commit is contained in:
Jiajie Hu 2019-11-18 08:15:18 +00:00 committed by Commit Bot service account
parent 612a63abe1
commit d0c07f112e
1 changed files with 12 additions and 8 deletions

View File

@ -123,6 +123,9 @@ 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());
@ -311,6 +314,15 @@ namespace dawn_native { namespace vulkan {
DAWN_TRY_ASSIGN(fence, GetUnusedFence());
DAWN_TRY(CheckVkSuccess(fn.QueueSubmit(mQueue, 1, &submitInfo, fence), "vkQueueSubmit"));
// Enqueue the semaphores before incrementing the serial, so that they can be deleted as
// soon as the current submission is finished.
for (VkSemaphore semaphore : mRecordingContext.waitSemaphores) {
mDeleter->DeleteWhenUnused(semaphore);
}
for (VkSemaphore semaphore : mRecordingContext.signalSemaphores) {
mDeleter->DeleteWhenUnused(semaphore);
}
mLastSubmittedSerial++;
mFencesInFlight.emplace(fence, mLastSubmittedSerial);
@ -320,14 +332,6 @@ namespace dawn_native { namespace vulkan {
mRecordingContext = CommandRecordingContext();
DAWN_TRY(PrepareRecordingContext());
for (VkSemaphore semaphore : mRecordingContext.waitSemaphores) {
mDeleter->DeleteWhenUnused(semaphore);
}
for (VkSemaphore semaphore : mRecordingContext.signalSemaphores) {
mDeleter->DeleteWhenUnused(semaphore);
}
return {};
}