vulkan: Wait for device to be idle before create/recreating swapchain
authorJosé Roberto de Souza <jose.souza@intel.com>
Wed, 12 Jul 2023 20:26:27 +0000 (13:26 -0700)
committerJosé Roberto de Souza <jose.souza@intel.com>
Thu, 13 Jul 2023 12:40:55 +0000 (05:40 -0700)
Wait for device to be idle because this function is also called in
window resizes.
And if we destroy old swapchain it also destroy the old VkImages,
those images could be in use by a vulkan render.

This fixes a issue reported in Mesa repository when running
GTK with Xe KMD.

Fixes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9044
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
gdk/gdkvulkancontext.c

index 541104928cf4aa14564ad41ce62b25cc457f0dc8..4b7efecddcdb55ddcd6b084a05b919d036332070 100644 (file)
@@ -383,6 +383,13 @@ gdk_vulkan_context_check_swapchain (GdkVulkanContext  *context,
 
   device = gdk_vulkan_context_get_device (context);
 
+  /*
+   * Wait for device to be idle because this function is also called in window resizes.
+   * And if we destroy old swapchain it also destroy the old VkImages, those images could
+   * be in use by a vulkan render.
+   */
+  vkDeviceWaitIdle (device);
+
   res = GDK_VK_CHECK (vkGetPhysicalDeviceSurfaceCapabilitiesKHR, gdk_vulkan_context_get_physical_device (context),
                                                                  priv->surface,
                                                                  &capabilities);