mirror of
https://gitee.com/openharmony/third_party_mesa3d
synced 2024-11-27 17:40:43 +00:00
mesa: remove unnecessary 'sort by year' for the GL extensions
The sorting was originally added to work around broken games (comment says Quake3 demo) that were copying the extensions list into small buffer. Sorting does not solve the problem, since we'll still overflow and cause corruption/crash. Better workaround is to actually trim the string ... as done with a later commit which introduces the MESA_EXTENSION_MAX_YEAR env. variable. Side note: On my machine, the existing sorting makes no changes to the extensions string. Cc: Jose Fonseca <jfonseca@vmware.com> Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
parent
a3f82876f4
commit
3d81e11b49
@ -352,30 +352,6 @@ _mesa_extension_supported(const struct gl_context *ctx, extension_index i)
|
||||
return (ctx->Version >= ext->version[ctx->API]) && base[ext->offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two entries of the extensions table. Sorts first by year,
|
||||
* then by name.
|
||||
*
|
||||
* Arguments are indices into _mesa_extension_table.
|
||||
*/
|
||||
static int
|
||||
extension_compare(const void *p1, const void *p2)
|
||||
{
|
||||
extension_index i1 = * (const extension_index *) p1;
|
||||
extension_index i2 = * (const extension_index *) p2;
|
||||
const struct mesa_extension *e1 = &_mesa_extension_table[i1];
|
||||
const struct mesa_extension *e2 = &_mesa_extension_table[i2];
|
||||
int res;
|
||||
|
||||
res = (int)e1->year - (int)e2->year;
|
||||
|
||||
if (res == 0) {
|
||||
res = strcmp(e1->name, e2->name);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct the GL_EXTENSIONS string. Called the first time that
|
||||
@ -391,7 +367,7 @@ _mesa_make_extension_string(struct gl_context *ctx)
|
||||
/* Number of extensions */
|
||||
unsigned count;
|
||||
/* Indices of the extensions sorted by year */
|
||||
extension_index *extension_indices;
|
||||
extension_index extension_indices[MESA_EXTENSION_COUNT];
|
||||
/* String of extra extensions. */
|
||||
const char *extra_extensions = get_extension_override(ctx);
|
||||
unsigned k;
|
||||
@ -415,8 +391,8 @@ _mesa_make_extension_string(struct gl_context *ctx)
|
||||
|
||||
if (i->year <= maxYear &&
|
||||
_mesa_extension_supported(ctx, k)) {
|
||||
length += strlen(i->name) + 1; /* +1 for space */
|
||||
++count;
|
||||
length += strlen(i->name) + 1; /* +1 for space */
|
||||
extension_indices[count++] = k;
|
||||
}
|
||||
}
|
||||
if (extra_extensions != NULL)
|
||||
@ -427,28 +403,6 @@ _mesa_make_extension_string(struct gl_context *ctx)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extension_indices = malloc(count * sizeof(extension_index));
|
||||
if (extension_indices == NULL) {
|
||||
free(exts);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Sort extensions in chronological order because certain old applications
|
||||
* (e.g., Quake3 demo) store the extension list in a static size buffer so
|
||||
* chronologically order ensure that the extensions that such applications
|
||||
* expect will fit into that buffer.
|
||||
*/
|
||||
j = 0;
|
||||
for (k = 0; k < MESA_EXTENSION_COUNT; ++k) {
|
||||
if (_mesa_extension_table[k].year <= maxYear &&
|
||||
_mesa_extension_supported(ctx, k)) {
|
||||
extension_indices[j++] = k;
|
||||
}
|
||||
}
|
||||
assert(j == count);
|
||||
qsort(extension_indices, count,
|
||||
sizeof *extension_indices, extension_compare);
|
||||
|
||||
/* Build the extension string.*/
|
||||
for (j = 0; j < count; ++j) {
|
||||
const struct mesa_extension *i = &_mesa_extension_table[extension_indices[j]];
|
||||
@ -456,7 +410,6 @@ _mesa_make_extension_string(struct gl_context *ctx)
|
||||
strcat(exts, i->name);
|
||||
strcat(exts, " ");
|
||||
}
|
||||
free(extension_indices);
|
||||
if (extra_extensions != 0) {
|
||||
strcat(exts, extra_extensions);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user