diff options
author | Eric Anholt <[email protected]> | 2014-09-24 22:03:06 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-09-29 11:33:34 -0700 |
commit | 64122b16ce74a3fb65269bab325c651c26ccd2d0 (patch) | |
tree | 15354dcfe913bb725fb7af1f2c825e7907f3151e /src/gallium/drivers | |
parent | 3311513041b81fe4e2fcf2c0e8a363a6d292c7b1 (diff) |
vc4: Dump constant uniform values in VC4_DEBUG=qir.
Definitely helps when trying to understand and optimize a program.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_opt_algebraic.c | 16 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_opt_copy_propagation.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_opt_cse.c | 15 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_opt_dead_code.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_qir.c | 17 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_qir.h | 2 |
6 files changed, 32 insertions, 24 deletions
diff --git a/src/gallium/drivers/vc4/vc4_opt_algebraic.c b/src/gallium/drivers/vc4/vc4_opt_algebraic.c index 868677acbde..b5cde0511d0 100644 --- a/src/gallium/drivers/vc4/vc4_opt_algebraic.c +++ b/src/gallium/drivers/vc4/vc4_opt_algebraic.c @@ -37,24 +37,24 @@ static bool debug; static void -dump_from(struct qinst *inst) +dump_from(struct vc4_compile *c, struct qinst *inst) { if (!debug) return; fprintf(stderr, "optimizing: "); - qir_dump_inst(inst); + qir_dump_inst(c, inst); fprintf(stderr, "\n"); } static void -dump_to(struct qinst *inst) +dump_to(struct vc4_compile *c, struct qinst *inst) { if (!debug) return; fprintf(stderr, "to: "); - qir_dump_inst(inst); + qir_dump_inst(c, inst); fprintf(stderr, "\n"); } @@ -99,21 +99,21 @@ qir_opt_algebraic(struct vc4_compile *c) /* Turn "dst = (sf == x) ? a : a)" into * "dst = a" */ - dump_from(inst); + dump_from(c, inst); inst->op = QOP_MOV; inst->src[0] = inst->src[1]; inst->src[1] = c->undef; progress = true; - dump_to(inst); + dump_to(c, inst); } else if (is_zero(c, defs, inst->src[1])) { /* Replace references to a 0 uniform value * with the SEL_X_0 equivalent. */ - dump_from(inst); + dump_from(c, inst); inst->op -= (QOP_SEL_X_Y_ZS - QOP_SEL_X_0_ZS); inst->src[1] = c->undef; progress = true; - dump_to(inst); + dump_to(c, inst); } break; diff --git a/src/gallium/drivers/vc4/vc4_opt_copy_propagation.c b/src/gallium/drivers/vc4/vc4_opt_copy_propagation.c index 66b7c80a77d..0cffb284e44 100644 --- a/src/gallium/drivers/vc4/vc4_opt_copy_propagation.c +++ b/src/gallium/drivers/vc4/vc4_opt_copy_propagation.c @@ -63,7 +63,7 @@ qir_opt_copy_propagation(struct vc4_compile *c) !reads_a_uniform))) { if (debug) { fprintf(stderr, "Copy propagate: "); - qir_dump_inst(inst); + qir_dump_inst(c, inst); fprintf(stderr, "\n"); } @@ -73,7 +73,7 @@ qir_opt_copy_propagation(struct vc4_compile *c) if (debug) { fprintf(stderr, "to: "); - qir_dump_inst(inst); + qir_dump_inst(c, inst); fprintf(stderr, "\n"); } diff --git a/src/gallium/drivers/vc4/vc4_opt_cse.c b/src/gallium/drivers/vc4/vc4_opt_cse.c index ef4818f09b8..d3ef91083c6 100644 --- a/src/gallium/drivers/vc4/vc4_opt_cse.c +++ b/src/gallium/drivers/vc4/vc4_opt_cse.c @@ -62,7 +62,8 @@ inst_key_equals(const void *a, const void *b) } static struct qinst * -vc4_find_cse(struct hash_table *ht, struct qinst *inst, uint32_t sf_count, +vc4_find_cse(struct vc4_compile *c, struct hash_table *ht, + struct qinst *inst, uint32_t sf_count, uint32_t r4_count) { if (inst->dst.file != QFILE_TEMP || @@ -90,11 +91,11 @@ vc4_find_cse(struct hash_table *ht, struct qinst *inst, uint32_t sf_count, fprintf(stderr, "CSE found match:\n"); fprintf(stderr, " Original inst: "); - qir_dump_inst(entry->data); + qir_dump_inst(c, entry->data); fprintf(stderr, "\n"); fprintf(stderr, " Our inst: "); - qir_dump_inst(inst); + qir_dump_inst(c, inst); fprintf(stderr, "\n"); } @@ -109,7 +110,7 @@ vc4_find_cse(struct hash_table *ht, struct qinst *inst, uint32_t sf_count, if (debug) { fprintf(stderr, "Added to CSE HT: "); - qir_dump_inst(inst); + qir_dump_inst(c, inst); fprintf(stderr, "\n"); } @@ -143,7 +144,7 @@ qir_opt_cse(struct vc4_compile *c) if (debug) { fprintf(stderr, "Removing redundant SF: "); - qir_dump_inst(inst); + qir_dump_inst(c, inst); fprintf(stderr, "\n"); } qir_remove_instruction(inst); @@ -154,7 +155,7 @@ qir_opt_cse(struct vc4_compile *c) sf_count++; } } else { - struct qinst *cse = vc4_find_cse(ht, inst, + struct qinst *cse = vc4_find_cse(c, ht, inst, sf_count, r4_count); if (cse) { inst->src[0] = cse->dst; @@ -166,7 +167,7 @@ qir_opt_cse(struct vc4_compile *c) if (debug) { fprintf(stderr, " Turned into: "); - qir_dump_inst(inst); + qir_dump_inst(c, inst); fprintf(stderr, "\n"); } } diff --git a/src/gallium/drivers/vc4/vc4_opt_dead_code.c b/src/gallium/drivers/vc4/vc4_opt_dead_code.c index a675a1ac5ab..9f7606fb52b 100644 --- a/src/gallium/drivers/vc4/vc4_opt_dead_code.c +++ b/src/gallium/drivers/vc4/vc4_opt_dead_code.c @@ -51,7 +51,7 @@ qir_opt_dead_code(struct vc4_compile *c) !qir_has_side_effects(inst)) { if (debug) { fprintf(stderr, "Removing: "); - qir_dump_inst(inst); + qir_dump_inst(c, inst); fprintf(stderr, "\n"); } qir_remove_instruction(inst); diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c index efba6d3c55e..0975460ffec 100644 --- a/src/gallium/drivers/vc4/vc4_qir.c +++ b/src/gallium/drivers/vc4/vc4_qir.c @@ -181,7 +181,7 @@ qir_reads_r4(struct qinst *inst) } static void -qir_print_reg(struct qreg reg) +qir_print_reg(struct vc4_compile *c, struct qreg reg) { const char *files[] = { [QFILE_TEMP] = "t", @@ -193,17 +193,24 @@ qir_print_reg(struct qreg reg) fprintf(stderr, "null"); else fprintf(stderr, "%s%d", files[reg.file], reg.index); + + if (reg.file == QFILE_UNIF && + c->uniform_contents[reg.index] == QUNIFORM_CONSTANT) { + fprintf(stderr, " (0x%08x / %f)", + c->uniform_data[reg.index], + uif(c->uniform_data[reg.index])); + } } void -qir_dump_inst(struct qinst *inst) +qir_dump_inst(struct vc4_compile *c, struct qinst *inst) { fprintf(stderr, "%s ", qir_get_op_name(inst->op)); - qir_print_reg(inst->dst); + qir_print_reg(c, inst->dst); for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) { fprintf(stderr, ", "); - qir_print_reg(inst->src[i]); + qir_print_reg(c, inst->src[i]); } } @@ -214,7 +221,7 @@ qir_dump(struct vc4_compile *c) foreach(node, &c->instructions) { struct qinst *inst = (struct qinst *)node; - qir_dump_inst(inst); + qir_dump_inst(c, inst); fprintf(stderr, "\n"); } } diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h index 0d490ff9ef5..f4b01423387 100644 --- a/src/gallium/drivers/vc4/vc4_qir.h +++ b/src/gallium/drivers/vc4/vc4_qir.h @@ -277,7 +277,7 @@ bool qir_writes_r4(struct qinst *inst); bool qir_reads_r4(struct qinst *inst); void qir_dump(struct vc4_compile *c); -void qir_dump_inst(struct qinst *inst); +void qir_dump_inst(struct vc4_compile *c, struct qinst *inst); const char *qir_get_stage_name(enum qstage stage); void qir_optimize(struct vc4_compile *c); |