From a8879daf9c3d187822ef2784567a15197a830c2c Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Wed, 1 Apr 2026 13:15:02 -0400 Subject: [PATCH] pan/bi: Add a bi_try_compose_swizzles() helper Reviewed-by: Lorenzo Rossi Part-of: --- src/panfrost/compiler/bifrost/compiler.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/panfrost/compiler/bifrost/compiler.h b/src/panfrost/compiler/bifrost/compiler.h index 828d7319784..fcbe016c0b1 100644 --- a/src/panfrost/compiler/bifrost/compiler.h +++ b/src/panfrost/compiler/bifrost/compiler.h @@ -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) {