An interface block member may specify the type:
in {
    in vec4 in_var_with_qualifier;
};

When specified with the member, it must match the same
type as interface block type.

It can also omit the qualifier:
uniform {
    vec4 uniform_var_without_qualifier;
};

When the type is not specified with the member,
it will adopt the same type as the interface block.

Signed-off-by: Jordan Justen <jordan.l.jus...@intel.com>
---
 src/glsl/glsl_parser.yy |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 70764d6..c254a2f 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1958,8 +1958,34 @@ basic_interface_block:
                        "an instance name are not allowed");
           }
 
+          unsigned interface_type_mask, interface_type_flags;
+          struct ast_type_qualifier temp_type_qualifier;
+
+          temp_type_qualifier.flags.i = 0;
+          temp_type_qualifier.flags.q.uniform = true;
+          temp_type_qualifier.flags.q.in = true;
+          temp_type_qualifier.flags.q.out = true;
+          interface_type_mask = temp_type_qualifier.flags.i;
+          interface_type_flags = $1.flags.i & interface_type_mask;
           block->layout.flags.i |= $1.flags.i;
 
+          foreach_list_typed (ast_declarator_list, member, link, 
&block->declarations) {
+             ast_type_qualifier& qualifier = member->type->qualifier;
+             if ((qualifier.flags.i & interface_type_mask) == 0) {
+                qualifier.flags.i |= interface_type_flags;
+             } else if ((qualifier.flags.i & interface_type_mask) !=
+                        interface_type_flags) {
+                /* GLSLangSpec.1.50.11, 4.3.7 Interface Blocks:
+                 * "Input variables, output variables, and uniform variables 
can only
+                 *  be in in blocks, out blocks, and uniform blocks, 
respectively."
+                 */
+                _mesa_glsl_error(& @1, state,
+                                 "uniform/in/out qualifier on "
+                                 "interface block member does not match "
+                                 "the interface block\n");
+             }
+          }
+
           $$ = block;
        }
        ;
-- 
1.7.10.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to