[Mesa-dev] [PATCH 13/16] driconf: introduce the equivalent of MESA_GL_VERSION_OVERRIDE in drirc

Martin Peres martin.peres at linux.intel.com
Fri Jun 5 06:04:07 PDT 2015


When both MESA_GL_VERSION_OVERRIDE and drirc's mesa_extension_override are
set, the environment variable takes precedence.

As DRI2 also needs to have this parameter, let's add the option in
dri2's optionCache and read the gl_version_override parameter before
passing it to _mesa_override_gl_version_contextless().

Signed-off-by: Martin Peres <martin.peres at linux.intel.com>
---
 src/mesa/drivers/dri/common/dri_util.c          | 14 ++++++++++----
 src/mesa/drivers/dri/common/xmlpool.h           |  3 ++-
 src/mesa/drivers/dri/common/xmlpool/t_options.h |  4 ++++
 src/mesa/main/shared_options.c                  |  3 +++
 src/mesa/main/shared_options.h                  |  6 ++++++
 src/mesa/main/version.c                         | 13 +++++++++----
 src/mesa/state_tracker/st_manager.c             |  4 +++-
 7 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index e7ababe..8b40441 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -57,6 +57,10 @@ const char __dri2ConfigOptions[] =
       DRI_CONF_SECTION_PERFORMANCE
          DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1)
       DRI_CONF_SECTION_END
+
+      DRI_CONF_SECTION_DEBUG
+         DRI_CONF_GL_VERSION_OVERRIDE()
+      DRI_CONF_SECTION_END
    DRI_CONF_END;
 
 /*****************************************************************/
@@ -166,6 +170,12 @@ driCreateNewScreen2(int scrn, int fd,
     gl_api api;
     unsigned version;
 
+    /* Init the gl constants with the gl version override value */
+    driParseOptionInfo(&psp->optionInfo, __dri2ConfigOptions);
+    driParseConfigFiles(&psp->optionCache, &psp->optionInfo, psp->myNum, "dri2");
+    consts.options.GLVersionOverride = driQueryOptionstr(&psp->optionCache,
+                                                         "gl_version_override");
+
     api = API_OPENGLES2;
     if (_mesa_override_gl_version_contextless(&consts, &api, &version))
        psp->max_gl_es2_version = version;
@@ -189,10 +199,6 @@ driCreateNewScreen2(int scrn, int fd,
     if (psp->max_gl_es2_version >= 30)
        psp->api_mask |= (1 << __DRI_API_GLES3);
 
-    driParseOptionInfo(&psp->optionInfo, __dri2ConfigOptions);
-    driParseConfigFiles(&psp->optionCache, &psp->optionInfo, psp->myNum, "dri2");
-
-
     return psp;
 }
 
diff --git a/src/mesa/drivers/dri/common/xmlpool.h b/src/mesa/drivers/dri/common/xmlpool.h
index 7503060..98e346f 100644
--- a/src/mesa/drivers/dri/common/xmlpool.h
+++ b/src/mesa/drivers/dri/common/xmlpool.h
@@ -115,7 +115,8 @@
    DRI_CONF_DISABLE_GLSL_LINE_CONTINUATIONS("false") \
    DRI_CONF_EXTENSION_OVERRIDE() \
    DRI_CONF_DISABLE_BLEND_FUNC_EXTENDED("false") \
-   DRI_CONF_DISABLE_SHADER_BIT_ENCODING("false")
+   DRI_CONF_DISABLE_SHADER_BIT_ENCODING("false") \
+   DRI_CONF_GL_VERSION_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 a836a34..f5689ef 100644
--- a/src/mesa/drivers/dri/common/xmlpool/t_options.h
+++ b/src/mesa/drivers/dri/common/xmlpool/t_options.h
@@ -115,6 +115,10 @@ 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
 
+#define DRI_CONF_GL_VERSION_OVERRIDE(def) \
+DRI_CONF_OPT_BEGIN(gl_version_override, string, def) \
+        DRI_CONF_DESC(en,gettext("Force a GL version")) \
+DRI_CONF_OPT_END
 
 
 /**
diff --git a/src/mesa/main/shared_options.c b/src/mesa/main/shared_options.c
index 7a5fe1d..5a90523 100644
--- a/src/mesa/main/shared_options.c
+++ b/src/mesa/main/shared_options.c
@@ -49,4 +49,7 @@ _mesa_shared_options_fill(struct driOptionCache *optionCache,
 
    sharedOptions->ForceGLSLVersion =
       driQueryOptioni(optionCache, "force_glsl_version");
+
+   sharedOptions->GLVersionOverride =
+         driQueryOptionstr(optionCache, "gl_version_override");
 }
diff --git a/src/mesa/main/shared_options.h b/src/mesa/main/shared_options.h
index 33c4dea..7a395ab 100644
--- a/src/mesa/main/shared_options.h
+++ b/src/mesa/main/shared_options.h
@@ -86,6 +86,11 @@ struct shared_options
     */
    GLuint ForceGLSLVersion;
 
+   /**
+    * If non-NULL, overrides the GL version.
+    */
+   const GLchar * GLVersionOverride;
+
    /* misc */
 };
 
@@ -105,6 +110,7 @@ _mesa_shared_options_fill_defaults(struct shared_options *sharedOptions)
    sharedOptions->ExtensionOverride = NULL;
    sharedOptions->ForceGLSLExtensionsWarn = GL_FALSE;
    sharedOptions->ForceGLSLVersion = 0;
+   sharedOptions->GLVersionOverride = NULL;
 }
 
 #ifdef __cplusplus
diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index 409e5ae..3912a18 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -51,8 +51,8 @@ check_for_ending(const char *string, const char *ending)
  * fwd_context is only valid if version > 0
  */
 static void
-get_gl_override(gl_api api, int *version, bool *fwd_context,
-                bool *compat_context)
+get_gl_override(gl_api api, const char *gl_version_override_str,
+                int *version, bool *fwd_context, bool *compat_context)
 {
    const char *env_var = (api == API_OPENGL_CORE || api == API_OPENGL_COMPAT)
       ? "MESA_GL_VERSION_OVERRIDE" : "MESA_GLES_VERSION_OVERRIDE";
@@ -69,7 +69,11 @@ get_gl_override(gl_api api, int *version, bool *fwd_context,
       override_version = 0;
 
       version_str = getenv(env_var);
-      if (version_str) {
+
+      if (!version_str)
+         version_str = gl_version_override_str;
+
+      if (version_str && strlen(version_str) > 0) {
          fc_suffix = check_for_ending(version_str, "FC");
          compat_suffix = check_for_ending(version_str, "COMPAT");
 
@@ -140,7 +144,8 @@ _mesa_override_gl_version_contextless(struct gl_constants *consts,
    int version;
    bool fwd_context, compat_context;
 
-   get_gl_override(*apiOut, &version, &fwd_context, &compat_context);
+   get_gl_override(*apiOut, consts->options.GLVersionOverride, &version,
+                   &fwd_context, &compat_context);
 
    if (version > 0) {
       *versionOut = version;
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index ebdbb00..72460e4 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -924,11 +924,13 @@ static unsigned get_version(struct pipe_screen *screen,
    struct gl_extensions extensions = {0};
    GLuint version;
 
+   /* Init the gl constants with the gl version override value */
+   _mesa_init_constants(&consts, &options->shared_options, api);
+
    if (_mesa_override_gl_version_contextless(&consts, &api, &version)) {
       return version;
    }
 
-   _mesa_init_constants(&consts, &options->shared_options, api);
    _mesa_init_extensions(&extensions);
 
    st_init_limits(screen, &consts, &extensions);
-- 
2.4.2



More information about the mesa-dev mailing list