[Mesa-dev] [PATCH 07/12] glsl parser: handle interface block member qualifier

Jordan Justen jordan.l.justen at intel.com
Tue Mar 12 13:35:45 PDT 2013


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

In this case it must match the interface block type.

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

In this case, it should use the same type as the interface block.

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

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index d21ca2d..ac1d8ed 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1976,6 +1976,23 @@ basic_interface_block:
 	   interface_type_flags = $1.flags.i & interface_type_mask;
 	   block->layout.flags.i |= interface_type_flags;
 
+	   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



More information about the mesa-dev mailing list