From 8fd90334a13608a781e36fc830cd79bf746edd42 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 20 Aug 2019 00:27:28 -0700 Subject: Pass the MixRow buffer size as a span --- alc/mixer/mixer_neon.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'alc/mixer/mixer_neon.cpp') 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_(const ALfloat *data, const al::span OutBuffe } template<> -void MixRow_(ALfloat *OutBuffer, const al::span Gains, - const ALfloat *InSamples, const ALsizei InStride, const ALsizei BufferSize) +void MixRow_(const al::span OutBuffer, const al::span 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_(ALfloat *OutBuffer, const al::span 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; }); } } -- cgit v1.2.3