From 1012c71167d121742c9a13019cf3d990e8d9de41 Mon Sep 17 00:00:00 2001
From: Alix Bott <bott.alix@gmail.com>
Date: Tue, 3 Oct 2023 22:24:54 +0200
Subject: [PATCH] Fix x11 hang when resizing on vulkan (#4184)

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
---
 wgpu-hal/src/vulkan/instance.rs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs
index 8fad89e5d5..1c730cbea2 100644
--- a/wgpu-hal/src/vulkan/instance.rs
+++ b/wgpu-hal/src/vulkan/instance.rs
@@ -157,6 +157,12 @@ impl super::Swapchain {
     /// - The device must have been made idle before calling this function.
     unsafe fn release_resources(self, device: &ash::Device) -> Self {
         profiling::scope!("Swapchain::release_resources");
+        {
+            profiling::scope!("vkDeviceWaitIdle");
+            // We need to also wait until all presentation work is done. Because there is no way to portably wait until
+            // the presentation work is done, we are forced to wait until the device is idle.
+            let _ = unsafe { device.device_wait_idle() };
+        };
         unsafe { device.destroy_fence(self.fence, None) };
         self
     }