summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2011-09-26 11:48:46 -0700
committerChad Versace <[email protected]>2011-09-27 11:23:17 -0700
commit0527c11d7aa42bd74f4527d7299e3c18f37c4c44 (patch)
tree70c481ba9bbb2ae69f884bcabe3e83756d72d2aa /src/mesa/main
parentb565e62a4499aad445bdbc0ba3a8bbc1c61e68ab (diff)
mesa: Allow override of GL version with environment variable
It is necessary to manually set the GL version to 3.0 in order to run Piglit tests that use glGetUniform*(). This patch allows one to override the version of the OpenGL context by setting the environment variable MESA_GL_VERSION_OVERRIDE. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/version.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index 384281479a3..a5deeabd2f1 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -27,7 +27,29 @@
#include "version.h"
#include "git_sha1.h"
+/**
+ * Override the context's GL version if the environment variable
+ * MESA_GL_VERSION_OVERRIDE is set. Valid values of MESA_GL_VERSION_OVERRIDE
+ * are point-separated version numbers, such as "3.0".
+ */
+static void
+override_version(struct gl_context *ctx, GLuint *major, GLuint *minor)
+{
+ const char *env_var = "MESA_GL_VERSION_OVERRIDE";
+ const char *version;
+ int n;
+
+ version = getenv(env_var);
+ if (!version) {
+ return;
+ }
+ n = sscanf(version, "%d.%d", major, minor);
+ if (n != 2) {
+ fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version);
+ return;
+ }
+}
/**
* Examine enabled GL extensions to determine GL version.
@@ -178,6 +200,9 @@ compute_version(struct gl_context *ctx)
ctx->VersionMajor = major;
ctx->VersionMinor = minor;
+
+ override_version(ctx, &ctx->VersionMajor, &ctx->VersionMinor);
+
ctx->VersionString = (char *) malloc(max);
if (ctx->VersionString) {
_mesa_snprintf(ctx->VersionString, max,