mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
synced 2024-11-27 06:20:05 +00:00
Introduced a rule that custom pool with linear algorithm must have maxBlockCount = 1 (or 0 for default).
This commit is contained in:
parent
0ebdf0c63e
commit
f799c4f146
@ -1821,6 +1821,16 @@ static void TestLinearAllocator()
|
||||
bufInfo.clear();
|
||||
}
|
||||
|
||||
// Try to create pool with maxBlockCount higher than 1. It should fail.
|
||||
{
|
||||
VmaPoolCreateInfo altPoolCreateInfo = poolCreateInfo;
|
||||
altPoolCreateInfo.maxBlockCount = 2;
|
||||
|
||||
VmaPool altPool = nullptr;
|
||||
res = vmaCreatePool(g_hAllocator, &altPoolCreateInfo, &altPool);
|
||||
assert(res != VK_SUCCESS);
|
||||
}
|
||||
|
||||
vmaDestroyPool(g_hAllocator, pool);
|
||||
}
|
||||
|
||||
|
@ -11543,13 +11543,23 @@ bool VmaAllocator_T::TouchAllocation(VmaAllocation hAllocation)
|
||||
|
||||
VkResult VmaAllocator_T::CreatePool(const VmaPoolCreateInfo* pCreateInfo, VmaPool* pPool)
|
||||
{
|
||||
VMA_DEBUG_LOG(" CreatePool: MemoryTypeIndex=%u", pCreateInfo->memoryTypeIndex);
|
||||
VMA_DEBUG_LOG(" CreatePool: MemoryTypeIndex=%u, flags=%u", pCreateInfo->memoryTypeIndex, pCreateInfo->flags);
|
||||
|
||||
const bool isLinearAlgorithm = (pCreateInfo->flags & VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT) != 0;
|
||||
|
||||
VmaPoolCreateInfo newCreateInfo = *pCreateInfo;
|
||||
|
||||
if(newCreateInfo.maxBlockCount == 0)
|
||||
{
|
||||
newCreateInfo.maxBlockCount = SIZE_MAX;
|
||||
newCreateInfo.maxBlockCount = isLinearAlgorithm ? 1 : SIZE_MAX;
|
||||
}
|
||||
if(newCreateInfo.minBlockCount > newCreateInfo.maxBlockCount)
|
||||
{
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
if(isLinearAlgorithm && newCreateInfo.maxBlockCount > 1)
|
||||
{
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
if(newCreateInfo.blockSize == 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user