freedreno: clear last_fence after resource tracking

The resource tracking in the clear/draw_vbo/blit paths could itself
trigger a flush.  Which would update last_fence.  So we need to clear
last_fence *after* all the dependency tracking.

Fixes: ddb7fadaf8 ("freedreno: avoid no-op flushes by re-using last-fence")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2992
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5188>
(cherry picked from commit 8728c42031)
This commit is contained in:
Rob Clark 2020-05-23 10:52:52 -07:00 committed by Eric Engestrom
parent f2dd854bfe
commit 9b3aa87227
3 changed files with 19 additions and 7 deletions

View file

@ -436,7 +436,7 @@
"description": "freedreno: clear last_fence after resource tracking",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": "ddb7fadaf8b1aa3004e72d6b0e28e465f8f45fba"
},

View file

@ -631,8 +631,6 @@ handle_rgba_blit(struct fd_context *ctx, const struct pipe_blit_info *info)
if (!can_do_blit(info))
return false;
fd_fence_ref(&ctx->last_fence, NULL);
batch = fd_bc_alloc_batch(&ctx->screen->batch_cache, ctx, true);
fd6_emit_restore(batch, batch->draw);
@ -645,6 +643,12 @@ handle_rgba_blit(struct fd_context *ctx, const struct pipe_blit_info *info)
mtx_unlock(&ctx->screen->lock);
/* Clearing last_fence must come after the batch dependency tracking
* (resource_read()/resource_write()), as that can trigger a flush,
* re-populating last_fence
*/
fd_fence_ref(&ctx->last_fence, NULL);
fd_batch_set_stage(batch, FD_STAGE_BLIT);
fd_log_stream(batch, stream, util_dump_blit_info(stream, info));

View file

@ -93,8 +93,6 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
return;
}
fd_fence_ref(&ctx->last_fence, NULL);
/* Upload a user index buffer. */
struct pipe_resource *indexbuf = NULL;
unsigned index_offset = 0;
@ -285,6 +283,12 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
/* and any buffers used, need to be resolved: */
batch->resolve |= buffers;
/* Clearing last_fence must come after the batch dependency tracking
* (resource_read()/resource_written()), as that can trigger a flush,
* re-populating last_fence
*/
fd_fence_ref(&ctx->last_fence, NULL);
DBG("%p: %x %ux%u num_draws=%u (%s/%s)", batch, buffers,
pfb->width, pfb->height, batch->num_draws,
util_format_short_name(pipe_surface_format(pfb->cbufs[0])),
@ -321,8 +325,6 @@ fd_clear(struct pipe_context *pctx, unsigned buffers, const struct pipe_scissor_
if (!fd_render_condition_check(pctx))
return;
fd_fence_ref(&ctx->last_fence, NULL);
if (ctx->in_discard_blit) {
fd_batch_reset(batch);
fd_context_all_dirty(ctx);
@ -369,6 +371,12 @@ fd_clear(struct pipe_context *pctx, unsigned buffers, const struct pipe_scissor_
mtx_unlock(&ctx->screen->lock);
/* Clearing last_fence must come after the batch dependency tracking
* (resource_read()/resource_written()), as that can trigger a flush,
* re-populating last_fence
*/
fd_fence_ref(&ctx->last_fence, NULL);
DBG("%p: %x %ux%u depth=%f, stencil=%u (%s/%s)", batch, buffers,
pfb->width, pfb->height, depth, stencil,
util_format_short_name(pipe_surface_format(pfb->cbufs[0])),