From 41984e42ab8b40121014d015aed367565f8c53d8 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 1 Jun 2016 00:43:35 +0200 Subject: [PATCH] Added GTC_type_aligned with aligned *vec* types --- glm/detail/_swizzle.hpp | 18 +- glm/detail/func_common.inl | 84 ++++---- glm/detail/func_common_simd.inl | 40 ++-- glm/detail/func_exponential.inl | 16 +- glm/detail/func_exponential_simd.inl | 8 +- glm/detail/func_geometric.inl | 48 ++--- glm/detail/func_geometric_simd.inl | 16 +- glm/detail/func_integer.inl | 2 +- glm/detail/func_matrix_simd.inl | 12 +- glm/detail/precision.hpp | 37 +++- glm/detail/type_vec4.hpp | 30 +-- glm/detail/type_vec4.inl | 92 ++++---- glm/detail/type_vec4_simd.inl | 102 ++++----- glm/gtc/integer.inl | 8 +- glm/gtc/quaternion.inl | 6 +- glm/gtc/type_aligned.hpp | 303 +++++++++++++++++++++++++++ glm/gtx/fast_square_root.inl | 6 +- readme.md | 2 + test/core/core_type_vec4.cpp | 12 +- test/gtc/CMakeLists.txt | 1 + test/gtc/gtc_type_aligned.cpp | 11 + test/gtc/gtc_type_precision.cpp | 29 --- 22 files changed, 607 insertions(+), 276 deletions(-) create mode 100644 glm/gtc/type_aligned.hpp create mode 100644 test/gtc/gtc_type_aligned.cpp diff --git a/glm/detail/_swizzle.hpp b/glm/detail/_swizzle.hpp index a6b4ab45..8e134d90 100644 --- a/glm/detail/_swizzle.hpp +++ b/glm/detail/_swizzle.hpp @@ -20,25 +20,25 @@ namespace detail char _buffer[1]; }; - template class vecType, int E0, int E1, int E2, int E3> + template class vecType, int E0, int E1, int E2, int E3, bool Aligned> struct _swizzle_base1 : public _swizzle_base0 { }; - template class vecType, int E0, int E1> - struct _swizzle_base1<2, T, P, vecType, E0,E1,-1,-2> : public _swizzle_base0 + template class vecType, int E0, int E1, bool Aligned> + struct _swizzle_base1<2, T, P, vecType, E0,E1,-1,-2, Aligned> : public _swizzle_base0 { GLM_FUNC_QUALIFIER vecType operator ()() const { return vecType(this->elem(E0), this->elem(E1)); } }; - template class vecType, int E0, int E1, int E2> - struct _swizzle_base1<3, T, P, vecType, E0,E1,E2,-1> : public _swizzle_base0 + template class vecType, int E0, int E1, int E2, bool Aligned> + struct _swizzle_base1<3, T, P, vecType, E0,E1,E2,-1, Aligned> : public _swizzle_base0 { GLM_FUNC_QUALIFIER vecType operator ()() const { return vecType(this->elem(E0), this->elem(E1), this->elem(E2)); } }; - template class vecType, int E0, int E1, int E2, int E3> - struct _swizzle_base1<4, T, P, vecType, E0,E1,E2,E3> : public _swizzle_base0 + template class vecType, int E0, int E1, int E2, int E3, bool Aligned> + struct _swizzle_base1<4, T, P, vecType, E0,E1,E2,E3, Aligned> : public _swizzle_base0 { GLM_FUNC_QUALIFIER vecType operator ()() const { return vecType(this->elem(E0), this->elem(E1), this->elem(E2), this->elem(E3)); } }; @@ -56,7 +56,7 @@ namespace detail containing duplicate elements so that they cannot be used as r-values). */ template class vecType, int E0, int E1, int E2, int E3, int DUPLICATE_ELEMENTS> - struct _swizzle_base2 : public _swizzle_base1 + struct _swizzle_base2 : public _swizzle_base1::value> { GLM_FUNC_QUALIFIER _swizzle_base2& operator= (const T& t) { @@ -134,7 +134,7 @@ namespace detail // Specialization for swizzles containing duplicate elements. These cannot be modified. template class vecType, int E0, int E1, int E2, int E3> - struct _swizzle_base2 : public _swizzle_base1 + struct _swizzle_base2 : public _swizzle_base1::value> { struct Stub {}; diff --git a/glm/detail/func_common.inl b/glm/detail/func_common.inl index 3e3a0b77..eab2c8ca 100644 --- a/glm/detail/func_common.inl +++ b/glm/detail/func_common.inl @@ -107,7 +107,7 @@ namespace detail } }; - template class vecType> + template class vecType, bool Aligned> struct compute_abs_vector { GLM_FUNC_QUALIFIER static vecType call(vecType const & x) @@ -116,7 +116,7 @@ namespace detail } }; - template class vecType> + template class vecType, bool Aligned> struct compute_mix_vector { GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y, vecType const & a) @@ -127,8 +127,8 @@ namespace detail } }; - template class vecType> - struct compute_mix_vector + template class vecType, bool Aligned> + struct compute_mix_vector { GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y, vecType const & a) { @@ -139,7 +139,7 @@ namespace detail } }; - template class vecType> + template class vecType, bool Aligned> struct compute_mix_scalar { GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y, U const & a) @@ -150,8 +150,8 @@ namespace detail } }; - template class vecType> - struct compute_mix_scalar + template class vecType, bool Aligned> + struct compute_mix_scalar { GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y, bool const & a) { @@ -179,7 +179,7 @@ namespace detail } }; - template class vecType, bool isFloat = true> + template class vecType, bool isFloat, bool Aligned> struct compute_sign { GLM_FUNC_QUALIFIER static vecType call(vecType const & x) @@ -189,8 +189,8 @@ namespace detail }; # if GLM_ARCH == GLM_ARCH_X86 - template class vecType> - struct compute_sign + template class vecType, bool Aligned> + struct compute_sign { GLM_FUNC_QUALIFIER static vecType call(vecType const & x) { @@ -202,7 +202,7 @@ namespace detail }; # endif - template class vecType> + template class vecType, bool Aligned> struct compute_floor { GLM_FUNC_QUALIFIER static vecType call(vecType const & x) @@ -211,7 +211,7 @@ namespace detail } }; - template class vecType> + template class vecType, bool Aligned> struct compute_ceil { GLM_FUNC_QUALIFIER static vecType call(vecType const & x) @@ -220,7 +220,7 @@ namespace detail } }; - template class vecType> + template class vecType, bool Aligned> struct compute_fract { GLM_FUNC_QUALIFIER static vecType call(vecType const & x) @@ -229,7 +229,7 @@ namespace detail } }; - template class vecType> + template class vecType, bool Aligned> struct compute_trunc { GLM_FUNC_QUALIFIER static vecType call(vecType const & x) @@ -238,7 +238,7 @@ namespace detail } }; - template class vecType> + template class vecType, bool Aligned> struct compute_round { GLM_FUNC_QUALIFIER static vecType call(vecType const & x) @@ -247,7 +247,7 @@ namespace detail } }; - template class vecType> + template class vecType, bool Aligned> struct compute_mod { GLM_FUNC_QUALIFIER static vecType call(vecType const & a, vecType const & b) @@ -257,7 +257,7 @@ namespace detail } }; - template class vecType> + template class vecType, bool Aligned> struct compute_min_vector { GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y) @@ -266,7 +266,7 @@ namespace detail } }; - template class vecType> + template class vecType, bool Aligned> struct compute_max_vector { GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y) @@ -275,7 +275,7 @@ namespace detail } }; - template class vecType> + template class vecType, bool Aligned> struct compute_clamp_vector { GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & minVal, vecType const & maxVal) @@ -284,7 +284,7 @@ namespace detail } }; - template class vecType> + template class vecType, bool Aligned> struct compute_step_vector { GLM_FUNC_QUALIFIER static vecType call(vecType const & edge, vecType const & x) @@ -293,7 +293,7 @@ namespace detail } }; - template class vecType> + template class vecType, bool Aligned> struct compute_smoothstep_vector { GLM_FUNC_QUALIFIER static vecType call(vecType const & edge0, vecType const & edge1, vecType const & x) @@ -314,7 +314,7 @@ namespace detail template class vecType> GLM_FUNC_QUALIFIER vecType abs(vecType const & x) { - return detail::compute_abs_vector::call(x); + return detail::compute_abs_vector::value>::call(x); } // sign @@ -326,7 +326,7 @@ namespace detail std::numeric_limits::is_iec559 || (std::numeric_limits::is_signed && std::numeric_limits::is_integer), "'sign' only accept signed inputs"); - return detail::compute_sign::is_iec559>::call(tvec1(x)).x; + return detail::compute_sign::is_iec559, highp>::call(tvec1(x)).x; } template class vecType> @@ -336,7 +336,7 @@ namespace detail std::numeric_limits::is_iec559 || (std::numeric_limits::is_signed && std::numeric_limits::is_integer), "'sign' only accept signed inputs"); - return detail::compute_sign::is_iec559>::call(x); + return detail::compute_sign::is_iec559, detail::is_aligned

::value>::call(x); } // floor @@ -345,21 +345,21 @@ namespace detail GLM_FUNC_QUALIFIER vecType floor(vecType const & x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'floor' only accept floating-point inputs."); - return detail::compute_floor::call(x); + return detail::compute_floor::value>::call(x); } template class vecType> GLM_FUNC_QUALIFIER vecType trunc(vecType const & x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'trunc' only accept floating-point inputs"); - return detail::compute_trunc::call(x); + return detail::compute_trunc::value>::call(x); } template class vecType> GLM_FUNC_QUALIFIER vecType round(vecType const & x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'round' only accept floating-point inputs"); - return detail::compute_round::call(x); + return detail::compute_round::value>::call(x); } /* @@ -432,7 +432,7 @@ namespace detail GLM_FUNC_QUALIFIER vecType fract(vecType const & x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fract' only accept floating-point inputs"); - return detail::compute_fract::call(x); + return detail::compute_fract::value>::call(x); } // mod @@ -445,13 +445,13 @@ namespace detail template class vecType> GLM_FUNC_QUALIFIER vecType mod(vecType const & x, T y) { - return detail::compute_mod::call(x, vecType(y)); + return detail::compute_mod::value>::call(x, vecType(y)); } template class vecType> GLM_FUNC_QUALIFIER vecType mod(vecType const & x, vecType const & y) { - return detail::compute_mod::call(x, y); + return detail::compute_mod::value>::call(x, y); } // modf @@ -509,26 +509,26 @@ namespace detail GLM_FUNC_QUALIFIER vecType min(vecType const & a, T b) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'min' only accept floating-point inputs for the interpolator a"); - return detail::compute_min_vector::call(a, vecType(b)); + return detail::compute_min_vector::value>::call(a, vecType(b)); } template class vecType> GLM_FUNC_QUALIFIER vecType min(vecType const & a, vecType const & b) { - return detail::compute_min_vector::call(a, b); + return detail::compute_min_vector::value>::call(a, b); } // max template class vecType> GLM_FUNC_QUALIFIER vecType max(vecType const & a, T b) { - return detail::compute_max_vector::call(a, vecType(b)); + return detail::compute_max_vector::value>::call(a, vecType(b)); } template class vecType> GLM_FUNC_QUALIFIER vecType max(vecType const & a, vecType const & b) { - return detail::compute_max_vector::call(a, b); + return detail::compute_max_vector::value>::call(a, b); } // clamp @@ -543,14 +543,14 @@ namespace detail GLM_FUNC_QUALIFIER vecType clamp(vecType const & x, T minVal, T maxVal) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, "'clamp' only accept floating-point or integer inputs"); - return detail::compute_clamp_vector::call(x, vecType(minVal), vecType(maxVal)); + return detail::compute_clamp_vector::value>::call(x, vecType(minVal), vecType(maxVal)); } template class vecType> GLM_FUNC_QUALIFIER vecType clamp(vecType const & x, vecType const & minVal, vecType const & maxVal) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, "'clamp' only accept floating-point or integer inputs"); - return detail::compute_clamp_vector::call(x, minVal, maxVal); + return detail::compute_clamp_vector::value>::call(x, minVal, maxVal); } template @@ -562,13 +562,13 @@ namespace detail template class vecType> GLM_FUNC_QUALIFIER vecType mix(vecType const & x, vecType const & y, U a) { - return detail::compute_mix_scalar::call(x, y, a); + return detail::compute_mix_scalar::value>::call(x, y, a); } template class vecType> GLM_FUNC_QUALIFIER vecType mix(vecType const & x, vecType const & y, vecType const & a) { - return detail::compute_mix_vector::call(x, y, a); + return detail::compute_mix_vector::value>::call(x, y, a); } // step @@ -581,13 +581,13 @@ namespace detail template