From 5bc1cb4a1f11550632d2ffcdb6f714c33e7a91f5 Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Wed, 30 Dec 2020 12:41:03 -0500 Subject: [PATCH] A few small changes until we're ready to go all-in on c++17 over-aligned allocation --- indra/llmath/llmatrix4a.h | 26 +++++++++++++++++++--- indra/llmath/llsimdtypes.h | 5 ----- indra/llmath/llvector4a.h | 45 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 66 insertions(+), 10 deletions(-) diff --git a/indra/llmath/llmatrix4a.h b/indra/llmath/llmatrix4a.h index df94d7327e6..7be4e5a066a 100644 --- a/indra/llmath/llmatrix4a.h +++ b/indra/llmath/llmatrix4a.h @@ -32,10 +32,10 @@ #include "m4math.h" #include "m3math.h" -class alignas(16) LLMatrix4a +LL_ALIGN_PREFIX(16) class LLMatrix4a { public: - LLVector4a mMatrix[4]; + LL_ALIGN_PREFIX(16) LLVector4a mMatrix[4] LL_ALIGN_POSTFIX(16); public: enum { @@ -45,6 +45,26 @@ class alignas(16) LLMatrix4a ROW_TRANS }; + void* operator new(size_t size) + { + return ll_aligned_malloc_16(size); + } + + void* operator new[](size_t size) + { + return ll_aligned_malloc_16(size); + } + + void operator delete(void* ptr) + { + ll_aligned_free_16(ptr); + } + + void operator delete[](void* ptr) + { + ll_aligned_free_16(ptr); + } + LLMatrix4a() = default; LLMatrix4a(const LLQuad& q1,const LLQuad& q2,const LLQuad& q3,const LLQuad& q4) { @@ -767,7 +787,7 @@ class alignas(16) LLMatrix4a return _mm_movemask_epi8(_mm_castps_si128(_mm_and_ps(mask1, mask2))) == 0xFFFF; } -}; +} LL_ALIGN_POSTFIX(16); #ifndef SHOW_ASSERT static_assert(std::is_trivial<LLMatrix4a>::value, "LLMatrix4a must be a trivial type"); diff --git a/indra/llmath/llsimdtypes.h b/indra/llmath/llsimdtypes.h index ce1e24dc681..715c3563480 100644 --- a/indra/llmath/llsimdtypes.h +++ b/indra/llmath/llsimdtypes.h @@ -66,11 +66,6 @@ class LLSimdScalar mQ = _mm_set_ss(f); } - static inline LLSimdScalar getZero() - { - return _mm_setzero_ps(); - } - inline F32 getF32() const; inline LLBool32 isApproximatelyEqual(const LLSimdScalar& rhs, F32 tolerance = F_APPROXIMATELY_ZERO) const; diff --git a/indra/llmath/llvector4a.h b/indra/llmath/llvector4a.h index 0e564889a5e..aa75c5f076c 100644 --- a/indra/llmath/llvector4a.h +++ b/indra/llmath/llvector4a.h @@ -94,6 +94,26 @@ struct alignas(16) LLVector4a static void memcpyNonAliased16(F32* __restrict dst, const F32* __restrict src, size_t bytes); + void* operator new(size_t size) + { + return ll_aligned_malloc_16(size); + } + + void* operator new[](size_t size) + { + return ll_aligned_malloc_16(size); + } + + void operator delete(void* ptr) + { + ll_aligned_free_16(ptr); + } + + void operator delete[](void* ptr) + { + ll_aligned_free_16(ptr); + } + //////////////////////////////////// // CONSTRUCTORS //////////////////////////////////// @@ -380,7 +400,8 @@ inline std::ostream& operator<<(std::ostream& s, const LLVector4a& v) return s; } -struct alignas(16) LLIVector4a +LL_ALIGN_PREFIX(16) +struct LLIVector4a { friend struct LLVector4a; @@ -391,6 +412,26 @@ struct alignas(16) LLIVector4a return _mm_setzero_si128(); } + void* operator new(size_t size) + { + return ll_aligned_malloc_16(size); + } + + void* operator new[](size_t size) + { + return ll_aligned_malloc_16(size); + } + + void operator delete(void* ptr) + { + ll_aligned_free_16(ptr); + } + + void operator delete[](void* ptr) + { + ll_aligned_free_16(ptr); + } + //////////////////////////////////// // CONSTRUCTORS //////////////////////////////////// @@ -498,7 +539,7 @@ struct alignas(16) LLIVector4a } LLIQuad mQ; -}; +} LL_ALIGN_POSTFIX(16); static_assert(std::is_trivial<LLIVector4a>{}, "LLIVector4a must be a trivial type"); static_assert(std::is_standard_layout<LLIVector4a>{}, "LLIVector4a must be a standard layout type"); -- GitLab