r600/sfn: Tie in address load splitting
authorGert Wollny <gert.wollny@collabora.com>
Mon, 17 Apr 2023 10:06:45 +0000 (12:06 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 28 Apr 2023 13:13:55 +0000 (13:13 +0000)
Add R600_NIR_DEBUG flag "noaddrsplit" to disable the behaviour and use the
old code path.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21347>

src/gallium/drivers/r600/sfn/sfn_debug.cpp
src/gallium/drivers/r600/sfn/sfn_debug.h
src/gallium/drivers/r600/sfn/sfn_nir.cpp

index d23123c..9bfd375 100644 (file)
@@ -65,6 +65,7 @@ static const struct debug_named_value sfn_debug_options[] = {
    {"opt",      SfnLog::opt,         "Log optimization"                     },
    {"steps",    SfnLog::steps,       "Log shaders at transformation steps"  },
    {"noopt",    SfnLog::noopt,       "Don't run backend optimizations"      },
+   {"noaddrsplit", SfnLog::noaddrsplit, "Don't split address loads early"   },
    DEBUG_NAMED_VALUE_END
 };
 
index be7c3bb..5cedf77 100644 (file)
@@ -69,7 +69,8 @@ public:
       all = (1 << 15) - 1,
       nomerge = 1 << 16,
       steps = 1 << 17,
-      noopt = 1 << 18
+      noopt = 1 << 18,
+      noaddrsplit = 1 << 19
    };
 
    SfnLog();
index 4ba3fb5..6d0d588 100644 (file)
@@ -43,6 +43,7 @@
 #include "sfn_ra.h"
 #include "sfn_scheduler.h"
 #include "sfn_shader.h"
+#include "sfn_split_address_loads.h"
 #include "util/u_prim.h"
 
 #include <vector>
@@ -1006,6 +1007,23 @@ r600_shader_from_nir(struct r600_context *rctx,
       }
    }
 
+   if (!r600::sfn_log.has_debug_flag(r600::SfnLog::noaddrsplit))
+      split_address_loads(*shader);
+   
+   if (r600::sfn_log.has_debug_flag(r600::SfnLog::steps)) {
+      std::cerr << "Shader after splitting address loads\n";
+      shader->print(std::cerr);
+   }
+   
+   if (!r600::sfn_log.has_debug_flag(r600::SfnLog::noopt)) {
+      optimize(*shader);
+
+      if (r600::sfn_log.has_debug_flag(r600::SfnLog::steps)) {
+         std::cerr << "Shader after optimization\n";
+         shader->print(std::cerr);
+      }
+   }
+
    auto scheduled_shader = r600::schedule(shader);
    if (r600::sfn_log.has_debug_flag(r600::SfnLog::steps)) {
       std::cerr << "Shader after scheduling\n";
@@ -1044,9 +1062,10 @@ r600_shader_from_nir(struct r600_context *rctx,
 
    /* We already schedule the code with this in mind, no need to handle this
     * in the backend assembler */
-   pipeshader->shader.bc.ar_handling = AR_HANDLE_NORMAL;
-   pipeshader->shader.bc.r6xx_nop_after_rel_dst = 0;
-
+   if (!r600::sfn_log.has_debug_flag(r600::SfnLog::noaddrsplit)) {
+      pipeshader->shader.bc.ar_handling = AR_HANDLE_NORMAL;
+      pipeshader->shader.bc.r6xx_nop_after_rel_dst = 0;
+   }
 
    r600::sfn_log << r600::SfnLog::shader_info << "pipeshader->shader.processor_type = "
                  << pipeshader->shader.processor_type << "\n";