[Mesa-dev] [RFC 9/9] i965/fs: Emit MAD instructions when possible.
Matt Turner
mattst88 at gmail.com
Fri Oct 31 18:27:53 PDT 2014
Previously we didn't emit MAD instructions since they cannot take
immediate arguments, but with the opt_combine_constants() pass we can
handle this properly.
---
src/mesa/drivers/dri/i965/brw_fs_fp.cpp | 11 ++++++++---
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 5 -----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
index 6348bc1..62cea7a 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
@@ -318,9 +318,14 @@ fs_visitor::emit_fragment_program_code()
case OPCODE_MAD:
for (int i = 0; i < 4; i++) {
if (fpi->DstReg.WriteMask & (1 << i)) {
- fs_reg temp = fs_reg(this, glsl_type::float_type);
- emit(MUL(temp, offset(src[0], i), offset(src[1], i)));
- emit(ADD(offset(dst, i), temp, offset(src[2], i)));
+ if (brw->gen >= 6) {
+ emit(MAD(offset(dst, i), offset(src[2], i),
+ offset(src[1], i), offset(src[0], i)));
+ } else {
+ fs_reg temp = fs_reg(this, glsl_type::float_type);
+ emit(MUL(temp, offset(src[0], i), offset(src[1], i)));
+ emit(ADD(offset(dst, i), temp, offset(src[2], i)));
+ }
}
}
break;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 3fc9e39..c610a9e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -319,11 +319,6 @@ fs_visitor::try_emit_mad(ir_expression *ir)
return false;
}
- if (nonmul->as_constant() ||
- mul->operands[0]->as_constant() ||
- mul->operands[1]->as_constant())
- return false;
-
nonmul->accept(this);
fs_reg src0 = this->result;
--
2.0.4
More information about the mesa-dev
mailing list