From 3135f76331aee4f7bad50a7e1236f81e149cc746 Mon Sep 17 00:00:00 2001 From: "Eric R. Smith" Date: Tue, 6 Aug 2024 23:38:36 +0000 Subject: [PATCH] panfrost: fix texture.border_clamp regression for valhall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have to swizzle the border color in order to offset the automatic swizzling introduced to compensate for limited component order support in AFBC/AFRC. However, the border color format is only available if the `TEXTURE_BORDER_COLOR_QUIRK` is enabled, so set that for v10 (it was already set for v7). While testing, we uncovered another issue: valhall introduces a swizzle for depth+stencil formats that isn't present for bifrost, and also isn't needed (or wanted) for the border color. So ignore the border color swizzle for depth+stencil on valhall (on bifrost the swizzle is a no-op anyway). Fixes: 87aad0a5e4f ("panfrost: encode component order as an inverted swizzle (v10)") Reviewed-by: Louis-Francis Ratté-Boulianne Reviewed-by: Mary Guillemard Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 9 +++++++++ src/gallium/drivers/panfrost/pan_screen.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index c2602cdf85a..52bacb01b31 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -195,7 +195,12 @@ panfrost_create_sampler_state(struct pipe_context *pctx, * swizzle derived from the format, to allow more formats than the * hardware otherwise supports. When packing border colours, we need to * undo this bijection, by swizzling with its inverse. + * On v10+, watch out for depth+stencil formats, because those have a + * swizzle that doesn't really apply to the border color */ +#if PAN_ARCH >= 10 + if (!util_format_is_depth_and_stencil(cso->border_color_format)) { +#endif unsigned mali_format = GENX(panfrost_format_from_pipe_format)(cso->border_color_format)->hw; enum mali_rgb_component_order order = mali_format & BITFIELD_MASK(12); @@ -207,6 +212,10 @@ panfrost_create_sampler_state(struct pipe_context *pctx, util_format_apply_color_swizzle(&so->base.border_color, &cso->border_color, inverted_swizzle, false /* is_integer (irrelevant) */); +#if PAN_ARCH >= 10 + } +#endif + #endif bool using_nearest = cso->min_img_filter == PIPE_TEX_MIPFILTER_NEAREST; diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index 5cca2d69713..8717a422053 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -208,7 +208,7 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param) * handles this but we need to fix up the border colour. */ case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK: - if (dev->arch == 7) + if (dev->arch == 7 || dev->arch >= 10) return PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_FREEDRENO; else return 0;