aboutsummaryrefslogtreecommitdiff
path: root/mesalib
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-03-25 10:41:05 +0000
committermarha <marha@users.sourceforge.net>2011-03-25 10:41:05 +0000
commit272e57235cd60a2e65ac8258d96a02eb3939b687 (patch)
tree789d74bd6ec1cc468f1f81aab97d4e4dfdb2d5c5 /mesalib
parentb39f063f74bf0163eaf34db03134f226d18142ec (diff)
downloadvcxsrv-272e57235cd60a2e65ac8258d96a02eb3939b687.tar.gz
vcxsrv-272e57235cd60a2e65ac8258d96a02eb3939b687.tar.bz2
vcxsrv-272e57235cd60a2e65ac8258d96a02eb3939b687.zip
git update until 25 Mar 2011
xserver fontconfig glproto libXau libXft libXmu libfontenc libxcb mesa mkfontscale pixman randrproto xkeyboard-config xtrans xwininfo updated following packages: xproto-7.0.21 xineramaproto-1.2.1 libXt-1.1.1 libxkbfile-1.0.7 libXpm-3.5.9 libXfont-1.4.3 libXaw-1.0.9 bdftopcf-1.0.3 encodings-1.0.4 fixesproto-5.0 font-adobe-100dpi-1.0.3 font-adobe-75dpi-1.0.3 font-adobe-utopia-100dpi-1.0.4 font-adobe-utopia-75dpi-1.0.4 font-adobe-utopia-type1-1.0.4 font-alias-1.0.3 font-arabic-misc-1.0.3 font-bh-100dpi-1.0.3 font-bh-75dpi-1.0.3 font-bh-lucidatypewriter-100dpi-1.0.3 font-bh-lucidatypewriter-75dpi-1.0.3 font-bh-ttf-1.0.3 font-bh-type1-1.0.3 font-bitstream-100dpi-1.0.3 font-bitstream-75dpi-1.0.3 font-bitstream-speedo-1.0.2 font-bitstream-type1-1.0.3 font-cronyx-cyrillic-1.0.3 font-cursor-misc-1.0.3 font-daewoo-misc-1.0.3 font-dec-misc-1.0.3 font-ibm-type1-1.0.3 font-isas-misc-1.0.3 font-jis-misc-1.0.3 font-micro-misc-1.0.3 font-misc-cyrillic-1.0.3 font-misc-ethiopic-1.0.3 font-misc-meltho-1.0.3 font-misc-misc-1.1.2 font-mutt-misc-1.0.3 font-schumacher-misc-1.1.2 font-screen-cyrillic-1.0.4 font-sony-misc-1.0.3 font-sun-misc-1.0.3 font-util-1.2.0 font-winitzki-cyrillic-1.0.3 font-xfree86-type1-1.0.4
Diffstat (limited to 'mesalib')
-rw-r--r--mesalib/docs/envvars.html319
-rw-r--r--mesalib/src/mesa/main/debug.c1244
-rw-r--r--mesalib/src/mesa/main/debug.h184
-rw-r--r--mesalib/src/mesa/main/extensions.c24
4 files changed, 911 insertions, 860 deletions
diff --git a/mesalib/docs/envvars.html b/mesalib/docs/envvars.html
index 5240c803f..986d2f8eb 100644
--- a/mesalib/docs/envvars.html
+++ b/mesalib/docs/envvars.html
@@ -1,155 +1,164 @@
-<HTML>
-
-<TITLE>Environment Variables</TITLE>
-
-<link rel="stylesheet" type="text/css" href="mesa.css"></head>
-
-<BODY>
-
-<H1>Environment Variables</H1>
-
-<p>
-Normally, no environment variables need to be set. Most of the environment
-variables used by Mesa/Gallium are for debugging purposes, but they can
-sometimes be useful for debugging end-user issues.
-</p>
-
-
-<H2>LibGL environment variables</H2>
-
-<ul>
-<li>LIBGL_DEBUG - If defined debug information will be printed to stderr.
- If set to 'verbose' additional information will be printed.
-<li>LIBGL_DRIVERS_PATH - colon-separated list of paths to search for DRI drivers
-<li>LIBGL_ALWAYS_INDIRECT - forces an indirect rendering context/connection.
-<li>LIBGL_ALWAYS_SOFTWARE - if set, always use software rendering
-<li>LIBGL_NO_DRAWARRAYS - if set do not use DrawArrays GLX protocol (for debugging)
-</ul>
-
-
-
-<H2>Core Mesa environment variables</H2>
-
-<ul>
-<li>MESA_NO_ASM - if set, disables all assembly language optimizations
-<li>MESA_NO_MMX - if set, disables Intel MMX optimizations
-<li>MESA_NO_3DNOW - if set, disables AMD 3DNow! optimizations
-<li>MESA_NO_SSE - if set, disables Intel SSE optimizations
-<li>MESA_DEBUG - if set, error messages are printed to stderr. For example,
- if the application generates a GL_INVALID_ENUM error, a corresponding error
- message indicating where the error occured, and possibly why, will be
- printed to stderr.<br>
- If the value of MESA_DEBUG is 'FP' floating point arithmetic errors will
- generate exceptions.
-<li>MESA_TEX_PROG - if set, implement conventional texture env modes with
-fragment programs (intended for developers only)
-<li>MESA_TNL_PROG - if set, implement conventional vertex transformation
-operations with vertex programs (intended for developers only).
-Setting this variable automatically sets the MESA_TEX_PROG variable as well.
-<li>MESA_EXTENSION_OVERRIDE - can be used to enable/disable extensions.
-A value such as "GL_EXT_foo -GL_EXT_bar" will enable the GL_EXT_foo extension
-and disable the GL_EXT_bar extension.
-<li>MESA_GLSL - <a href="shading.html#envvars">shading language compiler options</a>
-</ul>
-
-
-<H2>Mesa Xlib driver environment variables</H2>
-
-<p>
-The following are only applicable to the Mesa Xlib software driver.
-See the <A HREF="xlibdriver.html">Xlib software driver page</A> for details.
-</p>
-<ul>
-<li>MESA_RGB_VISUAL - specifies the X visual and depth for RGB mode
-<li>MESA_CI_VISUAL - specifies the X visual and depth for CI mode
-<li>MESA_BACK_BUFFER - specifies how to implement the back color buffer,
- either "pixmap" or "ximage"
-<li>MESA_GAMMA - gamma correction coefficients for red, green, blue channels
-<li>MESA_XSYNC - enable synchronous X behavior (for debugging only)
-<li>MESA_GLX_FORCE_CI - if set, force GLX to treat 8bpp visuals as CI visuals
-<li>MESA_GLX_FX - set to either "fullscreen" for full-screen rendering,
- "window" to render into a window, or "disable" to disable the Glide driver.
-<li>MESA_GLX_FORCE_ALPHA - if set, forces RGB windows to have an alpha channel.
-<li>MESA_GLX_DEPTH_BITS - specifies default number of bits for depth buffer.
-<li>MESA_GLX_ALPHA_BITS - specifies default number of bits for alpha channel.
-</ul>
-
-
-<h2>i945/i965 driver environment variables (non-Gallium)</h2>
-
-<ul>
-<li>INTEL_STRICT_CONFORMANCE - if set to 1, enable sw fallbacks to improve
- OpenGL conformance. If set to 2, always use software rendering.
-<li>INTEL_NO_BLIT - if set, disable hardware-accelerated glBitmap,
- glCopyPixels, glDrawPixels.
-</ul>
-
-
-<h2>Radeon R300 driver environment variables (non-Gallium)</h2>
-
-<ul>
-<li>R300_NO_TCL - if set, disable hardware-accelerated Transform/Clip/Lighting.
-</ul>
-
-
-<h2>EGL environment variables</h2>
-
-<p>
-Mesa EGL supports different sets of environment variables. See the
-<a href="egl.html">Mesa EGL</a> page for the details.
-</p>
-
-
-<h2>Gallium environment variables</h2>
-
-<ul>
-<li>GALLIUM_PRINT_OPTIONS - if non-zero, print all the Gallium environment
- variables which are used, and their current values.
-<li>GALLIUM_NOSSE - if non-zero, do not use SSE runtime code generation for
- shader execution
-<li>GALLIUM_NOPPC - if non-zero, do not use PPC runtime code generation for
- shader execution
-<li>GALLIUM_DUMP_CPU - if non-zero, print information about the CPU on start-up
-<li>TGSI_PRINT_SANITY - if set, do extra sanity checking on TGSI shaders and
- print any errors to stderr.
-<LI>DRAW_FSE - ???
-<LI>DRAW_NO_FSE - ???
-<li>DRAW_USE_LLVM - if set to zero, the draw module will not use LLVM to execute
- shaders, vertex fetch, etc.
-</ul>
-
-<h3>Softpipe driver environment variables</h3>
-<ul>
-<li>SOFTPIPE_DUMP_FS - if set, the softpipe driver will print fragment shaders
- to stderr
-<li>SOFTPIPE_DUMP_GS - if set, the softpipe driver will print geometry shaders
- to stderr
-<li>SOFTPIPE_NO_RAST - if set, rasterization is no-op'd. For profiling purposes.
-</ul>
-
-
-<h3>LLVMpipe driver environment variables</h3>
-<ul>
-<li>LP_NO_RAST - if set LLVMpipe will no-op rasterization
-<li>LP_DEBUG - a comma-separated list of debug options is acceptec. See the
- source code for details.
-<li>LP_PERF - a comma-separated list of options to selectively no-op various
- parts of the driver. See the source code for details.
-<li>LP_NUM_THREADS - an integer indicating how many threads to use for rendering.
- Zero turns of threading completely. The default value is the number of CPU
- cores present.
-</ul>
-
-
-<p>
-Other Gallium drivers have their own environment variables. These may change
-frequently so the source code should be consulted for details.
-</p>
-
-
-<br>
-<br>
-
-
-</BODY>
-</HTML>
+<HTML>
+
+<TITLE>Environment Variables</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Environment Variables</H1>
+
+<p>
+Normally, no environment variables need to be set. Most of the environment
+variables used by Mesa/Gallium are for debugging purposes, but they can
+sometimes be useful for debugging end-user issues.
+</p>
+
+
+<H2>LibGL environment variables</H2>
+
+<ul>
+<li>LIBGL_DEBUG - If defined debug information will be printed to stderr.
+ If set to 'verbose' additional information will be printed.
+<li>LIBGL_DRIVERS_PATH - colon-separated list of paths to search for DRI drivers
+<li>LIBGL_ALWAYS_INDIRECT - forces an indirect rendering context/connection.
+<li>LIBGL_ALWAYS_SOFTWARE - if set, always use software rendering
+<li>LIBGL_NO_DRAWARRAYS - if set do not use DrawArrays GLX protocol (for debugging)
+</ul>
+
+
+
+<H2>Core Mesa environment variables</H2>
+
+<ul>
+<li>MESA_NO_ASM - if set, disables all assembly language optimizations
+<li>MESA_NO_MMX - if set, disables Intel MMX optimizations
+<li>MESA_NO_3DNOW - if set, disables AMD 3DNow! optimizations
+<li>MESA_NO_SSE - if set, disables Intel SSE optimizations
+<li>MESA_DEBUG - if set, error messages are printed to stderr. For example,
+ if the application generates a GL_INVALID_ENUM error, a corresponding error
+ message indicating where the error occured, and possibly why, will be
+ printed to stderr.<br>
+ If the value of MESA_DEBUG is 'FP' floating point arithmetic errors will
+ generate exceptions.
+<li>MESA_TEX_PROG - if set, implement conventional texture env modes with
+fragment programs (intended for developers only)
+<li>MESA_TNL_PROG - if set, implement conventional vertex transformation
+operations with vertex programs (intended for developers only).
+Setting this variable automatically sets the MESA_TEX_PROG variable as well.
+<li>MESA_EXTENSION_OVERRIDE - can be used to enable/disable extensions.
+A value such as "GL_EXT_foo -GL_EXT_bar" will enable the GL_EXT_foo extension
+and disable the GL_EXT_bar extension.
+<li>MESA_EXTENSION_MAX_YEAR - The GL_EXTENSIONS string returned by Mesa is sorted
+by extension year.
+If this variable is set to year X, only extensions defined on or before year
+X will be reported.
+This is to work-around a bug in some games where the extension string is
+copied into a fixed-size buffer without truncating.
+If the extension string is too long, the buffer overrun can cause the game
+to crash.
+This is a work-around for that.
+<li>MESA_GLSL - <a href="shading.html#envvars">shading language compiler options</a>
+</ul>
+
+
+<H2>Mesa Xlib driver environment variables</H2>
+
+<p>
+The following are only applicable to the Mesa Xlib software driver.
+See the <A HREF="xlibdriver.html">Xlib software driver page</A> for details.
+</p>
+<ul>
+<li>MESA_RGB_VISUAL - specifies the X visual and depth for RGB mode
+<li>MESA_CI_VISUAL - specifies the X visual and depth for CI mode
+<li>MESA_BACK_BUFFER - specifies how to implement the back color buffer,
+ either "pixmap" or "ximage"
+<li>MESA_GAMMA - gamma correction coefficients for red, green, blue channels
+<li>MESA_XSYNC - enable synchronous X behavior (for debugging only)
+<li>MESA_GLX_FORCE_CI - if set, force GLX to treat 8bpp visuals as CI visuals
+<li>MESA_GLX_FX - set to either "fullscreen" for full-screen rendering,
+ "window" to render into a window, or "disable" to disable the Glide driver.
+<li>MESA_GLX_FORCE_ALPHA - if set, forces RGB windows to have an alpha channel.
+<li>MESA_GLX_DEPTH_BITS - specifies default number of bits for depth buffer.
+<li>MESA_GLX_ALPHA_BITS - specifies default number of bits for alpha channel.
+</ul>
+
+
+<h2>i945/i965 driver environment variables (non-Gallium)</h2>
+
+<ul>
+<li>INTEL_STRICT_CONFORMANCE - if set to 1, enable sw fallbacks to improve
+ OpenGL conformance. If set to 2, always use software rendering.
+<li>INTEL_NO_BLIT - if set, disable hardware-accelerated glBitmap,
+ glCopyPixels, glDrawPixels.
+</ul>
+
+
+<h2>Radeon R300 driver environment variables (non-Gallium)</h2>
+
+<ul>
+<li>R300_NO_TCL - if set, disable hardware-accelerated Transform/Clip/Lighting.
+</ul>
+
+
+<h2>EGL environment variables</h2>
+
+<p>
+Mesa EGL supports different sets of environment variables. See the
+<a href="egl.html">Mesa EGL</a> page for the details.
+</p>
+
+
+<h2>Gallium environment variables</h2>
+
+<ul>
+<li>GALLIUM_PRINT_OPTIONS - if non-zero, print all the Gallium environment
+ variables which are used, and their current values.
+<li>GALLIUM_NOSSE - if non-zero, do not use SSE runtime code generation for
+ shader execution
+<li>GALLIUM_NOPPC - if non-zero, do not use PPC runtime code generation for
+ shader execution
+<li>GALLIUM_DUMP_CPU - if non-zero, print information about the CPU on start-up
+<li>TGSI_PRINT_SANITY - if set, do extra sanity checking on TGSI shaders and
+ print any errors to stderr.
+<LI>DRAW_FSE - ???
+<LI>DRAW_NO_FSE - ???
+<li>DRAW_USE_LLVM - if set to zero, the draw module will not use LLVM to execute
+ shaders, vertex fetch, etc.
+</ul>
+
+<h3>Softpipe driver environment variables</h3>
+<ul>
+<li>SOFTPIPE_DUMP_FS - if set, the softpipe driver will print fragment shaders
+ to stderr
+<li>SOFTPIPE_DUMP_GS - if set, the softpipe driver will print geometry shaders
+ to stderr
+<li>SOFTPIPE_NO_RAST - if set, rasterization is no-op'd. For profiling purposes.
+</ul>
+
+
+<h3>LLVMpipe driver environment variables</h3>
+<ul>
+<li>LP_NO_RAST - if set LLVMpipe will no-op rasterization
+<li>LP_DEBUG - a comma-separated list of debug options is acceptec. See the
+ source code for details.
+<li>LP_PERF - a comma-separated list of options to selectively no-op various
+ parts of the driver. See the source code for details.
+<li>LP_NUM_THREADS - an integer indicating how many threads to use for rendering.
+ Zero turns of threading completely. The default value is the number of CPU
+ cores present.
+</ul>
+
+
+<p>
+Other Gallium drivers have their own environment variables. These may change
+frequently so the source code should be consulted for details.
+</p>
+
+
+<br>
+<br>
+
+
+</BODY>
+</HTML>
diff --git a/mesalib/src/mesa/main/debug.c b/mesalib/src/mesa/main/debug.c
index e336b077e..2a8fd0880 100644
--- a/mesalib/src/mesa/main/debug.c
+++ b/mesalib/src/mesa/main/debug.c
@@ -1,610 +1,634 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.5
- *
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
- * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include "mtypes.h"
-#include "attrib.h"
-#include "colormac.h"
-#include "enums.h"
-#include "formats.h"
-#include "hash.h"
-#include "imports.h"
-#include "debug.h"
-#include "get.h"
-#include "pixelstore.h"
-#include "readpix.h"
-#include "texobj.h"
-
-
-static const char *
-tex_target_name(GLenum tgt)
-{
- static const struct {
- GLenum target;
- const char *name;
- } tex_targets[] = {
- { GL_TEXTURE_1D, "GL_TEXTURE_1D" },
- { GL_TEXTURE_2D, "GL_TEXTURE_2D" },
- { GL_TEXTURE_3D, "GL_TEXTURE_3D" },
- { GL_TEXTURE_CUBE_MAP, "GL_TEXTURE_CUBE_MAP" },
- { GL_TEXTURE_RECTANGLE, "GL_TEXTURE_RECTANGLE" },
- { GL_TEXTURE_1D_ARRAY_EXT, "GL_TEXTURE_1D_ARRAY" },
- { GL_TEXTURE_2D_ARRAY_EXT, "GL_TEXTURE_2D_ARRAY" }
- };
- GLuint i;
- for (i = 0; i < Elements(tex_targets); i++) {
- if (tex_targets[i].target == tgt)
- return tex_targets[i].name;
- }
- return "UNKNOWN TEX TARGET";
-}
-
-
-void
-_mesa_print_state( const char *msg, GLuint state )
-{
- _mesa_debug(NULL,
- "%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\n",
- msg,
- state,
- (state & _NEW_MODELVIEW) ? "ctx->ModelView, " : "",
- (state & _NEW_PROJECTION) ? "ctx->Projection, " : "",
- (state & _NEW_TEXTURE_MATRIX) ? "ctx->TextureMatrix, " : "",
- (state & _NEW_COLOR) ? "ctx->Color, " : "",
- (state & _NEW_DEPTH) ? "ctx->Depth, " : "",
- (state & _NEW_EVAL) ? "ctx->Eval/EvalMap, " : "",
- (state & _NEW_FOG) ? "ctx->Fog, " : "",
- (state & _NEW_HINT) ? "ctx->Hint, " : "",
- (state & _NEW_LIGHT) ? "ctx->Light, " : "",
- (state & _NEW_LINE) ? "ctx->Line, " : "",
- (state & _NEW_PIXEL) ? "ctx->Pixel, " : "",
- (state & _NEW_POINT) ? "ctx->Point, " : "",
- (state & _NEW_POLYGON) ? "ctx->Polygon, " : "",
- (state & _NEW_POLYGONSTIPPLE) ? "ctx->PolygonStipple, " : "",
- (state & _NEW_SCISSOR) ? "ctx->Scissor, " : "",
- (state & _NEW_STENCIL) ? "ctx->Stencil, " : "",
- (state & _NEW_TEXTURE) ? "ctx->Texture, " : "",
- (state & _NEW_TRANSFORM) ? "ctx->Transform, " : "",
- (state & _NEW_VIEWPORT) ? "ctx->Viewport, " : "",
- (state & _NEW_PACKUNPACK) ? "ctx->Pack/Unpack, " : "",
- (state & _NEW_ARRAY) ? "ctx->Array, " : "",
- (state & _NEW_RENDERMODE) ? "ctx->RenderMode, " : "",
- (state & _NEW_BUFFERS) ? "ctx->Visual, ctx->DrawBuffer,, " : "");
-}
-
-
-
-void
-_mesa_print_tri_caps( const char *name, GLuint flags )
-{
- _mesa_debug(NULL,
- "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s\n",
- name,
- flags,
- (flags & DD_FLATSHADE) ? "flat-shade, " : "",
- (flags & DD_SEPARATE_SPECULAR) ? "separate-specular, " : "",
- (flags & DD_TRI_LIGHT_TWOSIDE) ? "tri-light-twoside, " : "",
- (flags & DD_TRI_TWOSTENCIL) ? "tri-twostencil, " : "",
- (flags & DD_TRI_UNFILLED) ? "tri-unfilled, " : "",
- (flags & DD_TRI_STIPPLE) ? "tri-stipple, " : "",
- (flags & DD_TRI_OFFSET) ? "tri-offset, " : "",
- (flags & DD_TRI_SMOOTH) ? "tri-smooth, " : "",
- (flags & DD_LINE_SMOOTH) ? "line-smooth, " : "",
- (flags & DD_LINE_STIPPLE) ? "line-stipple, " : "",
- (flags & DD_POINT_SMOOTH) ? "point-smooth, " : "",
- (flags & DD_POINT_ATTEN) ? "point-atten, " : "",
- (flags & DD_TRI_CULL_FRONT_BACK) ? "cull-all, " : ""
- );
-}
-
-
-/**
- * Print information about this Mesa version and build options.
- */
-void _mesa_print_info( void )
-{
- _mesa_debug(NULL, "Mesa GL_VERSION = %s\n",
- (char *) _mesa_GetString(GL_VERSION));
- _mesa_debug(NULL, "Mesa GL_RENDERER = %s\n",
- (char *) _mesa_GetString(GL_RENDERER));
- _mesa_debug(NULL, "Mesa GL_VENDOR = %s\n",
- (char *) _mesa_GetString(GL_VENDOR));
- _mesa_debug(NULL, "Mesa GL_EXTENSIONS = %s\n",
- (char *) _mesa_GetString(GL_EXTENSIONS));
-#if defined(THREADS)
- _mesa_debug(NULL, "Mesa thread-safe: YES\n");
-#else
- _mesa_debug(NULL, "Mesa thread-safe: NO\n");
-#endif
-#if defined(USE_X86_ASM)
- _mesa_debug(NULL, "Mesa x86-optimized: YES\n");
-#else
- _mesa_debug(NULL, "Mesa x86-optimized: NO\n");
-#endif
-#if defined(USE_SPARC_ASM)
- _mesa_debug(NULL, "Mesa sparc-optimized: YES\n");
-#else
- _mesa_debug(NULL, "Mesa sparc-optimized: NO\n");
-#endif
-}
-
-
-/**
- * Set the debugging flags.
- *
- * \param debug debug string
- *
- * If compiled with debugging support then search for keywords in \p debug and
- * enables the verbose debug output of the respective feature.
- */
-static void add_debug_flags( const char *debug )
-{
-#ifdef DEBUG
- struct debug_option {
- const char *name;
- GLbitfield flag;
- };
- static const struct debug_option debug_opt[] = {
- { "varray", VERBOSE_VARRAY },
- { "tex", VERBOSE_TEXTURE },
- { "mat", VERBOSE_MATERIAL },
- { "pipe", VERBOSE_PIPELINE },
- { "driver", VERBOSE_DRIVER },
- { "state", VERBOSE_STATE },
- { "api", VERBOSE_API },
- { "list", VERBOSE_DISPLAY_LIST },
- { "lighting", VERBOSE_LIGHTING },
- { "disassem", VERBOSE_DISASSEM },
- { "draw", VERBOSE_DRAW },
- { "swap", VERBOSE_SWAPBUFFERS }
- };
- GLuint i;
-
- MESA_VERBOSE = 0x0;
- for (i = 0; i < Elements(debug_opt); i++) {
- if (strstr(debug, debug_opt[i].name))
- MESA_VERBOSE |= debug_opt[i].flag;
- }
-
- /* Debug flag:
- */
- if (strstr(debug, "flush"))
- MESA_DEBUG_FLAGS |= DEBUG_ALWAYS_FLUSH;
-
-#if defined(_FPU_GETCW) && defined(_FPU_SETCW)
- if (strstr(debug, "fpexceptions")) {
- /* raise FP exceptions */
- fpu_control_t mask;
- _FPU_GETCW(mask);
- mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM
- | _FPU_MASK_OM | _FPU_MASK_UM);
- _FPU_SETCW(mask);
- }
-#endif
-
-#else
- (void) debug;
-#endif
-}
-
-
-void
-_mesa_init_debug( struct gl_context *ctx )
-{
- char *c;
- c = _mesa_getenv("MESA_DEBUG");
- if (c)
- add_debug_flags(c);
-
- c = _mesa_getenv("MESA_VERBOSE");
- if (c)
- add_debug_flags(c);
-}
-
-
-/*
- * Write ppm file
- */
-static void
-write_ppm(const char *filename, const GLubyte *buffer, int width, int height,
- int comps, int rcomp, int gcomp, int bcomp, GLboolean invert)
-{
- FILE *f = fopen( filename, "w" );
- if (f) {
- int x, y;
- const GLubyte *ptr = buffer;
- fprintf(f,"P6\n");
- fprintf(f,"# ppm-file created by osdemo.c\n");
- fprintf(f,"%i %i\n", width,height);
- fprintf(f,"255\n");
- fclose(f);
- f = fopen( filename, "ab" ); /* reopen in binary append mode */
- for (y=0; y < height; y++) {
- for (x = 0; x < width; x++) {
- int yy = invert ? (height - 1 - y) : y;
- int i = (yy * width + x) * comps;
- fputc(ptr[i+rcomp], f); /* write red */
- fputc(ptr[i+gcomp], f); /* write green */
- fputc(ptr[i+bcomp], f); /* write blue */
- }
- }
- fclose(f);
- }
-}
-
-
-/**
- * Write a texture image to a ppm file.
- * \param face cube face in [0,5]
- * \param level mipmap level
- */
-static void
-write_texture_image(struct gl_texture_object *texObj,
- GLuint face, GLuint level)
-{
- struct gl_texture_image *img = texObj->Image[face][level];
- if (img) {
- GET_CURRENT_CONTEXT(ctx);
- struct gl_pixelstore_attrib store;
- GLubyte *buffer;
- char s[100];
-
- buffer = (GLubyte *) malloc(img->Width * img->Height
- * img->Depth * 4);
-
- store = ctx->Pack; /* save */
- ctx->Pack = ctx->DefaultPacking;
-
- ctx->Driver.GetTexImage(ctx, texObj->Target, level,
- GL_RGBA, GL_UNSIGNED_BYTE,
- buffer, texObj, img);
-
- /* make filename */
- _mesa_snprintf(s, sizeof(s), "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face);
-
- printf(" Writing image level %u to %s\n", level, s);
- write_ppm(s, buffer, img->Width, img->Height, 4, 0, 1, 2, GL_FALSE);
-
- ctx->Pack = store; /* restore */
-
- free(buffer);
- }
-}
-
-
-/**
- * Write renderbuffer image to a ppm file.
- */
-void
-_mesa_write_renderbuffer_image(const struct gl_renderbuffer *rb)
-{
- GET_CURRENT_CONTEXT(ctx);
- GLubyte *buffer;
- char s[100];
- GLenum format, type;
-
- if (rb->_BaseFormat == GL_RGB ||
- rb->_BaseFormat == GL_RGBA) {
- format = GL_RGBA;
- type = GL_UNSIGNED_BYTE;
- }
- else if (rb->_BaseFormat == GL_DEPTH_STENCIL) {
- format = GL_DEPTH_STENCIL;
- type = GL_UNSIGNED_INT_24_8;
- }
- else {
- _mesa_debug(NULL,
- "Unsupported BaseFormat 0x%x in "
- "_mesa_write_renderbuffer_image()\n",
- rb->_BaseFormat);
- return;
- }
-
- buffer = (GLubyte *) malloc(rb->Width * rb->Height * 4);
-
- ctx->Driver.ReadPixels(ctx, 0, 0, rb->Width, rb->Height,
- format, type, &ctx->DefaultPacking, buffer);
-
- /* make filename */
- _mesa_snprintf(s, sizeof(s), "/tmp/renderbuffer%u.ppm", rb->Name);
- _mesa_snprintf(s, sizeof(s), "C:\\renderbuffer%u.ppm", rb->Name);
-
- printf(" Writing renderbuffer image to %s\n", s);
-
- _mesa_debug(NULL, " Writing renderbuffer image to %s\n", s);
-
- write_ppm(s, buffer, rb->Width, rb->Height, 4, 0, 1, 2, GL_TRUE);
-
- free(buffer);
-}
-
-
-/** How many texture images (mipmap levels, faces) to write to files */
-#define WRITE_NONE 0
-#define WRITE_ONE 1
-#define WRITE_ALL 2
-
-static GLuint WriteImages;
-
-
-static void
-dump_texture(struct gl_texture_object *texObj, GLuint writeImages)
-{
- const GLuint numFaces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
- GLboolean written = GL_FALSE;
- GLuint i, j;
-
- printf("Texture %u\n", texObj->Name);
- printf(" Target %s\n", tex_target_name(texObj->Target));
- for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
- for (j = 0; j < numFaces; j++) {
- struct gl_texture_image *texImg = texObj->Image[j][i];
- if (texImg) {
- printf(" Face %u level %u: %d x %d x %d, format %s at %p\n",
- j, i,
- texImg->Width, texImg->Height, texImg->Depth,
- _mesa_get_format_name(texImg->TexFormat),
- texImg->Data);
- if (writeImages == WRITE_ALL ||
- (writeImages == WRITE_ONE && !written)) {
- write_texture_image(texObj, j, i);
- written = GL_TRUE;
- }
- }
- }
- }
-}
-
-
-/**
- * Dump a single texture.
- */
-void
-_mesa_dump_texture(GLuint texture, GLuint writeImages)
-{
- GET_CURRENT_CONTEXT(ctx);
- struct gl_texture_object *texObj = _mesa_lookup_texture(ctx, texture);
- if (texObj) {
- dump_texture(texObj, writeImages);
- }
-}
-
-
-static void
-dump_texture_cb(GLuint id, void *data, void *userData)
-{
- struct gl_texture_object *texObj = (struct gl_texture_object *) data;
- (void) userData;
- dump_texture(texObj, WriteImages);
-}
-
-
-/**
- * Print basic info about all texture objext to stdout.
- * If dumpImages is true, write PPM of level[0] image to a file.
- */
-void
-_mesa_dump_textures(GLuint writeImages)
-{
- GET_CURRENT_CONTEXT(ctx);
- WriteImages = writeImages;
- _mesa_HashWalk(ctx->Shared->TexObjects, dump_texture_cb, ctx);
-}
-
-
-static void
-dump_renderbuffer(const struct gl_renderbuffer *rb, GLboolean writeImage)
-{
- printf("Renderbuffer %u: %u x %u IntFormat = %s\n",
- rb->Name, rb->Width, rb->Height,
- _mesa_lookup_enum_by_nr(rb->InternalFormat));
- if (writeImage) {
- _mesa_write_renderbuffer_image(rb);
- }
-}
-
-
-static void
-dump_renderbuffer_cb(GLuint id, void *data, void *userData)
-{
- const struct gl_renderbuffer *rb = (const struct gl_renderbuffer *) data;
- (void) userData;
- dump_renderbuffer(rb, WriteImages);
-}
-
-
-/**
- * Print basic info about all renderbuffers to stdout.
- * If dumpImages is true, write PPM of level[0] image to a file.
- */
-void
-_mesa_dump_renderbuffers(GLboolean writeImages)
-{
- GET_CURRENT_CONTEXT(ctx);
- WriteImages = writeImages;
- _mesa_HashWalk(ctx->Shared->RenderBuffers, dump_renderbuffer_cb, ctx);
-}
-
-
-
-void
-_mesa_dump_color_buffer(const char *filename)
-{
- GET_CURRENT_CONTEXT(ctx);
- const GLuint w = ctx->DrawBuffer->Width;
- const GLuint h = ctx->DrawBuffer->Height;
- GLubyte *buf;
-
- buf = (GLubyte *) malloc(w * h * 4);
-
- _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
- _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
- _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
-
- _mesa_ReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buf);
-
- printf("ReadBuffer %p 0x%x DrawBuffer %p 0x%x\n",
- (void *) ctx->ReadBuffer->_ColorReadBuffer,
- ctx->ReadBuffer->ColorReadBuffer,
- (void *) ctx->DrawBuffer->_ColorDrawBuffers[0],
- ctx->DrawBuffer->ColorDrawBuffer[0]);
- printf("Writing %d x %d color buffer to %s\n", w, h, filename);
- write_ppm(filename, buf, w, h, 4, 0, 1, 2, GL_TRUE);
-
- _mesa_PopClientAttrib();
-
- free(buf);
-}
-
-
-void
-_mesa_dump_depth_buffer(const char *filename)
-{
- GET_CURRENT_CONTEXT(ctx);
- const GLuint w = ctx->DrawBuffer->Width;
- const GLuint h = ctx->DrawBuffer->Height;
- GLuint *buf;
- GLubyte *buf2;
- GLuint i;
-
- buf = (GLuint *) malloc(w * h * 4); /* 4 bpp */
- buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */
-
- _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
- _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
- _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
-
- _mesa_ReadPixels(0, 0, w, h, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, buf);
-
- /* spread 24 bits of Z across R, G, B */
- for (i = 0; i < w * h; i++) {
- buf2[i*3+0] = (buf[i] >> 24) & 0xff;
- buf2[i*3+1] = (buf[i] >> 16) & 0xff;
- buf2[i*3+2] = (buf[i] >> 8) & 0xff;
- }
-
- printf("Writing %d x %d depth buffer to %s\n", w, h, filename);
- write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE);
-
- _mesa_PopClientAttrib();
-
- free(buf);
- free(buf2);
-}
-
-
-void
-_mesa_dump_stencil_buffer(const char *filename)
-{
- GET_CURRENT_CONTEXT(ctx);
- const GLuint w = ctx->DrawBuffer->Width;
- const GLuint h = ctx->DrawBuffer->Height;
- GLubyte *buf;
- GLubyte *buf2;
- GLuint i;
-
- buf = (GLubyte *) malloc(w * h); /* 1 bpp */
- buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */
-
- _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
- _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
- _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
-
- _mesa_ReadPixels(0, 0, w, h, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, buf);
-
- for (i = 0; i < w * h; i++) {
- buf2[i*3+0] = buf[i];
- buf2[i*3+1] = (buf[i] & 127) * 2;
- buf2[i*3+2] = (buf[i] - 128) * 2;
- }
-
- printf("Writing %d x %d stencil buffer to %s\n", w, h, filename);
- write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE);
-
- _mesa_PopClientAttrib();
-
- free(buf);
- free(buf2);
-}
-
-
-/**
- * Quick and dirty function to "print" a texture to stdout.
- */
-void
-_mesa_print_texture(struct gl_context *ctx, const struct gl_texture_image *img)
-{
-#if CHAN_TYPE != GL_UNSIGNED_BYTE
- _mesa_problem(NULL, "PrintTexture not supported");
-#else
- GLuint i, j, c;
- const GLubyte *data = (const GLubyte *) img->Data;
-
- if (!data) {
- printf("No texture data\n");
- return;
- }
-
- /* XXX add more formats or make into a new format utility function */
- switch (img->TexFormat) {
- case MESA_FORMAT_A8:
- case MESA_FORMAT_L8:
- case MESA_FORMAT_I8:
- case MESA_FORMAT_CI8:
- c = 1;
- break;
- case MESA_FORMAT_AL88:
- case MESA_FORMAT_AL88_REV:
- c = 2;
- break;
- case MESA_FORMAT_RGB888:
- case MESA_FORMAT_BGR888:
- c = 3;
- break;
- case MESA_FORMAT_RGBA8888:
- case MESA_FORMAT_ARGB8888:
- c = 4;
- break;
- default:
- _mesa_problem(NULL, "error in PrintTexture\n");
- return;
- }
-
- for (i = 0; i < img->Height; i++) {
- for (j = 0; j < img->Width; j++) {
- if (c==1)
- printf("%02x ", data[0]);
- else if (c==2)
- printf("%02x%02x ", data[0], data[1]);
- else if (c==3)
- printf("%02x%02x%02x ", data[0], data[1], data[2]);
- else if (c==4)
- printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]);
- data += (img->RowStride - img->Width) * c;
- }
- /* XXX use img->ImageStride here */
- printf("\n");
- }
-#endif
-}
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "mtypes.h"
+#include "attrib.h"
+#include "colormac.h"
+#include "enums.h"
+#include "formats.h"
+#include "hash.h"
+#include "imports.h"
+#include "debug.h"
+#include "get.h"
+#include "pixelstore.h"
+#include "readpix.h"
+#include "texobj.h"
+
+
+static const char *
+tex_target_name(GLenum tgt)
+{
+ static const struct {
+ GLenum target;
+ const char *name;
+ } tex_targets[] = {
+ { GL_TEXTURE_1D, "GL_TEXTURE_1D" },
+ { GL_TEXTURE_2D, "GL_TEXTURE_2D" },
+ { GL_TEXTURE_3D, "GL_TEXTURE_3D" },
+ { GL_TEXTURE_CUBE_MAP, "GL_TEXTURE_CUBE_MAP" },
+ { GL_TEXTURE_RECTANGLE, "GL_TEXTURE_RECTANGLE" },
+ { GL_TEXTURE_1D_ARRAY_EXT, "GL_TEXTURE_1D_ARRAY" },
+ { GL_TEXTURE_2D_ARRAY_EXT, "GL_TEXTURE_2D_ARRAY" }
+ };
+ GLuint i;
+ for (i = 0; i < Elements(tex_targets); i++) {
+ if (tex_targets[i].target == tgt)
+ return tex_targets[i].name;
+ }
+ return "UNKNOWN TEX TARGET";
+}
+
+
+void
+_mesa_print_state( const char *msg, GLuint state )
+{
+ _mesa_debug(NULL,
+ "%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\n",
+ msg,
+ state,
+ (state & _NEW_MODELVIEW) ? "ctx->ModelView, " : "",
+ (state & _NEW_PROJECTION) ? "ctx->Projection, " : "",
+ (state & _NEW_TEXTURE_MATRIX) ? "ctx->TextureMatrix, " : "",
+ (state & _NEW_COLOR) ? "ctx->Color, " : "",
+ (state & _NEW_DEPTH) ? "ctx->Depth, " : "",
+ (state & _NEW_EVAL) ? "ctx->Eval/EvalMap, " : "",
+ (state & _NEW_FOG) ? "ctx->Fog, " : "",
+ (state & _NEW_HINT) ? "ctx->Hint, " : "",
+ (state & _NEW_LIGHT) ? "ctx->Light, " : "",
+ (state & _NEW_LINE) ? "ctx->Line, " : "",
+ (state & _NEW_PIXEL) ? "ctx->Pixel, " : "",
+ (state & _NEW_POINT) ? "ctx->Point, " : "",
+ (state & _NEW_POLYGON) ? "ctx->Polygon, " : "",
+ (state & _NEW_POLYGONSTIPPLE) ? "ctx->PolygonStipple, " : "",
+ (state & _NEW_SCISSOR) ? "ctx->Scissor, " : "",
+ (state & _NEW_STENCIL) ? "ctx->Stencil, " : "",
+ (state & _NEW_TEXTURE) ? "ctx->Texture, " : "",
+ (state & _NEW_TRANSFORM) ? "ctx->Transform, " : "",
+ (state & _NEW_VIEWPORT) ? "ctx->Viewport, " : "",
+ (state & _NEW_PACKUNPACK) ? "ctx->Pack/Unpack, " : "",
+ (state & _NEW_ARRAY) ? "ctx->Array, " : "",
+ (state & _NEW_RENDERMODE) ? "ctx->RenderMode, " : "",
+ (state & _NEW_BUFFERS) ? "ctx->Visual, ctx->DrawBuffer,, " : "");
+}
+
+
+
+void
+_mesa_print_tri_caps( const char *name, GLuint flags )
+{
+ _mesa_debug(NULL,
+ "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+ name,
+ flags,
+ (flags & DD_FLATSHADE) ? "flat-shade, " : "",
+ (flags & DD_SEPARATE_SPECULAR) ? "separate-specular, " : "",
+ (flags & DD_TRI_LIGHT_TWOSIDE) ? "tri-light-twoside, " : "",
+ (flags & DD_TRI_TWOSTENCIL) ? "tri-twostencil, " : "",
+ (flags & DD_TRI_UNFILLED) ? "tri-unfilled, " : "",
+ (flags & DD_TRI_STIPPLE) ? "tri-stipple, " : "",
+ (flags & DD_TRI_OFFSET) ? "tri-offset, " : "",
+ (flags & DD_TRI_SMOOTH) ? "tri-smooth, " : "",
+ (flags & DD_LINE_SMOOTH) ? "line-smooth, " : "",
+ (flags & DD_LINE_STIPPLE) ? "line-stipple, " : "",
+ (flags & DD_POINT_SMOOTH) ? "point-smooth, " : "",
+ (flags & DD_POINT_ATTEN) ? "point-atten, " : "",
+ (flags & DD_TRI_CULL_FRONT_BACK) ? "cull-all, " : ""
+ );
+}
+
+
+/**
+ * Print information about this Mesa version and build options.
+ */
+void _mesa_print_info( void )
+{
+ _mesa_debug(NULL, "Mesa GL_VERSION = %s\n",
+ (char *) _mesa_GetString(GL_VERSION));
+ _mesa_debug(NULL, "Mesa GL_RENDERER = %s\n",
+ (char *) _mesa_GetString(GL_RENDERER));
+ _mesa_debug(NULL, "Mesa GL_VENDOR = %s\n",
+ (char *) _mesa_GetString(GL_VENDOR));
+ _mesa_debug(NULL, "Mesa GL_EXTENSIONS = %s\n",
+ (char *) _mesa_GetString(GL_EXTENSIONS));
+#if defined(THREADS)
+ _mesa_debug(NULL, "Mesa thread-safe: YES\n");
+#else
+ _mesa_debug(NULL, "Mesa thread-safe: NO\n");
+#endif
+#if defined(USE_X86_ASM)
+ _mesa_debug(NULL, "Mesa x86-optimized: YES\n");
+#else
+ _mesa_debug(NULL, "Mesa x86-optimized: NO\n");
+#endif
+#if defined(USE_SPARC_ASM)
+ _mesa_debug(NULL, "Mesa sparc-optimized: YES\n");
+#else
+ _mesa_debug(NULL, "Mesa sparc-optimized: NO\n");
+#endif
+}
+
+
+/**
+ * Set the debugging flags.
+ *
+ * \param debug debug string
+ *
+ * If compiled with debugging support then search for keywords in \p debug and
+ * enables the verbose debug output of the respective feature.
+ */
+static void add_debug_flags( const char *debug )
+{
+#ifdef DEBUG
+ struct debug_option {
+ const char *name;
+ GLbitfield flag;
+ };
+ static const struct debug_option debug_opt[] = {
+ { "varray", VERBOSE_VARRAY },
+ { "tex", VERBOSE_TEXTURE },
+ { "mat", VERBOSE_MATERIAL },
+ { "pipe", VERBOSE_PIPELINE },
+ { "driver", VERBOSE_DRIVER },
+ { "state", VERBOSE_STATE },
+ { "api", VERBOSE_API },
+ { "list", VERBOSE_DISPLAY_LIST },
+ { "lighting", VERBOSE_LIGHTING },
+ { "disassem", VERBOSE_DISASSEM },
+ { "draw", VERBOSE_DRAW },
+ { "swap", VERBOSE_SWAPBUFFERS }
+ };
+ GLuint i;
+
+ MESA_VERBOSE = 0x0;
+ for (i = 0; i < Elements(debug_opt); i++) {
+ if (strstr(debug, debug_opt[i].name))
+ MESA_VERBOSE |= debug_opt[i].flag;
+ }
+
+ /* Debug flag:
+ */
+ if (strstr(debug, "flush"))
+ MESA_DEBUG_FLAGS |= DEBUG_ALWAYS_FLUSH;
+
+#if defined(_FPU_GETCW) && defined(_FPU_SETCW)
+ if (strstr(debug, "fpexceptions")) {
+ /* raise FP exceptions */
+ fpu_control_t mask;
+ _FPU_GETCW(mask);
+ mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM
+ | _FPU_MASK_OM | _FPU_MASK_UM);
+ _FPU_SETCW(mask);
+ }
+#endif
+
+#else
+ (void) debug;
+#endif
+}
+
+
+void
+_mesa_init_debug( struct gl_context *ctx )
+{
+ char *c;
+ c = _mesa_getenv("MESA_DEBUG");
+ if (c)
+ add_debug_flags(c);
+
+ c = _mesa_getenv("MESA_VERBOSE");
+ if (c)
+ add_debug_flags(c);
+}
+
+
+/*
+ * Write ppm file
+ */
+static void
+write_ppm(const char *filename, const GLubyte *buffer, int width, int height,
+ int comps, int rcomp, int gcomp, int bcomp, GLboolean invert)
+{
+ FILE *f = fopen( filename, "w" );
+ if (f) {
+ int x, y;
+ const GLubyte *ptr = buffer;
+ fprintf(f,"P6\n");
+ fprintf(f,"# ppm-file created by osdemo.c\n");
+ fprintf(f,"%i %i\n", width,height);
+ fprintf(f,"255\n");
+ fclose(f);
+ f = fopen( filename, "ab" ); /* reopen in binary append mode */
+ for (y=0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ int yy = invert ? (height - 1 - y) : y;
+ int i = (yy * width + x) * comps;
+ fputc(ptr[i+rcomp], f); /* write red */
+ fputc(ptr[i+gcomp], f); /* write green */
+ fputc(ptr[i+bcomp], f); /* write blue */
+ }
+ }
+ fclose(f);
+ }
+ else {
+ fprintf(stderr, "Unable to create %s in write_ppm()\n", filename);
+ }
+}
+
+
+/**
+ * Write a texture image to a ppm file.
+ * \param face cube face in [0,5]
+ * \param level mipmap level
+ */
+static void
+write_texture_image(struct gl_texture_object *texObj,
+ GLuint face, GLuint level)
+{
+ struct gl_texture_image *img = texObj->Image[face][level];
+ if (img) {
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_pixelstore_attrib store;
+ GLubyte *buffer;
+ char s[100];
+
+ buffer = (GLubyte *) malloc(img->Width * img->Height
+ * img->Depth * 4);
+
+ store = ctx->Pack; /* save */
+ ctx->Pack = ctx->DefaultPacking;
+
+ ctx->Driver.GetTexImage(ctx, texObj->Target, level,
+ GL_RGBA, GL_UNSIGNED_BYTE,
+ buffer, texObj, img);
+
+ /* make filename */
+ _mesa_snprintf(s, sizeof(s), "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face);
+
+ printf(" Writing image level %u to %s\n", level, s);
+ write_ppm(s, buffer, img->Width, img->Height, 4, 0, 1, 2, GL_FALSE);
+
+ ctx->Pack = store; /* restore */
+
+ free(buffer);
+ }
+}
+
+
+/**
+ * Write renderbuffer image to a ppm file.
+ */
+void
+_mesa_write_renderbuffer_image(const struct gl_renderbuffer *rb)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLubyte *buffer;
+ char s[100];
+ GLenum format, type;
+
+ if (rb->_BaseFormat == GL_RGB ||
+ rb->_BaseFormat == GL_RGBA) {
+ format = GL_RGBA;
+ type = GL_UNSIGNED_BYTE;
+ }
+ else if (rb->_BaseFormat == GL_DEPTH_STENCIL) {
+ format = GL_DEPTH_STENCIL;
+ type = GL_UNSIGNED_INT_24_8;
+ }
+ else {
+ _mesa_debug(NULL,
+ "Unsupported BaseFormat 0x%x in "
+ "_mesa_write_renderbuffer_image()\n",
+ rb->_BaseFormat);
+ return;
+ }
+
+ buffer = (GLubyte *) malloc(rb->Width * rb->Height * 4);
+
+ ctx->Driver.ReadPixels(ctx, 0, 0, rb->Width, rb->Height,
+ format, type, &ctx->DefaultPacking, buffer);
+
+ /* make filename */
+ _mesa_snprintf(s, sizeof(s), "/tmp/renderbuffer%u.ppm", rb->Name);
+ _mesa_snprintf(s, sizeof(s), "C:\\renderbuffer%u.ppm", rb->Name);
+
+ printf(" Writing renderbuffer image to %s\n", s);
+
+ _mesa_debug(NULL, " Writing renderbuffer image to %s\n", s);
+
+ write_ppm(s, buffer, rb->Width, rb->Height, 4, 0, 1, 2, GL_TRUE);
+
+ free(buffer);
+}
+
+
+/** How many texture images (mipmap levels, faces) to write to files */
+#define WRITE_NONE 0
+#define WRITE_ONE 1
+#define WRITE_ALL 2
+
+static GLuint WriteImages;
+
+
+static void
+dump_texture(struct gl_texture_object *texObj, GLuint writeImages)
+{
+ const GLuint numFaces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
+ GLboolean written = GL_FALSE;
+ GLuint i, j;
+
+ printf("Texture %u\n", texObj->Name);
+ printf(" Target %s\n", tex_target_name(texObj->Target));
+ for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
+ for (j = 0; j < numFaces; j++) {
+ struct gl_texture_image *texImg = texObj->Image[j][i];
+ if (texImg) {
+ printf(" Face %u level %u: %d x %d x %d, format %s at %p\n",
+ j, i,
+ texImg->Width, texImg->Height, texImg->Depth,
+ _mesa_get_format_name(texImg->TexFormat),
+ texImg->Data);
+ if (writeImages == WRITE_ALL ||
+ (writeImages == WRITE_ONE && !written)) {
+ write_texture_image(texObj, j, i);
+ written = GL_TRUE;
+ }
+ }
+ }
+ }
+}
+
+
+/**
+ * Dump a single texture.
+ */
+void
+_mesa_dump_texture(GLuint texture, GLuint writeImages)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_texture_object *texObj = _mesa_lookup_texture(ctx, texture);
+ if (texObj) {
+ dump_texture(texObj, writeImages);
+ }
+}
+
+
+static void
+dump_texture_cb(GLuint id, void *data, void *userData)
+{
+ struct gl_texture_object *texObj = (struct gl_texture_object *) data;
+ (void) userData;
+ dump_texture(texObj, WriteImages);
+}
+
+
+/**
+ * Print basic info about all texture objext to stdout.
+ * If dumpImages is true, write PPM of level[0] image to a file.
+ */
+void
+_mesa_dump_textures(GLuint writeImages)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ WriteImages = writeImages;
+ _mesa_HashWalk(ctx->Shared->TexObjects, dump_texture_cb, ctx);
+}
+
+
+static void
+dump_renderbuffer(const struct gl_renderbuffer *rb, GLboolean writeImage)
+{
+ printf("Renderbuffer %u: %u x %u IntFormat = %s\n",
+ rb->Name, rb->Width, rb->Height,
+ _mesa_lookup_enum_by_nr(rb->InternalFormat));
+ if (writeImage) {
+ _mesa_write_renderbuffer_image(rb);
+ }
+}
+
+
+static void
+dump_renderbuffer_cb(GLuint id, void *data, void *userData)
+{
+ const struct gl_renderbuffer *rb = (const struct gl_renderbuffer *) data;
+ (void) userData;
+ dump_renderbuffer(rb, WriteImages);
+}
+
+
+/**
+ * Print basic info about all renderbuffers to stdout.
+ * If dumpImages is true, write PPM of level[0] image to a file.
+ */
+void
+_mesa_dump_renderbuffers(GLboolean writeImages)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ WriteImages = writeImages;
+ _mesa_HashWalk(ctx->Shared->RenderBuffers, dump_renderbuffer_cb, ctx);
+}
+
+
+
+void
+_mesa_dump_color_buffer(const char *filename)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const GLuint w = ctx->DrawBuffer->Width;
+ const GLuint h = ctx->DrawBuffer->Height;
+ GLubyte *buf;
+
+ buf = (GLubyte *) malloc(w * h * 4);
+
+ _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
+ _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
+ _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
+
+ _mesa_ReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+
+ printf("ReadBuffer %p 0x%x DrawBuffer %p 0x%x\n",
+ (void *) ctx->ReadBuffer->_ColorReadBuffer,
+ ctx->ReadBuffer->ColorReadBuffer,
+ (void *) ctx->DrawBuffer->_ColorDrawBuffers[0],
+ ctx->DrawBuffer->ColorDrawBuffer[0]);
+ printf("Writing %d x %d color buffer to %s\n", w, h, filename);
+ write_ppm(filename, buf, w, h, 4, 0, 1, 2, GL_TRUE);
+
+ _mesa_PopClientAttrib();
+
+ free(buf);
+}
+
+
+void
+_mesa_dump_depth_buffer(const char *filename)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const GLuint w = ctx->DrawBuffer->Width;
+ const GLuint h = ctx->DrawBuffer->Height;
+ GLuint *buf;
+ GLubyte *buf2;
+ GLuint i;
+
+ buf = (GLuint *) malloc(w * h * 4); /* 4 bpp */
+ buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */
+
+ _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
+ _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
+ _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
+
+ _mesa_ReadPixels(0, 0, w, h, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, buf);
+
+ /* spread 24 bits of Z across R, G, B */
+ for (i = 0; i < w * h; i++) {
+ buf2[i*3+0] = (buf[i] >> 24) & 0xff;
+ buf2[i*3+1] = (buf[i] >> 16) & 0xff;
+ buf2[i*3+2] = (buf[i] >> 8) & 0xff;
+ }
+
+ printf("Writing %d x %d depth buffer to %s\n", w, h, filename);
+ write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE);
+
+ _mesa_PopClientAttrib();
+
+ free(buf);
+ free(buf2);
+}
+
+
+void
+_mesa_dump_stencil_buffer(const char *filename)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const GLuint w = ctx->DrawBuffer->Width;
+ const GLuint h = ctx->DrawBuffer->Height;
+ GLubyte *buf;
+ GLubyte *buf2;
+ GLuint i;
+
+ buf = (GLubyte *) malloc(w * h); /* 1 bpp */
+ buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */
+
+ _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
+ _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
+ _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
+
+ _mesa_ReadPixels(0, 0, w, h, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, buf);
+
+ for (i = 0; i < w * h; i++) {
+ buf2[i*3+0] = buf[i];
+ buf2[i*3+1] = (buf[i] & 127) * 2;
+ buf2[i*3+2] = (buf[i] - 128) * 2;
+ }
+
+ printf("Writing %d x %d stencil buffer to %s\n", w, h, filename);
+ write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE);
+
+ _mesa_PopClientAttrib();
+
+ free(buf);
+ free(buf2);
+}
+
+
+void
+_mesa_dump_image(const char *filename, const void *image, GLuint w, GLuint h,
+ GLenum format, GLenum type)
+{
+ GLboolean invert = GL_TRUE;
+
+ if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+ write_ppm(filename, image, w, h, 4, 0, 1, 2, invert);
+ }
+ else if (format == GL_BGRA && type == GL_UNSIGNED_BYTE) {
+ write_ppm(filename, image, w, h, 4, 2, 1, 0, invert);
+ }
+ else if (format == GL_LUMINANCE_ALPHA && type == GL_UNSIGNED_BYTE) {
+ write_ppm(filename, image, w, h, 2, 1, 0, 0, invert);
+ }
+ else {
+ _mesa_problem(NULL, "Unsupported format/type in _mesa_dump_image()");
+ }
+}
+
+
+/**
+ * Quick and dirty function to "print" a texture to stdout.
+ */
+void
+_mesa_print_texture(struct gl_context *ctx, const struct gl_texture_image *img)
+{
+#if CHAN_TYPE != GL_UNSIGNED_BYTE
+ _mesa_problem(NULL, "PrintTexture not supported");
+#else
+ GLuint i, j, c;
+ const GLubyte *data = (const GLubyte *) img->Data;
+
+ if (!data) {
+ printf("No texture data\n");
+ return;
+ }
+
+ /* XXX add more formats or make into a new format utility function */
+ switch (img->TexFormat) {
+ case MESA_FORMAT_A8:
+ case MESA_FORMAT_L8:
+ case MESA_FORMAT_I8:
+ case MESA_FORMAT_CI8:
+ c = 1;
+ break;
+ case MESA_FORMAT_AL88:
+ case MESA_FORMAT_AL88_REV:
+ c = 2;
+ break;
+ case MESA_FORMAT_RGB888:
+ case MESA_FORMAT_BGR888:
+ c = 3;
+ break;
+ case MESA_FORMAT_RGBA8888:
+ case MESA_FORMAT_ARGB8888:
+ c = 4;
+ break;
+ default:
+ _mesa_problem(NULL, "error in PrintTexture\n");
+ return;
+ }
+
+ for (i = 0; i < img->Height; i++) {
+ for (j = 0; j < img->Width; j++) {
+ if (c==1)
+ printf("%02x ", data[0]);
+ else if (c==2)
+ printf("%02x%02x ", data[0], data[1]);
+ else if (c==3)
+ printf("%02x%02x%02x ", data[0], data[1], data[2]);
+ else if (c==4)
+ printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]);
+ data += (img->RowStride - img->Width) * c;
+ }
+ /* XXX use img->ImageStride here */
+ printf("\n");
+ }
+#endif
+}
diff --git a/mesalib/src/mesa/main/debug.h b/mesalib/src/mesa/main/debug.h
index 81fcf100d..d7c53b655 100644
--- a/mesalib/src/mesa/main/debug.h
+++ b/mesalib/src/mesa/main/debug.h
@@ -1,90 +1,94 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file debug.h
- * Debugging functions.
- *
- * \if subset
- * (No-op)
- *
- * \endif
- */
-
-
-#ifndef _DEBUG_H
-#define _DEBUG_H
-
-#include "glheader.h"
-#include "mfeatures.h"
-
-struct gl_context;
-struct gl_texture_image;
-
-#if _HAVE_FULL_GL
-
-extern void _mesa_print_tri_caps( const char *name, GLuint flags );
-extern void _mesa_print_enable_flags( const char *msg, GLuint flags );
-extern void _mesa_print_state( const char *msg, GLuint state );
-extern void _mesa_print_info( void );
-extern void _mesa_init_debug( struct gl_context *ctx );
-
-#else
-
-/** No-op */
-#define _mesa_print_state( m, s ) ((void)0)
-
-/** No-op */
-#define _mesa_print_info() ((void)0)
-
-/** No-op */
-#define _mesa_init_debug( c ) ((void)0)
-
-#endif
-
-extern void
-_mesa_write_renderbuffer_image(const struct gl_renderbuffer *rb);
-
-extern void
-_mesa_dump_texture(GLuint texture, GLuint writeImages);
-
-extern void
-_mesa_dump_textures(GLuint writeImages);
-
-extern void
-_mesa_dump_renderbuffers(GLboolean writeImages);
-
-extern void
-_mesa_dump_color_buffer(const char *filename);
-
-extern void
-_mesa_dump_depth_buffer(const char *filename);
-
-extern void
-_mesa_dump_stencil_buffer(const char *filename);
-
-extern void
-_mesa_print_texture(struct gl_context *ctx, const struct gl_texture_image *img);
-
-#endif
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file debug.h
+ * Debugging functions.
+ *
+ * \if subset
+ * (No-op)
+ *
+ * \endif
+ */
+
+
+#ifndef _DEBUG_H
+#define _DEBUG_H
+
+#include "glheader.h"
+#include "mfeatures.h"
+
+struct gl_context;
+struct gl_texture_image;
+
+#if _HAVE_FULL_GL
+
+extern void _mesa_print_tri_caps( const char *name, GLuint flags );
+extern void _mesa_print_enable_flags( const char *msg, GLuint flags );
+extern void _mesa_print_state( const char *msg, GLuint state );
+extern void _mesa_print_info( void );
+extern void _mesa_init_debug( struct gl_context *ctx );
+
+#else
+
+/** No-op */
+#define _mesa_print_state( m, s ) ((void)0)
+
+/** No-op */
+#define _mesa_print_info() ((void)0)
+
+/** No-op */
+#define _mesa_init_debug( c ) ((void)0)
+
+#endif
+
+extern void
+_mesa_write_renderbuffer_image(const struct gl_renderbuffer *rb);
+
+extern void
+_mesa_dump_texture(GLuint texture, GLuint writeImages);
+
+extern void
+_mesa_dump_textures(GLuint writeImages);
+
+extern void
+_mesa_dump_renderbuffers(GLboolean writeImages);
+
+extern void
+_mesa_dump_color_buffer(const char *filename);
+
+extern void
+_mesa_dump_depth_buffer(const char *filename);
+
+extern void
+_mesa_dump_stencil_buffer(const char *filename);
+
+extern void
+_mesa_dump_image(const char *filename, const void *image, GLuint w, GLuint h,
+ GLenum format, GLenum type);
+
+extern void
+_mesa_print_texture(struct gl_context *ctx, const struct gl_texture_image *img);
+
+#endif
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index 4b6e91c4f..d0c08ca71 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -753,7 +753,7 @@ _mesa_extension_is_enabled( struct gl_context *ctx, const char *name )
static char *
get_extension_override( struct gl_context *ctx )
{
- const char *env_const= _mesa_getenv("MESA_EXTENSION_OVERRIDE");
+ const char *env_const = _mesa_getenv("MESA_EXTENSION_OVERRIDE");
char *env;
char *ext;
char *extra_exts;
@@ -794,7 +794,7 @@ get_extension_override( struct gl_context *ctx )
}
/* Remove trailing space. */
- len = strlen(extra_exts);
+ len = strlen(extra_exts);
if (extra_exts[len - 1] == ' ')
extra_exts[len - 1] = '\0';
@@ -875,12 +875,24 @@ _mesa_make_extension_string(struct gl_context *ctx)
GLboolean *base = (GLboolean *) &ctx->Extensions;
const struct extension *i;
unsigned j;
-
+ unsigned maxYear = ~0;
+
+ /* Check if the MESA_EXTENSION_MAX_YEAR env var is set */
+ {
+ const char *env = getenv("MESA_EXTENSION_MAX_YEAR");
+ if (env) {
+ maxYear = atoi(env);
+ _mesa_debug(ctx, "Note: limiting GL extensions to %u or earlier\n",
+ maxYear);
+ }
+ }
/* Compute length of the extension string. */
count = 0;
for (i = extension_table; i->name != 0; ++i) {
- if (base[i->offset] && (i->api_set & (1 << ctx->API))) {
+ if (base[i->offset] &&
+ i->year <= maxYear &&
+ (i->api_set & (1 << ctx->API))) {
length += strlen(i->name) + 1; /* +1 for space */
++count;
}
@@ -908,7 +920,9 @@ _mesa_make_extension_string(struct gl_context *ctx)
*/
j = 0;
for (i = extension_table; i->name != 0; ++i) {
- if (base[i->offset] && (i->api_set & (1 << ctx->API))) {
+ if (base[i->offset] &&
+ i->year <= maxYear &&
+ (i->api_set & (1 << ctx->API))) {
extension_indices[j++] = i - extension_table;
}
}