diff --git a/Engine/Source/Runtime/Core/Math/SIMD/Alignment.h b/Engine/Source/Runtime/Core/Math/SIMD/Alignment.h deleted file mode 100644 index 2c42d48..0000000 --- a/Engine/Source/Runtime/Core/Math/SIMD/Alignment.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include "Core/Math/Boilerplate.h" - - -namespace Phanes::Core::Math::SIMD -{ - - // Structure to conveniently align arrays. - template - struct alignas(sizeof(T) * 4) AlignedVec - { - public: - T data[L]; - - AlignedVec(const T* n_aligned_data) - { - for (size_t i = 0; i < L; ++i) - { - data[i] = n_aligned_data[i]; - } - } - - const T* Get() - { - return data; - } - }; - -} diff --git a/Engine/Source/Runtime/Core/Math/SIMD/Alignment.hpp b/Engine/Source/Runtime/Core/Math/SIMD/Alignment.hpp new file mode 100644 index 0000000..dda4b40 --- /dev/null +++ b/Engine/Source/Runtime/Core/Math/SIMD/Alignment.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include +#include +#include + +namespace Phanes::Core::Math::SIMD +{ + // Structure to conveniently align arrays. + template + struct alignas(Align) AlignedVec + { + public: + static_assert(std::is_trivially_copyable_v, + "Alignment.hpp: AlignedVecSSE must be trivially copyable."); + static_assert(Align >= alignof(T) && (Align & (Align - 1)) == 0, + "Alignment.hpp: Alignment must be a power of two and >= alignof(T)."); + T data[L]; + + explicit AlignedVec(const T* n_aligned_data) + { + std::memcpy(data, n_aligned_data, sizeof(T) * L); + } + + const T* Get() const + { + return data; + } + }; + + template + using AlignedVecSSE = AlignedVec; + + template + using AlignedVecAVX = AlignedVec; +} // namespace Phanes::Core::Math::SIMD