diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 320f8ac4bae..e5442ce49cf 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -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; diff --git a/src/panfrost/lib/pan_texture.c b/src/panfrost/lib/pan_texture.c index 8b441b814df..f3ed3d0d43a 100644 --- a/src/panfrost/lib/pan_texture.c +++ b/src/panfrost/lib/pan_texture.c @@ -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 diff --git a/src/panfrost/vulkan/panvk_vX_sampler.c b/src/panfrost/vulkan/panvk_vX_sampler.c index 873ba41c229..34f6f9ec3ff 100644 --- a/src/panfrost/vulkan/panvk_vX_sampler.c +++ b/src/panfrost/vulkan/panvk_vX_sampler.c @@ -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);