mirror of https://github.com/zeldaret/botw.git
Havok: Fix hkSimdFloat32 for Neon
This commit is contained in:
parent
d696cfa65d
commit
65ab9695e9
|
@ -1,22 +1,44 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Havok/Common/Base/Types/hkBaseTypes.h>
|
#include <Havok/Common/Base/Types/hkBaseTypes.h>
|
||||||
|
|
||||||
|
#ifdef __aarch64__
|
||||||
|
#include <arm_neon.h>
|
||||||
|
#define HK_SIMD_FLOAT32_AARCH64_NEON
|
||||||
|
#else
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#endif
|
||||||
|
|
||||||
using hkSimdFloat32Parameter = class hkSimdFloat32;
|
using hkSimdFloat32Parameter = class hkSimdFloat32;
|
||||||
|
|
||||||
class hkSimdFloat32 {
|
class hkSimdFloat32 {
|
||||||
public:
|
public:
|
||||||
hkSimdFloat32() = default;
|
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; }
|
hkFloat32 val() const { return m_real; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
operator float() const { return val(); } // NOLINT(google-explicit-constructor)
|
||||||
|
|
||||||
void setAbs(hkSimdFloat32Parameter x);
|
void setAbs(hkSimdFloat32Parameter x);
|
||||||
|
|
||||||
|
#ifdef HK_SIMD_FLOAT32_AARCH64_NEON
|
||||||
|
__attribute__((vector_size(2 * sizeof(float)))) float m_real;
|
||||||
|
#else
|
||||||
hkFloat32 m_real;
|
hkFloat32 m_real;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void hkSimdFloat32::setAbs(hkSimdFloat32Parameter x) {
|
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);
|
m_real = std::abs(x.m_real);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue