diff --git a/libweston/compositor.c b/libweston/compositor.c index e371e07b..420bc847 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -2369,7 +2369,7 @@ surface_flush_damage(struct weston_surface *surface) surface->compositor->renderer->flush_damage(surface); if (pixman_region32_not_empty(&surface->damage)) - TL_POINT("core_flush_damage", TLP_SURFACE(surface), + TL_POINT(surface->compositor, "core_flush_damage", TLP_SURFACE(surface), TLP_OUTPUT(surface->output), TLP_END); pixman_region32_clear(&surface->damage); @@ -2631,7 +2631,7 @@ weston_output_repaint(struct weston_output *output, void *repaint_data) if (output->destroying) return 0; - TL_POINT("core_repaint_begin", TLP_OUTPUT(output), TLP_END); + TL_POINT(ec, "core_repaint_begin", TLP_OUTPUT(output), TLP_END); /* Rebuild the surface list and update surface transforms up front. */ weston_compositor_build_view_list(ec); @@ -2709,7 +2709,7 @@ weston_output_repaint(struct weston_output *output, void *repaint_data) animation->frame(animation, output, &output->frame_time); } - TL_POINT("core_repaint_posted", TLP_OUTPUT(output), TLP_END); + TL_POINT(ec, "core_repaint_posted", TLP_OUTPUT(output), TLP_END); return r; } @@ -2718,7 +2718,8 @@ static void weston_output_schedule_repaint_reset(struct weston_output *output) { output->repaint_status = REPAINT_NOT_SCHEDULED; - TL_POINT("core_repaint_exit_loop", TLP_OUTPUT(output), TLP_END); + TL_POINT(output->compositor, "core_repaint_exit_loop", + TLP_OUTPUT(output), TLP_END); } static int @@ -2877,7 +2878,7 @@ weston_output_finish_frame(struct weston_output *output, goto out; } - TL_POINT("core_repaint_finished", TLP_OUTPUT(output), + TL_POINT(compositor, "core_repaint_finished", TLP_OUTPUT(output), TLP_VBLANK(stamp), TLP_END); refresh_nsec = millihz_to_nsec(output->current_mode->refresh); @@ -3064,7 +3065,7 @@ weston_output_schedule_repaint(struct weston_output *output) return; if (!output->repaint_needed) - TL_POINT("core_repaint_req", TLP_OUTPUT(output), TLP_END); + TL_POINT(compositor, "core_repaint_req", TLP_OUTPUT(output), TLP_END); loop = wl_display_get_event_loop(compositor->wl_display); output->repaint_needed = true; @@ -3080,7 +3081,7 @@ weston_output_schedule_repaint(struct weston_output *output) assert(!output->idle_repaint_source); output->idle_repaint_source = wl_event_loop_add_idle(loop, idle_repaint, output); - TL_POINT("core_repaint_enter_loop", TLP_OUTPUT(output), TLP_END); + TL_POINT(compositor, "core_repaint_enter_loop", TLP_OUTPUT(output), TLP_END); } /** weston_compositor_schedule_repaint @@ -3529,7 +3530,7 @@ weston_surface_commit_state(struct weston_surface *surface, /* wl_surface.damage and wl_surface.damage_buffer */ if (pixman_region32_not_empty(&state->damage_surface) || pixman_region32_not_empty(&state->damage_buffer)) - TL_POINT("core_commit_damage", TLP_SURFACE(surface), TLP_END); + TL_POINT(surface->compositor, "core_commit_damage", TLP_SURFACE(surface), TLP_END); pixman_region32_union(&surface->damage, &surface->damage, &state->damage_surface); diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index e65306bf..57bd2223 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -42,7 +42,6 @@ #include #include "linux-sync-file.h" - #include "timeline.h" #include "gl-renderer.h" @@ -253,7 +252,7 @@ timeline_render_point_handler(int fd, uint32_t mask, void *data) if (weston_linux_sync_file_read_timestamp(trp->fd, &tspec) == 0) { - TL_POINT(tp_name, TLP_GPU(&tspec), + TL_POINT(trp->output->compositor, tp_name, TLP_GPU(&tspec), TLP_OUTPUT(trp->output), TLP_END); } } @@ -287,7 +286,8 @@ timeline_submit_render_sync(struct gl_renderer *gr, int fd; struct timeline_render_point *trp; - if (!gr->has_native_fence_sync || + if (!weston_log_scope_is_enabled(ec->timeline) || + !gr->has_native_fence_sync || sync == EGL_NO_SYNC_KHR) return; diff --git a/libweston/timeline.c b/libweston/timeline.c index 35ccc523..33a533c4 100644 --- a/libweston/timeline.c +++ b/libweston/timeline.c @@ -37,8 +37,6 @@ #include "timeline.h" #include "weston-log-internal.h" -WL_EXPORT int weston_timeline_enabled_; - struct timeline_emit_context { FILE *cur; struct weston_log_subscription *subscription; @@ -320,48 +318,59 @@ static const type_func type_dispatch[] = { }; WL_EXPORT void -weston_timeline_point(const char *name, ...) +weston_timeline_point(struct weston_log_scope *timeline_scope, + const char *name, ...) { - va_list argp; struct timespec ts; enum timeline_type otype; void *obj; char buf[512]; - struct timeline_emit_context ctx; + struct weston_log_subscription *sub = NULL; + + if (!weston_log_scope_is_enabled(timeline_scope)) + return; clock_gettime(CLOCK_MONOTONIC, &ts); - ctx.cur = fmemopen(buf, sizeof(buf), "w"); + while ((sub = weston_log_subscription_iterate(timeline_scope, sub))) { + va_list argp; + struct timeline_emit_context ctx = {}; - if (!ctx.cur) { - weston_log("Timeline error in fmemopen, closing.\n"); - return; - } + memset(buf, 0, sizeof(buf)); + ctx.cur = fmemopen(buf, sizeof(buf), "w"); + ctx.subscription = sub; + + if (!ctx.cur) { + weston_log("Timeline error in fmemopen, closing.\n"); + return; + } - fprintf(ctx.cur, "{ \"T\":[%" PRId64 ", %ld], \"N\":\"%s\"", - (int64_t)ts.tv_sec, ts.tv_nsec, name); + fprintf(ctx.cur, "{ \"T\":[%" PRId64 ", %ld], \"N\":\"%s\"", + (int64_t)ts.tv_sec, ts.tv_nsec, name); - va_start(argp, name); - while (1) { - otype = va_arg(argp, enum timeline_type); - if (otype == TLT_END) - break; + va_start(argp, name); + while (1) { + otype = va_arg(argp, enum timeline_type); + if (otype == TLT_END) + break; - obj = va_arg(argp, void *); - if (type_dispatch[otype]) { - fprintf(ctx.cur, ", "); - type_dispatch[otype](&ctx, obj); + obj = va_arg(argp, void *); + if (type_dispatch[otype]) { + fprintf(ctx.cur, ", "); + type_dispatch[otype](&ctx, obj); + } + } + va_end(argp); + + fprintf(ctx.cur, " }\n"); + fflush(ctx.cur); + if (ferror(ctx.cur)) { + weston_log("Timeline error in constructing entry, closing.\n"); + } else { + weston_log_subscription_printf(ctx.subscription, "%s", buf); } - } - va_end(argp); - fprintf(ctx.cur, " }\n"); - fflush(ctx.cur); - if (ferror(ctx.cur)) { - weston_log("Timeline error in constructing entry, closing.\n"); - } else { - weston_log_subscription_printf(ctx.subscription, "%s", buf); - } + fclose(ctx.cur); - fclose(ctx.cur); + } } diff --git a/libweston/timeline.h b/libweston/timeline.h index bc98add7..a84c27b4 100644 --- a/libweston/timeline.h +++ b/libweston/timeline.h @@ -33,8 +33,6 @@ #include #include -extern int weston_timeline_enabled_; - enum timeline_type { TLT_END = 0, TLT_OUTPUT, @@ -71,12 +69,12 @@ struct weston_timeline_subscription_object { #define TLP_VBLANK(t) TLT_VBLANK, TYPEVERIFY(const struct timespec *, (t)) #define TLP_GPU(t) TLT_GPU, TYPEVERIFY(const struct timespec *, (t)) -#define TL_POINT(...) do { \ - if (weston_timeline_enabled_) \ - weston_timeline_point(__VA_ARGS__); \ +#define TL_POINT(ec, ...) do { \ + weston_timeline_point(ec->timeline, __VA_ARGS__); \ } while (0) void -weston_timeline_point(const char *name, ...); +weston_timeline_point(struct weston_log_scope *timeline_scope, + const char *name, ...); #endif /* WESTON_TIMELINE_H */