aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2020-03-10 14:38:12 -0700
committerMarge Bot <[email protected]>2020-04-06 18:00:17 +0000
commit4638a16a9302a0e7ebf95dc5e025d2623127cf25 (patch)
treeef6fcedd81301b9fc88f47c417823ba8d00ad36f /src/compiler
parente78a7a182524f091e2d77ba97bfbe057c3975cab (diff)
nir: add some swizzle helpers
Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4455>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index c44513e5ac6..4d3c0d03ccf 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -881,6 +881,26 @@ nir_dest_num_components(nir_dest dest)
return dest.is_ssa ? dest.ssa.num_components : dest.reg.reg->num_components;
}
+/* Are all components the same, ie. .xxxx */
+static inline bool
+nir_is_same_comp_swizzle(uint8_t *swiz, unsigned nr_comp)
+{
+ for (unsigned i = 1; i < nr_comp; i++)
+ if (swiz[i] != swiz[0])
+ return false;
+ return true;
+}
+
+/* Are all components sequential, ie. .yzw */
+static inline bool
+nir_is_sequential_comp_swizzle(uint8_t *swiz, unsigned nr_comp)
+{
+ for (unsigned i = 1; i < nr_comp; i++)
+ if (swiz[i] != (swiz[0] + i))
+ return false;
+ return true;
+}
+
void nir_src_copy(nir_src *dest, const nir_src *src, void *instr_or_if);
void nir_dest_copy(nir_dest *dest, const nir_dest *src, nir_instr *instr);