From 899f388921b75f20d9040b70d561d2437c73cf37 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 16 Mar 2014 02:39:36 +0100 Subject: [PATCH] Fixed CUDA issues (#169, #168, #183, #182) --- glm/detail/func_exponential.inl | 8 ++--- glm/ext.hpp | 4 ++- glm/gtc/matrix_transform.inl | 21 ------------- glm/gtc/ulp.inl | 42 ++++++++++++++++++-------- glm/gtx/bit.inl | 52 ++++++++++++++++----------------- glm/gtx/compatibility.hpp | 8 ++--- glm/gtx/compatibility.inl | 14 ++++----- glm/gtx/dual_quaternion.hpp | 14 ++++----- glm/gtx/int_10_10_10_2.hpp | 2 +- glm/gtx/string_cast.hpp | 5 ++++ glm/gtx/string_cast.inl | 6 ++-- glm/gtx/vector_query.inl | 4 ++- readme.txt | 2 ++ 13 files changed, 94 insertions(+), 88 deletions(-) diff --git a/glm/detail/func_exponential.inl b/glm/detail/func_exponential.inl index 75537589..3a2f2379 100644 --- a/glm/detail/func_exponential.inl +++ b/glm/detail/func_exponential.inl @@ -160,7 +160,7 @@ namespace detail template struct compute_sqrt { - static detail::tvec1 call(detail::tvec1 const & x) + GLM_FUNC_QUALIFIER static detail::tvec1 call(detail::tvec1 const & x) { return detail::tvec1(std::sqrt(x.x)); } @@ -169,7 +169,7 @@ namespace detail template struct compute_sqrt { - static detail::tvec2 call(detail::tvec2 const & x) + GLM_FUNC_QUALIFIER static detail::tvec2 call(detail::tvec2 const & x) { return detail::tvec2(std::sqrt(x.x), std::sqrt(x.y)); } @@ -178,7 +178,7 @@ namespace detail template struct compute_sqrt { - static detail::tvec3 call(detail::tvec3 const & x) + GLM_FUNC_QUALIFIER static detail::tvec3 call(detail::tvec3 const & x) { return detail::tvec3(std::sqrt(x.x), std::sqrt(x.y), std::sqrt(x.z)); } @@ -187,7 +187,7 @@ namespace detail template struct compute_sqrt { - static detail::tvec4 call(detail::tvec4 const & x) + GLM_FUNC_QUALIFIER static detail::tvec4 call(detail::tvec4 const & x) { return detail::tvec4(std::sqrt(x.x), std::sqrt(x.y), std::sqrt(x.z), std::sqrt(x.w)); } diff --git a/glm/ext.hpp b/glm/ext.hpp index 3095dd7f..d2828285 100644 --- a/glm/ext.hpp +++ b/glm/ext.hpp @@ -120,7 +120,9 @@ #include "./gtx/rotate_vector.hpp" #include "./gtx/spline.hpp" #include "./gtx/std_based_type.hpp" -#include "./gtx/string_cast.hpp" +#if(!(GLM_COMPILER & GLM_COMPILER_CUDA)) +# include "./gtx/string_cast.hpp" +#endif #include "./gtx/transform.hpp" #include "./gtx/transform2.hpp" #include "./gtx/vec1.hpp" diff --git a/glm/gtc/matrix_transform.inl b/glm/gtc/matrix_transform.inl index 78c9ce85..25f13751 100644 --- a/glm/gtc/matrix_transform.inl +++ b/glm/gtc/matrix_transform.inl @@ -44,27 +44,6 @@ namespace glm return Result; } - - template - GLM_FUNC_QUALIFIER detail::tmat4x4 translate_slow - ( - detail::tmat4x4 const & m, - detail::tvec3 const & v - ) - { - detail::tmat4x4 Result(T(1)); - Result[3] = detail::tvec4(v, T(1)); - return m * Result; - - //detail::tmat4x4 Result(m); - Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3]; - //Result[3][0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2] + m[3][0]; - //Result[3][1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2] + m[3][1]; - //Result[3][2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2] + m[3][2]; - //Result[3][3] = m[0][3] * v[0] + m[1][3] * v[1] + m[2][3] * v[2] + m[3][3]; - //return Result; - } - template GLM_FUNC_QUALIFIER detail::tmat4x4 rotate ( diff --git a/glm/gtc/ulp.inl b/glm/gtc/ulp.inl index 0087e444..6483be14 100644 --- a/glm/gtc/ulp.inl +++ b/glm/gtc/ulp.inl @@ -194,24 +194,30 @@ namespace detail # pragma warning(pop) #endif -#if((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))) -# define GLM_NEXT_AFTER_FLT(x, toward) glm::detail::nextafterf((x), (toward)) -# define GLM_NEXT_AFTER_DBL(x, toward) _nextafter((x), (toward)) -#else -# define GLM_NEXT_AFTER_FLT(x, toward) nextafterf((x), (toward)) -# define GLM_NEXT_AFTER_DBL(x, toward) nextafter((x), (toward)) -#endif - namespace glm { + template <> GLM_FUNC_QUALIFIER float next_float(float const & x) { - return GLM_NEXT_AFTER_FLT(x, std::numeric_limits::max()); +# if((GLM_LANG & GLM_LANG_CXX11_FLAG)) + return std::nextafter(x, std::numeric_limits::max()); +# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))) + return detail::nextafterf(x, FLT_MAX); +# else + return nextafterf(x, FLT_MAX); +# endif } + template <> GLM_FUNC_QUALIFIER double next_float(double const & x) { - return GLM_NEXT_AFTER_DBL(x, std::numeric_limits::max()); +# if((GLM_LANG & GLM_LANG_CXX11_FLAG)) + return std::nextafter(x, std::numeric_limits::max()); +# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))) + return detail::nextafterf(x, std::numeric_limits::max()); +# else + return nextafter(x, DBL_MAX); +# endif } template class vecType> @@ -225,12 +231,24 @@ namespace glm GLM_FUNC_QUALIFIER float prev_float(float const & x) { - return GLM_NEXT_AFTER_FLT(x, std::numeric_limits::min()); +# if((GLM_LANG & GLM_LANG_CXX11_FLAG)) + return std::nextafter(x, std::numeric_limits::min()); +# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))) + return detail::nextafterf(x, FLT_MIN); +# else + return nextafterf(x, FLT_MIN); +# endif } GLM_FUNC_QUALIFIER double prev_float(double const & x) { - return GLM_NEXT_AFTER_DBL(x, std::numeric_limits::min()); +# if((GLM_LANG & GLM_LANG_CXX11_FLAG)) + return std::nextafter(x, std::numeric_limits::min()); +# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))) + return _nextafter(x, DBL_MIN); +# else + return nextafter(x, DBL_MIN); +# endif } template class vecType> diff --git a/glm/gtx/bit.inl b/glm/gtx/bit.inl index d34d068f..541ae7a8 100644 --- a/glm/gtx/bit.inl +++ b/glm/gtx/bit.inl @@ -312,13 +312,13 @@ namespace glm namespace detail { template - RET bitfieldInterleave(PARAM x, PARAM y); + GLM_FUNC_DECL RET bitfieldInterleave(PARAM x, PARAM y); template - RET bitfieldInterleave(PARAM x, PARAM y, PARAM z); + GLM_FUNC_DECL RET bitfieldInterleave(PARAM x, PARAM y, PARAM z); template - RET bitfieldInterleave(PARAM x, PARAM y, PARAM z, PARAM w); + GLM_FUNC_DECL RET bitfieldInterleave(PARAM x, PARAM y, PARAM z, PARAM w); /* template @@ -358,7 +358,7 @@ namespace glm } */ template <> - inline glm::uint16 bitfieldInterleave(glm::uint8 x, glm::uint8 y) + GLM_FUNC_QUALIFIER glm::uint16 bitfieldInterleave(glm::uint8 x, glm::uint8 y) { glm::uint16 REG1(x); glm::uint16 REG2(y); @@ -376,7 +376,7 @@ namespace glm } template <> - inline glm::uint32 bitfieldInterleave(glm::uint16 x, glm::uint16 y) + GLM_FUNC_QUALIFIER glm::uint32 bitfieldInterleave(glm::uint16 x, glm::uint16 y) { glm::uint32 REG1(x); glm::uint32 REG2(y); @@ -397,7 +397,7 @@ namespace glm } template <> - inline glm::uint64 bitfieldInterleave(glm::uint32 x, glm::uint32 y) + GLM_FUNC_QUALIFIER glm::uint64 bitfieldInterleave(glm::uint32 x, glm::uint32 y) { glm::uint64 REG1(x); glm::uint64 REG2(y); @@ -421,7 +421,7 @@ namespace glm } template <> - inline glm::uint64 bitfieldInterleave(glm::uint32 x, glm::uint32 y, glm::uint32 z) + GLM_FUNC_QUALIFIER glm::uint64 bitfieldInterleave(glm::uint32 x, glm::uint32 y, glm::uint32 z) { glm::uint64 REG1(x); glm::uint64 REG2(y); @@ -451,7 +451,7 @@ namespace glm } template <> - inline glm::uint64 bitfieldInterleave(glm::uint16 x, glm::uint16 y, glm::uint16 z, glm::uint16 w) + GLM_FUNC_QUALIFIER glm::uint64 bitfieldInterleave(glm::uint16 x, glm::uint16 y, glm::uint16 z, glm::uint16 w) { glm::uint64 REG1(x); glm::uint64 REG2(y); @@ -482,7 +482,7 @@ namespace glm } }//namespace detail - inline int16 bitfieldInterleave(int8 x, int8 y) + GLM_FUNC_QUALIFIER int16 bitfieldInterleave(int8 x, int8 y) { union sign8 { @@ -503,12 +503,12 @@ namespace glm return result.i; } - inline uint16 bitfieldInterleave(uint8 x, uint8 y) + GLM_FUNC_QUALIFIER uint16 bitfieldInterleave(uint8 x, uint8 y) { return detail::bitfieldInterleave(x, y); } - inline int32 bitfieldInterleave(int16 x, int16 y) + GLM_FUNC_QUALIFIER int32 bitfieldInterleave(int16 x, int16 y) { union sign16 { @@ -529,12 +529,12 @@ namespace glm return result.i; } - inline uint32 bitfieldInterleave(uint16 x, uint16 y) + GLM_FUNC_QUALIFIER uint32 bitfieldInterleave(uint16 x, uint16 y) { return detail::bitfieldInterleave(x, y); } - inline int64 bitfieldInterleave(int32 x, int32 y) + GLM_FUNC_QUALIFIER int64 bitfieldInterleave(int32 x, int32 y) { union sign32 { @@ -555,12 +555,12 @@ namespace glm return result.i; } - inline uint64 bitfieldInterleave(uint32 x, uint32 y) + GLM_FUNC_QUALIFIER uint64 bitfieldInterleave(uint32 x, uint32 y) { return detail::bitfieldInterleave(x, y); } - inline int32 bitfieldInterleave(int8 x, int8 y, int8 z) + GLM_FUNC_QUALIFIER int32 bitfieldInterleave(int8 x, int8 y, int8 z) { union sign8 { @@ -582,12 +582,12 @@ namespace glm return result.i; } - inline uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z) + GLM_FUNC_QUALIFIER uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z) { return detail::bitfieldInterleave(x, y, z); } - inline int64 bitfieldInterleave(int16 x, int16 y, int16 z) + GLM_FUNC_QUALIFIER int64 bitfieldInterleave(int16 x, int16 y, int16 z) { union sign16 { @@ -609,12 +609,12 @@ namespace glm return result.i; } - inline uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z) + GLM_FUNC_QUALIFIER uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z) { return detail::bitfieldInterleave(x, y, z); } - inline int64 bitfieldInterleave(int32 x, int32 y, int32 z) + GLM_FUNC_QUALIFIER int64 bitfieldInterleave(int32 x, int32 y, int32 z) { union sign16 { @@ -636,12 +636,12 @@ namespace glm return result.i; } - inline uint64 bitfieldInterleave(uint32 x, uint32 y, uint32 z) + GLM_FUNC_QUALIFIER uint64 bitfieldInterleave(uint32 x, uint32 y, uint32 z) { return detail::bitfieldInterleave(x, y, z); } - inline int32 bitfieldInterleave(int8 x, int8 y, int8 z, int8 w) + GLM_FUNC_QUALIFIER int32 bitfieldInterleave(int8 x, int8 y, int8 z, int8 w) { union sign8 { @@ -659,17 +659,17 @@ namespace glm sign_y.i = y; sign_z.i = z; sign_w.i = w; - result.u = bitfieldInterleave(sign_x.u, sign_y.u, sign_z.u); + result.u = bitfieldInterleave(sign_x.u, sign_y.u, sign_z.u, sign_w.u); return result.i; } - inline uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z, uint8 w) + GLM_FUNC_QUALIFIER uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z, uint8 w) { return detail::bitfieldInterleave(x, y, z, w); } - inline int64 bitfieldInterleave(int16 x, int16 y, int16 z, int16 w) + GLM_FUNC_QUALIFIER int64 bitfieldInterleave(int16 x, int16 y, int16 z, int16 w) { union sign16 { @@ -687,12 +687,12 @@ namespace glm sign_y.i = y; sign_z.i = z; sign_w.i = w; - result.u = bitfieldInterleave(sign_x.u, sign_y.u, sign_z.u); + result.u = bitfieldInterleave(sign_x.u, sign_y.u, sign_z.u, sign_w.u); return result.i; } - inline uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z, uint16 w) + GLM_FUNC_QUALIFIER uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z, uint16 w) { return detail::bitfieldInterleave(x, y, z, w); } diff --git a/glm/gtx/compatibility.hpp b/glm/gtx/compatibility.hpp index 18cbd3da..c262e3fc 100644 --- a/glm/gtx/compatibility.hpp +++ b/glm/gtx/compatibility.hpp @@ -82,10 +82,10 @@ namespace glm template GLM_FUNC_QUALIFIER detail::tvec3 atan2(const detail::tvec3& x, const detail::tvec3& y){return atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility) template GLM_FUNC_QUALIFIER detail::tvec4 atan2(const detail::tvec4& x, const detail::tvec4& y){return atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility) - template bool isfinite(genType const & x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) - template detail::tvec2 isfinite(const detail::tvec2& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) - template detail::tvec3 isfinite(const detail::tvec3& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) - template detail::tvec4 isfinite(const detail::tvec4& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) + template GLM_FUNC_DECL bool isfinite(genType const & x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) + template GLM_FUNC_DECL detail::tvec2 isfinite(const detail::tvec2& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) + template GLM_FUNC_DECL detail::tvec3 isfinite(const detail::tvec3& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) + template GLM_FUNC_DECL detail::tvec4 isfinite(const detail::tvec4& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) typedef bool bool1; //!< \brief boolean type with 1 component. (From GLM_GTX_compatibility extension) typedef detail::tvec2 bool2; //!< \brief boolean type with 2 components. (From GLM_GTX_compatibility extension) diff --git a/glm/gtx/compatibility.inl b/glm/gtx/compatibility.inl index 947945ad..d08ffb82 100644 --- a/glm/gtx/compatibility.inl +++ b/glm/gtx/compatibility.inl @@ -14,16 +14,14 @@ namespace glm GLM_FUNC_QUALIFIER bool isfinite( genType const & x) { -# if(GLM_COMPILER & GLM_COMPILER_VC) +# if(GLM_LANG & GLM_LANG_CXX11_FLAG) + return std::isfinite(x) != 0; +# elif(GLM_COMPILER & GLM_COMPILER_VC) return _finite(x); -# elif(GLM_COMPILER & GLM_COMPILER_GCC) -# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID) - return _isfinite(x) != 0; -# else - return std::isfinite(x) != 0; -# endif +# elif(GLM_COMPILER & GLM_COMPILER_GCC && GLM_PLATFORM & GLM_PLATFORM_ANDROID) + return _isfinite(x) != 0; # else - return std::isfinite(x) != 0; + return isfinite(x) != 0; # endif } diff --git a/glm/gtx/dual_quaternion.hpp b/glm/gtx/dual_quaternion.hpp index c674e259..c7c6c50a 100644 --- a/glm/gtx/dual_quaternion.hpp +++ b/glm/gtx/dual_quaternion.hpp @@ -142,14 +142,14 @@ namespace detail /// /// @see gtc_dual_quaternion template - detail::tdualquat normalize( + GLM_FUNC_DECL detail::tdualquat normalize( detail::tdualquat const & q); /// Returns the linear interpolation of two dual quaternion. /// /// @see gtc_dual_quaternion template - detail::tdualquat lerp( + GLM_FUNC_DECL detail::tdualquat lerp( detail::tdualquat const & x, detail::tdualquat const & y, T const & a); @@ -158,7 +158,7 @@ namespace detail /// /// @see gtc_dual_quaternion template - detail::tdualquat inverse( + GLM_FUNC_DECL detail::tdualquat inverse( detail::tdualquat const & q); /* @@ -175,28 +175,28 @@ namespace detail /// /// @see gtc_dual_quaternion template - detail::tmat2x4 mat2x4_cast( + GLM_FUNC_DECL detail::tmat2x4 mat2x4_cast( detail::tdualquat const & x); /// Converts a quaternion to a 3 * 4 matrix. /// /// @see gtc_dual_quaternion template - detail::tmat3x4 mat3x4_cast( + GLM_FUNC_DECL detail::tmat3x4 mat3x4_cast( detail::tdualquat const & x); /// Converts a 2 * 4 matrix (matrix which holds real and dual parts) to a quaternion. /// /// @see gtc_dual_quaternion template - detail::tdualquat dualquat_cast( + GLM_FUNC_DECL detail::tdualquat dualquat_cast( detail::tmat2x4 const & x); /// Converts a 3 * 4 matrix (augmented matrix rotation + translation) to a quaternion. /// /// @see gtc_dual_quaternion template - detail::tdualquat dualquat_cast( + GLM_FUNC_DECL detail::tdualquat dualquat_cast( detail::tmat3x4 const & x); diff --git a/glm/gtx/int_10_10_10_2.hpp b/glm/gtx/int_10_10_10_2.hpp index 49175305..c6f1faf7 100644 --- a/glm/gtx/int_10_10_10_2.hpp +++ b/glm/gtx/int_10_10_10_2.hpp @@ -35,7 +35,7 @@ namespace glm { //! Deprecated, use packUnorm3x10_1x2 instead. - GLM_DEPRECATED dword uint10_10_10_2_cast(glm::vec4 const & v); + GLM_DEPRECATED GLM_FUNC_DECL dword uint10_10_10_2_cast(glm::vec4 const & v); }//namespace glm diff --git a/glm/gtx/string_cast.hpp b/glm/gtx/string_cast.hpp index 1437d66f..bf73e7d3 100644 --- a/glm/gtx/string_cast.hpp +++ b/glm/gtx/string_cast.hpp @@ -36,6 +36,7 @@ /// @brief Setup strings for GLM type values /// /// need to be included to use these functionalities. +/// This extension is not supported with CUDA /////////////////////////////////////////////////////////////////////////////////// #ifndef GLM_GTX_string_cast @@ -47,6 +48,10 @@ #include "../gtx/quaternion.hpp" #include +#if(GLM_COMPILER & GLM_COMPILER_CUDA) +# error "GLM_GTX_string_cast is not supported on CUDA compiler" +#endif + #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) # pragma message("GLM: GLM_GTX_string_cast extension included") #endif diff --git a/glm/gtx/string_cast.inl b/glm/gtx/string_cast.inl index de714ceb..39b2fd78 100644 --- a/glm/gtx/string_cast.inl +++ b/glm/gtx/string_cast.inl @@ -23,11 +23,11 @@ namespace detail return std::string(); va_start(list, msg); -#if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC8)) +# if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC8)) vsprintf_s(text, STRING_BUFFER, msg, list); -#else// +# else// vsprintf(text, msg, list); -#endif// +# endif// va_end(list); return std::string(text); diff --git a/glm/gtx/vector_query.inl b/glm/gtx/vector_query.inl index 512b4f06..801ae64d 100644 --- a/glm/gtx/vector_query.inl +++ b/glm/gtx/vector_query.inl @@ -156,7 +156,9 @@ namespace detail detail::tvec2 const & v, T const & epsilon) { - + return detail::tvec2( + abs(v.x) < epsilon, + abs(v.y) < epsilon); } template diff --git a/readme.txt b/readme.txt index fccddb65..d47557b2 100644 --- a/readme.txt +++ b/readme.txt @@ -44,6 +44,8 @@ GLM 0.9.5.3: 2014-0X-XX - Fixed GTX_raw_data code dependency - Fixed GCC instruction set detection - Added GLM_GTX_matrix_transform_2d extension (#178, #176) +- Fixed CUDA issues (#169, #168, #183, #182) +- Added support for all extensions but GTX_string_cast to CUDA ================================================================================ GLM 0.9.5.2: 2014-02-08