summaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_parser.yy
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-01-18 17:06:57 +1100
committerTimothy Arceri <[email protected]>2016-01-20 08:06:45 +1100
commit564009986ff1485c467664542a9042e6ce4dcdfe (patch)
treed9ced4f72b47da1d1319b70d6219025122fff124 /src/glsl/glsl_parser.yy
parenta0a93470e3413d5a5890d988462bb898362bd68f (diff)
glsl: update parser to allow duplicate default layout qualifiers
In order to only create a single node for each default declaration we add a new boolean parameter to the in/out merge function to only create one once we reach the rightmost layout qualifier. 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." Acked-by: Matt Turner <[email protected]> Reviewed-by: Chris Forbes <[email protected]>
Diffstat (limited to 'src/glsl/glsl_parser.yy')
-rw-r--r--src/glsl/glsl_parser.yy66
1 files changed, 60 insertions, 6 deletions
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 925cb820ba9..6099aeb12ca 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -2742,7 +2742,20 @@ member_declaration:
;
layout_uniform_defaults:
- layout_qualifier UNIFORM ';'
+ layout_qualifier layout_uniform_defaults
+ {
+ $$ = NULL;
+ if (!state->has_420pack_or_es31()) {
+ _mesa_glsl_error(&@1, state, "duplicate layout(...) qualifiers");
+ YYERROR;
+ } else {
+ if (!state->default_uniform_qualifier->
+ merge_qualifier(& @1, state, $1)) {
+ YYERROR;
+ }
+ }
+ }
+ | layout_qualifier UNIFORM ';'
{
if (!state->default_uniform_qualifier->merge_qualifier(& @1, state, $1)) {
YYERROR;
@@ -2752,7 +2765,20 @@ layout_uniform_defaults:
;
layout_buffer_defaults:
- layout_qualifier BUFFER ';'
+ layout_qualifier layout_buffer_defaults
+ {
+ $$ = NULL;
+ if (!state->has_420pack_or_es31()) {
+ _mesa_glsl_error(&@1, state, "duplicate layout(...) qualifiers");
+ YYERROR;
+ } else {
+ if (!state->default_shader_storage_qualifier->
+ merge_qualifier(& @1, state, $1)) {
+ YYERROR;
+ }
+ }
+ }
+ | layout_qualifier BUFFER ';'
{
if (!state->default_shader_storage_qualifier->merge_qualifier(& @1, state, $1)) {
YYERROR;
@@ -2773,20 +2799,48 @@ layout_buffer_defaults:
;
layout_in_defaults:
- layout_qualifier IN_TOK ';'
+ layout_qualifier layout_in_defaults
{
$$ = NULL;
- if (!state->in_qualifier->merge_in_qualifier(& @1, state, $1, $$)) {
+ if (!state->has_420pack_or_es31()) {
+ _mesa_glsl_error(&@1, state, "duplicate layout(...) qualifiers");
+ YYERROR;
+ } else {
+ if (!state->in_qualifier->
+ merge_in_qualifier(& @1, state, $1, $$, false)) {
+ YYERROR;
+ }
+ }
+ }
+ | layout_qualifier IN_TOK ';'
+ {
+ $$ = NULL;
+ if (!state->in_qualifier->
+ merge_in_qualifier(& @1, state, $1, $$, true)) {
YYERROR;
}
}
;
layout_out_defaults:
- layout_qualifier OUT_TOK ';'
+ layout_qualifier layout_out_defaults
+ {
+ $$ = NULL;
+ if (!state->has_420pack_or_es31()) {
+ _mesa_glsl_error(&@1, state, "duplicate layout(...) qualifiers");
+ YYERROR;
+ } else {
+ if (!state->out_qualifier->
+ merge_out_qualifier(& @1, state, $1, $$, false)) {
+ YYERROR;
+ }
+ }
+ }
+ | layout_qualifier OUT_TOK ';'
{
$$ = NULL;
- if (!state->out_qualifier->merge_out_qualifier(& @1, state, $1, $$))
+ if (!state->out_qualifier->
+ merge_out_qualifier(& @1, state, $1, $$, true))
YYERROR;
}
;