diff options
author | Paul Berry <stereotype441@gmail.com> | 2012-08-01 14:50:05 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2012-12-06 12:13:21 -0800 |
commit | e3ded7fe628d5a842f2fae0da355a4034cff27cf (patch) | |
tree | 9f844ea688b37f3a564609d9331fe6440960b471 | |
parent | 5d0fd3270f028cd93efa5301c998be034826a102 (diff) |
glsl: Make use of new _mesa_glsl_parse_state::is_version() function.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
-rw-r--r-- | src/glsl/ast_function.cpp | 2 | ||||
-rw-r--r-- | src/glsl/ast_to_hir.cpp | 40 | ||||
-rw-r--r-- | src/glsl/glsl_lexer.ll | 4 | ||||
-rw-r--r-- | src/glsl/glsl_parser.yy | 5 | ||||
-rw-r--r-- | src/glsl/glsl_types.cpp | 8 |
5 files changed, 33 insertions, 26 deletions
diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index c0e05ad8589..5e1c8918b17 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -277,7 +277,7 @@ generate_call(exec_list *instructions, ir_function_signature *sig, * * Function calls were first allowed to be constant expressions in GLSL 1.20. */ - if (state->language_version >= 120) { + if (state->is_version(120, 0)) { ir_constant *value = sig->constant_expression_value(actual_parameters, NULL); if (value != NULL) { return value; diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index adada30509e..79e4be8dcf1 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -121,7 +121,7 @@ apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from, /* This conversion was added in GLSL 1.20. If the compilation mode is * GLSL 1.10, the conversion is skipped. */ - if (state->language_version < 120) + if (!state->is_version(120, 0)) return false; /* From page 27 (page 33 of the PDF) of the GLSL 1.50 spec: @@ -1660,15 +1660,18 @@ ast_expression::hir(exec_list *instructions, array->type->element_type()->is_sampler() && const_index == NULL) { - if (state->language_version == 100) { - _mesa_glsl_warning(&loc, state, - "sampler arrays indexed with non-constant " - "expressions is optional in GLSL ES 1.00"); - } else if (state->language_version < 130) { - _mesa_glsl_warning(&loc, state, - "sampler arrays indexed with non-constant " - "expressions is forbidden in GLSL 1.30 and " - "later"); + if (!state->is_version(130, 100)) { + if (state->es_shader) { + _mesa_glsl_warning(&loc, state, + "sampler arrays indexed with non-constant " + "expressions is optional in %s", + state->get_version_string()); + } else { + _mesa_glsl_warning(&loc, state, + "sampler arrays indexed with non-constant " + "expressions will be forbidden in GLSL 1.30 and " + "later"); + } } else { _mesa_glsl_error(&loc, state, "sampler arrays indexed with non-constant " @@ -2288,7 +2291,7 @@ get_variable_being_redeclared(ir_variable *var, ast_declaration *decl, * * gl_Color * * gl_SecondaryColor */ - } else if (state->language_version >= 130 + } else if (state->is_version(130, 0) && (strcmp(var->name, "gl_FrontColor") == 0 || strcmp(var->name, "gl_BackColor") == 0 || strcmp(var->name, "gl_FrontSecondaryColor") == 0 @@ -2611,7 +2614,7 @@ ast_declarator_list::hir(exec_list *instructions, * This is relaxed in GLSL 1.30. It is also relaxed by any extension * that adds the 'layout' keyword. */ - if ((state->language_version < 130) + if (!state->is_version(130, 0) && !state->ARB_explicit_attrib_location_enable && !state->ARB_fragment_coord_conventions_enable) { if (this->type->qualifier.flags.q.out) { @@ -2712,7 +2715,7 @@ ast_declarator_list::hir(exec_list *instructions, break; case GLSL_TYPE_UINT: case GLSL_TYPE_INT: - if (state->language_version > 120) + if (state->is_version(120, 0)) break; /* FALLTHROUGH */ default: @@ -2741,7 +2744,7 @@ ast_declarator_list::hir(exec_list *instructions, * vector, then it must be qualified with the interpolation qualifier * flat." */ - if (state->language_version >= 130 + if (state->is_version(130, 0) && state->target == vertex_shader && state->current_function == NULL && var->type->is_integer() @@ -2761,7 +2764,7 @@ ast_declarator_list::hir(exec_list *instructions, * centroid in, out, or centroid out in a declaration. They do not apply * to the deprecated storage qualifiers varying or centroid varying." */ - if (state->language_version >= 130 + if (state->is_version(130, 0) && this->type->qualifier.has_interpolation() && this->type->qualifier.flags.q.varying) { @@ -2787,7 +2790,7 @@ ast_declarator_list::hir(exec_list *instructions, * shader (in) can be further qualified with one or more of these * interpolation qualifiers" */ - if (state->language_version >= 130 + if (state->is_version(130, 0) && this->type->qualifier.has_interpolation()) { const char *i = this->type->qualifier.interpolation_string(); @@ -2817,7 +2820,7 @@ ast_declarator_list::hir(exec_list *instructions, /* From section 4.3.4 of the GLSL 1.30 spec: * "It is an error to use centroid in in a vertex shader." */ - if (state->language_version >= 130 + if (state->is_version(130, 0) && this->type->qualifier.flags.q.centroid && this->type->qualifier.flags.q.in && state->target == vertex_shader) { @@ -3161,7 +3164,8 @@ ast_function::hir(exec_list *instructions, * * Note that this language does not appear in GLSL 1.10. */ - if ((state->current_function != NULL) && (state->language_version != 110)) { + if ((state->current_function != NULL) && + state->is_version(120, 100)) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(&loc, state, "declaration of function `%s' not allowed within " diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll index c538d7d8e30..d2c8c317454 100644 --- a/src/glsl/glsl_lexer.ll +++ b/src/glsl/glsl_lexer.ll @@ -103,7 +103,7 @@ literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state, if (value > UINT_MAX) { /* Note that signed 0xffffffff is valid, not out of range! */ - if (state->language_version >= 130) { + if (state->is_version(130, 0)) { _mesa_glsl_error(lloc, state, "Literal value `%s' out of range", text); } else { @@ -333,7 +333,7 @@ struct return STRUCT; void return VOID_TOK; layout { - if ((yyextra->language_version >= 140) + if ((yyextra->is_version(140, 0)) || yyextra->AMD_conservative_depth_enable || yyextra->ARB_conservative_depth_enable || yyextra->ARB_explicit_attrib_location_enable diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index e68a601c89e..3b4d84b6e6d 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -310,9 +310,10 @@ pragma_statement: | PRAGMA_OPTIMIZE_OFF EOL | PRAGMA_INVARIANT_ALL EOL { - if (state->language_version == 110) { + if (!state->is_version(120, 100)) { _mesa_glsl_warning(& @1, state, - "pragma `invariant(all)' not supported in %s", + "pragma `invariant(all)' not supported in %s " + "(GLSL ES 1.00 or GLSL 1.20 required).", state->get_version_string()); } else { state->all_invariant = true; diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 3940a12a5cd..9edb7124cc2 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -290,16 +290,18 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) } if (state->ARB_texture_rectangle_enable || - state->language_version >= 140) { + state->is_version(140, 0)) { glsl_type::generate_ARB_texture_rectangle_types(state->symbols, state->ARB_texture_rectangle_warn); } - if (state->OES_texture_3D_enable && state->language_version == 100) { + if (state->OES_texture_3D_enable + && state->is_version(0, 100)) { glsl_type::generate_OES_texture_3D_types(state->symbols, state->OES_texture_3D_warn); } - if (state->EXT_texture_array_enable && state->language_version < 130) { + if (state->EXT_texture_array_enable + && !state->is_version(130, 0)) { // These are already included in 130; don't create twice. glsl_type::generate_EXT_texture_array_types(state->symbols, state->EXT_texture_array_warn); |