From 2877f4eda3d1b0c7431039e3142ecf1a282a34b1 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Tue, 21 Aug 2018 20:40:38 +0500 Subject: Update glm to 0.9.9.0 --- external/include/glm/detail/func_integer.inl | 224 ++++++++++++++------------- 1 file changed, 117 insertions(+), 107 deletions(-) (limited to 'external/include/glm/detail/func_integer.inl') diff --git a/external/include/glm/detail/func_integer.inl b/external/include/glm/detail/func_integer.inl index 25910eb..8f9ed43 100644 --- a/external/include/glm/detail/func_integer.inl +++ b/external/include/glm/detail/func_integer.inl @@ -1,6 +1,7 @@ /// @ref core /// @file glm/detail/func_integer.inl +#include "../ext/vec1.hpp" #include "type_vec2.hpp" #include "type_vec3.hpp" #include "type_vec4.hpp" @@ -24,49 +25,49 @@ namespace glm{ namespace detail { - template + template GLM_FUNC_QUALIFIER T mask(T Bits) { - return Bits >= sizeof(T) * 8 ? ~static_cast(0) : (static_cast(1) << Bits) - static_cast(1); + return Bits >= static_cast(sizeof(T) * 8) ? ~static_cast(0) : (static_cast(1) << Bits) - static_cast(1); } - template class vecType, bool Aligned, bool EXEC> + template struct compute_bitfieldReverseStep { - GLM_FUNC_QUALIFIER static vecType call(vecType const & v, T, T) + GLM_FUNC_QUALIFIER static vec call(vec const& v, T, T) { return v; } }; - template class vecType, bool Aligned> - struct compute_bitfieldReverseStep + template + struct compute_bitfieldReverseStep { - GLM_FUNC_QUALIFIER static vecType call(vecType const & v, T Mask, T Shift) + GLM_FUNC_QUALIFIER static vec call(vec const& v, T Mask, T Shift) { return (v & Mask) << Shift | (v & (~Mask)) >> Shift; } }; - template class vecType, bool Aligned, bool EXEC> + template struct compute_bitfieldBitCountStep { - GLM_FUNC_QUALIFIER static vecType call(vecType const & v, T, T) + GLM_FUNC_QUALIFIER static vec call(vec const& v, T, T) { return v; } }; - template class vecType, bool Aligned> - struct compute_bitfieldBitCountStep + template + struct compute_bitfieldBitCountStep { - GLM_FUNC_QUALIFIER static vecType call(vecType const & v, T Mask, T Shift) + GLM_FUNC_QUALIFIER static vec call(vec const& v, T Mask, T Shift) { return (v & Mask) + ((v >> Shift) & Mask); } }; - template + template struct compute_findLSB { GLM_FUNC_QUALIFIER static int call(genIUType Value) @@ -79,7 +80,7 @@ namespace detail }; # if GLM_HAS_BITSCAN_WINDOWS - template + template struct compute_findLSB { GLM_FUNC_QUALIFIER static int call(genIUType Value) @@ -91,7 +92,7 @@ namespace detail }; # if !((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_MODEL == GLM_MODEL_32)) - template + template struct compute_findLSB { GLM_FUNC_QUALIFIER static int call(genIUType Value) @@ -104,42 +105,42 @@ namespace detail # endif # endif//GLM_HAS_BITSCAN_WINDOWS - template class vecType, bool EXEC = true> + template struct compute_findMSB_step_vec { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x, T Shift) + GLM_FUNC_QUALIFIER static vec call(vec const& x, T Shift) { return x | (x >> Shift); } }; - template class vecType> - struct compute_findMSB_step_vec + template + struct compute_findMSB_step_vec { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x, T) + GLM_FUNC_QUALIFIER static vec call(vec const& x, T) { return x; } }; - template class vecType, int> + template struct compute_findMSB_vec { - GLM_FUNC_QUALIFIER static vecType call(vecType const & vec) + GLM_FUNC_QUALIFIER static vec call(vec const& v) { - vecType x(vec); - x = compute_findMSB_step_vec= 8>::call(x, static_cast( 1)); - x = compute_findMSB_step_vec= 8>::call(x, static_cast( 2)); - x = compute_findMSB_step_vec= 8>::call(x, static_cast( 4)); - x = compute_findMSB_step_vec= 16>::call(x, static_cast( 8)); - x = compute_findMSB_step_vec= 32>::call(x, static_cast(16)); - x = compute_findMSB_step_vec= 64>::call(x, static_cast(32)); - return vecType(sizeof(T) * 8 - 1) - glm::bitCount(~x); + vec x(v); + x = compute_findMSB_step_vec= 8>::call(x, static_cast( 1)); + x = compute_findMSB_step_vec= 8>::call(x, static_cast( 2)); + x = compute_findMSB_step_vec= 8>::call(x, static_cast( 4)); + x = compute_findMSB_step_vec= 16>::call(x, static_cast( 8)); + x = compute_findMSB_step_vec= 32>::call(x, static_cast(16)); + x = compute_findMSB_step_vec= 64>::call(x, static_cast(32)); + return vec(sizeof(T) * 8 - 1) - glm::bitCount(~x); } }; # if GLM_HAS_BITSCAN_WINDOWS - template + template GLM_FUNC_QUALIFIER int compute_findMSB_32(genIUType Value) { unsigned long Result(0); @@ -147,17 +148,17 @@ namespace detail return IsNotNull ? int(Result) : -1; } - template class vecType> - struct compute_findMSB_vec + template + struct compute_findMSB_vec { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x) + GLM_FUNC_QUALIFIER static vec call(vec const& x) { - return detail::functor1::call(compute_findMSB_32, x); + return detail::functor1::call(compute_findMSB_32, x); } }; # if !((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_MODEL == GLM_MODEL_32)) - template + template GLM_FUNC_QUALIFIER int compute_findMSB_64(genIUType Value) { unsigned long Result(0); @@ -165,12 +166,12 @@ namespace detail return IsNotNull ? int(Result) : -1; } - template class vecType> - struct compute_findMSB_vec + template + struct compute_findMSB_vec { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x) + GLM_FUNC_QUALIFIER static vec call(vec const& x) { - return detail::functor1::call(compute_findMSB_64, x); + return detail::functor1::call(compute_findMSB_64, x); } }; # endif @@ -178,7 +179,7 @@ namespace detail }//namespace detail // uaddCarry - GLM_FUNC_QUALIFIER uint uaddCarry(uint const & x, uint const & y, uint & Carry) + GLM_FUNC_QUALIFIER uint uaddCarry(uint const& x, uint const& y, uint & Carry) { uint64 const Value64(static_cast(x) + static_cast(y)); uint64 const Max32((static_cast(1) << static_cast(32)) - static_cast(1)); @@ -186,17 +187,17 @@ namespace detail return static_cast(Value64 % (Max32 + static_cast(1))); } - template class vecType> - GLM_FUNC_QUALIFIER vecType uaddCarry(vecType const & x, vecType const & y, vecType & Carry) + template + GLM_FUNC_QUALIFIER vec uaddCarry(vec const& x, vec const& y, vec& Carry) { - vecType Value64(vecType(x) + vecType(y)); - vecType Max32((static_cast(1) << static_cast(32)) - static_cast(1)); - Carry = mix(vecType(0), vecType(1), greaterThan(Value64, Max32)); - return vecType(Value64 % (Max32 + static_cast(1))); + vec Value64(vec(x) + vec(y)); + vec Max32((static_cast(1) << static_cast(32)) - static_cast(1)); + Carry = mix(vec(0), vec(1), greaterThan(Value64, Max32)); + return vec(Value64 % (Max32 + static_cast(1))); } // usubBorrow - GLM_FUNC_QUALIFIER uint usubBorrow(uint const & x, uint const & y, uint & Borrow) + GLM_FUNC_QUALIFIER uint usubBorrow(uint const& x, uint const& y, uint & Borrow) { GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), "uint and uint32 size mismatch"); @@ -207,17 +208,17 @@ namespace detail return static_cast((static_cast(1) << static_cast(32)) + (static_cast(y) - static_cast(x))); } - template class vecType> - GLM_FUNC_QUALIFIER vecType usubBorrow(vecType const & x, vecType const & y, vecType & Borrow) + template + GLM_FUNC_QUALIFIER vec usubBorrow(vec const& x, vec const& y, vec& Borrow) { - Borrow = mix(vecType(1), vecType(0), greaterThanEqual(x, y)); - vecType const YgeX(y - x); - vecType const XgeY(vecType((static_cast(1) << static_cast(32)) + (vecType(y) - vecType(x)))); + Borrow = mix(vec(1), vec(0), greaterThanEqual(x, y)); + vec const YgeX(y - x); + vec const XgeY(vec((static_cast(1) << static_cast(32)) + (vec(y) - vec(x)))); return mix(XgeY, YgeX, greaterThanEqual(y, x)); } // umulExtended - GLM_FUNC_QUALIFIER void umulExtended(uint const & x, uint const & y, uint & msb, uint & lsb) + GLM_FUNC_QUALIFIER void umulExtended(uint const& x, uint const& y, uint & msb, uint & lsb) { GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), "uint and uint32 size mismatch"); @@ -226,18 +227,18 @@ namespace detail lsb = static_cast(Value64); } - template class vecType> - GLM_FUNC_QUALIFIER void umulExtended(vecType const & x, vecType const & y, vecType & msb, vecType & lsb) + template + GLM_FUNC_QUALIFIER void umulExtended(vec const& x, vec const& y, vec& msb, vec& lsb) { GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), "uint and uint32 size mismatch"); - vecType Value64(vecType(x) * vecType(y)); - msb = vecType(Value64 >> static_cast(32)); - lsb = vecType(Value64); + vec Value64(vec(x) * vec(y)); + msb = vec(Value64 >> static_cast(32)); + lsb = vec(Value64); } // imulExtended - GLM_FUNC_QUALIFIER void imulExtended(int x, int y, int & msb, int & lsb) + GLM_FUNC_QUALIFIER void imulExtended(int x, int y, int& msb, int& lsb) { GLM_STATIC_ASSERT(sizeof(int) == sizeof(int32), "int and int32 size mismatch"); @@ -246,25 +247,25 @@ namespace detail lsb = static_cast(Value64); } - template class vecType> - GLM_FUNC_QUALIFIER void imulExtended(vecType const & x, vecType const & y, vecType & msb, vecType & lsb) + template + GLM_FUNC_QUALIFIER void imulExtended(vec const& x, vec const& y, vec& msb, vec& lsb) { GLM_STATIC_ASSERT(sizeof(int) == sizeof(int32), "int and int32 size mismatch"); - vecType Value64(vecType(x) * vecType(y)); - lsb = vecType(Value64 & static_cast(0xFFFFFFFF)); - msb = vecType((Value64 >> static_cast(32)) & static_cast(0xFFFFFFFF)); + vec Value64(vec(x) * vec(y)); + lsb = vec(Value64 & static_cast(0xFFFFFFFF)); + msb = vec((Value64 >> static_cast(32)) & static_cast(0xFFFFFFFF)); } // bitfieldExtract - template + template GLM_FUNC_QUALIFIER genIUType bitfieldExtract(genIUType Value, int Offset, int Bits) { - return bitfieldExtract(tvec1(Value), Offset, Bits).x; + return bitfieldExtract(vec<1, genIUType>(Value), Offset, Bits).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType bitfieldExtract(vecType const & Value, int Offset, int Bits) + template + GLM_FUNC_QUALIFIER vec bitfieldExtract(vec const& Value, int Offset, int Bits) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldExtract' only accept integer inputs"); @@ -272,14 +273,14 @@ namespace detail } // bitfieldInsert - template - GLM_FUNC_QUALIFIER genIUType bitfieldInsert(genIUType const & Base, genIUType const & Insert, int Offset, int Bits) + template + GLM_FUNC_QUALIFIER genIUType bitfieldInsert(genIUType const& Base, genIUType const& Insert, int Offset, int Bits) { - return bitfieldInsert(tvec1(Base), tvec1(Insert), Offset, Bits).x; + return bitfieldInsert(vec<1, genIUType>(Base), vec<1, genIUType>(Insert), Offset, Bits).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType bitfieldInsert(vecType const & Base, vecType const & Insert, int Offset, int Bits) + template + GLM_FUNC_QUALIFIER vec bitfieldInsert(vec const& Base, vec const& Insert, int Offset, int Bits) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldInsert' only accept integer values"); @@ -288,47 +289,56 @@ namespace detail } // bitfieldReverse - template + template GLM_FUNC_QUALIFIER genType bitfieldReverse(genType x) { - return bitfieldReverse(glm::tvec1(x)).x; + return bitfieldReverse(glm::vec<1, genType, glm::defaultp>(x)).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType bitfieldReverse(vecType const & v) + template + GLM_FUNC_QUALIFIER vec bitfieldReverse(vec const& v) { - vecType x(v); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 2>::call(x, T(0x5555555555555555ull), static_cast( 1)); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 4>::call(x, T(0x3333333333333333ull), static_cast( 2)); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 8>::call(x, T(0x0F0F0F0F0F0F0F0Full), static_cast( 4)); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 16>::call(x, T(0x00FF00FF00FF00FFull), static_cast( 8)); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 32>::call(x, T(0x0000FFFF0000FFFFull), static_cast(16)); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 64>::call(x, T(0x00000000FFFFFFFFull), static_cast(32)); + vec x(v); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 2>::call(x, static_cast(0x5555555555555555ull), static_cast( 1)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 4>::call(x, static_cast(0x3333333333333333ull), static_cast( 2)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 8>::call(x, static_cast(0x0F0F0F0F0F0F0F0Full), static_cast( 4)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 16>::call(x, static_cast(0x00FF00FF00FF00FFull), static_cast( 8)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 32>::call(x, static_cast(0x0000FFFF0000FFFFull), static_cast(16)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 64>::call(x, static_cast(0x00000000FFFFFFFFull), static_cast(32)); return x; } // bitCount - template + template GLM_FUNC_QUALIFIER int bitCount(genType x) { - return bitCount(glm::tvec1(x)).x; + return bitCount(glm::vec<1, genType, glm::defaultp>(x)).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType bitCount(vecType const & v) + template + GLM_FUNC_QUALIFIER vec bitCount(vec const& v) { - vecType::type, P> x(*reinterpret_cast::type, P> const *>(&v)); - x = detail::compute_bitfieldBitCountStep::type, P, vecType, detail::is_aligned

::value, sizeof(T) * 8>= 2>::call(x, typename detail::make_unsigned::type(0x5555555555555555ull), typename detail::make_unsigned::type( 1)); - x = detail::compute_bitfieldBitCountStep::type, P, vecType, detail::is_aligned

::value, sizeof(T) * 8>= 4>::call(x, typename detail::make_unsigned::type(0x3333333333333333ull), typename detail::make_unsigned::type( 2)); - x = detail::compute_bitfieldBitCountStep::type, P, vecType, detail::is_aligned

::value, sizeof(T) * 8>= 8>::call(x, typename detail::make_unsigned::type(0x0F0F0F0F0F0F0F0Full), typename detail::make_unsigned::type( 4)); - x = detail::compute_bitfieldBitCountStep::type, P, vecType, detail::is_aligned

::value, sizeof(T) * 8>= 16>::call(x, typename detail::make_unsigned::type(0x00FF00FF00FF00FFull), typename detail::make_unsigned::type( 8)); - x = detail::compute_bitfieldBitCountStep::type, P, vecType, detail::is_aligned

::value, sizeof(T) * 8>= 32>::call(x, typename detail::make_unsigned::type(0x0000FFFF0000FFFFull), typename detail::make_unsigned::type(16)); - x = detail::compute_bitfieldBitCountStep::type, P, vecType, detail::is_aligned

::value, sizeof(T) * 8>= 64>::call(x, typename detail::make_unsigned::type(0x00000000FFFFFFFFull), typename detail::make_unsigned::type(32)); - return vecType(x); +# if GLM_COMPILER & GLM_COMPILER_VC +# pragma warning(push) +# pragma warning(disable : 4310) //cast truncates constant value +# endif + + vec::type, Q> x(*reinterpret_cast::type, Q> const *>(&v)); + x = detail::compute_bitfieldBitCountStep::type, Q, detail::is_aligned::value, sizeof(T) * 8>= 2>::call(x, typename detail::make_unsigned::type(0x5555555555555555ull), typename detail::make_unsigned::type( 1)); + x = detail::compute_bitfieldBitCountStep::type, Q, detail::is_aligned::value, sizeof(T) * 8>= 4>::call(x, typename detail::make_unsigned::type(0x3333333333333333ull), typename detail::make_unsigned::type( 2)); + x = detail::compute_bitfieldBitCountStep::type, Q, detail::is_aligned::value, sizeof(T) * 8>= 8>::call(x, typename detail::make_unsigned::type(0x0F0F0F0F0F0F0F0Full), typename detail::make_unsigned::type( 4)); + x = detail::compute_bitfieldBitCountStep::type, Q, detail::is_aligned::value, sizeof(T) * 8>= 16>::call(x, typename detail::make_unsigned::type(0x00FF00FF00FF00FFull), typename detail::make_unsigned::type( 8)); + x = detail::compute_bitfieldBitCountStep::type, Q, detail::is_aligned::value, sizeof(T) * 8>= 32>::call(x, typename detail::make_unsigned::type(0x0000FFFF0000FFFFull), typename detail::make_unsigned::type(16)); + x = detail::compute_bitfieldBitCountStep::type, Q, detail::is_aligned::value, sizeof(T) * 8>= 64>::call(x, typename detail::make_unsigned::type(0x00000000FFFFFFFFull), typename detail::make_unsigned::type(32)); + return vec(x); + +# if GLM_COMPILER & GLM_COMPILER_VC +# pragma warning(pop) +# endif } // findLSB - template + template GLM_FUNC_QUALIFIER int findLSB(genIUType Value) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findLSB' only accept integer values"); @@ -336,29 +346,29 @@ namespace detail return detail::compute_findLSB::call(Value); } - template class vecType> - GLM_FUNC_QUALIFIER vecType findLSB(vecType const & x) + template + GLM_FUNC_QUALIFIER vec findLSB(vec const& x) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findLSB' only accept integer values"); - return detail::functor1::call(findLSB, x); + return detail::functor1::call(findLSB, x); } // findMSB - template - GLM_FUNC_QUALIFIER int findMSB(genIUType x) + template + GLM_FUNC_QUALIFIER int findMSB(genIUType v) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findMSB' only accept integer values"); - return findMSB(tvec1(x)).x; + return findMSB(vec<1, genIUType>(v)).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType findMSB(vecType const & x) + template + GLM_FUNC_QUALIFIER vec findMSB(vec const& v) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findMSB' only accept integer values"); - return detail::compute_findMSB_vec::call(x); + return detail::compute_findMSB_vec::call(v); } }//namespace glm -- cgit v1.2.3