diff --git a/src/gallium/drivers/r600/sb/sb_bc.h b/src/gallium/drivers/r600/sb/sb_bc.h index 6961600..c94aa36 100644 --- a/src/gallium/drivers/r600/sb/sb_bc.h +++ b/src/gallium/drivers/r600/sb/sb_bc.h @@ -606,6 +606,31 @@ struct shader_stats { void dump_diff(shader_stats &s); }; +/* Use static sb_context::dskip_* member variables to skip shaders. + * Default mode is skipping shaders (use shaders from the default + * backend. Aternative mode is dry-running shaders. + * range: [dskip_start, dskip_end], e.g. [5,6] means shaders 5 & 6 + * dskip_mode is a bitfield controlled by the SB_SKIP_* macros. + */ + +#define SB_SKIP_ENABLED (1 << 0) // enable shader selection +#define SB_SKIP_IN_RANGE (1 << 1) // shader id inside range else outside range +#define SB_SKIP_DRY_RUN (1 << 2) // run in skip or dry-run mode +#define SB_SKIP_DUMP_IR (1 << 3) // dump IR code +#define SB_SKIP_DUMP_STAT (1 << 4) // dump stats +#define SB_SKIP_DUMP_BC (1 << 5) // dump bytecode (disasm) + +#define SB_SKIP_DO(mode) \ + ((sb_context::dskip_mode & (SB_SKIP_ENABLED | SB_SKIP_##mode)) \ + == (SB_SKIP_ENABLED | SB_SKIP_##mode)) +#define SB_SKIP_DO_RANGE(id,mode) \ + (SB_SKIP_DO(mode) && sb_context::is_in_range(id)) + +#define SB_DUMP_STAT(id,code) do { if (sb_context::dump_stat || \ + (SB_SKIP_DO_RANGE(id,DUMP_STAT))) { code } } while (0) +#define SB_DUMP_PASS(id,code) do { if (sb_context::dump_pass || \ + (SB_SKIP_DO_RANGE(id,DUMP_IR))) { code } } while (0) + class sb_context { public: @@ -648,6 +673,12 @@ public: int init(r600_isa *isa, sb_hw_chip chip, sb_hw_class cclass); + static bool is_in_range(unsigned shader_id) + { + return (dskip_start <= shader_id && shader_id <= dskip_end) == + ((dskip_mode & SB_SKIP_IN_RANGE) > 0); + } + bool is_r600() {return hw_class == HW_CLASS_R600;} bool is_r700() {return hw_class == HW_CLASS_R700;} bool is_evergreen() {return hw_class == HW_CLASS_EVERGREEN;} @@ -721,9 +752,6 @@ public: }; -#define SB_DUMP_STAT(a) do { if (sb_context::dump_stat) { a } } while (0) -#define SB_DUMP_PASS(a) do { if (sb_context::dump_pass) { a } } while (0) - class bc_decoder { sb_context &ctx; diff --git a/src/gallium/drivers/r600/sb/sb_core.cpp b/src/gallium/drivers/r600/sb/sb_core.cpp index afea818..8745d8f 100644 --- a/src/gallium/drivers/r600/sb/sb_core.cpp +++ b/src/gallium/drivers/r600/sb/sb_core.cpp @@ -101,11 +101,10 @@ int r600_sb_bytecode_process(struct r600_context *rctx, } int64_t time_start = 0; - if (sb_context::dump_stat) { + SB_DUMP_STAT(shader_id, time_start = os_time_get_nano(); - } - - SB_DUMP_STAT( sblog << "\nsb: shader " << shader_id << "\n"; ); + sblog << "\nsb: shader " << shader_id << "\n"; + ); bc_parser parser(*ctx, bc, pshader); @@ -116,7 +115,7 @@ int r600_sb_bytecode_process(struct r600_context *rctx, shader *sh = parser.get_shader(); - if (dump_bytecode) { + if (dump_bytecode || SB_SKIP_DO_RANGE(shader_id, DUMP_BC)) { bc_dump(*sh, bc->bytecode, bc->ndw).run(); } @@ -127,25 +126,15 @@ int r600_sb_bytecode_process(struct r600_context *rctx, if (sh->target != TARGET_FETCH) { sh->src_stats.ndw = bc->ndw; - sh->collect_stats(false); + SB_DUMP_STAT(shader_id, sh->collect_stats(false);); } - /* skip some shaders (use shaders from default backend) - * dskip_start - range start, dskip_end - range_end, - * e.g. start = 5, end = 6 means shaders 5 & 6 - * - * dskip_mode == 0 - disabled, - * dskip_mode == 1 - don't process the shaders from the [start;end] range - * dskip_mode == 2 - process only the shaders from the range - */ - if (sb_context::dskip_mode) { - if ((sb_context::dskip_start <= shader_id && - shader_id <= sb_context::dskip_end) == - (sb_context::dskip_mode == 1)) { + if (sb_context::dskip_mode & SB_SKIP_ENABLED) { + if (!(sb_context::dskip_mode & SB_SKIP_DRY_RUN) && + sb_context::is_in_range(shader_id)) { sblog << "sb: skipped shader " << shader_id << " : " << "[" << sb_context::dskip_start << "; " - << sb_context::dskip_end << "] mode " - << sb_context::dskip_mode << "\n"; + << sb_context::dskip_end << "]\n"; return 0; } } @@ -155,7 +144,9 @@ int r600_sb_bytecode_process(struct r600_context *rctx, return r; } - SB_DUMP_PASS( sblog << "\n\n###### after parse\n"; sh->dump_ir(); ); + SB_DUMP_PASS(shader_id, sblog << "\n\n###### after parse\n"; sh->dump_ir(); ); + + unsigned passno = 0; #define SB_RUN_PASS(n, dump) \ do { \ @@ -169,8 +160,8 @@ int r600_sb_bytecode_process(struct r600_context *rctx, return 0; \ } \ if (dump) { \ - SB_DUMP_PASS( sblog << "\n\n###### after " << #n << "\n"; \ - sh->dump_ir();); \ + SB_DUMP_PASS(shader_id, sblog << "\n\n###### after " << #n << "\n"; \ + sh->dump_ir();) ; \ } \ assert(!r); \ } while (0) @@ -249,12 +240,15 @@ int r600_sb_bytecode_process(struct r600_context *rctx, bytecode &nbc = builder.get_bytecode(); - if (dump_bytecode) { + if (dump_bytecode || SB_SKIP_DO_RANGE(shader_id, DUMP_BC)) { bc_dump(*sh, &nbc).run(); } - if (!sb_context::dry_run) { - + if (sb_context::dry_run) { + SB_DUMP_STAT(shader_id, sblog << "sb: dry run: optimized bytecode is not used\n"; ); + } else if (SB_SKIP_DO_RANGE(shader_id, DRY_RUN)) { + sblog << "sb: dry run shader " << shader_id << ": optimized bytecode is not used\n"; + } else { free(bc->bytecode); bc->ndw = nbc.ndw(); bc->bytecode = (uint32_t*) malloc(bc->ndw << 2); @@ -262,11 +256,9 @@ int r600_sb_bytecode_process(struct r600_context *rctx, bc->ngpr = sh->ngpr; bc->nstack = sh->nstack; - } else { - SB_DUMP_STAT( sblog << "sb: dry run: optimized bytecode is not used\n"; ); } - if (sb_context::dump_stat) { + SB_DUMP_STAT(shader_id, int64_t t = os_time_get_nano() - time_start; sblog << "sb: processing shader " << shader_id << " done ( " @@ -281,7 +273,7 @@ int r600_sb_bytecode_process(struct r600_context *rctx, sh->opt_stats.dump(); sblog << "diff: "; sh->src_stats.dump_diff(sh->opt_stats); - } + ); delete sh; return 0; diff --git a/src/gallium/drivers/r600/sb/sb_gcm.cpp b/src/gallium/drivers/r600/sb/sb_gcm.cpp index 236b2ea..3eba7a5 100644 --- a/src/gallium/drivers/r600/sb/sb_gcm.cpp +++ b/src/gallium/drivers/r600/sb/sb_gcm.cpp @@ -43,7 +43,8 @@ namespace r600_sb { int gcm::run() { - GCM_DUMP( sblog << "==== GCM ==== \n"; sh.dump_ir(); ); + GCM_DUMP( sblog << "==== GCM ==== \n"; + if (sb_context::dump_pass) sh.dump_ir(); ); collect_instructions(sh.root, true); @@ -83,7 +84,7 @@ int gcm::run() { assert(pending.empty()); - GCM_DUMP( sh.dump_ir(); ); + GCM_DUMP( if (sb_context::dump_pass) sh.dump_ir(); ); GCM_DUMP( sblog << "\n\n ############## gcm late\n\n"; ); diff --git a/src/gallium/drivers/r600/sb/sb_peephole.cpp b/src/gallium/drivers/r600/sb/sb_peephole.cpp index d4b9755..8038697 100644 --- a/src/gallium/drivers/r600/sb/sb_peephole.cpp +++ b/src/gallium/drivers/r600/sb/sb_peephole.cpp @@ -76,9 +76,12 @@ void peephole::optimize_cc_op(alu_node* a) { if (aflags & (AF_PRED | AF_SET | AF_KILL)) { optimize_cc_op2(a); - } else if (aflags & AF_CMOV) { + } +#if 0 + else if (aflags & AF_CMOV) { optimize_CNDcc_op(a); } +#endif } void peephole::convert_float_setcc(alu_node *f2i, alu_node *s) { diff --git a/src/gallium/drivers/r600/sb/sb_shader.cpp b/src/gallium/drivers/r600/sb/sb_shader.cpp index 8c7b39b..79e423b 100644 --- a/src/gallium/drivers/r600/sb/sb_shader.cpp +++ b/src/gallium/drivers/r600/sb/sb_shader.cpp @@ -358,8 +358,7 @@ shader::~shader() { } void shader::dump_ir() { - if (ctx.dump_pass) - dump(*this).run(); + dump(*this).run(); } value* shader::get_value_version(value* v, unsigned ver) { @@ -394,8 +393,8 @@ void shader::add_gpr_array(unsigned gpr_start, unsigned gpr_count, if (comp_mask & 1) { gpr_array *a = new gpr_array( sel_chan(gpr_start, chan), gpr_count); - - SB_DUMP_PASS( sblog << "add_gpr_array: @" << a->base_gpr + // FIXME: how to handle shader_id correctly? + SB_DUMP_PASS(0, sblog << "add_gpr_array: @" << a->base_gpr << " [" << a->array_size << "]\n"; ); @@ -491,9 +490,6 @@ alu_node* shader::clone(alu_node* n) { } void shader::collect_stats(bool opt) { - if (!sb_context::dump_stat) - return; - shader_stats &s = opt ? opt_stats : src_stats; s.shaders = 1;