i965: Share OPCODE_MAD between brw_wm_glsl.c and brw_wm_emit.c
authorEric Anholt <eric@anholt.net>
Wed, 12 Aug 2009 02:17:31 +0000 (19:17 -0700)
committerEric Anholt <eric@anholt.net>
Sat, 7 Nov 2009 05:08:54 +0000 (21:08 -0800)
src/mesa/drivers/dri/i965/brw_wm.h
src/mesa/drivers/dri/i965/brw_wm_emit.c
src/mesa/drivers/dri/i965/brw_wm_glsl.c

index 18f17f2..e0445aa 100644 (file)
@@ -351,5 +351,11 @@ void emit_lrp(struct brw_compile *p,
              const struct brw_reg *arg0,
              const struct brw_reg *arg1,
              const struct brw_reg *arg2);
+void emit_mad(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1,
+             const struct brw_reg *arg2);
 
 #endif
index bc5abb9..6cdc4f7 100644 (file)
@@ -402,12 +402,12 @@ void emit_alu2(struct brw_compile *p,
 }
 
 
-static void emit_mad( struct brw_compile *p, 
-                     const struct brw_reg *dst,
-                     GLuint mask,
-                     const struct brw_reg *arg0,
-                     const struct brw_reg *arg1,
-                     const struct brw_reg *arg2 )
+void emit_mad(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1,
+             const struct brw_reg *arg2)
 {
    GLuint i;
 
index 536eac8..55e3e9f 100644 (file)
@@ -1214,29 +1214,6 @@ static void emit_kil(struct brw_wm_compile *c)
     brw_pop_insn_state(p);
 }
 
-static void emit_mad(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-    struct brw_reg dst, src0, src1, src2;
-    int i;
-
-    for (i = 0; i < 4; i++) {
-       if (mask & (1<<i)) {
-           dst = get_dst_reg(c, inst, i);
-           src0 = get_src_reg(c, inst, 0, i);
-           src1 = get_src_reg_imm(c, inst, 1, i);
-           src2 = get_src_reg_imm(c, inst, 2, i);
-           brw_MUL(p, dst, src0, src1);
-
-           brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
-           brw_ADD(p, dst, dst, src2);
-           brw_set_saturate(p, 0);
-       }
-    }
-}
-
 static void emit_sop(struct brw_wm_compile *c,
                      const struct prog_instruction *inst, GLuint cond)
 {
@@ -2734,7 +2711,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
                emit_pow(c, inst);
                break;
            case OPCODE_MAD:
-               emit_mad(c, inst);
+               emit_mad(p, dst, dst_flags, args[0], args[1], args[2]);
                break;
            case OPCODE_NOISE1:
                emit_noise1(c, inst);