summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2013-07-13 19:35:02 -0700
committerKenneth Graunke <[email protected]>2013-07-18 16:57:23 -0700
commitb5d6c51e2bff2a11d8150c04e5e470be941911a7 (patch)
tree3f6469cd27515715df2964f7fc7ad46ad2f8640e
parent844307a58470f88cf895789a6f797a0722d11434 (diff)
glsl: Handle centroid qualifier ordering in C code, not the parser.
The GL_ARB_shading_language_420pack extension/GLSL 4.20 split centroid off into a new category, "auxiliary storage qualifiers," and allow these to be placed anywhere in the series. So we have to stop recognizing "centroid in"/"centroid out"/"centroid varying" in the grammar and get more creative. The same approach used before works here, too. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
-rw-r--r--src/glsl/glsl_parser.yy50
1 files changed, 30 insertions, 20 deletions
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 5a7db874df2..718531cea8a 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -162,6 +162,7 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)
%type <node> simple_statement
%type <n> precision_qualifier
%type <type_qualifier> type_qualifier
+%type <type_qualifier> auxiliary_storage_qualifier
%type <type_qualifier> storage_qualifier
%type <type_qualifier> interpolation_qualifier
%type <type_qualifier> layout_qualifier
@@ -1325,6 +1326,7 @@ type_qualifier:
memset(& $$, 0, sizeof($$));
$$.flags.q.invariant = 1;
}
+ | auxiliary_storage_qualifier
| storage_qualifier
| interpolation_qualifier
| layout_qualifier
@@ -1338,13 +1340,13 @@ type_qualifier:
* In GLSL 4.20, these can be specified in any order. In earlier versions,
* they appear in this order (see GLSL 1.50 section 4.7 & comments below):
*
- * invariant interpolation storage precision ...or...
+ * invariant interpolation auxiliary storage precision ...or...
* layout storage precision
*
* Each qualifier's rule ensures that the accumulated qualifiers on the right
* side don't contain any that must appear on the left hand side.
* For example, when processing a storage qualifier, we check that there are
- * no interpolation, layout, or invariant qualifiers to the right.
+ * no auxiliary, interpolation, layout, or invariant qualifiers to the right.
*/
| INVARIANT type_qualifier
{
@@ -1410,6 +1412,20 @@ type_qualifier:
$$ = $1;
$$.merge_qualifier(&@1, state, $2);
}
+ | auxiliary_storage_qualifier type_qualifier
+ {
+ if ($2.has_auxiliary_storage()) {
+ _mesa_glsl_error(&@1, state,
+ "Duplicate auxiliary storage qualifier (centroid).\n");
+ }
+
+ if ($2.flags.q.invariant || $2.has_interpolation() || $2.has_layout()) {
+ _mesa_glsl_error(&@1, state, "Auxiliary storage qualifiers must come "
+ "just before storage qualifiers.\n");
+ }
+ $$ = $1;
+ $$.flags.i |= $2.flags.i;
+ }
| storage_qualifier type_qualifier
{
/* Section 4.3 of the GLSL 1.20 specification states:
@@ -1420,9 +1436,11 @@ type_qualifier:
_mesa_glsl_error(&@1, state, "Duplicate storage qualifier.\n");
if (!state->ARB_shading_language_420pack_enable &&
- ($2.flags.q.invariant || $2.has_interpolation() || $2.has_layout())) {
+ ($2.flags.q.invariant || $2.has_interpolation() || $2.has_layout() ||
+ $2.has_auxiliary_storage())) {
_mesa_glsl_error(&@1, state, "Storage qualifiers must come after "
- "invariant, interpolation, and layout qualifiers.\n");
+ "invariant, interpolation, layout and auxiliary "
+ "storage qualifiers.\n");
}
$$ = $1;
@@ -1441,6 +1459,14 @@ type_qualifier:
}
;
+auxiliary_storage_qualifier:
+ CENTROID
+ {
+ memset(& $$, 0, sizeof($$));
+ $$.flags.q.centroid = 1;
+ }
+ /* TODO: "sample" and "patch" also go here someday. */
+
storage_qualifier:
CONST_TOK
{
@@ -1457,12 +1483,6 @@ storage_qualifier:
memset(& $$, 0, sizeof($$));
$$.flags.q.varying = 1;
}
- | CENTROID VARYING
- {
- memset(& $$, 0, sizeof($$));
- $$.flags.q.centroid = 1;
- $$.flags.q.varying = 1;
- }
| IN_TOK
{
memset(& $$, 0, sizeof($$));
@@ -1473,16 +1493,6 @@ storage_qualifier:
memset(& $$, 0, sizeof($$));
$$.flags.q.out = 1;
}
- | CENTROID IN_TOK
- {
- memset(& $$, 0, sizeof($$));
- $$.flags.q.centroid = 1; $$.flags.q.in = 1;
- }
- | CENTROID OUT_TOK
- {
- memset(& $$, 0, sizeof($$));
- $$.flags.q.centroid = 1; $$.flags.q.out = 1;
- }
| UNIFORM
{
memset(& $$, 0, sizeof($$));