vc4: Add support for the POW opcode
authorEric Anholt <eric@anholt.net>
Wed, 16 Jul 2014 15:44:50 +0000 (08:44 -0700)
committerEric Anholt <eric@anholt.net>
Sat, 9 Aug 2014 01:59:47 +0000 (18:59 -0700)
v2: Rebase on helpers.

src/gallium/drivers/vc4/vc4_program.c

index c82e0cc17c22e2cb83a3271a9d42a359e4ec360e..005b986829afb1434d0dc6276ffb21b3134ea208 100644 (file)
@@ -243,6 +243,20 @@ tgsi_to_qir_lrp(struct tgsi_to_qir *trans,
 
 }
 
+static struct qreg
+tgsi_to_qir_pow(struct tgsi_to_qir *trans,
+                struct tgsi_full_instruction *tgsi_inst,
+                enum qop op, struct qreg *src, int i)
+{
+        struct qcompile *c = trans->c;
+
+        /* Note that this instruction replicates its result from the x channel
+         */
+        return qir_EXP2(c, qir_FMUL(c,
+                                    src[1 * 4 + 0],
+                                    qir_LOG2(c, src[0 * 4 + 0])));
+}
+
 static struct qreg
 tgsi_to_qir_dp(struct tgsi_to_qir *trans,
                struct tgsi_full_instruction *tgsi_inst,
@@ -360,6 +374,7 @@ emit_tgsi_instruction(struct tgsi_to_qir *trans,
                 [TGSI_OPCODE_LG2] = { QOP_LOG2, tgsi_to_qir_alu },
                 [TGSI_OPCODE_LIT] = { QOP_MOV, tgsi_to_qir_alu }, /* XXX */
                 [TGSI_OPCODE_LRP] = { 0, tgsi_to_qir_lrp },
+                [TGSI_OPCODE_POW] = { 0, tgsi_to_qir_pow },
         };
         static int asdf = 0;
         uint32_t tgsi_op = tgsi_inst->Instruction.Opcode;