Mesa (main): freedreno: Flush batches on shadow/uncompress
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jun 15 19:26:49 UTC 2021
Module: Mesa
Branch: main
Commit: c64f217495d5da5a4f79548150b79511361d5759
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c64f217495d5da5a4f79548150b79511361d5759
Author: Rob Clark <robdclark at chromium.org>
Date: Mon Jun 14 15:18:25 2021 -0700
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 at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11371>
---
src/gallium/drivers/freedreno/freedreno_resource.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index 54c520f1b1a..74b0b10cf5b 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);
More information about the mesa-commit
mailing list