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>
(cherry picked from commit 1aa832e5f5)
This commit is contained in:
Louis-Francis Ratté-Boulianne
2024-01-24 01:18:56 -05:00
committed by Eric Engestrom
parent 05ea7d854e
commit 28f92ab484
2 changed files with 5 additions and 1 deletions

View File

@@ -924,7 +924,7 @@
"description": "panfrost: Legalize before updating part of a AFBC-packed texture",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "33b48a55857b15f7e7b892a89cad2f0ad2399ba6",
"notes": null

View File

@@ -1588,6 +1588,10 @@ panfrost_ptr_unmap(struct pipe_context *pctx, struct pipe_transfer *transfer)
pan_resource(trans->staging.rsrc)->image.data.bo;
panfrost_bo_reference(prsrc->image.data.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),