From b8caaa3000a9eb452c7ea54f9d9eb80927e22814 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 23 Jul 2019 20:02:06 -0700 Subject: [PATCH] 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 --- src/panfrost/midgard/helpers.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/panfrost/midgard/helpers.h b/src/panfrost/midgard/helpers.h index 7a0a9d8..81d1093 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 -- 2.7.4