aboutsummaryrefslogtreecommitdiff
path: root/mesalib
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib')
-rw-r--r--mesalib/docs/envvars.html9
-rw-r--r--mesalib/src/mesa/main/debug.c24
-rw-r--r--mesalib/src/mesa/main/debug.h4
-rw-r--r--mesalib/src/mesa/main/extensions.c24
4 files changed, 56 insertions, 5 deletions
diff --git a/mesalib/docs/envvars.html b/mesalib/docs/envvars.html
index 5240c803f..c710bca51 100644
--- a/mesalib/docs/envvars.html
+++ b/mesalib/docs/envvars.html
@@ -49,6 +49,15 @@ 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>
diff --git a/mesalib/src/mesa/main/debug.c b/mesalib/src/mesa/main/debug.c
index e336b077e..f82e32ed8 100644
--- a/mesalib/src/mesa/main/debug.c
+++ b/mesalib/src/mesa/main/debug.c
@@ -251,6 +251,9 @@ write_ppm(const char *filename, const GLubyte *buffer, int width, int height,
}
fclose(f);
}
+ else {
+ fprintf(stderr, "Unable to create %s in write_ppm()\n", filename);
+ }
}
@@ -549,6 +552,27 @@ _mesa_dump_stencil_buffer(const char *filename)
}
+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.
*/
diff --git a/mesalib/src/mesa/main/debug.h b/mesalib/src/mesa/main/debug.h
index 81fcf100d..eda377abb 100644
--- a/mesalib/src/mesa/main/debug.h
+++ b/mesalib/src/mesa/main/debug.h
@@ -85,6 +85,10 @@ 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 6de672e92..b58d3635e 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;
}
}