From b0d422cd2a99d2fd26ab11880d5d8410ebfc64b2 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Mon, 16 Mar 2015 12:18:31 -0700 Subject: [PATCH] i965/fs: Print spills:fills and number of promoted constants. Reviewed-by: Jason Ekstrand Reviewed-by: Chris Forbes --- src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp | 2 +- src/mesa/drivers/dri/i965/brw_fs.cpp | 2 +- src/mesa/drivers/dri/i965/brw_fs.h | 4 ++++ .../drivers/dri/i965/brw_fs_combine_constants.cpp | 1 + src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 22 ++++++++++++++-------- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 4 ++-- src/mesa/drivers/dri/i965/brw_vec4.cpp | 3 ++- 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp index f9b1737..32919b1 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp @@ -31,7 +31,7 @@ brw_blorp_eu_emitter::brw_blorp_eu_emitter(struct brw_context *brw, : mem_ctx(ralloc_context(NULL)), generator(brw, mem_ctx, (void *) rzalloc(mem_ctx, struct brw_wm_prog_key), (struct brw_stage_prog_data *) rzalloc(mem_ctx, struct brw_wm_prog_data), - NULL, false, "BLORP") + NULL, 0, false, "BLORP") { if (debug_flag) generator.enable_debug("blorp"); diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 3d4d31a..1008467 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -4068,7 +4068,7 @@ brw_wm_fs_emit(struct brw_context *brw, } fs_generator g(brw, mem_ctx, (void *) key, &prog_data->base, - &fp->Base, v.runtime_check_aads_emit, "FS"); + &fp->Base, v.promoted_constants, v.runtime_check_aads_emit, "FS"); if (unlikely(INTEL_DEBUG & DEBUG_WM)) { char *name; diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 23e7135..2f362db 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -514,6 +514,8 @@ public: bool spilled_any_registers; const unsigned dispatch_width; /**< 8 or 16 */ + + unsigned promoted_constants; }; /** @@ -529,6 +531,7 @@ public: const void *key, struct brw_stage_prog_data *prog_data, struct gl_program *fp, + unsigned promoted_constants, bool runtime_check_aads_emit, const char *stage_abbrev); ~fs_generator(); @@ -640,6 +643,7 @@ private: unsigned dispatch_width; /**< 8 or 16 */ exec_list discard_halt_patches; + unsigned promoted_constants; bool runtime_check_aads_emit; bool debug_flag; const char *shader_name; diff --git a/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp b/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp index 7ddb253..ebde8df 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp @@ -286,6 +286,7 @@ fs_visitor::opt_combine_constants() reg.subreg_offset = 0; } } + promoted_constants = table.len; /* Rewrite the immediate sources to refer to the new GRFs. */ for (int i = 0; i < table.len; i++) { diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index e086266..05a2db4 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -126,13 +126,15 @@ fs_generator::fs_generator(struct brw_context *brw, const void *key, struct brw_stage_prog_data *prog_data, struct gl_program *prog, + unsigned promoted_constants, bool runtime_check_aads_emit, const char *stage_abbrev) : brw(brw), key(key), prog_data(prog_data), - prog(prog), runtime_check_aads_emit(runtime_check_aads_emit), - debug_flag(false), stage_abbrev(stage_abbrev), mem_ctx(mem_ctx) + prog(prog), promoted_constants(promoted_constants), + runtime_check_aads_emit(runtime_check_aads_emit), debug_flag(false), + stage_abbrev(stage_abbrev), mem_ctx(mem_ctx) { ctx = &brw->ctx; @@ -1563,6 +1565,7 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width) brw_set_default_compression_control(p, BRW_COMPRESSION_COMPRESSED); int start_offset = p->next_insn_offset; + int spill_count = 0, fill_count = 0; int loop_count = 0; struct annotation_info annotation; @@ -1959,14 +1962,17 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width) case SHADER_OPCODE_GEN4_SCRATCH_WRITE: generate_scratch_write(inst, src[0]); + spill_count++; break; case SHADER_OPCODE_GEN4_SCRATCH_READ: generate_scratch_read(inst, dst); + fill_count++; break; case SHADER_OPCODE_GEN7_SCRATCH_READ: generate_scratch_read_gen7(inst, dst); + fill_count++; break; case SHADER_OPCODE_URB_WRITE_SIMD8: @@ -2111,10 +2117,10 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width) if (unlikely(debug_flag)) { fprintf(stderr, "Native code for %s\n" - "SIMD%d shader: %d instructions. %d loops. Compacted %d to %d" + "SIMD%d shader: %d instructions. %d loops. %d:%d spills:fills. Promoted %u constants. Compacted %d to %d" " bytes (%.0f%%)\n", - shader_name, - dispatch_width, before_size / 16, loop_count, before_size, after_size, + shader_name, dispatch_width, before_size / 16, loop_count, + spill_count, fill_count, promoted_constants, before_size, after_size, 100.0f * (before_size - after_size) / before_size); dump_assembly(p->store, annotation.ann_count, annotation.ann, brw, prog); @@ -2126,10 +2132,10 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width) MESA_DEBUG_SOURCE_SHADER_COMPILER, MESA_DEBUG_TYPE_OTHER, MESA_DEBUG_SEVERITY_NOTIFICATION, - "%s SIMD%d shader: %d inst, %d loops, " - "compacted %d to %d bytes.\n", + "%s SIMD%d shader: %d inst, %d loops, %d:%d spills:fills, " + "Promoted %u constants, compacted %d to %d bytes.\n", stage_abbrev, dispatch_width, before_size / 16, loop_count, - before_size, after_size); + spill_count, fill_count, promoted_constants, before_size, after_size); return start_offset; } diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 0d5252a..60a7a97 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -4082,7 +4082,7 @@ fs_visitor::fs_visitor(struct brw_context *brw, reg_null_d(retype(brw_null_vec(dispatch_width), BRW_REGISTER_TYPE_D)), reg_null_ud(retype(brw_null_vec(dispatch_width), BRW_REGISTER_TYPE_UD)), key(key), prog_data(&prog_data->base), - dispatch_width(dispatch_width) + dispatch_width(dispatch_width), promoted_constants(0) { this->mem_ctx = mem_ctx; init(); @@ -4101,7 +4101,7 @@ fs_visitor::fs_visitor(struct brw_context *brw, reg_null_d(retype(brw_null_vec(dispatch_width), BRW_REGISTER_TYPE_D)), reg_null_ud(retype(brw_null_vec(dispatch_width), BRW_REGISTER_TYPE_UD)), key(key), prog_data(&prog_data->base.base), - dispatch_width(dispatch_width) + dispatch_width(dispatch_width), promoted_constants(0) { this->mem_ctx = mem_ctx; init(); diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index 8edb4d0..b13dd58 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -1969,7 +1969,8 @@ brw_vs_emit(struct brw_context *brw, } fs_generator g(brw, mem_ctx, (void *) &c->key, &prog_data->base.base, - &c->vp->program.Base, v.runtime_check_aads_emit, "VS"); + &c->vp->program.Base, v.promoted_constants, + v.runtime_check_aads_emit, "VS"); if (INTEL_DEBUG & DEBUG_VS) { char *name = ralloc_asprintf(mem_ctx, "%s vertex shader %d", prog->Label ? prog->Label : "unnamed", -- 2.7.4