From 8be64fb570b15be1f2daf3545b5e9c3299704914 Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Sat, 7 Jun 2014 20:12:20 -0700 Subject: [PATCH] main/extensions: Create a context-less set_extensions function 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 Reviewed-by: Anuj Phogat --- 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 822f8cd64e8..5de6625b88f 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -473,12 +473,29 @@ _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; @@ -489,7 +506,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); @@ -499,8 +516,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; } } @@ -554,7 +569,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.30.2