diff options
author | Chris Robinson <[email protected]> | 2019-08-20 00:27:28 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-08-20 00:27:28 -0700 |
commit | 8fd90334a13608a781e36fc830cd79bf746edd42 (patch) | |
tree | cefd2023a67138e29db07a32d114dd1ed5a00b9a /alc/mixer | |
parent | 34a61122f64d6295f50508cc6945350a5be04924 (diff) |
Pass the MixRow buffer size as a span
Diffstat (limited to 'alc/mixer')
-rw-r--r-- | alc/mixer/defs.h | 3 | ||||
-rw-r--r-- | alc/mixer/mixer_c.cpp | 14 | ||||
-rw-r--r-- | alc/mixer/mixer_neon.cpp | 25 | ||||
-rw-r--r-- | alc/mixer/mixer_sse.cpp | 27 |
4 files changed, 31 insertions, 38 deletions
diff --git a/alc/mixer/defs.h b/alc/mixer/defs.h index 19fb42d0..adaed8f5 100644 --- a/alc/mixer/defs.h +++ b/alc/mixer/defs.h @@ -32,7 +32,8 @@ const ALfloat *Resample_(const InterpState *state, const ALfloat *RESTRICT src, template<InstSetType InstTag> void Mix_(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer, ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos, const ALsizei BufferSize); template<InstSetType InstTag> -void MixRow_(ALfloat *OutBuffer, const al::span<const ALfloat> Gains, const ALfloat *InSamples, const ALsizei InStride, const ALsizei BufferSize); +void MixRow_(const al::span<float> OutBuffer, const al::span<const float> Gains, + const float *InSamples, const size_t InStride); template<InstSetType InstTag> void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, MixHrtfFilter *hrtfparams, const ALsizei BufferSize); diff --git a/alc/mixer/mixer_c.cpp b/alc/mixer/mixer_c.cpp index 4985933c..dd094040 100644 --- a/alc/mixer/mixer_c.cpp +++ b/alc/mixer/mixer_c.cpp @@ -189,20 +189,18 @@ void Mix_<CTag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer, * stepping is necessary. */ template<> -void MixRow_<CTag>(ALfloat *OutBuffer, const al::span<const ALfloat> Gains, - const ALfloat *InSamples, const ALsizei InStride, const ALsizei BufferSize) +void MixRow_<CTag>(const al::span<float> OutBuffer, const al::span<const float> Gains, + const float *InSamples, const size_t InStride) { - ASSUME(BufferSize > 0); - - for(const ALfloat gain : Gains) + for(const float gain : Gains) { - const ALfloat *RESTRICT src{InSamples}; + const float *RESTRICT src{InSamples}; InSamples += InStride; if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) continue; - for(ALsizei i{0};i < BufferSize;i++) - OutBuffer[i] += src[i] * gain; + std::transform(OutBuffer.begin(), OutBuffer.end(), src, OutBuffer.begin(), + [gain](const ALfloat cur, const ALfloat src) -> ALfloat { return cur + src*gain; }); } } diff --git a/alc/mixer/mixer_neon.cpp b/alc/mixer/mixer_neon.cpp index c6ea2c60..829d4ea1 100644 --- a/alc/mixer/mixer_neon.cpp +++ b/alc/mixer/mixer_neon.cpp @@ -276,11 +276,9 @@ void Mix_<NEONTag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffe } template<> -void MixRow_<NEONTag>(ALfloat *OutBuffer, const al::span<const ALfloat> Gains, - const ALfloat *InSamples, const ALsizei InStride, const ALsizei BufferSize) +void MixRow_<NEONTag>(const al::span<ALfloat> OutBuffer, const al::span<const ALfloat> Gains, + const ALfloat *InSamples, const ALsizei InStride) { - ASSUME(BufferSize > 0); - for(const ALfloat gain : Gains) { const ALfloat *RESTRICT src{InSamples}; @@ -289,20 +287,19 @@ void MixRow_<NEONTag>(ALfloat *OutBuffer, const al::span<const ALfloat> Gains, if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) continue; - ALsizei pos{0}; - if LIKELY(BufferSize > 3) + auto out_iter = OutBuffer.begin(); + if(size_t todo{OutBuffer.size() >> 2}) { - ALsizei todo{BufferSize >> 2}; - float32x4_t gain4{vdupq_n_f32(gain)}; + const float32x4_t gain4{vdupq_n_f32(gain)}; do { - const float32x4_t val4 = vld1q_f32(&src[pos]); - float32x4_t dry4 = vld1q_f32(&OutBuffer[pos]); + const float32x4_t val4 = vld1q_f32(src); + float32x4_t dry4 = vld1q_f32(out_iter); dry4 = vmlaq_f32(dry4, val4, gain4); - vst1q_f32(&OutBuffer[pos], dry4); - pos += 4; + vst1q_f32(out_iter, dry4); + out_iter += 4; src += 4; } while(--todo); } - for(;pos < BufferSize;pos++) - OutBuffer[pos] += src[pos]*gain; + std::transform(out_iter, OutBuffer.end(), src, out_iter, + [gain](const ALfloat cur, const ALfloat src) -> ALfloat { return cur + src*gain; }); } } diff --git a/alc/mixer/mixer_sse.cpp b/alc/mixer/mixer_sse.cpp index b5958c8e..b3454898 100644 --- a/alc/mixer/mixer_sse.cpp +++ b/alc/mixer/mixer_sse.cpp @@ -229,33 +229,30 @@ void Mix_<SSETag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer } template<> -void MixRow_<SSETag>(ALfloat *OutBuffer, const al::span<const ALfloat> Gains, - const ALfloat *InSamples, const ALsizei InStride, const ALsizei BufferSize) +void MixRow_<SSETag>(const al::span<float> OutBuffer, const al::span<const float> Gains, + const float *InSamples, const size_t InStride) { - ASSUME(BufferSize > 0); - - for(const ALfloat gain : Gains) + for(const float gain : Gains) { - const ALfloat *RESTRICT src{InSamples}; + const float *RESTRICT src{InSamples}; InSamples += InStride; if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) continue; - ALsizei pos{0}; - if LIKELY(BufferSize > 3) + auto out_iter = OutBuffer.begin(); + if(size_t todo{OutBuffer.size() >> 2}) { - ALsizei todo{BufferSize >> 2}; const __m128 gain4 = _mm_set1_ps(gain); do { - const __m128 val4{_mm_load_ps(&src[pos])}; - __m128 dry4{_mm_load_ps(&OutBuffer[pos])}; + const __m128 val4{_mm_load_ps(src)}; + __m128 dry4{_mm_load_ps(out_iter)}; dry4 = _mm_add_ps(dry4, _mm_mul_ps(val4, gain4)); - _mm_store_ps(&OutBuffer[pos], dry4); - pos += 4; + _mm_store_ps(out_iter, dry4); + out_iter += 4; src += 4; } while(--todo); } - for(;pos < BufferSize;pos++) - OutBuffer[pos] += src[pos]*gain; + std::transform(out_iter, OutBuffer.end(), src, out_iter, + [gain](const ALfloat cur, const ALfloat src) -> ALfloat { return cur + src*gain; }); } } |