nir/lower_task_shader: insert barrier before/after shared memory read/write

Fixes: 8aff8d3dd4 ("nir: Add common task shader lowering to make the backend's job easier.")
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17143>
This commit is contained in:
Marcin Ślusarz
2022-06-20 15:41:38 +02:00
committed by Marge Bot
parent c601ba332b
commit 49b8fffeed

View File

@@ -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);