summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2012-11-27 23:21:56 -0800
committerIan Romanick <[email protected]>2013-01-25 09:07:33 -0500
commit0d2e6336a21e20afe37861030ac2161aadd0499e (patch)
treefa9f9fc92eba8c2e9b35d6e23c81ffe8857cc7bd /src
parentb226a058dbb59a24254a149be182a08bcb10bee3 (diff)
glsl: Refactor uniform block parser rules.
The existing code has a lot of duplication; the only difference between the two cases is whether we merge in an additional layout qualifier. Apparently creating a layout_qualifieropt rule that can be empty causes a lot of conflicts and confusion. However, refactoring out the guts of the ast_uniform_block creation works fine. Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/glsl_parser.yy37
1 files changed, 16 insertions, 21 deletions
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 88aae64d424..16173660cac 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -220,7 +220,7 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)
%type <node> declaration
%type <node> declaration_statement
%type <node> jump_statement
-%type <node> uniform_block
+%type <node> uniform_block basic_uniform_block
%type <struct_specifier> struct_specifier
%type <declarator_list> struct_declaration_list
%type <declarator_list> struct_declaration
@@ -1884,31 +1884,26 @@ function_definition:
/* layout_qualifieropt is packed into this rule */
uniform_block:
- UNIFORM NEW_IDENTIFIER '{' member_list '}' ';'
+ basic_uniform_block
{
- void *ctx = state;
- $$ = new(ctx) ast_uniform_block(*state->default_uniform_qualifier,
- $2, $4);
-
- 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");
- }
+ $$ = $1;
}
- | layout_qualifier UNIFORM NEW_IDENTIFIER '{' member_list '}' ';'
+ | layout_qualifier basic_uniform_block
{
- void *ctx = state;
-
- ast_type_qualifier qual = *state->default_uniform_qualifier;
- if (!qual.merge_qualifier(& @1, state, $1)) {
+ ast_uniform_block *block = (ast_uniform_block *) $2;
+ if (!block->layout.merge_qualifier(& @1, state, $1)) {
YYERROR;
}
- $$ = new(ctx) ast_uniform_block(qual, $3, $5);
+ $$ = block;
+ }
+ ;
+
+basic_uniform_block:
+ UNIFORM NEW_IDENTIFIER '{' member_list '}' ';'
+ {
+ void *ctx = state;
+ $$ = new(ctx) ast_uniform_block(*state->default_uniform_qualifier,
+ $2, $4);
if (!state->ARB_uniform_buffer_object_enable) {
_mesa_glsl_error(& @1, state,