diff options
author | Chris Robinson <[email protected]> | 2020-10-21 17:16:27 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-10-21 17:16:27 -0700 |
commit | 7bb37deb51c6c1d0faa4f2fbe92f8051e64d6401 (patch) | |
tree | e1a8cf7da46d8816ee0e1a3ff6151206735bc981 /alc/mixer | |
parent | 3e62600ecc3c2f1be4da0d3e8166f5c67cc25fed (diff) |
Replace the mixer fraction macros with constexpr variables
Diffstat (limited to 'alc/mixer')
-rw-r--r-- | alc/mixer/defs.h | 5 | ||||
-rw-r--r-- | alc/mixer/mixer_c.cpp | 10 | ||||
-rw-r--r-- | alc/mixer/mixer_neon.cpp | 22 | ||||
-rw-r--r-- | alc/mixer/mixer_sse.cpp | 10 | ||||
-rw-r--r-- | alc/mixer/mixer_sse2.cpp | 12 | ||||
-rw-r--r-- | alc/mixer/mixer_sse41.cpp | 12 |
6 files changed, 36 insertions, 35 deletions
diff --git a/alc/mixer/defs.h b/alc/mixer/defs.h index 0f3a0f3d..762355d2 100644 --- a/alc/mixer/defs.h +++ b/alc/mixer/defs.h @@ -5,6 +5,7 @@ #include "alcmain.h" #include "alspan.h" +#include "alu.h" #include "hrtf.h" union InterpState; @@ -39,8 +40,8 @@ inline void InitPosArrays(ALuint frac, ALuint increment, ALuint *frac_arr, ALuin for(size_t i{1};i < size;i++) { const ALuint frac_tmp{frac_arr[i-1] + increment}; - pos_arr[i] = pos_arr[i-1] + (frac_tmp>>FRACTIONBITS); - frac_arr[i] = frac_tmp&FRACTIONMASK; + pos_arr[i] = pos_arr[i-1] + (frac_tmp>>MixerFracBits); + frac_arr[i] = frac_tmp&MixerFracMask; } } diff --git a/alc/mixer/mixer_c.cpp b/alc/mixer/mixer_c.cpp index 5d71e0a4..2be60892 100644 --- a/alc/mixer/mixer_c.cpp +++ b/alc/mixer/mixer_c.cpp @@ -21,15 +21,15 @@ struct FastBSincTag; namespace { -constexpr ALuint FracPhaseBitDiff{FRACTIONBITS - BSincPhaseBits}; +constexpr ALuint FracPhaseBitDiff{MixerFracBits - BSincPhaseBits}; constexpr ALuint FracPhaseDiffOne{1 << FracPhaseBitDiff}; inline float do_point(const InterpState&, const float *RESTRICT vals, const ALuint) { return vals[0]; } inline float do_lerp(const InterpState&, const float *RESTRICT vals, const ALuint frac) -{ return lerp(vals[0], vals[1], static_cast<float>(frac)*(1.0f/FRACTIONONE)); } +{ return lerp(vals[0], vals[1], static_cast<float>(frac)*(1.0f/MixerFracOne)); } inline float do_cubic(const InterpState&, const float *RESTRICT vals, const ALuint frac) -{ return cubic(vals[0], vals[1], vals[2], vals[3], static_cast<float>(frac)*(1.0f/FRACTIONONE)); } +{ return cubic(vals[0], vals[1], vals[2], vals[3], static_cast<float>(frac)*(1.0f/MixerFracOne)); } inline float do_bsinc(const InterpState &istate, const float *RESTRICT vals, const ALuint frac) { const size_t m{istate.bsinc.m}; @@ -78,8 +78,8 @@ const float *DoResample(const InterpState *state, const float *RESTRICT src, ALu out = Sampler(istate, src, frac); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } return dst.data(); } diff --git a/alc/mixer/mixer_neon.cpp b/alc/mixer/mixer_neon.cpp index cfa541c7..1b6e7b54 100644 --- a/alc/mixer/mixer_neon.cpp +++ b/alc/mixer/mixer_neon.cpp @@ -21,7 +21,7 @@ struct FastBSincTag; namespace { -constexpr ALuint FracPhaseBitDiff{FRACTIONBITS - BSincPhaseBits}; +constexpr ALuint FracPhaseBitDiff{MixerFracBits - BSincPhaseBits}; constexpr ALuint FracPhaseDiffOne{1 << FracPhaseBitDiff}; inline void ApplyCoeffs(float2 *RESTRICT Values, const uint_fast32_t IrSize, @@ -54,8 +54,8 @@ const float *Resample_<LerpTag,NEONTag>(const InterpState*, const float *RESTRIC ALuint increment, const al::span<float> dst) { const int32x4_t increment4 = vdupq_n_s32(static_cast<int>(increment*4)); - const float32x4_t fracOne4 = vdupq_n_f32(1.0f/FRACTIONONE); - const int32x4_t fracMask4 = vdupq_n_s32(FRACTIONMASK); + const float32x4_t fracOne4 = vdupq_n_f32(1.0f/MixerFracOne); + const int32x4_t fracMask4 = vdupq_n_s32(MixerFracMask); alignas(16) ALuint pos_[4], frac_[4]; int32x4_t pos4, frac4; @@ -82,7 +82,7 @@ const float *Resample_<LerpTag,NEONTag>(const InterpState*, const float *RESTRIC dst_iter += 4; frac4 = vaddq_s32(frac4, increment4); - pos4 = vaddq_s32(pos4, vshrq_n_s32(frac4, FRACTIONBITS)); + pos4 = vaddq_s32(pos4, vshrq_n_s32(frac4, MixerFracBits)); frac4 = vandq_s32(frac4, fracMask4); } @@ -92,11 +92,11 @@ const float *Resample_<LerpTag,NEONTag>(const InterpState*, const float *RESTRIC frac = static_cast<ALuint>(vgetq_lane_s32(frac4, 0)); do { - *(dst_iter++) = lerp(src[0], src[1], static_cast<float>(frac) * (1.0f/FRACTIONONE)); + *(dst_iter++) = lerp(src[0], src[1], static_cast<float>(frac) * (1.0f/MixerFracOne)); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } while(--todo); } return dst.data(); @@ -142,8 +142,8 @@ const float *Resample_<BSincTag,NEONTag>(const InterpState *state, const float * out_sample = vget_lane_f32(vadd_f32(vget_low_f32(r4), vget_high_f32(r4)), 0); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } return dst.data(); } @@ -183,8 +183,8 @@ const float *Resample_<FastBSincTag,NEONTag>(const InterpState *state, out_sample = vget_lane_f32(vadd_f32(vget_low_f32(r4), vget_high_f32(r4)), 0); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } return dst.data(); } diff --git a/alc/mixer/mixer_sse.cpp b/alc/mixer/mixer_sse.cpp index e1aa479c..6c0e5762 100644 --- a/alc/mixer/mixer_sse.cpp +++ b/alc/mixer/mixer_sse.cpp @@ -20,7 +20,7 @@ struct FastBSincTag; namespace { -constexpr ALuint FracPhaseBitDiff{FRACTIONBITS - BSincPhaseBits}; +constexpr ALuint FracPhaseBitDiff{MixerFracBits - BSincPhaseBits}; constexpr ALuint FracPhaseDiffOne{1 << FracPhaseBitDiff}; #define MLA4(x, y, z) _mm_add_ps(x, _mm_mul_ps(y, z)) @@ -115,8 +115,8 @@ const float *Resample_<BSincTag,SSETag>(const InterpState *state, const float *R out_sample = _mm_cvtss_f32(r4); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } return dst.data(); } @@ -157,8 +157,8 @@ const float *Resample_<FastBSincTag,SSETag>(const InterpState *state, const floa out_sample = _mm_cvtss_f32(r4); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } return dst.data(); } diff --git a/alc/mixer/mixer_sse2.cpp b/alc/mixer/mixer_sse2.cpp index 088284a7..892e0758 100644 --- a/alc/mixer/mixer_sse2.cpp +++ b/alc/mixer/mixer_sse2.cpp @@ -35,8 +35,8 @@ const float *Resample_<LerpTag,SSE2Tag>(const InterpState*, const float *RESTRIC ALuint increment, const al::span<float> dst) { const __m128i increment4{_mm_set1_epi32(static_cast<int>(increment*4))}; - const __m128 fracOne4{_mm_set1_ps(1.0f/FRACTIONONE)}; - const __m128i fracMask4{_mm_set1_epi32(FRACTIONMASK)}; + const __m128 fracOne4{_mm_set1_ps(1.0f/MixerFracOne)}; + const __m128i fracMask4{_mm_set1_epi32(MixerFracMask)}; alignas(16) ALuint pos_[4], frac_[4]; InitPosArrays(frac, increment, frac_, pos_, 4); @@ -64,7 +64,7 @@ const float *Resample_<LerpTag,SSE2Tag>(const InterpState*, const float *RESTRIC dst_iter += 4; frac4 = _mm_add_epi32(frac4, increment4); - pos4 = _mm_add_epi32(pos4, _mm_srli_epi32(frac4, FRACTIONBITS)); + pos4 = _mm_add_epi32(pos4, _mm_srli_epi32(frac4, MixerFracBits)); frac4 = _mm_and_si128(frac4, fracMask4); } @@ -74,11 +74,11 @@ const float *Resample_<LerpTag,SSE2Tag>(const InterpState*, const float *RESTRIC frac = static_cast<ALuint>(_mm_cvtsi128_si32(frac4)); do { - *(dst_iter++) = lerp(src[0], src[1], static_cast<float>(frac) * (1.0f/FRACTIONONE)); + *(dst_iter++) = lerp(src[0], src[1], static_cast<float>(frac) * (1.0f/MixerFracOne)); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } while(--todo); } return dst.data(); diff --git a/alc/mixer/mixer_sse41.cpp b/alc/mixer/mixer_sse41.cpp index f18cd6b4..19391ea3 100644 --- a/alc/mixer/mixer_sse41.cpp +++ b/alc/mixer/mixer_sse41.cpp @@ -36,8 +36,8 @@ const float *Resample_<LerpTag,SSE4Tag>(const InterpState*, const float *RESTRIC ALuint increment, const al::span<float> dst) { const __m128i increment4{_mm_set1_epi32(static_cast<int>(increment*4))}; - const __m128 fracOne4{_mm_set1_ps(1.0f/FRACTIONONE)}; - const __m128i fracMask4{_mm_set1_epi32(FRACTIONMASK)}; + const __m128 fracOne4{_mm_set1_ps(1.0f/MixerFracOne)}; + const __m128i fracMask4{_mm_set1_epi32(MixerFracMask)}; alignas(16) ALuint pos_[4], frac_[4]; InitPosArrays(frac, increment, frac_, pos_, 4); @@ -65,7 +65,7 @@ const float *Resample_<LerpTag,SSE4Tag>(const InterpState*, const float *RESTRIC dst_iter += 4; frac4 = _mm_add_epi32(frac4, increment4); - pos4 = _mm_add_epi32(pos4, _mm_srli_epi32(frac4, FRACTIONBITS)); + pos4 = _mm_add_epi32(pos4, _mm_srli_epi32(frac4, MixerFracBits)); frac4 = _mm_and_si128(frac4, fracMask4); } @@ -79,11 +79,11 @@ const float *Resample_<LerpTag,SSE4Tag>(const InterpState*, const float *RESTRIC frac = static_cast<ALuint>(_mm_cvtsi128_si32(frac4)); do { - *(dst_iter++) = lerp(src[0], src[1], static_cast<float>(frac) * (1.0f/FRACTIONONE)); + *(dst_iter++) = lerp(src[0], src[1], static_cast<float>(frac) * (1.0f/MixerFracOne)); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } while(--todo); } return dst.data(); |