From 738c9c3c543b985b025a4a60fcc9c2e212e2d821 Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Tue, 4 Feb 2014 11:32:56 -0800 Subject: [PATCH] glsl: Generate error for invalid input layout declarations Fixes various piglit tests: spec/glsl-1.50/compiler/incorrect-in-layout-qualifier-*.geom Signed-off-by: Jordan Justen Reviewed-by: Anuj Phogat --- src/glsl/ast_type.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp index 2f36cf43c11..eba577764b0 100644 --- a/src/glsl/ast_type.cpp +++ b/src/glsl/ast_type.cpp @@ -207,6 +207,8 @@ ast_type_qualifier::merge_in_qualifier(YYLTYPE *loc, void *mem_ctx = state; bool create_gs_ast = false; bool create_cs_ast = false; + ast_type_qualifier valid_in_mask; + valid_in_mask.flags.i = 0; switch (state->stage) { case MESA_SHADER_GEOMETRY: @@ -229,6 +231,8 @@ ast_type_qualifier::merge_in_qualifier(YYLTYPE *loc, create_gs_ast |= q.flags.q.prim_type && !state->in_qualifier->flags.q.prim_type; + + valid_in_mask.flags.q.prim_type = 1; break; case MESA_SHADER_FRAGMENT: if (q.flags.q.early_fragment_tests) { @@ -241,6 +245,8 @@ ast_type_qualifier::merge_in_qualifier(YYLTYPE *loc, create_cs_ast |= q.flags.q.local_size != 0 && state->in_qualifier->flags.q.local_size == 0; + + valid_in_mask.flags.q.local_size = 1; break; default: _mesa_glsl_error(loc, state, @@ -249,6 +255,13 @@ ast_type_qualifier::merge_in_qualifier(YYLTYPE *loc, break; } + /* Generate an error when invalid input layout qualifiers are used. */ + if ((q.flags.i & ~valid_in_mask.flags.i) != 0) { + _mesa_glsl_error(loc, state, + "invalid input layout qualifiers used"); + return false; + } + /* Input layout qualifiers can be specified multiple * times in separate declarations, as long as they match. */ -- 2.30.2