Don't store and manage wet buffers separately
parent
0f4679981b
commit
af5d4fb77d
20
alc/alc.cpp
20
alc/alc.cpp
|
@ -2217,13 +2217,6 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
|
|||
std::unique_lock<std::mutex> proplock{context->mPropLock};
|
||||
std::unique_lock<std::mutex> slotlock{context->mEffectSlotLock};
|
||||
|
||||
/* Clear out unused wet buffers. */
|
||||
auto buffer_not_in_use = [](WetBufferPtr &wetbuffer) noexcept -> bool
|
||||
{ return !wetbuffer->mInUse; };
|
||||
auto wetbuffer_iter = std::remove_if(context->mWetBuffers.begin(),
|
||||
context->mWetBuffers.end(), buffer_not_in_use);
|
||||
context->mWetBuffers.erase(wetbuffer_iter, context->mWetBuffers.end());
|
||||
|
||||
/* Clear out unused effect slot clusters. */
|
||||
auto slot_cluster_not_in_use = [](ContextBase::EffectSlotCluster &cluster)
|
||||
{
|
||||
|
@ -2238,6 +2231,19 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
|
|||
context->mEffectSlotClusters.end(), slot_cluster_not_in_use);
|
||||
context->mEffectSlotClusters.erase(slotcluster_iter, context->mEffectSlotClusters.end());
|
||||
|
||||
/* Free all wet buffers. Any in use will be reallocated with an updated
|
||||
* configuration in aluInitEffectPanning.
|
||||
*/
|
||||
for(auto&& slots : context->mEffectSlotClusters)
|
||||
{
|
||||
for(size_t i{0};i < ContextBase::EffectSlotClusterSize;++i)
|
||||
{
|
||||
slots[i].mWetBuffer.clear();
|
||||
slots[i].mWetBuffer.shrink_to_fit();
|
||||
slots[i].Wet.Buffer = {};
|
||||
}
|
||||
}
|
||||
|
||||
if(ALeffectslot *slot{context->mDefaultSlot.get()})
|
||||
{
|
||||
aluInitEffectPanning(slot->mSlot, context);
|
||||
|
|
|
@ -128,9 +128,6 @@ ALCcontext::~ALCcontext()
|
|||
eax_uninitialize();
|
||||
#endif // ALSOFT_EAX
|
||||
|
||||
/* Delete the ALeffectslots, so the EffectSlots can be deleted before the
|
||||
* WetBuffers are deleted.
|
||||
*/
|
||||
mDefaultSlot = nullptr;
|
||||
count = std::accumulate(mEffectSlotList.cbegin(), mEffectSlotList.cend(), size_t{0u},
|
||||
[](size_t cur, const EffectSlotSubList &sublist) noexcept -> size_t
|
||||
|
@ -139,8 +136,6 @@ ALCcontext::~ALCcontext()
|
|||
WARN("%zu AuxiliaryEffectSlot%s not deleted\n", count, (count==1)?"":"s");
|
||||
mEffectSlotList.clear();
|
||||
mNumEffectSlots = 0;
|
||||
|
||||
mEffectSlotClusters.clear();
|
||||
}
|
||||
|
||||
void ALCcontext::init()
|
||||
|
|
|
@ -68,9 +68,6 @@ struct EffectSlotSubList {
|
|||
struct ALCcontext : public al::intrusive_ref<ALCcontext>, ContextBase {
|
||||
const al::intrusive_ptr<ALCdevice> mALDevice;
|
||||
|
||||
/* Wet buffers used by effect slots. */
|
||||
al::vector<WetBufferPtr> mWetBuffers;
|
||||
|
||||
|
||||
bool mPropsDirty{true};
|
||||
bool mDeferUpdates{false};
|
||||
|
|
|
@ -1129,49 +1129,12 @@ void aluInitEffectPanning(EffectSlot *slot, ALCcontext *context)
|
|||
DeviceBase *device{context->mDevice};
|
||||
const size_t count{AmbiChannelsFromOrder(device->mAmbiOrder)};
|
||||
|
||||
auto wetbuffer_iter = context->mWetBuffers.end();
|
||||
if(slot->mWetBuffer)
|
||||
{
|
||||
/* If the effect slot already has a wet buffer attached, allocate a new
|
||||
* one in its place.
|
||||
*/
|
||||
wetbuffer_iter = context->mWetBuffers.begin();
|
||||
for(;wetbuffer_iter != context->mWetBuffers.end();++wetbuffer_iter)
|
||||
{
|
||||
if(wetbuffer_iter->get() == slot->mWetBuffer)
|
||||
{
|
||||
slot->mWetBuffer = nullptr;
|
||||
slot->Wet.Buffer = {};
|
||||
|
||||
*wetbuffer_iter = WetBufferPtr{new(FamCount(count)) WetBuffer{count}};
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(wetbuffer_iter == context->mWetBuffers.end())
|
||||
{
|
||||
/* Otherwise, search for an unused wet buffer. */
|
||||
wetbuffer_iter = context->mWetBuffers.begin();
|
||||
for(;wetbuffer_iter != context->mWetBuffers.end();++wetbuffer_iter)
|
||||
{
|
||||
if(!(*wetbuffer_iter)->mInUse)
|
||||
break;
|
||||
}
|
||||
if(wetbuffer_iter == context->mWetBuffers.end())
|
||||
{
|
||||
/* Otherwise, allocate a new one to use. */
|
||||
context->mWetBuffers.emplace_back(WetBufferPtr{new(FamCount(count)) WetBuffer{count}});
|
||||
wetbuffer_iter = context->mWetBuffers.end()-1;
|
||||
}
|
||||
}
|
||||
WetBuffer *wetbuffer{slot->mWetBuffer = wetbuffer_iter->get()};
|
||||
wetbuffer->mInUse = true;
|
||||
slot->mWetBuffer.resize(count);
|
||||
|
||||
auto acnmap_begin = AmbiIndex::FromACN().begin();
|
||||
auto iter = std::transform(acnmap_begin, acnmap_begin + count, slot->Wet.AmbiMap.begin(),
|
||||
[](const uint8_t &acn) noexcept -> BFChannelConfig
|
||||
{ return BFChannelConfig{1.0f, acn}; });
|
||||
std::fill(iter, slot->Wet.AmbiMap.end(), BFChannelConfig{});
|
||||
slot->Wet.Buffer = wetbuffer->mBuffer;
|
||||
slot->Wet.Buffer = slot->mWetBuffer;
|
||||
}
|
||||
|
|
|
@ -40,17 +40,6 @@ enum class DistanceModel : unsigned char {
|
|||
};
|
||||
|
||||
|
||||
struct WetBuffer {
|
||||
bool mInUse;
|
||||
al::FlexArray<FloatBufferLine, 16> mBuffer;
|
||||
|
||||
WetBuffer(size_t count) : mBuffer{count} { }
|
||||
|
||||
DEF_FAM_NEWDEL(WetBuffer, mBuffer)
|
||||
};
|
||||
using WetBufferPtr = std::unique_ptr<WetBuffer>;
|
||||
|
||||
|
||||
struct ContextProps {
|
||||
std::array<float,3> Position;
|
||||
std::array<float,3> Velocity;
|
||||
|
|
|
@ -17,9 +17,3 @@ EffectSlotArray *EffectSlot::CreatePtrArray(size_t count) noexcept
|
|||
void *ptr{al_calloc(alignof(EffectSlotArray), EffectSlotArray::Sizeof(count*2))};
|
||||
return al::construct_at(static_cast<EffectSlotArray*>(ptr), count);
|
||||
}
|
||||
|
||||
EffectSlot::~EffectSlot()
|
||||
{
|
||||
if(mWetBuffer)
|
||||
mWetBuffer->mInUse = false;
|
||||
}
|
||||
|
|
|
@ -78,9 +78,8 @@ struct EffectSlot {
|
|||
float AirAbsorptionGainHF{1.0f};
|
||||
|
||||
/* Mixing buffer used by the Wet mix. */
|
||||
WetBuffer *mWetBuffer{nullptr};
|
||||
al::vector<FloatBufferLine,16> mWetBuffer;
|
||||
|
||||
~EffectSlot();
|
||||
|
||||
static EffectSlotArray *CreatePtrArray(size_t count) noexcept;
|
||||
|
||||
|
|
Loading…
Reference in New Issue