[Mesa-dev] [PATCH 02/10] glsl: Track UBO block names in the symbol table.

Ian Romanick idr at freedesktop.org
Thu Jan 17 07:55:21 PST 2013


On 01/16/2013 11:56 PM, Pohjolainen, Topi wrote:
> On Wed, Jan 16, 2013 at 03:03:41PM -0800, Ian Romanick wrote:
>> From: Kenneth Graunke <kenneth at whitecape.org>
>>
>> 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.
>>
>> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
>> ---
>>   src/glsl/ast_to_hir.cpp        |  6 ++++++
>>   src/glsl/glsl_symbol_table.cpp | 14 +++++++++++---
>>   src/glsl/glsl_symbol_table.h   |  1 +
>>   3 files changed, 18 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
>> index ea5e3b7..31dd51a 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) {
>> diff --git a/src/glsl/glsl_symbol_table.cpp b/src/glsl/glsl_symbol_table.cpp
>> index f934ea8..6171a27 100644
>> --- a/src/glsl/glsl_symbol_table.cpp
>> +++ b/src/glsl/glsl_symbol_table.cpp
>> @@ -41,13 +41,15 @@ public:
>>         ralloc_free(entry);
>>      }
>>
>> -   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) {}
>> +   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(t), u(u) {}
>
> I guess you did not mean to initialize 't' on itself.

That looks like a copy-and-paste bug.  I'll fix that.

> ---------------------------------------------------------------------
> Intel Finland Oy
> Registered Address: PL 281, 00181 Helsinki
> Business Identity Code: 0357606 - 4
> Domiciled in Helsinki
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>



More information about the mesa-dev mailing list