From 49b8fffeed9dc9b6002d69cf16edffe059112daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=9Alusarz?= Date: Mon, 20 Jun 2022 15:41:38 +0200 Subject: [PATCH] nir/lower_task_shader: insert barrier before/after shared memory read/write MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: 8aff8d3dd42 ("nir: Add common task shader lowering to make the backend's job easier.") Reviewed-by: Timur Kristóf Part-of: --- src/compiler/nir/nir_lower_task_shader.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/compiler/nir/nir_lower_task_shader.c b/src/compiler/nir/nir_lower_task_shader.c index e242c0d1171..6d7040828fe 100644 --- a/src/compiler/nir/nir_lower_task_shader.c +++ b/src/compiler/nir/nir_lower_task_shader.c @@ -88,10 +88,23 @@ append_launch_mesh_workgroups_to_nv_task(nir_builder *b, nir_ssa_def *zero = nir_imm_int(b, 0); nir_store_shared(b, zero, zero, .base = s->task_count_shared_addr); + nir_scoped_barrier(b, + .execution_scope = NIR_SCOPE_WORKGROUP, + .memory_scope = NIR_SCOPE_WORKGROUP, + .memory_semantics = NIR_MEMORY_RELEASE, + .memory_modes = nir_var_mem_shared); + /* At the end of the shader, read the task count from shared memory * and emit launch_mesh_workgroups. */ b->cursor = nir_after_cf_list(&b->impl->body); + + nir_scoped_barrier(b, + .execution_scope = NIR_SCOPE_WORKGROUP, + .memory_scope = NIR_SCOPE_WORKGROUP, + .memory_semantics = NIR_MEMORY_ACQUIRE, + .memory_modes = nir_var_mem_shared); + nir_ssa_def *task_count = nir_load_shared(b, 1, 32, zero, .base = s->task_count_shared_addr);