Mesa (master): etnaviv: move etna_dump_shader(..) to generic location

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 3 08:40:22 UTC 2020


Module: Mesa
Branch: master
Commit: 2dc73d2c7f7c8c6a51d1631a38eb02f0b3f7ab7b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2dc73d2c7f7c8c6a51d1631a38eb02f0b3f7ab7b

Author: Christian Gmeiner <christian.gmeiner at gmail.com>
Date:   Fri Oct 30 19:26:00 2020 +0100

etnaviv: move etna_dump_shader(..) to generic location

Before this change we had two identical etna_dump_shader
functions - one for tgsi and one for nir.

Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
Reviewed-by: Lucas Stach <l.stach at pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7397>

---

 src/gallium/drivers/etnaviv/etnaviv_compiler.h     |  3 --
 src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c | 51 ------------------
 .../drivers/etnaviv/etnaviv_compiler_tgsi.c        | 52 -------------------
 src/gallium/drivers/etnaviv/etnaviv_shader.c       | 60 +++++++++++++++++++---
 4 files changed, 53 insertions(+), 113 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.h b/src/gallium/drivers/etnaviv/etnaviv_compiler.h
index 3646baec52b..e7d977c4dd4 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.h
@@ -167,9 +167,6 @@ etna_destroy_shader(struct etna_shader_variant *shader);
 bool
 etna_compile_shader_nir(struct etna_shader_variant *shader);
 
-void
-etna_dump_shader_nir(const struct etna_shader_variant *shader);
-
 bool
 etna_link_shader_nir(struct etna_shader_link_info *info,
                      const struct etna_shader_variant *vs,
diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c
index 27aa2c21379..bbf5f45f7f2 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c
@@ -31,7 +31,6 @@
 #include "etnaviv_asm.h"
 #include "etnaviv_context.h"
 #include "etnaviv_debug.h"
-#include "etnaviv_disasm.h"
 #include "etnaviv_nir.h"
 #include "etnaviv_uniforms.h"
 #include "etnaviv_util.h"
@@ -1197,56 +1196,6 @@ etna_destroy_shader_nir(struct etna_shader_variant *shader)
    FREE(shader);
 }
 
-extern const char *tgsi_swizzle_names[];
-void
-etna_dump_shader_nir(const struct etna_shader_variant *shader)
-{
-   if (shader->stage == MESA_SHADER_VERTEX)
-      printf("VERT\n");
-   else
-      printf("FRAG\n");
-
-   etna_disasm(shader->code, shader->code_size, PRINT_RAW);
-
-   printf("num loops: %i\n", shader->num_loops);
-   printf("num temps: %i\n", shader->num_temps);
-   printf("immediates:\n");
-   for (int idx = 0; idx < shader->uniforms.imm_count; ++idx) {
-      printf(" [%i].%s = %f (0x%08x) (%d)\n",
-             idx / 4,
-             tgsi_swizzle_names[idx % 4],
-             *((float *)&shader->uniforms.imm_data[idx]),
-             shader->uniforms.imm_data[idx],
-             shader->uniforms.imm_contents[idx]);
-   }
-   printf("inputs:\n");
-   for (int idx = 0; idx < shader->infile.num_reg; ++idx) {
-      printf(" [%i] name=%s comps=%i\n", shader->infile.reg[idx].reg,
-               (shader->stage == MESA_SHADER_VERTEX) ?
-               gl_vert_attrib_name(shader->infile.reg[idx].slot) :
-               gl_varying_slot_name(shader->infile.reg[idx].slot),
-               shader->infile.reg[idx].num_components);
-   }
-   printf("outputs:\n");
-   for (int idx = 0; idx < shader->outfile.num_reg; ++idx) {
-      printf(" [%i] name=%s comps=%i\n", shader->outfile.reg[idx].reg,
-               (shader->stage == MESA_SHADER_VERTEX) ?
-               gl_varying_slot_name(shader->outfile.reg[idx].slot) :
-               gl_frag_result_name(shader->outfile.reg[idx].slot),
-               shader->outfile.reg[idx].num_components);
-   }
-   printf("special:\n");
-   if (shader->stage == MESA_SHADER_VERTEX) {
-      printf("  vs_pos_out_reg=%i\n", shader->vs_pos_out_reg);
-      printf("  vs_pointsize_out_reg=%i\n", shader->vs_pointsize_out_reg);
-      printf("  vs_load_balancing=0x%08x\n", shader->vs_load_balancing);
-   } else {
-      printf("  ps_color_out_reg=%i\n", shader->ps_color_out_reg);
-      printf("  ps_depth_out_reg=%i\n", shader->ps_depth_out_reg);
-   }
-   printf("  input_count_unk8=0x%08x\n", shader->input_count_unk8);
-}
-
 static const struct etna_shader_inout *
 etna_shader_vs_lookup(const struct etna_shader_variant *sobj,
                       const struct etna_shader_inout *in)
diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_tgsi.c b/src/gallium/drivers/etnaviv/etnaviv_compiler_tgsi.c
index ee52f596350..5ddc1cd9d1a 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler_tgsi.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_tgsi.c
@@ -53,7 +53,6 @@
 #include "etnaviv_asm.h"
 #include "etnaviv_context.h"
 #include "etnaviv_debug.h"
-#include "etnaviv_disasm.h"
 #include "etnaviv_uniforms.h"
 #include "etnaviv_util.h"
 
@@ -2502,57 +2501,6 @@ out:
    return ret;
 }
 
-extern const char *tgsi_swizzle_names[];
-void
-etna_dump_shader(const struct etna_shader_variant *shader)
-{
-   if (shader->stage == MESA_SHADER_VERTEX)
-      printf("VERT\n");
-   else
-      printf("FRAG\n");
-
-
-   etna_disasm(shader->code, shader->code_size, PRINT_RAW);
-
-   printf("num loops: %i\n", shader->num_loops);
-   printf("num temps: %i\n", shader->num_temps);
-   printf("immediates:\n");
-   for (int idx = 0; idx < shader->uniforms.imm_count; ++idx) {
-      printf(" [%i].%s = %f (0x%08x) (%d)\n",
-             idx / 4,
-             tgsi_swizzle_names[idx % 4],
-             *((float *)&shader->uniforms.imm_data[idx]),
-             shader->uniforms.imm_data[idx],
-             shader->uniforms.imm_contents[idx]);
-   }
-   printf("inputs:\n");
-   for (int idx = 0; idx < shader->infile.num_reg; ++idx) {
-      printf(" [%i] name=%s comps=%i\n", shader->infile.reg[idx].reg,
-               (shader->stage == MESA_SHADER_VERTEX) ?
-               gl_vert_attrib_name(shader->infile.reg[idx].slot) :
-               gl_varying_slot_name(shader->infile.reg[idx].slot),
-               shader->infile.reg[idx].num_components);
-   }
-   printf("outputs:\n");
-   for (int idx = 0; idx < shader->outfile.num_reg; ++idx) {
-      printf(" [%i] name=%s comps=%i\n", shader->outfile.reg[idx].reg,
-               (shader->stage == MESA_SHADER_VERTEX) ?
-               gl_varying_slot_name(shader->outfile.reg[idx].slot) :
-               gl_frag_result_name(shader->outfile.reg[idx].slot),
-               shader->outfile.reg[idx].num_components);
-   }
-   printf("special:\n");
-   if (shader->stage == MESA_SHADER_VERTEX) {
-      printf("  vs_pos_out_reg=%i\n", shader->vs_pos_out_reg);
-      printf("  vs_pointsize_out_reg=%i\n", shader->vs_pointsize_out_reg);
-      printf("  vs_load_balancing=0x%08x\n", shader->vs_load_balancing);
-   } else {
-      printf("  ps_color_out_reg=%i\n", shader->ps_color_out_reg);
-      printf("  ps_depth_out_reg=%i\n", shader->ps_depth_out_reg);
-   }
-   printf("  input_count_unk8=0x%08x\n", shader->input_count_unk8);
-}
-
 void
 etna_destroy_shader(struct etna_shader_variant *shader)
 {
diff --git a/src/gallium/drivers/etnaviv/etnaviv_shader.c b/src/gallium/drivers/etnaviv/etnaviv_shader.c
index 5564a2ff4dc..eab551e3506 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_shader.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_shader.c
@@ -29,6 +29,7 @@
 #include "etnaviv_compiler.h"
 #include "etnaviv_context.h"
 #include "etnaviv_debug.h"
+#include "etnaviv_disasm.h"
 #include "etnaviv_disk_cache.h"
 #include "etnaviv_screen.h"
 #include "etnaviv_util.h"
@@ -56,6 +57,56 @@ static bool etna_icache_upload_shader(struct etna_context *ctx, struct etna_shad
    return true;
 }
 
+extern const char *tgsi_swizzle_names[];
+void
+etna_dump_shader(const struct etna_shader_variant *shader)
+{
+   if (shader->stage == MESA_SHADER_VERTEX)
+      printf("VERT\n");
+   else
+      printf("FRAG\n");
+
+   etna_disasm(shader->code, shader->code_size, PRINT_RAW);
+
+   printf("num loops: %i\n", shader->num_loops);
+   printf("num temps: %i\n", shader->num_temps);
+   printf("immediates:\n");
+   for (int idx = 0; idx < shader->uniforms.imm_count; ++idx) {
+      printf(" [%i].%s = %f (0x%08x) (%d)\n",
+             idx / 4,
+             tgsi_swizzle_names[idx % 4],
+             *((float *)&shader->uniforms.imm_data[idx]),
+             shader->uniforms.imm_data[idx],
+             shader->uniforms.imm_contents[idx]);
+   }
+   printf("inputs:\n");
+   for (int idx = 0; idx < shader->infile.num_reg; ++idx) {
+      printf(" [%i] name=%s comps=%i\n", shader->infile.reg[idx].reg,
+               (shader->stage == MESA_SHADER_VERTEX) ?
+               gl_vert_attrib_name(shader->infile.reg[idx].slot) :
+               gl_varying_slot_name(shader->infile.reg[idx].slot),
+               shader->infile.reg[idx].num_components);
+   }
+   printf("outputs:\n");
+   for (int idx = 0; idx < shader->outfile.num_reg; ++idx) {
+      printf(" [%i] name=%s comps=%i\n", shader->outfile.reg[idx].reg,
+               (shader->stage == MESA_SHADER_VERTEX) ?
+               gl_varying_slot_name(shader->outfile.reg[idx].slot) :
+               gl_frag_result_name(shader->outfile.reg[idx].slot),
+               shader->outfile.reg[idx].num_components);
+   }
+   printf("special:\n");
+   if (shader->stage == MESA_SHADER_VERTEX) {
+      printf("  vs_pos_out_reg=%i\n", shader->vs_pos_out_reg);
+      printf("  vs_pointsize_out_reg=%i\n", shader->vs_pointsize_out_reg);
+      printf("  vs_load_balancing=0x%08x\n", shader->vs_load_balancing);
+   } else {
+      printf("  ps_color_out_reg=%i\n", shader->ps_color_out_reg);
+      printf("  ps_depth_out_reg=%i\n", shader->ps_depth_out_reg);
+   }
+   printf("  input_count_unk8=0x%08x\n", shader->input_count_unk8);
+}
+
 /* Link vs and fs together: fill in shader_state from vs and fs
  * as this function is called every time a new fs or vs is bound, the goal is to
  * do little processing as possible here, and to precompute as much as possible in
@@ -76,13 +127,8 @@ etna_link_shaders(struct etna_context *ctx, struct compiled_shader_state *cs,
 
 #ifdef DEBUG
    if (DBG_ENABLED(ETNA_DBG_DUMP_SHADERS)) {
-      if (DBG_ENABLED(ETNA_DBG_NIR)) {
-         etna_dump_shader_nir(vs);
-         etna_dump_shader_nir(fs);
-      } else {
-         etna_dump_shader(vs);
-         etna_dump_shader(fs);
-      }
+      etna_dump_shader(vs);
+      etna_dump_shader(fs);
    }
 #endif
 



More information about the mesa-commit mailing list