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

Function vmaCreateImage

include/vk_mem_alloc.h:16528–16621  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16526}
16527
16528VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateImage(
16529 VmaAllocator allocator,
16530 const VkImageCreateInfo* pImageCreateInfo,
16531 const VmaAllocationCreateInfo* pAllocationCreateInfo,
16532 VkImage* pImage,
16533 VmaAllocation* pAllocation,
16534 VmaAllocationInfo* pAllocationInfo)
16535{
16536 VMA_ASSERT(allocator && pImageCreateInfo && pAllocationCreateInfo && pImage && pAllocation);
16537
16538 VMA_ASSERT((pImageCreateInfo->flags & VK_IMAGE_CREATE_DISJOINT_BIT_COPY) == 0 &&
16539 "vmaCreateImage() doesn't support disjoint multi-planar images. Please allocate memory for the planes using vmaAllocateMemory() and bind them using vmaBindImageMemory2().");
16540
16541 if(pImageCreateInfo->extent.width == 0 ||
16542 pImageCreateInfo->extent.height == 0 ||
16543 pImageCreateInfo->extent.depth == 0 ||
16544 pImageCreateInfo->mipLevels == 0 ||
16545 pImageCreateInfo->arrayLayers == 0)
16546 {
16547 return VK_ERROR_INITIALIZATION_FAILED;
16548 }
16549
16550 VMA_DEBUG_LOG("vmaCreateImage");
16551
16552 VMA_DEBUG_GLOBAL_MUTEX_LOCK
16553
16554 *pImage = VK_NULL_HANDLE;
16555 *pAllocation = VK_NULL_HANDLE;
16556
16557 // 1. Create VkImage.
16558 VkResult res = (*allocator->GetVulkanFunctions().vkCreateImage)(
16559 allocator->m_hDevice,
16560 pImageCreateInfo,
16561 allocator->GetAllocationCallbacks(),
16562 pImage);
16563 if(res == VK_SUCCESS)
16564 {
16565 VmaSuballocationType suballocType = pImageCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL ?
16566 VMA_SUBALLOCATION_TYPE_IMAGE_OPTIMAL :
16567 VMA_SUBALLOCATION_TYPE_IMAGE_LINEAR;
16568
16569 // 2. Allocate memory using allocator.
16570 VkMemoryRequirements vkMemReq = {};
16571 bool requiresDedicatedAllocation = false;
16572 bool prefersDedicatedAllocation = false;
16573 allocator->GetImageMemoryRequirements(*pImage, vkMemReq,
16574 requiresDedicatedAllocation, prefersDedicatedAllocation);
16575
16576 res = allocator->AllocateMemory(
16577 vkMemReq,
16578 requiresDedicatedAllocation,
16579 prefersDedicatedAllocation,
16580 VK_NULL_HANDLE, // dedicatedBuffer
16581 *pImage, // dedicatedImage
16582 VmaBufferImageUsage(*pImageCreateInfo), // dedicatedBufferImageUsage
16583 *pAllocationCreateInfo,
16584 suballocType,
16585 1, // allocationCount

Callers

nothing calls this directly

Calls 8

VmaBufferImageUsageClass · 0.85
AllocateMemoryMethod · 0.80
BindImageMemoryMethod · 0.80
InitImageUsageMethod · 0.80
GetAllocationInfoMethod · 0.80
FreeMemoryMethod · 0.80

Tested by

no test coverage detected