From c44163876a2858aea219a08bd2e048b76953cff9 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Thu, 14 Jul 2016 10:32:02 -0400 Subject: freedreno: track batch/blit types Add a bit of extra book-keeping about blits and back-blits (from resource shadowing). If the app uploads all mipmap levels, as opposed to uploading the first level and then glGenerateMipmap(), we can discard the back-blit (as opposed to being naive and shadowing the resource for each mipmap level). Also, after a normal blit, we might as well flush the batch immediately, since there is not likely to be further rendering to the surface. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_state.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/gallium/drivers/freedreno/freedreno_state.c') diff --git a/src/gallium/drivers/freedreno/freedreno_state.c b/src/gallium/drivers/freedreno/freedreno_state.c index 849ea08037d..f83fd219f0a 100644 --- a/src/gallium/drivers/freedreno/freedreno_state.c +++ b/src/gallium/drivers/freedreno/freedreno_state.c @@ -119,13 +119,28 @@ fd_set_framebuffer_state(struct pipe_context *pctx, struct pipe_framebuffer_state *cso; if (ctx->screen->reorder) { - struct fd_batch *batch; - if (likely(ctx->batch)) - fd_hw_query_set_stage(ctx->batch, ctx->batch->draw, FD_STAGE_NULL); + struct fd_batch *batch, *old_batch = NULL; + + fd_batch_reference(&old_batch, ctx->batch); + + if (likely(old_batch)) + fd_hw_query_set_stage(old_batch, old_batch->draw, FD_STAGE_NULL); + batch = fd_batch_from_fb(&ctx->screen->batch_cache, ctx, framebuffer); fd_batch_reference(&ctx->batch, NULL); ctx->batch = batch; ctx->dirty = ~0; + + if (old_batch && old_batch->blit && !old_batch->back_blit) { + /* for blits, there is not really much point in hanging on + * to the uncommitted batch (ie. you probably don't blit + * multiple times to the same surface), so we might as + * well go ahead and flush this one: + */ + fd_batch_flush(old_batch); + } + + fd_batch_reference(&old_batch, NULL); } else { DBG("%d: cbufs[0]=%p, zsbuf=%p", ctx->batch->needs_flush, framebuffer->cbufs[0], framebuffer->zsbuf); -- cgit v1.2.3