From: Kristian H. Kristensen Date: Wed, 23 Oct 2019 03:05:47 +0000 (-0700) Subject: freedreno/a6xx: Allocate and program tessellation buffer X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5dd51d2da75fdbabaa9cef1c9b4bf976117691b5;p=mesa.git freedreno/a6xx: Allocate and program tessellation buffer 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 Acked-by: Eric Anholt Reviewed-by: Rob Clark --- diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c b/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c index 708347931ac..470e972f9e5 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c @@ -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); diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c index 737a87a8dc6..f0dd8148229 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.c +++ b/src/gallium/drivers/freedreno/freedreno_batch.c @@ -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); diff --git a/src/gallium/drivers/freedreno/freedreno_batch.h b/src/gallium/drivers/freedreno/freedreno_batch.h index ecee0a87878..5061186f1b5 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.h +++ b/src/gallium/drivers/freedreno/freedreno_batch.h @@ -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);