diff options
author | Eric Anholt <[email protected]> | 2014-08-05 13:35:19 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-08-08 18:59:47 -0700 |
commit | f069367f3938741c07658f54390c16550e1b5a5c (patch) | |
tree | 6cbf2073a67fc1bcfc1f5b38cfdf55e66c9e85c0 /src/gallium | |
parent | bf542cd37286decbd9fc0c939007b82176e16a81 (diff) |
vc4: Add support for the TGSI FRC opcode.
v2: Rebase on helpers.
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 307eda02cbe..8c0b241d7ef 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -301,6 +301,23 @@ tgsi_to_qir_trunc(struct tgsi_to_qir *trans, return qir_ITOF(c, qir_FTOI(c, src[0 * 4 + i])); } +/** + * Computes x - floor(x), which is tricky because our FTOI truncates (rounds + * to zero). + */ +static struct qreg +tgsi_to_qir_frc(struct tgsi_to_qir *trans, + struct tgsi_full_instruction *tgsi_inst, + enum qop op, struct qreg *src, int i) +{ + struct qcompile *c = trans->c; + struct qreg trunc = qir_ITOF(c, qir_FTOI(c, src[0 * 4 + i])); + struct qreg diff = qir_FSUB(c, src[0 * 4 + i], trunc); + return qir_CMP(c, + diff, + qir_FADD(c, diff, qir_uniform_f(trans, 1.0)), + diff); +} static struct qreg tgsi_to_qir_dp(struct tgsi_to_qir *trans, @@ -424,6 +441,7 @@ emit_tgsi_instruction(struct tgsi_to_qir *trans, [TGSI_OPCODE_LRP] = { 0, tgsi_to_qir_lrp }, [TGSI_OPCODE_POW] = { 0, tgsi_to_qir_pow }, [TGSI_OPCODE_TRUNC] = { 0, tgsi_to_qir_trunc }, + [TGSI_OPCODE_FRC] = { 0, tgsi_to_qir_frc }, }; static int asdf = 0; uint32_t tgsi_op = tgsi_inst->Instruction.Opcode; |