--- src/mesa/drivers/dri/i965/brw_fs.cpp | 31 +++++++++++----------- .../drivers/dri/i965/brw_fs_combine_constants.cpp | 13 +++++---- .../drivers/dri/i965/brw_fs_copy_propagation.cpp | 14 +++++----- src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 2 +- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 9 ++----- src/mesa/drivers/dri/i965/brw_ir_fs.h | 13 +++------ 6 files changed, 35 insertions(+), 47 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 41a3f81..6ee590e 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -432,7 +432,6 @@ fs_reg::fs_reg(struct ::brw_reg reg) : backend_reg(reg) { this->reg_offset = 0; - this->subreg_offset = 0; this->reladdr = NULL; this->stride = 1; if (this->file == IMM && @@ -447,7 +446,6 @@ bool fs_reg::equals(const fs_reg &r) const { return (this->backend_reg::equals(r) && - subreg_offset == r.subreg_offset && !reladdr && !r.reladdr && stride == r.stride); } @@ -456,7 +454,8 @@ fs_reg & fs_reg::set_smear(unsigned subreg) { assert(file != ARF && file != FIXED_GRF && file != IMM); - subreg_offset = subreg * type_sz(type); + assert(subreg * type_sz(type) < (1 << 5)); /* subnr is 5 bits */ + subnr = subreg * type_sz(type); stride = 0; return *this; } @@ -1513,7 +1512,7 @@ fs_visitor::assign_curb_setup() assert(inst->src[i].stride == 0); inst->src[i] = byte_offset( retype(brw_reg, inst->src[i].type), - inst->src[i].subreg_offset); + inst->src[i].subnr); } } } @@ -1653,7 +1652,7 @@ fs_visitor::convert_attr_sources_to_hw_regs(fs_inst *inst) unsigned width = inst->src[i].stride == 0 ? 1 : inst->exec_size; struct brw_reg reg = stride(byte_offset(retype(brw_vec8_grf(grf, 0), inst->src[i].type), - inst->src[i].subreg_offset), + inst->src[i].subnr), inst->exec_size * inst->src[i].stride, width, inst->src[i].stride); reg.abs = inst->src[i].abs; @@ -2597,7 +2596,7 @@ fs_visitor::compute_to_mrf() inst->dst.type != inst->src[0].type || inst->src[0].abs || inst->src[0].negate || !inst->src[0].is_contiguous() || - inst->src[0].subreg_offset) + inst->src[0].subnr) continue; /* Work out which hardware MRF registers are written by this @@ -3367,7 +3366,7 @@ fs_visitor::lower_integer_multiplication() assert(src1_1_w.stride == 1); src1_1_w.stride = 2; } - src1_1_w.subreg_offset += type_sz(BRW_REGISTER_TYPE_UW); + src1_1_w.subnr += type_sz(BRW_REGISTER_TYPE_UW); } ibld.MUL(low, inst->src[0], src1_0_w); ibld.MUL(high, inst->src[0], src1_1_w); @@ -3386,7 +3385,7 @@ fs_visitor::lower_integer_multiplication() assert(src0_1_w.stride == 1); src0_1_w.stride = 2; } - src0_1_w.subreg_offset += type_sz(BRW_REGISTER_TYPE_UW); + src0_1_w.subnr += type_sz(BRW_REGISTER_TYPE_UW); ibld.MUL(low, src0_0_w, inst->src[1]); ibld.MUL(high, src0_1_w, inst->src[1]); @@ -3394,14 +3393,14 @@ fs_visitor::lower_integer_multiplication() fs_reg dst = inst->dst; dst.type = BRW_REGISTER_TYPE_UW; - dst.subreg_offset = 2; + dst.subnr = 2; dst.stride = 2; high.type = BRW_REGISTER_TYPE_UW; high.stride = 2; low.type = BRW_REGISTER_TYPE_UW; - low.subreg_offset = 2; + low.subnr = 2; low.stride = 2; ibld.ADD(dst, low, high); @@ -4642,9 +4641,9 @@ fs_visitor::dump_instruction(backend_instruction *be_inst, FILE *file) case VGRF: fprintf(file, "vgrf%d", inst->dst.nr); if (alloc.sizes[inst->dst.nr] != inst->regs_written || - inst->dst.subreg_offset) + inst->dst.subnr) fprintf(file, "+%d.%d", - inst->dst.reg_offset, inst->dst.subreg_offset); + inst->dst.reg_offset, inst->dst.subnr); break; case FIXED_GRF: fprintf(file, "g%d", inst->dst.nr); @@ -4698,9 +4697,9 @@ fs_visitor::dump_instruction(backend_instruction *be_inst, FILE *file) case VGRF: fprintf(file, "vgrf%d", inst->src[i].nr); if (alloc.sizes[inst->src[i].nr] != (unsigned)inst->regs_read(i) || - inst->src[i].subreg_offset) + inst->src[i].subnr) fprintf(file, "+%d.%d", inst->src[i].reg_offset, - inst->src[i].subreg_offset); + inst->src[i].subnr); break; case FIXED_GRF: fprintf(file, "g%d", inst->src[i].nr); @@ -4715,9 +4714,9 @@ fs_visitor::dump_instruction(backend_instruction *be_inst, FILE *file) fprintf(file, "u%d", inst->src[i].nr + inst->src[i].reg_offset); if (inst->src[i].reladdr) { fprintf(file, "+reladdr"); - } else if (inst->src[i].subreg_offset) { + } else if (inst->src[i].subnr) { fprintf(file, "+%d.%d", inst->src[i].reg_offset, - inst->src[i].subreg_offset); + inst->src[i].subnr); } break; case BAD_FILE: 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 d7a1456..f7c9786 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp @@ -121,7 +121,7 @@ struct imm { * The GRF register and subregister number where we've decided to store the * constant value. */ - uint8_t subreg_offset; + uint8_t subnr; uint16_t nr; /** The number of coissuable instructions using this immediate. */ @@ -281,12 +281,11 @@ fs_visitor::opt_combine_constants() ibld.MOV(reg, brw_imm_f(imm->val)); imm->nr = reg.nr; - imm->subreg_offset = reg.subreg_offset; + imm->subnr = reg.subnr; - reg.subreg_offset += sizeof(float); - if ((unsigned)reg.subreg_offset == 8 * sizeof(float)) { + reg.subnr += sizeof(float); + if (reg.subnr == 0) { reg.nr = alloc.allocate(1); - reg.subreg_offset = 0; } } promoted_constants = table.len; @@ -297,7 +296,7 @@ fs_visitor::opt_combine_constants() fs_reg *reg = link->reg; reg->file = VGRF; reg->nr = table.imm[i].nr; - reg->subreg_offset = table.imm[i].subreg_offset; + reg->subnr = table.imm[i].subnr; reg->stride = 0; reg->negate = signbit(reg->f) != signbit(table.imm[i].val); assert((isnan(reg->f) && isnan(table.imm[i].val)) || @@ -314,7 +313,7 @@ fs_visitor::opt_combine_constants() imm->val, imm->block->num, imm->nr, - imm->subreg_offset, + imm->subnr, imm->must_promote, imm->uses_by_coissue, imm->first_use_ip, diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp index fd25307..d876d07 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp @@ -352,7 +352,7 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry) * that entry is writing. */ if (inst->src[arg].reg_offset < entry->dst.reg_offset || - (inst->src[arg].reg_offset * 32 + inst->src[arg].subreg_offset + + (inst->src[arg].reg_offset * 32 + inst->src[arg].subnr + inst->regs_read(arg) * inst->src[arg].stride * 32) > (entry->dst.reg_offset + entry->regs_written) * 32) return false; @@ -445,7 +445,7 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry) case ARF: case FIXED_GRF: inst->src[arg].reg_offset = entry->src.reg_offset; - inst->src[arg].subreg_offset = entry->src.subreg_offset; + inst->src[arg].subnr = entry->src.subnr; break; case ATTR: case VGRF: @@ -461,15 +461,15 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry) */ /* Compute the offset of inst->src[arg] relative to inst->dst */ - assert(entry->dst.subreg_offset == 0); + assert(entry->dst.subnr == 0); int rel_offset = inst->src[arg].reg_offset - entry->dst.reg_offset; - int rel_suboffset = inst->src[arg].subreg_offset; + int rel_suboffset = inst->src[arg].subnr; /* Compute the final register offset (in bytes) */ - int offset = entry->src.reg_offset * 32 + entry->src.subreg_offset; + int offset = entry->src.reg_offset * 32 + entry->src.subnr; offset += rel_offset * 32 + rel_suboffset; inst->src[arg].reg_offset = offset / 32; - inst->src[arg].subreg_offset = offset % 32; + inst->src[arg].subnr = offset % 32; } break; @@ -523,7 +523,7 @@ fs_visitor::try_constant_propagate(fs_inst *inst, acp_entry *entry) * that entry is writing. */ if (inst->src[i].reg_offset < entry->dst.reg_offset || - (inst->src[i].reg_offset * 32 + inst->src[i].subreg_offset + + (inst->src[i].reg_offset * 32 + inst->src[i].subnr + inst->regs_read(i) * inst->src[i].stride * 32) > (entry->dst.reg_offset + entry->regs_written) * 32) continue; diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index 1916a99..a2d379e 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -84,7 +84,7 @@ brw_reg_from_fs_reg(fs_inst *inst, fs_reg *reg, unsigned gen) } brw_reg = retype(brw_reg, reg->type); - brw_reg = byte_offset(brw_reg, reg->subreg_offset); + brw_reg = byte_offset(brw_reg, reg->subnr); brw_reg.abs = reg->abs; brw_reg.negate = reg->negate; break; diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 0efb2fa..54c34d4 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -544,13 +544,13 @@ fs_visitor::optimize_frontfacing_ternary(nir_alu_instr *instr, } tmp.type = BRW_REGISTER_TYPE_W; - tmp.subreg_offset = 2; + tmp.subnr = 2; tmp.stride = 2; bld.OR(tmp, g0, brw_imm_uw(0x3f80)); tmp.type = BRW_REGISTER_TYPE_D; - tmp.subreg_offset = 0; + tmp.subnr = 0; tmp.stride = 1; } else { /* Bit 31 of g1.6 is 0 if the polygon is front facing. */ @@ -2564,11 +2564,6 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr for (unsigned i = 0; i < instr->num_components; i++) { packed_consts.set_smear(const_offset->u[0] % 16 / 4 + i); - /* The std140 packing rules don't allow vectors to cross 16-byte - * boundaries, and a reg is 32 bytes. - */ - assert(packed_consts.subreg_offset < 32); - bld.MOV(dest, packed_consts); dest = offset(dest, bld, 1); } diff --git a/src/mesa/drivers/dri/i965/brw_ir_fs.h b/src/mesa/drivers/dri/i965/brw_ir_fs.h index c3eec2e..1841625 100644 --- a/src/mesa/drivers/dri/i965/brw_ir_fs.h +++ b/src/mesa/drivers/dri/i965/brw_ir_fs.h @@ -52,12 +52,6 @@ public: /** Smear a channel of the reg to all channels. */ fs_reg &set_smear(unsigned subreg); - /** - * Offset in bytes from the start of the register. Values up to a - * backend_reg::reg_offset unit are valid. - */ - int subreg_offset; - fs_reg *reladdr; /** Register region horizontal stride */ @@ -98,7 +92,7 @@ byte_offset(fs_reg reg, unsigned delta) case UNIFORM: assert(delta == 0); } - reg.subreg_offset += delta % 32; + reg.subnr += delta % 32; return reg; } @@ -127,8 +121,9 @@ horiz_offset(fs_reg reg, unsigned delta) static inline fs_reg component(fs_reg reg, unsigned idx) { - assert(reg.subreg_offset == 0); - reg.subreg_offset = idx * type_sz(reg.type); + assert(reg.subnr == 0); + assert(idx * type_sz(reg.type) < (1 << 5)); /* subnr is 5 bits */ + reg.subnr = idx * type_sz(reg.type); reg.stride = 0; return reg; } -- 2.4.10 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev