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"
35 static const struct dri_debug_control debug_control
[] = {
36 {"fall", RADEON_FALLBACKS
},
37 {"tex", RADEON_TEXTURE
},
38 {"ioctl", RADEON_IOCTL
},
39 {"verts", RADEON_RENDER
},
40 {"render", RADEON_RENDER
},
41 {"swrender", RADEON_SWRENDER
},
42 {"state", RADEON_STATE
},
43 {"shader", RADEON_SHADER
},
44 {"vfmt", RADEON_VFMT
},
45 {"vtxf", RADEON_VFMT
},
48 {"sanity", RADEON_SANITY
},
49 {"sync", RADEON_SYNC
},
50 {"pixel", RADEON_PIXEL
},
51 {"mem", RADEON_MEMORY
},
53 {"allmsg", ~RADEON_SYNC
}, /* avoid the term "sync" because the parser uses strstr */
57 radeon_debug_type_t radeon_enabled_debug_types
;
59 void radeon_init_debug(void)
61 radeon_enabled_debug_types
= driParseDebugString(getenv("RADEON_DEBUG"), debug_control
);
63 radeon_enabled_debug_types
|= RADEON_GENERAL
;
66 void _radeon_debug_add_indent(void)
68 GET_CURRENT_CONTEXT(ctx
);
69 radeonContextPtr radeon
= RADEON_CONTEXT(ctx
);
70 const size_t length
= sizeof(radeon
->debug
.indent
)
71 / sizeof(radeon
->debug
.indent
[0]);
72 if (radeon
->debug
.indent_depth
< length
- 1) {
73 radeon
->debug
.indent
[radeon
->debug
.indent_depth
] = '\t';
74 ++radeon
->debug
.indent_depth
;
78 void _radeon_debug_remove_indent(void)
80 GET_CURRENT_CONTEXT(ctx
);
81 radeonContextPtr radeon
= RADEON_CONTEXT(ctx
);
82 if (radeon
->debug
.indent_depth
> 0) {
83 radeon
->debug
.indent
[radeon
->debug
.indent_depth
] = '\0';
84 --radeon
->debug
.indent_depth
;
88 extern void _radeon_print(const radeon_debug_type_t type
,
89 const radeon_debug_level_t level
,
93 GET_CURRENT_CONTEXT(ctx
);
95 radeonContextPtr radeon
= RADEON_CONTEXT(ctx
);
96 // FIXME: Make this multi thread safe
97 if (radeon
->debug
.indent_depth
)
98 fprintf(stderr
, "%s", radeon
->debug
.indent
);
100 vfprintf(stderr
, message
, values
);