summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2014-07-16 09:08:48 -0700
committerEric Anholt <[email protected]>2014-08-08 18:59:47 -0700
commit6ff2129d5842898eb87d2a457ee018fe66471f06 (patch)
tree0fedcae3e82d9623aa5c9ddf12ac0158e7d62fdd /src/gallium/drivers/vc4
parent63e49da0a58d6579162f12b4c8e68696eeb6c833 (diff)
vc4: Add support for the lit opcode.
v2: Fix how it was using the X channel for the real work of the opcode, instead of Y. Fixes glean's LIT test. v3: Rebase on the helpers.
Diffstat (limited to 'src/gallium/drivers/vc4')
-rw-r--r--src/gallium/drivers/vc4/vc4_program.c38
-rw-r--r--src/gallium/drivers/vc4/vc4_qir.h8
2 files changed, 45 insertions, 1 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 005b986829a..1cf518dceb2 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -225,6 +225,42 @@ tgsi_to_qir_mad(struct tgsi_to_qir *trans,
}
static struct qreg
+tgsi_to_qir_lit(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 x = src[0 * 4 + 0];
+ struct qreg y = src[0 * 4 + 1];
+ struct qreg w = src[0 * 4 + 3];
+
+ switch (i) {
+ case 0:
+ case 3:
+ return qir_uniform_f(trans, 1.0);
+ case 1:
+ return qir_FMAX(c, src[0 * 4 + 0], qir_uniform_f(trans, 0.0));
+ case 2: {
+ struct qreg zero = qir_uniform_f(trans, 0.0);
+
+ /* XXX: Clamp w to -128..128 */
+ return qir_CMP(c,
+ x,
+ zero,
+ qir_EXP2(c, qir_FMUL(c,
+ w,
+ qir_LOG2(c,
+ qir_FMAX(c,
+ y,
+ zero)))));
+ }
+ default:
+ assert(!"not reached");
+ return c->undef;
+ }
+}
+
+static struct qreg
tgsi_to_qir_lrp(struct tgsi_to_qir *trans,
struct tgsi_full_instruction *tgsi_inst,
enum qop op, struct qreg *src, int i)
@@ -372,7 +408,7 @@ emit_tgsi_instruction(struct tgsi_to_qir *trans,
[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 */
+ [TGSI_OPCODE_LIT] = { 0, tgsi_to_qir_lit },
[TGSI_OPCODE_LRP] = { 0, tgsi_to_qir_lrp },
[TGSI_OPCODE_POW] = { 0, tgsi_to_qir_pow },
};
diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h
index 5332478039a..ff222e4aeff 100644
--- a/src/gallium/drivers/vc4/vc4_qir.h
+++ b/src/gallium/drivers/vc4/vc4_qir.h
@@ -198,4 +198,12 @@ qir_VPM_WRITE(struct qcompile *c, struct qreg a)
qir_emit(c, qir_inst(QOP_VPM_WRITE, c->undef, a, c->undef));
}
+static inline struct qreg
+qir_CMP(struct qcompile *c, struct qreg cmp, struct qreg a, struct qreg b)
+{
+ struct qreg t = qir_get_temp(c);
+ qir_emit(c, qir_inst4(QOP_CMP, t, cmp, a, b, c->undef));
+ return t;
+}
+
#endif /* VC4_QIR_H */