From 54509d27d9cf7f85db30111a3b74bbdd031f2d9b Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 29 Mar 2022 16:35:49 -0500 Subject: [PATCH] anv: Disallow blending on swizzled formats Fixes: c20f78dc5d7e ("anv: Support swizzled formats.") Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_formats.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c index 636e929508f..a8ba32bd9cb 100644 --- a/src/intel/vulkan/anv_formats.c +++ b/src/intel/vulkan/anv_formats.c @@ -627,7 +627,14 @@ anv_get_image_format_features2(const struct intel_device_info *devinfo, plane_format.swizzle.a == ISL_CHANNEL_SELECT_ALPHA) { flags |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT_KHR; - if (isl_format_supports_alpha_blending(devinfo, plane_format.isl_format)) + /* While we can render to swizzled formats, they don't blend correctly + * if there are blend constants involved. The swizzle just remaps the + * output of the shader to different channels in the texture. It + * doesn't change the interpretation of the constant blend factors in + * COLOR_CALC_STATE. + */ + if (isl_format_supports_alpha_blending(devinfo, plane_format.isl_format) && + isl_swizzle_is_identity(plane_format.swizzle)) flags |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT_KHR; }