ac/nir: implement scoped_barrier
authorRhys Perry <pendingchaos02@gmail.com>
Fri, 17 Jul 2020 18:16:08 +0000 (19:16 +0100)
committerMarge Bot <eric+marge@anholt.net>
Wed, 29 Jul 2020 17:57:13 +0000 (17:57 +0000)
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5980>

src/amd/llvm/ac_nir_to_llvm.c

index 62b5d15a32b64ceabf5b62f735644dee2398f476..ef6ab7cea92fcc19fcf01880c7496ab27a47b12c 100644 (file)
@@ -3945,6 +3945,25 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
        case nir_intrinsic_memory_barrier_shared:
                emit_membar(&ctx->ac, instr);
                break;
+       case nir_intrinsic_scoped_barrier: {
+               assert(!(nir_intrinsic_memory_semantics(instr) &
+                        (NIR_MEMORY_MAKE_AVAILABLE | NIR_MEMORY_MAKE_VISIBLE)));
+
+               nir_variable_mode modes = nir_intrinsic_memory_modes(instr);
+
+               unsigned wait_flags = 0;
+               if (modes & (nir_var_mem_global | nir_var_mem_ssbo))
+                       wait_flags |= AC_WAIT_VLOAD | AC_WAIT_VSTORE;
+               if (modes & nir_var_mem_shared)
+                       wait_flags |= AC_WAIT_LGKM;
+
+               if (wait_flags)
+                       ac_build_waitcnt(&ctx->ac, wait_flags);
+
+               if (nir_intrinsic_execution_scope(instr) == NIR_SCOPE_WORKGROUP)
+                       ac_emit_barrier(&ctx->ac, ctx->stage);
+               break;
+       }
        case nir_intrinsic_memory_barrier_tcs_patch:
                break;
        case nir_intrinsic_control_barrier: