From 5383661092fc46cf7013052210e6d624f4d5b596 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 21 Jan 2013 23:01:33 -0500 Subject: [PATCH] glsl: Track blocks in the symbol table using the glsl_type instead of the gl_uniform_block Eventually the gl_uniform_block information won't be calculated until linking. Block names need to be checked for name clashes during compiling, so we have to track it differently. v2: Update the commit message. Suggested by Carl Worth. Signed-off-by: Ian Romanick Reviewed-by: Kenneth Graunke --- src/glsl/ast_to_hir.cpp | 12 ++++++------ src/glsl/glsl_symbol_table.cpp | 14 +++----------- src/glsl/glsl_symbol_table.h | 1 - 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index e2d7265..80a02e9 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -4219,12 +4219,6 @@ 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); - } - if (this->layout.flags.q.shared) { ubo->_Packing = ubo_packing_shared; } else if (this->layout.flags.q.packed) { @@ -4260,6 +4254,12 @@ ast_uniform_block::hir(exec_list *instructions, (enum glsl_interface_packing) ubo->_Packing, this->block_name); + if (!state->symbols->add_type(block_type->name, block_type)) { + YYLTYPE loc = this->get_location(); + _mesa_glsl_error(&loc, state, "Uniform block name `%s' already taken in " + "the current scope.\n", this->block_name); + } + /* Since interface blocks cannot contain statements, it should be * impossible for the block to generate any instructions. */ diff --git a/src/glsl/glsl_symbol_table.cpp b/src/glsl/glsl_symbol_table.cpp index eb275b1..8d34547 100644 --- a/src/glsl/glsl_symbol_table.cpp +++ b/src/glsl/glsl_symbol_table.cpp @@ -41,15 +41,13 @@ public: ralloc_free(entry); } - symbol_table_entry(ir_variable *v) : v(v), f(0), t(0), u(0) {} - symbol_table_entry(ir_function *f) : v(0), f(f), t(0), u(0) {} - symbol_table_entry(const glsl_type *t) : v(0), f(0), t(t), u(0) {} - symbol_table_entry(struct gl_uniform_block *u) : v(0), f(0), t(0), u(u) {} + symbol_table_entry(ir_variable *v) : v(v), f(0), t(0) {} + symbol_table_entry(ir_function *f) : v(0), f(f), t(0) {} + symbol_table_entry(const glsl_type *t) : v(0), f(0), t(t) {} ir_variable *v; ir_function *f; const glsl_type *t; - struct gl_uniform_block *u; }; glsl_symbol_table::glsl_symbol_table() @@ -134,12 +132,6 @@ bool glsl_symbol_table::add_function(ir_function *f) return _mesa_symbol_table_add_symbol(table, -1, f->name, entry) == 0; } -bool glsl_symbol_table::add_uniform_block(struct gl_uniform_block *u) -{ - symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(u); - return _mesa_symbol_table_add_symbol(table, -1, u->Name, entry) == 0; -} - void glsl_symbol_table::add_global_function(ir_function *f) { symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(f); diff --git a/src/glsl/glsl_symbol_table.h b/src/glsl/glsl_symbol_table.h index f95fb8a..9f56027 100644 --- a/src/glsl/glsl_symbol_table.h +++ b/src/glsl/glsl_symbol_table.h @@ -99,7 +99,6 @@ public: bool add_variable(ir_variable *v); bool add_type(const char *name, const glsl_type *t); bool add_function(ir_function *f); - bool add_uniform_block(struct gl_uniform_block *u); /*@}*/ /** -- 2.7.4