From: Ian Romanick Date: Tue, 22 Jan 2013 02:51:15 +0000 (-0500) Subject: glsl: Add ir_variable::interface_type field X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7a7b44b329c8090969587d1dab23721d47f82e4a;p=mesa.git glsl: Add ir_variable::interface_type field For variables that are in an interface block or are an instance of an interface block, this is the GLSL_TYPE_INTERFACE type for that block. Convert the ir_variable::is_in_uniform_block method added in the previous commit to use this field instead of ir_variable::uniform_block. v2: Fix the place-holder comment on ir_variable::interface_type. Suggested by Paul Berry. Signed-off-by: Ian Romanick Reviewed-by: Carl Worth Reviewed-by: Kenneth Graunke --- diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 163c39aeb93..372ffde1b16 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -4268,6 +4268,7 @@ ast_uniform_block::hir(exec_list *instructions, this->instance_name, ir_var_uniform); + var->interface_type = block_type; state->symbols->add_variable(var); instructions->push_tail(var); } else { @@ -4277,6 +4278,7 @@ ast_uniform_block::hir(exec_list *instructions, ralloc_strdup(state, fields[i].name), ir_var_uniform); var->uniform_block = ubo - state->uniform_blocks; + var->interface_type = block_type; state->symbols->add_variable(var); instructions->push_tail(var); diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 14212dfb7a2..ff47b3a5a80 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -354,7 +354,7 @@ public: */ inline bool is_in_uniform_block() const { - return this->mode == ir_var_uniform && this->uniform_block != -1; + return this->mode == ir_var_uniform && this->interface_type != NULL; } /** @@ -540,6 +540,14 @@ public: * objects. */ ir_constant *constant_initializer; + + /** + * For variables that are in an interface block or are an instance of an + * interface block, this is the \c GLSL_TYPE_INTERFACE type for that block. + * + * \sa ir_variable::location + */ + const glsl_type *interface_type; }; diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 3e22f2d2ab0..c221a96c3f3 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -77,6 +77,8 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const var->constant_initializer = this->constant_initializer->clone(mem_ctx, ht); + var->interface_type = this->interface_type; + if (ht) { hash_table_insert(ht, var, (void *)const_cast(this)); }