| 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%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_TWOSTENCIL) ? "tri-twostencil, " : "", |
| 96 |
(flags & DD_TRI_UNFILLED) ? "tri-unfilled, " : "", |
| 97 |
(flags & DD_TRI_STIPPLE) ? "tri-stipple, " : "", |
| 98 |
(flags & DD_TRI_OFFSET) ? "tri-offset, " : "", |
| 99 |
(flags & DD_TRI_SMOOTH) ? "tri-smooth, " : "", |
| 100 |
(flags & DD_LINE_SMOOTH) ? "line-smooth, " : "", |
| 101 |
(flags & DD_LINE_STIPPLE) ? "line-stipple, " : "", |
| 102 |
(flags & DD_LINE_WIDTH) ? "line-wide, " : "", |
| 103 |
(flags & DD_POINT_SMOOTH) ? "point-smooth, " : "", |
| 104 |
(flags & DD_POINT_SIZE) ? "point-size, " : "", |
| 105 |
(flags & DD_POINT_ATTEN) ? "point-atten, " : "", |
| 106 |
(flags & DD_TRI_CULL_FRONT_BACK) ? "cull-all, " : "" |
| 107 |
); |
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
/** |
| 112 |
* Print information about this Mesa version and build options. |
| 113 |
*/ |
| 114 |
void _mesa_print_info( void ) |
| 115 |
{ |
| 116 |
_mesa_debug(NULL, "Mesa GL_VERSION = %s\n", |
| 117 |
(char *) _mesa_GetString(GL_VERSION)); |
| 118 |
_mesa_debug(NULL, "Mesa GL_RENDERER = %s\n", |
| 119 |
(char *) _mesa_GetString(GL_RENDERER)); |
| 120 |
_mesa_debug(NULL, "Mesa GL_VENDOR = %s\n", |
| 121 |
(char *) _mesa_GetString(GL_VENDOR)); |
| 122 |
_mesa_debug(NULL, "Mesa GL_EXTENSIONS = %s\n", |
| 123 |
(char *) _mesa_GetString(GL_EXTENSIONS)); |
| 124 |
#if defined(THREADS) |
| 125 |
_mesa_debug(NULL, "Mesa thread-safe: YES\n"); |
| 126 |
#else |
| 127 |
_mesa_debug(NULL, "Mesa thread-safe: NO\n"); |
| 128 |
#endif |
| 129 |
#if defined(USE_X86_ASM) |
| 130 |
_mesa_debug(NULL, "Mesa x86-optimized: YES\n"); |
| 131 |
#else |
| 132 |
_mesa_debug(NULL, "Mesa x86-optimized: NO\n"); |
| 133 |
#endif |
| 134 |
#if defined(USE_SPARC_ASM) |
| 135 |
_mesa_debug(NULL, "Mesa sparc-optimized: YES\n"); |
| 136 |
#else |
| 137 |
_mesa_debug(NULL, "Mesa sparc-optimized: NO\n"); |
| 138 |
#endif |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
/** |
| 143 |
* Set the debugging flags. |
| 144 |
* |
| 145 |
* \param debug debug string |
| 146 |
* |
| 147 |
* If compiled with debugging support then search for keywords in \p debug and |
| 148 |
* enables the verbose debug output of the respective feature. |
| 149 |
*/ |
| 150 |
static void add_debug_flags( const char *debug ) |
| 151 |
{ |
| 152 |
#ifdef MESA_DEBUG |
| 153 |
if (_mesa_strstr(debug, "varray")) |
| 154 |
MESA_VERBOSE |= VERBOSE_VARRAY; |
| 155 |
|
| 156 |
if (_mesa_strstr(debug, "tex")) |
| 157 |
MESA_VERBOSE |= VERBOSE_TEXTURE; |
| 158 |
|
| 159 |
if (_mesa_strstr(debug, "imm")) |
| 160 |
MESA_VERBOSE |= VERBOSE_IMMEDIATE; |
| 161 |
|
| 162 |
if (_mesa_strstr(debug, "pipe")) |
| 163 |
MESA_VERBOSE |= VERBOSE_PIPELINE; |
| 164 |
|
| 165 |
if (_mesa_strstr(debug, "driver")) |
| 166 |
MESA_VERBOSE |= VERBOSE_DRIVER; |
| 167 |
|
| 168 |
if (_mesa_strstr(debug, "state")) |
| 169 |
MESA_VERBOSE |= VERBOSE_STATE; |
| 170 |
|
| 171 |
if (_mesa_strstr(debug, "api")) |
| 172 |
MESA_VERBOSE |= VERBOSE_API; |
| 173 |
|
| 174 |
if (_mesa_strstr(debug, "list")) |
| 175 |
MESA_VERBOSE |= VERBOSE_DISPLAY_LIST; |
| 176 |
|
| 177 |
if (_mesa_strstr(debug, "lighting")) |
| 178 |
MESA_VERBOSE |= VERBOSE_LIGHTING; |
| 179 |
|
| 180 |
if (_mesa_strstr(debug, "disassem")) |
| 181 |
MESA_VERBOSE |= VERBOSE_DISASSEM; |
| 182 |
|
| 183 |
/* Debug flag: |
| 184 |
*/ |
| 185 |
if (_mesa_strstr(debug, "flush")) |
| 186 |
MESA_DEBUG_FLAGS |= DEBUG_ALWAYS_FLUSH; |
| 187 |
#else |
| 188 |
(void) debug; |
| 189 |
#endif |
| 190 |
} |
| 191 |
|
| 192 |
|
| 193 |
void |
| 194 |
_mesa_init_debug( GLcontext *ctx ) |
| 195 |
{ |
| 196 |
char *c; |
| 197 |
|
| 198 |
/* For debug/development only */ |
| 199 |
ctx->FirstTimeCurrent = GL_TRUE; |
| 200 |
|
| 201 |
/* Dither disable */ |
| 202 |
ctx->NoDither = _mesa_getenv("MESA_NO_DITHER") ? GL_TRUE : GL_FALSE; |
| 203 |
if (ctx->NoDither) { |
| 204 |
if (_mesa_getenv("MESA_DEBUG")) { |
| 205 |
_mesa_debug(ctx, "MESA_NO_DITHER set - dithering disabled\n"); |
| 206 |
} |
| 207 |
ctx->Color.DitherFlag = GL_FALSE; |
| 208 |
} |
| 209 |
|
| 210 |
c = _mesa_getenv("MESA_DEBUG"); |
| 211 |
if (c) |
| 212 |
add_debug_flags(c); |
| 213 |
|
| 214 |
c = _mesa_getenv("MESA_VERBOSE"); |
| 215 |
if (c) |
| 216 |
add_debug_flags(c); |
| 217 |
} |
| 218 |
|