From a5d2a63ef340597dedd34c1e7095c7e090d80706 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Tue, 1 Apr 2014 01:20:03 +0200 Subject: [PATCH] - Added workaround for a CUDA compiler bug (#186, #185) --- glm/detail/func_exponential.inl | 14 ++++++++++++-- glm/detail/func_geometric.inl | 7 ++++++- glm/gtx/fast_square_root.inl | 14 ++++++++++++-- readme.txt | 1 + 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/glm/detail/func_exponential.inl b/glm/detail/func_exponential.inl index 3a2f2379..767323f7 100644 --- a/glm/detail/func_exponential.inl +++ b/glm/detail/func_exponential.inl @@ -197,12 +197,22 @@ namespace detail // sqrt GLM_FUNC_QUALIFIER float sqrt(float x) { - return detail::compute_sqrt::call(x).x; +# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6 + detail::tvec1 tmp(detail::compute_sqrt::call(x)); + return tmp.x; +# else + return detail::compute_sqrt::call(x).x; +# endif } GLM_FUNC_QUALIFIER double sqrt(double x) { - return detail::compute_sqrt::call(x).x; +# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6 + detail::tvec1 tmp(detail::compute_sqrt::call(x)); + return tmp.x; +# else + return detail::compute_sqrt::call(x).x; +# endif } template class vecType> diff --git a/glm/detail/func_geometric.inl b/glm/detail/func_geometric.inl index 58aca38b..2f8691dd 100644 --- a/glm/detail/func_geometric.inl +++ b/glm/detail/func_geometric.inl @@ -43,7 +43,12 @@ namespace detail { GLM_FUNC_QUALIFIER static T call(detail::tvec1 const & x, detail::tvec1 const & y) { - return detail::tvec1(x * y).x; +# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6 + detail::tvec1 tmp(x * y); + return tmp.x; +# else + return detail::tvec1(x * y).x; +# endif } }; diff --git a/glm/gtx/fast_square_root.inl b/glm/gtx/fast_square_root.inl index b3f97957..a08bdbf2 100644 --- a/glm/gtx/fast_square_root.inl +++ b/glm/gtx/fast_square_root.inl @@ -27,13 +27,23 @@ namespace glm template <> GLM_FUNC_QUALIFIER float fastInverseSqrt(float const & x) { - return detail::compute_inversesqrt::call(detail::tvec1(x)).x; +# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6 + detail::tvec1 tmp(detail::compute_inversesqrt::call(detail::tvec1(x))); + return tmp.x; +# else + return detail::compute_inversesqrt::call(detail::tvec1(x)).x; +# endif } template <> GLM_FUNC_QUALIFIER double fastInverseSqrt(double const & x) { - return detail::compute_inversesqrt::call(detail::tvec1(x)).x; +# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6 + detail::tvec1 tmp(detail::compute_inversesqrt::call(detail::tvec1(x))); + return tmp.x; +# else + return detail::compute_inversesqrt::call(detail::tvec1(x)).x; +# endif } template