diff options
author | Jordan Justen <[email protected]> | 2013-03-09 11:36:11 -0800 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2013-05-23 09:37:11 -0700 |
commit | 6d3d974e379caadde53c5361e26384935c199769 (patch) | |
tree | 68feb08ab085c7eb186c1e7842f4ab4fa81b6559 /src | |
parent | 744c2704061f9c0c660fb5c48d4e74a586335ef0 (diff) |
glsl: parse in/out types for interface blocks
Previously only 'uniform' was allowed for uniform blocks.
Now, in/out can be parsed, but it will only be allowed for
GLSL >= 150.
Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/glsl_parser.yy | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index 33b74eaf73d..0a2a77b8f16 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -165,6 +165,7 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg) %type <type_qualifier> layout_qualifier %type <type_qualifier> layout_qualifier_id_list layout_qualifier_id %type <type_qualifier> interface_block_layout_qualifier +%type <type_qualifier> interface_qualifier %type <type_specifier> type_specifier %type <type_specifier> type_specifier_no_prec %type <type_specifier> type_specifier_nonarray @@ -1215,11 +1216,11 @@ layout_qualifier_id: { $$ = $1; /* Layout qualifiers for ARB_uniform_buffer_object. */ - if (!state->ARB_uniform_buffer_object_enable) { + if ($$.flags.q.uniform && !state->ARB_uniform_buffer_object_enable) { _mesa_glsl_error(& @1, state, "#version 140 / GL_ARB_uniform_buffer_object " "layout qualifier `%s' is used\n", $1); - } else if (state->ARB_uniform_buffer_object_warn) { + } else if ($$.flags.q.uniform && state->ARB_uniform_buffer_object_warn) { _mesa_glsl_warning(& @1, state, "#version 140 / GL_ARB_uniform_buffer_object " "layout qualifier `%s' is used\n", $1); @@ -1909,21 +1910,29 @@ interface_block: ; basic_interface_block: - UNIFORM NEW_IDENTIFIER '{' member_list '}' instance_name_opt ';' + interface_qualifier NEW_IDENTIFIER '{' member_list '}' instance_name_opt ';' { ast_interface_block *const block = $6; block->block_name = $2; block->declarations.push_degenerate_list_at_head(& $4->link); - if (!state->ARB_uniform_buffer_object_enable) { - _mesa_glsl_error(& @1, state, - "#version 140 / GL_ARB_uniform_buffer_object " - "required for defining uniform blocks\n"); - } else if (state->ARB_uniform_buffer_object_warn) { - _mesa_glsl_warning(& @1, state, - "#version 140 / GL_ARB_uniform_buffer_object " - "required for defining uniform blocks\n"); + if ($1.flags.q.uniform) { + if (!state->ARB_uniform_buffer_object_enable) { + _mesa_glsl_error(& @1, state, + "#version 140 / GL_ARB_uniform_buffer_object " + "required for defining uniform blocks\n"); + } else if (state->ARB_uniform_buffer_object_warn) { + _mesa_glsl_warning(& @1, state, + "#version 140 / GL_ARB_uniform_buffer_object " + "required for defining uniform blocks\n"); + } + } else { + if (state->es_shader || state->language_version < 150) { + _mesa_glsl_error(& @1, state, + "#version 150 required for using " + "interface blocks.\n"); + } } /* Since block arrays require names, and both features are added in @@ -1937,10 +1946,30 @@ basic_interface_block: "blocks with an instance name\n"); } + block->layout.flags.i |= $1.flags.i; + $$ = block; } ; +interface_qualifier: + IN_TOK + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.in = 1; + } + | OUT_TOK + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.out = 1; + } + | UNIFORM + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.uniform = 1; + } + ; + instance_name_opt: /* empty */ { |