struct gl_extensions _mesa_extension_override_enables;
struct gl_extensions _mesa_extension_override_disables;
static char *extra_extensions = NULL;
-static char *cant_disable_extensions = NULL;
/**
#undef EXT
};
+static bool disabled_extensions[ARRAY_SIZE(_mesa_extension_table)];
/**
* Given an extension name, lookup up the corresponding member of struct
- * gl_extensions and return that member's offset (in bytes). If the name is
- * not found in the \c _mesa_extension_table, return 0.
+ * gl_extensions and return that member's index. If the name is
+ * not found in the \c _mesa_extension_table, return -1.
*
* \param name Name of extension.
- * \return Offset of member in struct gl_extensions.
+ * \return Index of member in struct gl_extensions.
*/
-static size_t
-name_to_offset(const char* name)
+static int
+name_to_index(const char* name)
{
unsigned i;
if (name == 0)
- return 0;
+ return -1;
for (i = 0; i < ARRAY_SIZE(_mesa_extension_table); ++i) {
if (strcmp(name, _mesa_extension_table[i].name) == 0)
- return _mesa_extension_table[i].offset;
+ return i;
}
- return 0;
+ return -1;
}
/**
* \return offset of extensions withint `ext' or 0 if extension is not known
*/
static size_t
-set_extension(struct gl_extensions *ext, const char *name, GLboolean state)
+set_extension(struct gl_extensions *ext, int i, GLboolean state)
{
size_t offset;
- offset = name_to_offset(name);
+ offset = i < 0 ? 0 : _mesa_extension_table[i].offset;
if (offset != 0 && (offset != o(dummy_true) || state != GL_FALSE)) {
((GLboolean *) ext)[offset] = state;
}
{
override_extensions_in_context(ctx);
- if (cant_disable_extensions != NULL) {
- _mesa_problem(ctx,
- "Trying to disable permanently enabled extensions: %s",
- cant_disable_extensions);
- }
-
if (extra_extensions == NULL) {
return calloc(1, sizeof(char));
} else {
/**
- * \brief Free extra_extensions and cant_disable_extensions strings
+ * \brief Free extra_extensions string
*
* These strings are allocated early during the first context creation by
* _mesa_one_time_init_extension_overrides.
free_unknown_extensions_strings(void)
{
free(extra_extensions);
- free(cant_disable_extensions);
}
/* extra_exts: List of unrecognized extensions. */
extra_extensions = calloc(ALIGN(strlen(env_const) + 2, 4), sizeof(char));
- cant_disable_extensions = calloc(ALIGN(strlen(env_const) + 2, 4), sizeof(char));
/* Copy env_const because strtok() is destructive. */
env = strdup(env_const);
if (env == NULL ||
- extra_extensions == NULL ||
- cant_disable_extensions == NULL) {
+ extra_extensions == NULL) {
free(env);
free(extra_extensions);
- free(cant_disable_extensions);
return;
}
for (ext = strtok(env, " "); ext != NULL; ext = strtok(NULL, " ")) {
int enable;
+ int i;
bool recognized;
switch (ext[0]) {
case '+':
break;
}
- offset = set_extension(&_mesa_extension_override_enables, ext, enable);
+ i = name_to_index(ext);
+ offset = set_extension(&_mesa_extension_override_enables, i, enable);
if (offset != 0 && (offset != o(dummy_true) || enable != GL_FALSE)) {
((GLboolean *) &_mesa_extension_override_disables)[offset] = !enable;
recognized = true;
recognized = false;
}
- if (!recognized) {
- if (enable) {
- strcat(extra_extensions, ext);
- strcat(extra_extensions, " ");
- } else if (offset == o(dummy_true)) {
- strcat(cant_disable_extensions, ext);
- strcat(cant_disable_extensions, " ");
- }
+ if (i >= 0)
+ disabled_extensions[i] = !enable;
+
+ if (!recognized && enable) {
+ strcat(extra_extensions, ext);
+ strcat(extra_extensions, " ");
}
}
} else if (extra_extensions[len - 1] == ' ') {
extra_extensions[len - 1] = '\0';
}
- len = strlen(cant_disable_extensions);
- if (len == 0) {
- free(cant_disable_extensions);
- cant_disable_extensions = NULL;
- } else if (cant_disable_extensions[len - 1] == ' ') {
- cant_disable_extensions[len - 1] = '\0';
- }
}
const bool *base = (bool *) &ctx->Extensions;
const struct mesa_extension *ext = _mesa_extension_table + i;
- return (ctx->Version >= ext->version[ctx->API]) && base[ext->offset];
+ return !disabled_extensions[i] &&
+ (ctx->Version >= ext->version[ctx->API]) && base[ext->offset];
}
/**