[gtk/wip/alexl/gl-debug: 2/4] GskGLRenderer: Label various gl objects



commit 5bd6e92a798b1b7f2111c6d9af32c7c4ff06df79
Author: Alexander Larsson <alexl redhat com>
Date:   Wed Apr 24 13:27:43 2019 +0200

    GskGLRenderer: Label various gl objects
    
    This means the names are more useful in tools like renderdoc.

 gsk/gl/gskgldriver.c        | 16 +++++++++++++++-
 gsk/gl/gskgldriverprivate.h |  1 +
 gsk/gl/gskglglyphcache.c    |  5 +++++
 gsk/gl/gskglrenderer.c      | 21 +++++++++++++++++++++
 4 files changed, 42 insertions(+), 1 deletion(-)
---
diff --git a/gsk/gl/gskgldriver.c b/gsk/gl/gskgldriver.c
index de90d84d54..95351cd051 100644
--- a/gsk/gl/gskgldriver.c
+++ b/gsk/gl/gskgldriver.c
@@ -4,6 +4,7 @@
 
 #include "gskdebugprivate.h"
 #include "gskprofilerprivate.h"
+#include "gdk/gdkglcontextprivate.h"
 #include "gdk/gdktextureprivate.h"
 #include "gdk/gdkgltextureprivate.h"
 
@@ -298,6 +299,13 @@ gsk_gl_driver_collect_textures (GskGLDriver *self)
   return old_size - g_hash_table_size (self->textures);
 }
 
+
+GdkGLContext *
+gsk_gl_driver_get_gl_context (GskGLDriver *self)
+{
+  return self->gl_context;
+}
+
 int
 gsk_gl_driver_get_max_texture_size (GskGLDriver *self)
 {
@@ -527,6 +535,8 @@ gsk_gl_driver_get_texture_for_texture (GskGLDriver *self,
     }
 
   t = create_texture (self, gdk_texture_get_width (texture), gdk_texture_get_height (texture));
+  gdk_gl_context_label_object_printf (self->gl_context, GL_TEXTURE, t->texture_id,
+                                      "GdkTexture<%p> %d", texture, t->texture_id);
 
   if (gdk_texture_set_render_data (texture, self, t, gsk_gl_driver_release_texture))
     t->user = texture;
@@ -639,7 +649,11 @@ gsk_gl_driver_create_render_target (GskGLDriver *self,
   glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, t->texture_id, 0);
 
   if (add_depth_buffer || add_stencil_buffer)
-    glGenRenderbuffersEXT (1, &depth_stencil_buffer_id);
+    {
+      glGenRenderbuffersEXT (1, &depth_stencil_buffer_id);
+      gdk_gl_context_label_object_printf (self->gl_context, GL_RENDERBUFFER, depth_stencil_buffer_id,
+                                          "%s buffer for %d", add_depth_buffer ? "Depth" : "Stencil", 
texture_id);
+    }
   else
     depth_stencil_buffer_id = 0;
 
diff --git a/gsk/gl/gskgldriverprivate.h b/gsk/gl/gskgldriverprivate.h
index a73b62b2d0..a3cd675dea 100644
--- a/gsk/gl/gskgldriverprivate.h
+++ b/gsk/gl/gskgldriverprivate.h
@@ -23,6 +23,7 @@ typedef struct {
 
 
 GskGLDriver *   gsk_gl_driver_new                       (GdkGLContext    *context);
+GdkGLContext   *gsk_gl_driver_get_gl_context            (GskGLDriver     *driver);
 
 int             gsk_gl_driver_get_max_texture_size      (GskGLDriver     *driver);
 
diff --git a/gsk/gl/gskglglyphcache.c b/gsk/gl/gskglglyphcache.c
index 44618a257c..d3627fb8ea 100644
--- a/gsk/gl/gskglglyphcache.c
+++ b/gsk/gl/gskglglyphcache.c
@@ -5,6 +5,8 @@
 #include "gskdebugprivate.h"
 #include "gskprivate.h"
 
+#include "gdk/gdkglcontextprivate.h"
+
 #include <graphene.h>
 #include <cairo.h>
 #include <epoxy/gl.h>
@@ -345,6 +347,9 @@ gsk_gl_glyph_cache_get_glyph_image (GskGLGlyphCache        *self,
     {
       atlas->image = g_new0 (GskGLImage, 1);
       gsk_gl_image_create (atlas->image, self->gl_driver, atlas->width, atlas->height);
+      gdk_gl_context_label_object_printf (gsk_gl_driver_get_gl_context (self->gl_driver),
+                                          GL_TEXTURE, atlas->image->texture_id,
+                                          "Glyph atlas %d", atlas->image->texture_id);
     }
 
   if (atlas->pending_glyph.key != NULL)
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index 1ee037feb7..6cf6dba7c7 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -20,6 +20,7 @@
 #include "gskprivate.h"
 
 #include "gdk/gdkgltextureprivate.h"
+#include "gdk/gdkglcontextprivate.h"
 
 #include <epoxy/gl.h>
 #include <cairo-ft.h>
@@ -477,6 +478,8 @@ render_fallback_node (GskGLRenderer       *self,
   texture_id = gsk_gl_driver_create_texture (self->gl_driver,
                                              surface_width,
                                              surface_height);
+  gdk_gl_context_label_object_printf  (self->gl_context, GL_TEXTURE, texture_id,
+                                       "Fallback %s %d", node->node_class->type_name, texture_id);
 
   gsk_gl_driver_bind_source_texture (self->gl_driver, texture_id);
   gsk_gl_driver_init_texture_with_surface (self->gl_driver,
@@ -1427,9 +1430,13 @@ render_outset_shadow_node (GskGLRenderer       *self,
       GskRoundedRect blit_clip;
 
       texture_id = gsk_gl_driver_create_texture (self->gl_driver, texture_width, texture_height);
+      gdk_gl_context_label_object_printf (self->gl_context, GL_TEXTURE, texture_id,
+                                          "Outset Shadow Temp %d", texture_id);
       gsk_gl_driver_bind_source_texture (self->gl_driver, texture_id);
       gsk_gl_driver_init_texture_empty (self->gl_driver, texture_id);
       render_target = gsk_gl_driver_create_render_target (self->gl_driver, texture_id, FALSE, FALSE);
+      gdk_gl_context_label_object_printf  (self->gl_context, GL_FRAMEBUFFER, render_target,
+                                           "Outset Shadow FB Temp %d", render_target);
 
 
       graphene_matrix_init_ortho (&item_proj,
@@ -1460,9 +1467,13 @@ render_outset_shadow_node (GskGLRenderer       *self,
       });
 
       blurred_texture_id = gsk_gl_driver_create_permanent_texture (self->gl_driver, texture_width, 
texture_height);
+      gdk_gl_context_label_object_printf (self->gl_context, GL_TEXTURE, blurred_texture_id,
+                                          "Outset Shadow Cache %d", blurred_texture_id);
       gsk_gl_driver_bind_source_texture (self->gl_driver, blurred_texture_id);
       gsk_gl_driver_init_texture_empty (self->gl_driver, blurred_texture_id);
       blurred_render_target = gsk_gl_driver_create_render_target (self->gl_driver, blurred_texture_id, TRUE, 
TRUE);
+      gdk_gl_context_label_object_printf  (self->gl_context, GL_FRAMEBUFFER, render_target,
+                                           "Outset Shadow Cache FB %d", render_target);
 
       ops_set_render_target (builder, blurred_render_target);
       ops_pop_clip (builder);
@@ -2641,9 +2652,14 @@ add_offscreen_ops (GskGLRenderer         *self,
   }
 
   texture_id = gsk_gl_driver_create_texture (self->gl_driver, width, height);
+  gdk_gl_context_label_object_printf (self->gl_context, GL_TEXTURE, texture_id,
+                                      "Offscreen<%s> %d", child_node->node_class->type_name, texture_id);
+
   gsk_gl_driver_bind_source_texture (self->gl_driver, texture_id);
   gsk_gl_driver_init_texture_empty (self->gl_driver, texture_id);
   render_target = gsk_gl_driver_create_render_target (self->gl_driver, texture_id, TRUE, TRUE);
+  gdk_gl_context_label_object_printf  (self->gl_context, GL_FRAMEBUFFER, render_target,
+                                       "Offscreen<%s> FB %d", child_node->node_class->type_name, 
render_target);
 
   graphene_matrix_init_ortho (&item_proj,
                               bounds->origin.x * scale,
@@ -3035,6 +3051,9 @@ gsk_gl_renderer_render_texture (GskRenderer           *renderer,
   glGenTextures (1, &texture_id);
   glBindTexture (GL_TEXTURE_2D, texture_id);
 
+  gdk_gl_context_label_object_printf  (self->gl_context, GL_TEXTURE, texture_id,
+                                       "Texture %s<%p> %d", root->node_class->type_name, root, texture_id);
+
   if (gdk_gl_context_get_use_es (self->gl_context))
     glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
   else
@@ -3042,6 +3061,8 @@ gsk_gl_renderer_render_texture (GskRenderer           *renderer,
 
   glGenFramebuffers (1, &fbo_id);
   glBindFramebuffer (GL_FRAMEBUFFER, fbo_id);
+  gdk_gl_context_label_object_printf  (self->gl_context, GL_FRAMEBUFFER, fbo_id,
+                                       "FB %s<%p> %d", root->node_class->type_name, root, fbo_id);
   glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0);
   g_assert_cmphex (glCheckFramebufferStatus (GL_FRAMEBUFFER), ==, GL_FRAMEBUFFER_COMPLETE);
 


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