From 0be4403f652716e42562a0a3fc8786d773fd6bfe Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Fri, 10 Jan 2025 14:56:10 -0600 Subject: [PATCH] timeline: Add flow ids for surfaces We add a flow_id when we touch a surface that has no flow id, and clear it when we flush damage, so a flow line will be drawn connecting any operations on a surface and terminating in its damage clear. This is less useful for surfaces that never receive explicit damage after they're set up, such as background images and the panel, as they might never show up as a damage track, and have an unterminated flow line. For surfaces that do show up on a damage track, we can follow them back to the commit that caused them to update. Signed-off-by: Derek Foreman --- include/libweston/libweston.h | 1 + libweston/compositor.c | 29 ++++++++++++++++------------- libweston/timeline-perfetto.c | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index ffc603ec9..d1e7587d5 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -2078,6 +2078,7 @@ struct weston_surface { struct wl_resource *cm_surface; uint64_t damage_track_id; + uint64_t flow_id; }; struct weston_subsurface { diff --git a/libweston/compositor.c b/libweston/compositor.c index 48b54b914..313167710 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -263,7 +263,7 @@ maybe_replace_paint_node(struct weston_paint_node *pnode) static void paint_node_update_early(struct weston_paint_node *pnode) { - WESTON_TRACE_FUNC(); + WESTON_TRACE_FUNC_FLOW(&pnode->surface->flow_id); struct weston_matrix *mat = &pnode->buffer_to_output_matrix; bool view_dirty = pnode->status & PAINT_NODE_VIEW_DIRTY; bool output_dirty = pnode->status & PAINT_NODE_OUTPUT_DIRTY; @@ -291,7 +291,7 @@ paint_node_update_early(struct weston_paint_node *pnode) static void paint_node_update_late(struct weston_paint_node *pnode) { - WESTON_TRACE_FUNC(); + WESTON_TRACE_FUNC_FLOW(&pnode->surface->flow_id); struct weston_surface *surf = pnode->surface; bool vis_dirty = pnode->status & PAINT_NODE_VISIBILITY_DIRTY; bool plane_dirty = pnode->status & PAINT_NODE_PLANE_DIRTY; @@ -1905,7 +1905,7 @@ weston_view_update_transform_enable(struct weston_view *view) WL_EXPORT void weston_view_update_transform(struct weston_view *view) { - WESTON_TRACE_FUNC(); + WESTON_TRACE_FUNC_FLOW(&view->surface->flow_id); struct weston_view *parent = view->geometry.parent; struct weston_view *child; struct weston_layer *layer; @@ -3267,7 +3267,7 @@ weston_surface_attach(struct weston_surface *surface, struct weston_surface_state *state, enum weston_surface_status status) { - WESTON_TRACE_FUNC(); + WESTON_TRACE_FUNC_FLOW(&surface->flow_id); struct weston_buffer *buffer = state->buffer; struct weston_buffer *old_buffer = surface->buffer_ref.buffer; @@ -3356,7 +3356,7 @@ weston_output_damage(struct weston_output *output) static void paint_node_add_damage(struct weston_paint_node *node) { - WESTON_TRACE_FUNC(); + WESTON_TRACE_FUNC_FLOW(&node->surface->flow_id); struct weston_view *view = node->view; pixman_region32_t damage; @@ -3385,7 +3385,7 @@ paint_node_add_damage(struct weston_paint_node *node) static void paint_node_flush_surface_damage(struct weston_paint_node *pnode) { - WESTON_TRACE_FUNC(); + WESTON_TRACE_FUNC_FLOW(&pnode->surface->flow_id); struct weston_output *output = pnode->output; struct weston_surface *surface = pnode->surface; struct weston_buffer *buffer = surface->buffer_ref.buffer; @@ -3393,13 +3393,13 @@ paint_node_flush_surface_damage(struct weston_paint_node *pnode) if (buffer->type == WESTON_BUFFER_SHM) { if (pnode->draw_solid) - return; + goto out; surface->compositor->renderer->flush_damage(pnode); } if (!pixman_region32_not_empty(&surface->damage)) - return; + goto out; wl_list_for_each(walk_node, &surface->paint_node_list, surface_link) { assert(walk_node->surface == surface); @@ -3410,6 +3410,9 @@ paint_node_flush_surface_damage(struct weston_paint_node *pnode) TL_POINT(surface->compositor, TLP_CORE_FLUSH_DAMAGE, TLP_SURFACE(surface), TLP_OUTPUT(output), TLP_END); + +out: + surface->flow_id = 0; } static void @@ -3490,7 +3493,7 @@ output_accumulate_damage(struct weston_output *output) static struct weston_paint_node * view_ensure_paint_node(struct weston_view *view, struct weston_output *output) { - WESTON_TRACE_FUNC(); + WESTON_TRACE_FUNC_FLOW(&view->surface->flow_id); struct weston_paint_node *pnode; if (!output) @@ -3568,7 +3571,7 @@ static void view_list_add(struct weston_compositor *compositor, struct weston_view *view) { - WESTON_TRACE_FUNC(); + WESTON_TRACE_FUNC_FLOW(&view->surface->flow_id); struct weston_subsurface *sub; weston_view_update_transform(view); @@ -4820,7 +4823,7 @@ static enum weston_surface_status weston_surface_commit_state(struct weston_surface *surface, struct weston_surface_state *state) { - WESTON_TRACE_FUNC(); + WESTON_TRACE_FUNC_FLOW(&surface->flow_id); struct weston_view *view; pixman_region32_t opaque; enum weston_surface_status status = state->status; @@ -4950,7 +4953,7 @@ weston_surface_commit_state(struct weston_surface *surface, static enum weston_surface_status weston_surface_commit(struct weston_surface *surface) { - WESTON_TRACE_FUNC(); + WESTON_TRACE_FUNC_FLOW(&surface->flow_id); enum weston_surface_status status; status = weston_surface_commit_state(surface, &surface->pending); @@ -4973,8 +4976,8 @@ weston_subsurface_parent_commit(struct weston_subsurface *sub, static void surface_commit(struct wl_client *client, struct wl_resource *resource) { - WESTON_TRACE_FUNC(); struct weston_surface *surface = wl_resource_get_user_data(resource); + WESTON_TRACE_FUNC_FLOW(&surface->flow_id); struct weston_subsurface *sub = weston_surface_to_subsurface(surface); enum weston_surface_status status; diff --git a/libweston/timeline-perfetto.c b/libweston/timeline-perfetto.c index 24007de62..a03eab86f 100644 --- a/libweston/timeline-perfetto.c +++ b/libweston/timeline-perfetto.c @@ -157,7 +157,7 @@ weston_timeline_perfetto(struct weston_log_scope *timeline_scope, break; case TLP_CORE_FLUSH_DAMAGE: WESTON_TRACE_TIMESTAMP_END("Damaged", surface->damage_track_id, CLOCK_MONOTONIC, now_ns); - WESTON_TRACE_TIMESTAMP_BEGIN("Clean", surface->damage_track_id, 0, CLOCK_MONOTONIC, now_ns); + WESTON_TRACE_TIMESTAMP_BEGIN("Clean", surface->damage_track_id, surface->flow_id, CLOCK_MONOTONIC, now_ns); break; case TLP_CORE_REPAINT_BEGIN: WESTON_TRACE_TIMESTAMP_END("Scheduled", output->paint_track_id, CLOCK_MONOTONIC, now_ns);