[Mesa-dev] [PATCH 03/13] mesa: split extensions overrides and glGetString(GL_EXTENSIONS)

Emil Velikov emil.l.velikov at gmail.com
Tue Nov 7 11:54:43 UTC 2017


From: Emil Velikov <emil.velikov at collabora.com>

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 <jordan.l.justen at intel.com>
Cc: Brian Paul <brianp at vmware.com>
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 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 3947a71a46a..1594545be5e 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -1050,6 +1050,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 8c511805b51..f22ebb4ca07 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 5d8dd8b97ef..cc7ef57c192 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -465,6 +465,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.14.1



More information about the mesa-dev mailing list