summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/glsl_parser_extras.cpp
diff options
context:
space:
mode:
authorAndres Gomez <[email protected]>2016-10-18 18:18:21 +0300
committerAndres Gomez <[email protected]>2016-11-25 13:18:30 +0200
commit70456aca8d1934ec53c24cfe1cfb4273d2bc9397 (patch)
treecfc6e17d371f45b571dc4ee2f8ac59d7d01ab82d /src/compiler/glsl/glsl_parser_extras.cpp
parent9f13d0c64bee2935ba41a318196f8851a92ad348 (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/glsl_parser_extras.cpp')
-rw-r--r--src/compiler/glsl/glsl_parser_extras.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 85a2e943ff5..78f7fe25965 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -276,12 +276,10 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->default_uniform_qualifier = new(this) ast_type_qualifier();
this->default_uniform_qualifier->flags.q.shared = 1;
this->default_uniform_qualifier->flags.q.column_major = 1;
- this->default_uniform_qualifier->is_default_qualifier = true;
this->default_shader_storage_qualifier = new(this) ast_type_qualifier();
this->default_shader_storage_qualifier->flags.q.shared = 1;
this->default_shader_storage_qualifier->flags.q.column_major = 1;
- this->default_shader_storage_qualifier->is_default_qualifier = true;
this->fs_uses_gl_fragcoord = false;
this->fs_redeclares_gl_fragcoord = false;
@@ -1003,22 +1001,22 @@ _mesa_ast_process_interface_block(YYLTYPE *locp,
*/
uint64_t block_interface_qualifier = q.flags.i;
- block->layout.flags.i |= block_interface_qualifier;
+ block->default_layout.flags.i |= block_interface_qualifier;
if (state->stage == MESA_SHADER_GEOMETRY &&
state->has_explicit_attrib_stream() &&
- block->layout.flags.q.out) {
+ block->default_layout.flags.q.out) {
/* Assign global layout's stream value. */
- block->layout.flags.q.stream = 1;
- block->layout.flags.q.explicit_stream = 0;
- block->layout.stream = state->out_qualifier->stream;
+ block->default_layout.flags.q.stream = 1;
+ block->default_layout.flags.q.explicit_stream = 0;
+ block->default_layout.stream = state->out_qualifier->stream;
}
- if (state->has_enhanced_layouts() && block->layout.flags.q.out) {
+ if (state->has_enhanced_layouts() && block->default_layout.flags.q.out) {
/* Assign global layout's xfb_buffer value. */
- block->layout.flags.q.xfb_buffer = 1;
- block->layout.flags.q.explicit_xfb_buffer = 0;
- block->layout.xfb_buffer = state->out_qualifier->xfb_buffer;
+ block->default_layout.flags.q.xfb_buffer = 1;
+ block->default_layout.flags.q.explicit_xfb_buffer = 0;
+ block->default_layout.xfb_buffer = state->out_qualifier->xfb_buffer;
}
foreach_list_typed (ast_declarator_list, member, link, &block->declarations) {