[Mesa-dev] [PATCH 04/21] etnaviv: add debug option to report NIR as supported and preferred shader IR

Philipp Zabel p.zabel at pengutronix.de
Tue Jun 5 14:38:28 UTC 2018


Add a debug option ETNA_MESA_DEBUG="nir" that will cause the etnaviv
gallium pipe driver to advertise support and preference for NIR shaders.

Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>
Signed-off-by: Michael Tretter <m.tretter at pengutronix.de>
---
 src/gallium/drivers/etnaviv/etnaviv_debug.h  |  3 +++
 src/gallium/drivers/etnaviv/etnaviv_screen.c | 11 +++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_debug.h b/src/gallium/drivers/etnaviv/etnaviv_debug.h
index 4051e95dd5fb..8dacf6b2433e 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_debug.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_debug.h
@@ -54,6 +54,9 @@
 #define ETNA_DBG_SHADERDB        0x800000 /* dump program compile information */
 #define ETNA_DBG_NO_SINGLEBUF    0x1000000 /* disable single buffer feature */
 
+/* Experimental features */
+#define ETNA_DBG_NIR		0x10000000 /* Enable NIR compiler */
+
 extern int etna_mesa_debug; /* set in etna_screen.c from ETNA_DEBUG */
 
 #define DBG_ENABLED(flag) unlikely(etna_mesa_debug & (flag))
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index e031807117c0..d3b3f507adf0 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -65,6 +65,7 @@ static const struct debug_named_value debug_options[] = {
    {"cflush_all",     ETNA_DBG_CFLUSH_ALL, "Flush every cash before state update"},
    {"msaa2x",         ETNA_DBG_MSAA_2X, "Force 2x msaa"},
    {"msaa4x",         ETNA_DBG_MSAA_4X, "Force 4x msaa"},
+   {"nir",            ETNA_DBG_NIR, "Enable experimental NIR compiler"},
    {"flush_all",      ETNA_DBG_FLUSH_ALL, "Flush after every rendered primitive"},
    {"zero",           ETNA_DBG_ZERO, "Zero all resources after allocation"},
    {"draw_stall",     ETNA_DBG_DRAW_STALL, "Stall FE/PE after each rendered primitive"},
@@ -454,7 +455,10 @@ etna_screen_get_shader_param(struct pipe_screen *pscreen,
                 ? screen->specs.fragment_sampler_count
                 : screen->specs.vertex_sampler_count;
    case PIPE_SHADER_CAP_PREFERRED_IR:
-      return PIPE_SHADER_IR_TGSI;
+      if (etna_mesa_debug & ETNA_DBG_NIR)
+         return PIPE_SHADER_IR_NIR;
+      else
+         return PIPE_SHADER_IR_TGSI;
    case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
       return 4096;
    case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED:
@@ -464,7 +468,10 @@ etna_screen_get_shader_param(struct pipe_screen *pscreen,
    case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE:
       return false;
    case PIPE_SHADER_CAP_SUPPORTED_IRS:
-      return 0;
+      if (etna_mesa_debug & ETNA_DBG_NIR)
+         return (1 << PIPE_SHADER_IR_TGSI) | (1 << PIPE_SHADER_IR_NIR);
+      else
+         return (1 << PIPE_SHADER_IR_TGSI);
    case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT:
       return 32;
    case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS:
-- 
2.17.1



More information about the mesa-dev mailing list