From ba8a347f932f966422a5e156e54e8d05b664cf44 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Mon, 6 Nov 2017 15:20:35 +0000 Subject: [PATCH] mesa: split extensions overrides and glGetString(GL_EXTENSIONS) Currently we apply the extension overrides and construct the extensions string upon MakeCurrent. They are two distinct things, so let's slit the two while pushing the overrides management _before_ _mesa_compute_version(). This ensures that the version is updated to reflect the enabled/disabled extensions. Cc: Jordan Justen Signed-off-by: Emil Velikov Reviewed-by: Brian Paul --- src/mesa/drivers/dri/i915/i830_context.c | 1 + src/mesa/drivers/dri/i915/i915_context.c | 1 + src/mesa/drivers/dri/i965/brw_context.c | 1 + src/mesa/drivers/dri/r200/r200_context.c | 1 + src/mesa/drivers/dri/radeon/radeon_context.c | 1 + src/mesa/drivers/dri/swrast/swrast.c | 1 + src/mesa/drivers/osmesa/osmesa.c | 1 + src/mesa/drivers/x11/xm_api.c | 1 + src/mesa/main/extensions.c | 32 ++++++++------------ src/mesa/main/extensions.h | 2 ++ src/mesa/main/tests/dispatch_sanity.cpp | 1 + src/mesa/state_tracker/st_context.c | 1 + 12 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/mesa/drivers/dri/i915/i830_context.c b/src/mesa/drivers/dri/i915/i830_context.c index 299e54d50eb..4aa96cad0f8 100644 --- a/src/mesa/drivers/dri/i915/i830_context.c +++ b/src/mesa/drivers/dri/i915/i830_context.c @@ -124,6 +124,7 @@ i830CreateContext(int api, _tnl_allow_vertex_fog(ctx, 1); _tnl_allow_pixel_fog(ctx, 0); + _mesa_override_extensions(ctx); _mesa_compute_version(ctx); _mesa_initialize_dispatch_tables(ctx); diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c index 4f6bdb74e7c..e40e358281a 100644 --- a/src/mesa/drivers/dri/i915/i915_context.c +++ b/src/mesa/drivers/dri/i915/i915_context.c @@ -289,6 +289,7 @@ i915CreateContext(int api, _tnl_allow_vertex_fog(ctx, 0); _tnl_allow_pixel_fog(ctx, 1); + _mesa_override_extensions(ctx); _mesa_compute_version(ctx); _mesa_initialize_dispatch_tables(ctx); diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index f49ac4480af..dd55b436698 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -1051,6 +1051,7 @@ brwCreateContext(gl_api api, if (INTEL_DEBUG & DEBUG_SHADER_TIME) brw_init_shader_time(brw); + _mesa_override_extensions(ctx); _mesa_compute_version(ctx); _mesa_initialize_dispatch_tables(ctx); diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index edd433ae97e..eb7d92f3c60 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -394,6 +394,7 @@ GLboolean r200CreateContext( gl_api api, TCL_FALLBACK(&rmesa->radeon.glCtx, R200_TCL_FALLBACK_TCL_DISABLE, 1); } + _mesa_override_extensions(ctx); _mesa_compute_version(ctx); /* Exec table initialization requires the version to be computed */ diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index 04c76cdba1d..8ad0911586c 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -353,6 +353,7 @@ r100CreateContext( gl_api api, /* _tnl_need_dlist_norm_lengths( ctx, GL_FALSE ); */ } + _mesa_override_extensions(ctx); _mesa_compute_version(ctx); /* Exec table initialization requires the version to be computed */ diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index f9bd1b9d560..4bee01ad308 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -817,6 +817,7 @@ dri_create_context(gl_api api, _mesa_meta_init(mesaCtx); _mesa_enable_sw_extensions(mesaCtx); + _mesa_override_extensions(mesaCtx); _mesa_compute_version(mesaCtx); _mesa_initialize_dispatch_tables(mesaCtx); diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 72bff3da2c6..1df3da4cd24 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -913,6 +913,7 @@ OSMesaCreateContextAttribs(const int *attribList, OSMesaContext sharelist) swrast->choose_line = osmesa_choose_line; swrast->choose_triangle = osmesa_choose_triangle; + _mesa_override_extensions(ctx); _mesa_compute_version(ctx); if (ctx->Version < version_major * 10 + version_minor) { diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index a0695c3d87c..ec2a73cb369 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -957,6 +957,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) _mesa_meta_init(mesaCtx); + _mesa_override_extensions(mesaCtx); _mesa_compute_version(mesaCtx); /* Exec table initialization requires the version to be computed */ diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index f185aa5aab5..13a72b111d5 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -78,8 +78,8 @@ name_to_index(const char* name) * Overrides extensions in \c ctx based on the values in * _mesa_extension_override_enables and _mesa_extension_override_disables. */ -static void -override_extensions_in_context(struct gl_context *ctx) +void +_mesa_override_extensions(struct gl_context *ctx) { unsigned i; const GLboolean *enables = @@ -199,27 +199,12 @@ set_extension(struct gl_extensions *ext, int i, GLboolean state) } /** - * \brief Apply the \c MESA_EXTENSION_OVERRIDE environment variable. - * - * \c MESA_EXTENSION_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 '-'. - * - Enable recognized extension names that are not prefixed. - * - Collect unrecognized extension names in a new string. - * - * \c MESA_EXTENSION_OVERRIDE was previously parsed during - * _mesa_one_time_init_extension_overrides. We just use the results of that - * parsing in this function. - * - * \return Space-separated list of unrecognized extension names (which must - * be freed). Does not return \c NULL. + * The unrecognized extensions from \c MESA_EXTENSION_OVERRIDE. + * Must be freed, does not return \c NULL. */ static char * get_extension_override( struct gl_context *ctx ) { - override_extensions_in_context(ctx); - if (extra_extensions == NULL) { return calloc(1, sizeof(char)); } else { @@ -244,9 +229,16 @@ free_unknown_extensions_strings(void) /** - * \brief Initialize extension override tables. + * \brief Initialize extension override tables based on \c MESA_EXTENSION_OVERRIDE * * This should be called one time early during first context initialization. + + * \c MESA_EXTENSION_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 '-'. + * - Enable recognized extension names that are not prefixed. + * - Collect unrecognized extension names in a new string. */ void _mesa_one_time_init_extension_overrides(void) diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h index efef1be4751..ebed8fa4fc0 100644 --- a/src/mesa/main/extensions.h +++ b/src/mesa/main/extensions.h @@ -53,6 +53,8 @@ extern void _mesa_init_extensions(struct gl_extensions *extentions); extern GLubyte *_mesa_make_extension_string(struct gl_context *ctx); +extern void _mesa_override_extensions(struct gl_context *ctx); + extern GLuint _mesa_get_extension_count(struct gl_context *ctx); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index d7183de0f1a..ae46419ec48 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -112,6 +112,7 @@ DispatchSanity_test::SetUpCtx(gl_api api, unsigned int version) &driver_functions); _vbo_CreateContext(&ctx); + _mesa_override_extensions(&ctx); ctx.Version = version; _mesa_initialize_dispatch_tables(&ctx); diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index eae294e3eb2..da1cca471ba 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -536,6 +536,7 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, st->bitmap.cache.empty = true; + _mesa_override_extensions(ctx); _mesa_compute_version(ctx); if (ctx->Version == 0) { -- 2.30.2