From bc393d8fd195f2d4400b6aeb42fa40b92d6b4b68 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Thu, 21 Jun 2018 21:33:43 -0700 Subject: Improved memory allocation for shader variables and resource cache in Vk backend --- Common/src/FixedBlockMemoryAllocator.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'Common/src') diff --git a/Common/src/FixedBlockMemoryAllocator.cpp b/Common/src/FixedBlockMemoryAllocator.cpp index 261336ea..37a21e36 100644 --- a/Common/src/FixedBlockMemoryAllocator.cpp +++ b/Common/src/FixedBlockMemoryAllocator.cpp @@ -26,25 +26,22 @@ namespace Diligent { - FixedBlockMemoryAllocator::FixedBlockMemoryAllocator(IMemoryAllocator &RawMemoryAllocator, size_t BlockSize, Uint32 NumBlocksInPage) : - m_PagePool(STD_ALLOCATOR_RAW_MEM(MemoryPage, RawMemoryAllocator, "Allocator for vector")), - m_AvailablePages(STD_ALLOCATOR_RAW_MEM(size_t, RawMemoryAllocator, "Allocator for unordered_set")), - m_AddrToPageId(STD_ALLOCATOR_RAW_MEM(AddrToPageIdMapElem, RawMemoryAllocator, "Allocator for unordered_map")), + FixedBlockMemoryAllocator::FixedBlockMemoryAllocator(IMemoryAllocator& RawMemoryAllocator, + size_t BlockSize, + Uint32 NumBlocksInPage) : + m_PagePool (STD_ALLOCATOR_RAW_MEM(MemoryPage, RawMemoryAllocator, "Allocator for vector")), + m_AvailablePages (STD_ALLOCATOR_RAW_MEM(size_t, RawMemoryAllocator, "Allocator for unordered_set")), + m_AddrToPageId (STD_ALLOCATOR_RAW_MEM(AddrToPageIdMapElem, RawMemoryAllocator, "Allocator for unordered_map")), m_RawMemoryAllocator(RawMemoryAllocator), - m_BlockSize(BlockSize), - m_NumBlocksInPage(NumBlocksInPage) + m_BlockSize (BlockSize), + m_NumBlocksInPage (NumBlocksInPage) { - //tmpLargeBuffer = new Uint8[100 << 20]; - //tmpCurrPtr = tmpLargeBuffer; - // Allocate one page CreateNewPage(); } FixedBlockMemoryAllocator::~FixedBlockMemoryAllocator() { - //delete[] tmpLargeBuffer; - #ifdef _DEBUG for (size_t p = 0; p < m_PagePool.size(); ++p) { @@ -63,10 +60,6 @@ namespace Diligent void* FixedBlockMemoryAllocator::Allocate( size_t Size, const Char* dbgDescription, const char* dbgFileName, const Int32 dbgLineNumber) { - //auto *ptr = tmpCurrPtr; - //tmpCurrPtr += Size; - //return ptr; - VERIFY(m_BlockSize == Size, "Requested size (", Size, ") does not match the block size (", m_BlockSize, ")"); std::lock_guard LockGuard(m_Mutex); -- cgit v1.2.3