diff --git a/Engine/Source/Runtime/Core/public/Math/Detail/IntVector2Decl.inl b/Engine/Source/Runtime/Core/public/Math/Detail/IntVector2Decl.inl index 35a45ef..dccd592 100644 --- a/Engine/Source/Runtime/Core/public/Math/Detail/IntVector2Decl.inl +++ b/Engine/Source/Runtime/Core/public/Math/Detail/IntVector2Decl.inl @@ -153,8 +153,8 @@ namespace Phanes::Core::Math::Detail } }; - template - struct compute_ivec2_mod + template + struct compute_ivec2_mod { static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) { diff --git a/Engine/Source/Runtime/Core/public/Math/Include.h b/Engine/Source/Runtime/Core/public/Math/Include.h index dc655a5..4bb732e 100644 --- a/Engine/Source/Runtime/Core/public/Math/Include.h +++ b/Engine/Source/Runtime/Core/public/Math/Include.h @@ -2,4 +2,5 @@ // --- Vectors ------------------------ -#include "Core/public/Math/Vector2.hpp" // <-- Includes Vector3/4 automatically \ No newline at end of file +#include "Core/public/Math/Vector2.hpp" // <-- Includes Vector3/4 automatically +#include "Core/public/Math/IntVector2.hpp" \ No newline at end of file diff --git a/Engine/Source/Runtime/Core/public/Math/IntVector2.inl b/Engine/Source/Runtime/Core/public/Math/IntVector2.inl index 0d7466c..6cd2d0f 100644 --- a/Engine/Source/Runtime/Core/public/Math/IntVector2.inl +++ b/Engine/Source/Runtime/Core/public/Math/IntVector2.inl @@ -7,8 +7,6 @@ #include "Core/public/Math/SIMD/PhanesSIMDTypes.h" -#include "Core/public/Math/IntVector2.hpp" - namespace Phanes::Core::Math { template diff --git a/Engine/Source/Runtime/Core/public/Math/MathFwd.h b/Engine/Source/Runtime/Core/public/Math/MathFwd.h index 98b3bb5..9dfce21 100644 --- a/Engine/Source/Runtime/Core/public/Math/MathFwd.h +++ b/Engine/Source/Runtime/Core/public/Math/MathFwd.h @@ -51,13 +51,6 @@ namespace Phanes::Core::Math { * Specific instantiation of forward declarations. */ - // TIntVector2 - typedef TIntVector2 IntVector2; - typedef TIntVector2 IntVector2l; - - typedef std::vector IntVector2List; - typedef std::vector IntVector2Listl; - // TIntVector3 typedef TIntVector3 IntVector3; typedef TIntVector3 IntVector3l; diff --git a/Engine/Source/Runtime/Core/public/Math/SIMD/PhanesVectorMathSSE.hpp b/Engine/Source/Runtime/Core/public/Math/SIMD/PhanesVectorMathSSE.hpp index 4d6ba96..072d500 100644 --- a/Engine/Source/Runtime/Core/public/Math/SIMD/PhanesVectorMathSSE.hpp +++ b/Engine/Source/Runtime/Core/public/Math/SIMD/PhanesVectorMathSSE.hpp @@ -197,28 +197,6 @@ namespace Phanes::Core::Math::Detail } }; - template<> - struct compute_vec4_eq - { - static FORCEINLINE bool map(const Phanes::Core::Math::TVector4& v1, const Phanes::Core::Math::TVector4& v2) - { - float r; - _mm_store_ps1(&r, _mm_cmpeq_ps(v1.comp, v2.comp)); - return (r == 0xffffffff) ? true : false; - } - }; - - template<> - struct compute_vec4_ieq - { - static FORCEINLINE bool map(const Phanes::Core::Math::TVector4& v1, const Phanes::Core::Math::TVector4& v2) - { - float r; - _mm_store_ps1(&r, _mm_cmpneq_ps(v1.comp, v2.comp)); - return (r == 0xffffffff) ? true : false; - } - }; - // ============ // // TVector3 // @@ -257,34 +235,6 @@ namespace Phanes::Core::Math::Detail }; - - template<> struct compute_vec3_eq : public compute_vec4_eq - { - static FORCEINLINE bool map(Phanes::Core::Math::TVector3& v1, Phanes::Core::Math::TVector3& v2) - { - v1.comp = _mm_setr_ps(v1.x, v1.y, v1.z, 0.0f); - v2.comp = _mm_setr_ps(v2.x, v2.y, v2.z, 0.0f); - - float r; - _mm_store_ps1(&r, _mm_cmpeq_ps(v1.comp, v2.comp)); - return (r == 0xffffffff) ? true : false; - } - }; - - template<> struct compute_vec3_ieq : public compute_vec4_ieq - { - static FORCEINLINE bool map(Phanes::Core::Math::TVector3& v1, Phanes::Core::Math::TVector3& v2) - { - v1.comp = _mm_setr_ps(v1.x, v1.y, v1.z, 0.0f); - v2.comp = _mm_setr_ps(v2.x, v2.y, v2.z, 0.0f); - - float r; - _mm_store_ps1(&r, _mm_cmpneq_ps(v1.comp, v2.comp)); - return (r == 0xffffffff) ? true : false; - } - }; - - template<> struct compute_vec3_add : public compute_vec4_add {}; template<> struct compute_vec3_sub : public compute_vec4_sub {}; template<> struct compute_vec3_mul : public compute_vec4_mul {}; @@ -399,32 +349,149 @@ namespace Phanes::Core::Math::Detail } }; - template<> - struct compute_vec2_eq - { - static FORCEINLINE bool map(const Phanes::Core::Math::TVector2& v1, const Phanes::Core::Math::TVector2& v2) - { - double r; - _mm_store1_pd(&r, _mm_cmpeq_pd(v1.comp, v2.comp)); - return (r == 0xffffffff) ? true : false; - } - }; - - template<> - struct compute_vec2_ieq - { - static FORCEINLINE bool map(const Phanes::Core::Math::TVector2& v1, const Phanes::Core::Math::TVector2& v2) - { - double r; - _mm_store1_pd(&r, _mm_cmpneq_pd(v1.comp, v2.comp)); - return (r == 0xffffffff) ? true : false; - } - }; - // =============== // // TIntVector2 // // =============== // + template<> + struct construct_ivec2 + { + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& v1, const TIntVector2& v2) + { + v1.comp = _mm_setr_epi64x(v2.x, v2.y); + } + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& v1, Phanes::Core::Types::int64 s) + { + v1.comp = _mm_set1_epi64x(s); + } + + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& v1, Phanes::Core::Types::int64 x, Phanes::Core::Types::int64 y) + { + v1.comp = _mm_setr_epi64x(x, y); + } + + + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Types::int64* comp) + { + v1.comp = _mm_loadu_epi64(comp); + } + }; + + template<> + struct compute_ivec2_add + { + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + { + r.comp = _mm_add_epi64(v1.comp, v2.comp); + } + + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, T s) + { + r.comp = _mm_add_epi64(v1.comp, _mm_set1_epi64x(s)); + } + }; + + template<> + struct compute_ivec2_sub + { + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + { + r.comp = _mm_sub_epi64(v1.comp, v2.comp); + } + + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, T s) + { + r.comp = _mm_sub_epi64(v1.comp, _mm_set1_epi64x(s)); + } + }; + + template<> + struct compute_ivec2_inc + { + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1) + { + r.comp = _mm_add_epi64(v1.comp, _mm_set1_epi64x(1)); + } + }; + + template<> + struct compute_ivec2_dec + { + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1) + { + r.comp = _mm_sub_epi64(v1.comp, _mm_set1_epi64x(1)); + } + }; + + template<> + struct compute_ivec2_and + { + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + { + r.comp = _mm_and_si128(v1.comp, v2.comp); + } + + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, T s) + { + r.comp = _mm_and_si128(v1.comp, _mm_set1_epi64x(s)); + } + }; + + template<> + struct compute_ivec2_or + { + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + { + r.comp = _mm_or_si128(v1.comp, v2.comp); + } + + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, T s) + { + r.comp = _mm_or_si128(v1.comp, _mm_set1_epi64x(s)); + } + }; + + template<> + struct compute_ivec2_xor + { + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + { + r.comp = _mm_xor_si128(v1.comp, v2.comp); + } + + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, T s) + { + r.comp = _mm_xor_si128(v1.comp, _mm_set1_epi64x(s)); + } + }; + + template<> + struct compute_ivec2_left_shift + { + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + { + r.comp = _mm_sll_epi64(v1.comp, v2.comp); + } + + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, T s) + { + r.comp = _mm_sll_epi64(v1.comp, _mm_set1_epi64x(s)); + } + }; + + template<> + struct compute_ivec2_right_shift + { + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + { + r.comp = _mm_srl_epi64(v1.comp, v2.comp); + } + + static FORCEINLINE void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, T s) + { + r.comp = _mm_srl_epi64(v1.comp, _mm_set1_epi64x(s)); + } + }; } \ No newline at end of file