diff options
author | Matthias Clasen <mclasen@redhat.com> | 2018-01-14 09:52:52 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2018-01-14 17:05:04 -0500 |
commit | c56419818fac67cdf653e1254e68553f5371e7aa (patch) | |
tree | 36893f9a7495ad4c066bdc54845d927592651720 /gsk/vulkan | |
parent | 782c76c146dc0af26aeea50992f60e346e4f93f5 (diff) | |
download | gtk+-c56419818fac67cdf653e1254e68553f5371e7aa.tar.gz |
gsk: make logging per-renderer
Add a setter for per-renderer debug flags, and use
them where possible. Some places don't have easy access
to a renderer, so this is not complete.
Also, use g_message instead of g_print throughout.
Diffstat (limited to 'gsk/vulkan')
-rw-r--r-- | gsk/vulkan/gskvulkanglyphcache.c | 25 | ||||
-rw-r--r-- | gsk/vulkan/gskvulkanglyphcacheprivate.h | 3 | ||||
-rw-r--r-- | gsk/vulkan/gskvulkanrenderer.c | 2 | ||||
-rw-r--r-- | gsk/vulkan/gskvulkanrenderpass.c | 52 | ||||
-rw-r--r-- | gsk/vulkan/gskvulkanshader.c | 2 |
5 files changed, 45 insertions, 39 deletions
diff --git a/gsk/vulkan/gskvulkanglyphcache.c b/gsk/vulkan/gskvulkanglyphcache.c index 8d12f5ce66..ce3a6947e6 100644 --- a/gsk/vulkan/gskvulkanglyphcache.c +++ b/gsk/vulkan/gskvulkanglyphcache.c @@ -5,6 +5,7 @@ #include "gskvulkanimageprivate.h" #include "gskdebugprivate.h" #include "gskprivate.h" +#include "gskrendererprivate.h" #include <graphene.h> @@ -35,6 +36,7 @@ struct _GskVulkanGlyphCache { GObject parent_instance; GdkVulkanContext *vulkan; + GskRenderer *renderer; GHashTable *hash_table; GPtrArray *atlases; @@ -226,7 +228,7 @@ add_to_cache (GskVulkanGlyphCache *cache, atlas->num_glyphs++; #ifdef G_ENABLE_DEBUG - if (GSK_DEBUG_CHECK(GLYPH_CACHE)) + if (GSK_RENDERER_DEBUG_CHECK (cache->renderer, GLYPH_CACHE)) { g_print ("Glyph cache:\n"); for (i = 0; i < cache->atlases->len; i++) @@ -288,8 +290,9 @@ render_glyph (Atlas *atlas, } static void -upload_dirty_glyphs (Atlas *atlas, - GskVulkanUploader *uploader) +upload_dirty_glyphs (GskVulkanGlyphCache *cache, + Atlas *atlas, + GskVulkanUploader *uploader) { GList *l; guint num_regions; @@ -302,8 +305,8 @@ upload_dirty_glyphs (Atlas *atlas, for (l = atlas->dirty_glyphs, i = 0; l; l = l->next, i++) render_glyph (atlas, (DirtyGlyph *)l->data, ®ions[i]); - GSK_NOTE (GLYPH_CACHE, - g_print ("uploading %d glyphs to cache\n", num_regions)); + GSK_RENDERER_NOTE (cache->renderer, GLYPH_CACHE, + g_message ("uploading %d glyphs to cache", num_regions)); gsk_vulkan_image_upload_regions (atlas->image, uploader, num_regions, regions); @@ -312,11 +315,13 @@ upload_dirty_glyphs (Atlas *atlas, } GskVulkanGlyphCache * -gsk_vulkan_glyph_cache_new (GdkVulkanContext *vulkan) +gsk_vulkan_glyph_cache_new (GskRenderer *renderer, + GdkVulkanContext *vulkan) { GskVulkanGlyphCache *cache; cache = GSK_VULKAN_GLYPH_CACHE (g_object_new (GSK_TYPE_VULKAN_GLYPH_CACHE, NULL)); + cache->renderer = renderer; cache->vulkan = vulkan; g_ptr_array_add (cache->atlases, create_atlas (cache)); @@ -395,7 +400,7 @@ gsk_vulkan_glyph_cache_get_glyph_image (GskVulkanGlyphCache *cache, atlas->image = gsk_vulkan_image_new_for_atlas (cache->vulkan, atlas->width, atlas->height); if (atlas->dirty_glyphs) - upload_dirty_glyphs (atlas, uploader); + upload_dirty_glyphs (cache, atlas, uploader); return atlas->image; } @@ -449,8 +454,8 @@ gsk_vulkan_glyph_cache_begin_frame (GskVulkanGlyphCache *cache) if (atlas->old_pixels > MAX_OLD * atlas->width * atlas->height) { - GSK_NOTE(GLYPH_CACHE, - g_print ("Dropping atlas %d (%g.2%% old)\n", i, 100.0 * (double)atlas->old_pixels / (double)(atlas->width * atlas->height))); + GSK_RENDERER_NOTE(cache->renderer, GLYPH_CACHE, + g_message ("Dropping atlas %d (%g.2%% old)", i, 100.0 * (double)atlas->old_pixels / (double)(atlas->width * atlas->height))); g_ptr_array_remove_index (cache->atlases, i); drops[i] = 1; @@ -479,5 +484,5 @@ gsk_vulkan_glyph_cache_begin_frame (GskVulkanGlyphCache *cache) } } - GSK_NOTE(GLYPH_CACHE, g_print ("Dropped %d glyphs\n", dropped)); + GSK_RENDERER_NOTE(cache->renderer, GLYPH_CACHE, g_message ("Dropped %d glyphs", dropped)); } diff --git a/gsk/vulkan/gskvulkanglyphcacheprivate.h b/gsk/vulkan/gskvulkanglyphcacheprivate.h index 6cf223f27d..b566e5b9bc 100644 --- a/gsk/vulkan/gskvulkanglyphcacheprivate.h +++ b/gsk/vulkan/gskvulkanglyphcacheprivate.h @@ -11,7 +11,8 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE(GskVulkanGlyphCache, gsk_vulkan_glyph_cache, GSK, VULKAN_GLYPH_CACHE, GObject) -GskVulkanGlyphCache *gsk_vulkan_glyph_cache_new (GdkVulkanContext *vulkan); +GskVulkanGlyphCache *gsk_vulkan_glyph_cache_new (GskRenderer *renderer, + GdkVulkanContext *vulkan); GskVulkanImage * gsk_vulkan_glyph_cache_get_glyph_image (GskVulkanGlyphCache *cache, GskVulkanUploader *uploader, diff --git a/gsk/vulkan/gskvulkanrenderer.c b/gsk/vulkan/gskvulkanrenderer.c index 82c25ecd53..e6b180a90f 100644 --- a/gsk/vulkan/gskvulkanrenderer.c +++ b/gsk/vulkan/gskvulkanrenderer.c @@ -127,7 +127,7 @@ gsk_vulkan_renderer_realize (GskRenderer *renderer, self->render = gsk_vulkan_render_new (renderer, self->vulkan); - self->glyph_cache = gsk_vulkan_glyph_cache_new (self->vulkan); + self->glyph_cache = gsk_vulkan_glyph_cache_new (renderer, self->vulkan); return TRUE; } diff --git a/gsk/vulkan/gskvulkanrenderpass.c b/gsk/vulkan/gskvulkanrenderpass.c index 83fff2d5e7..880941e4c8 100644 --- a/gsk/vulkan/gskvulkanrenderpass.c +++ b/gsk/vulkan/gskvulkanrenderpass.c @@ -254,7 +254,7 @@ font_has_color_glyphs (const PangoFont *font) } #define FALLBACK(...) G_STMT_START { \ - GSK_NOTE (FALLBACK, g_print (__VA_ARGS__)); \ + GSK_RENDERER_NOTE (gsk_vulkan_render_get_renderer (render), FALLBACK, g_message (__VA_ARGS__)); \ goto fallback; \ }G_STMT_END @@ -277,7 +277,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, return; case GSK_SHADOW_NODE: default: - FALLBACK ("Unsupported node '%s'\n", node->node_class->type_name); + FALLBACK ("Unsupported node '%s'", node->node_class->type_name); case GSK_REPEAT_NODE: if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds)) @@ -287,7 +287,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR) pipeline_type = GSK_VULKAN_PIPELINE_TEXTURE_CLIP_ROUNDED; else - FALLBACK ("Repeat nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Repeat nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_REPEAT; op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type); g_array_append_val (self->render_ops, op); @@ -301,7 +301,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR) pipeline_type = GSK_VULKAN_PIPELINE_BLEND_MODE_CLIP_ROUNDED; else - FALLBACK ("Blend nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Blend nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_BLEND_MODE; op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type); g_array_append_val (self->render_ops, op); @@ -315,7 +315,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR) pipeline_type = GSK_VULKAN_PIPELINE_CROSS_FADE_CLIP_ROUNDED; else - FALLBACK ("Cross fade nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Cross fade nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_CROSS_FADE; op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type); g_array_append_val (self->render_ops, op); @@ -323,7 +323,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, case GSK_INSET_SHADOW_NODE: if (gsk_inset_shadow_node_get_blur_radius (node) > 0) - FALLBACK ("Blur support not implemented for inset shadows\n"); + FALLBACK ("Blur support not implemented for inset shadows"); else if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds)) pipeline_type = GSK_VULKAN_PIPELINE_INSET_SHADOW; else if (constants->clip.type == GSK_VULKAN_CLIP_RECT) @@ -331,7 +331,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR) pipeline_type = GSK_VULKAN_PIPELINE_INSET_SHADOW_CLIP_ROUNDED; else - FALLBACK ("Inset shadow nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Inset shadow nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_INSET_SHADOW; op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type); g_array_append_val (self->render_ops, op); @@ -339,7 +339,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, case GSK_OUTSET_SHADOW_NODE: if (gsk_outset_shadow_node_get_blur_radius (node) > 0) - FALLBACK ("Blur support not implemented for outset shadows\n"); + FALLBACK ("Blur support not implemented for outset shadows"); else if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds)) pipeline_type = GSK_VULKAN_PIPELINE_OUTSET_SHADOW; else if (constants->clip.type == GSK_VULKAN_CLIP_RECT) @@ -347,7 +347,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR) pipeline_type = GSK_VULKAN_PIPELINE_OUTSET_SHADOW_CLIP_ROUNDED; else - FALLBACK ("Outset shadow nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Outset shadow nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_OUTSET_SHADOW; op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type); g_array_append_val (self->render_ops, op); @@ -363,7 +363,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR) pipeline_type = GSK_VULKAN_PIPELINE_TEXTURE_CLIP_ROUNDED; else - FALLBACK ("Cairo nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Cairo nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_SURFACE; op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type); g_array_append_val (self->render_ops, op); @@ -388,7 +388,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR) pipeline_type = GSK_VULKAN_PIPELINE_COLOR_TEXT_CLIP_ROUNDED; else - FALLBACK ("Text nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Text nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_COLOR_TEXT; } else @@ -400,7 +400,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR) pipeline_type = GSK_VULKAN_PIPELINE_TEXT_CLIP_ROUNDED; else - FALLBACK ("Text nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Text nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_TEXT; } op.text.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type); @@ -447,7 +447,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR) pipeline_type = GSK_VULKAN_PIPELINE_TEXTURE_CLIP_ROUNDED; else - FALLBACK ("Texture nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Texture nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_TEXTURE; op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type); g_array_append_val (self->render_ops, op); @@ -461,7 +461,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR) pipeline_type = GSK_VULKAN_PIPELINE_COLOR_CLIP_ROUNDED; else - FALLBACK ("Color nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Color nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_COLOR; op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type); g_array_append_val (self->render_ops, op); @@ -470,7 +470,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, case GSK_LINEAR_GRADIENT_NODE: case GSK_REPEATING_LINEAR_GRADIENT_NODE: if (gsk_linear_gradient_node_get_n_color_stops (node) > GSK_VULKAN_LINEAR_GRADIENT_PIPELINE_MAX_COLOR_STOPS) - FALLBACK ("Linear gradient with %zu color stops, hardcoded limit is %u\n", + FALLBACK ("Linear gradient with %zu color stops, hardcoded limit is %u", gsk_linear_gradient_node_get_n_color_stops (node), GSK_VULKAN_LINEAR_GRADIENT_PIPELINE_MAX_COLOR_STOPS); if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds)) @@ -480,7 +480,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR) pipeline_type = GSK_VULKAN_PIPELINE_LINEAR_GRADIENT_CLIP_ROUNDED; else - FALLBACK ("Linear gradient nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Linear gradient nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_LINEAR_GRADIENT; op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type); g_array_append_val (self->render_ops, op); @@ -494,7 +494,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR) pipeline_type = GSK_VULKAN_PIPELINE_COLOR_MATRIX_CLIP_ROUNDED; else - FALLBACK ("Opacity nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Opacity nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_OPACITY; op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type); g_array_append_val (self->render_ops, op); @@ -508,7 +508,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR) pipeline_type = GSK_VULKAN_PIPELINE_BLUR_CLIP_ROUNDED; else - FALLBACK ("Blur nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Blur nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_BLUR; op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type); g_array_append_val (self->render_ops, op); @@ -522,7 +522,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR) pipeline_type = GSK_VULKAN_PIPELINE_COLOR_MATRIX_CLIP_ROUNDED; else - FALLBACK ("Color matrix nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Color matrix nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_COLOR_MATRIX; op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type); g_array_append_val (self->render_ops, op); @@ -536,7 +536,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR) pipeline_type = GSK_VULKAN_PIPELINE_BORDER_CLIP_ROUNDED; else - FALLBACK ("Border nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Border nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_BORDER; op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type); g_array_append_val (self->render_ops, op); @@ -568,7 +568,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, graphene_matrix_multiply (&transform, &mv, &self->mv); child = gsk_transform_node_get_child (node); if (!gsk_vulkan_push_constants_transform (&op.constants.constants, constants, &transform, &child->bounds)) - FALLBACK ("Transform nodes can't deal with clip type %u\n", constants->clip.type); + FALLBACK ("Transform nodes can't deal with clip type %u", constants->clip.type); op.type = GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS; g_array_append_val (self->render_ops, op); @@ -582,7 +582,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, case GSK_CLIP_NODE: { if (!gsk_vulkan_push_constants_intersect_rect (&op.constants.constants, constants, gsk_clip_node_peek_clip (node))) - FALLBACK ("Failed to find intersection between clip of type %u and rectangle\n", constants->clip.type); + FALLBACK ("Failed to find intersection between clip of type %u and rectangle", constants->clip.type); if (op.constants.constants.clip.type == GSK_VULKAN_CLIP_ALL_CLIPPED) return; @@ -601,7 +601,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self, if (!gsk_vulkan_push_constants_intersect_rounded (&op.constants.constants, constants, gsk_rounded_clip_node_peek_clip (node))) - FALLBACK ("Failed to find intersection between clip of type %u and rounded rectangle\n", constants->clip.type); + FALLBACK ("Failed to find intersection between clip of type %u and rounded rectangle", constants->clip.type); if (op.constants.constants.clip.type == GSK_VULKAN_CLIP_ALL_CLIPPED) return; @@ -773,7 +773,7 @@ gsk_vulkan_render_pass_get_node_as_texture (GskVulkanRenderPass *self, } } - GSK_NOTE (FALLBACK, g_print ("Node as texture not implemented for this case. Using %gx%g fallback surface\n", + GSK_RENDERER_NOTE (gsk_vulkan_render_get_renderer (render), FALLBACK, g_message ("Node as texture not implemented for this case. Using %gx%g fallback surface", ceil (bounds->size.width), ceil (bounds->size.height))); #ifdef G_ENABLE_DEBUG @@ -827,8 +827,8 @@ gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderPass *self, node = op->node; - GSK_NOTE (FALLBACK, - g_print ("Upload op=%s, node %s[%p], bounds %gx%g\n", + GSK_RENDERER_NOTE (gsk_vulkan_render_get_renderer (render), FALLBACK, + g_message ("Upload op=%s, node %s[%p], bounds %gx%g", op->type == GSK_VULKAN_OP_FALLBACK_CLIP ? "fallback-clip" : (op->type == GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP ? "fallback-rounded-clip" : "fallback"), node->name ? node->name : node->node_class->type_name, node, diff --git a/gsk/vulkan/gskvulkanshader.c b/gsk/vulkan/gskvulkanshader.c index 1010b21304..0446412ea7 100644 --- a/gsk/vulkan/gskvulkanshader.c +++ b/gsk/vulkan/gskvulkanshader.c @@ -65,7 +65,7 @@ gsk_vulkan_shader_new_from_resource (GdkVulkanContext *context, g_free (path); if (bytes == NULL) { - GSK_NOTE (VULKAN, g_printerr ("Error loading shader data: %s\n", local_error->message)); + GSK_NOTE (VULKAN, g_message ("Error loading shader data: %s", local_error->message)); g_propagate_error (error, local_error); return NULL; } |