diff --git a/glm/gtc/integer.hpp b/glm/gtc/integer.hpp index 2196d6db..2e3ad45e 100644 --- a/glm/gtc/integer.hpp +++ b/glm/gtc/integer.hpp @@ -41,8 +41,8 @@ // Dependencies #include "../detail/setup.hpp" #include "../detail/precision.hpp" -#include "../detail/type_int.hpp" -#include "../detail/_vectorize.hpp" +#include "../detail/func_integer.hpp" +#include "../detail/func_exponential.hpp" #include #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) @@ -54,7 +54,10 @@ namespace glm /// @addtogroup gtc_integer /// @{ - + /// Returns the log2 of x. Can be reliably using to compute mipmap count from the texture size. + /// From GLM_GTC_integer extension. + template + GLM_FUNC_DECL genIUType log2(genIUType x); /// @} } //namespace glm diff --git a/glm/gtc/integer.inl b/glm/gtc/integer.inl index eb482a66..db2d7ff3 100644 --- a/glm/gtc/integer.inl +++ b/glm/gtc/integer.inl @@ -29,9 +29,19 @@ namespace glm{ namespace detail { + GLM_FUNC_QUALIFIER unsigned int nlz(unsigned int x) + { + return 31u - findMSB(x); + } + template <> + struct compute_log2 + { + template + GLM_FUNC_QUALIFIER T operator() (T const & Value) const + { + return Value <= static_cast(1) ? T(0) : T(32) - nlz(Value - T(1)); + } + }; }//namespace detail - - - }//namespace glm diff --git a/glm/gtx/integer.hpp b/glm/gtx/integer.hpp index 00f1fd4a..4c6aa2bc 100644 --- a/glm/gtx/integer.hpp +++ b/glm/gtx/integer.hpp @@ -39,6 +39,7 @@ // Dependency: #include "../glm.hpp" +#include "../gtc/integer.hpp" #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) # pragma message("GLM: GLM_GTX_integer extension included") @@ -57,11 +58,6 @@ namespace glm //! From GLM_GTX_integer extension. GLM_FUNC_DECL int sqrt(int x); - //! Returns the log2 of x. Can be reliably using to compute mipmap count from the texture size. - //! From GLM_GTX_integer extension. - template - GLM_FUNC_DECL genIUType log2(genIUType x); - //! Returns the floor log2 of x. //! From GLM_GTX_integer extension. GLM_FUNC_DECL unsigned int floor_log2(unsigned int x); diff --git a/glm/gtx/integer.inl b/glm/gtx/integer.inl index c0badfb1..db30dacd 100644 --- a/glm/gtx/integer.inl +++ b/glm/gtx/integer.inl @@ -53,20 +53,6 @@ namespace detail x += (x >> 16); return(x & 0x0000003f); } - - template <> - struct compute_log2 - { - template - GLM_FUNC_QUALIFIER T operator() (T const & Value) const - { -#if(GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_GCC)) - return Value <= static_cast(1) ? T(0) : T(32) - nlz(Value - T(1)); -#else - return T(32) - nlz(Value - T(1)); -#endif - } - }; }//namespace detail // Henry Gordon Dietz: http://aggregate.org/MAGIC/