mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
synced 2024-11-09 22:20:07 +00:00
Merge pull request #249 from JustSid/master
Fixed two issues with the new defragmenter
This commit is contained in:
commit
9b8303f72b
@ -10909,6 +10909,7 @@ public:
|
|||||||
size_t GetBlockCount() const { return m_Blocks.size(); }
|
size_t GetBlockCount() const { return m_Blocks.size(); }
|
||||||
// To be used only while the m_Mutex is locked. Used during defragmentation.
|
// To be used only while the m_Mutex is locked. Used during defragmentation.
|
||||||
VmaDeviceMemoryBlock* GetBlock(size_t index) const { return m_Blocks[index]; }
|
VmaDeviceMemoryBlock* GetBlock(size_t index) const { return m_Blocks[index]; }
|
||||||
|
VMA_RW_MUTEX &GetMutex() { return m_Mutex; }
|
||||||
|
|
||||||
VkResult CreateMinBlocks();
|
VkResult CreateMinBlocks();
|
||||||
void AddStatistics(VmaStatistics& inoutStats);
|
void AddStatistics(VmaStatistics& inoutStats);
|
||||||
@ -13064,6 +13065,8 @@ VkResult VmaDefragmentationContext_T::DefragmentPassBegin(VmaDefragmentationPass
|
|||||||
{
|
{
|
||||||
if (m_PoolBlockVector != VMA_NULL)
|
if (m_PoolBlockVector != VMA_NULL)
|
||||||
{
|
{
|
||||||
|
VmaMutexLockWrite lock(m_PoolBlockVector->GetMutex(), m_PoolBlockVector->GetAllocator()->m_UseMutex);
|
||||||
|
|
||||||
if (m_PoolBlockVector->GetBlockCount() > 1)
|
if (m_PoolBlockVector->GetBlockCount() > 1)
|
||||||
ComputeDefragmentation(*m_PoolBlockVector, 0);
|
ComputeDefragmentation(*m_PoolBlockVector, 0);
|
||||||
else if (m_PoolBlockVector->GetBlockCount() == 1)
|
else if (m_PoolBlockVector->GetBlockCount() == 1)
|
||||||
@ -13075,6 +13078,8 @@ VkResult VmaDefragmentationContext_T::DefragmentPassBegin(VmaDefragmentationPass
|
|||||||
{
|
{
|
||||||
if (m_pBlockVectors[i] != VMA_NULL)
|
if (m_pBlockVectors[i] != VMA_NULL)
|
||||||
{
|
{
|
||||||
|
VmaMutexLockWrite lock(m_pBlockVectors[i]->GetMutex(), m_pBlockVectors[i]->GetAllocator()->m_UseMutex);
|
||||||
|
|
||||||
if (m_pBlockVectors[i]->GetBlockCount() > 1)
|
if (m_pBlockVectors[i]->GetBlockCount() > 1)
|
||||||
{
|
{
|
||||||
if (ComputeDefragmentation(*m_pBlockVectors[i], i))
|
if (ComputeDefragmentation(*m_pBlockVectors[i], i))
|
||||||
@ -13276,7 +13281,7 @@ VkResult VmaDefragmentationContext_T::DefragmentPassEnd(VmaDefragmentationPassMo
|
|||||||
for (const FragmentedBlock& block : immovableBlocks)
|
for (const FragmentedBlock& block : immovableBlocks)
|
||||||
{
|
{
|
||||||
VmaBlockVector* vector = m_pBlockVectors[block.data];
|
VmaBlockVector* vector = m_pBlockVectors[block.data];
|
||||||
for (size_t i = m_ImmovableBlockCount; vector->GetBlockCount(); ++i)
|
for (size_t i = m_ImmovableBlockCount; i < vector->GetBlockCount(); ++i)
|
||||||
{
|
{
|
||||||
if (vector->GetBlock(i) == block.block)
|
if (vector->GetBlock(i) == block.block)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user