Clutter Engine 0.0.1
Loading...
Searching...
No Matches
func_integer_simd.inl
1#include "../simd/integer.h"
2
3#if GLM_ARCH & GLM_ARCH_SSE2_BIT
4
5namespace glm{
6namespace detail
7{
8 template<qualifier Q>
9 struct compute_bitfieldReverseStep<4, uint, Q, true, true>
10 {
11 GLM_FUNC_QUALIFIER static vec<4, uint, Q> call(vec<4, uint, Q> const& v, uint Mask, uint Shift)
12 {
13 __m128i const set0 = v.data;
14
15 __m128i const set1 = _mm_set1_epi32(static_cast<int>(Mask));
16 __m128i const and1 = _mm_and_si128(set0, set1);
17 __m128i const sft1 = _mm_slli_epi32(and1, Shift);
18
19 __m128i const set2 = _mm_andnot_si128(set0, _mm_set1_epi32(-1));
20 __m128i const and2 = _mm_and_si128(set0, set2);
21 __m128i const sft2 = _mm_srai_epi32(and2, Shift);
22
23 __m128i const or0 = _mm_or_si128(sft1, sft2);
24
25 return or0;
26 }
27 };
28
29 template<qualifier Q>
30 struct compute_bitfieldBitCountStep<4, uint, Q, true, true>
31 {
32 GLM_FUNC_QUALIFIER static vec<4, uint, Q> call(vec<4, uint, Q> const& v, uint Mask, uint Shift)
33 {
34 __m128i const set0 = v.data;
35
36 __m128i const set1 = _mm_set1_epi32(static_cast<int>(Mask));
37 __m128i const and0 = _mm_and_si128(set0, set1);
38 __m128i const sft0 = _mm_slli_epi32(set0, Shift);
39 __m128i const and1 = _mm_and_si128(sft0, set1);
40 __m128i const add0 = _mm_add_epi32(and0, and1);
41
42 return add0;
43 }
44 };
45}//namespace detail
46
47# if GLM_ARCH & GLM_ARCH_AVX_BIT
48 template<>
49 GLM_FUNC_QUALIFIER int bitCount(uint x)
50 {
51 return _mm_popcnt_u32(x);
52 }
53
54# if(GLM_MODEL == GLM_MODEL_64)
55 template<>
56 GLM_FUNC_QUALIFIER int bitCount(detail::uint64 x)
57 {
58 return static_cast<int>(_mm_popcnt_u64(x));
59 }
60# endif//GLM_MODEL
61# endif//GLM_ARCH
62
63}//namespace glm
64
65#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
detail namespace with internal helper functions
Definition json.h:249
Core features
Definition common.hpp:21