From 327c7917fbf50a5a5576ba238433a1fe5354c3a3 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 18 Oct 2014 02:34:20 +0200 Subject: [PATCH] Fixed cases of unspecialized simd --- glm/detail/type_vec4.inl | 34 +++++++++++++++++++++++++--------- test/core/core_type_vec4.cpp | 9 +++++---- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 94568ade..50f27543 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -70,7 +70,7 @@ namespace glm w(0) {} -#if (GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2) +#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2) template <> GLM_FUNC_QUALIFIER tvec4::tvec4() : data(_mm_setzero_ps()) @@ -90,7 +90,7 @@ namespace glm w(v.w) {} -#if (GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2) +#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2) template <> GLM_FUNC_QUALIFIER tvec4::tvec4(tvec4 const & v) : data(v.data) @@ -126,7 +126,7 @@ namespace glm w(s) {} -#if((GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2)) +#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2) template <> GLM_FUNC_QUALIFIER tvec4::tvec4(float const & s) : data(_mm_set1_ps(s)) @@ -146,7 +146,7 @@ namespace glm w(d) {} -#if((GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2)) +#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2) template <> GLM_FUNC_QUALIFIER tvec4::tvec4(float const & a, float const & b, float const & c, float const & d) : data(_mm_set_ps(d, c, b, a)) @@ -303,7 +303,7 @@ namespace glm return *this; } -#if (GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2) +#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2) template <> GLM_FUNC_QUALIFIER tvec4 & tvec4::operator= (tvec4 const & v) { @@ -341,7 +341,7 @@ namespace glm return *this; } -#if (GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2) +#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2) template <> template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U s) @@ -350,6 +350,14 @@ namespace glm return *this; } + template <> + template <> + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(float s) + { + this->data = _mm_add_ps(this->data, _mm_set_ps1(s)); + return *this; + } + template <> template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U s) @@ -357,6 +365,14 @@ namespace glm this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(s))); return *this; } + + template <> + template <> + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(float s) + { + this->data = _mm_add_ps(this->data, _mm_set_ps1(s)); + return *this; + } #endif template @@ -370,10 +386,10 @@ namespace glm return *this; } -#if (GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2) +#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2) template <> template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & s) { this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(s))); return *this; @@ -381,7 +397,7 @@ namespace glm template <> template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & s) { this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(s))); return *this; diff --git a/test/core/core_type_vec4.cpp b/test/core/core_type_vec4.cpp index fa65f9e0..0c5e92ff 100644 --- a/test/core/core_type_vec4.cpp +++ b/test/core/core_type_vec4.cpp @@ -7,6 +7,7 @@ // File : test/core/type_vec4.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// +//#define GLM_FORCE_AVX2 #define GLM_SWIZZLE #include #include @@ -42,7 +43,7 @@ int test_vec4_ctor() { int Error = 0; -#if(GLM_HAS_INITIALIZER_LISTS) +#if GLM_HAS_INITIALIZER_LISTS { glm::vec4 a{ 0, 1, 2, 3 }; std::vector v = { @@ -60,7 +61,7 @@ int test_vec4_ctor() } #endif -#if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) +#if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE) { glm::vec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f); glm::vec4 B = A.xyzw; @@ -89,7 +90,7 @@ int test_vec4_ctor() Error += glm::all(glm::equal(A, L)) ? 0 : 1; Error += glm::all(glm::equal(A, M)) ? 0 : 1; } -#endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) +#endif// GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE) { glm::vec4 A(1); @@ -276,7 +277,7 @@ int test_vec4_swizzle_partial() glm::vec4 A(1, 2, 3, 4); -# if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE_RELAX)) +# if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE_RELAX) { glm::vec4 B(A.xy, A.zw); Error += A == B ? 0 : 1;