diff options
author | Rob Clark <[email protected]> | 2016-06-27 09:44:15 -0400 |
---|---|---|
committer | Rob Clark <[email protected]> | 2016-07-30 09:23:42 -0400 |
commit | 9f219c7047b51561f6f69274d445e6a6ec41c5f8 (patch) | |
tree | 9222818fd1f2d961640e0ae1752659ee58926268 /src/gallium/drivers/freedreno/freedreno_context.c | |
parent | f02a64dbdd2ec147167ad60357bd46d8d964290a (diff) |
freedreno: add batch-cache and batch reordering
Note that I originally also had a entry-point that would construct a key
and do lookup from a pipe_surface. I ended up not needing that (yet?)
but it is easy-enough to re-introduce later if we need it for the blit
path.
For now, not enabled by default, but can be enabled (on a3xx/a4xx) with
FD_MESA_DEBUG=reorder.
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/freedreno_context.c')
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_context.c | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index b9a1fe97745..e81d31175f0 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -38,39 +38,27 @@ #include "freedreno_query_hw.h" #include "freedreno_util.h" -/* emit accumulated render cmds, needed for example if render target has - * changed, or for flush() - */ -void -fd_context_render(struct pipe_context *pctx) -{ - struct fd_context *ctx = fd_context(pctx); - struct fd_batch *new_batch; - - fd_batch_flush(ctx->batch); - - new_batch = fd_batch_create(ctx); - util_copy_framebuffer_state(&new_batch->framebuffer, &ctx->batch->framebuffer); - fd_batch_reference(&ctx->batch, NULL); - ctx->batch = new_batch; -} - static void fd_context_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence, unsigned flags) { - struct fd_batch *batch = NULL; - - fd_batch_reference(&batch, fd_context(pctx)->batch); - - fd_context_render(pctx); + struct fd_context *ctx = fd_context(pctx); + uint32_t timestamp; + + if (!ctx->screen->reorder) { + struct fd_batch *batch = NULL; + fd_batch_reference(&batch, ctx->batch); + fd_batch_flush(batch); + timestamp = fd_ringbuffer_timestamp(batch->gmem); + fd_batch_reference(&batch, NULL); + } else { + timestamp = fd_bc_flush(&ctx->screen->batch_cache, ctx); + } if (fence) { fd_screen_fence_ref(pctx->screen, fence, NULL); - *fence = fd_fence_create(pctx, fd_ringbuffer_timestamp(batch->gmem)); + *fence = fd_fence_create(pctx, timestamp); } - - fd_batch_reference(&batch, NULL); } /** @@ -81,9 +69,14 @@ static void fd_emit_string_marker(struct pipe_context *pctx, const char *string, int len) { struct fd_context *ctx = fd_context(pctx); - struct fd_ringbuffer *ring = ctx->batch->draw; + struct fd_ringbuffer *ring; const uint32_t *buf = (const void *)string; + if (!ctx->batch) + return; + + ring = ctx->batch->draw; + /* max packet size is 0x3fff dwords: */ len = MIN2(len, 0x3fff * 4); @@ -110,6 +103,9 @@ fd_context_destroy(struct pipe_context *pctx) DBG(""); + fd_batch_reference(&ctx->batch, NULL); /* unref current batch */ + fd_bc_invalidate_context(ctx); + fd_prog_fini(pctx); fd_hw_query_fini(pctx); @@ -121,8 +117,6 @@ fd_context_destroy(struct pipe_context *pctx) util_slab_destroy(&ctx->transfer_pool); - fd_batch_reference(&ctx->batch, NULL); /* unref current batch */ - for (i = 0; i < ARRAY_SIZE(ctx->pipe); i++) { struct fd_vsc_pipe *pipe = &ctx->pipe[i]; if (!pipe->bo) @@ -177,7 +171,12 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen, pctx->emit_string_marker = fd_emit_string_marker; pctx->set_debug_callback = fd_set_debug_callback; - ctx->batch = fd_batch_create(ctx); + /* TODO what about compute? Ideally it creates it's own independent + * batches per compute job (since it isn't using tiling, so no point + * in getting involved with the re-ordering madness).. + */ + if (!screen->reorder) + ctx->batch = fd_bc_alloc_batch(&screen->batch_cache, ctx); fd_reset_wfi(ctx); |