From 17164d4e27fbccae83ae42d16f29884cba325ebc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 16 Dec 2019 19:00:00 -0500 Subject: [PATCH] radeonsi/gfx10: don't declare any LDS for NGG if it's not used Acked-by: Pierre-Eric Pelloux-Prayer --- src/gallium/drivers/radeonsi/si_shader.c | 15 +++++++++------ src/gallium/drivers/radeonsi/si_shader.h | 12 ++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 7e57337979e..e6678e026cd 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -6141,16 +6141,19 @@ static bool si_compile_tgsi_main(struct si_shader_context *ctx, * Add an extra dword per vertex to ensure an odd stride, which * avoids bank conflicts for SoA accesses. */ - declare_esgs_ring(ctx); + if (!gfx10_is_ngg_passthrough(shader)) + declare_esgs_ring(ctx); /* This is really only needed when streamout and / or vertex * compaction is enabled. */ - LLVMTypeRef asi32 = LLVMArrayType(ctx->i32, 8); - ctx->gs_ngg_scratch = LLVMAddGlobalInAddressSpace(ctx->ac.module, - asi32, "ngg_scratch", AC_ADDR_SPACE_LDS); - LLVMSetInitializer(ctx->gs_ngg_scratch, LLVMGetUndef(asi32)); - LLVMSetAlignment(ctx->gs_ngg_scratch, 4); + if (sel->so.num_outputs && !ctx->gs_ngg_scratch) { + LLVMTypeRef asi32 = LLVMArrayType(ctx->i32, 8); + ctx->gs_ngg_scratch = LLVMAddGlobalInAddressSpace(ctx->ac.module, + asi32, "ngg_scratch", AC_ADDR_SPACE_LDS); + LLVMSetInitializer(ctx->gs_ngg_scratch, LLVMGetUndef(asi32)); + LLVMSetAlignment(ctx->gs_ngg_scratch, 4); + } } /* For GFX9 merged shaders: diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index 52cc61d7978..d9a199bfa3c 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -785,6 +785,18 @@ si_get_main_shader_part(struct si_shader_selector *sel, return &sel->main_shader_part; } +static inline bool +gfx10_is_ngg_passthrough(struct si_shader *shader) +{ + struct si_shader_selector *sel = shader->selector; + + return sel->type != PIPE_SHADER_GEOMETRY && + !sel->so.num_outputs && + !sel->info.writes_edgeflag && + (sel->type != PIPE_SHADER_VERTEX || + !shader->key.mono.u.vs_export_prim_id); +} + static inline bool si_shader_uses_bindless_samplers(struct si_shader_selector *selector) { -- 2.30.2