From 9757c3cb6b810431f3ea1fdeca97da4aeeef384d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20Krist=C3=B3f?= Date: Thu, 15 Oct 2020 10:58:34 +0200 Subject: [PATCH] aco: Assert that workgroup barriers are not used inappropriately. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Example: It is possible for some NGG GS waves to have 0 ES and/or GS invocations, and in that case having an s_barrier inside divergent control flow can very possibly hang the GPU. Signed-off-by: Timur Kristóf Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_instruction_selection.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index 3b1d8ab5799..6717c6e6280 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -6559,6 +6559,11 @@ void emit_scoped_barrier(isel_context *ctx, nir_intrinsic_instr *instr) { assert(!(nir_semantics & (NIR_MEMORY_MAKE_AVAILABLE | NIR_MEMORY_MAKE_VISIBLE))); + /* Workgroup barriers can hang merged shaders that can potentially have 0 threads in either half. */ + assert(exec_scope != scope_workgroup || + ctx->shader->info.stage == MESA_SHADER_COMPUTE || + ctx->shader->info.stage == MESA_SHADER_TESS_CTRL); + bld.barrier(aco_opcode::p_barrier, memory_sync_info((storage_class)storage, (memory_semantics)semantics, mem_scope), exec_scope);