From 8273bd46877e2ea2b8a02b87a11c68102d07e1f2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 12:34:56 -0700 Subject: glsl2: Make the clone() method take a talloc context. In most cases, we needed to be reparenting the cloned IR to a different context (for example, to the linked shader instead of the unlinked shader), or optimization before the reparent would cause memory usage of the original object to grow and grow. --- src/glsl/ir_vec_index_to_cond_assign.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/glsl/ir_vec_index_to_cond_assign.cpp') diff --git a/src/glsl/ir_vec_index_to_cond_assign.cpp b/src/glsl/ir_vec_index_to_cond_assign.cpp index dbc6f9ada8..cd8dedf2fe 100644 --- a/src/glsl/ir_vec_index_to_cond_assign.cpp +++ b/src/glsl/ir_vec_index_to_cond_assign.cpp @@ -82,6 +82,8 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue orig_deref->array->type->is_array()) return ir; + void *mem_ctx = talloc_parent(ir); + assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT); /* Store the index to a temporary to avoid reusing its tree. */ @@ -109,7 +111,7 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue /* Just clone the rest of the deref chain when trying to get at the * underlying variable. */ - swizzle = new(base_ir) ir_swizzle(orig_deref->array->clone(NULL), + swizzle = new(base_ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL), i, 0, 0, 0, 1); deref = new(base_ir) ir_dereference_variable(var); @@ -165,6 +167,8 @@ ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir) orig_deref->array->type->is_array()) return visit_continue; + void *mem_ctx = talloc_parent(ir); + assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT); /* Store the index to a temporary to avoid reusing its tree. */ @@ -196,7 +200,7 @@ ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir) /* Just clone the rest of the deref chain when trying to get at the * underlying variable. */ - swizzle = new(ir) ir_swizzle(orig_deref->array->clone(NULL), + swizzle = new(ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL), i, 0, 0, 0, 1); deref = new(ir) ir_dereference_variable(var); -- cgit v1.2.3