From 7b4427b199f5aea6952d779eceeab5f7e8bae05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 1 Sep 2021 03:43:34 -0400 Subject: [PATCH] radeonsi: enable NGG passthrough when LDS is used, document the real constraints Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/gfx10_shader_ngg.c | 2 +- src/gallium/drivers/radeonsi/si_shader_llvm.c | 6 +----- src/gallium/drivers/radeonsi/si_state_shaders.c | 12 +++++++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c b/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c index 7a92ab91feb..69f18f9fe20 100644 --- a/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c +++ b/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c @@ -1339,7 +1339,7 @@ void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi) LLVMValueRef is_es_thread = si_is_es_thread(ctx); LLVMValueRef vtxindex[3]; - if (ctx->shader->key.opt.ngg_culling) { + if (ctx->shader->key.opt.ngg_culling || gfx10_is_ngg_passthrough(ctx->shader)) { for (unsigned i = 0; i < 3; ++i) vtxindex[i] = si_unpack_param(ctx, ctx->args.gs_vtx_offset[0], 10 * i, 9); } else { diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm.c b/src/gallium/drivers/radeonsi/si_shader_llvm.c index 083d73fca75..1a1dd07a507 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm.c @@ -896,12 +896,8 @@ bool si_llvm_translate_nir(struct si_shader_context *ctx, struct si_shader *shad /* Unconditionally declare scratch space base for streamout and * vertex compaction. Whether space is actually allocated is * determined during linking / PM4 creation. - * - * Add an extra dword per vertex to ensure an odd stride, which - * avoids bank conflicts for SoA accesses. */ - if (!gfx10_is_ngg_passthrough(shader)) - si_llvm_declare_esgs_ring(ctx); + si_llvm_declare_esgs_ring(ctx); /* This is really only needed when streamout and / or vertex * compaction is enabled. diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 76d96a56152..3ecbd5664a6 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -983,9 +983,15 @@ bool gfx10_is_ngg_passthrough(struct si_shader *shader) if (sel->screen->use_ngg_culling) return false; - return sel->info.stage != MESA_SHADER_GEOMETRY && !sel->so.num_outputs && !sel->info.writes_edgeflag && - !shader->key.opt.ngg_culling && - (sel->info.stage != MESA_SHADER_VERTEX || !shader->key.mono.u.vs_export_prim_id); + /* The definition of NGG passthrough is: + * - user GS is turned off (no amplification, no GS instancing, and no culling) + * - VGT_ESGS_RING_ITEMSIZE is ignored (behaving as if it was equal to 1) + * - vertex indices are packed into 1 VGPR + * - Dimgrey and later chips can optionally skip the gs_alloc_req message + * + * NGG passthrough still allows the use of LDS. + */ + return sel->info.stage != MESA_SHADER_GEOMETRY && !shader->key.opt.ngg_culling; } /* Common tail code for NGG primitive shaders. */