freedreno/a6xx: Program VFD_DEST_CNTL from program stateobj
authorKristian H. Kristensen <hoegsberg@google.com>
Thu, 21 May 2020 08:26:02 +0000 (01:26 -0700)
committerMarge Bot <eric+marge@anholt.net>
Fri, 29 May 2020 18:59:56 +0000 (18:59 +0000)
This only depends on the generated shader.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5140>

src/gallium/drivers/freedreno/a6xx/fd6_emit.c
src/gallium/drivers/freedreno/a6xx/fd6_program.c

index 9f281893dcdd89a1c9dbefabc3e37638e9df51a3..cdc8dfb85bd2797b7ec27924e9f8a769a83b24b6 100644 (file)
@@ -556,19 +556,8 @@ build_vbo_state(struct fd6_emit *emit, const struct ir3_shader_variant *vp)
 {
        const struct fd_vertex_state *vtx = emit->vtx;
 
-       /* Determine which inputs need VFD state */
-       int32_t map[32];
-       int32_t cnt = 0;
-       for (int32_t i = 0; i <= vp->inputs_count; i++) {
-               if (vp->inputs[i].sysval)
-                       continue;
-               if (vp->inputs[i].compmask) {
-                       map[cnt++] = i;
-               }
-       }
-
        struct fd_ringbuffer *ring = fd_submit_new_ringbuffer(emit->ctx->batch->submit,
-                       4 * (5 + cnt * 3 + vtx->vertexbuf.count * 4), FD_RINGBUFFER_STREAMING);
+                       4 * (3 + vtx->vertexbuf.count * 4), FD_RINGBUFFER_STREAMING);
 
        OUT_PKT4(ring, REG_A6XX_VFD_CONTROL_0, 1);
        OUT_RING(ring, A6XX_VFD_CONTROL_0_FETCH_CNT(vtx->vertexbuf.count) |
@@ -593,13 +582,7 @@ build_vbo_state(struct fd6_emit *emit, const struct ir3_shader_variant *vp)
                }
        }
 
-       OUT_PKT4(ring, REG_A6XX_VFD_DEST_CNTL(0), cnt);
-       for (int32_t j = 0; j < cnt; j++) {
-               int32_t i = map[j];
-
-               OUT_RING(ring, A6XX_VFD_DEST_CNTL_INSTR_WRITEMASK(vp->inputs[i].compmask) |
-                               A6XX_VFD_DEST_CNTL_INSTR_REGID(vp->inputs[i].regid));
-       }
+       return ring;
 }
 
 static struct fd_ringbuffer *
index 24c8ab080e2f33de33c50df595078220b53f9245..98774a2cfe56de2ede7a507463b7ae109ceda3b8 100644 (file)
@@ -806,6 +806,18 @@ setup_stateobj(struct fd_ringbuffer *ring, struct fd_screen *screen,
        OUT_PKT4(ring, REG_A6XX_PC_PRIMID_CNTL, 1);
        OUT_RING(ring, COND(primid_passthru, A6XX_PC_PRIMID_CNTL_PRIMID_PASSTHRU));
 
+       uint32_t non_sysval_input_count = 0;
+       for (uint32_t i = 0; i < vs->inputs_count; i++)
+               if (!vs->inputs[i].sysval)
+                       non_sysval_input_count++;
+
+       OUT_PKT4(ring, REG_A6XX_VFD_DEST_CNTL(0), non_sysval_input_count);
+       for (uint32_t i = 0; i < non_sysval_input_count; i++) {
+               assert(vs->inputs[i].compmask);
+               OUT_RING(ring, A6XX_VFD_DEST_CNTL_INSTR_WRITEMASK(vs->inputs[i].compmask) |
+                               A6XX_VFD_DEST_CNTL_INSTR_REGID(vs->inputs[i].regid));
+       }
+
        OUT_PKT4(ring, REG_A6XX_VFD_CONTROL_1, 6);
        OUT_RING(ring, A6XX_VFD_CONTROL_1_REGID4VTX(vertex_regid) |
                        A6XX_VFD_CONTROL_1_REGID4INST(instance_regid) |