From: Jason Ekstrand Date: Wed, 8 Jan 2020 01:22:13 +0000 (-0600) Subject: nir/lower_atomics_to_ssbo: Also lower barriers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d3737002eed280ac6362a88f29d6c30d66a1e852;p=mesa.git nir/lower_atomics_to_ssbo: Also lower barriers This is more correct for a pass which is supposed to completely lower away atomic counters. It also lets us stop supporting atomic counter barriers in most of the drivers. Reviewed-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eric Anholt Tested-by: Marge Bot Part-of: --- diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index a106631b4c1..df72b42c539 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -4949,9 +4949,6 @@ void emit_memory_barrier(isel_context *ctx, nir_intrinsic_instr *instr) { case nir_intrinsic_memory_barrier: bld.barrier(aco_opcode::p_memory_barrier_all); break; - case nir_intrinsic_memory_barrier_atomic_counter: - bld.barrier(aco_opcode::p_memory_barrier_atomic); - break; case nir_intrinsic_memory_barrier_buffer: bld.barrier(aco_opcode::p_memory_barrier_buffer); break; @@ -5723,7 +5720,6 @@ void visit_intrinsic(isel_context *ctx, nir_intrinsic_instr *instr) } case nir_intrinsic_group_memory_barrier: case nir_intrinsic_memory_barrier: - case nir_intrinsic_memory_barrier_atomic_counter: case nir_intrinsic_memory_barrier_buffer: case nir_intrinsic_memory_barrier_image: case nir_intrinsic_memory_barrier_shared: diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c index 17c21cadad9..4ae45c6204d 100644 --- a/src/amd/llvm/ac_nir_to_llvm.c +++ b/src/amd/llvm/ac_nir_to_llvm.c @@ -2876,7 +2876,6 @@ static void emit_membar(struct ac_llvm_context *ac, case nir_intrinsic_group_memory_barrier: wait_flags = AC_WAIT_LGKM | AC_WAIT_VLOAD | AC_WAIT_VSTORE; break; - case nir_intrinsic_memory_barrier_atomic_counter: case nir_intrinsic_memory_barrier_buffer: case nir_intrinsic_memory_barrier_image: wait_flags = AC_WAIT_VLOAD | AC_WAIT_VSTORE; @@ -3547,7 +3546,6 @@ static void visit_intrinsic(struct ac_nir_context *ctx, break; case nir_intrinsic_memory_barrier: case nir_intrinsic_group_memory_barrier: - case nir_intrinsic_memory_barrier_atomic_counter: case nir_intrinsic_memory_barrier_buffer: case nir_intrinsic_memory_barrier_image: case nir_intrinsic_memory_barrier_shared: diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index ffd166f90f4..1479962fac8 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -2243,7 +2243,6 @@ ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr) } case nir_intrinsic_memory_barrier: - case nir_intrinsic_memory_barrier_atomic_counter: case nir_intrinsic_memory_barrier_buffer: case nir_intrinsic_memory_barrier_image: case nir_intrinsic_memory_barrier_shared: diff --git a/src/compiler/nir/nir_lower_atomics_to_ssbo.c b/src/compiler/nir/nir_lower_atomics_to_ssbo.c index 918f060a8df..7ff0123b7bb 100644 --- a/src/compiler/nir/nir_lower_atomics_to_ssbo.c +++ b/src/compiler/nir/nir_lower_atomics_to_ssbo.c @@ -47,6 +47,13 @@ lower_instr(nir_intrinsic_instr *instr, unsigned ssbo_offset, nir_builder *b) b->cursor = nir_before_instr(&instr->instr); switch (instr->intrinsic) { + case nir_intrinsic_memory_barrier_atomic_counter: + /* Atomic counters are now SSBOs so memoryBarrierAtomicCounter() is now + * memoryBarrierBuffer(). + */ + instr->intrinsic = nir_intrinsic_memory_barrier_buffer; + return true; + case nir_intrinsic_ssbo_atomic_add: case nir_intrinsic_ssbo_atomic_imin: case nir_intrinsic_ssbo_atomic_umin: diff --git a/src/compiler/nir/nir_opt_combine_stores.c b/src/compiler/nir/nir_opt_combine_stores.c index 791ec094c00..285a2564a95 100644 --- a/src/compiler/nir/nir_opt_combine_stores.c +++ b/src/compiler/nir/nir_opt_combine_stores.c @@ -311,7 +311,6 @@ combine_stores_block(struct combine_stores_state *state, nir_block *block) nir_var_mem_shared); break; - case nir_intrinsic_memory_barrier_atomic_counter: case nir_intrinsic_memory_barrier_buffer: combine_stores_with_modes(state, nir_var_mem_ssbo); break; diff --git a/src/compiler/nir/nir_opt_copy_prop_vars.c b/src/compiler/nir/nir_opt_copy_prop_vars.c index dbce55bfb8c..54fbad221a7 100644 --- a/src/compiler/nir/nir_opt_copy_prop_vars.c +++ b/src/compiler/nir/nir_opt_copy_prop_vars.c @@ -808,7 +808,6 @@ copy_prop_vars_block(struct copy_prop_var_state *state, break; case nir_intrinsic_memory_barrier_buffer: - case nir_intrinsic_memory_barrier_atomic_counter: if (debug) dump_instr(instr); apply_barrier_for_modes(copies, nir_var_mem_ssbo); diff --git a/src/compiler/nir/nir_opt_dead_write_vars.c b/src/compiler/nir/nir_opt_dead_write_vars.c index 578e8706818..0980647c63d 100644 --- a/src/compiler/nir/nir_opt_dead_write_vars.c +++ b/src/compiler/nir/nir_opt_dead_write_vars.c @@ -140,7 +140,6 @@ remove_dead_write_vars_local(void *mem_ctx, nir_block *block) } case nir_intrinsic_memory_barrier_buffer: - case nir_intrinsic_memory_barrier_atomic_counter: clear_unused_for_modes(&unused_writes, nir_var_mem_ssbo); break; diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index f1ba10456ed..7a26a57c08d 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -1174,7 +1174,6 @@ emit_intrinsic_barrier(struct ir3_context *ctx, nir_intrinsic_instr *intr) IR3_BARRIER_IMAGE_R | IR3_BARRIER_IMAGE_W | IR3_BARRIER_BUFFER_R | IR3_BARRIER_BUFFER_W; break; - case nir_intrinsic_memory_barrier_atomic_counter: case nir_intrinsic_memory_barrier_buffer: barrier = ir3_FENCE(b); barrier->cat7.g = true; @@ -1644,7 +1643,6 @@ emit_intrinsic(struct ir3_context *ctx, nir_intrinsic_instr *intr) case nir_intrinsic_control_barrier: case nir_intrinsic_memory_barrier: case nir_intrinsic_group_memory_barrier: - case nir_intrinsic_memory_barrier_atomic_counter: case nir_intrinsic_memory_barrier_buffer: case nir_intrinsic_memory_barrier_image: case nir_intrinsic_memory_barrier_shared: diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp index 8a0274e30a6..22dbbae4a92 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp @@ -652,7 +652,6 @@ Converter::getSubOp(nir_intrinsic_op op) case nir_intrinsic_group_memory_barrier: case nir_intrinsic_memory_barrier: - case nir_intrinsic_memory_barrier_atomic_counter: case nir_intrinsic_memory_barrier_buffer: case nir_intrinsic_memory_barrier_image: return NV50_IR_SUBOP_MEMBAR(M, GL); @@ -2654,7 +2653,6 @@ Converter::visit(nir_intrinsic_instr *insn) } case nir_intrinsic_group_memory_barrier: case nir_intrinsic_memory_barrier: - case nir_intrinsic_memory_barrier_atomic_counter: case nir_intrinsic_memory_barrier_buffer: case nir_intrinsic_memory_barrier_image: case nir_intrinsic_memory_barrier_shared: { diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp index c794bb90d97..c3748b503a9 100644 --- a/src/intel/compiler/brw_fs_nir.cpp +++ b/src/intel/compiler/brw_fs_nir.cpp @@ -4274,7 +4274,6 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr case nir_intrinsic_scoped_memory_barrier: case nir_intrinsic_group_memory_barrier: case nir_intrinsic_memory_barrier_shared: - case nir_intrinsic_memory_barrier_atomic_counter: case nir_intrinsic_memory_barrier_buffer: case nir_intrinsic_memory_barrier_image: case nir_intrinsic_memory_barrier: {