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;
-
-enum {
- DISABLE = 0,
- GLL = 1 << API_OPENGL_COMPAT, /* GL Legacy / Compatibility */
- GLC = 1 << API_OPENGL_CORE, /* GL Core */
- GL = (1 << API_OPENGL_COMPAT) | (1 << API_OPENGL_CORE),
- ES1 = 1 << API_OPENGLES,
- ES2 = 1 << API_OPENGLES2,
- ES3 = 1 << (API_OPENGL_LAST + 1),
- ES31 = 1 << (API_OPENGL_LAST + 2),
-};
-
-/**
- * \brief An element of the \c extension_table.
- */
-struct extension {
- /** Name of extension, such as "GL_ARB_depth_clamp". */
- const char *name;
-
- /** Offset (in bytes) of the corresponding member in struct gl_extensions. */
- size_t offset;
-
- /** Set of API's in which the extension exists, as a bitset. */
- uint8_t api_set;
-
- /** Year the extension was proposed or approved. Used to sort the
- * extension string chronologically. */
- uint16_t year;
-};
/**
*/
#define o(x) offsetof(struct gl_extensions, x)
-
-/**
- * \brief Table of supported OpenGL extensions for all API's.
- */
-static const struct extension extension_table[] = {
-#define EXT(name_str, driver_cap, api_flags, yyyy) \
- { .name = "GL_" #name_str, .offset = o(driver_cap), .api_set = api_flags, .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;
}
typedef unsigned short extension_index;
+/**
+ * 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 _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 mesa_extension *ext = _mesa_extension_table + i;
+
+ 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;
extension_index *extension_indices;
/* String of extra extensions. */
char *extra_extensions = get_extension_override(ctx);
- GLboolean *base = (GLboolean *) &ctx->Extensions;
unsigned k;
unsigned j;
unsigned maxYear = ~0;
- unsigned api_set = (1 << ctx->API);
- if (_mesa_is_gles3(ctx))
- api_set |= ES3;
- if (_mesa_is_gles31(ctx))
- api_set |= ES31;
/* Check if the MESA_EXTENSION_MAX_YEAR env var is set */
{
/* 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 (base[i->offset] &&
- i->year <= maxYear &&
- (i->api_set & api_set)) {
+ if (i->year <= maxYear &&
+ _mesa_extension_supported(ctx, k)) {
length += strlen(i->name) + 1; /* +1 for space */
++count;
}
* expect will fit into that buffer.
*/
j = 0;
- for (k = 0; k < ARRAY_SIZE(extension_table); ++k) {
- const struct extension *i = extension_table + k;
-
- if (base[i->offset] &&
- i->year <= maxYear &&
- (i->api_set & api_set)) {
+ 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]];
- assert(base[i->offset] && (i->api_set & api_set));
+ 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, " ");
}
GLuint
_mesa_get_extension_count(struct gl_context *ctx)
{
- GLboolean *base;
unsigned k;
- unsigned api_set = (1 << ctx->API);
- if (_mesa_is_gles3(ctx))
- api_set |= ES3;
- if (_mesa_is_gles31(ctx))
- api_set |= ES31;
/* only count once */
if (ctx->Extensions.Count != 0)
return ctx->Extensions.Count;
- base = (GLboolean *) &ctx->Extensions;
- for (k = 0; k < ARRAY_SIZE(extension_table); ++k) {
- const struct extension *i = extension_table + k;
-
- if (base[i->offset] && (i->api_set & api_set)) {
+ for (k = 0; k < MESA_EXTENSION_COUNT; ++k) {
+ if (_mesa_extension_supported(ctx, k))
ctx->Extensions.Count++;
- }
}
return ctx->Extensions.Count;
}
const GLubyte *
_mesa_get_enabled_extension(struct gl_context *ctx, GLuint index)
{
- const GLboolean *base;
- size_t n;
- unsigned k;
- unsigned api_set = (1 << ctx->API);
- if (_mesa_is_gles3(ctx))
- api_set |= ES3;
- if (_mesa_is_gles31(ctx))
- api_set |= ES31;
-
- base = (GLboolean*) &ctx->Extensions;
- n = 0;
- for (k = 0; k < ARRAY_SIZE(extension_table); ++k) {
- const struct extension *i = extension_table + k;
-
- if (base[i->offset] && (i->api_set & api_set)) {
+ size_t n = 0;
+ unsigned i;
+
+ for (i = 0; i < MESA_EXTENSION_COUNT; ++i) {
+ if (_mesa_extension_supported(ctx, i)) {
if (n == index)
- return (const GLubyte*) i->name;
+ return (const GLubyte*) _mesa_extension_table[i].name;
else
++n;
}