summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2011-09-27 13:53:11 -0700
committerChad Versace <[email protected]>2011-09-28 11:29:52 -0700
commita1eff5570f5e3f893fe4d453aef5ce143712ab09 (patch)
tree603b8e0db9e686558f5fcab3a6365fa84a89e0f1 /src/mesa/main
parent124fc96ddf2695b4eca1a9b373f33cb993de9f6a (diff)
mesa: Allow overriding GLSL version with environment variable
Override the context's GLSL version if the environment variable MESA_GLSL_VERSION_OVERRIDE is set. Valid values for MESA_GLSL_VERSION_OVERRIDE are integers, such as "130". MESA_GLSL_VERSION_OVERRIDE has the same behavior as INTEL_GLSL_VERSION, except that it applies to all drivers, not just Intel's. Since the former supercedes the latter, this patch disables the latter. Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/context.c1
-rw-r--r--src/mesa/main/version.c24
-rw-r--r--src/mesa/main/version.h2
3 files changed, 27 insertions, 0 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index b20063c33b2..2532c47de15 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -627,6 +627,7 @@ _mesa_init_constants(struct gl_context *ctx)
/* Shading language version */
if (ctx->API == API_OPENGL) {
ctx->Const.GLSLVersion = 120;
+ _mesa_override_glsl_version(ctx);
}
else if (ctx->API == API_OPENGLES2) {
ctx->Const.GLSLVersion = 100;
diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index 00b423cd479..665b0e7ad28 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -52,6 +52,30 @@ override_version(struct gl_context *ctx, GLuint *major, GLuint *minor)
}
/**
+ * Override the context's GLSL version if the environment variable
+ * MESA_GLSL_VERSION_OVERRIDE is set. Valid values for
+ * MESA_GLSL_VERSION_OVERRIDE are integers, such as "130".
+ */
+void
+_mesa_override_glsl_version(struct gl_context *ctx)
+{
+ const char *env_var = "MESA_GLSL_VERSION_OVERRIDE";
+ const char *version;
+ int n;
+
+ version = getenv(env_var);
+ if (!version) {
+ return;
+ }
+
+ n = sscanf(version, "%d", &ctx->Const.GLSLVersion);
+ if (n != 1) {
+ fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version);
+ return;
+ }
+}
+
+/**
* Examine enabled GL extensions to determine GL version.
* Return major and minor version numbers.
*/
diff --git a/src/mesa/main/version.h b/src/mesa/main/version.h
index 0a0512c339d..32e141f0e0e 100644
--- a/src/mesa/main/version.h
+++ b/src/mesa/main/version.h
@@ -56,5 +56,7 @@ struct gl_context;
extern void
_mesa_compute_version(struct gl_context *ctx);
+extern void
+_mesa_override_glsl_version(struct gl_context *ctx);
#endif /* VERSION_H */