From 1aa832e5f5879e70a2c25c3517951ccddd36a599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Francis=20Ratt=C3=A9-Boulianne?= Date: Wed, 24 Jan 2024 01:18:56 -0500 Subject: [PATCH] panfrost: Legalize before updating part of a AFBC-packed texture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When updating an AFBC-packed resource, we need to make sure it is legalized before blitting the staging resource to it. We can't rely on the blit to properly convert the resource as it will result in blit recursion and a crash. If the whole texture is updated however, there is no need to unpack as the content can be discarded. Just create a new BO with the right format. Signed-off-by: Louis-Francis Ratté-Boulianne Reviewed-by: Erik Faye-Lund Fixes: 33b48a55857 ("panfrost: Add debug flag to force packing of AFBC textures on upload") Part-of: --- src/gallium/drivers/panfrost/pan_resource.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index cc6ebb4b929..bcdf0753f8b 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -1609,6 +1609,10 @@ panfrost_ptr_unmap(struct pipe_context *pctx, struct pipe_transfer *transfer) prsrc->image.data.base = prsrc->bo->ptr.gpu; panfrost_bo_reference(prsrc->bo); } else { + bool discard = panfrost_can_discard(&prsrc->base, &transfer->box, + transfer->usage); + pan_legalize_afbc_format(ctx, prsrc, prsrc->image.layout.format, + true, discard); pan_blit_from_staging(pctx, trans); panfrost_flush_batches_accessing_rsrc( ctx, pan_resource(trans->staging.rsrc),