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

Author: Daniel Schürmann <[email protected]>
Date:   Mon Apr  3 11:14:49 2023 +0200

aco: don't use shared VGPRs for shaders consisting of multiple binaries

When using multiple binaries, we don't know the required number of VGPRs 
beforehand,
which means we either have to over-allocate VGPRs or avoid shared VGPRs.
As bpermute is the only instructions needing shared VGPRs, we decide for the 
latter.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22267>

---

 src/amd/compiler/aco_instruction_selection.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/amd/compiler/aco_instruction_selection.cpp 
b/src/amd/compiler/aco_instruction_selection.cpp
index 6a47812531d..ed86cdd0177 100644
--- a/src/amd/compiler/aco_instruction_selection.cpp
+++ b/src/amd/compiler/aco_instruction_selection.cpp
@@ -192,7 +192,17 @@ emit_bpermute(isel_context* ctx, Builder& bld, Temp index, 
Temp data)
    if (index.regClass() == s1)
       return bld.readlane(bld.def(s1), data, index);
 
-   if (ctx->options->gfx_level <= GFX7) {
+   /* Avoid using shared VGPRs for shuffle on GFX10 when the shader consists
+    * of multiple binaries, because the VGPR use is not known when choosing
+    * which registers to use for the shared VGPRs.
+    */
+   const bool avoid_shared_vgprs =
+      ctx->options->gfx_level >= GFX10 && ctx->options->gfx_level < GFX11 &&
+      ctx->program->wave_size == 64 &&
+      ((ctx->stage == fragment_fs && ctx->program->info.ps.has_epilog) ||
+       ctx->stage == raytracing_cs);
+
+   if (ctx->options->gfx_level <= GFX7 || avoid_shared_vgprs) {
       /* GFX6-7: there is no bpermute instruction */
       Operand index_op(index);
       Operand input_data(data);

Reply via email to