When both MESA_EXTENSION_OVERRIDE and drirc's mesa_extension_override are set, the environment variable takes precedence.
We also now perform one_time_init after init_attrib_groups so as the shared option would be initialized before running the extension override code. v2: - change the name from mesa_extension_override to extension_override - make the presence of the environment variable enough to disable the drirc-provided version - init all the constants in i915 before calling _mesa_initialize_context - make GLchar *ExtensionOverride in struct gl_constants constant v3: - reworked to use the new shared options infrastructure Signed-off-by: Martin Peres <martin.pe...@linux.intel.com> --- src/mesa/drivers/dri/common/xmlpool.h | 3 ++- src/mesa/drivers/dri/common/xmlpool/t_options.h | 5 +++++ src/mesa/main/context.c | 8 ++++---- src/mesa/main/extensions.c | 6 +++++- src/mesa/main/extensions.h | 2 +- src/mesa/main/shared_options.c | 3 +++ src/mesa/main/shared_options.h | 6 ++++++ 7 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/common/xmlpool.h b/src/mesa/drivers/dri/common/xmlpool.h index b2480d6..f14377f 100644 --- a/src/mesa/drivers/dri/common/xmlpool.h +++ b/src/mesa/drivers/dri/common/xmlpool.h @@ -112,7 +112,8 @@ DRI_CONF_FORCE_GLSL_EXTENSIONS_WARN("false") \ DRI_CONF_FORCE_GLSL_VERSION(0) \ DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER("false") \ - DRI_CONF_DISABLE_GLSL_LINE_CONTINUATIONS("false") + DRI_CONF_DISABLE_GLSL_LINE_CONTINUATIONS("false") \ + DRI_CONF_EXTENSION_OVERRIDE() #define DRI_CONF_SECTION_MISC_SHARED \ "<!-- No shared msic options yet -->\n" diff --git a/src/mesa/drivers/dri/common/xmlpool/t_options.h b/src/mesa/drivers/dri/common/xmlpool/t_options.h index 4e5a721..a836a34 100644 --- a/src/mesa/drivers/dri/common/xmlpool/t_options.h +++ b/src/mesa/drivers/dri/common/xmlpool/t_options.h @@ -110,6 +110,11 @@ DRI_CONF_OPT_BEGIN_B(allow_glsl_extension_directive_midshader, def) \ DRI_CONF_DESC(en,gettext("Allow GLSL #extension directives in the middle of shaders")) \ DRI_CONF_OPT_END +#define DRI_CONF_EXTENSION_OVERRIDE(def) \ +DRI_CONF_OPT_BEGIN(extension_override, string, def) \ + DRI_CONF_DESC(en,gettext("Allow enabling/disabling a list of GL extensions")) \ +DRI_CONF_OPT_END + /** diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index facc92b..197785d 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -399,7 +399,7 @@ one_time_init( struct gl_context *ctx ) assert( sizeof(GLint) == 4 ); assert( sizeof(GLuint) == 4 ); - _mesa_one_time_init_extension_overrides(); + _mesa_one_time_init_extension_overrides(ctx); _mesa_get_cpu_features(); @@ -1177,9 +1177,6 @@ _mesa_initialize_context(struct gl_context *ctx, _mesa_override_gl_version(ctx); - /* misc one-time initializations */ - one_time_init(ctx); - /* Plug in driver functions and context pointer here. * This is important because when we call alloc_shared_state() below * we'll call ctx->Driver.NewTextureObject() to create the default @@ -1203,6 +1200,9 @@ _mesa_initialize_context(struct gl_context *ctx, if (!init_attrib_groups( ctx, shared_options )) goto fail; + /* misc one-time initializations */ + one_time_init(ctx); + /* setup the API dispatch tables with all nop functions */ ctx->OutsideBeginEnd = alloc_dispatch_table(); if (!ctx->OutsideBeginEnd) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index f9bf503..1d86fd7 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -603,7 +603,7 @@ free_unknown_extensions_strings(void) * This should be called one time early during first context initialization. */ void -_mesa_one_time_init_extension_overrides(void) +_mesa_one_time_init_extension_overrides( struct gl_context *ctx ) { const char *env_const = getenv("MESA_EXTENSION_OVERRIDE"); char *env; @@ -611,6 +611,10 @@ _mesa_one_time_init_extension_overrides(void) int len; size_t offset; + /* the environment variable takes precedence over drirc */ + if (!env_const) + env_const = ctx->Const.options.ExtensionOverride; + atexit(free_unknown_extensions_strings); memset(&_mesa_extension_override_enables, 0, sizeof(struct gl_extensions)); diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h index 595512a..e5e5748 100644 --- a/src/mesa/main/extensions.h +++ b/src/mesa/main/extensions.h @@ -43,7 +43,7 @@ struct gl_extensions; extern void _mesa_enable_sw_extensions(struct gl_context *ctx); -extern void _mesa_one_time_init_extension_overrides(void); +extern void _mesa_one_time_init_extension_overrides(struct gl_context *ctx); extern void _mesa_init_extensions(struct gl_extensions *extentions); diff --git a/src/mesa/main/shared_options.c b/src/mesa/main/shared_options.c index ca1dc33..6d6a1c1 100644 --- a/src/mesa/main/shared_options.c +++ b/src/mesa/main/shared_options.c @@ -35,6 +35,9 @@ _mesa_shared_options_fill(struct driOptionCache *optionCache, sharedOptions->DisableGLSLLineContinuations = driQueryOptionb(optionCache, "disable_glsl_line_continuations"); + sharedOptions->ExtensionOverride = + driQueryOptionstr(optionCache, "extension_override"); + sharedOptions->ForceGLSLExtensionsWarn = driQueryOptionb(optionCache, "force_glsl_extensions_warn"); diff --git a/src/mesa/main/shared_options.h b/src/mesa/main/shared_options.h index aab159d..a132fef 100644 --- a/src/mesa/main/shared_options.h +++ b/src/mesa/main/shared_options.h @@ -60,6 +60,11 @@ struct shared_options GLboolean DisableGLSLLineContinuations; /** + * Allow enabling/disabling a list of GL extension. + */ + const GLchar *ExtensionOverride; + + /** * Changes default GLSL extension behavior from "error" to "warn". It's out * of spec, but it can make some apps work that otherwise wouldn't. */ @@ -85,6 +90,7 @@ _mesa_shared_options_fill_defaults(struct shared_options *sharedOptions) { sharedOptions->AllowGLSLExtensionDirectiveMidShader = GL_FALSE; sharedOptions->DisableGLSLLineContinuations = GL_FALSE; + sharedOptions->ExtensionOverride = NULL; sharedOptions->ForceGLSLExtensionsWarn = GL_FALSE; sharedOptions->ForceGLSLVersion = 0; } -- 2.4.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev