From a15790e62422c5c35532b2a74788aa6655a4259e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 16 Jan 2022 15:41:23 +0100 Subject: [PATCH] Havok: Add hkVector4f::load --- .../Common/Base/Math/Vector/hkVector4f.h | 4 +++ .../Common/Base/Math/Vector/hkVector4f.inl | 31 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/lib/hkStubs/Havok/Common/Base/Math/Vector/hkVector4f.h b/lib/hkStubs/Havok/Common/Base/Math/Vector/hkVector4f.h index 37c806d8..2e9b145f 100644 --- a/lib/hkStubs/Havok/Common/Base/Math/Vector/hkVector4f.h +++ b/lib/hkStubs/Havok/Common/Base/Math/Vector/hkVector4f.h @@ -158,6 +158,10 @@ public: return u; } + /// Load N floats from in. + template + void load(const hkFloat32* in); + /// Store N floats to out. template void store(hkFloat32* out) const; diff --git a/lib/hkStubs/Havok/Common/Base/Math/Vector/hkVector4f.inl b/lib/hkStubs/Havok/Common/Base/Math/Vector/hkVector4f.inl index bb99d27a..ed42e7fe 100644 --- a/lib/hkStubs/Havok/Common/Base/Math/Vector/hkVector4f.inl +++ b/lib/hkStubs/Havok/Common/Base/Math/Vector/hkVector4f.inl @@ -386,6 +386,37 @@ inline const hkVector4f& hkVector4f::getConstant() { return reinterpret_cast(g_vectorfConstants[Constant]); } +template +inline void hkVector4f::load(const hkFloat32* in) { + static_assert(1 <= N && N <= 4, "invalid N"); +#ifdef HK_VECTOR4F_AARCH64_NEON + switch (N) { + case 1: + v = vld1q_dup_f32(in); + break; + case 2: { + auto xy = vld1_f32(in); + v = vcombine_f32(xy, xy); + break; + } + case 3: { + auto xy = vld1_f32(in); + auto zz = vld1_dup_f32(in + 2); + v = vcombine_f32(xy, zz); + break; + } + case 4: + v = vld1q_f32(in); + break; + default: + break; + } +#else + for (int i = 0; i < N; ++i) + v[i] = in[i]; +#endif +} + template inline void hkVector4f::store(hkFloat32* out) const { static_assert(1 <= N && N <= 4, "invalid N");