pan/bi: Add a bi_try_compose_swizzles() helper

Reviewed-by: Lorenzo Rossi <lorenzo.rossi@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40720>
This commit is contained in:
Faith Ekstrand 2026-04-01 13:15:02 -04:00 committed by Marge Bot
parent 3b728cb613
commit a8879daf9c

View file

@ -183,6 +183,22 @@ bi_swizzle_from_byte_channels(const unsigned byte_channels[4],
}
}
static inline bool
bi_try_compose_swizzles(enum bi_swizzle *ab_out,
enum bi_swizzle a, enum bi_swizzle b)
{
unsigned a_bytes[4], b_bytes[4];
bi_swizzle_to_byte_channels(a, a_bytes);
bi_swizzle_to_byte_channels(b, b_bytes);
unsigned ab_bytes[4];
for (unsigned i = 0; i < 4; i++) {
ab_bytes[i] = b_bytes[a_bytes[i]];
}
return bi_swizzle_from_byte_channels(ab_bytes, ab_out);
}
static inline enum bi_swizzle
bi_swizzle_from_half(bool x, bool y)
{