summaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_parser.yy
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2012-07-31 01:28:35 -0700
committerKenneth Graunke <[email protected]>2012-07-31 11:20:49 -0700
commit3a90dc22d1c74e8719c95221f15043e7f3e69286 (patch)
tree3a66c55e5bf8102b2da179f82b0891e7b329f030 /src/glsl/glsl_parser.yy
parent19bd5936af7278c0cce0728e8d6dec1a951eaf58 (diff)
glsl: Refactor #version validation to be more future-proof.
The previous implementation required a flag in _mesa_glsl_parse_state and line of code to initialize it for every version of the shading language we intend to support. As we look to add 150, 330, 400, 410, 420, and beyond, this gets rather unwieldy. This patch retains the switch statement (to reject, say, #version 111), but removes all the bits. Code to check for ctx->API == API_OPENGL_CORE could easily be added to the 110 and 120 cases to reject those. v2: Use _mesa_is_desktop_gl to preserve the existing behavior in the presence of the new API_OPENGL_CORE enumeration. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> [v1]
Diffstat (limited to 'src/glsl/glsl_parser.yy')
-rw-r--r--src/glsl/glsl_parser.yy23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 98739340d63..d44ec50e124 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -29,6 +29,7 @@
#include "ast.h"
#include "glsl_parser_extras.h"
#include "glsl_types.h"
+#include "main/context.h"
#define YYLEX_PARAM state->scanner
@@ -259,19 +260,25 @@ version_statement:
switch ($2) {
case 100:
state->es_shader = true;
- supported = state->Const.GLSL_100ES;
+ supported = state->ctx->API == API_OPENGLES2 ||
+ state->ctx->Extensions.ARB_ES2_compatibility;
break;
case 110:
- supported = state->Const.GLSL_110;
- break;
case 120:
- supported = state->Const.GLSL_120;
- break;
+ /* FINISHME: 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.
+ */
case 130:
- supported = state->Const.GLSL_130;
- break;
case 140:
- supported = state->Const.GLSL_140;
+ case 150:
+ case 330:
+ case 400:
+ case 410:
+ case 420:
+ supported = _mesa_is_desktop_gl(state->ctx) &&
+ ((unsigned) $2) <= state->ctx->Const.GLSLVersion;
break;
default:
supported = false;