freedreno/a6xx: Allocate and program tessellation buffer
authorKristian H. Kristensen <hoegsberg@google.com>
Wed, 23 Oct 2019 03:05:47 +0000 (20:05 -0700)
committerKristian H. Kristensen <hoegsberg@google.com>
Fri, 8 Nov 2019 00:40:27 +0000 (16:40 -0800)
Tessellation needs a couple of buffers that should hold the entire
output from a full VS+TCS draw call.

Signed-off-by: Kristian H. Kristensen <hoegsberg@google.com>
Acked-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/a6xx/fd6_gmem.c
src/gallium/drivers/freedreno/freedreno_batch.c
src/gallium/drivers/freedreno/freedreno_batch.h

index 708347931ac967d20e5f39e4d17715c45c0c99e1..470e972f9e5fa40ad46e20a2784c868533c88c80 100644 (file)
@@ -650,6 +650,8 @@ emit_binning_pass(struct fd_batch *batch)
        uint32_t x2 = gmem->minx + gmem->width - 1;
        uint32_t y2 = gmem->miny + gmem->height - 1;
 
+       debug_assert(!batch->tessellation);
+
        set_scissor(ring, x1, y1, x2, y2);
 
        emit_marker6(ring, 7);
@@ -1498,6 +1500,27 @@ emit_sysmem_clears(struct fd_batch *batch, struct fd_ringbuffer *ring)
        fd6_event_write(batch, ring, 0x1d, true);
 }
 
+static void
+setup_tess_buffers(struct fd_batch *batch, struct fd_ringbuffer *ring)
+{
+       struct fd_context *ctx = batch->ctx;
+
+       batch->tessfactor_bo = fd_bo_new(ctx->screen->dev,
+                       batch->tessfactor_size,
+                       DRM_FREEDRENO_GEM_TYPE_KMEM, "tessfactor");
+
+       batch->tessparam_bo = fd_bo_new(ctx->screen->dev,
+                       batch->tessparam_size,
+                       DRM_FREEDRENO_GEM_TYPE_KMEM, "tessparam");
+
+       OUT_PKT4(ring, REG_A6XX_PC_TESSFACTOR_ADDR_LO, 2);
+       OUT_RELOCW(ring, batch->tessfactor_bo, 0, 0, 0);
+
+       batch->tess_addrs_constobj->cur = batch->tess_addrs_constobj->start;
+       OUT_RELOCW(batch->tess_addrs_constobj, batch->tessparam_bo, 0, 0, 0);
+       OUT_RELOCW(batch->tess_addrs_constobj, batch->tessfactor_bo, 0, 0, 0);
+}
+
 static void
 fd6_emit_sysmem_prep(struct fd_batch *batch)
 {
@@ -1521,6 +1544,9 @@ fd6_emit_sysmem_prep(struct fd_batch *batch)
        OUT_RING(ring, A6XX_CP_SET_MARKER_0_MODE(RM6_BYPASS) | 0x10); /* | 0x10 ? */
        emit_marker6(ring, 7);
 
+       if (batch->tessellation)
+               setup_tess_buffers(batch, ring);
+
        OUT_PKT7(ring, CP_SKIP_IB2_ENABLE_GLOBAL, 1);
        OUT_RING(ring, 0x0);
 
index 737a87a8dc61ef68bec6b9641da7dd9579fdc697..f0dd8148229fa8bd370ee70849edb762dad83646 100644 (file)
@@ -166,6 +166,12 @@ batch_fini(struct fd_batch *batch)
                batch->tile_fini = NULL;
        }
 
+       if (batch->tessellation) {
+               fd_bo_del(batch->tessfactor_bo);
+               fd_bo_del(batch->tessparam_bo);
+               fd_ringbuffer_del(batch->tess_addrs_constobj);
+       }
+
        fd_submit_del(batch->submit);
 
        util_dynarray_fini(&batch->draw_patches);
index ecee0a8787819b8cc12b2fc3b32cf9b43e01767a..5061186f1b5842415f6dcb5db30c56ba162f6dc6 100644 (file)
@@ -224,6 +224,18 @@ struct fd_batch {
 
        /** set of dependent batches.. holds refs to dependent batches: */
        uint32_t dependents_mask;
+
+       /* Buffer for tessellation engine input
+        */
+       struct fd_bo *tessfactor_bo;
+       uint32_t tessfactor_size;
+
+       /* Buffer for passing parameters between TCS and TES
+        */
+       struct fd_bo *tessparam_bo;
+       uint32_t tessparam_size;
+
+       struct fd_ringbuffer *tess_addrs_constobj;
 };
 
 struct fd_batch * fd_batch_create(struct fd_context *ctx, bool nondraw);