[mutter/gbsneto/tracing: 1/4] clutter: Add more descriptive profiling sections



commit b74be1db4de8571638f261c25f4464ba7e8d73ee
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Apr 12 17:19:31 2019 -0300

    clutter: Add more descriptive profiling sections
    
    The idea here is to be able to visualize and immediately
    understand what is happening. Something like:
    
    ```
                       [ view1 ] [ view2 ]
     [---- Layout ---][------ Paint ------][ Pick ]
    [================== Update =====================]
    ```
    
    But with colors. A few of the previous profiling data
    sections were removed, since they didn't really add to
    reading the graph.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/197

 clutter/clutter/clutter-stage.c           | 27 +++++++++++++++++----------
 clutter/clutter/cogl/clutter-stage-cogl.c |  5 ++++-
 cogl/cogl/cogl-trace.h                    | 12 ++++++------
 3 files changed, 27 insertions(+), 17 deletions(-)
---
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 14df24b4c..6d408f692 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -633,8 +633,6 @@ clutter_stage_do_paint_view (ClutterStage                *stage,
   float viewport[4];
   cairo_rectangle_int_t geom;
 
-  COGL_TRACE_BEGIN_SCOPED (ClutterStageDoPaintView);
-
   _clutter_stage_window_get_geometry (priv->impl, &geom);
 
   viewport[0] = priv->viewport[0];
@@ -688,14 +686,12 @@ _clutter_stage_paint_view (ClutterStage                *stage,
 {
   ClutterStagePrivate *priv = stage->priv;
 
-  COGL_TRACE_BEGIN_SCOPED (ClutterStagePaintView);
-
   if (!priv->impl)
     return;
 
-  clutter_stage_do_paint_view (stage, view, clip);
+  COGL_TRACE_BEGIN_SCOPED (ClutterStagePaintView, "Paint (view)");
 
-  COGL_TRACE_BEGIN_SCOPED (ClutterStagePaintViewAfterPaint);
+  clutter_stage_do_paint_view (stage, view, clip);
   g_signal_emit (stage, stage_signals[AFTER_PAINT], 0);
 }
 
@@ -709,8 +705,6 @@ clutter_stage_paint (ClutterActor *self)
   ClutterActorIter iter;
   ClutterActor *child;
 
-  COGL_TRACE_BEGIN_SCOPED (ClutterStagePaint);
-
   clutter_actor_iter_init (&iter, self);
   while (clutter_actor_iter_next (&iter, &child))
     clutter_actor_paint (child);
@@ -1234,22 +1228,31 @@ _clutter_stage_do_update (ClutterStage *stage)
   if (!CLUTTER_ACTOR_IS_REALIZED (stage))
     return FALSE;
 
+  COGL_TRACE_BEGIN_SCOPED (ClutterStageDoUpdate, "Update");
+
   /* NB: We need to ensure we have an up to date layout *before* we
    * check or clear the pending redraws flag since a relayout may
    * queue a redraw.
    */
+  COGL_TRACE_BEGIN (ClutterStageRelayout, "Layout");
+
   _clutter_stage_maybe_relayout (CLUTTER_ACTOR (stage));
 
+  COGL_TRACE_END (ClutterStageRelayout);
+
   if (!priv->redraw_pending)
     return FALSE;
 
   if (stage_was_relayout)
     pointers = _clutter_stage_check_updated_pointers (stage);
 
-  clutter_stage_maybe_finish_queue_redraws (stage);
+  COGL_TRACE_BEGIN (ClutterStagePaint, "Paint");
 
+  clutter_stage_maybe_finish_queue_redraws (stage);
   clutter_stage_do_redraw (stage);
 
+  COGL_TRACE_END (ClutterStagePaint);
+
   /* reset the guard, so that new redraws are possible */
   priv->redraw_pending = FALSE;
 
@@ -1263,12 +1266,16 @@ _clutter_stage_do_update (ClutterStage *stage)
     }
 #endif /* CLUTTER_ENABLE_DEBUG */
 
+  COGL_TRACE_BEGIN (ClutterStagePick, "Pick");
+
   while (pointers)
     {
       _clutter_input_device_update (pointers->data, NULL, TRUE);
       pointers = g_slist_delete_link (pointers, pointers);
     }
 
+  COGL_TRACE_END (ClutterStagePick);
+
   return TRUE;
 }
 
@@ -2954,7 +2961,7 @@ clutter_stage_read_pixels (ClutterStage *stage,
   float pixel_height;
   uint8_t *pixels;
 
-  COGL_TRACE_BEGIN_SCOPED (ClutterStageReadPixels);
+  COGL_TRACE_BEGIN_SCOPED (ClutterStageReadPixels, "Read Pixels");
 
   g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
 
diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c
index 002ebe30c..4d2bd3f9c 100644
--- a/clutter/clutter/cogl/clutter-stage-cogl.c
+++ b/clutter/clutter/cogl/clutter-stage-cogl.c
@@ -936,6 +936,9 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
 
   if (do_swap_buffer)
     {
+      COGL_TRACE_BEGIN_SCOPED (ClutterStageCoglRedrawViewSwapFramebuffer,
+                               "Paint (swap framebuffer)");
+
       if (clutter_stage_view_get_onscreen (view) !=
           clutter_stage_view_get_framebuffer (view))
         {
@@ -960,7 +963,7 @@ clutter_stage_cogl_redraw (ClutterStageWindow *stage_window)
   gboolean swap_event = FALSE;
   GList *l;
 
-  COGL_TRACE_BEGIN (ClutterStageCoglRedraw);
+  COGL_TRACE_BEGIN (ClutterStageCoglRedraw, "Paint (Cogl Redraw)");
 
   for (l = _clutter_stage_window_get_views (stage_window); l; l = l->next)
     {
diff --git a/cogl/cogl/cogl-trace.h b/cogl/cogl/cogl-trace.h
index a5e1a6855..f4d5121e5 100644
--- a/cogl/cogl/cogl-trace.h
+++ b/cogl/cogl/cogl-trace.h
@@ -105,22 +105,22 @@ cogl_auto_trace_end_helper (CoglTraceHead **head)
     cogl_trace_end (*head);
 }
 
-#define COGL_TRACE_BEGIN(Name) \
+#define COGL_TRACE_BEGIN(Name, description) \
   CoglTraceHead CoglTrace##Name = { 0 }; \
   if (cogl_trace_thread_context) \
-    cogl_trace_begin (&CoglTrace##Name, #Name); \
+    cogl_trace_begin (&CoglTrace##Name, description); \
 
 #define COGL_TRACE_END(Name)\
   if (cogl_trace_thread_context) \
     cogl_trace_end (&CoglTrace##Name);
 
-#define COGL_TRACE_BEGIN_SCOPED(Name) \
+#define COGL_TRACE_BEGIN_SCOPED(Name, description) \
   CoglTraceHead CoglTrace##Name = { 0 }; \
   __attribute__((cleanup (cogl_auto_trace_end_helper))) \
     CoglTraceHead *ScopedCoglTrace##Name = NULL; \
   if (cogl_trace_thread_context) \
     { \
-      cogl_trace_begin (&CoglTrace##Name, #Name); \
+      cogl_trace_begin (&CoglTrace##Name, description); \
       ScopedCoglTrace##Name = &CoglTrace##Name; \
     }
 
@@ -128,9 +128,9 @@ cogl_auto_trace_end_helper (CoglTraceHead **head)
 
 #include <stdio.h>
 
-#define COGL_TRACE_BEGIN(Name) (void) 0
+#define COGL_TRACE_BEGIN(Name, description) (void) 0
 #define COGL_TRACE_END(Name) (void) 0
-#define COGL_TRACE_BEGIN_SCOPED(Name) (void) 0
+#define COGL_TRACE_BEGIN_SCOPED(Name, description) (void) 0
 
 void cogl_set_tracing_enabled_on_thread_with_fd (void *data,
                                                  int   fd);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]