From 5b20588a1eb4eb08d6762157a39d828015456d8b Mon Sep 17 00:00:00 2001
From: Peter Clifton <pcjc2@cam.ac.uk>
Date: Wed, 17 Nov 2010 04:05:48 +0000
Subject: [PATCH] Enable dead code elimination for unused interpolated channels
Work around limitations in the dead-code eliminator, and use
separate virtual registers for the PLN and MOV results. This
allows the dead-code eliminator to track the usage of the MOV
result and the PLN result separately.
---
src/mesa/drivers/dri/i965/brw_fs.cpp | 27 ++++++++++++++++-----------
1 files changed, 16 insertions(+), 11 deletions(-)
@@ -440,10 +440,13 @@ fs_visitor::emit_fragcoord_interpolation(ir_variable *ir)
fs_reg *
fs_visitor::emit_general_interpolation(ir_variable *ir)
{
- fs_reg *reg = new(this->mem_ctx) fs_reg(this, ir->type);
+ fs_reg *reg1 = new(this->mem_ctx) fs_reg(this, ir->type);
+ fs_reg *reg2 = new(this->mem_ctx) fs_reg(this, ir->type);
/* Interpolation is always in floating point regs. */
- reg->type = BRW_REGISTER_TYPE_F;
- fs_reg attr = *reg;
+ reg1->type = BRW_REGISTER_TYPE_F;
+ reg2->type = BRW_REGISTER_TYPE_F;
+ fs_reg attr1 = *reg1;
+ fs_reg attr2 = *reg2;
unsigned int array_elements;
const glsl_type *type;
@@ -466,7 +469,8 @@ fs_visitor::emit_general_interpolation(ir_variable *ir)
/* If there's no incoming setup data for this slot, don't
* emit interpolation for it.
*/
- attr.reg_offset += type->vector_elements;
+ attr1.reg_offset += type->vector_elements;
+ attr2.reg_offset += type->vector_elements;
location++;
continue;
}
@@ -474,28 +478,29 @@ fs_visitor::emit_general_interpolation(ir_variable *ir)
for (unsigned int c = 0; c < type->vector_elements; c++) {
struct brw_reg interp = interp_reg(location, c);
emit(fs_inst(FS_OPCODE_LINTERP,
- attr,
+ attr1,
this->delta_x,
this->delta_y,
fs_reg(interp)));
- attr.reg_offset++;
+ attr1.reg_offset++;
}
if (intel->gen < 6) {
- attr.reg_offset -= type->vector_elements;
+ attr1.reg_offset -= type->vector_elements;
for (unsigned int c = 0; c < type->vector_elements; c++) {
emit(fs_inst(BRW_OPCODE_MUL,
- attr,
- attr,
+ attr2,
+ attr1,
this->pixel_w));
- attr.reg_offset++;
+ attr1.reg_offset++;
+ attr2.reg_offset++;
}
}
location++;
}
}
- return reg;
+ return reg2;
}
fs_reg *
--
1.7.1