[Mesa-dev] [PATCH 2/7] main/extensions: Create a context-less set_extensions function
Jordan Justen
jordan.l.justen at intel.com
Sun Jun 8 15:17:24 PDT 2014
We will add new gl_extensions structures that capture the environment
variable extension overrides and are available early in context
creation.
This will allow a driver to take actions during its initialization
based on the extension overrides.
Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
src/mesa/main/extensions.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index c141576..12f786b 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -473,10 +473,27 @@ _mesa_enable_sw_extensions(struct gl_context *ctx)
/**
* Either enable or disable the named extension.
+ * \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)
+{
+ size_t offset;
+
+ offset = name_to_offset(name);
+ if (offset != 0 && (offset != o(dummy_true) || state != GL_FALSE)) {
+ ((GLboolean *) ext)[offset] = state;
+ }
+
+ return offset;
+}
+
+/**
+ * Either enable or disable the named extension.
* \return GL_TRUE for success, GL_FALSE if invalid extension name
*/
static GLboolean
-set_extension( struct gl_context *ctx, const char *name, GLboolean state )
+set_ctx_extension(struct gl_context *ctx, const char *name, GLboolean state)
{
size_t offset;
@@ -487,7 +504,7 @@ set_extension( struct gl_context *ctx, const char *name, GLboolean state )
return GL_FALSE;
}
- offset = name_to_offset(name);
+ offset = set_extension(&ctx->Extensions, name, state);
if (offset == 0) {
_mesa_problem(ctx, "Trying to enable/disable unknown extension %s",
name);
@@ -497,8 +514,6 @@ set_extension( struct gl_context *ctx, const char *name, GLboolean state )
"%s", name);
return GL_FALSE;
} else {
- GLboolean *base = (GLboolean *) &ctx->Extensions;
- base[offset] = state;
return GL_TRUE;
}
}
@@ -552,7 +567,7 @@ get_extension_override( struct gl_context *ctx )
enable = 1;
break;
}
- recognized = set_extension(ctx, ext, enable);
+ recognized = set_ctx_extension(ctx, ext, enable);
if (!recognized && enable) {
strcat(extra_exts, ext);
strcat(extra_exts, " ");
--
2.0.0
More information about the mesa-dev
mailing list