mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
Added log2 to GTC_integer
This commit is contained in:
parent
88894045af
commit
4f4763600f
@ -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 <limits>
|
||||
|
||||
#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 <typename genIUType>
|
||||
GLM_FUNC_DECL genIUType log2(genIUType x);
|
||||
|
||||
/// @}
|
||||
} //namespace glm
|
||||
|
@ -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<false>
|
||||
{
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T operator() (T const & Value) const
|
||||
{
|
||||
return Value <= static_cast<T>(1) ? T(0) : T(32) - nlz(Value - T(1));
|
||||
}
|
||||
};
|
||||
}//namespace detail
|
||||
|
||||
|
||||
|
||||
}//namespace glm
|
||||
|
@ -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 <typename genIUType>
|
||||
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);
|
||||
|
@ -53,20 +53,6 @@ namespace detail
|
||||
x += (x >> 16);
|
||||
return(x & 0x0000003f);
|
||||
}
|
||||
|
||||
template <>
|
||||
struct compute_log2<false>
|
||||
{
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T operator() (T const & Value) const
|
||||
{
|
||||
#if(GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_GCC))
|
||||
return Value <= static_cast<T>(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/
|
||||
|
Loading…
Reference in New Issue
Block a user