diff options
author | Michel Dänzer <mdaenzer@redhat.com> | 2024-04-23 11:50:34 +0200 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2024-04-26 15:11:00 +0000 |
commit | c3be21f1778ff3e3de4d6506bb20a0ffd11f5003 (patch) | |
tree | 2adc9aabd22a436cfc6dd9cab41c41d5e4901585 | |
parent | 2a417e3fc1911f5edc912621fe532c1c3ec64d0b (diff) |
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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28874>
-rw-r--r-- | src/vulkan/wsi/wsi_common_wayland.c | 8 |
1 files changed, 8 insertions, 0 deletions
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; } |