radeonsi/gfx10: don't declare any LDS for NGG if it's not used
authorMarek Olšák <marek.olsak@amd.com>
Tue, 17 Dec 2019 00:00:00 +0000 (19:00 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 27 Dec 2019 18:50:57 +0000 (13:50 -0500)
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h

index 7e57337979ec7f157fd321fbac7e8048356163a0..e6678e026cd4691b730c0091d9e0e5f78ae10d09 100644 (file)
@@ -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:
index 52cc61d7978081d70898d20913793b379e315ab0..d9a199bfa3c3a70a28dcf61e6f4f0d140abdbead 100644 (file)
@@ -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)
 {