*/
/**
- * \file ir_structure_splitting.cpp
+ * \file opt_structure_splitting.cpp
*
* If a structure is only ever referenced by its components, then
* split those components out to individual variables so they can be
ir_variable **components;
- /** talloc_parent(this->var) -- the shader's talloc context. */
+ /** ralloc_parent(this->var) -- the shader's ralloc context. */
void *mem_ctx;
};
public:
ir_structure_reference_visitor(void)
{
- this->mem_ctx = talloc_new(NULL);
+ this->mem_ctx = ralloc_context(NULL);
this->variable_list.make_empty();
}
~ir_structure_reference_visitor(void)
{
- talloc_free(mem_ctx);
+ ralloc_free(mem_ctx);
}
virtual ir_visitor_status visit(ir_variable *);
ir_visitor_status
ir_structure_reference_visitor::visit_enter(ir_assignment *ir)
{
+ /* If there are no structure references yet, no need to bother with
+ * processing the expression tree.
+ */
+ if (this->variable_list.is_empty())
+ return visit_continue_with_parent;
+
if (ir->lhs->as_dereference_variable() &&
ir->rhs->as_dereference_variable() &&
!ir->condition) {
if (refs.variable_list.is_empty())
return false;
- void *mem_ctx = talloc_new(NULL);
+ void *mem_ctx = ralloc_context(NULL);
/* Replace the decls of the structures to be split with their split
* components.
variable_entry2 *entry = (variable_entry2 *)iter.get();
const struct glsl_type *type = entry->var->type;
- entry->mem_ctx = talloc_parent(entry->var);
+ entry->mem_ctx = ralloc_parent(entry->var);
- entry->components = talloc_array(mem_ctx,
+ entry->components = ralloc_array(mem_ctx,
ir_variable *,
type->length);
for (unsigned int i = 0; i < entry->var->type->length; i++) {
- const char *name = talloc_asprintf(mem_ctx, "%s_%s",
+ const char *name = ralloc_asprintf(mem_ctx, "%s_%s",
entry->var->name,
type->fields.structure[i].name);
ir_structure_splitting_visitor split(&refs.variable_list);
visit_list_elements(&split, instructions);
- talloc_free(mem_ctx);
+ ralloc_free(mem_ctx);
return true;
}