From 3e70c968de363168fc491ca673a4798284a10c44 Mon Sep 17 00:00:00 2001 From: Samuel Iglesias Gonsalvez Date: Wed, 23 Sep 2015 08:48:21 +0200 Subject: [PATCH] nir: modify the instruction insertion in nir_visitor::visit(ir_call *ir) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch moves nir_instr_insert_after_cf_list call into each case in the intrinsics switch at nir_visitor::visit(ir_call *ir) and define a nir_dest variable which will be used when handling ir->return_deref after the switch. This patch simplifies the code for nir_intrinsic_load_ssbo implementation changes we are going to do next. Reviewed-by: Kristian Høgsberg --- src/glsl/nir/glsl_to_nir.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index add6b6261b4..d0b769a9c13 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -656,6 +656,7 @@ nir_visitor::visit(ir_call *ir) } nir_intrinsic_instr *instr = nir_intrinsic_instr_create(shader, op); + nir_dest *dest = &instr->dest; switch (op) { case nir_intrinsic_atomic_counter_read_var: @@ -665,6 +666,7 @@ nir_visitor::visit(ir_call *ir) (ir_dereference *) ir->actual_parameters.get_head(); instr->variables[0] = evaluate_deref(&instr->instr, param); nir_ssa_dest_init(&instr->instr, &instr->dest, 1, NULL); + nir_instr_insert_after_cf_list(this->cf_node_list, &instr->instr); break; } case nir_intrinsic_image_load: @@ -702,8 +704,10 @@ nir_visitor::visit(ir_call *ir) } if (op == nir_intrinsic_image_size || - op == nir_intrinsic_image_samples) + op == nir_intrinsic_image_samples) { + nir_instr_insert_after_cf_list(this->cf_node_list, &instr->instr); break; + } /* Set the address argument, extending the coordinate vector to four * components. @@ -745,9 +749,11 @@ nir_visitor::visit(ir_call *ir) instr->src[3] = evaluate_rvalue((ir_dereference *)param); param = param->get_next(); } + nir_instr_insert_after_cf_list(this->cf_node_list, &instr->instr); break; } case nir_intrinsic_memory_barrier: + nir_instr_insert_after_cf_list(this->cf_node_list, &instr->instr); break; case nir_intrinsic_store_ssbo: { exec_node *param = ir->actual_parameters.get_head(); @@ -771,6 +777,7 @@ nir_visitor::visit(ir_call *ir) instr = nir_intrinsic_instr_create(shader, op); instr->src[2] = evaluate_rvalue(offset); instr->const_index[0] = 0; + dest = &instr->dest; } else { instr->const_index[0] = const_offset->value.u[0]; } @@ -781,14 +788,13 @@ nir_visitor::visit(ir_call *ir) instr->num_components = val->type->vector_elements; instr->src[1] = evaluate_rvalue(block); + nir_instr_insert_after_cf_list(this->cf_node_list, &instr->instr); break; } default: unreachable("not reached"); } - nir_instr_insert_after_cf_list(this->cf_node_list, &instr->instr); - if (ir->return_deref) { nir_intrinsic_instr *store_instr = nir_intrinsic_instr_create(shader, nir_intrinsic_store_var); @@ -796,7 +802,7 @@ nir_visitor::visit(ir_call *ir) store_instr->variables[0] = evaluate_deref(&store_instr->instr, ir->return_deref); - store_instr->src[0] = nir_src_for_ssa(&instr->dest.ssa); + store_instr->src[0] = nir_src_for_ssa(&dest->ssa); nir_instr_insert_after_cf_list(this->cf_node_list, &store_instr->instr); -- 2.30.2