From f80f89b5604c8d4f6f483e526ee2b97a4b19a436 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 20 Oct 2021 22:22:53 +0200 Subject: [PATCH] linux-explicit-synchronization-v1: extract fence from DMA-BUF --- types/wlr_linux_explicit_synchronization_v1.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/types/wlr_linux_explicit_synchronization_v1.c b/types/wlr_linux_explicit_synchronization_v1.c index aebf4ec55f..115e243aca 100644 --- a/types/wlr_linux_explicit_synchronization_v1.c +++ b/types/wlr_linux_explicit_synchronization_v1.c @@ -327,13 +327,20 @@ bool wlr_linux_explicit_synchronization_v1_signal_surface_timeline( uint64_t dst_point) { struct wlr_linux_surface_synchronization_v1 *surface_sync = surface_sync_from_surface(explicit_sync, surface); - if (!surface_sync) { - // TODO: fallback to DMA-BUF fence export - return false; + if (surface_sync) { + return wlr_render_timeline_import_sync_file(timeline, dst_point, + surface_sync->current.acquire_fence_fd); } - return wlr_render_timeline_import_sync_file(timeline, dst_point, - surface_sync->current.acquire_fence_fd); + // Client doesn't support explicit sync, try to extract the fence from the + // DMA-BUF + struct wlr_dmabuf_attributes dmabuf; + if (surface->buffer == NULL || + !wlr_buffer_get_dmabuf(&surface->buffer->base, &dmabuf)) { + return false; + } + return wlr_render_timeline_import_dmabuf(timeline, dst_point, + dmabuf.fd[0]); } bool wlr_linux_explicit_synchronization_v1_wait_surface_timeline(