summaryrefslogtreecommitdiffstats
path: root/src/glsl/ast_type.cpp
diff options
context:
space:
mode:
authorTimothy Arceri <timothy.arceri@collabora.com>2016-01-15 12:43:10 +1100
committerTimothy Arceri <timothy.arceri@collabora.com>2016-01-20 08:06:50 +1100
commit6a660a5f5dad02a6594ea905c511ba3cae6862a5 (patch)
tree0041c81a83867d5741f7d7456abba01c74a48223 /src/glsl/ast_type.cpp
parent564009986ff1485c467664542a9042e6ce4dcdfe (diff)
downloadexternal_mesa3d-6a660a5f5dad02a6594ea905c511ba3cae6862a5.zip
external_mesa3d-6a660a5f5dad02a6594ea905c511ba3cae6862a5.tar.gz
external_mesa3d-6a660a5f5dad02a6594ea905c511ba3cae6862a5.tar.bz2
glsl: allow multiple layout qualifiers for a single declaration
From the ARB_shading_language_420pack spec: "More than one layout qualifier may appear in a single declaration. If the same layout-qualifier-name occurs in multiple layout qualifiers for the same declaration, the last one overrides the former ones." The parser was already failing correctly when the extension is not available but testing for duplicates within a single layout qualifier was still causing this to fail when available as both cases share the same function for merging. Here we add a parameter to differentiate between the two uses and apply it to the duplicate test. Acked-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
Diffstat (limited to 'src/glsl/ast_type.cpp')
-rw-r--r--src/glsl/ast_type.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp
index 32cb0a0..cf494d9 100644
--- a/src/glsl/ast_type.cpp
+++ b/src/glsl/ast_type.cpp
@@ -114,10 +114,16 @@ ast_type_qualifier::interpolation_string() const
return NULL;
}
+/**
+ * This function merges both duplicate identifies within a single layout and
+ * multiple layout qualifiers on a single variable declaration. The
+ * is_single_layout_merge param is used differentiate between the two.
+ */
bool
ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
_mesa_glsl_parse_state *state,
- const ast_type_qualifier &q)
+ const ast_type_qualifier &q,
+ bool is_single_layout_merge)
{
ast_type_qualifier ubo_mat_mask;
ubo_mat_mask.flags.i = 0;
@@ -157,7 +163,7 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
allowed_duplicates_mask.flags.i |=
stream_layout_mask.flags.i;
- if (!state->has_enhanced_layouts() &&
+ if (is_single_layout_merge && !state->has_enhanced_layouts() &&
(this->flags.i & q.flags.i & ~allowed_duplicates_mask.flags.i) != 0) {
_mesa_glsl_error(loc, state,
"duplicate layout qualifiers used");
@@ -294,7 +300,7 @@ ast_type_qualifier::merge_out_qualifier(YYLTYPE *loc,
ast_node* &node, bool create_node)
{
void *mem_ctx = state;
- const bool r = this->merge_qualifier(loc, state, q);
+ const bool r = this->merge_qualifier(loc, state, q, false);
if (state->stage == MESA_SHADER_GEOMETRY) {
if (q.flags.q.prim_type) {