From c3be21f1778ff3e3de4d6506bb20a0ffd11f5003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Tue, 23 Apr 2024 11:50:34 +0200 Subject: [PATCH] wsi/wayland: Dispatch event queue in wsi_wl_swapchain_queue_present With explicit sync, only if it wasn't done earlier for FIFO. Prevents potentially unbounded memory usage for (wl_buffer.release events in) the queue, since we don't dispatch the queue anywhere else with explicit sync. v2: * Use wl_display_dispatch_queue_pending instead of wl_display_dispatch_queue_timeout. (Sebastian Wick) * Call it from wsi_wl_swapchain_queue_present instead of wsi_wl_swapchain_acquire_next_image_explicit. (Joshua Ashton) Fixes: 5f7a5a27ef1b ("wsi: Implement linux-drm-syncobj-v1") Part-of: --- src/vulkan/wsi/wsi_common_wayland.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 1cc1b78afaf..ebfc80a84a5 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -1974,6 +1974,7 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain *wsi_chain, const VkPresentRegionKHR *damage) { struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain; + bool queue_dispatched = false; /* While the specification suggests we can keep presenting already acquired * images on a retired swapchain, there is no requirement to support that. @@ -2003,6 +2004,8 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain *wsi_chain, wsi_wl_surface->display->queue); if (ret < 0) return VK_ERROR_OUT_OF_DATE_KHR; + + queue_dispatched = true; } if (chain->base.image_info.explicit_sync) { @@ -2074,6 +2077,11 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain *wsi_chain, wl_surface_commit(wsi_wl_surface->surface); wl_display_flush(wsi_wl_surface->display->wl_display); + if (!queue_dispatched && wsi_chain->image_info.explicit_sync) { + wl_display_dispatch_queue_pending(wsi_wl_surface->display->wl_display, + wsi_wl_surface->display->queue); + } + return VK_SUCCESS; }