panfrost: Re-emit texture descriptor if the data size has changed

When updating an AFBC-packed resource, the size of the resulting
texture data can change while the BO and modifier stay the same. We
still need to update the texture descriptor in that situation so
that the size is properly reported. Having a smaller size than the
real one might cause artifacts as the GPU doesn't want to read past
the reported size.

A future (more foolproof) fix might involve having a hash key to
track the size of all slices independently, but this patch still
improves the situation and make sure we don't hit a relatively
common issue when using `PAN_MESA_DEBUG=forcepack`.

Fixes: bc55d150a9 ("panfrost: Add support for AFBC packing")
Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32598>
This commit is contained in:
Louis-Francis Ratté-Boulianne
2024-12-11 12:09:42 -05:00
parent 8609f49d05
commit 30825140d0

View File

@@ -80,6 +80,7 @@ struct panfrost_sampler_view {
struct panfrost_pool_ref state;
struct mali_texture_packed bifrost_descriptor;
mali_ptr texture_bo;
uint64_t texture_size;
uint64_t modifier;
/* Pool used to allocate the descriptor. If NULL, defaults to the global
@@ -1614,6 +1615,7 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
}
so->texture_bo = prsrc->image.data.base;
so->texture_size = prsrc->image.layout.data_size;
so->modifier = prsrc->image.layout.modifier;
/* MSAA only supported for 2D textures */
@@ -1722,6 +1724,7 @@ panfrost_update_sampler_view(struct panfrost_sampler_view *view,
{
struct panfrost_resource *rsrc = pan_resource(view->base.texture);
if (view->texture_bo != rsrc->image.data.base ||
view->texture_size != rsrc->image.layout.data_size ||
view->modifier != rsrc->image.layout.modifier) {
panfrost_bo_unreference(view->state.bo);
panfrost_create_sampler_view_bo(view, pctx, &rsrc->base);