mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/D3D12MemoryAllocator.git
synced 2024-11-24 04:50:12 +00:00
Pass "use mutex" flag to AllocationObjectAllocator.
This commit is contained in:
parent
8991a630c5
commit
b901f4d92e
@ -2790,8 +2790,8 @@ class AllocationObjectAllocator
|
|||||||
{
|
{
|
||||||
D3D12MA_CLASS_NO_COPY(AllocationObjectAllocator);
|
D3D12MA_CLASS_NO_COPY(AllocationObjectAllocator);
|
||||||
public:
|
public:
|
||||||
AllocationObjectAllocator(const ALLOCATION_CALLBACKS& allocationCallbacks)
|
AllocationObjectAllocator(const ALLOCATION_CALLBACKS& allocationCallbacks, bool useMutex)
|
||||||
: m_Allocator(allocationCallbacks, 1024) {}
|
: m_Allocator(allocationCallbacks, 1024), m_UseMutex(useMutex) {}
|
||||||
|
|
||||||
template<typename... Types>
|
template<typename... Types>
|
||||||
Allocation* Allocate(Types... args);
|
Allocation* Allocate(Types... args);
|
||||||
@ -2799,6 +2799,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
D3D12MA_MUTEX m_Mutex;
|
D3D12MA_MUTEX m_Mutex;
|
||||||
|
bool m_UseMutex;
|
||||||
PoolAllocator<Allocation> m_Allocator;
|
PoolAllocator<Allocation> m_Allocator;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2806,13 +2807,13 @@ private:
|
|||||||
template<typename... Types>
|
template<typename... Types>
|
||||||
Allocation* AllocationObjectAllocator::Allocate(Types... args)
|
Allocation* AllocationObjectAllocator::Allocate(Types... args)
|
||||||
{
|
{
|
||||||
MutexLock mutexLock(m_Mutex);
|
MutexLock mutexLock(m_Mutex, m_UseMutex);
|
||||||
return m_Allocator.Alloc(std::forward<Types>(args)...);
|
return m_Allocator.Alloc(std::forward<Types>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AllocationObjectAllocator::Free(Allocation* alloc)
|
void AllocationObjectAllocator::Free(Allocation* alloc)
|
||||||
{
|
{
|
||||||
MutexLock mutexLock(m_Mutex);
|
MutexLock mutexLock(m_Mutex, m_UseMutex);
|
||||||
m_Allocator.Free(alloc);
|
m_Allocator.Free(alloc);
|
||||||
}
|
}
|
||||||
#endif // _D3D12MA_ALLOCATION_OBJECT_ALLOCATOR_FUNCTIONS
|
#endif // _D3D12MA_ALLOCATION_OBJECT_ALLOCATOR_FUNCTIONS
|
||||||
@ -6094,7 +6095,7 @@ AllocatorPimpl::AllocatorPimpl(const ALLOCATION_CALLBACKS& allocationCallbacks,
|
|||||||
m_AllocationCallbacks(allocationCallbacks),
|
m_AllocationCallbacks(allocationCallbacks),
|
||||||
m_CurrentFrameIndex(0),
|
m_CurrentFrameIndex(0),
|
||||||
// Below this line don't use allocationCallbacks but m_AllocationCallbacks!!!
|
// Below this line don't use allocationCallbacks but m_AllocationCallbacks!!!
|
||||||
m_AllocationObjectAllocator(m_AllocationCallbacks)
|
m_AllocationObjectAllocator(m_AllocationCallbacks, m_UseMutex)
|
||||||
{
|
{
|
||||||
// desc.pAllocationCallbacks intentionally ignored here, preprocessed by CreateAllocator.
|
// desc.pAllocationCallbacks intentionally ignored here, preprocessed by CreateAllocator.
|
||||||
ZeroMemory(&m_D3D12Options, sizeof(m_D3D12Options));
|
ZeroMemory(&m_D3D12Options, sizeof(m_D3D12Options));
|
||||||
|
Loading…
Reference in New Issue
Block a user