glsl: Make use of new _mesa_glsl_parse_state::is_version() function.
authorPaul Berry <stereotype441@gmail.com>
Wed, 1 Aug 2012 21:50:05 +0000 (14:50 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 6 Dec 2012 20:13:21 +0000 (12:13 -0800)
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
src/glsl/ast_function.cpp
src/glsl/ast_to_hir.cpp
src/glsl/glsl_lexer.ll
src/glsl/glsl_parser.yy
src/glsl/glsl_types.cpp

index c0e05ad8589bf2a69621da058b733d1c34b214a2..5e1c8918b17dc0a2050cbad944a1e8a51489abee 100644 (file)
@@ -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;
index adada30509eef6856159c9401d06677405c68140..79e4be8dcf1713baded1d17903d3e8a5791eb01a 100644 (file)
@@ -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 "
index c538d7d8e309c23a0450fc7eaa41a9ab88950f7c..d2c8c317454578f34ab15bfbd82d161cd28b77b5 100644 (file)
@@ -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
index e68a601c89e5fd06c5a097dc4794bd1cc31258a1..3b4d84b6e6d6f3875afa4a887718b780606ceba7 100644 (file)
@@ -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;
index 3940a12a5cdef10a9e1d16a912f439c0c35744fc..9edb7124cc2260981de7eb7f27aea78256addb49 100644 (file)
@@ -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);