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>
diff --git a/src/dawn_native/vulkan/DeviceVk.cpp b/src/dawn_native/vulkan/DeviceVk.cpp
index 6c6d3dc..0ba4c31 100644
--- a/src/dawn_native/vulkan/DeviceVk.cpp
+++ b/src/dawn_native/vulkan/DeviceVk.cpp
@@ -148,7 +148,22 @@
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