i965: Prepare for using the ATTR register file in the fs backend
The scalar vertex shader will use the ATTR register file for vertex attributes. This patch adds support for the ATTR file to fs_visitor. Signed-off-by: Kristian Høgsberg <krh@bitplanet.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
df0966fb1a
commit
3d10f0a98c
|
@ -76,7 +76,7 @@ fs_inst::init(enum opcode opcode, uint8_t exec_size, const fs_reg &dst,
|
||||||
this->exec_size = dst.width;
|
this->exec_size = dst.width;
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < sources; ++i) {
|
for (int i = 0; i < sources; ++i) {
|
||||||
if (src[i].file != GRF)
|
if (src[i].file != GRF && src[i].file != ATTR)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (this->exec_size <= 1)
|
if (this->exec_size <= 1)
|
||||||
|
@ -97,6 +97,7 @@ fs_inst::init(enum opcode opcode, uint8_t exec_size, const fs_reg &dst,
|
||||||
break;
|
break;
|
||||||
case GRF:
|
case GRF:
|
||||||
case HW_REG:
|
case HW_REG:
|
||||||
|
case ATTR:
|
||||||
assert(this->src[i].width > 0);
|
assert(this->src[i].width > 0);
|
||||||
if (this->src[i].width == 1) {
|
if (this->src[i].width == 1) {
|
||||||
this->src[i].effective_width = this->exec_size;
|
this->src[i].effective_width = this->exec_size;
|
||||||
|
@ -121,6 +122,7 @@ fs_inst::init(enum opcode opcode, uint8_t exec_size, const fs_reg &dst,
|
||||||
case GRF:
|
case GRF:
|
||||||
case HW_REG:
|
case HW_REG:
|
||||||
case MRF:
|
case MRF:
|
||||||
|
case ATTR:
|
||||||
this->regs_written = (dst.width * dst.stride * type_sz(dst.type) + 31) / 32;
|
this->regs_written = (dst.width * dst.stride * type_sz(dst.type) + 31) / 32;
|
||||||
break;
|
break;
|
||||||
case BAD_FILE:
|
case BAD_FILE:
|
||||||
|
@ -3132,6 +3134,9 @@ fs_visitor::dump_instruction(backend_instruction *be_inst, FILE *file)
|
||||||
case UNIFORM:
|
case UNIFORM:
|
||||||
fprintf(file, "***u%d***", inst->dst.reg + inst->dst.reg_offset);
|
fprintf(file, "***u%d***", inst->dst.reg + inst->dst.reg_offset);
|
||||||
break;
|
break;
|
||||||
|
case ATTR:
|
||||||
|
fprintf(file, "***attr%d***", inst->dst.reg + inst->dst.reg_offset);
|
||||||
|
break;
|
||||||
case HW_REG:
|
case HW_REG:
|
||||||
if (inst->dst.fixed_hw_reg.file == BRW_ARCHITECTURE_REGISTER_FILE) {
|
if (inst->dst.fixed_hw_reg.file == BRW_ARCHITECTURE_REGISTER_FILE) {
|
||||||
switch (inst->dst.fixed_hw_reg.nr) {
|
switch (inst->dst.fixed_hw_reg.nr) {
|
||||||
|
@ -3183,6 +3188,9 @@ fs_visitor::dump_instruction(backend_instruction *be_inst, FILE *file)
|
||||||
case MRF:
|
case MRF:
|
||||||
fprintf(file, "***m%d***", inst->src[i].reg);
|
fprintf(file, "***m%d***", inst->src[i].reg);
|
||||||
break;
|
break;
|
||||||
|
case ATTR:
|
||||||
|
fprintf(file, "attr%d", inst->src[i].reg + inst->src[i].reg_offset);
|
||||||
|
break;
|
||||||
case UNIFORM:
|
case UNIFORM:
|
||||||
fprintf(file, "u%d", inst->src[i].reg + inst->src[i].reg_offset);
|
fprintf(file, "u%d", inst->src[i].reg + inst->src[i].reg_offset);
|
||||||
if (inst->src[i].reladdr) {
|
if (inst->src[i].reladdr) {
|
||||||
|
|
|
@ -140,6 +140,7 @@ byte_offset(fs_reg reg, unsigned delta)
|
||||||
case BAD_FILE:
|
case BAD_FILE:
|
||||||
break;
|
break;
|
||||||
case GRF:
|
case GRF:
|
||||||
|
case ATTR:
|
||||||
reg.reg_offset += delta / 32;
|
reg.reg_offset += delta / 32;
|
||||||
break;
|
break;
|
||||||
case MRF:
|
case MRF:
|
||||||
|
@ -165,6 +166,7 @@ horiz_offset(fs_reg reg, unsigned delta)
|
||||||
break;
|
break;
|
||||||
case GRF:
|
case GRF:
|
||||||
case MRF:
|
case MRF:
|
||||||
|
case ATTR:
|
||||||
return byte_offset(reg, delta * reg.stride * type_sz(reg.type));
|
return byte_offset(reg, delta * reg.stride * type_sz(reg.type));
|
||||||
default:
|
default:
|
||||||
assert(delta == 0);
|
assert(delta == 0);
|
||||||
|
@ -181,6 +183,7 @@ offset(fs_reg reg, unsigned delta)
|
||||||
break;
|
break;
|
||||||
case GRF:
|
case GRF:
|
||||||
case MRF:
|
case MRF:
|
||||||
|
case ATTR:
|
||||||
return byte_offset(reg, delta * reg.width * reg.stride * type_sz(reg.type));
|
return byte_offset(reg, delta * reg.width * reg.stride * type_sz(reg.type));
|
||||||
case UNIFORM:
|
case UNIFORM:
|
||||||
reg.reg_offset += delta;
|
reg.reg_offset += delta;
|
||||||
|
|
|
@ -107,8 +107,6 @@ brw_reg_from_fs_reg(fs_reg *reg)
|
||||||
/* Probably unused. */
|
/* Probably unused. */
|
||||||
brw_reg = brw_null_reg();
|
brw_reg = brw_null_reg();
|
||||||
break;
|
break;
|
||||||
case UNIFORM:
|
|
||||||
unreachable("not reached");
|
|
||||||
default:
|
default:
|
||||||
unreachable("not reached");
|
unreachable("not reached");
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,8 +197,15 @@ fs_visitor::visit(ir_dereference_array *ir)
|
||||||
src.type = brw_type_for_base_type(ir->type);
|
src.type = brw_type_for_base_type(ir->type);
|
||||||
|
|
||||||
if (constant_index) {
|
if (constant_index) {
|
||||||
assert(src.file == UNIFORM || src.file == GRF || src.file == HW_REG);
|
if (src.file == ATTR) {
|
||||||
src = offset(src, constant_index->value.i[0] * element_size);
|
/* Attribute arrays get loaded as one vec4 per element. In that case
|
||||||
|
* offset the source register.
|
||||||
|
*/
|
||||||
|
src.reg += constant_index->value.i[0];
|
||||||
|
} else {
|
||||||
|
assert(src.file == UNIFORM || src.file == GRF || src.file == HW_REG);
|
||||||
|
src = offset(src, constant_index->value.i[0] * element_size);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Variable index array dereference. We attach the variable index
|
/* Variable index array dereference. We attach the variable index
|
||||||
* component to the reg as a pointer to a register containing the
|
* component to the reg as a pointer to a register containing the
|
||||||
|
@ -571,7 +578,8 @@ fs_visitor::visit(ir_expression *ir)
|
||||||
ir->operands[operand]->fprint(stderr);
|
ir->operands[operand]->fprint(stderr);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
assert(this->result.file == GRF || this->result.file == UNIFORM);
|
assert(this->result.file == GRF ||
|
||||||
|
this->result.file == UNIFORM || this->result.file == ATTR);
|
||||||
op[operand] = this->result;
|
op[operand] = this->result;
|
||||||
|
|
||||||
/* Matrix expression operands should have been broken down to vector
|
/* Matrix expression operands should have been broken down to vector
|
||||||
|
|
Loading…
Reference in New Issue