From 342e9ac7e8f790244b1a2bb5da63823c64d8c120 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Sat, 28 Mar 2026 22:06:33 -0400 Subject: [PATCH] pan/bi: Add a bi_swizzle_from_half() helper Reviewed-by: Lorenzo Rossi Part-of: --- src/panfrost/compiler/bifrost/compiler.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/panfrost/compiler/bifrost/compiler.h b/src/panfrost/compiler/bifrost/compiler.h index 87d2d5e9fcd..d4611030c18 100644 --- a/src/panfrost/compiler/bifrost/compiler.h +++ b/src/panfrost/compiler/bifrost/compiler.h @@ -139,6 +139,12 @@ bi_swizzle_to_byte_channels(enum bi_swizzle swizzle, unsigned *channels) #undef B } +static inline enum bi_swizzle +bi_swizzle_from_half(bool x, bool y) +{ + return (enum bi_swizzle)(BI_SWIZZLE_H00 | (x << 1) | y); +} + /* Given a packed i16vec2/i8vec4 constant, apply a swizzle. Useful for constant * folding and Valhall constant optimization. */ @@ -336,7 +342,7 @@ static inline bi_index bi_swz_16(bi_index idx, bool x, bool y) { assert(idx.swizzle == BI_SWIZZLE_H01); - idx.swizzle = (enum bi_swizzle)(BI_SWIZZLE_H00 | (x << 1) | y); + idx.swizzle = bi_swizzle_from_half(x, y); return idx; }