summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2014-10-13 08:05:35 +0100
committerEric Anholt <[email protected]>2014-10-13 08:06:48 +0100
commit83365a5b57b6ab966329bceb858d41d6159d7f3d (patch)
tree8dfc6cd33066b50b480c8ffbc41ce33c51fb2693 /src/gallium/drivers
parent926eaa9af464f2448b3840bb401c0b2efe43bb40 (diff)
vc4: Add support for the CEIL opcode.
Not as big of a deal as SSG, but still +9 piglit tests.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/vc4/vc4_program.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 15da3ed3005..b7c51a7195b 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -722,6 +722,27 @@ tgsi_to_qir_flr(struct vc4_compile *c,
trunc);
}
+/**
+ * Computes ceil(x), which is tricky because our FTOI truncates (rounds to
+ * zero).
+ */
+static struct qreg
+tgsi_to_qir_ceil(struct vc4_compile *c,
+ struct tgsi_full_instruction *tgsi_inst,
+ enum qop op, struct qreg *src, int i)
+{
+ struct qreg trunc = qir_ITOF(c, qir_FTOI(c, src[0 * 4 + i]));
+
+ /* This will be < 0 if we truncated and the truncation was of a value
+ * that was > 0 in the first place.
+ */
+ qir_SF(c, qir_FSUB(c, trunc, src[0 * 4 + i]));
+
+ return qir_SEL_X_Y_NS(c,
+ qir_FADD(c, trunc, qir_uniform_f(c, 1.0)),
+ trunc);
+}
+
static struct qreg
tgsi_to_qir_abs(struct vc4_compile *c,
struct tgsi_full_instruction *tgsi_inst,
@@ -1083,6 +1104,7 @@ emit_tgsi_instruction(struct vc4_compile *c,
[TGSI_OPCODE_LG2] = { QOP_LOG2, tgsi_to_qir_scalar },
[TGSI_OPCODE_LRP] = { 0, tgsi_to_qir_lrp },
[TGSI_OPCODE_TRUNC] = { 0, tgsi_to_qir_trunc },
+ [TGSI_OPCODE_CEIL] = { 0, tgsi_to_qir_ceil },
[TGSI_OPCODE_FRC] = { 0, tgsi_to_qir_frc },
[TGSI_OPCODE_FLR] = { 0, tgsi_to_qir_flr },
[TGSI_OPCODE_SIN] = { 0, tgsi_to_qir_sin },