From: Alyssa Rosenzweig Date: Wed, 24 Jul 2019 03:02:06 +0000 (-0700) Subject: pan/midgard: Add mir_simple_swizzle helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b8caaa3000a9eb452c7ea54f9d9eb80927e22814;p=mesa.git pan/midgard: Add mir_simple_swizzle helper Checks for x/xy/xyz/xyzw style swizzles (slightly more general but you get the idea). Signed-off-by: Alyssa Rosenzweig --- diff --git a/src/panfrost/midgard/helpers.h b/src/panfrost/midgard/helpers.h index 7a0a9d845e4..81d10936201 100644 --- a/src/panfrost/midgard/helpers.h +++ b/src/panfrost/midgard/helpers.h @@ -303,4 +303,19 @@ vector_alu_apply_swizzle(unsigned src, unsigned swizzle) return vector_alu_srco_unsigned(s); } +/* Checks for an xyzw.. swizzle, given a mask */ + +static inline bool +mir_is_simple_swizzle(unsigned swizzle, unsigned mask) +{ + for (unsigned i = 0; i < 16; ++i) { + if (!(mask & (1 << i))) continue; + + if (((swizzle >> (2 * i)) & 0x3) != i) + return false; + } + + return true; +} + #endif