From e62817b8252974b8a98393275874ee303840bf13 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Fri, 12 May 2017 18:49:50 +0500 Subject: 2017-05-12 --- depedencies/include/glm/gtc/integer.inl | 71 +++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 depedencies/include/glm/gtc/integer.inl (limited to 'depedencies/include/glm/gtc/integer.inl') diff --git a/depedencies/include/glm/gtc/integer.inl b/depedencies/include/glm/gtc/integer.inl new file mode 100644 index 0000000..7ce2918 --- /dev/null +++ b/depedencies/include/glm/gtc/integer.inl @@ -0,0 +1,71 @@ +/// @ref gtc_integer +/// @file glm/gtc/integer.inl + +namespace glm{ +namespace detail +{ + template class vecType, bool Aligned> + struct compute_log2 + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & vec) + { + //Equivalent to return findMSB(vec); but save one function call in ASM with VC + //return findMSB(vec); + return vecType(detail::compute_findMSB_vec::call(vec)); + } + }; + +# if GLM_HAS_BITSCAN_WINDOWS + template + struct compute_log2 + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & vec) + { + tvec4 Result(glm::uninitialize); + + _BitScanReverse(reinterpret_cast(&Result.x), vec.x); + _BitScanReverse(reinterpret_cast(&Result.y), vec.y); + _BitScanReverse(reinterpret_cast(&Result.z), vec.z); + _BitScanReverse(reinterpret_cast(&Result.w), vec.w); + + return Result; + } + }; +# endif//GLM_HAS_BITSCAN_WINDOWS +}//namespace detail + template + GLM_FUNC_QUALIFIER int iround(genType x) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'iround' only accept floating-point inputs"); + assert(static_cast(0.0) <= x); + + return static_cast(x + static_cast(0.5)); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType iround(vecType const& x) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'iround' only accept floating-point inputs"); + assert(all(lessThanEqual(vecType(0), x))); + + return vecType(x + static_cast(0.5)); + } + + template + GLM_FUNC_QUALIFIER uint uround(genType x) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'uround' only accept floating-point inputs"); + assert(static_cast(0.0) <= x); + + return static_cast(x + static_cast(0.5)); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType uround(vecType const& x) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'uround' only accept floating-point inputs"); + assert(all(lessThanEqual(vecType(0), x))); + + return vecType(x + static_cast(0.5)); + } +}//namespace glm -- cgit v1.2.3