mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
synced 2024-11-05 12:20:07 +00:00
Internal optimization with m_pBlockVectors
This commit is contained in:
parent
ad9c5bf8d7
commit
b4d341de13
@ -13775,6 +13775,8 @@ void VmaDefragmentationContext_T::AddAllocations(
|
|||||||
pBlockVectorDefragCtx = m_DefaultPoolContexts[memTypeIndex];
|
pBlockVectorDefragCtx = m_DefaultPoolContexts[memTypeIndex];
|
||||||
if(!pBlockVectorDefragCtx)
|
if(!pBlockVectorDefragCtx)
|
||||||
{
|
{
|
||||||
|
VMA_ASSERT(m_hAllocator->m_pBlockVectors[memTypeIndex] && "Trying to use unsupported memory type!");
|
||||||
|
|
||||||
pBlockVectorDefragCtx = vma_new(m_hAllocator, VmaBlockVectorDefragmentationContext)(
|
pBlockVectorDefragCtx = vma_new(m_hAllocator, VmaBlockVectorDefragmentationContext)(
|
||||||
m_hAllocator,
|
m_hAllocator,
|
||||||
VMA_NULL, // hCustomPool
|
VMA_NULL, // hCustomPool
|
||||||
@ -14769,9 +14771,11 @@ VmaAllocator_T::VmaAllocator_T(const VmaAllocatorCreateInfo* pCreateInfo) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(uint32_t memTypeIndex = 0; memTypeIndex < GetMemoryTypeCount(); ++memTypeIndex)
|
for(uint32_t memTypeIndex = 0; memTypeIndex < GetMemoryTypeCount(); ++memTypeIndex)
|
||||||
|
{
|
||||||
|
// Create only supported types
|
||||||
|
if((m_GlobalMemoryTypeBits & (1u << memTypeIndex)) != 0)
|
||||||
{
|
{
|
||||||
const VkDeviceSize preferredBlockSize = CalcPreferredBlockSize(memTypeIndex);
|
const VkDeviceSize preferredBlockSize = CalcPreferredBlockSize(memTypeIndex);
|
||||||
|
|
||||||
m_pBlockVectors[memTypeIndex] = vma_new(this, VmaBlockVector)(
|
m_pBlockVectors[memTypeIndex] = vma_new(this, VmaBlockVector)(
|
||||||
this,
|
this,
|
||||||
VK_NULL_HANDLE, // hParentPool
|
VK_NULL_HANDLE, // hParentPool
|
||||||
@ -14789,6 +14793,7 @@ VmaAllocator_T::VmaAllocator_T(const VmaAllocatorCreateInfo* pCreateInfo) :
|
|||||||
// No need to call m_pBlockVectors[memTypeIndex][blockVectorTypeIndex]->CreateMinBlocks here,
|
// No need to call m_pBlockVectors[memTypeIndex][blockVectorTypeIndex]->CreateMinBlocks here,
|
||||||
// becase minBlockCount is 0.
|
// becase minBlockCount is 0.
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult VmaAllocator_T::Init(const VmaAllocatorCreateInfo* pCreateInfo)
|
VkResult VmaAllocator_T::Init(const VmaAllocatorCreateInfo* pCreateInfo)
|
||||||
@ -15114,7 +15119,7 @@ VkResult VmaAllocator_T::AllocateMemoryOfType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
VmaBlockVector* const blockVector = m_pBlockVectors[memTypeIndex];
|
VmaBlockVector* const blockVector = m_pBlockVectors[memTypeIndex];
|
||||||
VMA_ASSERT(blockVector);
|
VMA_ASSERT(blockVector && "Trying to use unsupported memory type!");
|
||||||
|
|
||||||
const VkDeviceSize preferredBlockSize = blockVector->GetPreferredBlockSize();
|
const VkDeviceSize preferredBlockSize = blockVector->GetPreferredBlockSize();
|
||||||
bool preferDedicatedMemory =
|
bool preferDedicatedMemory =
|
||||||
@ -15652,6 +15657,7 @@ void VmaAllocator_T::FreeMemory(
|
|||||||
{
|
{
|
||||||
const uint32_t memTypeIndex = allocation->GetMemoryTypeIndex();
|
const uint32_t memTypeIndex = allocation->GetMemoryTypeIndex();
|
||||||
pBlockVector = m_pBlockVectors[memTypeIndex];
|
pBlockVector = m_pBlockVectors[memTypeIndex];
|
||||||
|
VMA_ASSERT(pBlockVector && "Trying to free memory of unsupported type!");
|
||||||
}
|
}
|
||||||
pBlockVector->Free(allocation);
|
pBlockVector->Free(allocation);
|
||||||
}
|
}
|
||||||
@ -15685,7 +15691,7 @@ void VmaAllocator_T::CalculateStats(VmaStats* pStats)
|
|||||||
for(uint32_t memTypeIndex = 0; memTypeIndex < GetMemoryTypeCount(); ++memTypeIndex)
|
for(uint32_t memTypeIndex = 0; memTypeIndex < GetMemoryTypeCount(); ++memTypeIndex)
|
||||||
{
|
{
|
||||||
VmaBlockVector* const pBlockVector = m_pBlockVectors[memTypeIndex];
|
VmaBlockVector* const pBlockVector = m_pBlockVectors[memTypeIndex];
|
||||||
VMA_ASSERT(pBlockVector);
|
if (pBlockVector != VMA_NULL)
|
||||||
pBlockVector->AddStats(pStats);
|
pBlockVector->AddStats(pStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16053,11 +16059,10 @@ VkResult VmaAllocator_T::CheckCorruption(uint32_t memoryTypeBits)
|
|||||||
|
|
||||||
// Process default pools.
|
// Process default pools.
|
||||||
for(uint32_t memTypeIndex = 0; memTypeIndex < GetMemoryTypeCount(); ++memTypeIndex)
|
for(uint32_t memTypeIndex = 0; memTypeIndex < GetMemoryTypeCount(); ++memTypeIndex)
|
||||||
{
|
|
||||||
if(((1u << memTypeIndex) & memoryTypeBits) != 0)
|
|
||||||
{
|
{
|
||||||
VmaBlockVector* const pBlockVector = m_pBlockVectors[memTypeIndex];
|
VmaBlockVector* const pBlockVector = m_pBlockVectors[memTypeIndex];
|
||||||
VMA_ASSERT(pBlockVector);
|
if(pBlockVector != VMA_NULL)
|
||||||
|
{
|
||||||
VkResult localRes = pBlockVector->CheckCorruption();
|
VkResult localRes = pBlockVector->CheckCorruption();
|
||||||
switch(localRes)
|
switch(localRes)
|
||||||
{
|
{
|
||||||
@ -16688,9 +16693,12 @@ void VmaAllocator_T::PrintDetailedMap(VmaJsonWriter& json)
|
|||||||
bool allocationsStarted = false;
|
bool allocationsStarted = false;
|
||||||
for(uint32_t memTypeIndex = 0; memTypeIndex < GetMemoryTypeCount(); ++memTypeIndex)
|
for(uint32_t memTypeIndex = 0; memTypeIndex < GetMemoryTypeCount(); ++memTypeIndex)
|
||||||
{
|
{
|
||||||
if(m_pBlockVectors[memTypeIndex]->IsEmpty() == false)
|
VmaBlockVector* pBlockVector = m_pBlockVectors[memTypeIndex];
|
||||||
|
if(pBlockVector != VMA_NULL)
|
||||||
{
|
{
|
||||||
if(allocationsStarted == false)
|
if (pBlockVector->IsEmpty() == false)
|
||||||
|
{
|
||||||
|
if (allocationsStarted == false)
|
||||||
{
|
{
|
||||||
allocationsStarted = true;
|
allocationsStarted = true;
|
||||||
json.WriteString("DefaultPools");
|
json.WriteString("DefaultPools");
|
||||||
@ -16701,7 +16709,8 @@ void VmaAllocator_T::PrintDetailedMap(VmaJsonWriter& json)
|
|||||||
json.ContinueString(memTypeIndex);
|
json.ContinueString(memTypeIndex);
|
||||||
json.EndString();
|
json.EndString();
|
||||||
|
|
||||||
m_pBlockVectors[memTypeIndex]->PrintDetailedMap(json);
|
pBlockVector->PrintDetailedMap(json);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(allocationsStarted)
|
if(allocationsStarted)
|
||||||
|
Loading…
Reference in New Issue
Block a user