diff options
author | Danylo Piliaiev <[email protected]> | 2019-05-23 19:05:23 +0300 |
---|---|---|
committer | Matt Turner <[email protected]> | 2019-08-05 17:19:09 +0000 |
commit | 04a995158084acbd1917b4c7e0f8d381e1c9222d (patch) | |
tree | 5e719246b49db173196dc71853dea02bf95fa986 /src/intel/compiler/brw_fs_generator.cpp | |
parent | 430823c96b1ab9c5e99fedbf06856a2a24d36d91 (diff) |
intel/compiler: add ability to override shader's assembly
When dumping shader's assembly with INTEL_DEBUG=vs,tcs,...
sha1 of the resulting assembly is also printed, having environment
variable INTEL_SHADER_ASM_READ_PATH present driver will try to
load a "%sha1%.bin" file from the path and substitute current
assembly with the one from the file.
Signed-off-by: Danylo Piliaiev <[email protected]>
Reviewed-by: Sagar Ghuge <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/intel/compiler/brw_fs_generator.cpp')
-rw-r--r-- | src/intel/compiler/brw_fs_generator.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/intel/compiler/brw_fs_generator.cpp b/src/intel/compiler/brw_fs_generator.cpp index 62d19719c39..cd83a1fac70 100644 --- a/src/intel/compiler/brw_fs_generator.cpp +++ b/src/intel/compiler/brw_fs_generator.cpp @@ -30,6 +30,7 @@ #include "brw_eu.h" #include "brw_fs.h" #include "brw_cfg.h" +#include "util/mesa-sha1.h" static enum brw_reg_file brw_file_from_reg(fs_reg *reg) @@ -2290,13 +2291,21 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width) int after_size = p->next_insn_offset - start_offset; if (unlikely(debug_flag)) { - fprintf(stderr, "Native code for %s\n" + unsigned char sha1[21]; + char sha1buf[41]; + + _mesa_sha1_compute(p->store + start_offset / sizeof(brw_inst), + after_size, sha1); + _mesa_sha1_format(sha1buf, sha1); + + fprintf(stderr, "Native code for %s (sha1 %s)\n" "SIMD%d shader: %d instructions. %d loops. %u cycles. " "%d:%d spills:fills. " "scheduled with mode %s. " "Promoted %u constants. " "Compacted %d to %d bytes (%.0f%%)\n", - shader_name, dispatch_width, before_size / 16, + shader_name, sha1buf, + dispatch_width, before_size / 16, loop_count, cfg->cycle_count, spill_count, fill_count, shader_stats.scheduler_mode, @@ -2304,7 +2313,12 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width) before_size, after_size, 100.0f * (before_size - after_size) / before_size); - dump_assembly(p->store, disasm_info); + /* overriding the shader makes disasm_info invalid */ + if (!brw_try_override_assembly(p, start_offset, sha1buf)) { + dump_assembly(p->store, disasm_info); + } else { + fprintf(stderr, "Successfully overrode shader with sha1 %s\n\n", sha1buf); + } } ralloc_free(disasm_info); assert(validated); |