Mesa (master): r300g: use util/u_debug

Joakim Sindholt jsindholt at kemper.freedesktop.org
Thu Jun 3 11:45:30 UTC 2010


Module: Mesa
Branch: master
Commit: 9eb730a735842e6631218ff1c57a60a9f1db1251
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9eb730a735842e6631218ff1c57a60a9f1db1251

Author: Joakim Sindholt <opensource at zhasha.com>
Date:   Wed Jun  2 20:37:44 2010 +0200

r300g: use util/u_debug

---

 src/gallium/drivers/r300/r300_debug.c |   59 +++------------------------------
 1 files changed, 5 insertions(+), 54 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c
index 024731a..297791f 100644
--- a/src/gallium/drivers/r300/r300_debug.c
+++ b/src/gallium/drivers/r300/r300_debug.c
@@ -22,16 +22,11 @@
 
 #include "r300_context.h"
 
-#include <stdio.h>
+#include "util/u_debug.h"
 
-struct debug_option {
-    const char * name;
-    unsigned flag;
-    const char * description;
-};
+#include <stdio.h>
 
-static struct debug_option debug_options[] = {
-    { "help", DBG_HELP, "Helpful meta-information about the driver" },
+static const struct debug_named_value debug_options[] = {
     { "fp", DBG_FP, "Fragment program handling (for debugging)" },
     { "vp", DBG_VP, "Vertex program handling (for debugging)" },
     { "cs", DBG_CS, "Command submissions (for debugging)" },
@@ -46,57 +41,13 @@ static struct debug_option debug_options[] = {
     { "noimmd", DBG_NO_IMMD, "Disable immediate mode (for benchmarking)" },
     { "stats", DBG_STATS, "Gather statistics (for lulz)" },
 
-    { "all", ~0, "Convenience option that enables all debug flags" },
-
     /* must be last */
-    { 0, 0, 0 }
+    DEBUG_NAMED_VALUE_END
 };
 
 void r300_init_debug(struct r300_screen * screen)
 {
-    const char * options = debug_get_option("RADEON_DEBUG", 0);
-    boolean printhint = FALSE;
-    size_t length;
-    struct debug_option * opt;
-
-    if (options) {
-        while(*options) {
-            if (*options == ' ' || *options == ',') {
-                options++;
-                continue;
-            }
-
-            length = strcspn(options, " ,");
-
-            for(opt = debug_options; opt->name; ++opt) {
-                if (!strncmp(options, opt->name, length)) {
-                    screen->debug |= opt->flag;
-                    break;
-                }
-            }
-
-            if (!opt->name) {
-                fprintf(stderr, "Unknown debug option: %s\n", options);
-                printhint = TRUE;
-            }
-
-            options += length;
-        }
-
-        if (!screen->debug)
-            printhint = TRUE;
-    }
-
-    if (printhint || screen->debug & DBG_HELP) {
-        fprintf(stderr, "You can enable debug output by setting "
-                        "the RADEON_DEBUG environment variable\n"
-                        "to a comma-separated list of debug options. "
-                        "Available options are:\n");
-
-        for(opt = debug_options; opt->name; ++opt) {
-            fprintf(stderr, "    %s: %s\n", opt->name, opt->description);
-        }
-    }
+    screen->debug = debug_get_flags_option("RADEON_DEBUG", debug_options, 0);
 }
 
 void r500_dump_rs_block(struct r300_rs_block *rs)




More information about the mesa-commit mailing list