mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2024-11-23 07:14:34 +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();
|
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);
|
vmaDestroyPool(g_hAllocator, pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11543,13 +11543,23 @@ bool VmaAllocator_T::TouchAllocation(VmaAllocation hAllocation)
|
|||||||
|
|
||||||
VkResult VmaAllocator_T::CreatePool(const VmaPoolCreateInfo* pCreateInfo, VmaPool* pPool)
|
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;
|
VmaPoolCreateInfo newCreateInfo = *pCreateInfo;
|
||||||
|
|
||||||
if(newCreateInfo.maxBlockCount == 0)
|
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)
|
if(newCreateInfo.blockSize == 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user