summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/glsl/ast.h6
-rw-r--r--src/compiler/glsl/ast_type.cpp50
-rw-r--r--src/compiler/glsl/glsl_parser.yy27
3 files changed, 60 insertions, 23 deletions
diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
index e40387b8f65..d8b425c5981 100644
--- a/src/compiler/glsl/ast.h
+++ b/src/compiler/glsl/ast.h
@@ -782,6 +782,12 @@ struct ast_type_qualifier {
_mesa_glsl_parse_state *state,
ast_node* &node);
+ /**
+ * Push pending layout qualifiers to the global values.
+ */
+ bool push_to_global(YYLTYPE *loc,
+ _mesa_glsl_parse_state *state);
+
bool validate_flags(YYLTYPE *loc,
_mesa_glsl_parse_state *state,
const ast_type_qualifier &allowed_flags,
diff --git a/src/compiler/glsl/ast_type.cpp b/src/compiler/glsl/ast_type.cpp
index 788f734b662..dc4f2073fc9 100644
--- a/src/compiler/glsl/ast_type.cpp
+++ b/src/compiler/glsl/ast_type.cpp
@@ -337,29 +337,10 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
}
}
- if (q.flags.q.explicit_xfb_stride)
+ if (q.flags.q.explicit_xfb_stride) {
+ this->flags.q.xfb_stride = 1;
+ this->flags.q.explicit_xfb_stride = 1;
this->xfb_stride = q.xfb_stride;
-
- /* Merge all we xfb_stride qualifiers into the global out */
- if (q.flags.q.explicit_xfb_stride || this->flags.q.xfb_stride) {
-
- /* Set xfb_stride flag to 0 to avoid adding duplicates every time
- * there is a merge.
- */
- this->flags.q.xfb_stride = 0;
-
- unsigned buff_idx;
- if (process_qualifier_constant(state, loc, "xfb_buffer",
- this->xfb_buffer, &buff_idx)) {
- if (state->out_qualifier->out_xfb_stride[buff_idx]
- && !is_single_layout_merge && !is_multiple_layouts_merge) {
- state->out_qualifier->out_xfb_stride[buff_idx]->merge_qualifier(
- new(state->linalloc) ast_layout_expression(*loc, this->xfb_stride));
- } else {
- state->out_qualifier->out_xfb_stride[buff_idx] =
- new(state->linalloc) ast_layout_expression(*loc, this->xfb_stride);
- }
- }
}
}
@@ -672,6 +653,31 @@ ast_type_qualifier::merge_into_in_qualifier(YYLTYPE *loc,
return r;
}
+bool
+ast_type_qualifier::push_to_global(YYLTYPE *loc,
+ _mesa_glsl_parse_state *state)
+{
+ if (this->flags.q.xfb_stride) {
+ this->flags.q.xfb_stride = 0;
+
+ unsigned buff_idx;
+ if (process_qualifier_constant(state, loc, "xfb_buffer",
+ this->xfb_buffer, &buff_idx)) {
+ if (state->out_qualifier->out_xfb_stride[buff_idx]) {
+ state->out_qualifier->out_xfb_stride[buff_idx]->merge_qualifier(
+ new(state->linalloc) ast_layout_expression(*loc,
+ this->xfb_stride));
+ } else {
+ state->out_qualifier->out_xfb_stride[buff_idx] =
+ new(state->linalloc) ast_layout_expression(*loc,
+ this->xfb_stride);
+ }
+ }
+ }
+
+ return true;
+}
+
/**
* Check if the current type qualifier has any illegal flags.
*
diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy
index 9136fddbd14..0c3781c3361 100644
--- a/src/compiler/glsl/glsl_parser.yy
+++ b/src/compiler/glsl/glsl_parser.yy
@@ -845,7 +845,9 @@ declaration:
}
}
block->layout = block->default_layout;
-
+ if (!block->layout.push_to_global(& @1, state)) {
+ YYERROR;
+ }
$$ = $1;
}
;
@@ -921,6 +923,9 @@ parameter_declaration:
{
$$ = $2;
$$->type->qualifier = $1;
+ if (!$$->type->qualifier.push_to_global(& @1, state)) {
+ YYERROR;
+ }
}
| parameter_qualifier parameter_type_specifier
{
@@ -930,6 +935,9 @@ parameter_declaration:
$$->type = new(ctx) ast_fully_specified_type();
$$->type->set_location_range(@1, @2);
$$->type->qualifier = $1;
+ if (!$$->type->qualifier.push_to_global(& @1, state)) {
+ YYERROR;
+ }
$$->type->specifier = $2;
}
;
@@ -1145,6 +1153,9 @@ fully_specified_type:
$$ = new(ctx) ast_fully_specified_type();
$$->set_location_range(@1, @2);
$$->qualifier = $1;
+ if (!$$->qualifier.push_to_global(& @1, state)) {
+ YYERROR;
+ }
$$->specifier = $2;
if ($$->specifier->structure != NULL &&
$$->specifier->structure->is_declaration) {
@@ -2911,6 +2922,10 @@ layout_defaults:
merge_qualifier(& @1, state, $1, false)) {
YYERROR;
}
+ if (!state->default_uniform_qualifier->
+ push_to_global(& @1, state)) {
+ YYERROR;
+ }
}
| layout_buffer_defaults
{
@@ -2919,6 +2934,10 @@ layout_defaults:
merge_qualifier(& @1, state, $1, false)) {
YYERROR;
}
+ if (!state->default_shader_storage_qualifier->
+ push_to_global(& @1, state)) {
+ YYERROR;
+ }
/* From the GLSL 4.50 spec, section 4.4.5:
*
@@ -2936,6 +2955,9 @@ layout_defaults:
if (!$1.merge_into_in_qualifier(& @1, state, $$)) {
YYERROR;
}
+ if (!state->in_qualifier->push_to_global(& @1, state)) {
+ YYERROR;
+ }
}
| layout_out_defaults
{
@@ -2943,5 +2965,8 @@ layout_defaults:
if (!$1.merge_into_out_qualifier(& @1, state, $$)) {
YYERROR;
}
+ if (!state->out_qualifier->push_to_global(& @1, state)) {
+ YYERROR;
+ }
}
;