vulkan: Free "in flight" fences/commands in ShutdownImpl

There might still be fences and commands marked as in-flight in
ShutdownImpl if the device was lost. Delete them anyway because since
the device was lost, it means that all objects are no longer in the
"pending" state (from the Vulkan spec point of view)

Bug: chromium:1244454
Change-Id: I905a9a8e5174591bf93e3cdac3cdcb349d75a581
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63102
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez 2021-08-30 20:01:04 +00:00 committed by Dawn LUCI CQ
parent 52ad8f6768
commit 6bb3f6f216
1 changed files with 11 additions and 0 deletions

View File

@ -935,7 +935,11 @@ namespace dawn_native { namespace vulkan {
} }
mRecordingContext.signalSemaphores.clear(); mRecordingContext.signalSemaphores.clear();
// Some commands might still be marked as in-flight if we shut down because of a device
// loss. Recycle them as unused so that we free them below.
RecycleCompletedCommands();
ASSERT(mCommandsInFlight.Empty()); ASSERT(mCommandsInFlight.Empty());
for (const CommandPoolAndBuffer& commands : mUnusedCommands) { for (const CommandPoolAndBuffer& commands : mUnusedCommands) {
// The VkCommandBuffer memory should be wholly owned by the pool and freed when it is // The VkCommandBuffer memory should be wholly owned by the pool and freed when it is
// destroyed, but that's not the case in some drivers and the leak memory. // destroyed, but that's not the case in some drivers and the leak memory.
@ -946,6 +950,13 @@ namespace dawn_native { namespace vulkan {
} }
mUnusedCommands.clear(); mUnusedCommands.clear();
// Some fences might still be marked as in-flight if we shut down because of a device loss.
// Delete them since at this point all commands are complete.
while (!mFencesInFlight.empty()) {
fn.DestroyFence(mVkDevice, *mFencesInFlight.front().first, nullptr);
mFencesInFlight.pop();
}
for (VkFence fence : mUnusedFences) { for (VkFence fence : mUnusedFences) {
fn.DestroyFence(mVkDevice, fence, nullptr); fn.DestroyFence(mVkDevice, fence, nullptr);
} }