Mesa (main): ac/nir/ngg: Move primitive ID workgroup barrier to proper place.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 21 22:18:47 UTC 2022


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

Author: Timur Kristóf <timur.kristof at gmail.com>
Date:   Mon Jul 18 15:42:57 2022 +0200

ac/nir/ngg: Move primitive ID workgroup barrier to proper place.

Previously, it was in a divergent branch, therefore
it could hang the GPU when a workgroup had a primitive-only wave.

Signed-off-by: Timur Kristóf <timur.kristof at gmail.com>
Reviewed-by: Qiang Yu <yuq825 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17581>

---

 src/amd/common/ac_nir_lower_ngg.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/amd/common/ac_nir_lower_ngg.c b/src/amd/common/ac_nir_lower_ngg.c
index b7e7ec8ba9f..fdb38279e3b 100644
--- a/src/amd/common/ac_nir_lower_ngg.c
+++ b/src/amd/common/ac_nir_lower_ngg.c
@@ -480,10 +480,6 @@ emit_store_ngg_nogs_es_primitive_id(nir_builder *b)
    nir_ssa_def *prim_id = NULL;
 
    if (b->shader->info.stage == MESA_SHADER_VERTEX) {
-      /* Workgroup barrier - wait for GS threads to store primitive ID in LDS. */
-      nir_scoped_barrier(b, .execution_scope = NIR_SCOPE_WORKGROUP, .memory_scope = NIR_SCOPE_WORKGROUP,
-                            .memory_semantics = NIR_MEMORY_ACQ_REL, .memory_modes = nir_var_mem_shared);
-
       /* LDS address where the primitive ID is stored */
       nir_ssa_def *thread_id_in_threadgroup = nir_load_local_invocation_index(b);
       nir_ssa_def *addr =  pervertex_lds_addr(b, thread_id_in_threadgroup, 4u);
@@ -1466,6 +1462,10 @@ ac_nir_lower_ngg_nogs(nir_shader *shader,
       }
 
       emit_ngg_nogs_prim_id_store_shared(b, &state);
+
+      /* Wait for GS threads to store primitive ID in LDS. */
+      nir_scoped_barrier(b, .execution_scope = NIR_SCOPE_WORKGROUP, .memory_scope = NIR_SCOPE_WORKGROUP,
+                            .memory_semantics = NIR_MEMORY_ACQ_REL, .memory_modes = nir_var_mem_shared);
    }
 
    nir_intrinsic_instr *export_vertex_instr;



More information about the mesa-commit mailing list