From 3473acdc2a4a6f97d2debb770013272b470a6ff3 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 22 May 2011 11:59:02 +0100 Subject: [PATCH 1/3] Fixed SIMD trunc implementation --- glm/gtx/simd_vec4.inl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/glm/gtx/simd_vec4.inl b/glm/gtx/simd_vec4.inl index b6fb0fd8..d7b1863a 100644 --- a/glm/gtx/simd_vec4.inl +++ b/glm/gtx/simd_vec4.inl @@ -314,6 +314,8 @@ namespace glm detail::fvec4SIMD const & x ) { + //return x < 0 ? -floor(-x) : floor(x); + __m128 Flr0 = detail::sse_flr_ps(_mm_sub_ps(_mm_setzero_ps(), x.Data)); __m128 Sub0 = _mm_sub_ps(Flr0, x.Data); __m128 Flr1 = detail::sse_flr_ps(x.Data); @@ -321,7 +323,7 @@ namespace glm __m128 Cmp0 = _mm_cmplt_ps(x.Data, glm::detail::zero); __m128 Cmp1 = _mm_cmpnlt_ps(x.Data, glm::detail::zero); - __m128 And0 = _mm_and_ps(Flr0, Cmp0); + __m128 And0 = _mm_and_ps(Sub0, Cmp0); __m128 And1 = _mm_and_ps(Flr1, Cmp1); return _mm_or_ps(And0, And1); From c216e0efb7795e45231d1c70f19da02008e5c151 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 22 May 2011 15:02:09 +0100 Subject: [PATCH 2/3] Merge GCC LLVM and Clang detections --- glm/core/setup.hpp | 62 ++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/glm/core/setup.hpp b/glm/core/setup.hpp index 7f74d979..38192aa5 100644 --- a/glm/core/setup.hpp +++ b/glm/core/setup.hpp @@ -43,6 +43,8 @@ // GCC defines #define GLM_COMPILER_GCC 0x02000000 +#define GLM_COMPILER_GCC_LLVM 0x02000000 +#define GLM_COMPILER_GCC_CLANG 0x02000000 #define GLM_COMPILER_GCC30 0x02000010 #define GLM_COMPILER_GCC31 0x02000020 #define GLM_COMPILER_GCC32 0x02000030 @@ -130,22 +132,19 @@ # define GLM_COMPILER GLM_COMPILER_VC # endif//_MSC_VER -#elif defined(__clang__) -# if (__clang_major__ == 2) && (__clang_minor__ == 6) -# define GLM_COMPILER GLM_COMPILER_CLANG26 -# elif (__clang_major__ == 2) && (__clang_minor__ == 7) -# define GLM_COMPILER GLM_COMPILER_CLANG27 -# elif (__clang_major__ == 2) && (__clang_minor__ == 8) -# define GLM_COMPILER GLM_COMPILER_CLANG28 -# elif (__clang_major__ == 2) && (__clang_minor__ == 9) -# define GLM_COMPILER GLM_COMPILER_CLANG29 -# endif - -#elif defined(__llvm__) -# define GLM_COMPILER GLM_COMPILER_LLVM_GCC - // G++ -#elif defined(__GNUC__) +#elif defined(__GNUC__) || defined(__llvm__) || defined(__clang__) +# if defined (__llvm__) +# pragma message("LLVM") +# define GLM_COMPILER_GCC_EXTRA GLM_COMPILER_GCC_LLVM +# elif defined (__clang__) +# pragma message("CLANG") +# define GLM_COMPILER_GCC_EXTRA GLM_COMPILER_GCC_CLANG +# else +# pragma message("GCC") +# define GLM_COMPILER_GCC_EXTRA 0 +# endif +# # if (__GNUC__ == 3) && (__GNUC_MINOR__ == 2) # define GLM_COMPILER GLM_COMPILER_GCC32 # elif (__GNUC__ == 3) && (__GNUC_MINOR__ == 3) @@ -155,29 +154,29 @@ # elif (__GNUC__ == 3) && (__GNUC_MINOR__ == 5) # define GLM_COMPILER GLM_COMPILER_GCC35 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 0) -# define GLM_COMPILER GLM_COMPILER_GCC40 +# define GLM_COMPILER (GLM_COMPILER_GCC40 | GLM_COMPILER_GCC_EXTRA) # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 1) -# define GLM_COMPILER GLM_COMPILER_GCC41 +# define GLM_COMPILER (GLM_COMPILER_GCC41 | GLM_COMPILER_GCC_EXTRA) # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) -# define GLM_COMPILER GLM_COMPILER_GCC42 +# define GLM_COMPILER (GLM_COMPILER_GCC42 | GLM_COMPILER_GCC_EXTRA) # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 3) -# define GLM_COMPILER GLM_COMPILER_GCC43 +# define GLM_COMPILER (GLM_COMPILER_GCC43 | GLM_COMPILER_GCC_EXTRA) # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 4) -# define GLM_COMPILER GLM_COMPILER_GCC44 +# define GLM_COMPILER (GLM_COMPILER_GCC44 | GLM_COMPILER_GCC_EXTRA) # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 5) -# define GLM_COMPILER GLM_COMPILER_GCC45 +# define GLM_COMPILER (GLM_COMPILER_GCC45 | GLM_COMPILER_GCC_EXTRA) # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 6) -# define GLM_COMPILER GLM_COMPILER_GCC46 +# define GLM_COMPILER (GLM_COMPILER_GCC46 | GLM_COMPILER_GCC_EXTRA) # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 7) -# define GLM_COMPILER GLM_COMPILER_GCC47 +# define GLM_COMPILER (GLM_COMPILER_GCC47 | GLM_COMPILER_GCC_EXTRA) # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) -# define GLM_COMPILER GLM_COMPILER_GCC48 +# define GLM_COMPILER (GLM_COMPILER_GCC48 | GLM_COMPILER_GCC_EXTRA) # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 9) -# define GLM_COMPILER GLM_COMPILER_GCC49 +# define GLM_COMPILER (GLM_COMPILER_GCC49 | GLM_COMPILER_GCC_EXTRA) # elif (__GNUC__ == 5) && (__GNUC_MINOR__ == 0) -# define GLM_COMPILER GLM_COMPILER_GCC50 +# define GLM_COMPILER (GLM_COMPILER_GCC50 | GLM_COMPILER_GCC_EXTRA) # else -# define GLM_COMPILER GLM_COMPILER_GCC +# define GLM_COMPILER (GLM_COMPILER_GCC | GLM_COMPILER_GCC_EXTRA) # endif // Borland C++ @@ -218,7 +217,13 @@ # elif(GLM_COMPILER & GLM_COMPILER_LLVM_GCC) # pragma message("GLM: LLVM GCC compiler detected") # elif(GLM_COMPILER & GLM_COMPILER_GCC) -# pragma message("GLM: GCC compiler detected") +# if(GLM_COMPILER & GLM_COMPILER_GCC_LLVM) +# pragma message("GLM: LLVM GCC compiler detected") +# elif(GLM_COMPILER & GLM_COMPILER_GCC_CLANG) +# pragma message("GLM: CLANG compiler detected") +# else +# pragma message("GLM: GCC compiler detected") +# endif # elif(GLM_COMPILER & GLM_COMPILER_BC) # pragma message("GLM: Borland compiler detected but not supported") # elif(GLM_COMPILER & GLM_COMPILER_CODEWARRIOR) @@ -339,7 +344,6 @@ # define GLM_ARCH GLM_ARCH_PURE # endif #elif((GLM_COMPILER & GLM_COMPILER_GCC) && (defined(__i386__) || defined(__x86_64__))) -# error "GCC" # if(defined(__AVX__)) # define GLM_ARCH GLM_ARCH_AVX # elif(defined(__SSE3__)) From 7064dbd3a0b6be01218821c0a96087891640bc94 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 22 May 2011 16:21:48 +0100 Subject: [PATCH 3/3] Fixing swizzle operator on Clang... WIP --- glm/gtc/swizzle.hpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/glm/gtc/swizzle.hpp b/glm/gtc/swizzle.hpp index b3441326..b2e46b89 100644 --- a/glm/gtc/swizzle.hpp +++ b/glm/gtc/swizzle.hpp @@ -75,7 +75,7 @@ namespace swizzle ///< GLM_GTC_swizzle extension template \ GLM_FUNC_QUALIFIER TYPE& swizzle(detail::tvec##SIZE & v) \ {return v[x];} - +/* static_swizzle1(detail::float16, 2) static_swizzle1(detail::float16, 3) static_swizzle1(detail::float16, 4) @@ -126,32 +126,34 @@ namespace swizzle ///< GLM_GTC_swizzle extension template \ GLM_FUNC_QUALIFIER TYPE swizzle(TYPE const & v) \ {return TYPE(v[x], v[y], v[z], v[w]);} -/* -# define static_swizzle2_const(TYPE, SIZE) \ +*/ + +# define static_swizzle2_const(TYPE, SIZE) \ template \ GLM_FUNC_QUALIFIER detail::tvec2 swizzle(detail::tvec##SIZE const & v) \ {return detail::tvec2(v[x], v[y]);} -# define static_swizzle3_const(TYPE, SIZE) \ +# define static_swizzle3_const(TYPE, SIZE) \ template \ GLM_FUNC_QUALIFIER detail::tvec3 swizzle(detail::tvec##SIZE const & v) \ {return detail::tvec3(v[x], v[y], v[z]);} -# define static_swizzle4_const(TYPE, SIZE) \ +# define static_swizzle4_const(TYPE, SIZE) \ template \ GLM_FUNC_QUALIFIER detail::tvec4 swizzle(detail::tvec##SIZE const & v) \ {return detail::tvec4(v[x], v[y], v[z], v[w]);} -*/ - static_swizzle2_const(glm::f16vec2) - static_swizzle2_const(glm::f16vec3) - static_swizzle2_const(glm::f16vec4) - static_swizzle2_const(glm::f32vec2) - static_swizzle2_const(glm::f32vec3) - static_swizzle2_const(glm::f32vec4) - static_swizzle2_const(glm::f64vec2) - static_swizzle2_const(glm::f64vec3) - static_swizzle2_const(glm::f64vec4) + + static_swizzle2_const(glm::f16vec2, 2) + static_swizzle2_const(glm::f16vec3, 3) + static_swizzle2_const(glm::f16vec4, 4) + static_swizzle2_const(glm::f32vec2, 2) + static_swizzle2_const(glm::f32vec3, 3) + static_swizzle2_const(glm::f32vec4, 4) + static_swizzle2_const(glm::f64vec2, 2) + static_swizzle2_const(glm::f64vec3, 3) + static_swizzle2_const(glm::f64vec4, 4) +/* static_swizzle2_const(glm::i8vec2) static_swizzle2_const(glm::i8vec3) static_swizzle2_const(glm::i8vec4) @@ -339,7 +341,7 @@ namespace swizzle ///< GLM_GTC_swizzle extension static_swizzle4_ref(glm::u16vec4) static_swizzle4_ref(glm::u32vec4) static_swizzle4_ref(glm::u64vec4) - +*/ }//namespace swizzle }//namespace gtc }//namespace glm