Increase MaxChannels to be a multiple of 4
[openal-soft/openal-hmr.git] / Alc / mixer_sse.c
blobbbca54eca213a7a2fad6bf602217369dc7dfff1b
1 #include "config.h"
3 #ifdef HAVE_XMMINTRIN_H
4 #include <xmmintrin.h>
5 #endif
7 #include "AL/al.h"
8 #include "AL/alc.h"
9 #include "alMain.h"
10 #include "alu.h"
13 static __inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*RESTRICT Values)[2],
14 ALfloat (*RESTRICT Coeffs)[2],
15 ALfloat (*RESTRICT CoeffStep)[2],
16 ALfloat left, ALfloat right)
18 const __m128 lrlr = { left, right, left, right };
19 __m128 vals = { 0.0f, 0.0f, 0.0f, 0.0f };
20 __m128 coeffs, coeffstep;
21 ALuint c;
22 for(c = 0;c < HRIR_LENGTH;c += 2)
24 const ALuint o0 = (Offset++)&HRIR_MASK;
25 const ALuint o1 = (Offset++)&HRIR_MASK;
27 coeffs = _mm_load_ps(&Coeffs[c][0]);
28 vals = _mm_loadl_pi(vals, (__m64*)&Values[o0][0]);
29 vals = _mm_loadh_pi(vals, (__m64*)&Values[o1][0]);
31 vals = _mm_add_ps(vals, _mm_mul_ps(coeffs, lrlr));
32 _mm_storel_pi((__m64*)&Values[o0][0], vals);
33 _mm_storeh_pi((__m64*)&Values[o1][0], vals);
35 coeffstep = _mm_load_ps(&CoeffStep[c][0]);
36 coeffs = _mm_add_ps(coeffs, coeffstep);
37 _mm_store_ps(&Coeffs[c][0], coeffs);
41 static __inline void ApplyCoeffs(ALuint Offset, ALfloat (*RESTRICT Values)[2],
42 ALfloat (*RESTRICT Coeffs)[2],
43 ALfloat left, ALfloat right)
45 const __m128 lrlr = { left, right, left, right };
46 __m128 vals = { 0.0f, 0.0f, 0.0f, 0.0f };
47 __m128 coeffs;
48 ALuint c;
49 for(c = 0;c < HRIR_LENGTH;c += 2)
51 const ALuint o0 = (Offset++)&HRIR_MASK;
52 const ALuint o1 = (Offset++)&HRIR_MASK;
54 coeffs = _mm_load_ps(&Coeffs[c][0]);
55 vals = _mm_loadl_pi(vals, (__m64*)&Values[o0][0]);
56 vals = _mm_loadh_pi(vals, (__m64*)&Values[o1][0]);
58 vals = _mm_add_ps(vals, _mm_mul_ps(coeffs, lrlr));
59 _mm_storel_pi((__m64*)&Values[o0][0], vals);
60 _mm_storeh_pi((__m64*)&Values[o1][0], vals);
64 #define SUFFIX SSE
65 #define SAMPLER point32
66 #include "mixer_inc.c"
67 #undef SAMPLER
68 #define SAMPLER lerp32
69 #include "mixer_inc.c"
70 #undef SAMPLER
71 #define SAMPLER cubic32
72 #include "mixer_inc.c"
73 #undef SAMPLER
74 #undef SUFFIX