<div dir="ltr"><div class="gmail_quote">From: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
<br>
Provide the ability to prevent any permanently enabled extension<br>
from appearing in the string returned by glGetString[i]().<br>
<br>
Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
---<br>
src/mesa/main/extensions.c | 64 +++++++++++++++++-----------------------------<br>
1 file changed, 24 insertions(+), 40 deletions(-)<br>
<br>
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c<br>
index 01cfdf1..fa50cb6 100644<br>
--- a/src/mesa/main/extensions.c<br>
+++ b/src/mesa/main/extensions.c<br>
@@ -40,7 +40,6 @@<br>
struct gl_extensions _mesa_extension_override_enables;<br>
struct gl_extensions _mesa_extension_override_disables;<br>
static char *extra_extensions = NULL;<br>
-static char *cant_disable_extensions = NULL;<br>
<br>
<br>
/**<br>
@@ -68,29 +67,30 @@ const struct mesa_extension _mesa_extension_table[] = {<br>
#undef EXT<br>
};<br>
<br>
+static bool disabled_extensions[ARRAY_SIZE(_mesa_extension_table)];<br>
<br>
/**<br>
* Given an extension name, lookup up the corresponding member of struct<br>
- * gl_extensions and return that member's offset (in bytes). If the name is<br>
- * not found in the \c _mesa_extension_table, return 0.<br>
+ * gl_extensions and return that member's index. If the name is<br>
+ * not found in the \c _mesa_extension_table, return -1.<br>
*<br>
* \param name Name of extension.<br>
- * \return Offset of member in struct gl_extensions.<br>
+ * \return Index of member in struct gl_extensions.<br>
*/<br>
-static size_t<br>
-name_to_offset(const char* name)<br>
+static int<br>
+name_to_index(const char* name)<br>
{<br>
unsigned i;<br>
<br>
if (name == 0)<br>
- return 0;<br>
+ return -1;<br>
<br>
for (i = 0; i < ARRAY_SIZE(_mesa_extension_table); ++i) {<br>
if (strcmp(name, _mesa_extension_table[i].name) == 0)<br>
- return _mesa_extension_table[i].offset;<br>
+ return i;<br>
}<br>
<br>
- return 0;<br>
+ return -1;<br>
}<br>
<br>
/**<br>
@@ -206,11 +206,11 @@ _mesa_enable_sw_extensions(struct gl_context *ctx)<br>
* \return offset of extensions withint `ext' or 0 if extension is not known<br>
*/<br>
static size_t<br>
-set_extension(struct gl_extensions *ext, const char *name, GLboolean state)<br>
+set_extension(struct gl_extensions *ext, int i, GLboolean state)<br>
{<br>
size_t offset;<br>
<br>
- offset = name_to_offset(name);<br>
+ offset = i < 0 ? 0 : _mesa_extension_table[i].offset;<br>
if (offset != 0 && (offset != o(dummy_true) || state != GL_FALSE)) {<br>
((GLboolean *) ext)[offset] = state;<br>
}<br>
@@ -240,12 +240,6 @@ get_extension_override( struct gl_context *ctx )<br>
{<br>
override_extensions_in_context(ctx);<br>
<br>
- if (cant_disable_extensions != NULL) {<br>
- _mesa_problem(ctx,<br>
- "Trying to disable permanently enabled extensions: %s",<br>
- cant_disable_extensions);<br>
- }<br>
-<br>
if (extra_extensions == NULL) {<br>
return calloc(1, sizeof(char));<br>
} else {<br>
@@ -257,7 +251,7 @@ get_extension_override( struct gl_context *ctx )<br>
<br>
<br>
/**<br>
- * \brief Free extra_extensions and cant_disable_extensions strings<br>
+ * \brief Free extra_extensions string<br>
*<br>
* These strings are allocated early during the first context creation by<br>
* _mesa_one_time_init_extension_overrides.<br>
@@ -266,7 +260,6 @@ static void<br>
free_unknown_extensions_strings(void)<br>
{<br>
free(extra_extensions);<br>
- free(cant_disable_extensions);<br>
}<br>
<br>
<br>
@@ -295,22 +288,20 @@ _mesa_one_time_init_extension_overrides(void)<br>
<br>
/* extra_exts: List of unrecognized extensions. */<br>
extra_extensions = calloc(ALIGN(strlen(env_const) + 2, 4), sizeof(char));<br>
- cant_disable_extensions = calloc(ALIGN(strlen(env_const) + 2, 4), sizeof(char));<br>
<br>
/* Copy env_const because strtok() is destructive. */<br>
env = strdup(env_const);<br>
<br>
if (env == NULL ||<br>
- extra_extensions == NULL ||<br>
- cant_disable_extensions == NULL) {<br>
+ extra_extensions == NULL) {<br>
free(env);<br>
free(extra_extensions);<br>
- free(cant_disable_extensions);<br>
return;<br>
}<br>
<br>
for (ext = strtok(env, " "); ext != NULL; ext = strtok(NULL, " ")) {<br>
int enable;<br>
+ int i;<br>
bool recognized;<br>
switch (ext[0]) {<br>
case '+':<br>
@@ -326,7 +317,8 @@ _mesa_one_time_init_extension_overrides(void)<br>
break;<br>
}<br>
<br>
- offset = set_extension(&_mesa_extension_override_enables, ext, enable);<br>
+ i = name_to_index(ext);<br>
+ offset = set_extension(&_mesa_extension_override_enables, i, enable);<br>
if (offset != 0 && (offset != o(dummy_true) || enable != GL_FALSE)) {<br>
((GLboolean *) &_mesa_extension_override_disables)[offset] = !enable;<br>
recognized = true;<br>
@@ -334,14 +326,12 @@ _mesa_one_time_init_extension_overrides(void)<br>
recognized = false;<br>
}<br>
<br>
- if (!recognized) {<br>
- if (enable) {<br>
- strcat(extra_extensions, ext);<br>
- strcat(extra_extensions, " ");<br>
- } else if (offset == o(dummy_true)) {<br>
- strcat(cant_disable_extensions, ext);<br>
- strcat(cant_disable_extensions, " ");<br>
- }<br>
+ if (i >= 0)<br>
+ disabled_extensions[i] = !enable;<br>
+<br>
+ if (!recognized && enable) {<br>
+ strcat(extra_extensions, ext);<br>
+ strcat(extra_extensions, " ");<br>
}<br>
}<br>
<br>
@@ -355,13 +345,6 @@ _mesa_one_time_init_extension_overrides(void)<br>
} else if (extra_extensions[len - 1] == ' ') {<br>
extra_extensions[len - 1] = '\0';<br>
}<br>
- len = strlen(cant_disable_extensions);<br>
- if (len == 0) {<br>
- free(cant_disable_extensions);<br>
- cant_disable_extensions = NULL;<br>
- } else if (cant_disable_extensions[len - 1] == ' ') {<br>
- cant_disable_extensions[len - 1] = '\0';<br>
- }<br>
}<br>
<br>
<br>
@@ -402,7 +385,8 @@ _mesa_extension_supported(const struct gl_context *ctx, extension_index i)<br>
const bool *base = (bool *) &ctx->Extensions;<br>
const struct mesa_extension *ext = _mesa_extension_table + i;<br>
<br>
- return (ctx->Version >= ext->version[ctx->API]) && base[ext->offset];<br>
+ return !disabled_extensions[i] &&<br>
+ (ctx->Version >= ext->version[ctx->API]) && base[ext->offset];<br>
}<br>
<br>
/**<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.6.2<br>
<br>
</font></span></div><br></div>