mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
synced 2024-11-05 04:10:06 +00:00
Implemented vmaClearVirtualBlock
This commit is contained in:
parent
9a091e8ccb
commit
cc61fe10d8
@ -7767,13 +7767,10 @@ void VmaBlockMetadata_Generic::Init(VkDeviceSize size)
|
||||
suballoc.offset = 0;
|
||||
suballoc.size = size;
|
||||
suballoc.type = VMA_SUBALLOCATION_TYPE_FREE;
|
||||
suballoc.userData = VMA_NULL;
|
||||
|
||||
VMA_ASSERT(size > VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER);
|
||||
m_Suballocations.push_back(suballoc);
|
||||
VmaSuballocationList::iterator suballocItem = m_Suballocations.end();
|
||||
--suballocItem;
|
||||
m_FreeSuballocationsBySize.push_back(suballocItem);
|
||||
m_FreeSuballocationsBySize.push_back(m_Suballocations.begin());
|
||||
}
|
||||
|
||||
bool VmaBlockMetadata_Generic::Validate() const
|
||||
@ -8288,7 +8285,22 @@ void VmaBlockMetadata_Generic::GetAllocationInfo(VkDeviceSize offset, VmaVirtual
|
||||
|
||||
void VmaBlockMetadata_Generic::Clear()
|
||||
{
|
||||
VMA_ASSERT(0 && "TODO implement");
|
||||
const VkDeviceSize size = GetSize();
|
||||
|
||||
VMA_ASSERT(IsVirtual());
|
||||
m_FreeCount = 1;
|
||||
m_SumFreeSize = size;
|
||||
m_Suballocations.clear();
|
||||
m_FreeSuballocationsBySize.clear();
|
||||
|
||||
VmaSuballocation suballoc = {};
|
||||
suballoc.offset = 0;
|
||||
suballoc.size = size;
|
||||
suballoc.type = VMA_SUBALLOCATION_TYPE_FREE;
|
||||
m_Suballocations.push_back(suballoc);
|
||||
|
||||
VMA_ASSERT(size > VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER);
|
||||
m_FreeSuballocationsBySize.push_back(m_Suballocations.begin());
|
||||
}
|
||||
|
||||
void VmaBlockMetadata_Generic::SetAllocationUserData(VkDeviceSize offset, void* userData)
|
||||
|
@ -2799,9 +2799,24 @@ static void TestVirtualBlocks()
|
||||
// # Final cleanup
|
||||
|
||||
vmaVirtualFree(block, alloc2Offset);
|
||||
|
||||
//vmaClearVirtualBlock(block);
|
||||
vmaDestroyVirtualBlock(block);
|
||||
|
||||
{
|
||||
// Another virtual block, using Clear this time.
|
||||
TEST(vmaCreateVirtualBlock(&blockCreateInfo, &block) == VK_SUCCESS);
|
||||
|
||||
allocCreateInfo = VmaVirtualAllocationCreateInfo{};
|
||||
allocCreateInfo.size = MEGABYTE;
|
||||
|
||||
for(size_t i = 0; i < 8; ++i)
|
||||
{
|
||||
VkDeviceSize offset = 0;
|
||||
TEST(vmaVirtualAllocate(block, &allocCreateInfo, &offset) == VK_SUCCESS);
|
||||
}
|
||||
|
||||
vmaClearVirtualBlock(block);
|
||||
vmaDestroyVirtualBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
static void TestAllocationVersusResourceSize()
|
||||
@ -6679,7 +6694,7 @@ void Test()
|
||||
{
|
||||
wprintf(L"TESTING:\n");
|
||||
|
||||
if(true)
|
||||
if(false)
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Temporarily insert custom tests here:
|
||||
|
Loading…
Reference in New Issue
Block a user