X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglsl%2Fir_clone.cpp;h=bee60a241e4d7e32f5f2deabc0b253d086f6d7ed;hb=d97b060e6f305ce4ad050881944404b920c86edf;hp=86a620552aa77fe598510f9fbbbcbfaf5aca9bde;hpb=4d78446d782e2d942b4cd0cd00a27bf922ccd479;p=mesa.git diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 86a620552aa..bee60a241e4 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -45,25 +45,18 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const var->data.max_array_access = this->data.max_array_access; if (this->is_interface_instance()) { - var->max_ifc_array_access = + var->u.max_ifc_array_access = rzalloc_array(var, unsigned, this->interface_type->length); - memcpy(var->max_ifc_array_access, this->max_ifc_array_access, + memcpy(var->u.max_ifc_array_access, this->u.max_ifc_array_access, this->interface_type->length * sizeof(unsigned)); } memcpy(&var->data, &this->data, sizeof(var->data)); - var->warn_extension = this->warn_extension; - - 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->get_state_slots()) { + ir_state_slot *s = var->allocate_state_slots(this->get_num_state_slots()); + memcpy(s, this->get_state_slots(), + sizeof(s[0]) * var->get_num_state_slots()); } if (this->constant_value) @@ -165,7 +158,7 @@ ir_call::clone(void *mem_ctx, struct hash_table *ht) const ir_expression * ir_expression::clone(void *mem_ctx, struct hash_table *ht) const { - ir_rvalue *op[Elements(this->operands)] = { NULL, }; + ir_rvalue *op[ARRAY_SIZE(this->operands)] = { NULL, }; unsigned int i; for (i = 0; i < get_num_operands(); i++) { @@ -229,6 +222,8 @@ ir_texture::clone(void *mem_ctx, struct hash_table *ht) const case ir_tex: case ir_lod: case ir_query_levels: + case ir_texture_samples: + case ir_samples_identical: break; case ir_txb: new_tex->lod_info.bias = this->lod_info.bias->clone(mem_ctx, ht); @@ -274,10 +269,14 @@ ir_function::clone(void *mem_ctx, struct hash_table *ht) const { ir_function *copy = new(mem_ctx) ir_function(this->name); - foreach_list_const(node, &this->signatures) { - const ir_function_signature *const sig = - (const ir_function_signature *const) node; + copy->is_subroutine = this->is_subroutine; + copy->subroutine_index = this->subroutine_index; + copy->num_subroutine_types = this->num_subroutine_types; + copy->subroutine_types = ralloc_array(mem_ctx, const struct glsl_type *, copy->num_subroutine_types); + for (int i = 0; i < copy->num_subroutine_types; i++) + copy->subroutine_types[i] = this->subroutine_types[i]; + foreach_in_list(const ir_function_signature, sig, &this->signatures) { ir_function_signature *sig_copy = sig->clone(mem_ctx, ht); copy->add_signature(sig_copy); @@ -298,9 +297,7 @@ ir_function_signature::clone(void *mem_ctx, struct hash_table *ht) const /* Clone the instruction list. */ - foreach_list_const(node, &this->body) { - const ir_instruction *const inst = (const ir_instruction *) node; - + foreach_in_list(const ir_instruction, inst, &this->body) { ir_instruction *const inst_copy = inst->clone(mem_ctx, ht); copy->body.push_tail(inst_copy); } @@ -320,9 +317,7 @@ ir_function_signature::clone_prototype(void *mem_ctx, struct hash_table *ht) con /* Clone the parameter list, but NOT the body. */ - foreach_list_const(node, &this->parameters) { - const ir_variable *const param = (const ir_variable *) node; - + foreach_in_list(const ir_variable, param, &this->parameters) { assert(const_cast(param)->as_variable() != NULL); ir_variable *const param_copy = param->clone(mem_ctx, ht); @@ -341,6 +336,7 @@ ir_constant::clone(void *mem_ctx, struct hash_table *ht) const case GLSL_TYPE_UINT: case GLSL_TYPE_INT: case GLSL_TYPE_FLOAT: + case GLSL_TYPE_DOUBLE: case GLSL_TYPE_BOOL: return new(mem_ctx) ir_constant(this->type, &this->value); @@ -375,6 +371,7 @@ ir_constant::clone(void *mem_ctx, struct hash_table *ht) const case GLSL_TYPE_ATOMIC_UINT: case GLSL_TYPE_VOID: case GLSL_TYPE_ERROR: + case GLSL_TYPE_SUBROUTINE: case GLSL_TYPE_INTERFACE: assert(!"Should not get here."); break; @@ -426,8 +423,7 @@ clone_ir_list(void *mem_ctx, exec_list *out, const exec_list *in) struct hash_table *ht = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); - foreach_list_const(node, in) { - const ir_instruction *const original = (ir_instruction *) node; + foreach_in_list(const ir_instruction, original, in) { ir_instruction *copy = original->clone(mem_ctx, ht); out->push_tail(copy);