Clutter Engine 0.0.1
Loading...
Searching...
No Matches
integer.inl
1
2
3namespace glm{
4namespace detail
5{
6 template<length_t L, typename T, qualifier Q, bool Aligned>
7 struct compute_log2<L, T, Q, false, Aligned>
8 {
9 GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& v)
10 {
11 //Equivalent to return findMSB(vec); but save one function call in ASM with VC
12 //return findMSB(vec);
13 return vec<L, T, Q>(detail::compute_findMSB_vec<L, T, Q, sizeof(T) * 8>::call(v));
14 }
15 };
16
17# if GLM_HAS_BITSCAN_WINDOWS
18 template<qualifier Q, bool Aligned>
19 struct compute_log2<4, int, Q, false, Aligned>
20 {
21 GLM_FUNC_QUALIFIER static vec<4, int, Q> call(vec<4, int, Q> const& v)
22 {
23 vec<4, int, Q> Result;
24 _BitScanReverse(reinterpret_cast<unsigned long*>(&Result.x), v.x);
25 _BitScanReverse(reinterpret_cast<unsigned long*>(&Result.y), v.y);
26 _BitScanReverse(reinterpret_cast<unsigned long*>(&Result.z), v.z);
27 _BitScanReverse(reinterpret_cast<unsigned long*>(&Result.w), v.w);
28 return Result;
29 }
30 };
31# endif//GLM_HAS_BITSCAN_WINDOWS
32}//namespace detail
33 template<typename genType>
34 GLM_FUNC_QUALIFIER int iround(genType x)
35 {
36 GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'iround' only accept floating-point inputs");
37 assert(static_cast<genType>(0.0) <= x);
38
39 return static_cast<int>(x + static_cast<genType>(0.5));
40 }
41
42 template<length_t L, typename T, qualifier Q>
43 GLM_FUNC_QUALIFIER vec<L, int, Q> iround(vec<L, T, Q> const& x)
44 {
45 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'iround' only accept floating-point inputs");
46 assert(all(lessThanEqual(vec<L, T, Q>(0), x)));
47
48 return vec<L, int, Q>(x + static_cast<T>(0.5));
49 }
50
51 template<typename genType>
52 GLM_FUNC_QUALIFIER uint uround(genType x)
53 {
54 GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'uround' only accept floating-point inputs");
55 assert(static_cast<genType>(0.0) <= x);
56
57 return static_cast<uint>(x + static_cast<genType>(0.5));
58 }
59
60 template<length_t L, typename T, qualifier Q>
61 GLM_FUNC_QUALIFIER vec<L, uint, Q> uround(vec<L, T, Q> const& x)
62 {
63 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'uround' only accept floating-point inputs");
64 assert(all(lessThanEqual(vec<L, T, Q>(0), x)));
65
66 return vec<L, uint, Q>(x + static_cast<T>(0.5));
67 }
68}//namespace glm
GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool all(vec< L, bool, Q > const &v)
Definition func_vector_relational.inl:67
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec< L, bool, Q > lessThanEqual(vec< L, T, Q > const &x, vec< L, T, Q > const &y)
Definition func_vector_relational.inl:13
GLM_FUNC_DECL vec< L, int, Q > iround(vec< L, T, Q > const &x)
Definition integer.inl:43
GLM_FUNC_DECL vec< L, uint, Q > uround(vec< L, T, Q > const &x)
Definition integer.inl:61
detail namespace with internal helper functions
Definition json.h:249
Core features
Definition common.hpp:21
Definition func_integer.inl:122
Definition func_exponential.inl:25
Definition qualifier.hpp:35