Module: Mesa
Branch: main
Commit: 91fa9397639ded341c7eb48644d3004584683bb3
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=91fa9397639ded341c7eb48644d3004584683bb3

Author: Caio Oliveira <[email protected]>
Date:   Sun Feb 26 22:02:49 2023 -0800

panfrost: Use NIR scoped barriers instead of memory barriers

Now both GLSL and SPIR-V will produce the scoped barriers, so no
need to handle the old ones.

Control barriers are still present in some cases, so keep that
for now.

Reviewed-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3339>

---

 src/panfrost/compiler/bifrost_compile.c |  9 ---------
 src/panfrost/compiler/bifrost_compile.h |  2 ++
 src/panfrost/midgard/midgard_compile.c  | 11 -----------
 src/panfrost/midgard/midgard_compile.h  |  2 ++
 4 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/src/panfrost/compiler/bifrost_compile.c 
b/src/panfrost/compiler/bifrost_compile.c
index 0931261f38b..daf8d160e9c 100644
--- a/src/panfrost/compiler/bifrost_compile.c
+++ b/src/panfrost/compiler/bifrost_compile.c
@@ -1640,15 +1640,6 @@ bi_emit_intrinsic(bi_builder *b, nir_intrinsic_instr 
*instr)
       bi_emit_store(b, instr, BI_SEG_WLS);
       break;
 
-   /* Blob doesn't seem to do anything for memory barriers, note +BARRIER
-    * is illegal in fragment shaders */
-   case nir_intrinsic_memory_barrier:
-   case nir_intrinsic_memory_barrier_buffer:
-   case nir_intrinsic_memory_barrier_image:
-   case nir_intrinsic_memory_barrier_shared:
-   case nir_intrinsic_group_memory_barrier:
-      break;
-
    case nir_intrinsic_control_barrier:
       assert(b->shader->stage != MESA_SHADER_FRAGMENT);
       bi_barrier(b);
diff --git a/src/panfrost/compiler/bifrost_compile.h 
b/src/panfrost/compiler/bifrost_compile.h
index 69ce3ac9511..58d265bf7f0 100644
--- a/src/panfrost/compiler/bifrost_compile.h
+++ b/src/panfrost/compiler/bifrost_compile.h
@@ -92,6 +92,8 @@ static const nir_shader_compiler_options bifrost_nir_options 
= {
    .force_indirect_unrolling =
       (nir_var_shader_in | nir_var_shader_out | nir_var_function_temp),
    .force_indirect_unrolling_sampler = true,
+
+   .use_scoped_barrier = true,
 };
 
 #endif
diff --git a/src/panfrost/midgard/midgard_compile.c 
b/src/panfrost/midgard/midgard_compile.c
index 6a1db58333b..13d454faf1a 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -2103,17 +2103,6 @@ emit_intrinsic(compiler_context *ctx, 
nir_intrinsic_instr *instr)
       emit_special(ctx, instr, 97);
       break;
 
-   /* Midgard doesn't seem to want special handling, though we do need to
-    * take care when scheduling to avoid incorrect reordering.
-    */
-   case nir_intrinsic_memory_barrier:
-   case nir_intrinsic_memory_barrier_buffer:
-   case nir_intrinsic_memory_barrier_image:
-   case nir_intrinsic_memory_barrier_shared:
-   case nir_intrinsic_group_memory_barrier:
-      schedule_barrier(ctx);
-      break;
-
    case nir_intrinsic_control_barrier:
       schedule_barrier(ctx);
       emit_control_barrier(ctx);
diff --git a/src/panfrost/midgard/midgard_compile.h 
b/src/panfrost/midgard/midgard_compile.h
index 1b88eb11339..83965280ccd 100644
--- a/src/panfrost/midgard/midgard_compile.h
+++ b/src/panfrost/midgard/midgard_compile.h
@@ -101,6 +101,8 @@ static const nir_shader_compiler_options 
midgard_nir_options = {
    .force_indirect_unrolling =
       (nir_var_shader_in | nir_var_shader_out | nir_var_function_temp),
    .force_indirect_unrolling_sampler = true,
+
+   .use_scoped_barrier = true,
 };
 
 #endif

Reply via email to