From 4b99e2273f14f28b5d18f7ec96cefbba605b2dd3 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 5 Feb 2019 13:40:56 -0800 Subject: Fixed issue with counting invalid master blocks in DynamicHeap (fixed https://github.com/DiligentGraphics/DiligentEngine/issues/33) --- Graphics/GraphicsEngineNextGenBase/include/DynamicHeap.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'Graphics/GraphicsEngineNextGenBase') diff --git a/Graphics/GraphicsEngineNextGenBase/include/DynamicHeap.h b/Graphics/GraphicsEngineNextGenBase/include/DynamicHeap.h index 52d122a3..146f00df 100644 --- a/Graphics/GraphicsEngineNextGenBase/include/DynamicHeap.h +++ b/Graphics/GraphicsEngineNextGenBase/include/DynamicHeap.h @@ -131,7 +131,7 @@ public: StaleMasterBlock (const StaleMasterBlock&) = delete; StaleMasterBlock& operator= (const StaleMasterBlock&) = delete; StaleMasterBlock& operator= ( StaleMasterBlock&&) = delete; - + StaleMasterBlock(StaleMasterBlock&& rhs)noexcept : Block (std::move(rhs.Block)), Mgr (rhs.Mgr) @@ -154,6 +154,7 @@ public: }; for(auto& Block : Blocks) { + DEV_CHECK_ERR(Block.IsValid(), "Attempting to release invalid master block"); Device.SafeReleaseDeviceObject(StaleMasterBlock{std::move(Block), this}, CmdQueueMask); } } @@ -169,10 +170,14 @@ protected: MasterBlock AllocateMasterBlock(OffsetType SizeInBytes, OffsetType Alignment) { std::lock_guard Lock(m_AllocationsMgrMtx); + auto NewBlock = m_AllocationsMgr.Allocate(SizeInBytes, Alignment); #ifdef DEVELOPMENT - ++m_MasterBlockCounter; + if (NewBlock.IsValid()) + { + ++m_MasterBlockCounter; + } #endif - return m_AllocationsMgr.Allocate(SizeInBytes, Alignment); + return NewBlock; } private: -- cgit v1.2.3