panfrost: Legalize before updating part of a AFBC-packed texture

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 <lfrb@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Fixes: 33b48a5585 ("panfrost: Add debug flag to force packing of AFBC textures on upload")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27208>
This commit is contained in:
Louis-Francis Ratté-Boulianne 2024-01-24 01:18:56 -05:00 committed by Marge Bot
parent ee77168d57
commit 1aa832e5f5

View file

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