Module: Mesa
Branch: main
Commit: fbe7aec446f177ca8e0910a157c63f1d4b1df7be
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fbe7aec446f177ca8e0910a157c63f1d4b1df7be

Author: Qiang Yu <[email protected]>
Date:   Fri Apr 14 15:51:34 2023 +0800

aco: skip scratch buffer init when its arg is not used

radeonsi does not pass scratch buffer address by arg,
but dynamical relocation symbol when upload. Just skip
this part to enable radeonsi use aco, but it will fail
when spill.

Reviewed-by: Rhys Perry <[email protected]>
Signed-off-by: Qiang Yu <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22525>

---

 src/amd/compiler/aco_instruction_selection.cpp | 28 ++++++++++++++------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/amd/compiler/aco_instruction_selection.cpp 
b/src/amd/compiler/aco_instruction_selection.cpp
index 7e9c82f6413..33a88ebf7e7 100644
--- a/src/amd/compiler/aco_instruction_selection.cpp
+++ b/src/amd/compiler/aco_instruction_selection.cpp
@@ -11252,20 +11252,22 @@ add_startpgm(struct isel_context* ctx)
       }
    }
 
-   if (ctx->program->gfx_level < GFX9) {
-      /* Stash these in the program so that they can be accessed later when
-       * handling spilling.
-       */
-      ctx->program->private_segment_buffer = get_arg(ctx, 
ctx->args->ring_offsets);
-      ctx->program->scratch_offset = get_arg(ctx, ctx->args->scratch_offset);
+   if (ctx->args->ring_offsets.used) {
+      if (ctx->program->gfx_level < GFX9) {
+         /* Stash these in the program so that they can be accessed later when
+          * handling spilling.
+          */
+         ctx->program->private_segment_buffer = get_arg(ctx, 
ctx->args->ring_offsets);
+         ctx->program->scratch_offset = get_arg(ctx, 
ctx->args->scratch_offset);
 
-   } else if (ctx->program->gfx_level <= GFX10_3 && ctx->program->stage != 
raytracing_cs) {
-      /* Manually initialize scratch. For RT stages scratch initialization is 
done in the prolog. */
-      Operand scratch_offset = Operand(get_arg(ctx, 
ctx->args->scratch_offset));
-      scratch_offset.setLateKill(true);
-      Builder bld(ctx->program, ctx->block);
-      bld.pseudo(aco_opcode::p_init_scratch, bld.def(s2), bld.def(s1, scc),
-                 get_arg(ctx, ctx->args->ring_offsets), scratch_offset);
+      } else if (ctx->program->gfx_level <= GFX10_3 && ctx->program->stage != 
raytracing_cs) {
+         /* Manually initialize scratch. For RT stages scratch initialization 
is done in the prolog. */
+         Operand scratch_offset = Operand(get_arg(ctx, 
ctx->args->scratch_offset));
+         scratch_offset.setLateKill(true);
+         Builder bld(ctx->program, ctx->block);
+         bld.pseudo(aco_opcode::p_init_scratch, bld.def(s2), bld.def(s1, scc),
+                    get_arg(ctx, ctx->args->ring_offsets), scratch_offset);
+      }
    }
 
    return startpgm;

Reply via email to