From 4f29169913f99252c54e1922f6d164e2ef530a58 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Nov 2012 00:18:02 -0800 Subject: glsl: Track UBO block names in the symbol table. The GLSL 1.40 spec says: "Uniform block names and variable names declared within uniform blocks are scoped at the program level." Track the block name in the symbol table and emit errors when conflicts exist. Fixes es3conform's uniform_buffer_object_block_name_conflict test, and fixes the piglit block-name-clashes-with-{variable,function,struct}.vert tests. NOTE: This is a candidate for the 9.0 branch. v2: Fix bad constructor initialization. Noticed by Topi Pohjolainen. Reviewed-by: Ian Romanick --- src/glsl/ast_to_hir.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/glsl/ast_to_hir.cpp') diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index ea5e3b773e3..31dd51aa921 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -4132,6 +4132,12 @@ ast_uniform_block::hir(exec_list *instructions, struct gl_uniform_block *ubo = get_next_uniform_block(state); ubo->Name = ralloc_strdup(state->uniform_blocks, this->block_name); + if (!state->symbols->add_uniform_block(ubo)) { + YYLTYPE loc = this->get_location(); + _mesa_glsl_error(&loc, state, "Uniform block name `%s' already taken in " + "the current scope.\n", ubo->Name); + } + unsigned int num_variables = 0; foreach_list_typed(ast_declarator_list, decl_list, link, &declarations) { foreach_list_const(node, &decl_list->declarations) { -- cgit v1.2.3