From 9e9636f675442ac98ee5d8b79f821e4c79912a7a Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 3 Apr 2024 14:37:12 +0200 Subject: [PATCH] scene: add support for linux-drm-syncobj-v1 --- types/scene/surface.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/types/scene/surface.c b/types/scene/surface.c index 1905b4df..2aff5af3 100644 --- a/types/scene/surface.c +++ b/types/scene/surface.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include "types/wlr_scene.h" @@ -164,8 +165,29 @@ static void surface_reconfigure(struct wlr_scene_surface *scene_surface) { if (surface->buffer) { client_buffer_mark_next_can_damage(surface->buffer); - wlr_scene_buffer_set_buffer_with_damage(scene_buffer, - &surface->buffer->base, &surface->buffer_damage); + struct wlr_linux_drm_syncobj_surface_v1_state *syncobj_surface_state = + wlr_linux_drm_syncobj_v1_get_surface_state(surface); + + struct wlr_drm_syncobj_timeline *wait_timeline = NULL; + uint64_t wait_point = 0; + if (syncobj_surface_state != NULL) { + wait_timeline = syncobj_surface_state->acquire_timeline; + wait_point = syncobj_surface_state->acquire_point; + } + + struct wlr_scene_buffer_set_buffer_options options = { + .damage = &surface->buffer_damage, + .wait_timeline = wait_timeline, + .wait_point = wait_point, + }; + wlr_scene_buffer_set_buffer_with_options(scene_buffer, + &surface->buffer->base, &options); + + if (syncobj_surface_state != NULL && + (surface->current.committed & WLR_SURFACE_STATE_BUFFER)) { + wlr_linux_drm_syncobj_v1_state_signal_release_with_buffer(syncobj_surface_state, + &surface->buffer->base); + } } else { wlr_scene_buffer_set_buffer(scene_buffer, NULL); }