#include "glsl_types.h"
#include "main/context.h"
-#define YYLEX_PARAM state->scanner
-
#undef yyerror
static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)
{
_mesa_glsl_error(loc, st, "%s", msg);
}
+
+static int
+_mesa_glsl_lex(YYSTYPE *val, YYLTYPE *loc, _mesa_glsl_parse_state *state)
+{
+ return _mesa_glsl_lexer_lex(val, loc, state->scanner);
+}
+
+static bool match_layout_qualifier(const char *s1, const char *s2,
+ _mesa_glsl_parse_state *state)
+{
+ /* From the GLSL 1.50 spec, section 4.3.8 (Layout Qualifiers):
+ *
+ * "The tokens in any layout-qualifier-id-list ... are not case
+ * sensitive, unless explicitly noted otherwise."
+ *
+ * The text "unless explicitly noted otherwise" appears to be
+ * vacuous--no desktop GLSL spec (up through GLSL 4.40) notes
+ * otherwise.
+ *
+ * However, the GLSL ES 3.00 spec says, in section 4.3.8 (Layout
+ * Qualifiers):
+ *
+ * "As for other identifiers, they are case sensitive."
+ *
+ * So we need to do a case-sensitive or a case-insensitive match,
+ * depending on whether we are compiling for GLSL ES.
+ */
+ if (state->es_shader)
+ return strcmp(s1, s2);
+ else
+ return strcasecmp(s1, s2);
+}
%}
%expect 0
@$.source = 0;
}
-%lex-param {void *scanner}
+%lex-param {struct _mesa_glsl_parse_state *state}
%parse-param {struct _mesa_glsl_parse_state *state}
%union {
%token SAMPLER2DMS ISAMPLER2DMS USAMPLER2DMS
%token SAMPLER2DMSARRAY ISAMPLER2DMSARRAY USAMPLER2DMSARRAY
%token SAMPLEREXTERNALOES
+%token ATOMIC_UINT
%token STRUCT VOID_TOK WHILE
%token <identifier> IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER
%type <identifier> any_identifier
%token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4
%token SAMPLER3DRECT
%token SIZEOF CAST NAMESPACE USING
-%token COHERENT RESTRICT READONLY WRITEONLY RESOURCE ATOMIC_UINT PATCH SAMPLE
+%token COHERENT RESTRICT READONLY WRITEONLY RESOURCE PATCH SAMPLE
%token SUBROUTINE
%token ERROR_TOK
%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
%type <type_qualifier> interface_block_layout_qualifier
%type <type_qualifier> interface_qualifier
%type <type_specifier> type_specifier
-%type <type_specifier> type_specifier_no_prec
%type <type_specifier> type_specifier_nonarray
%type <identifier> basic_type_specifier_nonarray
%type <fully_specified_type> fully_specified_type
%type <node> for_init_statement
%type <for_rest_statement> for_rest_statement
%type <n> integer_constant
+%type <node> layout_defaults
%right THEN ELSE
%%
if (!state->is_version(120, 100)) {
_mesa_glsl_warning(& @1, state,
"pragma `invariant(all)' not supported in %s "
- "(GLSL ES 1.00 or GLSL 1.20 required).",
+ "(GLSL ES 1.00 or GLSL 1.20 required)",
state->get_version_string());
} else {
state->all_invariant = true;
{
$$ = $1;
}
- | PRECISION precision_qualifier type_specifier_no_prec ';'
+ | PRECISION precision_qualifier type_specifier ';'
{
- $3->precision = $2;
- $3->is_precision_statement = true;
+ $3->default_precision = $2;
$$ = $3;
}
| interface_block
| CONST_TOK parameter_qualifier
{
if ($2.flags.q.constant)
- _mesa_glsl_error(&@1, state, "duplicate const qualifier.\n");
+ _mesa_glsl_error(&@1, state, "duplicate const qualifier");
$$ = $2;
$$.flags.q.constant = 1;
| parameter_direction_qualifier parameter_qualifier
{
if (($1.flags.q.in || $1.flags.q.out) && ($2.flags.q.in || $2.flags.q.out))
- _mesa_glsl_error(&@1, state, "duplicate in/out/inout qualifier\n");
+ _mesa_glsl_error(&@1, state, "duplicate in/out/inout qualifier");
if (!state->ARB_shading_language_420pack_enable && $2.flags.q.constant)
_mesa_glsl_error(&@1, state, "const must be specified before "
- "in/out/inout.\n");
+ "in/out/inout");
$$ = $1;
$$.merge_qualifier(&@1, state, $2);
}
+ | precision_qualifier parameter_qualifier
+ {
+ if ($2.precision != ast_precision_none)
+ _mesa_glsl_error(&@1, state, "duplicate precision qualifier");
+
+ if (!state->ARB_shading_language_420pack_enable && $2.flags.i != 0)
+ _mesa_glsl_error(&@1, state, "precision qualifiers must come last");
+
+ $$ = $2;
+ $$.precision = $1;
+ }
parameter_direction_qualifier:
IN_TOK
memset(& $$, 0, sizeof($$));
/* Layout qualifiers for ARB_fragment_coord_conventions. */
- if (!$$.flags.i && state->ARB_fragment_coord_conventions_enable) {
- if (strcmp($1, "origin_upper_left") == 0) {
+ if (!$$.flags.i && (state->ARB_fragment_coord_conventions_enable ||
+ state->is_version(150, 0))) {
+ if (match_layout_qualifier($1, "origin_upper_left", state) == 0) {
$$.flags.q.origin_upper_left = 1;
- } else if (strcmp($1, "pixel_center_integer") == 0) {
+ } else if (match_layout_qualifier($1, "pixel_center_integer",
+ state) == 0) {
$$.flags.q.pixel_center_integer = 1;
}
if ($$.flags.i && state->ARB_fragment_coord_conventions_warn) {
_mesa_glsl_warning(& @1, state,
"GL_ARB_fragment_coord_conventions layout "
- "identifier `%s' used\n", $1);
+ "identifier `%s' used", $1);
}
}
if (!$$.flags.i &&
(state->AMD_conservative_depth_enable ||
state->ARB_conservative_depth_enable)) {
- if (strcmp($1, "depth_any") == 0) {
+ if (match_layout_qualifier($1, "depth_any", state) == 0) {
$$.flags.q.depth_any = 1;
- } else if (strcmp($1, "depth_greater") == 0) {
+ } else if (match_layout_qualifier($1, "depth_greater", state) == 0) {
$$.flags.q.depth_greater = 1;
- } else if (strcmp($1, "depth_less") == 0) {
+ } else if (match_layout_qualifier($1, "depth_less", state) == 0) {
$$.flags.q.depth_less = 1;
- } else if (strcmp($1, "depth_unchanged") == 0) {
+ } else if (match_layout_qualifier($1, "depth_unchanged",
+ state) == 0) {
$$.flags.q.depth_unchanged = 1;
}
if ($$.flags.i && state->AMD_conservative_depth_warn) {
_mesa_glsl_warning(& @1, state,
"GL_AMD_conservative_depth "
- "layout qualifier `%s' is used\n", $1);
+ "layout qualifier `%s' is used", $1);
}
if ($$.flags.i && state->ARB_conservative_depth_warn) {
_mesa_glsl_warning(& @1, state,
"GL_ARB_conservative_depth "
- "layout qualifier `%s' is used\n", $1);
+ "layout qualifier `%s' is used", $1);
}
}
/* See also interface_block_layout_qualifier. */
- if (!$$.flags.i && state->ARB_uniform_buffer_object_enable) {
- if (strcmp($1, "std140") == 0) {
+ if (!$$.flags.i && state->has_uniform_buffer_objects()) {
+ if (match_layout_qualifier($1, "std140", state) == 0) {
$$.flags.q.std140 = 1;
- } else if (strcmp($1, "shared") == 0) {
+ } else if (match_layout_qualifier($1, "shared", state) == 0) {
$$.flags.q.shared = 1;
- } else if (strcmp($1, "column_major") == 0) {
+ } else if (match_layout_qualifier($1, "column_major", state) == 0) {
$$.flags.q.column_major = 1;
/* "row_major" is a reserved word in GLSL 1.30+. Its token is parsed
* below in the interface_block_layout_qualifier rule.
*
* It is not a reserved word in GLSL ES 3.00, so it's handled here as
* an identifier.
+ *
+ * Also, this takes care of alternate capitalizations of
+ * "row_major" (which is necessary because layout qualifiers
+ * are case-insensitive in desktop GLSL).
*/
- } else if (strcmp($1, "row_major") == 0) {
+ } else if (match_layout_qualifier($1, "row_major", state) == 0) {
$$.flags.q.row_major = 1;
+ /* "packed" is a reserved word in GLSL, and its token is
+ * parsed below in the interface_block_layout_qualifier rule.
+ * However, we must take care of alternate capitalizations of
+ * "packed", because layout qualifiers are case-insensitive
+ * in desktop GLSL.
+ */
+ } else if (match_layout_qualifier($1, "packed", state) == 0) {
+ $$.flags.q.packed = 1;
}
if ($$.flags.i && state->ARB_uniform_buffer_object_warn) {
_mesa_glsl_warning(& @1, state,
"#version 140 / GL_ARB_uniform_buffer_object "
- "layout qualifier `%s' is used\n", $1);
+ "layout qualifier `%s' is used", $1);
+ }
+ }
+
+ /* Layout qualifiers for GLSL 1.50 geometry shaders. */
+ if (!$$.flags.i) {
+ struct {
+ const char *s;
+ GLenum e;
+ } map[] = {
+ { "points", GL_POINTS },
+ { "lines", GL_LINES },
+ { "lines_adjacency", GL_LINES_ADJACENCY },
+ { "line_strip", GL_LINE_STRIP },
+ { "triangles", GL_TRIANGLES },
+ { "triangles_adjacency", GL_TRIANGLES_ADJACENCY },
+ { "triangle_strip", GL_TRIANGLE_STRIP },
+ };
+ for (unsigned i = 0; i < Elements(map); i++) {
+ if (match_layout_qualifier($1, map[i].s, state) == 0) {
+ $$.flags.q.prim_type = 1;
+ $$.prim_type = map[i].e;
+ break;
+ }
+ }
+
+ if ($$.flags.i && !state->is_version(150, 0)) {
+ _mesa_glsl_error(& @1, state, "#version 150 layout "
+ "qualifier `%s' used", $1);
}
}
if (!$$.flags.i) {
_mesa_glsl_error(& @1, state, "unrecognized layout identifier "
- "`%s'\n", $1);
+ "`%s'", $1);
YYERROR;
}
}
{
memset(& $$, 0, sizeof($$));
- if (state->ARB_explicit_attrib_location_enable) {
- if (strcmp("location", $1) == 0) {
- $$.flags.q.explicit_location = 1;
+ if (match_layout_qualifier("location", $1, state) == 0) {
+ $$.flags.q.explicit_location = 1;
- if ($3 >= 0) {
- $$.location = $3;
- } else {
- _mesa_glsl_error(& @3, state,
- "invalid location %d specified\n", $3);
- YYERROR;
- }
+ if ($3 >= 0) {
+ $$.location = $3;
+ } else {
+ _mesa_glsl_error(& @3, state, "invalid location %d specified", $3);
+ YYERROR;
}
+ }
+
+ if (match_layout_qualifier("index", $1, state) == 0) {
+ $$.flags.q.explicit_index = 1;
+
+ if ($3 >= 0) {
+ $$.index = $3;
+ } else {
+ _mesa_glsl_error(& @3, state, "invalid index %d specified", $3);
+ YYERROR;
+ }
+ }
- if (strcmp("index", $1) == 0) {
- $$.flags.q.explicit_index = 1;
+ if ((state->ARB_shading_language_420pack_enable ||
+ state->ARB_shader_atomic_counters_enable) &&
+ match_layout_qualifier("binding", $1, state) == 0) {
+ $$.flags.q.explicit_binding = 1;
+ $$.binding = $3;
+ }
+
+ if (state->ARB_shader_atomic_counters_enable &&
+ match_layout_qualifier("offset", $1, state) == 0) {
+ $$.flags.q.explicit_offset = 1;
+ $$.offset = $3;
+ }
+
+ if (match_layout_qualifier("max_vertices", $1, state) == 0) {
+ $$.flags.q.max_vertices = 1;
- if ($3 >= 0) {
- $$.index = $3;
- } else {
+ if ($3 < 0) {
+ _mesa_glsl_error(& @3, state,
+ "invalid max_vertices %d specified", $3);
+ YYERROR;
+ } else {
+ $$.max_vertices = $3;
+ if (!state->is_version(150, 0)) {
_mesa_glsl_error(& @3, state,
- "invalid index %d specified\n", $3);
- YYERROR;
+ "#version 150 max_vertices qualifier "
+ "specified", $3);
}
}
}
*/
if (!$$.flags.i) {
_mesa_glsl_error(& @1, state, "unrecognized layout identifier "
- "`%s'\n", $1);
+ "`%s'", $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);
+ "identifier `%s' used", $1);
}
}
| interface_block_layout_qualifier
{
$$ = $1;
/* Layout qualifiers for ARB_uniform_buffer_object. */
- if ($$.flags.q.uniform && !state->ARB_uniform_buffer_object_enable) {
+ if ($$.flags.q.uniform && !state->has_uniform_buffer_objects()) {
_mesa_glsl_error(& @1, state,
"#version 140 / GL_ARB_uniform_buffer_object "
- "layout qualifier `%s' is used\n", $1);
+ "layout qualifier `%s' is used", $1);
} else if ($$.flags.q.uniform && state->ARB_uniform_buffer_object_warn) {
_mesa_glsl_warning(& @1, state,
"#version 140 / GL_ARB_uniform_buffer_object "
- "layout qualifier `%s' is used\n", $1);
+ "layout qualifier `%s' is used", $1);
}
}
;
* (due to them being reserved keywords) instead of identifiers like
* most qualifiers. See the any_identifier path of
* layout_qualifier_id for the others.
+ *
+ * Note that since layout qualifiers are case-insensitive in desktop
+ * GLSL, all of these qualifiers need to be handled as identifiers as
+ * well (by the any_identifier path of layout_qualifier_id).
*/
interface_block_layout_qualifier:
ROW_MAJOR
memset(& $$, 0, sizeof($$));
$$.flags.q.invariant = 1;
}
+ | auxiliary_storage_qualifier
| storage_qualifier
| interpolation_qualifier
| layout_qualifier
+ | precision_qualifier
+ {
+ memset(&$$, 0, sizeof($$));
+ $$.precision = $1;
+ }
/* Multiple qualifiers:
* 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
{
if ($2.flags.q.invariant)
- _mesa_glsl_error(&@1, state, "Duplicate \"invariant\" qualifier.\n");
+ _mesa_glsl_error(&@1, state, "duplicate \"invariant\" qualifier");
if ($2.has_layout()) {
_mesa_glsl_error(&@1, state,
- "\"invariant\" cannot be used with layout(...).\n");
+ "\"invariant\" cannot be used with layout(...)");
}
$$ = $2;
* only one after all, and the 1.40 text is a clarification, not a change.
*/
if ($2.has_interpolation())
- _mesa_glsl_error(&@1, state, "Duplicate interpolation qualifier.\n");
+ _mesa_glsl_error(&@1, state, "duplicate interpolation qualifier");
if ($2.has_layout()) {
- _mesa_glsl_error(&@1, state, "Interpolation qualifiers cannot be used "
- "with layout(...).\n");
+ _mesa_glsl_error(&@1, state, "interpolation qualifiers cannot be used "
+ "with layout(...)");
}
if (!state->ARB_shading_language_420pack_enable && $2.flags.q.invariant) {
- _mesa_glsl_error(&@1, state, "Interpolation qualifiers must come "
- "after \"invariant\".\n");
+ _mesa_glsl_error(&@1, state, "interpolation qualifiers must come "
+ "after \"invariant\"");
}
$$ = $1;
* qualifier, but always seems to in examples.
*/
if (!state->ARB_shading_language_420pack_enable && $2.has_layout())
- _mesa_glsl_error(&@1, state, "Duplicate layout(...) qualifiers.\n");
+ _mesa_glsl_error(&@1, state, "duplicate layout(...) qualifiers");
if ($2.flags.q.invariant)
_mesa_glsl_error(&@1, state, "layout(...) cannot be used with "
- "the \"invariant\" qualifier\n");
+ "the \"invariant\" qualifier");
if ($2.has_interpolation()) {
_mesa_glsl_error(&@1, state, "layout(...) cannot be used with "
- "interpolation qualifiers.\n");
+ "interpolation qualifiers");
}
$$ = $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)");
+ }
+
+ if (!state->ARB_shading_language_420pack_enable &&
+ ($2.flags.q.invariant || $2.has_interpolation() || $2.has_layout())) {
+ _mesa_glsl_error(&@1, state, "auxiliary storage qualifiers must come "
+ "just before storage qualifiers");
+ }
+ $$ = $1;
+ $$.flags.i |= $2.flags.i;
+ }
| storage_qualifier type_qualifier
{
/* Section 4.3 of the GLSL 1.20 specification states:
* 1.30 clarifies this to "may have one storage qualifier".
*/
if ($2.has_storage())
- _mesa_glsl_error(&@1, state, "Duplicate storage qualifier.\n");
+ _mesa_glsl_error(&@1, state, "duplicate storage qualifier");
if (!state->ARB_shading_language_420pack_enable &&
- ($2.flags.q.invariant || $2.has_interpolation() || $2.has_layout())) {
- _mesa_glsl_error(&@1, state, "Storage qualifiers must come after "
- "invariant, interpolation, and layout qualifiers.\n");
+ ($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, layout and auxiliary "
+ "storage qualifiers");
}
$$ = $1;
$$.merge_qualifier(&@1, state, $2);
}
+ | precision_qualifier type_qualifier
+ {
+ if ($2.precision != ast_precision_none)
+ _mesa_glsl_error(&@1, state, "duplicate precision qualifier");
+
+ if (!state->ARB_shading_language_420pack_enable && $2.flags.i != 0)
+ _mesa_glsl_error(&@1, state, "precision qualifiers must come last");
+
+ $$ = $2;
+ $$.precision = $1;
+ }
;
+auxiliary_storage_qualifier:
+ CENTROID
+ {
+ memset(& $$, 0, sizeof($$));
+ $$.flags.q.centroid = 1;
+ }
+ /* TODO: "sample" and "patch" also go here someday. */
+
storage_qualifier:
CONST_TOK
{
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($$));
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($$));
;
type_specifier:
- type_specifier_no_prec
- {
- $$ = $1;
- }
- | precision_qualifier type_specifier_no_prec
- {
- $$ = $2;
- $$->precision = $1;
- }
- ;
-
-type_specifier_no_prec:
type_specifier_nonarray
| type_specifier_nonarray '[' ']'
{
| SAMPLER2DMSARRAY { $$ = "sampler2DMSArray"; }
| ISAMPLER2DMSARRAY { $$ = "isampler2DMSArray"; }
| USAMPLER2DMSARRAY { $$ = "usampler2DMSArray"; }
+ | ATOMIC_UINT { $$ = "atomic_uint"; }
;
precision_qualifier:
;
struct_declaration:
- type_specifier struct_declarator_list ';'
+ fully_specified_type struct_declarator_list ';'
{
void *ctx = state;
- ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
+ ast_fully_specified_type *const type = $1;
type->set_location(yylloc);
- type->specifier = $1;
+ if (type->qualifier.flags.i != 0)
+ _mesa_glsl_error(&@1, state,
+ "only precision qualifiers may be applied to "
+ "structure members");
+
$$ = new(ctx) ast_declarator_list(type);
$$->set_location(yylloc);
$$ = new(ctx) ast_declaration($1, false, NULL, NULL);
$$->set_location(yylloc);
}
+ | any_identifier '[' ']'
+ {
+ void *ctx = state;
+ $$ = new(ctx) ast_declaration($1, true, NULL, NULL);
+ $$->set_location(yylloc);
+ }
| any_identifier '[' constant_expression ']'
{
void *ctx = state;
statement
{
if ($1 == NULL) {
- _mesa_glsl_error(& @1, state, "<nil> statement\n");
+ _mesa_glsl_error(& @1, state, "<nil> statement");
assert($1 != NULL);
}
| statement_list statement
{
if ($2 == NULL) {
- _mesa_glsl_error(& @2, state, "<nil> statement\n");
+ _mesa_glsl_error(& @2, state, "<nil> statement");
assert($2 != NULL);
}
$$ = $1;
function_definition { $$ = $1; }
| declaration { $$ = $1; }
| pragma_statement { $$ = NULL; }
- | layout_defaults { $$ = NULL; }
+ | layout_defaults { $$ = $1; }
;
function_definition:
block->declarations.push_degenerate_list_at_head(& $4->link);
if ($1.flags.q.uniform) {
- if (!state->ARB_uniform_buffer_object_enable) {
+ if (!state->has_uniform_buffer_objects()) {
_mesa_glsl_error(& @1, state,
"#version 140 / GL_ARB_uniform_buffer_object "
- "required for defining uniform blocks\n");
+ "required for defining uniform blocks");
} else if (state->ARB_uniform_buffer_object_warn) {
_mesa_glsl_warning(& @1, state,
"#version 140 / GL_ARB_uniform_buffer_object "
- "required for defining uniform blocks\n");
+ "required for defining uniform blocks");
}
} else {
if (state->es_shader || state->language_version < 150) {
_mesa_glsl_error(& @1, state,
"#version 150 required for using "
- "interface blocks.\n");
+ "interface blocks");
}
}
if ((state->target == vertex_shader) && $1.flags.q.in) {
_mesa_glsl_error(& @1, state,
"`in' interface block is not allowed for "
- "a vertex shader\n");
+ "a vertex shader");
} else if ((state->target == fragment_shader) && $1.flags.q.out) {
_mesa_glsl_error(& @1, state,
"`out' interface block is not allowed for "
- "a fragment shader\n");
+ "a fragment shader");
}
/* Since block arrays require names, and both features are added in
_mesa_glsl_error(& @1, state,
"uniform/in/out qualifier on "
"interface block member does not match "
- "the interface block\n");
+ "the interface block");
}
}
/* empty */
{
$$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
- NULL, NULL);
+ NULL, false, NULL);
}
| NEW_IDENTIFIER
{
$$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
- $1, NULL);
+ $1, false, NULL);
}
| NEW_IDENTIFIER '[' constant_expression ']'
{
$$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
- $1, $3);
+ $1, true, $3);
}
| NEW_IDENTIFIER '[' ']'
{
- _mesa_glsl_error(& @1, state,
- "instance block arrays must be explicitly sized\n");
-
$$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
- $1, NULL);
+ $1, true, NULL);
}
;
if (type->qualifier.flags.q.attribute) {
_mesa_glsl_error(& @1, state,
"keyword 'attribute' cannot be used with "
- "interface block member\n");
+ "interface block member");
} else if (type->qualifier.flags.q.varying) {
_mesa_glsl_error(& @1, state,
"keyword 'varying' cannot be used with "
- "interface block member\n");
+ "interface block member");
}
$$ = new(ctx) ast_declarator_list(type);
$$->set_location(yylloc);
- $$->ubo_qualifiers_valid = true;
$$->declarations.push_degenerate_list_at_head(& $2->link);
}
if (!state->default_uniform_qualifier->merge_qualifier(& @1, state, $1)) {
YYERROR;
}
+ $$ = NULL;
+ }
+
+ | layout_qualifier IN_TOK ';'
+ {
+ void *ctx = state;
+ $$ = NULL;
+ if (state->target != geometry_shader) {
+ _mesa_glsl_error(& @1, state,
+ "input layout qualifiers only valid in "
+ "geometry shaders");
+ } else if (!$1.flags.q.prim_type) {
+ _mesa_glsl_error(& @1, state,
+ "input layout qualifiers must specify a primitive"
+ " type");
+ } else {
+ /* Make sure this is a valid input primitive type. */
+ switch ($1.prim_type) {
+ case GL_POINTS:
+ case GL_LINES:
+ case GL_LINES_ADJACENCY:
+ case GL_TRIANGLES:
+ case GL_TRIANGLES_ADJACENCY:
+ $$ = new(ctx) ast_gs_input_layout(@1, $1.prim_type);
+ break;
+ default:
+ _mesa_glsl_error(&@1, state,
+ "invalid geometry shader input primitive type");
+ break;
+ }
+ }
+ }
+
+ | layout_qualifier OUT_TOK ';'
+ {
+ if (state->target != geometry_shader) {
+ _mesa_glsl_error(& @1, state,
+ "out layout qualifiers only valid in "
+ "geometry shaders");
+ } else {
+ if ($1.flags.q.prim_type) {
+ /* Make sure this is a valid output primitive type. */
+ switch ($1.prim_type) {
+ case GL_POINTS:
+ case GL_LINE_STRIP:
+ case GL_TRIANGLE_STRIP:
+ break;
+ default:
+ _mesa_glsl_error(&@1, state, "invalid geometry shader output "
+ "primitive type");
+ break;
+ }
+ }
+ if (!state->out_qualifier->merge_qualifier(& @1, state, $1))
+ YYERROR;
+ }
+ $$ = NULL;
}