aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main')
-rw-r--r--mesalib/src/mesa/main/context.c1
-rw-r--r--mesalib/src/mesa/main/shaderapi.c1
-rw-r--r--mesalib/src/mesa/main/version.c26
-rw-r--r--mesalib/src/mesa/main/version.h2
4 files changed, 29 insertions, 1 deletions
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index b20063c33..2532c47de 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/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/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index 74997eaaa..3ce14d154 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -137,6 +137,7 @@ _mesa_sizeof_glsl_type(GLenum type)
switch (type) {
case GL_FLOAT:
case GL_INT:
+ case GL_UNSIGNED_INT:
case GL_BOOL:
case GL_SAMPLER_1D:
case GL_SAMPLER_2D:
diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c
index 3b5a78d1b..738b5cb61 100644
--- a/mesalib/src/mesa/main/version.c
+++ b/mesalib/src/mesa/main/version.c
@@ -44,7 +44,7 @@ override_version(struct gl_context *ctx, GLuint *major, GLuint *minor)
return;
}
- n = sscanf(version, "%d.%d", major, minor);
+ n = sscanf(version, "%u.%u", major, minor);
if (n != 2) {
fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version);
return;
@@ -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, "%u", &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/mesalib/src/mesa/main/version.h b/mesalib/src/mesa/main/version.h
index 0a0512c33..32e141f0e 100644
--- a/mesalib/src/mesa/main/version.h
+++ b/mesalib/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 */