Silence gcc 3.4 warnings on ReactOS. Mostly unused var warnings. (patch 1015696)
[mesa.git] / src / mesa / main / debug.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.1
4 *
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 #include "mtypes.h"
26 #include "context.h"
27 #include "imports.h"
28 #include "debug.h"
29 #include "get.h"
30
31 /**
32 * Primitive names
33 */
34 const char *_mesa_prim_name[GL_POLYGON+4] = {
35 "GL_POINTS",
36 "GL_LINES",
37 "GL_LINE_LOOP",
38 "GL_LINE_STRIP",
39 "GL_TRIANGLES",
40 "GL_TRIANGLE_STRIP",
41 "GL_TRIANGLE_FAN",
42 "GL_QUADS",
43 "GL_QUAD_STRIP",
44 "GL_POLYGON",
45 "outside begin/end",
46 "inside unkown primitive",
47 "unknown state"
48 };
49
50 void
51 _mesa_print_state( const char *msg, GLuint state )
52 {
53 _mesa_debug(NULL,
54 "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
55 msg,
56 state,
57 (state & _NEW_MODELVIEW) ? "ctx->ModelView, " : "",
58 (state & _NEW_PROJECTION) ? "ctx->Projection, " : "",
59 (state & _NEW_TEXTURE_MATRIX) ? "ctx->TextureMatrix, " : "",
60 (state & _NEW_COLOR_MATRIX) ? "ctx->ColorMatrix, " : "",
61 (state & _NEW_ACCUM) ? "ctx->Accum, " : "",
62 (state & _NEW_COLOR) ? "ctx->Color, " : "",
63 (state & _NEW_DEPTH) ? "ctx->Depth, " : "",
64 (state & _NEW_EVAL) ? "ctx->Eval/EvalMap, " : "",
65 (state & _NEW_FOG) ? "ctx->Fog, " : "",
66 (state & _NEW_HINT) ? "ctx->Hint, " : "",
67 (state & _NEW_LIGHT) ? "ctx->Light, " : "",
68 (state & _NEW_LINE) ? "ctx->Line, " : "",
69 (state & _NEW_PIXEL) ? "ctx->Pixel, " : "",
70 (state & _NEW_POINT) ? "ctx->Point, " : "",
71 (state & _NEW_POLYGON) ? "ctx->Polygon, " : "",
72 (state & _NEW_POLYGONSTIPPLE) ? "ctx->PolygonStipple, " : "",
73 (state & _NEW_SCISSOR) ? "ctx->Scissor, " : "",
74 (state & _NEW_TEXTURE) ? "ctx->Texture, " : "",
75 (state & _NEW_TRANSFORM) ? "ctx->Transform, " : "",
76 (state & _NEW_VIEWPORT) ? "ctx->Viewport, " : "",
77 (state & _NEW_PACKUNPACK) ? "ctx->Pack/Unpack, " : "",
78 (state & _NEW_ARRAY) ? "ctx->Array, " : "",
79 (state & _NEW_RENDERMODE) ? "ctx->RenderMode, " : "",
80 (state & _NEW_BUFFERS) ? "ctx->Visual, ctx->DrawBuffer,, " : "");
81 }
82
83
84
85 void
86 _mesa_print_tri_caps( const char *name, GLuint flags )
87 {
88 _mesa_debug(NULL,
89 "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
90 name,
91 flags,
92 (flags & DD_FLATSHADE) ? "flat-shade, " : "",
93 (flags & DD_SEPARATE_SPECULAR) ? "separate-specular, " : "",
94 (flags & DD_TRI_LIGHT_TWOSIDE) ? "tri-light-twoside, " : "",
95 (flags & DD_TRI_UNFILLED) ? "tri-unfilled, " : "",
96 (flags & DD_TRI_STIPPLE) ? "tri-stipple, " : "",
97 (flags & DD_TRI_OFFSET) ? "tri-offset, " : "",
98 (flags & DD_TRI_SMOOTH) ? "tri-smooth, " : "",
99 (flags & DD_LINE_SMOOTH) ? "line-smooth, " : "",
100 (flags & DD_LINE_STIPPLE) ? "line-stipple, " : "",
101 (flags & DD_LINE_WIDTH) ? "line-wide, " : "",
102 (flags & DD_POINT_SMOOTH) ? "point-smooth, " : "",
103 (flags & DD_POINT_SIZE) ? "point-size, " : "",
104 (flags & DD_POINT_ATTEN) ? "point-atten, " : "",
105 (flags & DD_TRI_CULL_FRONT_BACK) ? "cull-all, " : ""
106 );
107 }
108
109
110 /**
111 * Print information about this Mesa version and build options.
112 */
113 void _mesa_print_info( void )
114 {
115 _mesa_debug(NULL, "Mesa GL_VERSION = %s\n",
116 (char *) _mesa_GetString(GL_VERSION));
117 _mesa_debug(NULL, "Mesa GL_RENDERER = %s\n",
118 (char *) _mesa_GetString(GL_RENDERER));
119 _mesa_debug(NULL, "Mesa GL_VENDOR = %s\n",
120 (char *) _mesa_GetString(GL_VENDOR));
121 _mesa_debug(NULL, "Mesa GL_EXTENSIONS = %s\n",
122 (char *) _mesa_GetString(GL_EXTENSIONS));
123 #if defined(THREADS)
124 _mesa_debug(NULL, "Mesa thread-safe: YES\n");
125 #else
126 _mesa_debug(NULL, "Mesa thread-safe: NO\n");
127 #endif
128 #if defined(USE_X86_ASM)
129 _mesa_debug(NULL, "Mesa x86-optimized: YES\n");
130 #else
131 _mesa_debug(NULL, "Mesa x86-optimized: NO\n");
132 #endif
133 #if defined(USE_SPARC_ASM)
134 _mesa_debug(NULL, "Mesa sparc-optimized: YES\n");
135 #else
136 _mesa_debug(NULL, "Mesa sparc-optimized: NO\n");
137 #endif
138 }
139
140
141 /**
142 * Set the debugging flags.
143 *
144 * \param debug debug string
145 *
146 * If compiled with debugging support then search for keywords in \p debug and
147 * enables the verbose debug output of the respective feature.
148 */
149 static void add_debug_flags( const char *debug )
150 {
151 #ifdef MESA_DEBUG
152 if (_mesa_strstr(debug, "varray"))
153 MESA_VERBOSE |= VERBOSE_VARRAY;
154
155 if (_mesa_strstr(debug, "tex"))
156 MESA_VERBOSE |= VERBOSE_TEXTURE;
157
158 if (_mesa_strstr(debug, "imm"))
159 MESA_VERBOSE |= VERBOSE_IMMEDIATE;
160
161 if (_mesa_strstr(debug, "pipe"))
162 MESA_VERBOSE |= VERBOSE_PIPELINE;
163
164 if (_mesa_strstr(debug, "driver"))
165 MESA_VERBOSE |= VERBOSE_DRIVER;
166
167 if (_mesa_strstr(debug, "state"))
168 MESA_VERBOSE |= VERBOSE_STATE;
169
170 if (_mesa_strstr(debug, "api"))
171 MESA_VERBOSE |= VERBOSE_API;
172
173 if (_mesa_strstr(debug, "list"))
174 MESA_VERBOSE |= VERBOSE_DISPLAY_LIST;
175
176 if (_mesa_strstr(debug, "lighting"))
177 MESA_VERBOSE |= VERBOSE_LIGHTING;
178
179 /* Debug flag:
180 */
181 if (_mesa_strstr(debug, "flush"))
182 MESA_DEBUG_FLAGS |= DEBUG_ALWAYS_FLUSH;
183 #else
184 (void) debug;
185 #endif
186 }
187
188
189 void
190 _mesa_init_debug( GLcontext *ctx )
191 {
192 char *c;
193
194 /* For debug/development only */
195 ctx->FirstTimeCurrent = GL_TRUE;
196
197 /* Dither disable */
198 ctx->NoDither = _mesa_getenv("MESA_NO_DITHER") ? GL_TRUE : GL_FALSE;
199 if (ctx->NoDither) {
200 if (_mesa_getenv("MESA_DEBUG")) {
201 _mesa_debug(ctx, "MESA_NO_DITHER set - dithering disabled\n");
202 }
203 ctx->Color.DitherFlag = GL_FALSE;
204 }
205
206 c = _mesa_getenv("MESA_DEBUG");
207 if (c)
208 add_debug_flags(c);
209
210 c = _mesa_getenv("MESA_VERBOSE");
211 if (c)
212 add_debug_flags(c);
213 }
214