From: Rob Clark Date: Mon, 14 Jun 2021 22:18:25 +0000 (-0700) Subject: freedreno: Flush batches on shadow/uncompress X-Git-Tag: upstream/21.2.3~1888 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c64f217495d5da5a4f79548150b79511361d5759;p=platform%2Fupstream%2Fmesa.git freedreno: Flush batches on shadow/uncompress Normally when we shadow a resource (whether it is changing the modifier or not) we do not need to flush existing batches, since they reference the original version of the resource. There is a special case for resources that are referenced by a batches framebuffer state, because this state is emitted when the batch is flushed. Because of this, we need those batches to be flushed before we shadow the resource. Signed-off-by: Rob Clark Part-of: --- diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 54c520f..74b0b10 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -357,11 +357,23 @@ fd_try_shadow_resource(struct fd_context *ctx, struct fd_resource *rsc, { struct pipe_context *pctx = &ctx->base; struct pipe_resource *prsc = &rsc->b.b; + struct fd_screen *screen = fd_screen(pctx->screen); + struct fd_batch *batch; bool fallback = false; if (prsc->next) return false; + /* Because IB1 ("gmem") cmdstream is built only when we flush the + * batch, we need to flush any batches that reference this rsc as + * a render target. Otherwise the framebuffer state emitted in + * IB1 will reference the resources new state, and not the state + * at the point in time that the earlier draws referenced it. + */ + foreach_batch (batch, &screen->batch_cache, rsc->track->bc_batch_mask) { + fd_batch_flush(batch); + } + /* If you have a sequence where there is a single rsc associated * with the current render target, and then you end up shadowing * that same rsc on the 3d pipe (u_blitter), because of how we @@ -435,7 +447,6 @@ fd_try_shadow_resource(struct fd_context *ctx, struct fd_resource *rsc, * transfer those references over: */ debug_assert(shadow->track->batch_mask == 0); - struct fd_batch *batch; foreach_batch (batch, &ctx->screen->batch_cache, rsc->track->batch_mask) { struct set_entry *entry = _mesa_set_search(batch->resources, rsc); _mesa_set_remove(batch->resources, entry);