tree-wide: replace MAYBE_UNUSED with ASSERTED
[mesa.git] / src / compiler / glsl / ast_type.cpp
index 1adb1f4752ab4aa0dd0a6151aee45d0862037c5e..8026302f0acc8f9f932dd69d77ef41feee1a9a15 100644 (file)
@@ -44,7 +44,6 @@ ast_fully_specified_type::has_qualifiers(_mesa_glsl_parse_state *state) const
    ast_type_qualifier subroutine_only;
    subroutine_only.flags.i = 0;
    subroutine_only.flags.q.subroutine = 1;
-   subroutine_only.flags.q.subroutine_def = 1;
    if (state->has_explicit_uniform_location()) {
       subroutine_only.flags.q.explicit_index = 1;
    }
@@ -63,16 +62,17 @@ ast_type_qualifier::has_layout() const
 {
    return this->flags.q.origin_upper_left
           || this->flags.q.pixel_center_integer
-          || this->flags.q.depth_any
-          || this->flags.q.depth_greater
-          || this->flags.q.depth_less
-          || this->flags.q.depth_unchanged
+          || this->flags.q.depth_type
           || this->flags.q.std140
           || this->flags.q.std430
           || this->flags.q.shared
           || this->flags.q.column_major
           || this->flags.q.row_major
           || this->flags.q.packed
+          || this->flags.q.bindless_sampler
+          || this->flags.q.bindless_image
+          || this->flags.q.bound_sampler
+          || this->flags.q.bound_image
           || this->flags.q.explicit_align
           || this->flags.q.explicit_component
           || this->flags.q.explicit_location
@@ -116,17 +116,117 @@ bool ast_type_qualifier::has_memory() const
           || this->flags.q.write_only;
 }
 
+bool ast_type_qualifier::is_subroutine_decl() const
+{
+   return this->flags.q.subroutine && !this->subroutine_list;
+}
+
+static bool
+validate_prim_type(YYLTYPE *loc,
+                   _mesa_glsl_parse_state *state,
+                   const ast_type_qualifier &qualifier,
+                   const ast_type_qualifier &new_qualifier)
+{
+   /* Input layout qualifiers can be specified multiple
+    * times in separate declarations, as long as they match.
+    */
+   if (qualifier.flags.q.prim_type && new_qualifier.flags.q.prim_type
+       && qualifier.prim_type != new_qualifier.prim_type) {
+      _mesa_glsl_error(loc, state,
+                       "conflicting input primitive %s specified",
+                       state->stage == MESA_SHADER_GEOMETRY ?
+                       "type" : "mode");
+      return false;
+   }
+
+   return true;
+}
+
+static bool
+validate_vertex_spacing(YYLTYPE *loc,
+                        _mesa_glsl_parse_state *state,
+                        const ast_type_qualifier &qualifier,
+                        const ast_type_qualifier &new_qualifier)
+{
+   if (qualifier.flags.q.vertex_spacing && new_qualifier.flags.q.vertex_spacing
+       && qualifier.vertex_spacing != new_qualifier.vertex_spacing) {
+      _mesa_glsl_error(loc, state,
+                       "conflicting vertex spacing specified");
+      return false;
+   }
+
+   return true;
+}
+
+static bool
+validate_ordering(YYLTYPE *loc,
+                  _mesa_glsl_parse_state *state,
+                  const ast_type_qualifier &qualifier,
+                  const ast_type_qualifier &new_qualifier)
+{
+   if (qualifier.flags.q.ordering && new_qualifier.flags.q.ordering
+       && qualifier.ordering != new_qualifier.ordering) {
+      _mesa_glsl_error(loc, state,
+                       "conflicting ordering specified");
+      return false;
+   }
+
+   return true;
+}
+
+static bool
+validate_point_mode(ASSERTED const ast_type_qualifier &qualifier,
+                    ASSERTED const ast_type_qualifier &new_qualifier)
+{
+   /* Point mode can only be true if the flag is set. */
+   assert (!qualifier.flags.q.point_mode || !new_qualifier.flags.q.point_mode
+           || (qualifier.point_mode && new_qualifier.point_mode));
+
+   return true;
+}
+
+static void
+merge_bindless_qualifier(_mesa_glsl_parse_state *state)
+{
+   if (state->default_uniform_qualifier->flags.q.bindless_sampler) {
+      state->bindless_sampler_specified = true;
+      state->default_uniform_qualifier->flags.q.bindless_sampler = false;
+   }
+
+   if (state->default_uniform_qualifier->flags.q.bindless_image) {
+      state->bindless_image_specified = true;
+      state->default_uniform_qualifier->flags.q.bindless_image = false;
+   }
+
+   if (state->default_uniform_qualifier->flags.q.bound_sampler) {
+      state->bound_sampler_specified = true;
+      state->default_uniform_qualifier->flags.q.bound_sampler = false;
+   }
+
+   if (state->default_uniform_qualifier->flags.q.bound_image) {
+      state->bound_image_specified = true;
+      state->default_uniform_qualifier->flags.q.bound_image = false;
+   }
+}
+
 /**
- * This function merges both duplicate identifies within a single layout and
- * multiple layout qualifiers on a single variable declaration. The
- * is_single_layout_merge param is used differentiate between the two.
+ * This function merges duplicate layout identifiers.
+ *
+ * It deals with duplicates within a single layout qualifier, among multiple
+ * layout qualifiers on a single declaration and on several declarations for
+ * the same variable.
+ *
+ * The is_single_layout_merge and is_multiple_layouts_merge parameters are
+ * used to differentiate among them.
  */
 bool
 ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
                                     _mesa_glsl_parse_state *state,
                                     const ast_type_qualifier &q,
-                                    bool is_single_layout_merge)
+                                    bool is_single_layout_merge,
+                                    bool is_multiple_layouts_merge)
 {
+   bool r = true;
    ast_type_qualifier ubo_mat_mask;
    ubo_mat_mask.flags.i = 0;
    ubo_mat_mask.flags.q.row_major = 1;
@@ -170,6 +270,17 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
    input_layout_mask.flags.q.precise = 1;
    input_layout_mask.flags.q.sample = 1;
    input_layout_mask.flags.q.smooth = 1;
+   input_layout_mask.flags.q.non_coherent = 1;
+
+   if (state->has_bindless()) {
+      /* Allow to use image qualifiers with shader inputs/outputs. */
+      input_layout_mask.flags.q.coherent = 1;
+      input_layout_mask.flags.q._volatile = 1;
+      input_layout_mask.flags.q.restrict_flag = 1;
+      input_layout_mask.flags.q.read_only = 1;
+      input_layout_mask.flags.q.write_only = 1;
+      input_layout_mask.flags.q.explicit_image_format = 1;
+   }
 
    /* Uniform block layout qualifiers get to overwrite each
     * other (rightmost having priority), while all other
@@ -195,20 +306,21 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
       return false;
    }
 
+   if (is_multiple_layouts_merge && !state->has_420pack_or_es31()) {
+      _mesa_glsl_error(loc, state,
+                       "duplicate layout(...) qualifiers");
+      return false;
+   }
+
    if (q.flags.q.prim_type) {
-      if (this->flags.q.prim_type && this->prim_type != q.prim_type) {
-         _mesa_glsl_error(loc, state,
-                          "conflicting input primitive %s specified",
-                          state->stage == MESA_SHADER_GEOMETRY ?
-                          "type" : "mode");
-         return false;
-      }
+      r &= validate_prim_type(loc, state, *this, q);
       this->flags.q.prim_type = 1;
       this->prim_type = q.prim_type;
    }
 
    if (q.flags.q.max_vertices) {
-      if (this->flags.q.max_vertices && !is_single_layout_merge) {
+      if (this->flags.q.max_vertices
+          && !is_single_layout_merge && !is_multiple_layouts_merge) {
          this->max_vertices->merge_qualifier(q.max_vertices);
       } else {
          this->flags.q.max_vertices = 1;
@@ -216,8 +328,8 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
       }
    }
 
-   if (q.flags.q.subroutine_def) {
-      if (this->flags.q.subroutine_def) {
+   if (q.subroutine_list) {
+      if (this->subroutine_list) {
          _mesa_glsl_error(loc, state,
                           "conflicting subroutine qualifiers used");
       } else {
@@ -226,7 +338,8 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
    }
 
    if (q.flags.q.invocations) {
-      if (this->flags.q.invocations && !is_single_layout_merge) {
+      if (this->flags.q.invocations
+          && !is_single_layout_merge && !is_multiple_layouts_merge) {
          this->invocations->merge_qualifier(q.invocations);
       } else {
          this->flags.q.invocations = 1;
@@ -262,34 +375,16 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
          }
       }
 
-      if (q.flags.q.explicit_xfb_stride)
+      if (q.flags.q.explicit_xfb_stride) {
+         this->flags.q.xfb_stride = 1;
+         this->flags.q.explicit_xfb_stride = 1;
          this->xfb_stride = q.xfb_stride;
-
-      /* Merge all we xfb_stride qualifiers into the global out */
-      if (q.flags.q.explicit_xfb_stride || this->flags.q.xfb_stride) {
-
-         /* Set xfb_stride flag to 0 to avoid adding duplicates every time
-          * there is a merge.
-          */
-         this->flags.q.xfb_stride = 0;
-
-         unsigned buff_idx;
-         if (process_qualifier_constant(state, loc, "xfb_buffer",
-                                        this->xfb_buffer, &buff_idx)) {
-            if (state->out_qualifier->out_xfb_stride[buff_idx]
-                && !is_single_layout_merge) {
-               state->out_qualifier->out_xfb_stride[buff_idx]->merge_qualifier(
-                  new(state->linalloc) ast_layout_expression(*loc, this->xfb_stride));
-            } else {
-               state->out_qualifier->out_xfb_stride[buff_idx] =
-                  new(state->linalloc) ast_layout_expression(*loc, this->xfb_stride);
-            }
-         }
       }
    }
 
    if (q.flags.q.vertices) {
-      if (this->flags.q.vertices && !is_single_layout_merge) {
+      if (this->flags.q.vertices
+          && !is_single_layout_merge && !is_multiple_layouts_merge) {
          this->vertices->merge_qualifier(q.vertices);
       } else {
          this->flags.q.vertices = 1;
@@ -298,26 +393,19 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
    }
 
    if (q.flags.q.vertex_spacing) {
-      if (this->flags.q.vertex_spacing && this->vertex_spacing != q.vertex_spacing) {
-         _mesa_glsl_error(loc, state, "conflicting vertex spacing used");
-         return false;
-      }
+      r &= validate_vertex_spacing(loc, state, *this, q);
       this->flags.q.vertex_spacing = 1;
       this->vertex_spacing = q.vertex_spacing;
    }
 
    if (q.flags.q.ordering) {
-      if (this->flags.q.ordering && this->ordering != q.ordering) {
-         _mesa_glsl_error(loc, state, "conflicting ordering used");
-         return false;
-      }
+      r &= validate_ordering(loc, state, *this, q);
       this->flags.q.ordering = 1;
       this->ordering = q.ordering;
    }
 
    if (q.flags.q.point_mode) {
-      /* Point mode can only be true if the flag is set. */
-      assert (!this->flags.q.point_mode || (this->point_mode && q.point_mode));
+      r &= validate_point_mode(*this, q);
       this->flags.q.point_mode = 1;
       this->point_mode = q.point_mode;
    }
@@ -332,7 +420,8 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
 
    for (int i = 0; i < 3; i++) {
       if (q.flags.q.local_size & (1 << i)) {
-         if (this->local_size[i] && !is_single_layout_merge) {
+         if (this->local_size[i]
+             && !is_single_layout_merge && !is_multiple_layouts_merge) {
             this->local_size[i]->merge_qualifier(q.local_size[i]);
          } else {
             this->local_size[i] = q.local_size[i];
@@ -343,6 +432,23 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
    if (q.flags.q.local_size_variable)
       this->flags.q.local_size_variable = true;
 
+   if (q.flags.q.bindless_sampler)
+      this->flags.q.bindless_sampler = true;
+
+   if (q.flags.q.bindless_image)
+      this->flags.q.bindless_image = true;
+
+   if (q.flags.q.bound_sampler)
+      this->flags.q.bound_sampler = true;
+
+   if (q.flags.q.bound_image)
+      this->flags.q.bound_image = true;
+
+   if (q.flags.q.derivative_group) {
+      this->flags.q.derivative_group = true;
+      this->derivative_group = q.derivative_group;
+   }
+
    this->flags.i |= q.flags.i;
 
    if (this->flags.q.in &&
@@ -377,7 +483,20 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
       this->image_base_type = q.image_base_type;
    }
 
-   return true;
+   if (q.flags.q.bindless_sampler ||
+       q.flags.q.bindless_image ||
+       q.flags.q.bound_sampler ||
+       q.flags.q.bound_image)
+      merge_bindless_qualifier(state);
+
+   if (state->EXT_gpu_shader4_enable &&
+       state->stage == MESA_SHADER_FRAGMENT &&
+       this->flags.q.varying && q.flags.q.out) {
+      this->flags.q.varying = 0;
+      this->flags.q.out = 1;
+   }
+
+   return r;
 }
 
 bool
@@ -450,7 +569,7 @@ ast_type_qualifier::validate_out_qualifier(YYLTYPE *loc,
 bool
 ast_type_qualifier::merge_into_out_qualifier(YYLTYPE *loc,
                                              _mesa_glsl_parse_state *state,
-                                             ast_node* &node, bool create_node)
+                                             ast_node* &node)
 {
    const bool r = state->out_qualifier->merge_qualifier(loc, state,
                                                         *this, false);
@@ -461,8 +580,7 @@ ast_type_qualifier::merge_into_out_qualifier(YYLTYPE *loc,
       state->out_qualifier->flags.q.explicit_stream = 0;
       break;
    case MESA_SHADER_TESS_CTRL:
-      if (create_node)
-         node = new(state->linalloc) ast_tcs_output_layout(*loc);
+      node = new(state->linalloc) ast_tcs_output_layout(*loc);
       break;
    default:
       break;
@@ -529,10 +647,17 @@ ast_type_qualifier::validate_in_qualifier(YYLTYPE *loc,
       break;
    case MESA_SHADER_FRAGMENT:
       valid_in_mask.flags.q.early_fragment_tests = 1;
+      valid_in_mask.flags.q.inner_coverage = 1;
+      valid_in_mask.flags.q.post_depth_coverage = 1;
+      valid_in_mask.flags.q.pixel_interlock_ordered = 1;
+      valid_in_mask.flags.q.pixel_interlock_unordered = 1;
+      valid_in_mask.flags.q.sample_interlock_ordered = 1;
+      valid_in_mask.flags.q.sample_interlock_unordered = 1;
       break;
    case MESA_SHADER_COMPUTE:
       valid_in_mask.flags.q.local_size = 7;
       valid_in_mask.flags.q.local_size_variable = 1;
+      valid_in_mask.flags.q.derivative_group = 1;
       break;
    default:
       r = false;
@@ -552,38 +677,10 @@ ast_type_qualifier::validate_in_qualifier(YYLTYPE *loc,
     * error against the default global input qualifier as soon as we can, with
     * the closest error location in the shader.
     */
-
-   /* Input layout qualifiers can be specified multiple
-    * times in separate declarations, as long as they match.
-    */
-   if (state->in_qualifier->flags.q.prim_type && this->flags.q.prim_type
-       && state->in_qualifier->prim_type != this->prim_type) {
-      r = false;
-      _mesa_glsl_error(loc, state,
-                       "conflicting input primitive %s specified",
-                       state->stage == MESA_SHADER_GEOMETRY ?
-                       "type" : "mode");
-   }
-
-   if (state->in_qualifier->flags.q.vertex_spacing
-       && this->flags.q.vertex_spacing
-       && state->in_qualifier->vertex_spacing != this->vertex_spacing) {
-      r = false;
-      _mesa_glsl_error(loc, state,
-                       "conflicting vertex spacing specified");
-   }
-
-   if (state->in_qualifier->flags.q.ordering && this->flags.q.ordering
-       && state->in_qualifier->ordering != this->ordering) {
-      r = false;
-      _mesa_glsl_error(loc, state,
-                       "conflicting ordering specified");
-   }
-
-   /* Point mode can only be true if the flag is set. */
-   assert (!state->in_qualifier->flags.q.point_mode
-           || !this->flags.q.point_mode
-           || (state->in_qualifier->point_mode && this->point_mode));
+   r &= validate_prim_type(loc, state, *state->in_qualifier, *this);
+   r &= validate_vertex_spacing(loc, state, *state->in_qualifier, *this);
+   r &= validate_ordering(loc, state, *state->in_qualifier, *this);
+   r &= validate_point_mode(*state->in_qualifier, *this);
 
    return r;
 }
@@ -591,7 +688,7 @@ ast_type_qualifier::validate_in_qualifier(YYLTYPE *loc,
 bool
 ast_type_qualifier::merge_into_in_qualifier(YYLTYPE *loc,
                                             _mesa_glsl_parse_state *state,
-                                            ast_node* &node, bool create_node)
+                                            ast_node* &node)
 {
    bool r = true;
    void *lin_ctx = state->linalloc;
@@ -600,8 +697,7 @@ ast_type_qualifier::merge_into_in_qualifier(YYLTYPE *loc,
     * more repeated nodes will be created as we will have the flag set.
     */
    if (state->stage == MESA_SHADER_GEOMETRY
-       && this->flags.q.prim_type && !state->in_qualifier->flags.q.prim_type
-       && create_node) {
+       && this->flags.q.prim_type && !state->in_qualifier->flags.q.prim_type) {
       node = new(lin_ctx) ast_gs_input_layout(*loc, this->prim_type);
    }
 
@@ -612,13 +708,72 @@ ast_type_qualifier::merge_into_in_qualifier(YYLTYPE *loc,
       state->in_qualifier->flags.q.early_fragment_tests = false;
    }
 
+   if (state->in_qualifier->flags.q.inner_coverage) {
+      state->fs_inner_coverage = true;
+      state->in_qualifier->flags.q.inner_coverage = false;
+   }
+
+   if (state->in_qualifier->flags.q.post_depth_coverage) {
+      state->fs_post_depth_coverage = true;
+      state->in_qualifier->flags.q.post_depth_coverage = false;
+   }
+
+   if (state->fs_inner_coverage && state->fs_post_depth_coverage) {
+      _mesa_glsl_error(loc, state,
+                       "inner_coverage & post_depth_coverage layout qualifiers "
+                       "are mutally exclusives");
+      r = false;
+   }
+
+   if (state->in_qualifier->flags.q.pixel_interlock_ordered) {
+      state->fs_pixel_interlock_ordered = true;
+      state->in_qualifier->flags.q.pixel_interlock_ordered = false;
+   }
+
+   if (state->in_qualifier->flags.q.pixel_interlock_unordered) {
+      state->fs_pixel_interlock_unordered = true;
+      state->in_qualifier->flags.q.pixel_interlock_unordered = false;
+   }
+
+   if (state->in_qualifier->flags.q.sample_interlock_ordered) {
+      state->fs_sample_interlock_ordered = true;
+      state->in_qualifier->flags.q.sample_interlock_ordered = false;
+   }
+
+   if (state->in_qualifier->flags.q.sample_interlock_unordered) {
+      state->fs_sample_interlock_unordered = true;
+      state->in_qualifier->flags.q.sample_interlock_unordered = false;
+   }
+
+   if (state->fs_pixel_interlock_ordered +
+       state->fs_pixel_interlock_unordered +
+       state->fs_sample_interlock_ordered +
+       state->fs_sample_interlock_unordered > 1) {
+      _mesa_glsl_error(loc, state,
+                       "only one interlock mode can be used at any time.");
+      r = false;
+   }
+
+   if (state->in_qualifier->flags.q.derivative_group) {
+      if (state->cs_derivative_group != DERIVATIVE_GROUP_NONE) {
+         if (state->in_qualifier->derivative_group != DERIVATIVE_GROUP_NONE &&
+             state->cs_derivative_group != state->in_qualifier->derivative_group) {
+            _mesa_glsl_error(loc, state,
+                             "conflicting derivative groups.");
+            r = false;
+         }
+      } else {
+         state->cs_derivative_group = state->in_qualifier->derivative_group;
+      }
+   }
+
    /* We allow the creation of multiple cs_input_layout nodes. Coherence among
     * all existing nodes is checked later, when the AST node is transformed
     * into HIR.
     */
    if (state->in_qualifier->flags.q.local_size) {
-      if (create_node)
-         node = new(lin_ctx) ast_cs_input_layout(*loc, state->in_qualifier->local_size);
+      node = new(lin_ctx) ast_cs_input_layout(*loc,
+                                              state->in_qualifier->local_size);
       state->in_qualifier->flags.q.local_size = 0;
       for (int i = 0; i < 3; i++)
          state->in_qualifier->local_size[i] = NULL;
@@ -632,6 +787,31 @@ ast_type_qualifier::merge_into_in_qualifier(YYLTYPE *loc,
    return r;
 }
 
+bool
+ast_type_qualifier::push_to_global(YYLTYPE *loc,
+                                   _mesa_glsl_parse_state *state)
+{
+   if (this->flags.q.xfb_stride) {
+      this->flags.q.xfb_stride = 0;
+
+      unsigned buff_idx;
+      if (process_qualifier_constant(state, loc, "xfb_buffer",
+                                     this->xfb_buffer, &buff_idx)) {
+         if (state->out_qualifier->out_xfb_stride[buff_idx]) {
+            state->out_qualifier->out_xfb_stride[buff_idx]->merge_qualifier(
+               new(state->linalloc) ast_layout_expression(*loc,
+                                                          this->xfb_stride));
+         } else {
+            state->out_qualifier->out_xfb_stride[buff_idx] =
+               new(state->linalloc) ast_layout_expression(*loc,
+                                                          this->xfb_stride);
+         }
+      }
+   }
+
+   return true;
+}
+
 /**
  * Check if the current type qualifier has any illegal flags.
  *
@@ -655,7 +835,7 @@ ast_type_qualifier::validate_flags(YYLTYPE *loc,
                     "%s '%s':"
                     "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
                     "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
-                    "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+                    "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
                     message, name,
                     bad.flags.q.invariant ? " invariant" : "",
                     bad.flags.q.precise ? " precise" : "",
@@ -681,10 +861,7 @@ ast_type_qualifier::validate_flags(YYLTYPE *loc,
                     bad.flags.q.explicit_index ? " index" : "",
                     bad.flags.q.explicit_binding ? " binding" : "",
                     bad.flags.q.explicit_offset ? " offset" : "",
-                    bad.flags.q.depth_any ? " depth_any" : "",
-                    bad.flags.q.depth_greater ? " depth_greater" : "",
-                    bad.flags.q.depth_less ? " depth_less" : "",
-                    bad.flags.q.depth_unchanged ? " depth_unchanged" : "",
+                    bad.flags.q.depth_type ? " depth_type" : "",
                     bad.flags.q.std140 ? " std140" : "",
                     bad.flags.q.std430 ? " std430" : "",
                     bad.flags.q.shared ? " shared" : "",
@@ -715,7 +892,18 @@ ast_type_qualifier::validate_flags(YYLTYPE *loc,
                     bad.flags.q.point_mode ? " point_mode" : "",
                     bad.flags.q.vertices ? " vertices" : "",
                     bad.flags.q.subroutine ? " subroutine" : "",
-                    bad.flags.q.subroutine_def ? " subroutine_def" : "");
+                    bad.flags.q.blend_support ? " blend_support" : "",
+                    bad.flags.q.inner_coverage ? " inner_coverage" : "",
+                    bad.flags.q.bindless_sampler ? " bindless_sampler" : "",
+                    bad.flags.q.bindless_image ? " bindless_image" : "",
+                    bad.flags.q.bound_sampler ? " bound_sampler" : "",
+                    bad.flags.q.bound_image ? " bound_image" : "",
+                    bad.flags.q.post_depth_coverage ? " post_depth_coverage" : "",
+                    bad.flags.q.pixel_interlock_ordered ? " pixel_interlock_ordered" : "",
+                    bad.flags.q.pixel_interlock_unordered ? " pixel_interlock_unordered": "",
+                    bad.flags.q.sample_interlock_ordered ? " sample_interlock_ordered": "",
+                    bad.flags.q.sample_interlock_unordered ? " sample_interlock_unordered": "",
+                    bad.flags.q.non_coherent ? " noncoherent" : "");
    return false;
 }
 
@@ -723,8 +911,7 @@ bool
 ast_layout_expression::process_qualifier_constant(struct _mesa_glsl_parse_state *state,
                                                   const char *qual_indentifier,
                                                   unsigned *value,
-                                                  bool can_be_zero,
-                                                  bool must_match)
+                                                  bool can_be_zero)
 {
    int min_value = 0;
    bool first_pass = true;
@@ -741,8 +928,10 @@ ast_layout_expression::process_qualifier_constant(struct _mesa_glsl_parse_state
 
       ir_rvalue *const ir = const_expression->hir(&dummy_instructions, state);
 
-      ir_constant *const const_int = ir->constant_expression_value();
-      if (const_int == NULL || !const_int->type->is_integer()) {
+      ir_constant *const const_int =
+         ir->constant_expression_value(ralloc_parent(ir));
+
+      if (const_int == NULL || !const_int->type->is_integer_32()) {
          YYLTYPE loc = const_expression->get_location();
          _mesa_glsl_error(&loc, state, "%s must be an integral constant "
                           "expression", qual_indentifier);
@@ -757,19 +946,12 @@ ast_layout_expression::process_qualifier_constant(struct _mesa_glsl_parse_state
          return false;
       }
 
-      /* From section 4.4 "Layout Qualifiers" of the GLSL 4.50 spec:
-       * "When the same layout-qualifier-name occurs multiple times,
-       *  in a single declaration, the last occurrence overrides the
-       *  former occurrence(s)."
-       */
-      if (!first_pass) {
-         if ((must_match || !state->has_420pack()) && *value != const_int->value.u[0]) {
-            YYLTYPE loc = const_expression->get_location();
-            _mesa_glsl_error(&loc, state, "%s layout qualifier does not "
-                             "match previous declaration (%d vs %d)",
-                             qual_indentifier, *value, const_int->value.i[0]);
-            return false;
-         }
+      if (!first_pass && *value != const_int->value.u[0]) {
+         YYLTYPE loc = const_expression->get_location();
+         _mesa_glsl_error(&loc, state, "%s layout qualifier does not "
+                         "match previous declaration (%d vs %d)",
+                          qual_indentifier, *value, const_int->value.i[0]);
+         return false;
       } else {
          first_pass = false;
          *value = const_int->value.u[0];
@@ -803,8 +985,9 @@ process_qualifier_constant(struct _mesa_glsl_parse_state *state,
 
    ir_rvalue *const ir = const_expression->hir(&dummy_instructions, state);
 
-   ir_constant *const const_int = ir->constant_expression_value();
-   if (const_int == NULL || !const_int->type->is_integer()) {
+   ir_constant *const const_int =
+      ir->constant_expression_value(ralloc_parent(ir));
+   if (const_int == NULL || !const_int->type->is_integer_32()) {
       _mesa_glsl_error(loc, state, "%s must be an integral constant "
                        "expression", qual_indentifier);
       return false;