[gtk+] gsk: report fallback pixels as a profile counter



commit ae2c645a2a2557faf6e9d34f8b8fb70237b88c77
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Sep 25 21:02:21 2017 -0400

    gsk: report fallback pixels as a profile counter
    
    This makes the value show up in the inspector without
    any extra work. We report the number per-frame, since
    that makes the most sense.

 gsk/gskvulkanrenderer.c   |    4 ++++
 gsk/gskvulkanrenderpass.c |   32 ++++++++++++++++++++++++--------
 2 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/gsk/gskvulkanrenderer.c b/gsk/gskvulkanrenderer.c
index 15ac134..6666880 100644
--- a/gsk/gskvulkanrenderer.c
+++ b/gsk/gskvulkanrenderer.c
@@ -26,6 +26,7 @@ struct _GskVulkanTextureData {
 #ifdef G_ENABLE_DEBUG
 typedef struct {
   GQuark frames;
+  GQuark fallback_pixels;
 } ProfileCounters;
 
 typedef struct {
@@ -199,6 +200,7 @@ gsk_vulkan_renderer_render_texture (GskRenderer           *renderer,
 
 #ifdef G_ENABLE_DEBUG
   profiler = gsk_renderer_get_profiler (renderer);
+  gsk_profiler_counter_set (profiler, self->profile_counters.fallback_pixels, 0);
   gsk_profiler_timer_begin (profiler, self->profile_timers.cpu_time);
 #endif
 
@@ -304,6 +306,8 @@ gsk_vulkan_renderer_init (GskVulkanRenderer *self)
 
 #ifdef G_ENABLE_DEBUG
   self->profile_counters.frames = gsk_profiler_add_counter (profiler, "frames", "Frames", FALSE);
+  self->profile_counters.fallback_pixels = gsk_profiler_add_counter (profiler, "fallback-pixels", "Fallback 
pixels", TRUE);
+
   self->profile_timers.cpu_time = gsk_profiler_add_timer (profiler, "cpu-time", "CPU time", FALSE, TRUE);
 #endif
 }
diff --git a/gsk/gskvulkanrenderpass.c b/gsk/gskvulkanrenderpass.c
index 2fd633b..3cb7e66 100644
--- a/gsk/gskvulkanrenderpass.c
+++ b/gsk/gskvulkanrenderpass.c
@@ -3,8 +3,10 @@
 #include "gskvulkanrenderpassprivate.h"
 
 #include "gskdebugprivate.h"
+#include "gskprofilerprivate.h"
 #include "gskrendernodeprivate.h"
 #include "gskrenderer.h"
+#include "gskrendererprivate.h"
 #include "gskroundedrectprivate.h"
 #include "gskvulkanblendmodepipelineprivate.h"
 #include "gskvulkanblendpipelineprivate.h"
@@ -105,7 +107,7 @@ struct _GskVulkanRenderPass
 
   GArray *render_ops;
 
-  gsize fallback_pixels;
+  GQuark fallback_pixels;
 };
 
 GskVulkanRenderPass *
@@ -116,6 +118,9 @@ gsk_vulkan_render_pass_new (GdkVulkanContext *context)
   self = g_slice_new0 (GskVulkanRenderPass);
   self->vulkan = g_object_ref (context);
   self->render_ops = g_array_new (FALSE, FALSE, sizeof (GskVulkanOp));
+#ifdef G_ENABLE_DEBUG
+  self->fallback_pixels = g_quark_from_static_string ("fallback-pixels");
+#endif
 
   return self;
 }
@@ -123,9 +128,6 @@ gsk_vulkan_render_pass_new (GdkVulkanContext *context)
 void
 gsk_vulkan_render_pass_free (GskVulkanRenderPass *self)
 {
-  GSK_NOTE (FALLBACK,
-            g_print ("Uploaded %ld fallback pixels\n", self->fallback_pixels));
-
   g_array_unref (self->render_ops);
   g_object_unref (self->vulkan);
 
@@ -571,8 +573,15 @@ gsk_vulkan_render_pass_get_node_as_texture (GskVulkanRenderPass   *self,
 
   GSK_NOTE (FALLBACK, g_print ("Node as texture not implemented. Using %gx%g fallback surface\n",
                                ceil (bounds->size.width),
-                               ceil (bounds->size.height));
-                      self->fallback_pixels += ceil (bounds->size.width) * ceil (bounds->size.height));
+                               ceil (bounds->size.height)));
+#ifdef G_ENABLE_DEBUG
+  {
+    GskProfiler *profiler = gsk_renderer_get_profiler (gsk_vulkan_render_get_renderer (render));
+    gsk_profiler_counter_add (profiler,
+                              self->fallback_pixels,
+                              ceil (bounds->size.width) * ceil (bounds->size.height));
+  }
+#endif
 
   /* XXX: We could intersect bounds with clip bounds here */
   surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
@@ -617,8 +626,15 @@ gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderPass  *self,
                      (op->type == GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP ? "fallback-rounded-clip" : 
"fallback"),
                      node->name ? node->name : node->node_class->type_name, node,
                      ceil (node->bounds.size.width),
-                     ceil (node->bounds.size.height));
-             self->fallback_pixels += ceil (node->bounds.size.width) * ceil (node->bounds.size.height));
+                     ceil (node->bounds.size.height)));
+#ifdef G_ENABLE_DEBUG
+  {
+    GskProfiler *profiler = gsk_renderer_get_profiler (gsk_vulkan_render_get_renderer (render));
+    gsk_profiler_counter_add (profiler,
+                              self->fallback_pixels,
+                              ceil (node->bounds.size.width) * ceil (node->bounds.size.height));
+  }
+#endif
 
   /* XXX: We could intersect bounds with clip bounds here */
   surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,


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