2 * Copyright © 2009 Pauli Nieminen
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
16 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
17 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 * The above copyright notice and this permission notice (including the
22 * next paragraph) shall be included in all copies or substantial portions
27 * Pauli Nieminen <suokkos@gmail.com>
32 #include "radeon_debug.h"
33 #include "radeon_common_context.h"
38 static const struct dri_debug_control debug_control[] = {
39 {"fall", RADEON_FALLBACKS},
40 {"tex", RADEON_TEXTURE},
41 {"ioctl", RADEON_IOCTL},
42 {"verts", RADEON_VERTS},
43 {"render", RADEON_RENDER},
44 {"swrender", RADEON_SWRENDER},
45 {"state", RADEON_STATE},
46 {"shader", RADEON_SHADER},
47 {"vfmt", RADEON_VFMT},
48 {"vtxf", RADEON_VFMT},
51 {"sanity", RADEON_SANITY},
52 {"sync", RADEON_SYNC},
53 {"pixel", RADEON_PIXEL},
54 {"mem", RADEON_MEMORY},
56 {"allmsg", ~RADEON_SYNC}, /* avoid the term "sync" because the parser uses strstr */
60 radeon_debug_type_t radeon_enabled_debug_types;
62 void radeon_init_debug(void)
64 radeon_enabled_debug_types = driParseDebugString(getenv("RADEON_DEBUG"), debug_control);
66 radeon_enabled_debug_types |= RADEON_GENERAL;
69 void _radeon_debug_add_indent(void)
71 GET_CURRENT_CONTEXT(ctx);
72 radeonContextPtr radeon = RADEON_CONTEXT(ctx);
73 const size_t length = sizeof(radeon->debug.indent)
74 / sizeof(radeon->debug.indent[0]);
75 if (radeon->debug.indent_depth < length - 1) {
76 radeon->debug.indent[radeon->debug.indent_depth] = '\t';
77 ++radeon->debug.indent_depth;
81 void _radeon_debug_remove_indent(void)
83 GET_CURRENT_CONTEXT(ctx);
84 radeonContextPtr radeon = RADEON_CONTEXT(ctx);
85 if (radeon->debug.indent_depth > 0) {
86 radeon->debug.indent[radeon->debug.indent_depth] = '\0';
87 --radeon->debug.indent_depth;
91 void _radeon_print(const radeon_debug_type_t type,
92 const radeon_debug_level_t level,
96 GET_CURRENT_CONTEXT(ctx);
98 radeonContextPtr radeon = RADEON_CONTEXT(ctx);
99 // FIXME: Make this multi thread safe
100 if (radeon->debug.indent_depth)
101 fprintf(stderr, "%s", radeon->debug.indent);
104 va_start( values, message );
105 vfprintf(stderr, message, values);