panfrost: Limit reswizzle to AFBC formats

The texture/sampler reswizzle is implemented to allow AFBC for non
canonical component order formats, but it's enabled regardless of
whether the format supports AFBC.

Limit the reswizzling to only apply to formats that support AFBC.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32515>
This commit is contained in:
Lars-Ivar Hesselberg Simonsen
2024-12-03 15:11:56 +01:00
parent afbcf675c5
commit d83e374150
3 changed files with 20 additions and 16 deletions
+16 -14
View File
@@ -192,22 +192,24 @@ panfrost_create_sampler_state(struct pipe_context *pctx,
so->base = *cso;
#if PAN_ARCH == 7
/* On v7, pan_texture.c composes the API swizzle with a bijective
* 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.
*/
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);
if (panfrost_format_supports_afbc(PAN_ARCH, cso->border_color_format)) {
/* On v7, pan_texture.c composes the API swizzle with a bijective
* 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.
*/
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);
unsigned char inverted_swizzle[4];
panfrost_invert_swizzle(GENX(pan_decompose_swizzle)(order).post,
inverted_swizzle);
unsigned char inverted_swizzle[4];
panfrost_invert_swizzle(GENX(pan_decompose_swizzle)(order).post,
inverted_swizzle);
util_format_apply_color_swizzle(&so->base.border_color, &cso->border_color,
inverted_swizzle,
false /* is_integer (irrelevant) */);
util_format_apply_color_swizzle(&so->base.border_color,
&cso->border_color, inverted_swizzle,
false /* is_integer (irrelevant) */);
}
#endif
bool using_nearest = cso->min_img_filter == PIPE_TEX_MIPFILTER_NEAREST;
+2 -1
View File
@@ -670,7 +670,8 @@ GENX(panfrost_new_texture)(const struct pan_image_view *iview, void *out,
};
util_format_compose_swizzles(replicate_x, iview->swizzle, swizzle);
} else if ((PAN_ARCH == 7) && !panfrost_format_is_yuv(iview->format)) {
} else if ((PAN_ARCH == 7) && !panfrost_format_is_yuv(iview->format) &&
panfrost_format_supports_afbc(PAN_ARCH, iview->format)) {
#if PAN_ARCH == 7
/* v7 (only) restricts component orders when AFBC is in use.
* Rather than restrict AFBC, we use an allowed component order
+2 -1
View File
@@ -63,7 +63,8 @@ swizzle_border_color(VkClearColorValue *border_color, VkFormat fmt)
return;
enum pipe_format pfmt = vk_format_to_pipe_format(fmt);
if (panfrost_format_is_yuv(pfmt) || util_format_is_depth_or_stencil(pfmt))
if (panfrost_format_is_yuv(pfmt) || util_format_is_depth_or_stencil(pfmt) ||
!panfrost_format_supports_afbc(PAN_ARCH, pfmt))
return;
const struct util_format_description *fdesc = util_format_description(pfmt);