Havok: Add hkVector4f::load

This commit is contained in:
Léo Lam 2022-01-16 15:41:23 +01:00
parent 88f3c8c49a
commit a15790e624
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
2 changed files with 35 additions and 0 deletions

View File

@ -158,6 +158,10 @@ public:
return u;
}
/// Load N floats from in.
template <int N>
void load(const hkFloat32* in);
/// Store N floats to out.
template <int N>
void store(hkFloat32* out) const;

View File

@ -386,6 +386,37 @@ inline const hkVector4f& hkVector4f::getConstant() {
return reinterpret_cast<const hkVector4f&>(g_vectorfConstants[Constant]);
}
template <int N>
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 <int N>
inline void hkVector4f::store(hkFloat32* out) const {
static_assert(1 <= N && N <= 4, "invalid N");