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 <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11371>
This commit is contained in:
Rob Clark 2021-06-14 15:18:25 -07:00 committed by Marge Bot
parent de91d07927
commit c64f217495
1 changed files with 12 additions and 1 deletions

View File

@ -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);