From 6d3d974e379caadde53c5361e26384935c199769 Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Sat, 9 Mar 2013 11:36:11 -0800 Subject: [PATCH] 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 Reviewed-by: Eric Anholt Reviewed-by: Kenneth Graunke --- src/glsl/glsl_parser.yy | 51 ++++++++++++++++++++++++++++++++--------- 1 file 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 layout_qualifier %type layout_qualifier_id_list layout_qualifier_id %type interface_block_layout_qualifier +%type interface_qualifier %type type_specifier %type type_specifier_no_prec %type 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 */ { -- 2.30.2