X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglsl%2Fir_clone.cpp;h=c221a96c3f3562504e134ea9d70dcd0768781264;hb=9a204bb9f611e34396ea838b44517dd6eeb99bcc;hp=20a59b1e435f9501b3454a011472db6e7d8d5850;hpb=d3073f58c17d8675a2ecdd5dfa83e5520c78e1a8;p=mesa.git diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 20a59b1e435..c221a96c3f3 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -25,16 +25,17 @@ #include "main/compiler.h" #include "ir.h" #include "glsl_types.h" -extern "C" { #include "program/hash_table.h" + +ir_rvalue * +ir_rvalue::clone(void *mem_ctx, struct hash_table *ht) const +{ + /* The only possible instantiation is the generic error value. */ + return error_value(mem_ctx); } /** * Duplicate an IR variable - * - * \note - * This will probably be made \c virtual and moved to the base class - * eventually. */ ir_variable * ir_variable::clone(void *mem_ctx, struct hash_table *ht) const @@ -47,18 +48,37 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const var->centroid = this->centroid; var->invariant = this->invariant; var->interpolation = this->interpolation; - var->array_lvalue = this->array_lvalue; var->location = this->location; + var->index = this->index; + var->uniform_block = this->uniform_block; var->warn_extension = this->warn_extension; var->origin_upper_left = this->origin_upper_left; var->pixel_center_integer = this->pixel_center_integer; var->explicit_location = this->explicit_location; - if (this->explicit_location) - var->location = this->location; + var->explicit_index = this->explicit_index; + var->has_initializer = this->has_initializer; + var->depth_layout = this->depth_layout; + + var->num_state_slots = this->num_state_slots; + if (this->state_slots) { + /* FINISHME: This really wants to use something like talloc_reference, but + * FINISHME: ralloc doesn't have any similar function. + */ + var->state_slots = ralloc_array(var, ir_state_slot, + this->num_state_slots); + memcpy(var->state_slots, this->state_slots, + sizeof(this->state_slots[0]) * var->num_state_slots); + } if (this->constant_value) var->constant_value = this->constant_value->clone(mem_ctx, ht); + if (this->constant_initializer) + 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)); } @@ -145,8 +165,9 @@ ir_loop::clone(void *mem_ctx, struct hash_table *ht) const ir_call * ir_call::clone(void *mem_ctx, struct hash_table *ht) const { - if (this->type == glsl_type::error_type) - return ir_call::get_error_instruction(mem_ctx); + ir_dereference_variable *new_return_ref = NULL; + if (this->return_deref != NULL) + new_return_ref = this->return_deref->clone(mem_ctx, ht); exec_list new_parameters; @@ -155,7 +176,7 @@ ir_call::clone(void *mem_ctx, struct hash_table *ht) const new_parameters.push_tail(ir->clone(mem_ctx, ht)); } - return new(mem_ctx) ir_call(this->callee, &new_parameters); + return new(mem_ctx) ir_call(this->callee, new_return_ref, &new_parameters); } ir_expression * @@ -210,15 +231,16 @@ ir_texture::clone(void *mem_ctx, struct hash_table *ht) const new_tex->type = this->type; new_tex->sampler = this->sampler->clone(mem_ctx, ht); - new_tex->coordinate = this->coordinate->clone(mem_ctx, ht); + if (this->coordinate) + new_tex->coordinate = this->coordinate->clone(mem_ctx, ht); if (this->projector) new_tex->projector = this->projector->clone(mem_ctx, ht); if (this->shadow_comparitor) { new_tex->shadow_comparitor = this->shadow_comparitor->clone(mem_ctx, ht); } - for (int i = 0; i < 3; i++) - new_tex->offsets[i] = this->offsets[i]; + if (this->offset != NULL) + new_tex->offset = this->offset->clone(mem_ctx, ht); switch (this->op) { case ir_tex: @@ -228,6 +250,7 @@ ir_texture::clone(void *mem_ctx, struct hash_table *ht) const break; case ir_txl: case ir_txf: + case ir_txs: new_tex->lod_info.lod = this->lod_info.lod->clone(mem_ctx, ht); break; case ir_txd: @@ -300,6 +323,7 @@ ir_function_signature::clone_prototype(void *mem_ctx, struct hash_table *ht) con copy->is_defined = false; copy->is_builtin = this->is_builtin; + copy->origin = this; /* Clone the parameter list, but NOT the body. */ @@ -353,10 +377,15 @@ ir_constant::clone(void *mem_ctx, struct hash_table *ht) const return c; } - default: + case GLSL_TYPE_SAMPLER: + case GLSL_TYPE_VOID: + case GLSL_TYPE_ERROR: + case GLSL_TYPE_INTERFACE: assert(!"Should not get here."); - return NULL; + break; } + + return NULL; } @@ -373,9 +402,9 @@ public: * table. If it is found, replace it with the value from the table. */ ir_function_signature *sig = - (ir_function_signature *) hash_table_find(this->ht, ir->get_callee()); + (ir_function_signature *) hash_table_find(this->ht, ir->callee); if (sig != NULL) - ir->set_callee(sig); + ir->callee = sig; /* Since this may be used before function call parameters are flattened, * the children also need to be processed.