aboutsummaryrefslogtreecommitdiffstats
path: root/alc/alu.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-08-02 11:07:48 -0700
committerChris Robinson <[email protected]>2019-08-02 11:07:48 -0700
commitce7c86b21731b026f12f53dda42b9553ebd94fee (patch)
tree294ec48ca20438d90088c77ad7fefc0c62873f05 /alc/alu.cpp
parent61bb079036aa90a819f58d1c26b4f3c14588b218 (diff)
Avoid reloading the voices array when processing
Diffstat (limited to 'alc/alu.cpp')
-rw-r--r--alc/alu.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp
index 7d333fcb..253dbe48 100644
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -1343,20 +1343,20 @@ void CalcSourceParams(ALvoice *voice, ALCcontext *context, bool force)
}
-void ProcessParamUpdates(ALCcontext *ctx, const ALeffectslotArray *slots)
+void ProcessParamUpdates(ALCcontext *ctx, const ALeffectslotArray &slots,
+ const al::span<ALvoice> voices)
{
IncrementRef(ctx->mUpdateCount);
if(LIKELY(!ctx->mHoldUpdates.load(std::memory_order_acquire)))
{
bool cforce{CalcContextParams(ctx)};
bool force{CalcListenerParams(ctx) || cforce};
- force = std::accumulate(slots->begin(), slots->end(), force,
+ force = std::accumulate(slots.begin(), slots.end(), force,
[ctx,cforce](bool force, ALeffectslot *slot) -> bool
{ return CalcEffectSlotParams(slot, ctx, cforce) | force; }
);
- std::for_each(ctx->mVoices->begin(),
- ctx->mVoices->begin() + ctx->mVoiceCount.load(std::memory_order_acquire),
+ std::for_each(voices.begin(), voices.end(),
[ctx,force](ALvoice &voice) -> void
{
ALuint sid{voice.mSourceID.load(std::memory_order_acquire)};
@@ -1371,13 +1371,15 @@ void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo)
{
ASSUME(SamplesToDo > 0);
- const ALeffectslotArray *auxslots{ctx->mActiveAuxSlots.load(std::memory_order_acquire)};
+ const ALeffectslotArray &auxslots = *ctx->mActiveAuxSlots.load(std::memory_order_acquire);
+ const al::span<ALvoice> voices{ctx->mVoices->data(),
+ ctx->mVoiceCount.load(std::memory_order_acquire)};
/* Process pending propery updates for objects on the context. */
- ProcessParamUpdates(ctx, auxslots);
+ ProcessParamUpdates(ctx, auxslots, voices);
/* Clear auxiliary effect slot mixing buffers. */
- std::for_each(auxslots->begin(), auxslots->end(),
+ std::for_each(auxslots.begin(), auxslots.end(),
[SamplesToDo](ALeffectslot *slot) -> void
{
for(auto &buffer : slot->MixBuffer)
@@ -1386,8 +1388,7 @@ void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo)
);
/* Process voices that have a playing source. */
- std::for_each(ctx->mVoices->begin(),
- ctx->mVoices->begin() + ctx->mVoiceCount.load(std::memory_order_acquire),
+ std::for_each(voices.begin(), voices.end(),
[SamplesToDo,ctx](ALvoice &voice) -> void
{
const ALvoice::State vstate{voice.mPlayState.load(std::memory_order_acquire)};
@@ -1400,9 +1401,9 @@ void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo)
);
/* Process effects. */
- if(auxslots->size() < 1) return;
- auto slots = auxslots->data();
- auto slots_end = slots + auxslots->size();
+ if(auxslots.empty()) return;
+ auto slots = auxslots.data();
+ auto slots_end = slots + auxslots.size();
/* First sort the slots into scratch storage, so that effects come before
* their effect target (or their targets' target).