diff options
author | Eric Anholt <[email protected]> | 2014-07-16 08:25:22 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-08-08 18:59:46 -0700 |
commit | db8712bcbc7875f1b7cff1cf5c6e08eed028f77f (patch) | |
tree | 199003b63e7b35631b8e5f70d4fdb293cf5214b2 | |
parent | 792d1c92df6f58f219eb8b77e668424cdcc9c9af (diff) |
vc4: Add initial support for math opcodes
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_qpu_emit.c | 38 |
2 files changed, 41 insertions, 1 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 8a937359472..2107ef73c1f 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -258,6 +258,10 @@ emit_tgsi_instruction(struct tgsi_to_qir *trans, [TGSI_OPCODE_DP2] = { 0, tgsi_to_qir_dp2 }, [TGSI_OPCODE_DP3] = { 0, tgsi_to_qir_dp3 }, [TGSI_OPCODE_DP4] = { 0, tgsi_to_qir_dp4 }, + [TGSI_OPCODE_RCP] = { QOP_RCP, tgsi_to_qir_alu }, + [TGSI_OPCODE_RSQ] = { QOP_RSQ, tgsi_to_qir_alu }, + [TGSI_OPCODE_EX2] = { QOP_EXP2, tgsi_to_qir_alu }, + [TGSI_OPCODE_LG2] = { QOP_LOG2, tgsi_to_qir_alu }, [TGSI_OPCODE_LIT] = { QOP_MOV, tgsi_to_qir_alu }, /* XXX */ }; static int asdf = 0; diff --git a/src/gallium/drivers/vc4/vc4_qpu_emit.c b/src/gallium/drivers/vc4/vc4_qpu_emit.c index 0f6f2c171a4..330876734d1 100644 --- a/src/gallium/drivers/vc4/vc4_qpu_emit.c +++ b/src/gallium/drivers/vc4/vc4_qpu_emit.c @@ -196,6 +196,43 @@ vc4_generate_code(struct qcompile *c) qpu_m_NOP()); break; + case QOP_RCP: + case QOP_RSQ: + case QOP_EXP2: + case QOP_LOG2: + switch (qinst->op) { + case QOP_RCP: + insts[ni++] = qpu_inst(qpu_a_MOV(qpu_rb(QPU_W_SFU_RECIP), + src[0]), + qpu_m_NOP()); + break; + case QOP_RSQ: + insts[ni++] = qpu_inst(qpu_a_MOV(qpu_rb(QPU_W_SFU_RECIPSQRT), + src[0]), + qpu_m_NOP()); + break; + case QOP_EXP2: + insts[ni++] = qpu_inst(qpu_a_MOV(qpu_rb(QPU_W_SFU_EXP), + src[0]), + qpu_m_NOP()); + break; + case QOP_LOG2: + insts[ni++] = qpu_inst(qpu_a_MOV(qpu_rb(QPU_W_SFU_LOG), + src[0]), + qpu_m_NOP()); + break; + default: + abort(); + } + + insts[ni++] = qpu_inst(qpu_a_NOP(), qpu_m_NOP()); + insts[ni++] = qpu_inst(qpu_a_NOP(), qpu_m_NOP()); + + insts[ni++] = qpu_inst(qpu_a_MOV(dst, qpu_r4()), + qpu_m_NOP()); + + break; + case QOP_PACK_COLORS: for (int i = 0; i < 4; i++) { insts[ni++] = qpu_inst(qpu_a_NOP(), @@ -207,7 +244,6 @@ vc4_generate_code(struct qcompile *c) insts[ni++] = qpu_inst(qpu_a_MOV(dst, qpu_r5()), qpu_m_NOP()); - break; case QOP_TLB_COLOR_WRITE: |