summaryrefslogtreecommitdiff
path: root/src/glsl/glsl_parser.ypp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-10-05 17:00:31 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-10-08 14:21:22 -0700
commit7f68cbdc4d9f602dc2619ac4a90283a4f057a8cb (patch)
tree6a5f406c532817d3cddd651b5993d698e43cab22 /src/glsl/glsl_parser.ypp
parenteafebed5bdfd853c6ec7f7275e219378e441c49c (diff)
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.
Diffstat (limited to 'src/glsl/glsl_parser.ypp')
-rw-r--r--src/glsl/glsl_parser.ypp55
1 files changed, 51 insertions, 4 deletions
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: