From 551bdf25bc4e57bea51c54da7e31c44c507e6c9f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 22 Jun 2012 13:36:35 -0700 Subject: glsl: Add support for default layout qualifiers for uniforms. I ended up having to add rallocing of the ast_type_qualifier in order to avoid pulling in ast.h for glsl_parser_extras.h, because I wanted to track an ast_type_qualifier in the state. Fixes piglit ARB_uniform_buffer_object/row-major. Reviewed-by: Kenneth Graunke Reviewed-by: Ian Romanick --- src/glsl/ast_type.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src/glsl/ast_type.cpp') diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp index 6c44f8c41de..29493e2f6c6 100644 --- a/src/glsl/ast_type.cpp +++ b/src/glsl/ast_type.cpp @@ -71,3 +71,48 @@ ast_type_qualifier::interpolation_string() const else return NULL; } + +bool +ast_type_qualifier::merge_qualifier(YYLTYPE *loc, + _mesa_glsl_parse_state *state, + ast_type_qualifier q) +{ + 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 ((this->flags.i & q.flags.i & ~(ubo_mat_mask.flags.i | + ubo_layout_mask.flags.i)) != 0) { + _mesa_glsl_error(loc, state, + "duplicate layout qualifiers used\n"); + return false; + } + + if ((q.flags.i & ubo_mat_mask.flags.i) != 0) + this->flags.i &= ~ubo_mat_mask.flags.i; + if ((q.flags.i & ubo_layout_mask.flags.i) != 0) + this->flags.i &= ~ubo_layout_mask.flags.i; + + this->flags.i |= q.flags.i; + + if (q.flags.q.explicit_location) + this->location = q.location; + + if (q.flags.q.explicit_index) + this->index = q.index; + + return true; +} + -- cgit v1.2.3