etnaviv: properly reference flush_resources

The flush_resources recorded in the context need to stay alive until
the context is flushed, at which point additional resolve operations
are done to those resources. While the backing BO is alive due to being
referenced in the cmdstream, the resource might already be destroyed
at this point.

Keep a reference to the resource to make sure it is still available at
context flush time.

Fixes: 7b9d8d1936 ("etnaviv: flush used render buffers on context flush when neccessary")
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19280>
This commit is contained in:
Lucas Stach
2022-10-24 18:40:50 +02:00
committed by Marge Bot
parent 20b9eece6e
commit 16e0702ec7
2 changed files with 9 additions and 2 deletions

View File

@@ -518,6 +518,7 @@ etna_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence,
struct pipe_resource *prsc = (struct pipe_resource *)entry->key;
pctx->flush_resource(pctx, prsc);
pipe_resource_reference(&prsc, NULL);
}
_mesa_set_clear(ctx->flush_resources, NULL);

View File

@@ -793,8 +793,14 @@ etna_record_flush_resources(struct etna_context *ctx)
if (fb->nr_cbufs > 0) {
struct etna_surface *surf = etna_surface(fb->cbufs[0]);
if (!etna_resource(surf->prsc)->explicit_flush)
_mesa_set_add(ctx->flush_resources, surf->prsc);
if (!etna_resource(surf->prsc)->explicit_flush) {
bool found;
_mesa_set_search_or_add(ctx->flush_resources, surf->prsc, &found);
if (!found)
pipe_reference(NULL, &surf->prsc->reference);
}
}
return true;