r300-gallium: vs: Dot products.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 15 Apr 2009 20:23:25 +0000 (13:23 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 15 Apr 2009 22:10:23 +0000 (15:10 -0700)
src/gallium/drivers/r300/r300_state_tcl.c
src/gallium/drivers/r300/r300_state_tcl.h

index 47d6c6dfcdf364a3183c6778f217b1fb7a87e994..fc865a2b6371a0ed7270d2f72b16b2906ad6373f 100644 (file)
@@ -117,6 +117,9 @@ static INLINE unsigned r300_vs_dst(struct r300_vs_asm* assembler,
 static uint32_t r300_vs_op(unsigned op)
 {
     switch (op) {
+        case TGSI_OPCODE_DP3:
+        case TGSI_OPCODE_DP4:
+            return R300_VE_DOT_PRODUCT;
         case TGSI_OPCODE_MUL:
             return R300_VE_MULTIPLY;
         case TGSI_OPCODE_ADD:
@@ -195,6 +198,36 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs,
                     &inst->FullDstRegisters[0], inst->Instruction.Opcode,
                     2);
             break;
+        case TGSI_OPCODE_DP3:
+            /* Set alpha swizzle to zero for src0 and src1 */
+            if (!inst->FullSrcRegisters[0].SrcRegister.Extended) {
+                inst->FullSrcRegisters[0].SrcRegister.Extended = TRUE;
+                inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleX =
+                    inst->FullSrcRegisters[0].SrcRegister.SwizzleX;
+                inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleY =
+                    inst->FullSrcRegisters[0].SrcRegister.SwizzleY;
+                inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleZ =
+                    inst->FullSrcRegisters[0].SrcRegister.SwizzleZ;
+            }
+            inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleW =
+                TGSI_EXTSWIZZLE_ZERO;
+            if (!inst->FullSrcRegisters[1].SrcRegister.Extended) {
+                inst->FullSrcRegisters[1].SrcRegister.Extended = TRUE;
+                inst->FullSrcRegisters[1].SrcRegisterExtSwz.ExtSwizzleX =
+                    inst->FullSrcRegisters[1].SrcRegister.SwizzleX;
+                inst->FullSrcRegisters[1].SrcRegisterExtSwz.ExtSwizzleY =
+                    inst->FullSrcRegisters[1].SrcRegister.SwizzleY;
+                inst->FullSrcRegisters[1].SrcRegisterExtSwz.ExtSwizzleZ =
+                    inst->FullSrcRegisters[1].SrcRegister.SwizzleZ;
+            }
+            inst->FullSrcRegisters[1].SrcRegisterExtSwz.ExtSwizzleW =
+                TGSI_EXTSWIZZLE_ZERO;
+            /* Fall through */
+        case TGSI_OPCODE_DP4:
+            r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters,
+                    &inst->FullDstRegisters[0], inst->Instruction.Opcode,
+                    2);
+            break;
         case TGSI_OPCODE_MOV:
         case TGSI_OPCODE_SWZ:
             inst->FullSrcRegisters[1] = r300_constant_zero;
index 3d10e248e15a055a4b0645c59db5c3aff875ff95..de944028baa6cdac6105041f7e25e972a6a2b21b 100644 (file)
@@ -32,6 +32,7 @@
 
 /* XXX get these to r300_reg */
 #define R300_PVS_DST_OPCODE(x)   ((x) << 0)
+#   define R300_VE_DOT_PRODUCT            1
 #   define R300_VE_MULTIPLY               2
 #   define R300_VE_ADD                    3
 #define R300_PVS_DST_MACRO_INST    (1 << 7)