panfrost: Explictly filter out AFBC(SNORM)

We are about to allow any type that is not FLOAT on v9+ at the
pan_afbc_format() level, but this regresses
dEQP-GLES31.functional.copy_image.non_compressed.viewclass_16_bits.*_snorm*
tests because of the clamping that's done on values that fall outside
the [-2^(b-1)+1, 2^(b-1)-1] range (b being the number of bits in the
SNORM component).

In order to fix that, we would have to use a _UNORM type when copying,
but:

1. There are many places where internal copies can happen and it's hard
   to identify all of them
2. If we do it at the panfrost_blit_no_afbc_legalization() level, we
   might do format re-interpretation that's not wanted by the gallium
   layer

Given AFBC(SNORM) has not been supported so far, let's just go for the
simple solution and filter it out explicitly in panfrost_should_afbc().

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Christoph Pillmayer <christoph.pillmayer@arm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37158>
This commit is contained in:
Boris Brezillon 2025-09-10 18:30:11 +02:00 committed by Marge Bot
parent 8c208bc41e
commit 62dcc4c01b

View file

@ -617,6 +617,21 @@ panfrost_should_afbc(struct panfrost_device *dev,
if (!pan_afbc_supports_format(dev->arch, fmt))
return false;
/* According to the GL spec, -2^(b-1) and -2^(b-1)+1 both map to -1 in the
* SNORM representation. The Mali implementation seems to clamp the value
* to the [-2^(b-1)+1, 2^(b-1)-1] range, which is problematic in our
* staging_resource (LINEAR) -> final_resource (AFBC) transfer path, because
* we need a bit-exact copy (typically fails tests like
* dEQP-GLES31.functional.copy_image.non_compressed.viewclass_16_bits.rg8_snorm_r16ui.texture2d_to_renderbuffer
* if we don't).
* FIXME: We could get away with src/dst view format adjustments
* (SNORM->UNORM) in our blits, but we'd have to clearly identify which
* copies/blits we want to act like that and which ones we don't, and this is
* far from obvious when looking at the code, so let's filter out AFBC(SNORM)
* for now. */
if (util_format_is_snorm(fmt))
return false;
/* AFBC does not support layered (GLES3 style) multisampling. Use
* EXT_multisampled_render_to_texture instead */
if (pres->base.nr_samples > 1)