From 88161ced8d092e6e654d3c45466f132b0142f0fd Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 22 Jun 2021 15:10:12 -0700 Subject: [PATCH] freedreno: Swap needs_ubwc_clear when shadowing. The destination of the upcoming blit (the old rsc struct that houses the fresh BO) wouldn't have its ubwc cleared first, which if it got unfortunate data in a recycled BO could lead to blit failures. Part-of: --- src/gallium/drivers/freedreno/freedreno_resource.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 95c51956254..1bfded8a2ff 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -443,6 +443,12 @@ fd_try_shadow_resource(struct fd_context *ctx, struct fd_resource *rsc, swap(rsc->bo, shadow->bo); swap(rsc->valid, shadow->valid); + + /* swap() doesn't work because you can't typeof() the bitfield. */ + bool temp = shadow->needs_ubwc_clear; + shadow->needs_ubwc_clear = rsc->needs_ubwc_clear; + rsc->needs_ubwc_clear = temp; + swap(rsc->layout, shadow->layout); rsc->seqno = p_atomic_inc_return(&ctx->screen->rsc_seqno);