From 1a26e489262ad98d13a1d15d2fc95c57d9b89be5 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 15 Feb 2023 10:10:26 -0500 Subject: [PATCH] vulkan/wsi: avoid deadlocking dri3 when polling deleted windows for events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit upcoming xserver releases will emit PresentConfigureNotify with this flag set when a window is destroyed, ensuring drivers don't poll infinitely and deadlock fixes #6685 cc: mesa-stable Reviewed-by: Adam Jackson Reviewed-by: Michel Dänzer Acked-by: Daniel Stone Part-of: (cherry picked from commit 819cbf329a56f1e72a4192b727c7a6d44ad2c2d7) --- .pick_status.json | 2 +- src/vulkan/wsi/wsi_common_x11.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 6e6d43344ca..87f7b156d60 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2668,7 +2668,7 @@ "description": "vulkan/wsi: avoid deadlocking dri3 when polling deleted windows for events", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index a3c4538366f..0f851f6c25f 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -1029,6 +1029,10 @@ x11_get_wsi_image(struct wsi_swapchain *wsi_chain, uint32_t image_index) return &chain->images[image_index].base; } +/* XXX this belongs in presentproto */ +#ifndef PresentWindowDestroyed +#define PresentWindowDestroyed (1 << 0) +#endif /** * Process an X11 Present event. Does not update chain->status. */ @@ -1039,6 +1043,8 @@ x11_handle_dri3_present_event(struct x11_swapchain *chain, switch (event->evtype) { case XCB_PRESENT_CONFIGURE_NOTIFY: { xcb_present_configure_notify_event_t *config = (void *) event; + if (config->pixmap_flags & PresentWindowDestroyed) + return VK_ERROR_SURFACE_LOST_KHR; if (config->width != chain->extent.width || config->height != chain->extent.height)