i965: Implement frag prog DPH like DP4
authorIan Romanick <ian.d.romanick@intel.com>
Sat, 22 Aug 2009 08:35:12 +0000 (01:35 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Sat, 22 Aug 2009 08:35:12 +0000 (01:35 -0700)
DPH can output to any component, not just to X.  This allows fpalu.c
to run without hitting the assertion in emit_dph.

src/mesa/drivers/dri/i965/brw_wm_emit.c

index b3cf524..5f29ca1 100644 (file)
@@ -588,17 +588,19 @@ static void emit_dph( struct brw_compile *p,
                      const struct brw_reg *arg0,
                      const struct brw_reg *arg1 )
 {
+   const int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
+
    if (!(mask & WRITEMASK_XYZW))
       return; /* Do not emit dead code */
 
-   assert((mask & WRITEMASK_XYZW) == WRITEMASK_X);
+   assert(is_power_of_two(mask & WRITEMASK_XYZW));
 
    brw_MUL(p, brw_null_reg(), arg0[0], arg1[0]);
    brw_MAC(p, brw_null_reg(), arg0[1], arg1[1]);
-   brw_MAC(p, dst[0], arg0[2], arg1[2]);
+   brw_MAC(p, dst[dst_chan], arg0[2], arg1[2]);
 
    brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
-   brw_ADD(p, dst[0], dst[0], arg1[3]);
+   brw_ADD(p, dst[dst_chan], dst[dst_chan], arg1[3]);
    brw_set_saturate(p, 0);
 }