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;
/**
*/
#define o(x) offsetof(struct gl_extensions, x)
-
-/**
- * \brief Table of supported OpenGL extensions for all API's.
- */
-const struct mesa_extension _mesa_extension_table[] = {
-#define EXT(name_str, driver_cap, gll_ver, glc_ver, gles_ver, gles2_ver, yyyy) \
- { .name = "GL_" #name_str, .offset = o(driver_cap), \
- .version = { \
- [API_OPENGL_COMPAT] = gll_ver, \
- [API_OPENGL_CORE] = glc_ver, \
- [API_OPENGLES] = gles_ver, \
- [API_OPENGLES2] = gles2_ver, \
- }, \
- .year = yyyy \
- },
-#include "extensions_table.h"
-#undef EXT
-};
-
+static bool disabled_extensions[MESA_EXTENSION_COUNT];
/**
* 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) {
+ for (i = 0; i < MESA_EXTENSION_COUNT; ++i) {
if (strcmp(name, _mesa_extension_table[i].name) == 0)
- return _mesa_extension_table[i].offset;
+ return i;
}
- return 0;
+ return -1;
}
/**
(GLboolean*) &_mesa_extension_override_disables;
GLboolean *ctx_ext = (GLboolean*)&ctx->Extensions;
- for (i = 0; i < ARRAY_SIZE(_mesa_extension_table); ++i) {
+ for (i = 0; i < MESA_EXTENSION_COUNT; ++i) {
size_t offset = _mesa_extension_table[i].offset;
assert(!enables[offset] || !disables[offset]);
* \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) {
- free(env);
- free(extra_extensions);
- free(cant_disable_extensions);
- return;
+ if (env == NULL ||
+ extra_extensions == NULL) {
+ free(env);
+ free(extra_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];
}
/**
/* Compute length of the extension string. */
count = 0;
- for (k = 0; k < ARRAY_SIZE(_mesa_extension_table); ++k) {
+ for (k = 0; k < MESA_EXTENSION_COUNT; ++k) {
const struct mesa_extension *i = _mesa_extension_table + k;
if (i->year <= maxYear &&
* expect will fit into that buffer.
*/
j = 0;
- for (k = 0; k < ARRAY_SIZE(_mesa_extension_table); ++k) {
+ for (k = 0; k < MESA_EXTENSION_COUNT; ++k) {
if (_mesa_extension_table[k].year <= maxYear &&
_mesa_extension_supported(ctx, k)) {
extension_indices[j++] = k;
if (ctx->Extensions.Count != 0)
return ctx->Extensions.Count;
- for (k = 0; k < ARRAY_SIZE(_mesa_extension_table); ++k) {
+ for (k = 0; k < MESA_EXTENSION_COUNT; ++k) {
if (_mesa_extension_supported(ctx, k))
ctx->Extensions.Count++;
}
size_t n = 0;
unsigned i;
- for (i = 0; i < ARRAY_SIZE(_mesa_extension_table); ++i) {
+ for (i = 0; i < MESA_EXTENSION_COUNT; ++i) {
if (_mesa_extension_supported(ctx, i)) {
if (n == index)
return (const GLubyte*) _mesa_extension_table[i].name;