Fixed strict alignment warnings #235 #370

This commit is contained in:
Christophe Riccio 2015-08-31 18:55:45 +02:00
parent 2f4338269d
commit c10df14b58
6 changed files with 18 additions and 63 deletions

View File

@ -39,6 +39,7 @@ namespace glm
highp,
mediump,
lowp,
simd,
defaultp = highp
};
}//namespace glm

View File

@ -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];
};
@ -56,19 +56,19 @@ 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;
};
@ -76,7 +76,7 @@ namespace detail
# if (GLM_ARCH & GLM_ARCH_AVX) && GLM_NOT_BUGGY_VC32BITS
template <>
struct simd<double>
struct simd_data<double, simd>
{
typedef __m256d type;
};
@ -84,13 +84,13 @@ namespace detail
# 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;
};
@ -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)

View File

@ -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

View File

@ -34,14 +34,7 @@ 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
@ -49,28 +42,18 @@ namespace glm{
# 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) :
data(_mm_set_ps(d, c, b, a))
{}
template <>
GLM_FUNC_QUALIFIER tvec4<float, mediump>::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 <>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::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;
@ -78,7 +61,7 @@ namespace glm{
template <>
template <>
GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::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;
@ -86,31 +69,7 @@ namespace glm{
template <>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<float, mediump> & tvec4<float, mediump>::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)
{
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;

View File

@ -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.

View File

@ -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