| 16256 | } |
| 16257 | |
| 16258 | VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateBuffer( |
| 16259 | VmaAllocator allocator, |
| 16260 | const VkBufferCreateInfo* pBufferCreateInfo, |
| 16261 | const VmaAllocationCreateInfo* pAllocationCreateInfo, |
| 16262 | VkBuffer* pBuffer, |
| 16263 | VmaAllocation* pAllocation, |
| 16264 | VmaAllocationInfo* pAllocationInfo) |
| 16265 | { |
| 16266 | VMA_ASSERT(allocator && pBufferCreateInfo && pAllocationCreateInfo && pBuffer && pAllocation); |
| 16267 | |
| 16268 | if(pBufferCreateInfo->size == 0) |
| 16269 | { |
| 16270 | return VK_ERROR_INITIALIZATION_FAILED; |
| 16271 | } |
| 16272 | if((pBufferCreateInfo->usage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_COPY) != 0 && |
| 16273 | !allocator->m_UseKhrBufferDeviceAddress) |
| 16274 | { |
| 16275 | 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."); |
| 16276 | return VK_ERROR_INITIALIZATION_FAILED; |
| 16277 | } |
| 16278 | |
| 16279 | VMA_DEBUG_LOG("vmaCreateBuffer"); |
| 16280 | |
| 16281 | VMA_DEBUG_GLOBAL_MUTEX_LOCK |
| 16282 | |
| 16283 | *pBuffer = VK_NULL_HANDLE; |
| 16284 | *pAllocation = VK_NULL_HANDLE; |
| 16285 | |
| 16286 | // 1. Create VkBuffer. |
| 16287 | VkResult res = (*allocator->GetVulkanFunctions().vkCreateBuffer)( |
| 16288 | allocator->m_hDevice, |
| 16289 | pBufferCreateInfo, |
| 16290 | allocator->GetAllocationCallbacks(), |
| 16291 | pBuffer); |
| 16292 | if(res >= 0) |
| 16293 | { |
| 16294 | // 2. vkGetBufferMemoryRequirements. |
| 16295 | VkMemoryRequirements vkMemReq = {}; |
| 16296 | bool requiresDedicatedAllocation = false; |
| 16297 | bool prefersDedicatedAllocation = false; |
| 16298 | allocator->GetBufferMemoryRequirements(*pBuffer, vkMemReq, |
| 16299 | requiresDedicatedAllocation, prefersDedicatedAllocation); |
| 16300 | |
| 16301 | // 3. Allocate memory using allocator. |
| 16302 | res = allocator->AllocateMemory( |
| 16303 | vkMemReq, |
| 16304 | requiresDedicatedAllocation, |
| 16305 | prefersDedicatedAllocation, |
| 16306 | *pBuffer, // dedicatedBuffer |
| 16307 | VK_NULL_HANDLE, // dedicatedImage |
| 16308 | VmaBufferImageUsage(*pBufferCreateInfo, allocator->m_UseKhrMaintenance5), // dedicatedBufferImageUsage |
| 16309 | *pAllocationCreateInfo, |
| 16310 | VMA_SUBALLOCATION_TYPE_BUFFER, |
| 16311 | 1, // allocationCount |
| 16312 | pAllocation); |
| 16313 | |
| 16314 | if(res >= 0) |
| 16315 | { |
nothing calls this directly
no test coverage detected