diff --git a/cogl/cogl-debug-options.h b/cogl/cogl-debug-options.h
new file mode 100644
index 000000000..a73d7e1f6
--- /dev/null
+++ b/cogl/cogl-debug-options.h
@@ -0,0 +1,145 @@
+/*
+ * Cogl
+ *
+ * An object oriented GL/GLES Abstraction/Utility Layer
+ *
+ * Copyright (C) 2010 Intel Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ */
+
+OPT (HANDLE,
+     "Cogl Tracing",
+     "ref-counts",
+     "CoglObject references",
+     "Debug ref counting issues for CoglObjects")
+OPT (SLICING,
+     "Cogl Tracing",
+     "slicing",
+     "Trace Texture Slicing",
+     "debug the creation of texture slices")
+OPT (ATLAS,
+     "Cogl Tracing",
+     "atlas",
+     "Trace Atlas Textures",
+     "Debug texture atlas management")
+OPT (BLEND_STRINGS,
+     "Cogl Tracing",
+     "blend-strings",
+     "Trace Blend Strings",
+     "Debug CoglBlendString parsing")
+OPT (JOURNAL,
+     "Cogl Tracing",
+     "journal",
+     "Trace Journal",
+     "View all the geometry passing through the journal")
+OPT (BATCHING,
+     "Cogl Tracing",
+     "batching",
+     "Trace Batching",
+     "Show how geometry is being batched in the journal")
+OPT (MATRICES,
+     "Cogl Tracing",
+     "matrices",
+     "Trace matrices",
+     "Trace all matrix manipulation")
+/* XXX we should replace the "draw" option its very hand wavy... */
+OPT (DRAW,
+     "Cogl Tracing",
+     "draw",
+     "Trace Misc Drawing",
+     "Trace some misc drawing operations")
+OPT (PANGO,
+     "Cogl Tracing",
+     "pango",
+     "Trace Pango Renderer",
+     "Trace the Cogl Pango renderer")
+OPT (TEXTURE_PIXMAP,
+     "Cogl Tracing",
+     "texture-pixmap",
+     "Trace CoglTexturePixmap backend",
+     "Trace the Cogl texture pixmap backend")
+OPT (RECTANGLES,
+     "Visualize",
+     "rectangles",
+     "Outline rectangles",
+     "Add wire outlines for all rectangular geometry")
+OPT (DISABLE_BATCHING,
+     "Root Cause",
+     "disable-batching",
+     "Disable Journal batching",
+     "Disable batching of geometry in the Cogl Journal.")
+OPT (DISABLE_VBOS,
+     "Root Cause",
+     "disable-vbos",
+     "Disable GL Vertex Buffers",
+     "Disable use of OpenGL vertex buffer objects")
+OPT (DISABLE_PBOS,
+     "Root Cause",
+     "disable-pbos",
+     "Disable GL Pixel Buffers",
+     "Disable use of OpenGL pixel buffer objects")
+OPT (DISABLE_SOFTWARE_TRANSFORM,
+     "Root Cause",
+     "disable-software-transform",
+     "Disable software rect transform",
+     "Use the GPU to transform rectangular geometry")
+OPT (DUMP_ATLAS_IMAGE,
+     "Cogl Specialist",
+     "dump-atlas-image",
+     "Dump atlas images",
+     "Dump texture atlas changes to an image file")
+OPT (DISABLE_ATLAS,
+     "Root Cause",
+     "disable-atlas",
+     "Disable texture atlasing",
+     "Disable use of texture atlasing")
+OPT (DISABLE_TEXTURING,
+     "Root Cause",
+     "disable-texturing",
+     "Disable texturing",
+     "Disable texturing any primitives")
+OPT (DISABLE_ARBFP,
+     "Root Cause",
+     "disable-arbfp",
+     "Disable arbfp",
+     "Disable use of ARB fragment programs")
+OPT (DISABLE_GLSL,
+     "Root Cause",
+     "disable-glsl",
+     "Disable GLSL",
+     "Disable use of GLSL")
+OPT (DISABLE_BLENDING,
+     "Root Cause",
+     "disable-blending",
+     "Disable blending",
+     "Disable use of blending")
+OPT (SHOW_SOURCE,
+     "Cogl Tracing",
+     "show-source",
+     "Show source",
+     "Show generated ARBfp/GLSL source code")
+OPT (OPENGL,
+     "Cogl Tracing",
+     "opengl",
+     "Trace some OpenGL",
+     "Traces some select OpenGL calls")
+OPT (OFFSCREEN,
+     "Cogl Tracing",
+     "offscreen",
+     "Trace offscreen support",
+     "Debug offscreen support")
+
diff --git a/cogl/cogl-debug.c b/cogl/cogl-debug.c
index 0dbf7f254..2289af2ab 100644
--- a/cogl/cogl-debug.c
+++ b/cogl/cogl-debug.c
@@ -103,37 +103,14 @@ _cogl_parse_debug_string (const char *value,
   else if (strcmp (value, "help") == 0)
     {
       g_printerr ("\n\n%28s\n", "Supported debug values:");
-#define OPT(NAME, HELP) \
-      g_printerr ("%28s %s\n", NAME, HELP);
-      OPT ("handle:", "debug ref counting issues for Cogl objects");
-      OPT ("slicing:", "debug the creation of texture slices");
-      OPT ("atlas:", "debug texture atlas management");
-      OPT ("blend-strings:", "debug blend-string parsing");
-      OPT ("journal:", "view all geometry passing through the journal");
-      OPT ("batching:", "show how geometry is being batched in the journal");
-      OPT ("matrices:", "trace all matrix manipulation");
-      /* XXX: we should replace the "draw" option its very hand wavy... */
-      OPT ("draw:", "misc tracing of some drawing operations");
-      OPT ("pango:", "trace the pango renderer");
-      OPT ("texture-pixmap:", "trace the Cogl texture pixmap backend");
-      OPT ("rectangles:", "add wire outlines for all rectangular geometry");
-      OPT ("disable-batching:", "disable the journal batching");
-      OPT ("disable-vbos:", "disable use of OpenGL vertex buffer objects");
-      OPT ("disable-pbos:", "disable use of OpenGL pixel buffer objects");
-      OPT ("disable-software-transform",
-           "use the GPU to transform rectangular geometry");
-      OPT ("dump-atlas-image:", "dump atlas changes to an image file");
-      OPT ("disable-atlas:", "disable texture atlasing");
-      OPT ("disable-texturing:", "disable texturing primitives");
-      OPT ("disable-arbfp:", "disable use of ARBfp");
-      OPT ("disable-glsl:", "disable use of GLSL");
-      OPT ("disable-blending:", "disable use of blending");
-      OPT ("show-source:", "show generated ARBfp/GLSL");
-      OPT ("opengl:", "traces some select OpenGL calls");
-      OPT ("offscreen:", "debug offscreen support");
+#define OPT(MASK_NAME, GROUP, NAME, NAME_FORMATTED, DESCRIPTION) \
+      g_printerr ("%28s %s\n", NAME ":", DESCRIPTION);
+#include "cogl-debug-options.h"
       g_printerr ("\n%28s\n", "Special debug values:");
-      OPT ("all:", "Enables all non-behavioural debug options");
-      OPT ("verbose:", "Enables all non-behavioural debug options");
+      OPT (IGNORED, "ignored", "all", "ignored", \
+           "Enables all non-behavioural debug options");
+      OPT (IGNORED, "ignored", "verbose", "ignored", \
+           "Enables all non-behavioural debug options");
 #undef OPT
       exit (1);
     }
diff --git a/cogl/cogl-debug.h b/cogl/cogl-debug.h
index 4adc23676..e9029afb2 100644
--- a/cogl/cogl-debug.h
+++ b/cogl/cogl-debug.h
@@ -24,6 +24,8 @@
 #ifndef __COGL_DEBUG_H__
 #define __COGL_DEBUG_H__
 
+#include "cogl-profile.h"
+
 #include <glib.h>
 
 G_BEGIN_DECLS
@@ -59,17 +61,17 @@ typedef enum {
 #ifdef COGL_ENABLE_DEBUG
 
 #ifdef __GNUC__
-#define COGL_NOTE(type,x,a...)                      G_STMT_START { \
-        if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_##type)) {   \
-          g_message ("[" #type "] " G_STRLOC ": " x, ##a);         \
+#define COGL_NOTE(type,x,a...)                      G_STMT_START {            \
+        if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_##type)) {              \
+          _cogl_profile_trace_message ("[" #type "] " G_STRLOC " & " x, ##a); \
         }                                           } G_STMT_END
 
 #else
-#define COGL_NOTE(type,...)                         G_STMT_START { \
-        if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_##type)) {   \
-          char *_fmt = g_strdup_printf (__VA_ARGS__);              \
-          g_message ("[" #type "] " G_STRLOC ": %s", _fmt);        \
-          g_free (_fmt);                                           \
+#define COGL_NOTE(type,...)                         G_STMT_START {            \
+        if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_##type)) {              \
+          char *_fmt = g_strdup_printf (__VA_ARGS__);                         \
+          _cogl_profile_trace_message ("[" #type "] " G_STRLOC " & %s", _fmt);\
+          g_free (_fmt);                                                      \
         }                                           } G_STMT_END
 
 #endif /* __GNUC__ */
diff --git a/cogl/cogl-profile.c b/cogl/cogl-profile.c
index e17acda38..c8d11dd76 100644
--- a/cogl/cogl-profile.c
+++ b/cogl/cogl-profile.c
@@ -2,16 +2,51 @@
 #ifdef COGL_ENABLE_PROFILE
 
 #include "cogl-profile.h"
+#include "cogl-debug.h"
 
 #include <stdlib.h>
 
 UProfContext *_cogl_uprof_context;
 
+static gboolean
+debug_option_getter (void *user_data)
+{
+  unsigned int shift = GPOINTER_TO_UINT (user_data);
+  return (cogl_debug_flags & (1 << shift)) ? TRUE : FALSE;
+}
+
+static void
+debug_option_setter (gboolean value, void *user_data)
+{
+  unsigned int shift = GPOINTER_TO_UINT (user_data);
+
+  if (value)
+    cogl_debug_flags |= (1 << shift);
+  else
+    cogl_debug_flags &= ~(1 << shift);
+}
 
 static void __attribute__ ((constructor))
 cogl_uprof_constructor (void)
 {
   _cogl_uprof_context = uprof_context_new ("Cogl");
+#define OPT(MASK_NAME, GROUP, NAME, NAME_FORMATTED, DESCRIPTION) \
+  G_STMT_START { \
+    int shift; \
+    for (shift = 0; (COGL_DEBUG_ ## MASK_NAME >> shift) != 1; shift++) \
+        ; \
+    uprof_context_add_boolean_option (_cogl_uprof_context, \
+                                      GROUP, \
+                                      NAME, \
+                                      NAME_FORMATTED, \
+                                      DESCRIPTION, \
+                                      debug_option_getter, \
+                                      debug_option_setter, \
+                                      GUINT_TO_POINTER (shift)); \
+  } G_STMT_END;
+
+#include "cogl-debug-options.h"
+#undef OPT
 }
 
 static void __attribute__ ((destructor))
@@ -27,4 +62,17 @@ cogl_uprof_destructor (void)
   uprof_context_unref (_cogl_uprof_context);
 }
 
+void
+_cogl_profile_trace_message (const char *format, ...)
+{
+  va_list ap;
+
+  va_start (ap, format);
+  g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, ap);
+  va_end (ap);
+
+  if (_cogl_uprof_context)
+    uprof_context_vtrace_message (_cogl_uprof_context, format, ap);
+}
+
 #endif
diff --git a/cogl/cogl-profile.h b/cogl/cogl-profile.h
index a918e44b8..5473dd67a 100644
--- a/cogl/cogl-profile.h
+++ b/cogl/cogl-profile.h
@@ -38,6 +38,9 @@ extern UProfContext *_cogl_uprof_context;
 #define COGL_TIMER_START     UPROF_TIMER_START
 #define COGL_TIMER_STOP      UPROF_TIMER_STOP
 
+void
+_cogl_profile_trace_message (const char *format, ...);
+
 #else
 
 #define COGL_STATIC_TIMER(A,B,C,D,E) extern void _cogl_dummy_decl (void)
@@ -47,6 +50,7 @@ extern UProfContext *_cogl_uprof_context;
 #define COGL_TIMER_START(A,B) G_STMT_START{ (void)0; }G_STMT_END
 #define COGL_TIMER_STOP(A,B) G_STMT_START{ (void)0; }G_STMT_END
 
+#define _cogl_profile_trace_message g_message
 
 #endif
 
diff --git a/cogl/cogl-texture-3d.c b/cogl/cogl-texture-3d.c
index b684fb3c2..d6d705020 100644
--- a/cogl/cogl-texture-3d.c
+++ b/cogl/cogl-texture-3d.c
@@ -35,6 +35,7 @@
 #include "cogl-context.h"
 #include "cogl-handle.h"
 #include "cogl-journal-private.h"
+#include "cogl-material-private.h"
 #include "cogl-material-opengl-private.h"
 
 #include <string.h>