From 526c0404c28aafa2e5632c26657c1a9dbd713a96 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Wed, 12 Jul 2023 13:26:27 -0700 Subject: [PATCH] vulkan: Wait for device to be idle before create/recreating swapchain MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- gdk/gdkvulkancontext.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gdk/gdkvulkancontext.c b/gdk/gdkvulkancontext.c index 541104928c..4b7efecddc 100644 --- a/gdk/gdkvulkancontext.c +++ b/gdk/gdkvulkancontext.c @@ -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); -- 2.30.2