freedreno/a6xx: move ZSA state to stateobj
authorRob Clark <robdclark@gmail.com>
Sat, 13 Oct 2018 17:04:16 +0000 (13:04 -0400)
committerRob Clark <robdclark@gmail.com>
Wed, 17 Oct 2018 16:44:48 +0000 (12:44 -0400)
Step towards single cmdstream, where we need different state-group-id's
for binning vs draw ZSA state.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/a6xx/fd6_emit.c
src/gallium/drivers/freedreno/a6xx/fd6_emit.h

index e5c568fd6b553049a2bcd93b6d08db12587ae1cf..353fa5c9f66c932eb79ffecbf0b2c39d486790ad 100644 (file)
@@ -583,6 +583,35 @@ fd6_emit_vertex_bufs(struct fd_ringbuffer *ring, struct fd6_emit *emit)
        OUT_RING(ring, A6XX_VFD_CONTROL_0_VTXCNT(j) | (j << 8));
 }
 
+static struct fd_ringbuffer *
+build_zsa(struct fd6_emit *emit, bool binning_pass)
+{
+       struct fd6_zsa_stateobj *zsa = fd6_zsa_stateobj(emit->ctx->zsa);
+       struct pipe_framebuffer_state *pfb = &emit->ctx->batch->framebuffer;
+       struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
+       uint32_t gras_lrz_cntl = zsa->gras_lrz_cntl;
+       uint32_t rb_lrz_cntl = zsa->rb_lrz_cntl;
+
+       struct fd_ringbuffer *ring =
+               fd_ringbuffer_new_flags(emit->ctx->pipe, 16,
+                               FD_RINGBUFFER_OBJECT | FD_RINGBUFFER_STREAMING);
+
+       if (emit->no_lrz_write || !rsc->lrz || !rsc->lrz_valid) {
+               gras_lrz_cntl = 0;
+               rb_lrz_cntl = 0;
+       } else if (binning_pass && zsa->lrz_write) {
+               gras_lrz_cntl |= A6XX_GRAS_LRZ_CNTL_LRZ_WRITE;
+       }
+
+       OUT_PKT4(ring, REG_A6XX_GRAS_LRZ_CNTL, 1);
+       OUT_RING(ring, gras_lrz_cntl);
+
+       OUT_PKT4(ring, REG_A6XX_RB_LRZ_CNTL, 1);
+       OUT_RING(ring, rb_lrz_cntl);
+
+       return ring;
+}
+
 void
 fd6_emit_state(struct fd_ringbuffer *ring, struct fd6_emit *emit)
 {
@@ -613,27 +642,16 @@ fd6_emit_state(struct fd_ringbuffer *ring, struct fd6_emit *emit)
                OUT_RING(ring, zsa->rb_depth_cntl);
        }
 
-       if (dirty & (FD_DIRTY_ZSA | FD_DIRTY_PROG)) {
-               struct fd6_zsa_stateobj *zsa = fd6_zsa_stateobj(ctx->zsa);
-
-               if (pfb->zsbuf) {
-                       struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
-                       uint32_t gras_lrz_cntl = zsa->gras_lrz_cntl;
-                       uint32_t rb_lrz_cntl = zsa->rb_lrz_cntl;
-
-                       if (emit->no_lrz_write || !rsc->lrz || !rsc->lrz_valid) {
-                               gras_lrz_cntl = 0;
-                               rb_lrz_cntl = 0;
-                       } else if (emit->binning_pass && zsa->lrz_write) {
-                               gras_lrz_cntl |= A6XX_GRAS_LRZ_CNTL_LRZ_WRITE;
-                       }
+       if ((dirty & (FD_DIRTY_ZSA | FD_DIRTY_PROG)) && pfb->zsbuf) {
+               struct fd_ringbuffer *state;
 
-                       OUT_PKT4(ring, REG_A6XX_GRAS_LRZ_CNTL, 1);
-                       OUT_RING(ring, gras_lrz_cntl);
+               state = build_zsa(emit, false);
+               fd6_emit_add_group(emit, state, FD6_GROUP_ZSA, 0x6);
+               fd_ringbuffer_del(state);
 
-                       OUT_PKT4(ring, REG_A6XX_RB_LRZ_CNTL, 1);
-                       OUT_RING(ring, rb_lrz_cntl);
-               }
+               state = build_zsa(emit, true);
+               fd6_emit_add_group(emit, state, FD6_GROUP_ZSA_BINNING, 0x1);
+               fd_ringbuffer_del(state);
        }
 
        if (dirty & (FD_DIRTY_ZSA | FD_DIRTY_STENCIL_REF)) {
index 8130b86a0b83d946fac9c492a8c918432df8f884..450cb5e87344bb8d91c46de0cc24c03c89e883d5 100644 (file)
@@ -44,6 +44,8 @@ struct fd_ringbuffer;
  */
 enum fd6_state_id {
        FD6_GROUP_PROG,
+       FD6_GROUP_ZSA,
+       FD6_GROUP_ZSA_BINNING,
        FD6_GROUP_VS_CONST,
        FD6_GROUP_FS_CONST,
        FD6_GROUP_VS_TEX,