diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-12-11 08:37:01 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-12-11 08:37:01 +0000 |
commit | e4c140c4d4d00c16d99b15ee6677cbd2e3364031 (patch) | |
tree | 96364a9f799341ef8dff3d1534f1de0eb3a559b1 /lib/mesa/src/gallium/drivers/vc4 | |
parent | 10010c14c68222d4056694bf3643ee969d18cd4f (diff) |
Import Mesa 13.0.2
Diffstat (limited to 'lib/mesa/src/gallium/drivers/vc4')
5 files changed, 80 insertions, 69 deletions
diff --git a/lib/mesa/src/gallium/drivers/vc4/vc4_opt_peephole_sf.c b/lib/mesa/src/gallium/drivers/vc4/vc4_opt_peephole_sf.c index 577290b1f..f4856673b 100644 --- a/lib/mesa/src/gallium/drivers/vc4/vc4_opt_peephole_sf.c +++ b/lib/mesa/src/gallium/drivers/vc4/vc4_opt_peephole_sf.c @@ -62,7 +62,7 @@ inst_srcs_updated(struct qinst *inst, struct qinst *writer) */ switch (writer->dst.file) { case QFILE_TEMP: - for (int i = 0; i < qir_get_nsrc(inst); i++) { + for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) { if (inst->src[i].file == QFILE_TEMP && inst->src[i].index == writer->dst.index) { return true; @@ -95,7 +95,7 @@ inst_result_equals(struct qinst *a, struct qinst *b) return false; } - for (int i = 0; i < qir_get_nsrc(a); i++) { + for (int i = 0; i < qir_get_op_nsrc(a->op); i++) { if (!qir_reg_equals(a->src[i], b->src[i]) || src_file_varies_on_reread(a->src[i]) || src_file_varies_on_reread(b->src[i])) { diff --git a/lib/mesa/src/gallium/drivers/vc4/vc4_opt_vpm.c b/lib/mesa/src/gallium/drivers/vc4/vc4_opt_vpm.c index 6f196e7d1..83ba11b81 100644 --- a/lib/mesa/src/gallium/drivers/vc4/vc4_opt_vpm.c +++ b/lib/mesa/src/gallium/drivers/vc4/vc4_opt_vpm.c @@ -24,8 +24,10 @@ /** * @file vc4_opt_vpm.c * - * This modifies instructions that exclusively consume a value read from the - * VPM to directly read the VPM if other operands allow it. + * This modifies instructions that: + * 1. exclusively consume a value read from the VPM to directly read the VPM if + * other operands allow it. + * 2. generate the value consumed by a VPM write to write directly into the VPM. */ #include "vc4_qir.h" @@ -42,11 +44,21 @@ qir_opt_vpm(struct vc4_compile *c) return false; bool progress = false; + struct qinst *vpm_writes[64] = { 0 }; uint32_t use_count[c->num_temps]; + uint32_t vpm_write_count = 0; memset(&use_count, 0, sizeof(use_count)); qir_for_each_inst_inorder(inst, c) { - for (int i = 0; i < qir_get_nsrc(inst); i++) { + switch (inst->dst.file) { + case QFILE_VPM: + vpm_writes[vpm_write_count++] = inst; + break; + default: + break; + } + + for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) { if (inst->src[i].file == QFILE_TEMP) { uint32_t temp = inst->src[i].index; use_count[temp]++; @@ -69,7 +81,7 @@ qir_opt_vpm(struct vc4_compile *c) qir_is_tex(inst)) continue; - for (int j = 0; j < qir_get_nsrc(inst); j++) { + for (int j = 0; j < qir_get_op_nsrc(inst->op); j++) { if (inst->src[j].file != QFILE_TEMP || inst->src[j].pack) continue; @@ -94,7 +106,7 @@ qir_opt_vpm(struct vc4_compile *c) } uint32_t temps = 0; - for (int k = 0; k < qir_get_nsrc(inst); k++) { + for (int k = 0; k < qir_get_op_nsrc(inst->op); k++) { if (inst->src[k].file == QFILE_TEMP) temps++; } @@ -115,5 +127,42 @@ qir_opt_vpm(struct vc4_compile *c) } } + for (int i = 0; i < vpm_write_count; i++) { + if (!qir_is_raw_mov(vpm_writes[i]) || + vpm_writes[i]->src[0].file != QFILE_TEMP) { + continue; + } + + uint32_t temp = vpm_writes[i]->src[0].index; + if (use_count[temp] != 1) + continue; + + struct qinst *inst = c->defs[temp]; + if (!inst) + continue; + + if (qir_depends_on_flags(inst) || inst->sf) + continue; + + if (qir_has_side_effects(c, inst) || + qir_has_side_effect_reads(c, inst)) { + continue; + } + + /* Move the generating instruction to the end of the program + * to maintain the order of the VPM writes. + */ + assert(!vpm_writes[i]->sf); + list_del(&inst->link); + list_addtail(&inst->link, &vpm_writes[i]->link); + qir_remove_instruction(c, vpm_writes[i]); + + c->defs[inst->dst.index] = NULL; + inst->dst.file = QFILE_VPM; + inst->dst.index = 0; + + progress = true; + } + return progress; } diff --git a/lib/mesa/src/gallium/drivers/vc4/vc4_qir_emit_uniform_stream_resets.c b/lib/mesa/src/gallium/drivers/vc4/vc4_qir_emit_uniform_stream_resets.c index 443682a46..3fd6358e3 100644 --- a/lib/mesa/src/gallium/drivers/vc4/vc4_qir_emit_uniform_stream_resets.c +++ b/lib/mesa/src/gallium/drivers/vc4/vc4_qir_emit_uniform_stream_resets.c @@ -36,10 +36,24 @@ #include "util/u_math.h" static bool +inst_reads_a_uniform(struct qinst *inst) +{ + if (qir_is_tex(inst)) + return true; + + for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) { + if (inst->src[i].file == QFILE_UNIF) + return true; + } + + return false; +} + +static bool block_reads_any_uniform(struct qblock *block) { qir_for_each_inst(inst, block) { - if (qir_has_uniform_read(inst)) + if (inst_reads_a_uniform(inst)) return true; } @@ -80,7 +94,7 @@ qir_emit_uniform_stream_resets(struct vc4_compile *c) } qir_for_each_inst(inst, block) { - if (qir_has_uniform_read(inst)) + if (inst_reads_a_uniform(inst)) uniform_count++; } } diff --git a/lib/mesa/src/gallium/drivers/vc4/vc4_qir_live_variables.c b/lib/mesa/src/gallium/drivers/vc4/vc4_qir_live_variables.c index 7108b3ee9..beefb0d7f 100644 --- a/lib/mesa/src/gallium/drivers/vc4/vc4_qir_live_variables.c +++ b/lib/mesa/src/gallium/drivers/vc4/vc4_qir_live_variables.c @@ -205,7 +205,7 @@ qir_setup_def_use(struct vc4_compile *c) _mesa_hash_table_clear(partial_update_ht, NULL); qir_for_each_inst(inst, block) { - for (int i = 0; i < qir_get_nsrc(inst); i++) + for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) qir_setup_use(c, block, ip, inst->src[i]); qir_setup_def(c, block, ip, partial_update_ht, inst); @@ -301,13 +301,8 @@ qir_calculate_live_intervals(struct vc4_compile *c) { int bitset_words = BITSET_WORDS(c->num_temps); - /* If we called this function more than once, then we should be - * freeing the previous arrays. - */ - assert(!c->temp_start); - - c->temp_start = rzalloc_array(c, int, c->num_temps); - c->temp_end = rzalloc_array(c, int, c->num_temps); + c->temp_start = reralloc(c, c->temp_start, int, c->num_temps); + c->temp_end = reralloc(c, c->temp_end, int, c->num_temps); for (int i = 0; i < c->num_temps; i++) { c->temp_start[i] = MAX_INSTRUCTION; @@ -315,10 +310,10 @@ qir_calculate_live_intervals(struct vc4_compile *c) } qir_for_each_block(block, c) { - block->def = rzalloc_array(c, BITSET_WORD, bitset_words); - block->use = rzalloc_array(c, BITSET_WORD, bitset_words); - block->live_in = rzalloc_array(c, BITSET_WORD, bitset_words); - block->live_out = rzalloc_array(c, BITSET_WORD, bitset_words); + block->def = reralloc(c, block->def, BITSET_WORD, bitset_words); + block->use = reralloc(c, block->use, BITSET_WORD, bitset_words); + block->live_in = reralloc(c, block->live_in, BITSET_WORD, bitset_words); + block->live_out = reralloc(c, block->live_out, BITSET_WORD, bitset_words); } qir_setup_def_use(c); @@ -327,27 +322,4 @@ qir_calculate_live_intervals(struct vc4_compile *c) ; qir_compute_start_end(c, c->num_temps); - - if (vc4_debug & VC4_DEBUG_SHADERDB) { - int last_ip = 0; - for (int i = 0; i < c->num_temps; i++) - last_ip = MAX2(last_ip, c->temp_end[i]); - - int reg_pressure = 0; - int max_reg_pressure = 0; - for (int i = 0; i < last_ip; i++) { - for (int j = 0; j < c->num_temps; j++) { - if (c->temp_start[j] == i) - reg_pressure++; - if (c->temp_end[j] == i) - reg_pressure--; - } - max_reg_pressure = MAX2(max_reg_pressure, reg_pressure); - } - - fprintf(stderr, "SHADER-DB: %s prog %d/%d: %d max temps\n", - qir_get_stage_name(c->stage), - c->program_id, c->variant_id, - max_reg_pressure); - } } diff --git a/lib/mesa/src/gallium/drivers/vc4/vc4_qir_validate.c b/lib/mesa/src/gallium/drivers/vc4/vc4_qir_validate.c index 302eb4826..e7cfe5ad2 100644 --- a/lib/mesa/src/gallium/drivers/vc4/vc4_qir_validate.c +++ b/lib/mesa/src/gallium/drivers/vc4/vc4_qir_validate.c @@ -84,28 +84,9 @@ void qir_validate(struct vc4_compile *c) case QFILE_LOAD_IMM: fail_instr(c, inst, "Bad dest file"); break; - - case QFILE_TEX_S: - case QFILE_TEX_T: - case QFILE_TEX_R: - case QFILE_TEX_B: - if (inst->src[qir_get_tex_uniform_src(inst)].file != - QFILE_UNIF) { - fail_instr(c, inst, - "tex op missing implicit uniform"); - } - break; - - case QFILE_TEX_S_DIRECT: - if (inst->op != QOP_ADD) { - fail_instr(c, inst, - "kernel validation requires that " - "direct texture lookups use an ADD"); - } - break; } - for (int i = 0; i < qir_get_nsrc(inst); i++) { + for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) { struct qreg src = inst->src[i]; switch (src.file) { @@ -138,11 +119,6 @@ void qir_validate(struct vc4_compile *c) case QFILE_TLB_COLOR_WRITE_MS: case QFILE_TLB_Z_WRITE: case QFILE_TLB_STENCIL_SETUP: - case QFILE_TEX_S_DIRECT: - case QFILE_TEX_S: - case QFILE_TEX_T: - case QFILE_TEX_R: - case QFILE_TEX_B: fail_instr(c, inst, "Bad src file"); break; } |