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 extension 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 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(extension_table); ++i) {
- if (strcmp(name, extension_table[i].name) == 0)
- return extension_table[i].offset;
+ for (i = 0; i < MESA_EXTENSION_COUNT; ++i) {
+ if (strcmp(name, _mesa_extension_table[i].name) == 0)
+ return i;
}
- return 0;
+ return -1;
}
/**
(GLboolean*) &_mesa_extension_override_disables;
GLboolean *ctx_ext = (GLboolean*)&ctx->Extensions;
- for (i = 0; i < ARRAY_SIZE(extension_table); ++i) {
- size_t offset = extension_table[i].offset;
+ for (i = 0; i < MESA_EXTENSION_COUNT; ++i) {
+ size_t offset = _mesa_extension_table[i].offset;
assert(!enables[offset] || !disables[offset]);
if (enables[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';
- }
}
/* Then, selectively turn default extensions on. */
extensions->dummy_true = GL_TRUE;
- extensions->EXT_texture3D = GL_TRUE;
}
* Given an extension enum, return whether or not the extension is supported
* dependent on the following factors:
* There's driver support and the OpenGL/ES version is at least that
- * specified in the extension_table.
+ * specified in the _mesa_extension_table.
*/
static inline bool
_mesa_extension_supported(const struct gl_context *ctx, extension_index i)
{
const bool *base = (bool *) &ctx->Extensions;
- const struct extension *ext = extension_table + i;
+ 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];
}
/**
* Compare two entries of the extensions table. Sorts first by year,
* then by name.
*
- * Arguments are indices into extension_table.
+ * 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 extension *e1 = &extension_table[i1];
- const struct extension *e2 = &extension_table[i2];
+ 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;
/* Compute length of the extension string. */
count = 0;
- for (k = 0; k < ARRAY_SIZE(extension_table); ++k) {
- const struct extension *i = extension_table + k;
+ for (k = 0; k < MESA_EXTENSION_COUNT; ++k) {
+ const struct mesa_extension *i = _mesa_extension_table + k;
if (i->year <= maxYear &&
_mesa_extension_supported(ctx, k)) {
* expect will fit into that buffer.
*/
j = 0;
- for (k = 0; k < ARRAY_SIZE(extension_table); ++k) {
- if (extension_table[k].year <= maxYear &&
+ for (k = 0; k < MESA_EXTENSION_COUNT; ++k) {
+ if (_mesa_extension_table[k].year <= maxYear &&
_mesa_extension_supported(ctx, k)) {
extension_indices[j++] = k;
}
/* Build the extension string.*/
for (j = 0; j < count; ++j) {
- const struct extension *i = &extension_table[extension_indices[j]];
+ const struct mesa_extension *i = &_mesa_extension_table[extension_indices[j]];
assert(_mesa_extension_supported(ctx, extension_indices[j]));
strcat(exts, i->name);
strcat(exts, " ");
if (ctx->Extensions.Count != 0)
return ctx->Extensions.Count;
- for (k = 0; k < ARRAY_SIZE(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(extension_table); ++i) {
+ for (i = 0; i < MESA_EXTENSION_COUNT; ++i) {
if (_mesa_extension_supported(ctx, i)) {
if (n == index)
- return (const GLubyte*) extension_table[i].name;
+ return (const GLubyte*) _mesa_extension_table[i].name;
else
++n;
}