Fixed mod function specialization #281 Fixed bitscan detection
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../detail/precision.hpp"
|
||||
#include "../detail/func_common.hpp"
|
||||
#include "../detail/func_integer.hpp"
|
||||
#include "../detail/func_exponential.hpp"
|
||||
#include <limits>
|
||||
@@ -58,11 +59,46 @@ 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.
|
||||
/// Returns the log2 of x for integer values. Can be reliably using to compute mipmap count from the texture size.
|
||||
/// @see gtc_integer
|
||||
template <typename genIUType>
|
||||
GLM_FUNC_DECL genIUType log2(genIUType x);
|
||||
|
||||
/// Modulus. Returns x % y
|
||||
/// for each component in x using the floating point value y.
|
||||
///
|
||||
/// @tparam genIUType Integer-point scalar or vector types.
|
||||
///
|
||||
/// @see gtc_integer
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
|
||||
template <typename genIUType>
|
||||
GLM_FUNC_DECL genIUType mod(genIUType x, genIUType y);
|
||||
|
||||
/// Modulus. Returns x % y
|
||||
/// for each component in x using the floating point value y.
|
||||
///
|
||||
/// @tparam T Integer scalar types.
|
||||
/// @tparam vecType vector types.
|
||||
///
|
||||
/// @see gtc_integer
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> mod(vecType<T, P> const & x, T y);
|
||||
|
||||
/// Modulus. Returns x % y
|
||||
/// for each component in x using the floating point value y.
|
||||
///
|
||||
/// @tparam T Integer scalar types.
|
||||
/// @tparam vecType vector types.
|
||||
///
|
||||
/// @see gtc_integer
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<T, P> mod(vecType<T, P> const & x, vecType<T, P> const & y);
|
||||
|
||||
/// @}
|
||||
} //namespace glm
|
||||
|
||||
|
||||
@@ -44,24 +44,31 @@ namespace detail
|
||||
}
|
||||
};
|
||||
|
||||
# if(GLM_ARCH != GLM_ARCH_PURE) && (GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_LLVM))
|
||||
|
||||
template <precision P>
|
||||
struct compute_log2<int, P, tvec4, false>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static tvec4<int, P> call(tvec4<int, P> const & vec)
|
||||
# if GLM_HAS_BITSCAN_WINDOWS
|
||||
template <precision P>
|
||||
struct compute_log2<int, P, tvec4, false>
|
||||
{
|
||||
tvec4<int, P> Result(glm::uninitialize);
|
||||
GLM_FUNC_QUALIFIER static tvec4<int, P> call(tvec4<int, P> const & vec)
|
||||
{
|
||||
tvec4<int, P> Result(glm::uninitialize);
|
||||
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.x), vec.x);
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.y), vec.y);
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.z), vec.z);
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.w), vec.w);
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.x), vec.x);
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.y), vec.y);
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.z), vec.z);
|
||||
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result.w), vec.w);
|
||||
|
||||
return Result;
|
||||
return Result;
|
||||
}
|
||||
};
|
||||
# endif//GLM_HAS_BITSCAN_WINDOWS
|
||||
|
||||
template <typename T, precision P, template <class, precision> class vecType, typename genType>
|
||||
struct compute_mod<T, P, vecType, genType, false>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & a, genType const & b)
|
||||
{
|
||||
return a % b;
|
||||
}
|
||||
};
|
||||
|
||||
# endif//GLM_ARCH != GLM_ARCH_PURE
|
||||
}//namespace detail
|
||||
}//namespace glm
|
||||
|
||||
Reference in New Issue
Block a user