compositor: Add flow id into surface state

We're going to be adding protocols (commit-timing, fifo, syncobj) that
allow deferred surface content updates.

It makes sense to start the perfetto flow ids from the surface state so
we can track a flow from creation (ie:commit) to presentation.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2025-07-29 15:31:30 -05:00
parent 5e0099ddbb
commit b700c7cbee
3 changed files with 15 additions and 4 deletions

View file

@ -1733,6 +1733,7 @@ enum weston_surface_status {
};
struct weston_surface_state {
uint64_t flow_id;
enum weston_surface_status status;
/* wl_surface.attach */

View file

@ -4728,7 +4728,7 @@ static void
surface_commit(struct wl_client *client, struct wl_resource *resource)
{
struct weston_surface *surface = wl_resource_get_user_data(resource);
WESTON_TRACE_FUNC_FLOW(&surface->flow_id);
WESTON_TRACE_FUNC_FLOW(&surface->pending.flow_id);
enum weston_surface_status status;
struct weston_buffer *buffer;
int32_t tmp_w, tmp_h;

View file

@ -59,6 +59,7 @@ void
weston_surface_state_init(struct weston_surface *surface,
struct weston_surface_state *state)
{
state->flow_id = 0;
state->status = WESTON_SURFACE_CLEAN;
state->buffer_ref.buffer = NULL;
state->buf_offset = weston_coord_surface(0, 0, surface);
@ -90,6 +91,7 @@ weston_surface_state_fini(struct weston_surface_state *state)
{
struct wl_resource *cb, *next;
state->flow_id = 0;
wl_resource_for_each_safe(cb, next, &state->frame_callback_list)
wl_resource_destroy(cb);
@ -265,11 +267,14 @@ static enum weston_surface_status
weston_surface_apply_state(struct weston_surface *surface,
struct weston_surface_state *state)
{
WESTON_TRACE_FUNC_FLOW(&surface->flow_id);
WESTON_TRACE_FUNC_FLOW(&state->flow_id);
struct weston_view *view;
pixman_region32_t opaque;
enum weston_surface_status status = state->status;
surface->flow_id = state->flow_id;
state->flow_id = 0;
/* wl_surface.set_buffer_transform */
/* wl_surface.set_buffer_scale */
/* wp_viewport.set_source */
@ -420,7 +425,7 @@ static enum weston_surface_status
weston_surface_apply(struct weston_surface *surface,
struct weston_surface_state *state)
{
WESTON_TRACE_FUNC_FLOW(&surface->flow_id);
WESTON_TRACE_FUNC_FLOW(&state->flow_id);
enum weston_surface_status status;
struct weston_subsurface *sub;
@ -444,7 +449,9 @@ weston_surface_state_merge_from(struct weston_surface_state *dst,
struct weston_surface_state *src,
struct weston_surface *surface)
{
WESTON_TRACE_FUNC();
WESTON_TRACE_FUNC_FLOW(&dst->flow_id);
src->flow_id = 0;
/*
* If this commit would cause the surface to move by the
@ -521,6 +528,7 @@ weston_surface_state_merge_from(struct weston_surface_state *dst,
enum weston_surface_status
weston_surface_commit(struct weston_surface *surface)
{
WESTON_TRACE_FUNC_FLOW(&surface->pending.flow_id);
struct weston_subsurface *sub = weston_surface_to_subsurface(surface);
struct weston_surface_state *state = &surface->pending;
enum weston_surface_status status;
@ -569,6 +577,7 @@ weston_subsurface_update_effectively_synchronized(struct weston_subsurface *sub)
bool parent_e_sync = false;
struct weston_subsurface *child;
struct weston_surface *surf = sub->surface;
WESTON_TRACE_FUNC_FLOW(&surf->flow_id);
if (sub->parent) {
struct weston_subsurface *parent;
@ -599,6 +608,7 @@ weston_subsurface_update_effectively_synchronized(struct weston_subsurface *sub)
void
weston_subsurface_set_synchronized(struct weston_subsurface *sub, bool sync)
{
WESTON_TRACE_FUNC_FLOW(&sub->surface->flow_id);
bool old_e_sync = sub->effectively_synchronized;
if (sub->synchronized == sync)