Go to the documentation of this file.
60 m_RingBuffer{Size, Allocator}
72 std::lock_guard<std::mutex> Lock{m_RingBufferMtx};
78 std::lock_guard<std::mutex> Lock{m_RingBufferMtx};
88 std::lock_guard<std::mutex> Lock{m_RingBufferMtx};
89 return m_RingBuffer.
Allocate(SizeInBytes, Alignment);
93 std::mutex m_RingBufferMtx;
106 m_AllocationsMgr{Size, Allocator}
108 #ifdef DILIGENT_DEVELOPMENT
109 m_MasterBlockCounter = 0;
122 DEV_CHECK_ERR(m_MasterBlockCounter == 0, m_MasterBlockCounter,
" master block(s) have not been returned to the manager");
125 template <
typename RenderDeviceImplType>
128 struct StaleMasterBlock
135 Block {std::move(_Block)},
140 StaleMasterBlock (
const StaleMasterBlock&) =
delete;
141 StaleMasterBlock&
operator= (
const StaleMasterBlock&) =
delete;
142 StaleMasterBlock&
operator= ( StaleMasterBlock&&) =
delete;
144 StaleMasterBlock(StaleMasterBlock&& rhs)noexcept :
145 Block {std::move(rhs.Block)},
157 std::lock_guard<std::mutex> Lock{Mgr->m_AllocationsMgrMtx};
158 #ifdef DILIGENT_DEVELOPMENT
159 --Mgr->m_MasterBlockCounter;
161 Mgr->m_AllocationsMgr.
Free(std::move(Block));
165 for (
auto& Block : Blocks)
167 DEV_CHECK_ERR(Block.IsValid(),
"Attempting to release invalid master block");
168 Device.SafeReleaseDeviceObject(StaleMasterBlock{std::move(Block),
this}, CmdQueueMask);
177 #ifdef DILIGENT_DEVELOPMENT
178 int32_t GetMasterBlockCounter()
const
180 return m_MasterBlockCounter;
187 std::lock_guard<std::mutex> Lock{m_AllocationsMgrMtx};
188 auto NewBlock = m_AllocationsMgr.
Allocate(SizeInBytes, Alignment);
189 #ifdef DILIGENT_DEVELOPMENT
190 if (NewBlock.IsValid())
192 ++m_MasterBlockCounter;
199 std::mutex m_AllocationsMgrMtx;
202 #ifdef DILIGENT_DEVELOPMENT
203 std::atomic_int32_t m_MasterBlockCounter;
MasterBlockRingBufferBasedManager(IMemoryAllocator &Allocator, Uint32 Size)
Definition: DynamicHeap.hpp:58
Implementation of a ring buffer. The class is not thread-safe.
Definition: RingBuffer.hpp:43
OffsetType GetMaxSize() const
Definition: RingBuffer.hpp:225
void FinishCurrentFrame(Uint64 FenceValue)
Definition: RingBuffer.hpp:181
Definition: VariableSizeAllocationsManager.hpp:64
void ReleaseCompletedFrames(Uint64 CompletedFenceValue)
Definition: RingBuffer.hpp:197
Definition: DynamicHeap.hpp:51
MasterBlockListBasedManager(IMemoryAllocator &Allocator, Uint32 Size)
Definition: DynamicHeap.hpp:104
OffsetType GetMaxSize() const
Definition: VariableSizeAllocationsManager.hpp:357
uint64_t Uint64
64-bit unsigned integer
Definition: BasicTypes.h:50
~MasterBlockListBasedManager()
Definition: DynamicHeap.hpp:120
Definition: VariableSizeAllocationsManager.hpp:156
MasterBlock AllocateMasterBlock(OffsetType SizeInBytes, OffsetType Alignment)
Definition: DynamicHeap.hpp:185
OffsetType GetSize() const
Definition: DynamicHeap.hpp:173
void DiscardMasterBlocks(std::vector< MasterBlock > &, Uint64 FenceValue)
Definition: DynamicHeap.hpp:70
OffsetType GetUsedSize() const
Definition: DynamicHeap.hpp:174
OffsetType GetUsedSize() const
Definition: VariableSizeAllocationsManager.hpp:359
#define DEV_CHECK_ERR(...)
Definition: DebugUtilities.hpp:90
static constexpr const OffsetType InvalidOffset
Definition: DynamicHeap.hpp:56
RingBuffer::OffsetType OffsetType
Definition: DynamicHeap.hpp:54
OffsetType Allocate(OffsetType Size, OffsetType Alignment)
Definition: RingBuffer.hpp:115
OffsetType GetUsedSize() const
Definition: DynamicHeap.hpp:83
Allocation Allocate(OffsetType Size, OffsetType Alignment)
Definition: VariableSizeAllocationsManager.hpp:188
static constexpr const OffsetType InvalidOffset
Definition: RingBuffer.hpp:63
OffsetType GetUsedSize() const
Definition: RingBuffer.hpp:228
MasterBlockRingBufferBasedManager & operator=(const MasterBlockRingBufferBasedManager &)=delete
size_t OffsetType
Definition: VariableSizeAllocationsManager.hpp:67
void ReleaseStaleBlocks(Uint64 LastCompletedFenceValue)
Definition: DynamicHeap.hpp:76
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
RingBuffer::OffsetType MasterBlock
Definition: DynamicHeap.hpp:55
size_t OffsetType
Definition: RingBuffer.hpp:46
Base interface for a raw memory allocator.
Definition: MemoryAllocator.h:41
OffsetType GetSize() const
Definition: DynamicHeap.hpp:82
void ReleaseMasterBlocks(std::vector< MasterBlock > &Blocks, RenderDeviceImplType &Device, Uint64 CmdQueueMask)
Definition: DynamicHeap.hpp:126
MasterBlockListBasedManager & operator=(const MasterBlockListBasedManager &)=delete
MasterBlock AllocateMasterBlock(OffsetType SizeInBytes, OffsetType Alignment)
Definition: DynamicHeap.hpp:86
Definition: DynamicHeap.hpp:98
VariableSizeAllocationsManager::OffsetType OffsetType
Definition: DynamicHeap.hpp:101
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
void Free(Allocation &&allocation)
Definition: VariableSizeAllocationsManager.hpp:251