diff options
author | Kenneth Graunke <[email protected]> | 2012-07-31 01:28:35 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2012-07-31 11:20:49 -0700 |
commit | 3a90dc22d1c74e8719c95221f15043e7f3e69286 (patch) | |
tree | 3a66c55e5bf8102b2da179f82b0891e7b329f030 /src/glsl/glsl_parser_extras.cpp | |
parent | 19bd5936af7278c0cce0728e8d6dec1a951eaf58 (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_extras.cpp')
-rw-r--r-- | src/glsl/glsl_parser_extras.cpp | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 7a9b22197f0..4e1f3324011 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -85,23 +85,11 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, 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; - bool is_desktop_gl = _mesa_is_desktop_gl(ctx); - this->Const.GLSL_110 = is_desktop_gl; - this->Const.GLSL_120 = is_desktop_gl && (ctx->Const.GLSLVersion >= 120); - this->Const.GLSL_130 = is_desktop_gl && (ctx->Const.GLSLVersion >= 130); - this->Const.GLSL_140 = is_desktop_gl && (ctx->Const.GLSLVersion >= 140); - const unsigned lowest_version = (ctx->API == API_OPENGLES2) || ctx->Extensions.ARB_ES2_compatibility ? 100 : 110; const unsigned highest_version = - is_desktop_gl ? ctx->Const.GLSLVersion : 100; + _mesa_is_desktop_gl(ctx) ? ctx->Const.GLSLVersion : 100; char *supported = ralloc_strdup(this, ""); for (unsigned ver = lowest_version; ver <= highest_version; ver += 10) { |