From 1af7f41174231d56f3844b1816c878f85e1e4582 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Thu, 25 Jan 2024 16:15:33 +0100 Subject: [PATCH] wsi/wl: Refactor out code to update current present ID. Signed-off-by: Hans-Kristian Arntzen Reviewed-by: Joshua Ashton Reviewed-by: Sebastian Wick Part-of: --- src/vulkan/wsi/wsi_common_wayland.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index a11cbd21adb..40d25eb6907 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -1920,6 +1920,17 @@ presentation_handle_sync_output(void *data, { } +static void +wsi_wl_presentation_update_present_id(struct wsi_wl_present_id *id) +{ + /* present_ids.lock already held around dispatch */ + if (id->present_id > id->chain->present_ids.max_completed) + id->chain->present_ids.max_completed = id->present_id; + + wl_list_remove(&id->link); + vk_free(id->alloc, id); +} + static void presentation_handle_presented(void *data, struct wp_presentation_feedback *feedback, @@ -1929,14 +1940,8 @@ presentation_handle_presented(void *data, uint32_t flags) { struct wsi_wl_present_id *id = data; - - /* present_ids.lock already held around dispatch */ - if (id->present_id > id->chain->present_ids.max_completed) - id->chain->present_ids.max_completed = id->present_id; - + wsi_wl_presentation_update_present_id(id); wp_presentation_feedback_destroy(feedback); - wl_list_remove(&id->link); - vk_free(id->alloc, id); } static void @@ -1944,14 +1949,8 @@ presentation_handle_discarded(void *data, struct wp_presentation_feedback *feedback) { struct wsi_wl_present_id *id = data; - - /* present_ids.lock already held around dispatch */ - if (id->present_id > id->chain->present_ids.max_completed) - id->chain->present_ids.max_completed = id->present_id; - + wsi_wl_presentation_update_present_id(id); wp_presentation_feedback_destroy(feedback); - wl_list_remove(&id->link); - vk_free(id->alloc, id); } static const struct wp_presentation_feedback_listener