[Mesa-dev] [PATCH 07/21] mesa: refactor debug output set_message_state

Chia-I Wu olvaffe at gmail.com
Tue Apr 22 01:58:22 PDT 2014


Move message state update to debug_set_message_filter.

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 66896c4..c478aac 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_filter(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 filtered.
  */
@@ -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_filter(debug, source, type, id, enabled);
 }
 
 
-- 
1.8.5.3



More information about the mesa-dev mailing list