diff options
author | Ian Romanick <[email protected]> | 2010-06-30 17:30:03 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2010-07-28 14:14:38 -0700 |
commit | f50f06552eb1e4af27d6fe99c381eac6a0a4ea0f (patch) | |
tree | 76891e2f6c5f116f1feb30e36155d52269d3cfa2 /src/glsl/glsl_parser.ypp | |
parent | b706283c79de41caf775b0bb15b3c849932f2574 (diff) |
glsl2: Parser support for GL_ARB_fragment_coord_conventions
Diffstat (limited to 'src/glsl/glsl_parser.ypp')
-rw-r--r-- | src/glsl/glsl_parser.ypp | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index 6782255d45c..53132d9067d 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -97,6 +97,7 @@ %token LOWP MEDIUMP HIGHP PRECISION %token VERSION EXTENSION LINE PRAGMA COLON EOL INTERFACE OUTPUT +%token LAYOUT_TOK /* Reserved words that are not actually used in the grammar. */ @@ -117,6 +118,8 @@ %type <type_qualifier> type_qualifier %type <type_qualifier> storage_qualifier %type <type_qualifier> interpolation_qualifier +%type <type_qualifier> opt_layout_qualifier layout_qualifier +%type <type_qualifier> layout_qualifier_id_list layout_qualifier_id %type <type_specifier> type_specifier %type <type_specifier> type_specifier_no_prec %type <type_specifier> type_specifier_nonarray @@ -929,6 +932,60 @@ fully_specified_type: } ; +opt_layout_qualifier: + { $$.i = 0; } + | layout_qualifier + ; + +layout_qualifier: + LAYOUT_TOK '(' layout_qualifier_id_list ')' + { + $$ = $3; + } + ; + +layout_qualifier_id_list: + layout_qualifier_id + | layout_qualifier_id_list ',' layout_qualifier_id + { + $$.i = $1.i | $3.i; + } + ; + +layout_qualifier_id: + IDENTIFIER + { + $$.i = 0; + + if (state->ARB_fragment_coord_conventions_enable) { + bool got_one = false; + + if (strcmp($1, "origin_upper_left") == 0) { + got_one = true; + $$.q.origin_upper_left = 1; + } else if (strcmp($1, "pixel_center_integer") == 0) { + got_one = true; + $$.q.pixel_center_integer = 1; + } + + if (state->ARB_fragment_coord_conventions_warn && got_one) { + _mesa_glsl_warning(& @1, state, + "GL_ARB_fragment_coord_conventions layout " + "identifier `%s' used\n", $1); + } + } + + /* If the identifier didn't match any known layout identifiers, + * emit an error. + */ + if ($$.i == 0) { + _mesa_glsl_error(& @1, state, "unrecognized layout identifier " + "`%s'\n", $1); + YYERROR; + } + } + ; + interpolation_qualifier: SMOOTH { $$.i = 0; $$.q.smooth = 1; } | FLAT { $$.i = 0; $$.q.flat = 1; } @@ -955,9 +1012,9 @@ type_qualifier: storage_qualifier: CONST_TOK { $$.i = 0; $$.q.constant = 1; } | ATTRIBUTE { $$.i = 0; $$.q.attribute = 1; } - | VARYING { $$.i = 0; $$.q.varying = 1; } + | opt_layout_qualifier VARYING { $$.i = $1.i; $$.q.varying = 1; } | CENTROID VARYING { $$.i = 0; $$.q.centroid = 1; $$.q.varying = 1; } - | IN { $$.i = 0; $$.q.in = 1; } + | opt_layout_qualifier IN { $$.i = 0; $$.q.in = 1; } | OUT { $$.i = 0; $$.q.out = 1; } | CENTROID IN { $$.i = 0; $$.q.centroid = 1; $$.q.in = 1; } | CENTROID OUT { $$.i = 0; $$.q.centroid = 1; $$.q.out = 1; } |