MCPcopy Create free account
hub / github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator / CreatePool

Method CreatePool

include/vk_mem_alloc.h:14868–14919  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14866}
14867
14868VkResult VmaAllocator_T::CreatePool(const VmaPoolCreateInfo* pCreateInfo, VmaPool* pPool)
14869{
14870 VMA_DEBUG_LOG_FORMAT(" CreatePool: MemoryTypeIndex=%" PRIu32 ", flags=%" PRIu32, pCreateInfo->memoryTypeIndex, pCreateInfo->flags);
14871
14872 VmaPoolCreateInfo newCreateInfo = *pCreateInfo;
14873
14874 // Protection against uninitialized new structure member. If garbage data are left there, this pointer dereference would crash.
14875 if(pCreateInfo->pMemoryAllocateNext)
14876 {
14877 VMA_ASSERT(((const VkBaseInStructure*)pCreateInfo->pMemoryAllocateNext)->sType != 0);
14878 }
14879
14880 if(newCreateInfo.maxBlockCount == 0)
14881 {
14882 newCreateInfo.maxBlockCount = SIZE_MAX;
14883 }
14884 if(newCreateInfo.minBlockCount > newCreateInfo.maxBlockCount)
14885 {
14886 return VK_ERROR_INITIALIZATION_FAILED;
14887 }
14888 // Memory type index out of range or forbidden.
14889 if(pCreateInfo->memoryTypeIndex >= GetMemoryTypeCount() ||
14890 ((1U << pCreateInfo->memoryTypeIndex) & m_GlobalMemoryTypeBits) == 0)
14891 {
14892 return VK_ERROR_FEATURE_NOT_PRESENT;
14893 }
14894 if(newCreateInfo.minAllocationAlignment > 0)
14895 {
14896 VMA_ASSERT(VmaIsPow2(newCreateInfo.minAllocationAlignment));
14897 }
14898
14899 const VkDeviceSize preferredBlockSize = CalcPreferredBlockSize(newCreateInfo.memoryTypeIndex);
14900
14901 *pPool = vma_new(this, VmaPool_T)(this, newCreateInfo, preferredBlockSize);
14902
14903 VkResult res = (*pPool)->m_BlockVector.CreateMinBlocks();
14904 if(res != VK_SUCCESS)
14905 {
14906 vma_delete(this, *pPool);
14907 *pPool = VMA_NULL;
14908 return res;
14909 }
14910
14911 // Add to m_Pools.
14912 {
14913 VmaMutexLockWrite lock(m_PoolsMutex, m_UseMutex);
14914 (*pPool)->SetId(m_NextPoolId++);
14915 m_Pools.PushBack(*pPool);
14916 }
14917
14918 return VK_SUCCESS;
14919}
14920
14921void VmaAllocator_T::DestroyPool(VmaPool pool)
14922{

Callers

nothing calls this directly

Calls 5

VmaIsPow2Function · 0.85
vma_deleteFunction · 0.85
CreateMinBlocksMethod · 0.80
SetIdMethod · 0.80
PushBackMethod · 0.80

Tested by

no test coverage detected