diff --git a/src/microsoft/compiler/dxil_nir.c b/src/microsoft/compiler/dxil_nir.c index 77b55907a88..63d2a0c77f7 100644 --- a/src/microsoft/compiler/dxil_nir.c +++ b/src/microsoft/compiler/dxil_nir.c @@ -975,102 +975,6 @@ dxil_nir_opt_alu_deref_srcs(nir_shader *nir) return progress; } -static nir_ssa_def * -memcpy_load_deref_elem(nir_builder *b, nir_deref_instr *parent, - nir_ssa_def *index) -{ - nir_deref_instr *deref; - - index = nir_i2i(b, index, nir_dest_bit_size(parent->dest)); - assert(parent->deref_type == nir_deref_type_cast); - deref = nir_build_deref_ptr_as_array(b, parent, index); - - return nir_load_deref(b, deref); -} - -static void -memcpy_store_deref_elem(nir_builder *b, nir_deref_instr *parent, - nir_ssa_def *index, nir_ssa_def *value) -{ - nir_deref_instr *deref; - - index = nir_i2i(b, index, nir_dest_bit_size(parent->dest)); - assert(parent->deref_type == nir_deref_type_cast); - deref = nir_build_deref_ptr_as_array(b, parent, index); - nir_store_deref(b, deref, value, 1); -} - -static bool -lower_memcpy_deref(nir_builder *b, nir_intrinsic_instr *intr) -{ - nir_deref_instr *dst_deref = nir_src_as_deref(intr->src[0]); - nir_deref_instr *src_deref = nir_src_as_deref(intr->src[1]); - assert(intr->src[2].is_ssa); - nir_ssa_def *num_bytes = intr->src[2].ssa; - - assert(dst_deref && src_deref); - - b->cursor = nir_after_instr(&intr->instr); - - dst_deref = nir_build_deref_cast(b, &dst_deref->dest.ssa, dst_deref->modes, - glsl_uint8_t_type(), 1); - src_deref = nir_build_deref_cast(b, &src_deref->dest.ssa, src_deref->modes, - glsl_uint8_t_type(), 1); - - /* - * We want to avoid 64b instructions, so let's assume we'll always be - * passed a value that fits in a 32b type and truncate the 64b value. - */ - num_bytes = nir_u2u32(b, num_bytes); - - nir_variable *loop_index_var = - nir_local_variable_create(b->impl, glsl_uint_type(), "loop_index"); - nir_deref_instr *loop_index_deref = nir_build_deref_var(b, loop_index_var); - nir_store_deref(b, loop_index_deref, nir_imm_int(b, 0), 1); - - nir_loop *loop = nir_push_loop(b); - nir_ssa_def *loop_index = nir_load_deref(b, loop_index_deref); - nir_ssa_def *cmp = nir_ige(b, loop_index, num_bytes); - nir_if *loop_check = nir_push_if(b, cmp); - nir_jump(b, nir_jump_break); - nir_pop_if(b, loop_check); - nir_ssa_def *val = memcpy_load_deref_elem(b, src_deref, loop_index); - memcpy_store_deref_elem(b, dst_deref, loop_index, val); - nir_store_deref(b, loop_index_deref, nir_iadd_imm(b, loop_index, 1), 1); - nir_pop_loop(b, loop); - nir_instr_remove(&intr->instr); - return true; -} - -bool -dxil_nir_lower_memcpy_deref(nir_shader *nir) -{ - bool progress = false; - - foreach_list_typed(nir_function, func, node, &nir->functions) { - if (!func->is_entrypoint) - continue; - assert(func->impl); - - nir_builder b; - nir_builder_init(&b, func->impl); - - nir_foreach_block(block, func->impl) { - nir_foreach_instr_safe(instr, block) { - if (instr->type != nir_instr_type_intrinsic) - continue; - - nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr); - - if (intr->intrinsic == nir_intrinsic_memcpy_deref) - progress |= lower_memcpy_deref(&b, intr); - } - } - } - - return progress; -} - static void cast_phi(nir_builder *b, nir_phi_instr *phi, unsigned new_bit_size) { diff --git a/src/microsoft/compiler/dxil_nir.h b/src/microsoft/compiler/dxil_nir.h index fc384d17e7e..0dc63deabb2 100644 --- a/src/microsoft/compiler/dxil_nir.h +++ b/src/microsoft/compiler/dxil_nir.h @@ -41,7 +41,6 @@ bool dxil_nir_lower_loads_stores_to_dxil(nir_shader *shader); bool dxil_nir_lower_atomics_to_dxil(nir_shader *shader); bool dxil_nir_lower_deref_ssbo(nir_shader *shader); bool dxil_nir_opt_alu_deref_srcs(nir_shader *shader); -bool dxil_nir_lower_memcpy_deref(nir_shader *shader); bool dxil_nir_lower_upcast_phis(nir_shader *shader, unsigned min_bit_size); bool dxil_nir_lower_fp16_casts(nir_shader *shader); bool dxil_nir_split_clip_cull_distance(nir_shader *shader);