integer.inl 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. /// @ref gtc_integer
  2. namespace glm{
  3. namespace detail
  4. {
  5. template<length_t L, typename T, qualifier Q, bool Aligned>
  6. struct compute_log2<L, T, Q, false, Aligned>
  7. {
  8. GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& v)
  9. {
  10. //Equivalent to return findMSB(vec); but save one function call in ASM with VC
  11. //return findMSB(vec);
  12. return vec<L, T, Q>(detail::compute_findMSB_vec<L, T, Q, sizeof(T) * 8>::call(v));
  13. }
  14. };
  15. # if GLM_HAS_BITSCAN_WINDOWS
  16. template<qualifier Q, bool Aligned>
  17. struct compute_log2<4, int, Q, false, Aligned>
  18. {
  19. GLM_FUNC_QUALIFIER static vec<4, int, Q> call(vec<4, int, Q> const& v)
  20. {
  21. vec<4, int, Q> Result;
  22. _BitScanReverse(reinterpret_cast<unsigned long*>(&Result.x), v.x);
  23. _BitScanReverse(reinterpret_cast<unsigned long*>(&Result.y), v.y);
  24. _BitScanReverse(reinterpret_cast<unsigned long*>(&Result.z), v.z);
  25. _BitScanReverse(reinterpret_cast<unsigned long*>(&Result.w), v.w);
  26. return Result;
  27. }
  28. };
  29. # endif//GLM_HAS_BITSCAN_WINDOWS
  30. }//namespace detail
  31. }//namespace glm