From 62dcc4c01bf591c76341aca324c949873139bb68 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 10 Sep 2025 18:30:11 +0200 Subject: [PATCH] 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 Reviewed-by: Christoph Pillmayer Part-of: --- src/gallium/drivers/panfrost/pan_resource.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 894c78d8155..1d406e4a341 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -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)