public:
ast_uniform_block(ast_type_qualifier layout,
const char *block_name,
- ast_declarator_list *member_list)
- : layout(layout), block_name(block_name)
+ ast_declarator_list *member_list,
+ const char *instance_name)
+ : layout(layout), block_name(block_name), instance_name(instance_name)
{
declarations.push_degenerate_list_at_head(&member_list->link);
}
ast_type_qualifier layout;
const char *block_name;
+
+ /**
+ * Declared name of the block instance, if specified.
+ *
+ * If the block does not have an instance name, this field will be
+ * \c NULL.
+ */
+ const char *instance_name;
+
/** List of ast_declarator_list * */
exec_list declarations;
};
%token STRUCT VOID_TOK WHILE
%token <identifier> IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER
%type <identifier> any_identifier
+%type <identifier> instance_name_opt
%token <real> FLOATCONSTANT
%token <n> INTCONSTANT UINTCONSTANT BOOLCONSTANT
%token <identifier> FIELD_SELECTION
;
basic_uniform_block:
- UNIFORM NEW_IDENTIFIER '{' member_list '}' ';'
+ UNIFORM NEW_IDENTIFIER '{' member_list '}' instance_name_opt ';'
{
void *ctx = state;
$$ = new(ctx) ast_uniform_block(*state->default_uniform_qualifier,
- $2, $4);
+ $2, $4, $6);
if (!state->ARB_uniform_buffer_object_enable) {
_mesa_glsl_error(& @1, state,
}
;
+instance_name_opt:
+ /* empty */
+ {
+ $$ = NULL;
+ }
+ | NEW_IDENTIFIER
+ {
+ if (!(state->language_version == 300 && state->es_shader)) {
+ _mesa_glsl_error(& @1, state,
+ "#version 300 es required for using uniform "
+ "blocks with an instance name\n");
+ }
+ }
+ ;
+
member_list:
member_declaration
{