[Mesa-dev] [PATCH 1/2] i965/fs: Simulate MAD opcode with gen<6

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Tue May 6 03:53:58 PDT 2014


Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index d2dc5fa..22ca528 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -293,10 +293,6 @@ fs_visitor::try_emit_saturate(ir_expression *ir)
 bool
 fs_visitor::try_emit_mad(ir_expression *ir)
 {
-   /* 3-src instructions were introduced in gen6. */
-   if (brw->gen < 6)
-      return false;
-
    /* MAD can only handle floating-point data. */
    if (ir->type != glsl_type::float_type)
       return false;
@@ -327,7 +323,16 @@ fs_visitor::try_emit_mad(ir_expression *ir)
    fs_reg src2 = this->result;
 
    this->result = fs_reg(this, ir->type);
-   emit(BRW_OPCODE_MAD, this->result, src0, src1, src2);
+
+   /* 3-src instructions were introduced in gen6. */
+   if (brw->gen < 6) {
+      fs_reg temp = fs_reg(this, glsl_type::float_type);
+
+      emit(MUL(temp, src1, src2));
+      emit(ADD(this->result, src0, temp));
+   } else {
+      emit(BRW_OPCODE_MAD, this->result, src0, src1, src2);
+   }
 
    return true;
 }
-- 
1.8.1.2



More information about the mesa-dev mailing list