vc4: Use the same method as for FRAG_Z to handle fragcoord W.
authorEric Anholt <eric@anholt.net>
Fri, 19 Sep 2014 17:06:49 +0000 (10:06 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 19 Sep 2014 18:09:04 +0000 (11:09 -0700)
I need to get the non-reciprocal version of W for interpolation, anyway.

src/gallium/drivers/vc4/vc4_program.c
src/gallium/drivers/vc4/vc4_qir.c
src/gallium/drivers/vc4/vc4_qir.h
src/gallium/drivers/vc4/vc4_qpu_emit.c
src/gallium/drivers/vc4/vc4_register_allocate.c

index 1afb587754ba4d928f21bd6da3bbb16b7e023abf..a527f8b0e57c339b387047ce024e1da7de7831cb 100644 (file)
@@ -840,7 +840,7 @@ emit_fragcoord_input(struct vc4_compile *c, int attr)
                 qir_FMUL(c,
                          qir_ITOF(c, qir_FRAG_Z(c)),
                          qir_uniform_f(c, 1.0 / 0xffffff));
-        c->inputs[attr * 4 + 3] = qir_FRAG_RCP_W(c);
+        c->inputs[attr * 4 + 3] = qir_RCP(c, qir_FRAG_W(c));
 }
 
 static struct qreg
index 6196b92e2e0992c8b243e4a36766fa1e49a9dfde..b4d6812311bef8419be76d71860e8c209a0fd05b 100644 (file)
@@ -86,7 +86,7 @@ static const struct qir_op_info qir_op_info[] = {
         [QOP_FRAG_X] = { "frag_x", 1, 0 },
         [QOP_FRAG_Y] = { "frag_y", 1, 0 },
         [QOP_FRAG_Z] = { "frag_z", 1, 0 },
-        [QOP_FRAG_RCP_W] = { "frag_rcp_w", 1, 0 },
+        [QOP_FRAG_W] = { "frag_w", 1, 0 },
 
         [QOP_TEX_S] = { "tex_s", 0, 2 },
         [QOP_TEX_T] = { "tex_t", 0, 2 },
index 833795afcc5f8e611870f5c058cab59932a5c4ee..f3e5332edfcec75b6d833cf7053cce5a4be1f387 100644 (file)
@@ -106,7 +106,7 @@ enum qop {
         QOP_FRAG_X,
         QOP_FRAG_Y,
         QOP_FRAG_Z,
-        QOP_FRAG_RCP_W,
+        QOP_FRAG_W,
 
         /** Texture x coordinate parameter write */
         QOP_TEX_S,
@@ -363,7 +363,7 @@ QIR_NODST_2(TEX_B)
 QIR_ALU0(FRAG_X)
 QIR_ALU0(FRAG_Y)
 QIR_ALU0(FRAG_Z)
-QIR_ALU0(FRAG_RCP_W)
+QIR_ALU0(FRAG_W)
 QIR_ALU0(TEX_RESULT)
 QIR_ALU0(TLB_COLOR_READ)
 QIR_NODST_1(TLB_Z_WRITE)
index b8524e36e2031394169296e254d6726de80003c9..2fa131f134a62ee9622db825d55fcc4223ce47e4 100644 (file)
@@ -401,18 +401,12 @@ vc4_generate_code(struct vc4_compile *c)
                         break;
 
                 case QOP_FRAG_Z:
-                        /* QOP_FRAG_Z doesn't emit instructions, just
-                         * allocates the register to the Z payload.
+                case QOP_FRAG_W:
+                        /* QOP_FRAG_Z/W don't emit instructions, just allocate
+                         * the register to the Z/W payload.
                          */
                         break;
 
-                case QOP_FRAG_RCP_W:
-                        queue(c, qpu_a_MOV(qpu_rb(QPU_W_SFU_RECIP),
-                                           qpu_ra(QPU_R_FRAG_PAYLOAD_ZW)));
-
-                        queue(c, qpu_a_MOV(dst, qpu_r4()));
-                        break;
-
                 case QOP_TLB_DISCARD_SETUP:
                         discard = true;
                         queue(c, qpu_a_MOV(src[0], src[0]));
index 2ff130618cdb5468256c6acbd37b064de65f2e5d..3817e2bf084da2a27b83fdeba12e584fd4851eb2 100644 (file)
@@ -75,6 +75,8 @@ vc4_register_allocate(struct vc4_compile *c)
                 }
                 if (qinst->op == QOP_FRAG_Z)
                         reg_in_use[3 + 32 + QPU_R_FRAG_PAYLOAD_ZW] = true;
+                if (qinst->op == QOP_FRAG_W)
+                        reg_in_use[3 + QPU_R_FRAG_PAYLOAD_ZW] = true;
         }
 
         foreach(node, &c->instructions) {
@@ -130,6 +132,12 @@ vc4_register_allocate(struct vc4_compile *c)
                                                         continue;
                                                 }
                                                 break;
+                                        case QOP_FRAG_W:
+                                                if (reg.mux != QPU_MUX_A ||
+                                                    reg.addr != QPU_R_FRAG_PAYLOAD_ZW) {
+                                                        continue;
+                                                }
+                                                break;
                                         default:
                                                 if (reg.mux == QPU_MUX_R4)
                                                         continue;