summaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_parser_extras.cpp
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2011-01-31 15:02:24 -0800
committerIan Romanick <[email protected]>2011-01-31 15:32:56 -0800
commit14880a510a1a288df0778395097d5a52806abfb0 (patch)
tree275eb4aa6bd212329277fb36838408a61a3d28f8 /src/glsl/glsl_parser_extras.cpp
parente5e34ab18eeaffa465094f6281dfe293b84376db (diff)
glsl: Reject shader versions not supported by the implementation
Previously we'd happily compile GLSL 1.30 shaders on any driver. We'd also happily compile GLSL 1.10 and 1.20 shaders in an ES2 context. This has been a long standing FINISHME in the compiler. NOTE: This is a candidate for the 7.9 and 7.10 branches
Diffstat (limited to 'src/glsl/glsl_parser_extras.cpp')
-rw-r--r--src/glsl/glsl_parser_extras.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 5a8a5248c03..2ed8b843a24 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -79,6 +79,38 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *ctx,
this->Const.MaxFragmentUniformComponents = ctx->Const.FragmentProgram.MaxUniformComponents;
this->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers;
+
+ /* Note: Once the OpenGL 3.0 'forward compatible' context or the OpenGL 3.2
+ * Core context is supported, this logic will need change. Older versions of
+ * GLSL are no longer supported outside the compatibility contexts of 3.x.
+ */
+ this->Const.GLSL_100ES = (ctx->API == API_OPENGLES2)
+ || ctx->Extensions.ARB_ES2_compatibility;
+ this->Const.GLSL_110 = (ctx->API == API_OPENGL);
+ this->Const.GLSL_120 = (ctx->API == API_OPENGL)
+ && (ctx->Const.GLSLVersion >= 120);
+ this->Const.GLSL_130 = (ctx->API == API_OPENGL)
+ && (ctx->Const.GLSLVersion >= 130);
+
+ const unsigned lowest_version =
+ (ctx->API == API_OPENGLES2) || ctx->Extensions.ARB_ES2_compatibility
+ ? 100 : 110;
+ const unsigned highest_version =
+ (ctx->API == API_OPENGL) ? ctx->Const.GLSLVersion : 100;
+ char *supported = (char *) ralloc_context(this);
+
+ for (unsigned ver = lowest_version; ver <= highest_version; ver += 10) {
+ const char *const prefix = (ver == lowest_version)
+ ? ""
+ : ((ver == highest_version) ? ", and " : ", ");
+
+ ralloc_asprintf_append(& supported, "%s%d.%02d%s",
+ prefix,
+ ver / 100, ver % 100,
+ (ver == 100) ? " ES" : "");
+ }
+
+ this->supported_version_string = supported;
}
const char *