etnaviv: split dump_shader
authorChristian Gmeiner <christian.gmeiner@gmail.com>
Wed, 14 Aug 2019 08:06:17 +0000 (10:06 +0200)
committerChristian Gmeiner <christian.gmeiner@gmail.com>
Wed, 14 Aug 2019 13:10:07 +0000 (15:10 +0200)
Also this adds the missing impl for etna_dump_shader_nir(..).

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Jonathan Marek <jonathan@marek.ca>
src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c
src/gallium/drivers/etnaviv/etnaviv_compiler_tgsi.c
src/gallium/drivers/etnaviv/etnaviv_shader.c

index 4aad246cfb982dbece82e8d57fb60b22c1945193..dc6756af257078fa13155b28370571dd894ea278 100644 (file)
@@ -40,6 +40,7 @@
 #include "compiler/nir/nir_builder.h"
 #include "compiler/nir/nir_worklist.h"
 
+#include "tgsi/tgsi_strings.h"
 #include "util/u_half.h"
 
 struct etna_compile {
@@ -779,6 +780,56 @@ 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)
index 8214d4f5770478ce10363fdc191d1f335d608a43..72fab578a1e9dcb209eabe7a5faf819cc6ec3dcf 100644 (file)
@@ -2506,39 +2506,19 @@ etna_dump_shader(const struct etna_shader_variant *shader)
              shader->uniforms.imm_data[idx],
              shader->uniforms.imm_contents[idx]);
    }
-
-   if (DBG_ENABLED(ETNA_DBG_NIR)) {
-      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);
-      }
-   } else {
-      printf("inputs:\n");
-      for (int idx = 0; idx < shader->infile.num_reg; ++idx) {
-         printf(" [%i] name=%s index=%i comps=%i\n", shader->infile.reg[idx].reg,
-                tgsi_semantic_names[shader->infile.reg[idx].semantic.Name],
-                shader->infile.reg[idx].semantic.Index,
-                shader->infile.reg[idx].num_components);
-      }
-      printf("outputs:\n");
-      for (int idx = 0; idx < shader->outfile.num_reg; ++idx) {
-         printf(" [%i] name=%s index=%i comps=%i\n", shader->outfile.reg[idx].reg,
-                tgsi_semantic_names[shader->outfile.reg[idx].semantic.Name],
-                shader->outfile.reg[idx].semantic.Index,
-                shader->outfile.reg[idx].num_components);
-      }
+   printf("inputs:\n");
+   for (int idx = 0; idx < shader->infile.num_reg; ++idx) {
+      printf(" [%i] name=%s index=%i comps=%i\n", shader->infile.reg[idx].reg,
+               tgsi_semantic_names[shader->infile.reg[idx].semantic.Name],
+               shader->infile.reg[idx].semantic.Index,
+               shader->infile.reg[idx].num_components);
+   }
+   printf("outputs:\n");
+   for (int idx = 0; idx < shader->outfile.num_reg; ++idx) {
+      printf(" [%i] name=%s index=%i comps=%i\n", shader->outfile.reg[idx].reg,
+               tgsi_semantic_names[shader->outfile.reg[idx].semantic.Name],
+               shader->outfile.reg[idx].semantic.Index,
+               shader->outfile.reg[idx].num_components);
    }
    printf("special:\n");
    if (shader->stage == MESA_SHADER_VERTEX) {
index f0cde53d02368ef34b8e938e33f1c3b65307ba09..a87e94b2b013d8525b693b36b4b1e3cf32adb05f 100644 (file)
@@ -73,8 +73,13 @@ etna_link_shaders(struct etna_context *ctx, struct compiled_shader_state *cs,
 
 #ifdef DEBUG
    if (DBG_ENABLED(ETNA_DBG_DUMP_SHADERS)) {
-      etna_dump_shader(vs);
-      etna_dump_shader(fs);
+      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);
+      }
    }
 #endif