[Cogl] [PATCH] pipeline: only maintain breadcrumb for debug builds

Robert Bragg robert at sixbynine.org
Thu May 30 07:42:35 PDT 2013


From: Robert Bragg <robert at linux.intel.com>

This ensures we only add a static_breadcrumb pointer to every
CoglPipeline when build with debugging enabled. Since applications may
allocate a lot of pipelines we want to keep the basic size of pipelines
(ignoring optional sparse state) down to a minimum.
---
 cogl/cogl-pipeline-debug.c   | 7 ++++++-
 cogl/cogl-pipeline-private.h | 6 ++++++
 cogl/cogl-pipeline.c         | 6 ++++++
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/cogl/cogl-pipeline-debug.c b/cogl/cogl-pipeline-debug.c
index cd31111..afac990 100644
--- a/cogl/cogl-pipeline-debug.c
+++ b/cogl/cogl-pipeline-debug.c
@@ -158,7 +158,12 @@ dump_pipeline_cb (CoglNode *node, void *user_data)
                           pipeline,
                           COGL_OBJECT (pipeline)->ref_count,
                           pipeline->has_static_breadcrumb ?
-                          pipeline->static_breadcrumb : "NULL");
+#ifdef COGL_DEBUG_ENABLED
+                          pipeline->static_breadcrumb : "NULL"
+#else
+                          "NULL"
+#endif
+                          );
 
   changes_label = g_string_new ("");
   g_string_append_printf (changes_label,
diff --git a/cogl/cogl-pipeline-private.h b/cogl/cogl-pipeline-private.h
index f17e2f3..6172e76 100644
--- a/cogl/cogl-pipeline-private.h
+++ b/cogl/cogl-pipeline-private.h
@@ -375,10 +375,12 @@ struct _CoglPipeline
    * be allocated dynamically when required... */
   CoglPipelineBigState *big_state;
 
+#ifdef COGL_DEBUG_ENABLED
   /* For debugging purposes it's possible to associate a static const
    * string with a pipeline which can be an aid when trying to trace
    * where the pipeline originates from */
   const char      *static_breadcrumb;
+#endif
 
   /* Cached state... */
 
@@ -432,10 +434,12 @@ struct _CoglPipeline
 
   unsigned int          layers_cache_dirty:1;
 
+#ifdef COGL_DEBUG_ENABLED
   /* For debugging purposes it's possible to associate a static const
    * string with a pipeline which can be an aid when trying to trace
    * where the pipeline originates from */
   unsigned int          has_static_breadcrumb:1;
+#endif
 
   /* There are multiple fragment and vertex processing backends for
    * CoglPipeline, glsl, arbfp and fixed that are bundled under a
@@ -832,9 +836,11 @@ void
 _cogl_pipeline_set_blend_enabled (CoglPipeline *pipeline,
                                   CoglPipelineBlendEnable enable);
 
+#ifdef COGL_DEBUG_ENABLED
 void
 _cogl_pipeline_set_static_breadcrumb (CoglPipeline *pipeline,
                                       const char *breadcrumb);
+#endif
 
 unsigned long
 _cogl_pipeline_get_age (CoglPipeline *pipeline);
diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c
index 8769f8b..b52802f 100644
--- a/cogl/cogl-pipeline.c
+++ b/cogl/cogl-pipeline.c
@@ -395,7 +395,9 @@ cogl_pipeline_new (CoglContext *context)
   CoglPipeline *new;
 
   new = cogl_pipeline_copy (context->default_pipeline);
+#ifdef COGL_DEBUG_ENABLED
   _cogl_pipeline_set_static_breadcrumb (new, "new");
+#endif
   return new;
 }
 
@@ -1220,8 +1222,10 @@ _cogl_pipeline_pre_change_notify (CoglPipeline     *pipeline,
 
       new_authority =
         cogl_pipeline_copy (_cogl_pipeline_get_parent (pipeline));
+#ifdef COGL_DEBUG_ENABLED
       _cogl_pipeline_set_static_breadcrumb (new_authority,
                                             "pre_change_notify:copy-on-write");
+#endif
 
       /* We could explicitly walk the descendants, OR together the set
        * of differences that we determine this pipeline is the
@@ -2372,6 +2376,7 @@ _cogl_pipeline_journal_unref (CoglPipeline *pipeline)
   cogl_object_unref (pipeline);
 }
 
+#ifdef COGL_DEBUG_ENABLED
 void
 _cogl_pipeline_set_static_breadcrumb (CoglPipeline *pipeline,
                                       const char *breadcrumb)
@@ -2379,6 +2384,7 @@ _cogl_pipeline_set_static_breadcrumb (CoglPipeline *pipeline,
   pipeline->has_static_breadcrumb = TRUE;
   pipeline->static_breadcrumb = breadcrumb;
 }
+#endif
 
 typedef void (*LayerStateHashFunction) (CoglPipelineLayer *authority,
                                         CoglPipelineLayer **authorities,
-- 
1.8.2.1



More information about the Cogl mailing list