From 7f68cbdc4d9f602dc2619ac4a90283a4f057a8cb Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 5 Oct 2010 17:00:31 -0700 Subject: glsl: Add parser support for GL_ARB_explicit_attrib_location layouts Only layout(location=#) is supported. Setting the index requires GLSL 1.30 and GL_ARB_blend_func_extended. --- src/glsl/glsl_parser.ypp | 55 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) (limited to 'src/glsl/glsl_parser.ypp') diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index 16d39dc565..ed18179beb 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -983,10 +983,19 @@ layout_qualifier_id_list: layout_qualifier_id | layout_qualifier_id_list ',' layout_qualifier_id { - /* FINISHME: Should check for conflicting / duplicate flags here. - */ - $$ = $1; - $$.flags.i |= $3.flags.i; + if (($1.flags.i & $3.flags.i) != 0) { + _mesa_glsl_error(& @3, state, + "duplicate layout qualifiers used\n"); + YYERROR; + } + + $$.flags.i = $1.flags.i | $3.flags.i; + + if ($1.flags.q.explicit_location) + $$.location = $1.location; + + if ($3.flags.q.explicit_location) + $$.location = $3.location; } ; @@ -1020,6 +1029,44 @@ layout_qualifier_id: "identifier `%s' used\n", $1); } } + | IDENTIFIER '=' INTCONSTANT + { + bool got_one = false; + + memset(& $$, 0, sizeof($$)); + + if (state->ARB_explicit_attrib_location_enable) { + /* FINISHME: Handle 'index' once GL_ARB_blend_func_exteneded and + * FINISHME: GLSL 1.30 (or later) are supported. + */ + if (strcmp("location", $1) == 0) { + got_one = true; + + $$.flags.q.explicit_location = 1; + + if ($3 >= 0) { + $$.location = $3; + } else { + _mesa_glsl_error(& @3, state, + "invalid location %d specified\n", $3); + YYERROR; + } + } + } + + /* If the identifier didn't match any known layout identifiers, + * emit an error. + */ + if (!got_one) { + _mesa_glsl_error(& @1, state, "unrecognized layout identifier " + "`%s'\n", $1); + YYERROR; + } else if (state->ARB_explicit_attrib_location_warn) { + _mesa_glsl_warning(& @1, state, + "GL_ARB_explicit_attrib_location layout " + "identifier `%s' used\n", $1); + } + } ; interpolation_qualifier: -- cgit v1.2.3