[Mesa-dev] [PATCH 03/18] mesa: refactor debug output set_message_state

Chia-I Wu olvaffe at gmail.com
Fri Apr 25 03:41:56 PDT 2014


Move message state update to debug_set_message_enable.  No functional change.

Signed-off-by: Chia-I Wu <olv at lunarg.com>
---
 src/mesa/main/errors.c | 70 ++++++++++++++++++++++++++++----------------------
 1 file changed, 39 insertions(+), 31 deletions(-)

diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index 55b50b3..d2d072f 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -217,6 +217,43 @@ debug_create(void)
    return debug;
 }
 
+/*
+ * Sets the state of the given message source/type/ID tuple.
+ */
+static void
+debug_set_message_enable(struct gl_debug_state *debug,
+                         enum mesa_debug_source source,
+                         enum mesa_debug_type type,
+                         GLuint id, GLboolean enabled)
+{
+   GLint gstack = debug->GroupStackDepth;
+   struct gl_debug_namespace *nspace =
+      &debug->Namespaces[gstack][source][type];
+   uintptr_t state;
+
+   /* In addition to not being able to store zero as a value, HashTable also
+    * can't use zero as a key.
+    */
+   if (id)
+      state = (uintptr_t)_mesa_HashLookup(nspace->IDs, id);
+   else
+      state = nspace->ZeroID;
+
+   if (state == NOT_FOUND)
+      state = enabled ? ENABLED : DISABLED;
+   else {
+      if (enabled)
+         state |= ENABLED_BIT;
+      else
+         state &= ~ENABLED_BIT;
+   }
+
+   if (id)
+      _mesa_HashInsert(nspace->IDs, id, (void*)state);
+   else
+      nspace->ZeroID = state;
+}
+
 /**
  * Returns if the given message source/type/ID tuple is enabled.
  */
@@ -316,9 +353,6 @@ should_log(struct gl_context *ctx,
 }
 
 
-/**
- * Sets the state of the given message source/type/ID tuple.
- */
 static void
 set_message_state(struct gl_context *ctx,
                   enum mesa_debug_source source,
@@ -327,34 +361,8 @@ set_message_state(struct gl_context *ctx,
 {
    struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
 
-   if (debug) {
-      GLint gstack = debug->GroupStackDepth;
-      struct gl_debug_namespace *nspace =
-         &debug->Namespaces[gstack][source][type];
-      uintptr_t state;
-
-      /* In addition to not being able to store zero as a value, HashTable also
-       * can't use zero as a key.
-       */
-      if (id)
-         state = (uintptr_t)_mesa_HashLookup(nspace->IDs, id);
-      else
-         state = nspace->ZeroID;
-
-      if (state == NOT_FOUND)
-         state = enabled ? ENABLED : DISABLED;
-      else {
-         if (enabled)
-            state |= ENABLED_BIT;
-         else
-            state &= ~ENABLED_BIT;
-      }
-
-      if (id)
-         _mesa_HashInsert(nspace->IDs, id, (void*)state);
-      else
-         nspace->ZeroID = state;
-   }
+   if (debug)
+      debug_set_message_enable(debug, source, type, id, enabled);
 }
 
 
-- 
1.8.5.3



More information about the mesa-dev mailing list