From 397d45d05569d77f3191aa68086fc7432d74fd8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20Krist=C3=B3f?= Date: Wed, 29 Jan 2025 17:09:49 +0100 Subject: [PATCH] ac/nir/ngg: Mitigate NGG fully culled bug when GS output is compile-time zero. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This case is unlikely but possible. We forgot to handle it here, because it was originally handled by the backend compiler. On GFX10 chips that have issues with 0 vertices and primitives exported, this will always export at least 1 vertex and primitive. This could theoretically fix some hangs on Navi 10, although we are not aware of a specific issue caused by this problem. Cc: mesa-stable Reviewed-by: Marek Olšák Part-of: --- src/amd/common/nir/ac_nir_lower_ngg.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/amd/common/nir/ac_nir_lower_ngg.c b/src/amd/common/nir/ac_nir_lower_ngg.c index 4fcacbe8868..86acb7defe6 100644 --- a/src/amd/common/nir/ac_nir_lower_ngg.c +++ b/src/amd/common/nir/ac_nir_lower_ngg.c @@ -3444,7 +3444,16 @@ ngg_gs_finale(nir_builder *b, lower_ngg_gs_state *s) * The gs_alloc_req needs to happen on one wave only, otherwise the HW hangs. */ nir_if *if_wave_0 = nir_push_if(b, nir_ieq_imm(b, nir_load_subgroup_id(b), 0)); - alloc_vertices_and_primitives(b, max_vtxcnt, max_prmcnt); + { + /* When the GS outputs 0 vertices, make the vertex and primitive count compile-time zero. */ + if (b->shader->info.gs.vertices_out == 0) + max_vtxcnt = max_prmcnt = nir_imm_int(b, 0); + + if (s->options->gfx_level == GFX10) + alloc_vertices_and_primitives_gfx10_workaround(b, max_vtxcnt, max_prmcnt); + else + alloc_vertices_and_primitives(b, max_vtxcnt, max_prmcnt); + } nir_pop_if(b, if_wave_0); }