Bladeren bron

Fixed strict alignment warnings #235 #370

Christophe Riccio 10 jaren geleden
bovenliggende
commit
c10df14b58
6 gewijzigde bestanden met toevoegingen van 18 en 63 verwijderingen
  1. 1 0
      glm/detail/precision.hpp
  2. 9 11
      glm/detail/type_vec4.hpp
  3. 1 1
      glm/detail/type_vec4.inl
  4. 6 47
      glm/detail/type_vec4_sse2.inl
  5. 0 1
      glm/gtc/matrix_transform.hpp
  6. 1 3
      readme.md

+ 1 - 0
glm/detail/precision.hpp

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

+ 9 - 11
glm/detail/type_vec4.hpp

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

+ 1 - 1
glm/detail/type_vec4.inl

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

+ 6 - 47
glm/detail/type_vec4_sse2.inl

@@ -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,44 +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) :
+	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;
@@ -94,7 +61,7 @@ namespace glm{
 
 	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;
@@ -102,15 +69,7 @@ namespace glm{
 
 	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;

+ 0 - 1
glm/gtc/matrix_transform.hpp

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

+ 1 - 3
readme.md

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