radeon/r600: use new libdrm_radeon api
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_debug.c
index b5e7b668ceeb48426ab1f0534473aeb3afcd88b1..413000b6c068e63dbdf050665e2530ff3e24f231 100644 (file)
 #include "utils.h"
 
 #include "radeon_debug.h"
+#include "radeon_common_context.h"
+
+#include <stdarg.h>
+#include <stdio.h>
 
 static const struct dri_debug_control debug_control[] = {
        {"fall", RADEON_FALLBACKS},
        {"tex", RADEON_TEXTURE},
        {"ioctl", RADEON_IOCTL},
+       {"verts", RADEON_VERTS},
        {"render", RADEON_RENDER},
        {"swrender", RADEON_SWRENDER},
        {"state", RADEON_STATE},
@@ -60,3 +65,43 @@ void radeon_init_debug(void)
 
        radeon_enabled_debug_types |= RADEON_GENERAL;
 }
+
+void _radeon_debug_add_indent(void)
+{
+       GET_CURRENT_CONTEXT(ctx);
+       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+       const size_t length = sizeof(radeon->debug.indent)
+               / sizeof(radeon->debug.indent[0]);
+       if (radeon->debug.indent_depth < length - 1) {
+               radeon->debug.indent[radeon->debug.indent_depth] = '\t';
+               ++radeon->debug.indent_depth;
+       };
+}
+
+void _radeon_debug_remove_indent(void)
+{
+       GET_CURRENT_CONTEXT(ctx);
+       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+       if (radeon->debug.indent_depth > 0) {
+               radeon->debug.indent[radeon->debug.indent_depth] = '\0';
+               --radeon->debug.indent_depth;
+       }
+}
+
+void _radeon_print(const radeon_debug_type_t type,
+          const radeon_debug_level_t level,
+          const char* message,
+          ...)
+{
+       GET_CURRENT_CONTEXT(ctx);
+       if (ctx) {
+               radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+               // FIXME: Make this multi thread safe
+               if (radeon->debug.indent_depth)
+                       fprintf(stderr, "%s", radeon->debug.indent);
+       }
+       va_list values;
+       va_start( values, message );
+       vfprintf(stderr, message, values);
+       va_end( values );
+}