mesa: new MESA_EXTENSION_MAX_YEAR env var
If set to year X, only report extensions up to that year. This is a work-around for games that try to copy the extensions string to a fixed size buffer and overflow. If a game was released in year X, setting MESA_EXTENSION_MAX_YEAR to that year will likely fix the problem.
This commit is contained in:
@@ -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.
|
<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
|
A value such as "GL_EXT_foo -GL_EXT_bar" will enable the GL_EXT_foo extension
|
||||||
and disable the GL_EXT_bar 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>
|
<li>MESA_GLSL - <a href="shading.html#envvars">shading language compiler options</a>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@@ -875,12 +875,24 @@ _mesa_make_extension_string(struct gl_context *ctx)
|
|||||||
GLboolean *base = (GLboolean *) &ctx->Extensions;
|
GLboolean *base = (GLboolean *) &ctx->Extensions;
|
||||||
const struct extension *i;
|
const struct extension *i;
|
||||||
unsigned j;
|
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. */
|
/* Compute length of the extension string. */
|
||||||
count = 0;
|
count = 0;
|
||||||
for (i = extension_table; i->name != 0; ++i) {
|
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 */
|
length += strlen(i->name) + 1; /* +1 for space */
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
@@ -908,7 +920,9 @@ _mesa_make_extension_string(struct gl_context *ctx)
|
|||||||
*/
|
*/
|
||||||
j = 0;
|
j = 0;
|
||||||
for (i = extension_table; i->name != 0; ++i) {
|
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;
|
extension_indices[j++] = i - extension_table;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user