glsl2: Parser support for GL_ARB_fragment_coord_conventions

This commit is contained in:
Ian Romanick 2010-06-30 17:30:03 -07:00 committed by Eric Anholt
parent b706283c79
commit f50f06552e
8 changed files with 2145 additions and 1937 deletions

View File

@ -302,6 +302,12 @@ struct ast_type_qualifier {
unsigned smooth:1;
unsigned flat:1;
unsigned noperspective:1;
/** \name Layout qualifiers for GL_ARB_fragment_coord_conventions */
/*@{*/
unsigned origin_upper_left:1;
unsigned pixel_center_integer:1;
/*@}*/
};
class ast_struct_specifier : public ast_node {

File diff suppressed because it is too large Load Diff

View File

@ -201,6 +201,16 @@ sampler2DShadow return SAMPLER2DSHADOW;
struct return STRUCT;
void return VOID;
layout {
if ((yyextra->language_version >= 140)
|| (yyextra->ARB_fragment_coord_conventions_enable)){
return LAYOUT_TOK;
} else {
yylval->identifier = strdup(yytext);
return IDENTIFIER;
}
}
\+\+ return INC_OP;
-- return DEC_OP;
\<= return LE_OP;

File diff suppressed because it is too large Load Diff

View File

@ -155,46 +155,47 @@
EOL = 371,
INTERFACE = 372,
OUTPUT = 373,
ASM = 374,
CLASS = 375,
UNION = 376,
ENUM = 377,
TYPEDEF = 378,
TEMPLATE = 379,
THIS = 380,
PACKED = 381,
GOTO = 382,
INLINE_TOK = 383,
NOINLINE = 384,
VOLATILE = 385,
PUBLIC_TOK = 386,
STATIC = 387,
EXTERN = 388,
EXTERNAL = 389,
LONG = 390,
SHORT = 391,
DOUBLE = 392,
HALF = 393,
FIXED = 394,
UNSIGNED = 395,
INPUT = 396,
OUPTUT = 397,
HVEC2 = 398,
HVEC3 = 399,
HVEC4 = 400,
DVEC2 = 401,
DVEC3 = 402,
DVEC4 = 403,
FVEC2 = 404,
FVEC3 = 405,
FVEC4 = 406,
SAMPLER2DRECT = 407,
SAMPLER3DRECT = 408,
SAMPLER2DRECTSHADOW = 409,
SIZEOF = 410,
CAST = 411,
NAMESPACE = 412,
USING = 413
LAYOUT_TOK = 374,
ASM = 375,
CLASS = 376,
UNION = 377,
ENUM = 378,
TYPEDEF = 379,
TEMPLATE = 380,
THIS = 381,
PACKED = 382,
GOTO = 383,
INLINE_TOK = 384,
NOINLINE = 385,
VOLATILE = 386,
PUBLIC_TOK = 387,
STATIC = 388,
EXTERN = 389,
EXTERNAL = 390,
LONG = 391,
SHORT = 392,
DOUBLE = 393,
HALF = 394,
FIXED = 395,
UNSIGNED = 396,
INPUT = 397,
OUPTUT = 398,
HVEC2 = 399,
HVEC3 = 400,
HVEC4 = 401,
DVEC2 = 402,
DVEC3 = 403,
DVEC4 = 404,
FVEC2 = 405,
FVEC3 = 406,
FVEC4 = 407,
SAMPLER2DRECT = 408,
SAMPLER3DRECT = 409,
SAMPLER2DRECTSHADOW = 410,
SIZEOF = 411,
CAST = 412,
NAMESPACE = 413,
USING = 414
};
#endif
@ -236,7 +237,7 @@ typedef union YYSTYPE
/* Line 1676 of yacc.c */
#line 240 "glsl_parser.h"
#line 241 "glsl_parser.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */

View File

@ -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; }

View File

@ -198,6 +198,13 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
state->ARB_draw_buffers_enable = (ext_mode != extension_disable);
state->ARB_draw_buffers_warn = (ext_mode == extension_warn);
}
} else if (strcmp(name, "GL_ARB_fragment_coord_conventions") == 0) {
state->ARB_fragment_coord_conventions_enable =
(ext_mode != extension_disable);
state->ARB_fragment_coord_conventions_warn =
(ext_mode == extension_warn);
unsupported = !state->extensions->ARB_fragment_coord_conventions;
} else if (strcmp(name, "GL_ARB_texture_rectangle") == 0) {
state->ARB_texture_rectangle_enable = (ext_mode != extension_disable);
state->ARB_texture_rectangle_warn = (ext_mode == extension_warn);

View File

@ -118,6 +118,8 @@ struct _mesa_glsl_parse_state {
/*@{*/
unsigned ARB_draw_buffers_enable:1;
unsigned ARB_draw_buffers_warn:1;
unsigned ARB_fragment_coord_conventions_enable:1;
unsigned ARB_fragment_coord_conventions_warn:1;
unsigned ARB_texture_rectangle_enable:1;
unsigned ARB_texture_rectangle_warn:1;
unsigned EXT_texture_array_enable:1;