From 34e96aef601e8e417bbc61708d68e5f6bbd2842e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 3 May 2014 17:24:46 -0700 Subject: Make sure all gain steps are applied with the SSE and Neon mixers --- Alc/mixer_sse.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'Alc/mixer_sse.c') diff --git a/Alc/mixer_sse.c b/Alc/mixer_sse.c index c17a7e08..a2b8461d 100644 --- a/Alc/mixer_sse.c +++ b/Alc/mixer_sse.c @@ -156,6 +156,7 @@ void MixDirect_SSE(DirectParams *params, const ALfloat *restrict data, ALuint sr if(Step != 1.0f && Counter > 0) { DrySend = params->Mix.Gains.Current[srcchan][c]; + /* Mix with applying gain steps in aligned multiples of 4. */ if(BufferSize-pos > 3 && Counter-pos > 3) { gain = _mm_set_ps( @@ -175,14 +176,15 @@ void MixDirect_SSE(DirectParams *params, const ALfloat *restrict data, ALuint sr } while(BufferSize-pos > 3 && Counter-pos > 3); DrySend = _mm_cvtss_f32(_mm_shuffle_ps(gain, gain, _MM_SHUFFLE(3, 3, 3, 3))); } - if(!(BufferSize-pos > 3)) + /* Mix with applying left over gain steps that aren't aligned multiples of 4. */ + for(;pos < BufferSize && pos < Counter;pos++) { - for(;pos < BufferSize && pos < Counter;pos++) - { - OutBuffer[c][OutPos+pos] += data[pos]*DrySend; - DrySend *= Step; - } + OutBuffer[c][OutPos+pos] += data[pos]*DrySend; + DrySend *= Step; } + /* Mix until pos is aligned with 4 or the mix is done. */ + for(;pos < BufferSize && (pos&3) != 0;pos++) + OutBuffer[c][OutPos+pos] += data[pos]*DrySend; params->Mix.Gains.Current[srcchan][c] = DrySend; } @@ -237,14 +239,13 @@ void MixSend_SSE(SendParams *params, const ALfloat *restrict data, } while(BufferSize-pos > 3 && Counter-pos > 3); WetGain = _mm_cvtss_f32(_mm_shuffle_ps(gain, gain, _MM_SHUFFLE(3, 3, 3, 3))); } - if(!(BufferSize-pos > 3)) + for(;pos < BufferSize && pos < Counter;pos++) { - for(;pos < BufferSize && pos < Counter;pos++) - { - OutBuffer[0][OutPos+pos] += data[pos]*WetGain; - WetGain *= Step; - } + OutBuffer[0][OutPos+pos] += data[pos]*WetGain; + WetGain *= Step; } + for(;pos < BufferSize && (pos&3) != 0;pos++) + OutBuffer[0][OutPos+pos] += data[pos]*WetGain; params->Gain.Current = WetGain; } -- cgit v1.2.3