anv: fixup assertions on lowered storage formats

With VK_FORMAT_B10G11R11_UFLOAT_PACK32 in particular, we're seeing
applications create image views with swizzle = R,G,B,0

But since the format has no alpha channel, the swizzle value for it
does not matter for the equivalence we're trying to verify.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: a9edc268b9 ("anv: validate image view lowered storage formats for storage")
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18081>
This commit is contained in:
Lionel Landwerlin 2022-08-14 21:41:04 +03:00 committed by Marge Bot
parent 9e31b0fba1
commit 4ab38112f3
2 changed files with 17 additions and 1 deletions

View file

@ -2357,6 +2357,22 @@ isl_swizzle_is_identity(struct isl_swizzle swizzle)
swizzle.a == ISL_CHANNEL_SELECT_ALPHA;
}
static inline bool
isl_swizzle_is_identity_for_format(enum isl_format format,
struct isl_swizzle swizzle)
{
const struct isl_format_layout *layout = isl_format_get_layout(format);
#define channel_id_or_zero(name, ID) \
(swizzle.name == ISL_CHANNEL_SELECT_##ID || \
layout->channels.name.bits == 0)
return channel_id_or_zero(r, RED) &&
channel_id_or_zero(g, GREEN) &&
channel_id_or_zero(b, BLUE) &&
channel_id_or_zero(a, ALPHA);
#undef channel_id_or_zero
}
bool
isl_swizzle_supports_rendering(const struct intel_device_info *devinfo,
struct isl_swizzle swizzle);

View file

@ -2566,7 +2566,7 @@ anv_image_fill_surface_state(struct anv_device *device,
*/
assert(isl_formats_have_same_bits_per_channel(lower_format,
view.format) ||
isl_swizzle_is_identity(view.swizzle));
isl_swizzle_is_identity_for_format(view.format, view.swizzle));
view.format = lower_format;
}