From dd9d30e2489d938d5ec0d75702c82b943a1b3efa Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 16 Sep 2012 06:19:39 -0700 Subject: [PATCH] Implement an SSE MixSend method --- Alc/mixer_sse.c | 29 +++++++++++++++++++++++++++++ OpenAL32/Include/alAuxEffectSlot.h | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Alc/mixer_sse.c b/Alc/mixer_sse.c index 84884de3..c7898ce8 100644 --- a/Alc/mixer_sse.c +++ b/Alc/mixer_sse.c @@ -10,6 +10,7 @@ #include "alu.h" #include "alSource.h" +#include "alAuxEffectSlot.h" #include "mixer_defs.h" static __inline ALfloat lerp32(const ALfloat *vals, ALint step, ALuint frac) @@ -311,6 +312,34 @@ void MixDirect_SSE(ALsource *Source, ALCdevice *Device, DirectParams *params, } #define NO_MIXDIRECT +void MixSend_SSE(SendParams *params, const ALfloat *RESTRICT data, + ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize) +{ + ALeffectslot *Slot = params->Slot; + ALfloat *RESTRICT WetBuffer = Slot->WetBuffer; + ALfloat *RESTRICT WetClickRemoval = Slot->ClickRemoval; + ALfloat *RESTRICT WetPendingClicks = Slot->PendingClicks; + const ALfloat WetGain = params->Gain; + const __m128 gain = _mm_set1_ps(WetGain); + ALuint pos; + + pos = 0; + if(OutPos == 0) + WetClickRemoval[0] -= data[pos] * WetGain; + for(pos = 0;pos < BufferSize-3;pos+=4) + { + const __m128 val4 = _mm_load_ps(&data[pos]); + __m128 wet4 = _mm_load_ps(&WetBuffer[OutPos+pos]); + wet4 = _mm_add_ps(wet4, _mm_mul_ps(val4, gain)); + _mm_store_ps(&WetBuffer[OutPos+pos], wet4); + } + for(;pos < BufferSize;pos++) + WetBuffer[OutPos+pos] += data[pos] * WetGain; + if(OutPos == SamplesToDo) + WetPendingClicks[0] += data[pos] * WetGain; +} +#define NO_MIXSEND + #define SUFFIX SSE #include "mixer_inc.c" diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h index f025118f..cfa61a5f 100644 --- a/OpenAL32/Include/alAuxEffectSlot.h +++ b/OpenAL32/Include/alAuxEffectSlot.h @@ -26,7 +26,7 @@ typedef struct ALeffectslot volatile ALenum NeedsUpdate; ALeffectState *EffectState; - ALfloat WetBuffer[BUFFERSIZE]; + ALIGN(16) ALfloat WetBuffer[BUFFERSIZE]; ALfloat ClickRemoval[1]; ALfloat PendingClicks[1]; -- 2.11.4.GIT