[Mesa-dev] [PATCH] i965/fs: Print spills:fills and number of promoted constants.

Jason Ekstrand jason at jlekstrand.net
Tue Mar 17 14:15:16 PDT 2015


On Tue, Mar 17, 2015 at 2:09 PM, Matt Turner <mattst88 at gmail.com> wrote:
> ---
>  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       | 20 +++++++++++++-------
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp         |  4 ++--
>  src/mesa/drivers/dri/i965/brw_vec4.cpp               |  2 +-
>  7 files changed, 23 insertions(+), 12 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 8702ea8..7f671dc 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -4039,7 +4039,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 7716529..ed0bb8f 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.h
> +++ b/src/mesa/drivers/dri/i965/brw_fs.h
> @@ -512,6 +512,8 @@ public:
>     bool spilled_any_registers;
>
>     const unsigned dispatch_width; /**< 8 or 16 */
> +
> +   unsigned promoted_constants;
>  };
>
>  /**
> @@ -527,6 +529,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();
> @@ -638,6 +641,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..e61a9d3 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)
> +     debug_flag(false), stage_abbrev(stage_abbrev), mem_ctx(mem_ctx),
> +     promoted_constants(promoted_constants)
>  {
>     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 5d4b166..a1cdfa9 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> @@ -3989,7 +3989,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();
> @@ -4008,7 +4008,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..63dedae 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
> @@ -1969,7 +1969,7 @@ 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.runtime_check_aads_emit, v.promoted_constants, "VS");

Promoted constants and aads_emit need to be flipped around.  You got
it right for FS.

Also, does this require any adaptations to shader-db or does it work as-is?

Other than that,
Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>


>        if (INTEL_DEBUG & DEBUG_VS) {
>           char *name = ralloc_asprintf(mem_ctx, "%s vertex shader %d",
>                                        prog->Label ? prog->Label : "unnamed",
> --
> 2.0.5
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list