Vulkan: Explicitly wait for all fences to complete on Device destruction

This ensures that all fences are complete. Flaky failures on Windows
showed some fence statuses were NOT_READY despite having been checked
after calling vkQueueWaitIdle.

Bug: dawn:60
Change-Id: Id4fa18c8842daf75faa9df6fcba8afdca43623c9
Reviewed-on: https://dawn-review.googlesource.com/c/2920
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2018-12-04 23:55:01 +00:00 committed by Commit Bot service account
parent 9fca812285
commit 66b024e499
1 changed files with 16 additions and 1 deletions

View File

@ -148,7 +148,22 @@ namespace dawn_native { namespace vulkan {
ASSERT(false);
}
CheckPassedFences();
ASSERT(mFencesInFlight.empty());
// Make sure all fences are complete by explicitly waiting on them all
while (!mFencesInFlight.empty()) {
VkFence fence = mFencesInFlight.front().first;
Serial fenceSerial = mFencesInFlight.front().second;
ASSERT(fenceSerial > mCompletedSerial);
VkResult result = VK_TIMEOUT;
do {
result = fn.WaitForFences(mVkDevice, 1, &fence, true, UINT64_MAX);
} while (result == VK_TIMEOUT);
fn.DestroyFence(mVkDevice, fence, nullptr);
mFencesInFlight.pop();
mCompletedSerial = fenceSerial;
}
// 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