From 65ab9695e957e6f84d9923c28496c1ca5046a7ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Fri, 14 Jan 2022 00:53:27 +0100 Subject: [PATCH] Havok: Fix hkSimdFloat32 for Neon --- .../Common/Base/Math/Vector/hkSimdFloat32.h | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/hkStubs/Havok/Common/Base/Math/Vector/hkSimdFloat32.h b/lib/hkStubs/Havok/Common/Base/Math/Vector/hkSimdFloat32.h index 2a481f46..33a0332e 100644 --- a/lib/hkStubs/Havok/Common/Base/Math/Vector/hkSimdFloat32.h +++ b/lib/hkStubs/Havok/Common/Base/Math/Vector/hkSimdFloat32.h @@ -1,22 +1,44 @@ #pragma once #include + +#ifdef __aarch64__ +#include +#define HK_SIMD_FLOAT32_AARCH64_NEON +#else #include +#endif using hkSimdFloat32Parameter = class hkSimdFloat32; class hkSimdFloat32 { public: hkSimdFloat32() = default; - hkSimdFloat32(float x) : m_real(x) {} // NOLINT(google-explicit-constructor) - operator float() const { return val(); } // NOLINT(google-explicit-constructor) + +#ifdef HK_SIMD_FLOAT32_AARCH64_NEON + // NOLINTNEXTLINE(google-explicit-constructor) + hkSimdFloat32(const float& x) { m_real = vdup_n_f32(x); } + hkFloat32 val() const { return m_real[0]; } +#else + hkSimdFloat32(float x) : m_real{x} {} // NOLINT(google-explicit-constructor) hkFloat32 val() const { return m_real; } +#endif + + operator float() const { return val(); } // NOLINT(google-explicit-constructor) void setAbs(hkSimdFloat32Parameter x); +#ifdef HK_SIMD_FLOAT32_AARCH64_NEON + __attribute__((vector_size(2 * sizeof(float)))) float m_real; +#else hkFloat32 m_real; +#endif }; inline void hkSimdFloat32::setAbs(hkSimdFloat32Parameter x) { +#ifdef HK_SIMD_FLOAT32_AARCH64_NEON + m_real = vabs_f32(m_real); +#else m_real = std::abs(x.m_real); +#endif }