diff options
author | Eric Anholt <[email protected]> | 2010-08-04 12:34:56 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2010-08-04 12:42:47 -0700 |
commit | 8273bd46877e2ea2b8a02b87a11c68102d07e1f2 (patch) | |
tree | 3182808d4b54aa9c094a5e41bcda1405244b8e0b /src/glsl/ir.h | |
parent | 84ee01f40acf88185484df386b7715034e7685c9 (diff) |
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.
Diffstat (limited to 'src/glsl/ir.h')
-rw-r--r-- | src/glsl/ir.h | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/src/glsl/ir.h b/src/glsl/ir.h index f88a243cc02..f964b36083a 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -76,7 +76,8 @@ public: virtual void accept(ir_visitor *) = 0; virtual ir_visitor_status accept(ir_hierarchical_visitor *) = 0; - virtual ir_instruction *clone(struct hash_table *ht) const = 0; + virtual ir_instruction *clone(void *mem_ctx, + struct hash_table *ht) const = 0; /** * \name IR instruction downcast functions @@ -113,7 +114,7 @@ protected: class ir_rvalue : public ir_instruction { public: - virtual ir_rvalue *clone(struct hash_table *) const = 0; + virtual ir_rvalue *clone(void *mem_ctx, struct hash_table *) const = 0; virtual ir_constant *constant_expression_value() = 0; @@ -175,7 +176,7 @@ class ir_variable : public ir_instruction { public: ir_variable(const struct glsl_type *, const char *, ir_variable_mode); - virtual ir_variable *clone(struct hash_table *ht) const; + virtual ir_variable *clone(void *mem_ctx, struct hash_table *ht) const; virtual ir_variable *as_variable() { @@ -283,7 +284,8 @@ class ir_function_signature : public ir_instruction { public: ir_function_signature(const glsl_type *return_type); - virtual ir_function_signature *clone(struct hash_table *ht) const; + virtual ir_function_signature *clone(void *mem_ctx, + struct hash_table *ht) const; virtual void accept(ir_visitor *v) { @@ -369,7 +371,7 @@ class ir_function : public ir_instruction { public: ir_function(const char *name); - virtual ir_function *clone(struct hash_table *ht) const; + virtual ir_function *clone(void *mem_ctx, struct hash_table *ht) const; virtual ir_function *as_function() { @@ -439,7 +441,7 @@ public: ir_type = ir_type_if; } - virtual ir_if *clone(struct hash_table *ht) const; + virtual ir_if *clone(void *mem_ctx, struct hash_table *ht) const; virtual ir_if *as_if() { @@ -471,7 +473,7 @@ public: ir_type = ir_type_loop; } - virtual ir_loop *clone(struct hash_table *ht) const; + virtual ir_loop *clone(void *mem_ctx, struct hash_table *ht) const; virtual void accept(ir_visitor *v) { @@ -512,7 +514,7 @@ class ir_assignment : public ir_instruction { public: ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition); - virtual ir_assignment *clone(struct hash_table *ht) const; + virtual ir_assignment *clone(void *mem_ctx, struct hash_table *ht) const; virtual ir_constant *constant_expression_value(); @@ -662,7 +664,7 @@ public: return this; } - virtual ir_expression *clone(struct hash_table *ht) const; + virtual ir_expression *clone(void *mem_ctx, struct hash_table *ht) const; virtual ir_constant *constant_expression_value(); @@ -708,7 +710,7 @@ public: actual_parameters->move_nodes_to(& this->actual_parameters); } - virtual ir_call *clone(struct hash_table *ht) const; + virtual ir_call *clone(void *mem_ctx, struct hash_table *ht) const; virtual ir_constant *constant_expression_value(); @@ -805,7 +807,7 @@ public: this->ir_type = ir_type_return; } - virtual ir_return *clone(struct hash_table *) const; + virtual ir_return *clone(void *mem_ctx, struct hash_table *) const; virtual ir_return *as_return() { @@ -850,7 +852,7 @@ public: this->loop = loop; } - virtual ir_loop_jump *clone(struct hash_table *) const; + virtual ir_loop_jump *clone(void *mem_ctx, struct hash_table *) const; virtual void accept(ir_visitor *v) { @@ -893,7 +895,7 @@ public: this->condition = cond; } - virtual ir_discard *clone(struct hash_table *ht) const; + virtual ir_discard *clone(void *mem_ctx, struct hash_table *ht) const; virtual void accept(ir_visitor *v) { @@ -945,7 +947,7 @@ public: this->ir_type = ir_type_texture; } - virtual ir_texture *clone(struct hash_table *) const; + virtual ir_texture *clone(void *mem_ctx, struct hash_table *) const; virtual ir_constant *constant_expression_value(); @@ -1037,7 +1039,7 @@ public: ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask); - virtual ir_swizzle *clone(struct hash_table *) const; + virtual ir_swizzle *clone(void *mem_ctx, struct hash_table *) const; virtual ir_constant *constant_expression_value(); @@ -1083,7 +1085,7 @@ private: class ir_dereference : public ir_rvalue { public: - virtual ir_dereference *clone(struct hash_table *) const = 0; + virtual ir_dereference *clone(void *mem_ctx, struct hash_table *) const = 0; virtual ir_dereference *as_dereference() { @@ -1103,7 +1105,8 @@ class ir_dereference_variable : public ir_dereference { public: ir_dereference_variable(ir_variable *var); - virtual ir_dereference_variable *clone(struct hash_table *) const; + virtual ir_dereference_variable *clone(void *mem_ctx, + struct hash_table *) const; virtual ir_constant *constant_expression_value(); @@ -1151,7 +1154,8 @@ public: ir_dereference_array(ir_variable *var, ir_rvalue *array_index); - virtual ir_dereference_array *clone(struct hash_table *) const; + virtual ir_dereference_array *clone(void *mem_ctx, + struct hash_table *) const; virtual ir_constant *constant_expression_value(); @@ -1189,7 +1193,8 @@ public: ir_dereference_record(ir_variable *var, const char *field); - virtual ir_dereference_record *clone(struct hash_table *) const; + virtual ir_dereference_record *clone(void *mem_ctx, + struct hash_table *) const; virtual ir_constant *constant_expression_value(); @@ -1254,7 +1259,7 @@ public: */ static ir_constant *zero(void *mem_ctx, const glsl_type *type); - virtual ir_constant *clone(struct hash_table *) const; + virtual ir_constant *clone(void *mem_ctx, struct hash_table *) const; virtual ir_constant *constant_expression_value(); @@ -1327,7 +1332,7 @@ void validate_ir_tree(exec_list *instructions); * \param out List to hold the cloned instructions */ void -clone_ir_list(exec_list *out, const exec_list *in); +clone_ir_list(void *mem_ctx, exec_list *out, const exec_list *in); extern void _mesa_glsl_initialize_variables(exec_list *instructions, |