GskGLRenderer: Add debug groups

This adds debug groups in various places, including the debug
nodes if those are in use. This makes the traces in tools like
renderdoc much easier to read.
This commit is contained in:
Alexander Larsson 2019-04-24 13:28:11 +02:00
parent 4f7171885f
commit 32edf29c0a
4 changed files with 64 additions and 1 deletions

View File

@ -262,10 +262,15 @@ upload_dirty_glyph (GskGLGlyphCache *self,
g_assert (atlas->pending_glyph.key != NULL);
gdk_gl_context_push_debug_group_printf (gsk_gl_driver_get_gl_context (self->gl_driver),
"Uploading glyph %d", atlas->pending_glyph.key->glyph);
render_glyph (atlas, &atlas->pending_glyph, &region);
gsk_gl_image_upload_regions (atlas->image, self->gl_driver, 1, &region);
gdk_gl_context_pop_debug_group (gsk_gl_driver_get_gl_context (self->gl_driver));
g_free (region.data);
atlas->pending_glyph.key = NULL;

View File

@ -2517,9 +2517,11 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
break;
case GSK_DEBUG_NODE:
ops_push_debug_group (builder, gsk_debug_node_get_message (node));
gsk_gl_renderer_add_render_ops (self,
gsk_debug_node_get_child (node),
builder);
ops_pop_debug_group (builder);
break;
case GSK_COLOR_NODE:
@ -2784,7 +2786,9 @@ gsk_gl_renderer_render_ops (GskGLRenderer *self,
op->op == OP_CHANGE_VAO)
continue;
if (op->op != OP_CHANGE_PROGRAM &&
if (op->op != OP_PUSH_DEBUG_GROUP &&
op->op != OP_POP_DEBUG_GROUP &&
op->op != OP_CHANGE_PROGRAM &&
op->op != OP_CHANGE_RENDER_TARGET &&
op->op != OP_CLEAR &&
program == NULL)
@ -2889,6 +2893,14 @@ gsk_gl_renderer_render_ops (GskGLRenderer *self,
dump_framebuffer (op->dump.filename, op->dump.width, op->dump.height);
break;
case OP_PUSH_DEBUG_GROUP:
gdk_gl_context_push_debug_group (self->gl_context, op->debug_group.text);
break;
case OP_POP_DEBUG_GROUP:
gdk_gl_context_pop_debug_group (self->gl_context);
break;
default:
g_warn_if_reached ();
}
@ -2981,7 +2993,9 @@ gsk_gl_renderer_do_render (GskRenderer *renderer,
if (fbo_id != 0)
ops_set_render_target (&self->op_builder, fbo_id);
gdk_gl_context_push_debug_group (self->gl_context, "Adding render ops");
gsk_gl_renderer_add_render_ops (self, root, &self->op_builder);
gdk_gl_context_pop_debug_group (self->gl_context);
/* We correctly reset the state everywhere */
g_assert_cmpint (self->op_builder.current_render_target, ==, fbo_id);
@ -3010,7 +3024,9 @@ gsk_gl_renderer_do_render (GskRenderer *renderer,
glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glBlendEquation (GL_FUNC_ADD);
gdk_gl_context_push_debug_group (self->gl_context, "Rendering ops");
gsk_gl_renderer_render_ops (self, buffer_size);
gdk_gl_context_pop_debug_group (self->gl_context);
#ifdef G_ENABLE_DEBUG
gsk_profiler_counter_inc (profiler, self->profile_counters.frames);
@ -3038,6 +3054,9 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
g_return_val_if_fail (self->gl_context != NULL, NULL);
gdk_gl_context_push_debug_group_printf (self->gl_context,
"Render %s<%p> to texture", root->node_class->type_name, root);
width = ceilf (viewport->size.width);
height = ceilf (viewport->size.height);
@ -3075,6 +3094,9 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
NULL, NULL);
gsk_gl_driver_end_frame (self->gl_driver);
gdk_gl_context_pop_debug_group (self->gl_context);
gsk_gl_renderer_clear_tree (self);
return texture;
}
@ -3093,6 +3115,9 @@ gsk_gl_renderer_render (GskRenderer *renderer,
if (self->gl_context == NULL)
return;
gdk_gl_context_push_debug_group_printf (self->gl_context,
"Render root node %p", root);
surface = gsk_renderer_get_surface (renderer);
whole_surface = (GdkRectangle) {
0, 0,
@ -3138,6 +3163,8 @@ gsk_gl_renderer_render (GskRenderer *renderer,
gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (self->gl_context));
gdk_gl_context_pop_debug_group (self->gl_context);
g_clear_pointer (&self->render_region, cairo_region_destroy);
}

View File

@ -58,6 +58,28 @@ ops_dump_framebuffer (RenderOpBuilder *builder,
g_array_append_val (builder->render_ops, op);
}
void
ops_push_debug_group (RenderOpBuilder *builder,
const char *text)
{
RenderOp op;
op.op = OP_PUSH_DEBUG_GROUP;
strncpy (op.debug_group.text, text, sizeof(op.debug_group.text) - 1);
op.debug_group.text[sizeof(op.debug_group.text) - 1] = 0; /* Ensure zero terminated */
g_array_append_val (builder->render_ops, op);
}
void
ops_pop_debug_group (RenderOpBuilder *builder)
{
RenderOp op;
op.op = OP_POP_DEBUG_GROUP;
g_array_append_val (builder->render_ops, op);
}
float
ops_get_scale (const RenderOpBuilder *builder)
{

View File

@ -59,6 +59,8 @@ enum {
OP_CLEAR = 21,
OP_DRAW = 22,
OP_DUMP_FRAMEBUFFER = 23,
OP_PUSH_DEBUG_GROUP = 24,
OP_POP_DEBUG_GROUP = 25,
};
typedef struct
@ -217,6 +219,9 @@ typedef struct
int width;
int height;
} dump;
struct {
char text[180]; /* Size of linear_gradient, so 'should be enough' without growing RenderOp */
} debug_group;
};
} RenderOp;
@ -278,6 +283,10 @@ void ops_dump_framebuffer (RenderOpBuilder *builder,
int width,
int height);
void ops_init (RenderOpBuilder *builder);
void ops_push_debug_group (RenderOpBuilder *builder,
const char *text);
void ops_pop_debug_group (RenderOpBuilder *builder);
void ops_finish (RenderOpBuilder *builder);
void ops_push_modelview (RenderOpBuilder *builder,
const graphene_matrix_t *mv,