nir/lower_atomics_to_ssbo: Also lower barriers
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 8 Jan 2020 01:22:13 +0000 (19:22 -0600)
committerMarge Bot <eric+marge@anholt.net>
Mon, 13 Jan 2020 17:23:47 +0000 (17:23 +0000)
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 <caio.oliveira@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3307>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3307>

src/amd/compiler/aco_instruction_selection.cpp
src/amd/llvm/ac_nir_to_llvm.c
src/broadcom/compiler/nir_to_vir.c
src/compiler/nir/nir_lower_atomics_to_ssbo.c
src/compiler/nir/nir_opt_combine_stores.c
src/compiler/nir/nir_opt_copy_prop_vars.c
src/compiler/nir/nir_opt_dead_write_vars.c
src/freedreno/ir3/ir3_compiler_nir.c
src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
src/intel/compiler/brw_fs_nir.cpp

index a106631b4c1e4955ee74da1642d98e5a0733742c..df72b42c53902c36604493c9a7d5ea17363f5f0f 100644 (file)
@@ -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:
index 17c21cadad9129782dc57aeb136cd25ef4b4ae31..4ae45c6204d1716e371926ac8ccac648d6e6dc13 100644 (file)
@@ -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:
index ffd166f90f462690d534eed1fab55c7d51ee6107..1479962fac8a6079af71633b176329939764090d 100644 (file)
@@ -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:
index 918f060a8df507a15d0829d1cddf578c26aa3198..7ff0123b7bbce64f44df8c0cc2249a079197c396 100644 (file)
@@ -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:
index 791ec094c00563737e084c809b2c530d569b5c05..285a2564a95513328e5ea20326d769b2d1875ca1 100644 (file)
@@ -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;
index dbce55bfb8ca1fa852827d1833123321e7340a52..54fbad221a7a3f382bddb7cb3285d9a314a65ea2 100644 (file)
@@ -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);
index 578e8706818e9dd79d38ccbbc49f61c7db3b93bc..0980647c63df16b628f7896ad3c7c7c4a7dc7689 100644 (file)
@@ -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;
 
index f1ba10456ed78ad6592c982c9f898bdca6cba3ea..7a26a57c08d76f9d1d2f93e7c4d277f0cf88f030 100644 (file)
@@ -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:
index 8a0274e30a6c3557d04c1a67f19c2e8dd3420d79..22dbbae4a923b770c24f623f56ec6d79994d6dc0 100644 (file)
@@ -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: {
index c794bb90d978be682e5263565acecb3e363bd581..c3748b503a9ed586cf660aa31a8eb3972991fc90 100644 (file)
@@ -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: {