Skip to content

Commit

Permalink
Fixed strict alignment warnings #235 #370
Browse files Browse the repository at this point in the history
  • Loading branch information
Groovounet committed Aug 31, 2015
1 parent 2f43382 commit c10df14
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 63 deletions.
1 change: 1 addition & 0 deletions glm/detail/precision.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace glm
highp,
mediump,
lowp,
simd,
defaultp = highp
};
}//namespace glm
20 changes: 9 additions & 11 deletions glm/detail/type_vec4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
namespace glm{
namespace detail
{
template <typename T>
struct simd
template <typename T, precision P = defaultp>
struct simd_data
{
typedef T type[4];
};
Expand All @@ -56,41 +56,41 @@ namespace detail

# if (GLM_ARCH & GLM_ARCH_SSE2) && GLM_NOT_BUGGY_VC32BITS
template <>
struct simd<float>
struct simd_data<float, simd>
{
typedef __m128 type;
};

template <>
struct simd<int>
struct simd_data<int, simd>
{
typedef __m128i type;
};

template <>
struct simd<unsigned int>
struct simd_data<unsigned int, simd>
{
typedef __m128i type;
};
# endif

# if (GLM_ARCH & GLM_ARCH_AVX) && GLM_NOT_BUGGY_VC32BITS
template <>
struct simd<double>
struct simd_data<double, simd>
{
typedef __m256d type;
};
# endif

# if (GLM_ARCH & GLM_ARCH_AVX2) && GLM_NOT_BUGGY_VC32BITS
template <>
struct simd<int64>
struct simd_data<int64, simd>
{
typedef __m256i type;
};

template <>
struct simd<uint64>
struct simd_data<uint64, simd>
{
typedef __m256i type;
};
Expand Down Expand Up @@ -121,9 +121,7 @@ namespace detail
struct { T r, g, b, a; };
struct { T s, t, p, q; };

# ifdef GLM_SIMD
typename detail::simd<T>::type data;
# endif
typename detail::simd_data<T, P>::type data;

# ifdef GLM_SWIZZLE
_GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, x, y, z, w)
Expand Down
2 changes: 1 addition & 1 deletion glm/detail/type_vec4.inl
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ namespace glm
}
}//namespace glm

#if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SIMD) && GLM_NOT_BUGGY_VC32BITS
#if GLM_HAS_ANONYMOUS_UNION && GLM_NOT_BUGGY_VC32BITS
#if GLM_ARCH & GLM_ARCH_SSE2
# include "type_vec4_sse2.inl"
#endif
Expand Down
53 changes: 6 additions & 47 deletions glm/detail/type_vec4_sse2.inl
Original file line number Diff line number Diff line change
Expand Up @@ -34,83 +34,42 @@ namespace glm{

# if !GLM_HAS_DEFAULTED_FUNCTIONS
template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: data(_mm_setzero_ps())
# endif
{}

template <>
GLM_FUNC_QUALIFIER tvec4<float, mediump>::tvec4()
GLM_FUNC_QUALIFIER tvec4<float, simd>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: data(_mm_setzero_ps())
# endif
{}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS

template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4(float s) :
data(_mm_set1_ps(s))
{}

template <>
GLM_FUNC_QUALIFIER tvec4<float, mediump>::tvec4(float s) :
GLM_FUNC_QUALIFIER tvec4<float, simd>::tvec4(float s) :
data(_mm_set1_ps(s))
{}

template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4(float a, float b, float c, float d) :
GLM_FUNC_QUALIFIER tvec4<float, simd>::tvec4(float a, float b, float c, float d) :
data(_mm_set_ps(d, c, b, a))
{}

template <>
GLM_FUNC_QUALIFIER tvec4<float, mediump>::tvec4(float a, float b, float c, float d) :
data(_mm_set_ps(d, c, b, a))
{}

template <>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::operator+=(U scalar)
{
this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast<float>(scalar)));
return *this;
}

template <>
template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::operator+=<float>(float scalar)
{
this->data = _mm_add_ps(this->data, _mm_set_ps1(scalar));
return *this;
}

template <>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<float, mediump> & tvec4<float, mediump>::operator+=(U scalar)
GLM_FUNC_QUALIFIER tvec4<float, simd> & tvec4<float, simd>::operator+=(U scalar)
{
this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast<float>(scalar)));
return *this;
}

template <>
template <>
GLM_FUNC_QUALIFIER tvec4<float, mediump> & tvec4<float, mediump>::operator+=<float>(float scalar)
GLM_FUNC_QUALIFIER tvec4<float, simd> & tvec4<float, simd>::operator+=<float>(float scalar)
{
this->data = _mm_add_ps(this->data, _mm_set_ps1(scalar));
return *this;
}

template <>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::operator+=(tvec1<U, lowp> const & v)
{
this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast<float>(v.x)));
return *this;
}

template <>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<float, mediump> & tvec4<float, mediump>::operator+=(tvec1<U, mediump> const & v)
GLM_FUNC_QUALIFIER tvec4<float, simd> & tvec4<float, simd>::operator+=(tvec1<U, simd> const & v)
{
this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast<float>(v.x)));
return *this;
Expand Down
1 change: 0 additions & 1 deletion glm/gtc/matrix_transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ namespace glm
T near,
T far);


/// Creates a matrix for a right handed, symetric perspective-view frustum.
///
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
Expand Down
4 changes: 1 addition & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
## Release notes
#### [GLM 0.9.7.1](https://github.com/g-truc/glm/releases/latest) - 2015-XX-XX
##### Features:
- Added GLM_SIMD to enable automatic SIMD code generation for generic GLM types #235 #370
##### Fixes:
- Fixed strict alignment warnings #235 #370
- Fixed link errors on compilers not supported default function #377
- Fixed compilation warnings in vec4
Expand Down

0 comments on commit c10df14

Please sign in to comment.