From 4f5d589eccc00dbb7f22f7256eccd64df9472634 Mon Sep 17 00:00:00 2001 From: sharkautarch <128002472+sharkautarch@users.noreply.github.com> Date: Sat, 5 Oct 2024 13:23:27 -0400 Subject: [PATCH] simd constexpr vec: introduce new function compWiseTernary for bvec, for simd select from mask --- glm/detail/simd_constexpr/vec.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/glm/detail/simd_constexpr/vec.hpp b/glm/detail/simd_constexpr/vec.hpp index 6980ce37..c56da018 100644 --- a/glm/detail/simd_constexpr/vec.hpp +++ b/glm/detail/simd_constexpr/vec.hpp @@ -184,6 +184,14 @@ namespace glm return a[i]; } + template requires(std::is_same_v) + inline vec compWiseTernary(vec v1, vec v2) { + GccVec_t condMask = std::bit_cast(elementArr); + auto gv1 = std::bit_cast>(v1.elementArr); + auto gv2 = std::bit_cast>(v2.elementArr); + return vec(std::bit_cast> ((condMask ? gv1 : gv2))); + } + template static constexpr auto ctor_scalar(ScalarGetter scalar) { if (std::is_constant_evaluated()) {