summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2019-07-23 20:02:06 -0700
committerAlyssa Rosenzweig <[email protected]>2019-07-25 06:37:21 -0700
commitb8caaa3000a9eb452c7ea54f9d9eb80927e22814 (patch)
treeb45cf2a480ecec17cb5dd8d931bd65c94c8124fb
parent63385a3fdb6a42013be74091d0264a09550766ee (diff)
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 <[email protected]>
-rw-r--r--src/panfrost/midgard/helpers.h15
1 files changed, 15 insertions, 0 deletions
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