timeline: Add GPU timestamp timepoint argument
authorAlexandros Frantzis <alexandros.frantzis@collabora.com>
Wed, 27 Sep 2017 12:09:13 +0000 (15:09 +0300)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Fri, 29 Sep 2017 07:20:42 +0000 (10:20 +0300)
The purpose of this argument is to hold timestamp information about
events that occurred on the GPU. This argument allows us to include GPU
timestamps in timepoints such as the beginning and end of frame
rendering.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
libweston/timeline.c
libweston/timeline.h

index cf82428e839ae293ab70746c9a267151353d6469..8234c27cdd35b641630c0578c0ce2568aa55b68a 100644 (file)
@@ -232,12 +232,24 @@ emit_vblank_timestamp(struct timeline_emit_context *ctx, void *obj)
        return 1;
 }
 
+static int
+emit_gpu_timestamp(struct timeline_emit_context *ctx, void *obj)
+{
+       struct timespec *ts = obj;
+
+       fprintf(ctx->cur, "\"gpu\":[%" PRId64 ", %ld]",
+               (int64_t)ts->tv_sec, ts->tv_nsec);
+
+       return 1;
+}
+
 typedef int (*type_func)(struct timeline_emit_context *ctx, void *obj);
 
 static const type_func type_dispatch[] = {
        [TLT_OUTPUT] = emit_weston_output,
        [TLT_SURFACE] = emit_weston_surface,
        [TLT_VBLANK] = emit_vblank_timestamp,
+       [TLT_GPU] = emit_gpu_timestamp,
 };
 
 WL_EXPORT void
index b10a8157725960f486b6027a371fcb9d90d2e05d..9599d8138cb68636335680dd4bdf2c2c971e0579 100644 (file)
@@ -42,6 +42,7 @@ enum timeline_type {
        TLT_OUTPUT,
        TLT_SURFACE,
        TLT_VBLANK,
+       TLT_GPU,
 };
 
 #define TYPEVERIFY(type, arg) ({                       \
@@ -53,6 +54,7 @@ enum timeline_type {
 #define TLP_OUTPUT(o) TLT_OUTPUT, TYPEVERIFY(struct weston_output *, (o))
 #define TLP_SURFACE(s) TLT_SURFACE, TYPEVERIFY(struct weston_surface *, (s))
 #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_) \