vc4: Emit only one FRAG_Z or FRAG_W QIR opcode.
authorEric Anholt <eric@anholt.net>
Thu, 28 Apr 2016 01:49:59 +0000 (18:49 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 2 May 2016 18:06:29 +0000 (11:06 -0700)
We were generating piles of FRAG_W for interpolation, only to CSE them
away immediately.  Since this is the only thing that CSE is doing for us
any more, just avoid making the CSE work necessary.

src/gallium/drivers/vc4/vc4_qir.h

index 789918dee68117d0fae0f7bf4c5964d0e5c558d5..62624d4b1e2577fcb1f6b9b10125e59005ce04de 100644 (file)
@@ -374,6 +374,8 @@ struct vc4_compile {
 
         struct qreg line_x, point_x, point_y;
         struct qreg discard;
+        struct qreg payload_FRAG_Z;
+        struct qreg payload_FRAG_W;
 
         uint8_t vattr_sizes[8];
 
@@ -584,6 +586,21 @@ qir_##name(struct vc4_compile *c, struct qreg dest, struct qreg a)       \
         return dest;                                                     \
 }
 
+#define QIR_PAYLOAD(name)                                                \
+static inline struct qreg                                                \
+qir_##name(struct vc4_compile *c)                                        \
+{                                                                        \
+        struct qreg *payload = &c->payload_##name;                       \
+        if (payload->file != QFILE_NULL)                                 \
+                return *payload;                                         \
+        *payload = qir_get_temp(c);                                      \
+        struct qinst *inst = qir_inst(QOP_##name, *payload,              \
+                                      c->undef, c->undef);               \
+        list_add(&inst->link, &c->instructions);                         \
+        c->defs[payload->index] = inst;                                  \
+        return *payload;                                                 \
+}
+
 QIR_ALU1(MOV)
 QIR_ALU1(FMOV)
 QIR_ALU1(MMOV)
@@ -625,8 +642,8 @@ QIR_NODST_2(TEX_T)
 QIR_NODST_2(TEX_R)
 QIR_NODST_2(TEX_B)
 QIR_NODST_2(TEX_DIRECT)
-QIR_ALU0(FRAG_Z)
-QIR_ALU0(FRAG_W)
+QIR_PAYLOAD(FRAG_Z)
+QIR_PAYLOAD(FRAG_W)
 QIR_ALU0(TEX_RESULT)
 QIR_ALU0(TLB_COLOR_READ)
 QIR_NODST_1(MS_MASK)