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: 5f7a5a27ef ("wsi: Implement linux-drm-syncobj-v1")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28874>
This commit is contained in:
Michel Dänzer 2024-04-23 11:50:34 +02:00 committed by Marge Bot
parent 2a417e3fc1
commit c3be21f177
1 changed files with 8 additions and 0 deletions

View File

@ -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;
}