[Mesa-dev] [PATCH 3/5] mesa: define DEBUG_SILENT flag, use in output_if_debug()

Brian Paul brianp at vmware.com
Wed May 9 12:53:50 PDT 2012


---
 src/mesa/main/debug.c  |    1 +
 src/mesa/main/errors.c |   21 ++++++++++-----------
 src/mesa/main/mtypes.h |    3 ++-
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
index 5f37f37..0e73fcb 100644
--- a/src/mesa/main/debug.c
+++ b/src/mesa/main/debug.c
@@ -203,6 +203,7 @@ set_debug_flags(const char *str)
       GLbitfield flag;
    };
    static const struct option opts[] = {
+      { "silent", DEBUG_SILENT }, /* turn off debug messages */
       { "flush", DEBUG_ALWAYS_FLUSH } /* flush after each drawing command */
    };
    GLuint i;
diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index 4a187b7..69dbb65 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -802,21 +802,20 @@ output_if_debug(const char *prefixString, const char *outputString,
 {
    static int debug = -1;
 
-   /* Check the MESA_DEBUG environment variable if it hasn't
-    * been checked yet.  We only have to check it once...
+   /* Init the local 'debug' var once.
+    * Note: the _mesa_init_debug() function should have been called
+    * by now so MESA_DEBUG_FLAGS will be initialized.
     */
    if (debug == -1) {
-      char *env = _mesa_getenv("MESA_DEBUG");
-
-      /* In a debug build, we print warning messages *unless*
-       * MESA_DEBUG is 0.  In a non-debug build, we don't
-       * print warning messages *unless* MESA_DEBUG is
-       * set *to any value*.
-       */
 #ifdef DEBUG
-      debug = (env != NULL && atoi(env) == 0) ? 0 : 1;
+      /* in debug builds, print messages unless MESA_DEBUG="silent" */
+      if (MESA_DEBUG_FLAGS & DEBUG_SILENT)
+         debug = 0;
+      else
+         debug = 1;
 #else
-      debug = (env != NULL) ? 1 : 0;
+      /* in release builds, be silent unless MESA_DEBUG is set */
+      debug = _mesa_getenv("MESA_DEBUG") != NULL;
 #endif
    }
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 06ca0d5..8b26d2a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3522,7 +3522,8 @@ enum _verbose
 /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */
 enum _debug
 {
-   DEBUG_ALWAYS_FLUSH		= 0x1
+   DEBUG_SILENT                 = (1 << 0),
+   DEBUG_ALWAYS_FLUSH		= (1 << 1)
 };
 
 
-- 
1.7.3.4



More information about the mesa-dev mailing list