glsl: Merge UBO layout qualifiers in a qualifier list.
authorEric Anholt <eric@anholt.net>
Fri, 22 Jun 2012 20:31:56 +0000 (13:31 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 31 Jul 2012 19:06:20 +0000 (12:06 -0700)
Yes, you get to say things like "layout(row_major, column_major)" and
get column major.

Part of fixing piglit ARB_uniform_buffer_object/row_major.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/glsl_parser.yy

index b7e1a5b..ba21b54 100644 (file)
@@ -1113,13 +1113,35 @@ layout_qualifier_id_list:
        layout_qualifier_id
        | layout_qualifier_id_list ',' layout_qualifier_id
        {
-          if (($1.flags.i & $3.flags.i) != 0) {
+          ast_type_qualifier ubo_mat_mask;
+          ubo_mat_mask.flags.i = 0;
+          ubo_mat_mask.flags.q.row_major = 1;
+          ubo_mat_mask.flags.q.column_major = 1;
+
+          ast_type_qualifier ubo_layout_mask;
+          ubo_layout_mask.flags.i = 0;
+          ubo_layout_mask.flags.q.std140 = 1;
+          ubo_layout_mask.flags.q.packed = 1;
+          ubo_layout_mask.flags.q.shared = 1;
+
+          /* Uniform block layout qualifiers get to overwrite each
+           * other (rightmost having priority), while all other
+           * qualifiers currently don't allow duplicates.
+           */
+          if (($1.flags.i & $3.flags.i & ~(ubo_mat_mask.flags.i |
+                                           ubo_layout_mask.flags.i)) != 0) {
              _mesa_glsl_error(& @3, state,
                               "duplicate layout qualifiers used\n");
              YYERROR;
           }
 
           $$ = $1;
+
+          if (($3.flags.i & ubo_mat_mask.flags.i) != 0)
+             $$.flags.i &= ~ubo_mat_mask.flags.i;
+          if (($3.flags.i & ubo_layout_mask.flags.i) != 0)
+             $$.flags.i &= ~ubo_layout_mask.flags.i;
+
           $$.flags.i |= $3.flags.i;
 
           if ($3.flags.q.explicit_location)