i965: only try print GLSL IR once when using INTEL_DEBUG to dump ir
authorTimothy Arceri <timothy.arceri@collabora.com>
Thu, 3 Nov 2016 10:47:04 +0000 (21:47 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Thu, 17 Nov 2016 01:52:24 +0000 (12:52 +1100)
Since we started releasing GLSL IR after linking the only time we can
print GLSL IR is during linking. When regenerating variants only NIR
will be available.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
src/mesa/drivers/dri/i965/brw_cs.c
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_link.cpp
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/drivers/dri/i965/brw_program.h
src/mesa/drivers/dri/i965/brw_tcs.c
src/mesa/drivers/dri/i965/brw_tes.c
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/brw_wm.c

index d16fff8ffc3dd29e67c117e05af880792c1635dc..8b13b49b6ff2b94135e58821fcb29d34eab4a717 100644 (file)
@@ -116,9 +116,6 @@ brw_codegen_cs_prog(struct brw_context *brw,
       start_time = get_time();
    }
 
-   if (unlikely(INTEL_DEBUG & DEBUG_CS))
-      brw_dump_ir("compute", prog, &cs->base, &cp->program);
-
    int st_index = -1;
    if (INTEL_DEBUG & DEBUG_SHADER_TIME)
       st_index = brw_get_shader_time_index(brw, prog, &cp->program, ST_CS);
@@ -172,9 +169,6 @@ brw_codegen_cs_prog(struct brw_context *brw,
                            prog_data.base.total_scratch,
                            scratch_ids_per_subslice * subslices);
 
-   if (unlikely(INTEL_DEBUG & DEBUG_CS))
-      fprintf(stderr, "\n");
-
    brw_upload_cache(&brw->cache, BRW_CACHE_CS_PROG,
                     key, sizeof(*key),
                     program, program_size,
index 0f052d21b0a6cee5096a2b864d774315876e8fe5..77efa6382c51946547de9f6e3538291de4b626fd 100644 (file)
@@ -143,9 +143,6 @@ brw_codegen_gs_prog(struct brw_context *brw,
                        &prog_data.base.vue_map, outputs_written,
                        prog->SeparateShader);
 
-   if (unlikely(INTEL_DEBUG & DEBUG_GS))
-      brw_dump_ir("geometry", prog, gs, NULL);
-
    int st_index = -1;
    if (INTEL_DEBUG & DEBUG_SHADER_TIME)
       st_index = brw_get_shader_time_index(brw, prog, NULL, ST_GS);
index 57baea304eefe6cd80b408c4e1098c840c058a7a..fbb834be1a03f66f34ce557afca8c6fdaa38f5dd 100644 (file)
@@ -264,6 +264,16 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
 
       brw_add_texrect_params(prog);
 
+      bool debug_enabled =
+         (INTEL_DEBUG & intel_debug_flag_for_shader_stage(shader->Stage));
+
+      if (debug_enabled && shader->ir) {
+         fprintf(stderr, "GLSL IR for native %s shader %d:\n",
+                 _mesa_shader_stage_to_string(shader->Stage), shProg->Name);
+         _mesa_print_ir(stderr, shader->ir, NULL);
+         fprintf(stderr, "\n\n");
+      }
+
       prog->nir = brw_create_nir(brw, shProg, prog, (gl_shader_stage) stage,
                                  compiler->scalar_stage[stage]);
 
index 45f8603abd2bb71b183794007feeb4a2f622aa27..2f84e86adbebd13b453da363f34bd6efe12206a0 100644 (file)
@@ -640,22 +640,11 @@ brw_stage_prog_data_free(const void *p)
 }
 
 void
-brw_dump_ir(const char *stage, struct gl_shader_program *shader_prog,
-            struct gl_linked_shader *shader, struct gl_program *prog)
+brw_dump_arb_asm(const char *stage, struct gl_program *prog)
 {
-   if (shader_prog) {
-      if (shader->ir) {
-         fprintf(stderr,
-                 "GLSL IR for native %s shader %d:\n",
-                 stage, shader_prog->Name);
-         _mesa_print_ir(stderr, shader->ir, NULL);
-         fprintf(stderr, "\n\n");
-      }
-   } else {
-      fprintf(stderr, "ARB_%s_program %d ir for native %s shader\n",
-              stage, prog->Id, stage);
-      _mesa_print_program(prog);
-   }
+   fprintf(stderr, "ARB_%s_program %d ir for native %s shader\n",
+           stage, prog->Id, stage);
+   _mesa_print_program(prog);
 }
 
 void
index eed07a2c1c06c19ad6796f39d4b243c4fa13e265..43bc6254345f3addacaaba244ae6dad934fd43d7 100644 (file)
@@ -58,8 +58,7 @@ void
 brw_stage_prog_data_free(const void *prog_data);
 
 void
-brw_dump_ir(const char *stage, struct gl_shader_program *shader_prog,
-            struct gl_linked_shader *shader, struct gl_program *prog);
+brw_dump_arb_asm(const char *stage, struct gl_program *prog);
 
 void brw_upload_tcs_prog(struct brw_context *brw);
 void brw_tcs_populate_key(struct brw_context *brw,
index 7beccd794664c3ea1068f34e0dd7c2acf17fd927..24cc423e60c55f23745d6585fd3f453b4c063603 100644 (file)
@@ -250,9 +250,6 @@ brw_codegen_tcs_prog(struct brw_context *brw,
       }
    }
 
-   if (unlikely(INTEL_DEBUG & DEBUG_TCS) && tcs)
-      brw_dump_ir("tessellation control", shader_prog, tcs, NULL);
-
    int st_index = -1;
    if (unlikely(INTEL_DEBUG & DEBUG_SHADER_TIME))
       st_index = brw_get_shader_time_index(brw, shader_prog, NULL, ST_TCS);
index 6060c765a8fc60890ce3d4cc1452d405ba15f3ee..160f21e597f22dca3731a1a3bc3866f2863799a1 100644 (file)
@@ -171,9 +171,6 @@ brw_codegen_tes_prog(struct brw_context *brw,
                                &prog_data.base.base,
                                compiler->scalar_stage[MESA_SHADER_TESS_EVAL]);
 
-   if (unlikely(INTEL_DEBUG & DEBUG_TES))
-      brw_dump_ir("tessellation evaluation", shader_prog, tes, NULL);
-
    int st_index = -1;
    if (unlikely(INTEL_DEBUG & DEBUG_SHADER_TIME))
       st_index = brw_get_shader_time_index(brw, shader_prog, NULL, ST_TES);
index 02a88ca0988035b8756bc16bb61956236fbc3601..edb577f570a28129c505dd0972193ad5cb4df1b6 100644 (file)
@@ -178,7 +178,8 @@ brw_codegen_vs_prog(struct brw_context *brw,
    }
 
    if (unlikely(INTEL_DEBUG & DEBUG_VS)) {
-      brw_dump_ir("vertex", prog, vs ? &vs->base : NULL, &vp->program);
+      if (!prog)
+         brw_dump_arb_asm("vertex", &vp->program);
 
       fprintf(stderr, "VS Output ");
       brw_print_vue_map(stderr, &prog_data.base.vue_map);
index f434af9772c15e59185611c29aa8006d8853e70d..14ecaa858716cadfd6fcaf5440a0774d98d1c05b 100644 (file)
@@ -126,6 +126,9 @@ brw_codegen_wm_prog(struct brw_context *brw,
    } else {
       brw_nir_setup_arb_uniforms(fp->program.nir, &fp->program,
                                  &prog_data.base);
+
+      if (unlikely(INTEL_DEBUG & DEBUG_WM))
+         brw_dump_arb_asm("fragment", &fp->program);
    }
 
    if (unlikely(brw->perf_debug)) {
@@ -134,9 +137,6 @@ brw_codegen_wm_prog(struct brw_context *brw,
       start_time = get_time();
    }
 
-   if (unlikely(INTEL_DEBUG & DEBUG_WM))
-      brw_dump_ir("fragment", prog, fs ? &fs->base : NULL, &fp->program);
-
    int st_index8 = -1, st_index16 = -1;
    if (INTEL_DEBUG & DEBUG_SHADER_TIME) {
       st_index8 = brw_get_shader_time_index(brw, prog, &fp->program, ST_FS8);
@@ -177,7 +177,7 @@ brw_codegen_wm_prog(struct brw_context *brw,
                            prog_data.base.total_scratch,
                            devinfo->max_wm_threads);
 
-   if (unlikely(INTEL_DEBUG & DEBUG_WM))
+   if (unlikely((INTEL_DEBUG & DEBUG_WM) && !prog))
       fprintf(stderr, "\n");
 
    brw_upload_cache(&brw->cache, BRW_CACHE_FS_PROG,