diff options
author | Andres Gomez <[email protected]> | 2016-10-18 18:18:21 +0300 |
---|---|---|
committer | Andres Gomez <[email protected]> | 2016-11-25 13:18:30 +0200 |
commit | 70456aca8d1934ec53c24cfe1cfb4273d2bc9397 (patch) | |
tree | cfc6e17d371f45b571dc4ee2f8ac59d7d01ab82d /src/compiler/glsl/ast.h | |
parent | 9f13d0c64bee2935ba41a318196f8851a92ad348 (diff) |
glsl: merge layouts into the default one as the last step in interface blocks
Consider this example:
" #version 150 core
#extension GL_ARB_shading_language_420pack: require
#extension GL_ARB_explicit_attrib_location: require
layout(location=0) out vec4 o;
layout(binding=2) layout(binding=3, std140) uniform U {
vec4 a;
} u[2];"
As there is 2 layout-qualifiers for the uniform U and the binding
layout-qualifier-id is duplicated, the rules set by the
ARB_shading_language_420pack spec state that the rightmost should
prevail.
Our ast_type_qualifier merges with others in a way that if the value
for a layout-qualifier-id is set in both, the object being merged
overwrites the value of the object invoking the merge. Hence, the
merge has to happen from the left layout towards the right one and
this was not happening for interface blocks because we were merging
into the default layout qualifier.
Now, the merge is done from left to right and, as a last step, we
merge into the default layout qualifier if needed, so the values of
the explicit layouts prevail over it.
V2: added a default_layout variable instead of a layout_helper and
make the merge directly over the layout one. Suggested by Timothy.
Reviewed-by: Timothy Arceri <[email protected]>
Signed-off-by: Andres Gomez <[email protected]>
Diffstat (limited to 'src/compiler/glsl/ast.h')
-rw-r--r-- | src/compiler/glsl/ast.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h index 55f9a6c2e5a..e7c3aff6b82 100644 --- a/src/compiler/glsl/ast.h +++ b/src/compiler/glsl/ast.h @@ -725,9 +725,6 @@ struct ast_type_qualifier { */ glsl_base_type image_base_type; - /** Flag to know if this represents a default value for a qualifier */ - bool is_default_qualifier; - /** * Return true if and only if an interpolation qualifier is present. */ @@ -748,6 +745,11 @@ struct ast_type_qualifier { */ bool has_auxiliary_storage() const; + /** + * Return true if and only if a memory qualifier is present. + */ + bool has_memory() const; + bool merge_qualifier(YYLTYPE *loc, _mesa_glsl_parse_state *state, const ast_type_qualifier &q, @@ -1139,6 +1141,7 @@ public: virtual ir_rvalue *hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); + ast_type_qualifier default_layout; ast_type_qualifier layout; const char *block_name; |