Fixed cases of unspecialized simd

This commit is contained in:
Christophe Riccio 2014-10-18 02:34:20 +02:00
parent 8a1bf4410b
commit 327c7917fb
2 changed files with 30 additions and 13 deletions

View File

@ -70,7 +70,7 @@ namespace glm
w(0) 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 <> template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4() : GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4() :
data(_mm_setzero_ps()) data(_mm_setzero_ps())
@ -90,7 +90,7 @@ namespace glm
w(v.w) 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 <> template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4(tvec4<float, lowp> const & v) : GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4(tvec4<float, lowp> const & v) :
data(v.data) data(v.data)
@ -126,7 +126,7 @@ namespace glm
w(s) 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 <> template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4(float const & s) : GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4(float const & s) :
data(_mm_set1_ps(s)) data(_mm_set1_ps(s))
@ -146,7 +146,7 @@ namespace glm
w(d) 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 <> template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4(float const & a, float const & b, float const & c, float const & d) : GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4(float const & a, float const & b, float const & c, float const & d) :
data(_mm_set_ps(d, c, b, a)) data(_mm_set_ps(d, c, b, a))
@ -303,7 +303,7 @@ namespace glm
return *this; 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<float, lowp> & tvec4<float, lowp>::operator= (tvec4<float, lowp> const & v) GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::operator= (tvec4<float, lowp> const & v)
{ {
@ -341,7 +341,7 @@ namespace glm
return *this; 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 <>
template <typename U> template <typename U>
GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::operator+=(U s) GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::operator+=(U s)
@ -350,6 +350,14 @@ namespace glm
return *this; return *this;
} }
template <>
template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::operator+=<float>(float s)
{
this->data = _mm_add_ps(this->data, _mm_set_ps1(s));
return *this;
}
template <> template <>
template <typename U> template <typename U>
GLM_FUNC_QUALIFIER tvec4<float, mediump> & tvec4<float, mediump>::operator+=(U s) GLM_FUNC_QUALIFIER tvec4<float, mediump> & tvec4<float, mediump>::operator+=(U s)
@ -357,6 +365,14 @@ namespace glm
this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast<float>(s))); this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast<float>(s)));
return *this; return *this;
} }
template <>
template <>
GLM_FUNC_QUALIFIER tvec4<float, mediump> & tvec4<float, mediump>::operator+=<float>(float s)
{
this->data = _mm_add_ps(this->data, _mm_set_ps1(s));
return *this;
}
#endif #endif
template <typename T, precision P> template <typename T, precision P>
@ -370,10 +386,10 @@ namespace glm
return *this; 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 <>
template <typename U> template <typename U>
GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::operator+=(tvec1<U, P> const & s) GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::operator+=(tvec1<U, lowp> const & s)
{ {
this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast<float>(s))); this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast<float>(s)));
return *this; return *this;
@ -381,7 +397,7 @@ namespace glm
template <> template <>
template <typename U> template <typename U>
GLM_FUNC_QUALIFIER tvec4<float, mediump> & tvec4<float, mediump>::operator+=(tvec1<U, P> const & s) GLM_FUNC_QUALIFIER tvec4<float, mediump> & tvec4<float, mediump>::operator+=(tvec1<U, mediump> const & s)
{ {
this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast<float>(s))); this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast<float>(s)));
return *this; return *this;

View File

@ -7,6 +7,7 @@
// File : test/core/type_vec4.cpp // File : test/core/type_vec4.cpp
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
//#define GLM_FORCE_AVX2
#define GLM_SWIZZLE #define GLM_SWIZZLE
#include <glm/vector_relational.hpp> #include <glm/vector_relational.hpp>
#include <glm/vec2.hpp> #include <glm/vec2.hpp>
@ -42,7 +43,7 @@ int test_vec4_ctor()
{ {
int Error = 0; int Error = 0;
#if(GLM_HAS_INITIALIZER_LISTS) #if GLM_HAS_INITIALIZER_LISTS
{ {
glm::vec4 a{ 0, 1, 2, 3 }; glm::vec4 a{ 0, 1, 2, 3 };
std::vector<glm::vec4> v = { std::vector<glm::vec4> v = {
@ -60,7 +61,7 @@ int test_vec4_ctor()
} }
#endif #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 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B = A.xyzw; 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, L)) ? 0 : 1;
Error += glm::all(glm::equal(A, M)) ? 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); glm::vec4 A(1);
@ -276,7 +277,7 @@ int test_vec4_swizzle_partial()
glm::vec4 A(1, 2, 3, 4); 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); glm::vec4 B(A.xy, A.zw);
Error += A == B ? 0 : 1; Error += A == B ? 0 : 1;