MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / vmaCreateBufferWithAlignment

Function vmaCreateBufferWithAlignment

include/vk_mem_alloc.h:16349–16442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16347}
16348
16349VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateBufferWithAlignment(
16350 VmaAllocator allocator,
16351 const VkBufferCreateInfo* pBufferCreateInfo,
16352 const VmaAllocationCreateInfo* pAllocationCreateInfo,
16353 VkDeviceSize minAlignment,
16354 VkBuffer* pBuffer,
16355 VmaAllocation* pAllocation,
16356 VmaAllocationInfo* pAllocationInfo)
16357{
16358 VMA_ASSERT(allocator && pBufferCreateInfo && pAllocationCreateInfo && VmaIsPow2(minAlignment) && pBuffer && pAllocation);
16359
16360 if(pBufferCreateInfo->size == 0)
16361 {
16362 return VK_ERROR_INITIALIZATION_FAILED;
16363 }
16364 if((pBufferCreateInfo->usage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_COPY) != 0 &&
16365 !allocator->m_UseKhrBufferDeviceAddress)
16366 {
16367 VMA_ASSERT(0 && "Creating a buffer with VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT is not valid if VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT was not used.");
16368 return VK_ERROR_INITIALIZATION_FAILED;
16369 }
16370
16371 VMA_DEBUG_LOG("vmaCreateBufferWithAlignment");
16372
16373 VMA_DEBUG_GLOBAL_MUTEX_LOCK
16374
16375 *pBuffer = VK_NULL_HANDLE;
16376 *pAllocation = VK_NULL_HANDLE;
16377
16378 // 1. Create VkBuffer.
16379 VkResult res = (*allocator->GetVulkanFunctions().vkCreateBuffer)(
16380 allocator->m_hDevice,
16381 pBufferCreateInfo,
16382 allocator->GetAllocationCallbacks(),
16383 pBuffer);
16384 if(res >= 0)
16385 {
16386 // 2. vkGetBufferMemoryRequirements.
16387 VkMemoryRequirements vkMemReq = {};
16388 bool requiresDedicatedAllocation = false;
16389 bool prefersDedicatedAllocation = false;
16390 allocator->GetBufferMemoryRequirements(*pBuffer, vkMemReq,
16391 requiresDedicatedAllocation, prefersDedicatedAllocation);
16392
16393 // 2a. Include minAlignment
16394 vkMemReq.alignment = VMA_MAX(vkMemReq.alignment, minAlignment);
16395
16396 // 3. Allocate memory using allocator.
16397 res = allocator->AllocateMemory(
16398 vkMemReq,
16399 requiresDedicatedAllocation,
16400 prefersDedicatedAllocation,
16401 *pBuffer, // dedicatedBuffer
16402 VK_NULL_HANDLE, // dedicatedImage
16403 VmaBufferImageUsage(*pBufferCreateInfo, allocator->m_UseKhrMaintenance5), // dedicatedBufferImageUsage
16404 *pAllocationCreateInfo,
16405 VMA_SUBALLOCATION_TYPE_BUFFER,
16406 1, // allocationCount

Callers

nothing calls this directly

Calls 9

VmaIsPow2Function · 0.85
VmaBufferImageUsageClass · 0.85
AllocateMemoryMethod · 0.80
BindBufferMemoryMethod · 0.80
InitBufferUsageMethod · 0.80
GetAllocationInfoMethod · 0.80
FreeMemoryMethod · 0.80

Tested by

no test coverage detected