| 1 | /// @ref gtc_integer |
| 2 | |
| 3 | namespace glm{ |
| 4 | namespace 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 | }//namespace glm |