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

Author: Alyssa Rosenzweig <[email protected]>
Date:   Tue Feb 14 23:38:58 2023 -0500

agx: Add AGX_MESA_DEBUG=nopreamble option

Useful both for ruling out issues with shader preambles as well as (in some
cases) making for a nicer reading experience of the compiled assembly.

Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21430>

---

 src/asahi/compiler/agx_compile.c  | 4 +++-
 src/asahi/compiler/agx_compiler.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c
index b8d1333b401..f24cdaed1f4 100644
--- a/src/asahi/compiler/agx_compile.c
+++ b/src/asahi/compiler/agx_compile.c
@@ -46,6 +46,7 @@ static const struct debug_named_value agx_debug_options[] = {
    {"novalidate",AGX_DBG_NOVALIDATE,"Skip IR validation in debug builds"},
    {"noopt",     AGX_DBG_NOOPT,     "Disable backend optimizations"},
    {"wait",      AGX_DBG_WAIT,      "Wait after all async instructions"},
+   {"nopreamble",AGX_DBG_NOPREAMBLE,"Do not use shader preambles"},
    DEBUG_NAMED_VALUE_END
 };
 /* clang-format on */
@@ -1909,7 +1910,8 @@ agx_optimize_nir(nir_shader *nir, unsigned *preamble_size)
    NIR_PASS_V(nir, agx_nir_lower_address);
    NIR_PASS_V(nir, nir_lower_int64);
 
-   NIR_PASS_V(nir, agx_nir_opt_preamble, preamble_size);
+   if (likely(!(agx_debug & AGX_DBG_NOPREAMBLE)))
+      NIR_PASS_V(nir, agx_nir_opt_preamble, preamble_size);
 
    /* Forming preambles may dramatically reduce the instruction count
     * in certain blocks, causing some if-else statements to become
diff --git a/src/asahi/compiler/agx_compiler.h 
b/src/asahi/compiler/agx_compiler.h
index 2a80fab6068..da1ac2a7c34 100644
--- a/src/asahi/compiler/agx_compiler.h
+++ b/src/asahi/compiler/agx_compiler.h
@@ -48,6 +48,7 @@ enum agx_dbg {
    AGX_DBG_NOVALIDATE  = BITFIELD_BIT(5),
    AGX_DBG_NOOPT       = BITFIELD_BIT(6),
    AGX_DBG_WAIT        = BITFIELD_BIT(7),
+   AGX_DBG_NOPREAMBLE  = BITFIELD_BIT(8),
 };
 /* clang-format on */
 

Reply via email to