From bcf1a723928c5a8b73d5e2241612f298b3d6fcf1 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 8 Dec 2014 21:45:14 +0100 Subject: [PATCH 1/4] Fixed libc++ detection #284 --- glm/detail/setup.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index a32406d5..42b6beee 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -453,9 +453,11 @@ // http://msdn.microsoft.com/en-us/library/vstudio/hh567368(v=vs.120).aspx // N1720 -#define GLM_HAS_CXX11_STL ( \ - (GLM_LANG & GLM_LANG_CXX11_FLAG) || \ - ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2015))) +#if GLM_COMPILER & GLM_COMPILER_CLANG +# define GLM_HAS_CXX11_STL (GLM_LANG & GLM_LANG_CXX11_FLAG) && __has_include(<__config>) +#else +# define GLM_HAS_CXX11_STL (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2015) +#endif // N1720 #define GLM_HAS_STATIC_ASSERT ( \ From c1180c804c75aa10c101293cf7ca57a461fde500 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 1 Dec 2014 01:12:03 +0100 Subject: [PATCH 2/4] New organization idea for SIMD support --- glm/detail/type_vec4.inl | 10 +++++++++ glm/detail/type_vec4_avx.inl | 41 +++++++++++++++++++++++++++++++++++ glm/detail/type_vec4_avx2.inl | 41 +++++++++++++++++++++++++++++++++++ glm/detail/type_vec4_sse2.inl | 41 +++++++++++++++++++++++++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 glm/detail/type_vec4_avx.inl create mode 100644 glm/detail/type_vec4_avx2.inl create mode 100644 glm/detail/type_vec4_sse2.inl diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index f14b9cf2..6509efb8 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -1187,3 +1187,13 @@ namespace glm ~v.w); } }//namespace glm + +#if GLM_ARCH & GLM_ARCH_SSE2 +# include "type_vec4_sse2.inl" +#endif +#if GLM_ARCH & GLM_ARCH_AVX +# include "type_vec4_avx.inl" +#endif +#if GLM_ARCH & GLM_ARCH_AVX2 +# include "type_vec4_avx2.inl" +#endif diff --git a/glm/detail/type_vec4_avx.inl b/glm/detail/type_vec4_avx.inl new file mode 100644 index 00000000..509f6675 --- /dev/null +++ b/glm/detail/type_vec4_avx.inl @@ -0,0 +1,41 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// Restrictions: +/// By making use of the Software for military purposes, you choose to make +/// a Bunny unhappy. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/detail/type_tvec4_avx.inl +/// @date 2014-12-01 / 2014-12-01 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +namespace glm{ +namespace detail +{ + +}//namespace detail + + + +}//namespace glm diff --git a/glm/detail/type_vec4_avx2.inl b/glm/detail/type_vec4_avx2.inl new file mode 100644 index 00000000..28232504 --- /dev/null +++ b/glm/detail/type_vec4_avx2.inl @@ -0,0 +1,41 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// Restrictions: +/// By making use of the Software for military purposes, you choose to make +/// a Bunny unhappy. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/detail/type_tvec4_avx2.inl +/// @date 2014-12-01 / 2014-12-01 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +namespace glm{ +namespace detail +{ + +}//namespace detail + + + +}//namespace glm diff --git a/glm/detail/type_vec4_sse2.inl b/glm/detail/type_vec4_sse2.inl new file mode 100644 index 00000000..eb7b3d6b --- /dev/null +++ b/glm/detail/type_vec4_sse2.inl @@ -0,0 +1,41 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// Restrictions: +/// By making use of the Software for military purposes, you choose to make +/// a Bunny unhappy. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/detail/type_tvec4_sse2.inl +/// @date 2014-12-01 / 2014-12-01 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +namespace glm{ +namespace detail +{ + +}//namespace detail + + + +}//namespace glm From 459fe3a3fe7688fc5a8df307fc62450f5253516a Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 8 Dec 2014 23:21:59 +0100 Subject: [PATCH 3/4] Fixed Android build issue, STL C++11 is not supported by the NDK #284 --- glm/detail/setup.hpp | 6 ++++++ readme.txt | 1 + 2 files changed, 7 insertions(+) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 42b6beee..c26334f5 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -453,11 +453,17 @@ // http://msdn.microsoft.com/en-us/library/vstudio/hh567368(v=vs.120).aspx // N1720 +/* #if GLM_COMPILER & GLM_COMPILER_CLANG # define GLM_HAS_CXX11_STL (GLM_LANG & GLM_LANG_CXX11_FLAG) && __has_include(<__config>) #else # define GLM_HAS_CXX11_STL (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2015) #endif +*/ +#define GLM_HAS_CXX11_STL ((GLM_PLATFORM != GLM_PLATFORM_ANDROID) && (\ + (GLM_LANG & GLM_LANG_CXX11_FLAG) || \ + ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \ + ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2015)))) // N1720 #define GLM_HAS_STATIC_ASSERT ( \ diff --git a/readme.txt b/readme.txt index 5027ddff..2bef34ca 100644 --- a/readme.txt +++ b/readme.txt @@ -69,6 +69,7 @@ Fixes: - Fixed scalar uaddCarry build error with Cuda #276 - Fixed C++11 explicit conversion operators detection #282 - Fixed missing explicit convertion when using integer log2 with *vec1 types +- Fixed Android build issue, STL C++11 is not supported by the NDK #284 ================================================================================ GLM 0.9.6.0: 2014-11-30 From ff006034dfaabc11860084fe0c4478061cda8db9 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 8 Dec 2014 23:49:14 +0100 Subject: [PATCH 4/4] Fixed unsupported _BitScanForward64 and _BitScanReverse64 in VC10, Fixed Visual C++ 32 bit build #283 --- glm/detail/func_integer.inl | 20 +++++--- glm/detail/type_vec4.hpp | 8 +-- glm/detail/type_vec4.inl | 94 +---------------------------------- glm/detail/type_vec4_sse2.inl | 79 +++++++++++++++++++++++++++++ readme.txt | 2 + 5 files changed, 100 insertions(+), 103 deletions(-) diff --git a/glm/detail/func_integer.inl b/glm/detail/func_integer.inl index cc1c4d33..eead6f9a 100644 --- a/glm/detail/func_integer.inl +++ b/glm/detail/func_integer.inl @@ -116,6 +116,7 @@ namespace detail } }; +# if !((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER < GLM_COMPILER_VC2013) && (GLM_MODEL == GLM_MODEL_32)) template struct compute_findLSB { @@ -126,6 +127,7 @@ namespace detail return IsNotNull ? int(Result) : -1; } }; +# endif # endif//GLM_HAS_BITSCAN_WINDOWS template class vecType, bool EXEC = true> @@ -171,14 +173,6 @@ namespace detail return IsNotNull ? int(Result) : -1; } - template - GLM_FUNC_QUALIFIER int compute_findMSB_64(genIUType Value) - { - unsigned long Result(0); - unsigned char IsNotNull = _BitScanReverse64(&Result, *reinterpret_cast(&Value)); - return IsNotNull ? int(Result) : -1; - } - template class vecType> struct compute_findMSB_vec { @@ -188,6 +182,15 @@ namespace detail } }; +# if !((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER < GLM_COMPILER_VC2013) && (GLM_MODEL == GLM_MODEL_32)) + template + GLM_FUNC_QUALIFIER int compute_findMSB_64(genIUType Value) + { + unsigned long Result(0); + unsigned char IsNotNull = _BitScanReverse64(&Result, *reinterpret_cast(&Value)); + return IsNotNull ? int(Result) : -1; + } + template class vecType> struct compute_findMSB_vec { @@ -196,6 +199,7 @@ namespace detail return detail::functor1::call(compute_findMSB_64, x); } }; +# endif # endif//GLM_HAS_BITSCAN_WINDOWS }//namespace detail diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index b62906a2..95d3f5fe 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -53,7 +53,9 @@ namespace detail typedef T type[4]; }; -# if GLM_ARCH & GLM_ARCH_SSE2 +# define GLM_NOT_BUGGY_VC32BITS !(GLM_MODEL == GLM_MODEL_32 && GLM_COMPILER & GLM_COMPILER_VC && GLM_COMPILER < GLM_COMPILER_VC2013) + +# if GLM_ARCH & GLM_ARCH_SSE2 && GLM_NOT_BUGGY_VC32BITS template <> struct simd { @@ -73,7 +75,7 @@ namespace detail }; # endif -# if GLM_ARCH & GLM_ARCH_AVX +# if GLM_ARCH & GLM_ARCH_AVX && GLM_NOT_BUGGY_VC32BITS template <> struct simd { @@ -81,7 +83,7 @@ namespace detail }; # endif -# if GLM_ARCH & GLM_ARCH_AVX2 +# if GLM_ARCH & GLM_ARCH_AVX2 && GLM_NOT_BUGGY_VC32BITS template <> struct simd { diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 6509efb8..38fb6b5f 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -42,22 +42,6 @@ namespace glm # endif {} -#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2) - template <> - GLM_FUNC_QUALIFIER tvec4::tvec4() -# ifndef GLM_FORCE_NO_CTOR_INIT - : data(_mm_setzero_ps()) -# endif - {} - - template <> - GLM_FUNC_QUALIFIER tvec4::tvec4() -# ifndef GLM_FORCE_NO_CTOR_INIT - : data(_mm_setzero_ps()) -# endif - {} -#endif - template template GLM_FUNC_QUALIFIER tvec4::tvec4(tvec4 const & v) @@ -76,35 +60,11 @@ namespace glm : x(s), y(s), z(s), w(s) {} -#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2) - template <> - GLM_FUNC_QUALIFIER tvec4::tvec4(float s) : - data(_mm_set1_ps(s)) - {} - - template <> - GLM_FUNC_QUALIFIER tvec4::tvec4(float s) : - data(_mm_set1_ps(s)) - {} -#endif - template GLM_FUNC_QUALIFIER tvec4::tvec4(T a, T b, T c, T d) : x(a), y(b), z(c), w(d) {} -#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2) - template <> - GLM_FUNC_QUALIFIER tvec4::tvec4(float a, float b, float c, float d) : - data(_mm_set_ps(d, c, b, a)) - {} - - template <> - GLM_FUNC_QUALIFIER tvec4::tvec4(float a, float b, float c, float d) : - data(_mm_set_ps(d, c, b, a)) - {} -#endif - ////////////////////////////////////// // Conversion scalar constructors @@ -307,40 +267,6 @@ namespace glm return *this; } -#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2) - template <> - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U scalar) - { - this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(scalar))); - return *this; - } - - template <> - template <> - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(float scalar) - { - this->data = _mm_add_ps(this->data, _mm_set_ps1(scalar)); - return *this; - } - - template <> - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U scalar) - { - this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(scalar))); - return *this; - } - - template <> - template <> - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(float scalar) - { - this->data = _mm_add_ps(this->data, _mm_set_ps1(scalar)); - return *this; - } -#endif - template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & v) @@ -353,24 +279,6 @@ namespace glm return *this; } -#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2) - template <> - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & v) - { - this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(v.x))); - return *this; - } - - template <> - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & v) - { - this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(v.x))); - return *this; - } -#endif - template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec4 const & v) @@ -1188,6 +1096,7 @@ namespace glm } }//namespace glm +#if GLM_HAS_ANONYMOUS_UNION && GLM_NOT_BUGGY_VC32BITS #if GLM_ARCH & GLM_ARCH_SSE2 # include "type_vec4_sse2.inl" #endif @@ -1197,3 +1106,4 @@ namespace glm #if GLM_ARCH & GLM_ARCH_AVX2 # include "type_vec4_avx2.inl" #endif +#endif// diff --git a/glm/detail/type_vec4_sse2.inl b/glm/detail/type_vec4_sse2.inl index eb7b3d6b..cacec35a 100644 --- a/glm/detail/type_vec4_sse2.inl +++ b/glm/detail/type_vec4_sse2.inl @@ -36,6 +36,85 @@ namespace detail }//namespace detail + template <> + GLM_FUNC_QUALIFIER tvec4::tvec4() +# ifndef GLM_FORCE_NO_CTOR_INIT + : data(_mm_setzero_ps()) +# endif + {} + template <> + GLM_FUNC_QUALIFIER tvec4::tvec4() +# ifndef GLM_FORCE_NO_CTOR_INIT + : data(_mm_setzero_ps()) +# endif + {} + template <> + GLM_FUNC_QUALIFIER tvec4::tvec4(float s) : + data(_mm_set1_ps(s)) + {} + + template <> + GLM_FUNC_QUALIFIER tvec4::tvec4(float s) : + data(_mm_set1_ps(s)) + {} + + template <> + GLM_FUNC_QUALIFIER tvec4::tvec4(float a, float b, float c, float d) : + data(_mm_set_ps(d, c, b, a)) + {} + + template <> + GLM_FUNC_QUALIFIER tvec4::tvec4(float a, float b, float c, float d) : + data(_mm_set_ps(d, c, b, a)) + {} + + template <> + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U scalar) + { + this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(scalar))); + return *this; + } + + template <> + template <> + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(float scalar) + { + this->data = _mm_add_ps(this->data, _mm_set_ps1(scalar)); + return *this; + } + + template <> + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U scalar) + { + this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(scalar))); + return *this; + } + + template <> + template <> + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(float scalar) + { + this->data = _mm_add_ps(this->data, _mm_set_ps1(scalar)); + return *this; + } + + template <> + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & v) + { + this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(v.x))); + return *this; + } + + template <> + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & v) + { + this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(v.x))); + return *this; + } }//namespace glm diff --git a/readme.txt b/readme.txt index 2bef34ca..7bd57fb4 100644 --- a/readme.txt +++ b/readme.txt @@ -70,6 +70,8 @@ Fixes: - Fixed C++11 explicit conversion operators detection #282 - Fixed missing explicit convertion when using integer log2 with *vec1 types - Fixed Android build issue, STL C++11 is not supported by the NDK #284 +- Fixed unsupported _BitScanForward64 and _BitScanReverse64 in VC10 +- Fixed Visual C++ 32 bit build #283 ================================================================================ GLM 0.9.6.0: 2014-11-30