diff options
author | Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> | 2021-10-12 11:53:28 +0200 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2021-11-04 14:16:55 +0000 |
commit | f5dc334b6dd117b30b72ddb2f09ed60171dbb980 (patch) | |
tree | d36e0df10731bd22936898bd99d93c628de61775 | |
parent | 50c983402e5e81861a728009feddcc4ec43f8cea (diff) |
drirc: add mesa_extension_override option
This allows specific per-application override.
The existing MESA_EXTENSION_OVERRIDE env variable is kept.
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13364>
-rw-r--r-- | docs/envvars.rst | 3 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipe-loader/driinfo_gallium.h | 1 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_driconf.c | 1 | ||||
-rw-r--r-- | src/gallium/frontends/dri/dri_screen.c | 1 | ||||
-rw-r--r-- | src/gallium/frontends/wgl/stw_device.c | 1 | ||||
-rw-r--r-- | src/gallium/include/frontend/api.h | 1 | ||||
-rw-r--r-- | src/mesa/main/context.c | 19 | ||||
-rw-r--r-- | src/mesa/main/context.h | 2 | ||||
-rw-r--r-- | src/mesa/main/extensions.c | 13 | ||||
-rw-r--r-- | src/mesa/main/extensions.h | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_manager.c | 2 | ||||
-rw-r--r-- | src/util/driconf.h | 4 |
12 files changed, 34 insertions, 16 deletions
diff --git a/docs/envvars.rst b/docs/envvars.rst index d3321fd4556..1310ba3ee0b 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -78,7 +78,8 @@ Core Mesa environment variables :envvar:`MESA_EXTENSION_OVERRIDE` can be used to enable/disable extensions. A value such as ``GL_EXT_foo -GL_EXT_bar`` will enable the ``GL_EXT_foo`` extension - and disable the ``GL_EXT_bar`` extension. + and disable the ``GL_EXT_bar`` extension. Note that this will override + extensions override configured using driconf. :envvar:`MESA_EXTENSION_MAX_YEAR` The ``GL_EXTENSIONS`` string returned by Mesa is sorted by extension year. If this variable is set to year X, only extensions defined on diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h index e3bf517b6d5..90dd6c714b6 100644 --- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h +++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h @@ -41,6 +41,7 @@ DRI_CONF_SECTION_DEBUG DRI_CONF_FORCE_GL_RENDERER() DRI_CONF_OVERRIDE_VRAM_SIZE() DRI_CONF_GLX_EXTENSION_OVERRIDE() + DRI_CONF_MESA_EXTENSION_OVERRIDE() DRI_CONF_INDIRECT_GL_EXTENSION_OVERRIDE() DRI_CONF_DISABLE_PROTECTED_CONTENT_CHECK(false) DRI_CONF_IGNORE_MAP_UNSYNCHRONIZED(false) diff --git a/src/gallium/auxiliary/util/u_driconf.c b/src/gallium/auxiliary/util/u_driconf.c index 78667b84a14..cf87e5acdbf 100644 --- a/src/gallium/auxiliary/util/u_driconf.c +++ b/src/gallium/auxiliary/util/u_driconf.c @@ -66,6 +66,7 @@ u_driconf_fill_st_options(struct st_config_options *options, query_bool_option(transcode_astc); query_string_option(force_gl_vendor); query_string_option(force_gl_renderer); + query_string_option(mesa_extension_override); driComputeOptionsSha1(optionCache, options->config_options_sha1); } diff --git a/src/gallium/frontends/dri/dri_screen.c b/src/gallium/frontends/dri/dri_screen.c index ea7f7996be5..e68a8c19eec 100644 --- a/src/gallium/frontends/dri/dri_screen.c +++ b/src/gallium/frontends/dri/dri_screen.c @@ -510,6 +510,7 @@ dri_destroy_screen(__DRIscreen * sPriv) free(screen->options.force_gl_vendor); free(screen->options.force_gl_renderer); + free(screen->options.mesa_extension_override); /* The caller in dri_util preserves the fd ownership */ free(screen); diff --git a/src/gallium/frontends/wgl/stw_device.c b/src/gallium/frontends/wgl/stw_device.c index 8ffe752570c..52acb9e5c63 100644 --- a/src/gallium/frontends/wgl/stw_device.c +++ b/src/gallium/frontends/wgl/stw_device.c @@ -231,6 +231,7 @@ stw_cleanup(void) free(stw_dev->st_options.force_gl_vendor); free(stw_dev->st_options.force_gl_renderer); + free(stw_dev->st_options.mesa_extension_override); driDestroyOptionCache(&stw_dev->option_cache); driDestroyOptionInfo(&stw_dev->option_info); diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h index cde853f3334..66a03b24d43 100644 --- a/src/gallium/include/frontend/api.h +++ b/src/gallium/include/frontend/api.h @@ -243,6 +243,7 @@ struct st_config_options bool transcode_astc; char *force_gl_vendor; char *force_gl_renderer; + char *mesa_extension_override; unsigned char config_options_sha1[20]; }; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index ef70090ea99..e75b22d51c7 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -268,7 +268,7 @@ one_time_fini(void) */ static void -one_time_init(void) +one_time_init(const char *extensions_override) { GLuint i; @@ -281,7 +281,16 @@ one_time_init(void) _mesa_locale_init(); - _mesa_one_time_init_extension_overrides(); + const char *env_const = os_get_option("MESA_EXTENSION_OVERRIDE"); + if (env_const) { + if (extensions_override && + strcmp(extensions_override, env_const)) { + printf("Warning: MESA_EXTENSION_OVERRIDE used instead of driconf setting\n"); + } + extensions_override = env_const; + } + + _mesa_one_time_init_extension_overrides(extensions_override); _mesa_get_cpu_features(); @@ -327,13 +336,13 @@ static void init_lock(void) { * defined. */ void -_mesa_initialize(void) +_mesa_initialize(const char *extensions_override) { call_once(&init_once, init_lock); mtx_lock(&init_once_lock); if (!init_done) { - one_time_init(); + one_time_init(extensions_override); init_done = true; } mtx_unlock(&init_once_lock); @@ -1120,7 +1129,7 @@ _mesa_initialize_context(struct gl_context *ctx, _mesa_override_gl_version(ctx); /* misc one-time initializations */ - _mesa_initialize(); + _mesa_initialize(NULL); /* Plug in driver functions and context pointer here. * This is important because when we call alloc_shared_state() below diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 0f064d83ca6..2b8799fd9c5 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -90,7 +90,7 @@ _mesa_initialize_visual( struct gl_config *v, /*@{*/ extern void -_mesa_initialize(void); +_mesa_initialize(const char *extensions_override); extern GLboolean _mesa_initialize_context( struct gl_context *ctx, diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 27f37f73713..613fd3d6c7f 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -223,11 +223,11 @@ free_unknown_extensions_strings(void) /** - * \brief Initialize extension override tables based on \c MESA_EXTENSION_OVERRIDE + * \brief Initialize extension override tables based on \c override * * This should be called one time early during first context initialization. - * \c MESA_EXTENSION_OVERRIDE is a space-separated list of extensions to + * \c override is a space-separated list of extensions to * enable or disable. The list is processed thus: * - Enable recognized extension names that are prefixed with '+'. * - Disable recognized extension names that are prefixed with '-'. @@ -235,9 +235,8 @@ free_unknown_extensions_strings(void) * - Collect unrecognized extension names in a new string. */ void -_mesa_one_time_init_extension_overrides(void) +_mesa_one_time_init_extension_overrides(const char *override) { - const char *env_const = os_get_option("MESA_EXTENSION_OVERRIDE"); char *env; char *ext; size_t offset; @@ -246,12 +245,12 @@ _mesa_one_time_init_extension_overrides(void) memset(&_mesa_extension_override_enables, 0, sizeof(struct gl_extensions)); memset(&_mesa_extension_override_disables, 0, sizeof(struct gl_extensions)); - if (env_const == NULL) { + if (override == NULL || override[0] == '\0') { return; } - /* Copy env_const because strtok() is destructive. */ - env = strdup(env_const); + /* Copy 'override' because strtok() is destructive. */ + env = strdup(override); if (env == NULL) return; diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h index 303929baabc..cb5b48afcd3 100644 --- a/src/mesa/main/extensions.h +++ b/src/mesa/main/extensions.h @@ -47,7 +47,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(const char *override); extern void _mesa_init_extensions(struct gl_extensions *extentions); diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index aed501e3705..672d60a206d 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -903,7 +903,7 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi, return NULL; } - _mesa_initialize(); + _mesa_initialize(attribs->options.mesa_extension_override); /* Create a hash table for the framebuffer interface objects * if it has not been created for this st manager. diff --git a/src/util/driconf.h b/src/util/driconf.h index c514bd93f02..5f37f657ead 100644 --- a/src/util/driconf.h +++ b/src/util/driconf.h @@ -251,6 +251,10 @@ #define DRI_CONF_TRANSCODE_ASTC(def) \ DRI_CONF_OPT_B(transcode_astc, def, "Transcode ASTC formats to DXTC if unsupported") +#define DRI_CONF_MESA_EXTENSION_OVERRIDE() \ + DRI_CONF_OPT_S_NODEF(mesa_extension_override, \ + "Allow enabling/disabling a list of extensions") + #define DRI_CONF_GLX_EXTENSION_OVERRIDE() \ DRI_CONF_OPT_S_NODEF(glx_extension_override, \ "Allow enabling/disabling a list of GLX extensions") |