ac/nir/ngg: Mitigate NGG fully culled bug when GS output is compile-time zero.

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 <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33218>
This commit is contained in:
Timur Kristóf 2025-01-29 17:09:49 +01:00 committed by Marge Bot
parent 2b4c28e67c
commit 397d45d055

View file

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