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

Method CreateAllocationRequest_LowerAddress

include/vk_mem_alloc.h:8557–8733  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8555}
8556
8557bool VmaBlockMetadata_Linear::CreateAllocationRequest_LowerAddress(
8558 VkDeviceSize allocSize,
8559 VkDeviceSize allocAlignment,
8560 VmaSuballocationType allocType,
8561 uint32_t strategy,
8562 VmaAllocationRequest* pAllocationRequest)
8563{
8564 const VkDeviceSize blockSize = GetSize();
8565 const VkDeviceSize debugMargin = GetDebugMargin();
8566 const VkDeviceSize bufferImageGranularity = GetBufferImageGranularity();
8567 SuballocationVectorType& suballocations1st = AccessSuballocations1st();
8568 SuballocationVectorType& suballocations2nd = AccessSuballocations2nd();
8569
8570 if (m_2ndVectorMode == SECOND_VECTOR_EMPTY || m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK)
8571 {
8572 // Try to allocate at the end of 1st vector.
8573
8574 VkDeviceSize resultBaseOffset = 0;
8575 if (!suballocations1st.empty())
8576 {
8577 const VmaSuballocation& lastSuballoc = suballocations1st.back();
8578 resultBaseOffset = lastSuballoc.offset + lastSuballoc.size + debugMargin;
8579 }
8580
8581 // Start from offset equal to beginning of free space.
8582 VkDeviceSize resultOffset = resultBaseOffset;
8583
8584 // Apply alignment.
8585 resultOffset = VmaAlignUp(resultOffset, allocAlignment);
8586
8587 // Check previous suballocations for BufferImageGranularity conflicts.
8588 // Make bigger alignment if necessary.
8589 if (bufferImageGranularity > 1 && bufferImageGranularity != allocAlignment && !suballocations1st.empty())
8590 {
8591 bool bufferImageGranularityConflict = false;
8592 for (size_t prevSuballocIndex = suballocations1st.size(); prevSuballocIndex--; )
8593 {
8594 const VmaSuballocation& prevSuballoc = suballocations1st[prevSuballocIndex];
8595 if (VmaBlocksOnSamePage(prevSuballoc.offset, prevSuballoc.size, resultOffset, bufferImageGranularity))
8596 {
8597 if (VmaIsBufferImageGranularityConflict(prevSuballoc.type, allocType))
8598 {
8599 bufferImageGranularityConflict = true;
8600 break;
8601 }
8602 }
8603 else
8604 // Already on previous page.
8605 break;
8606 }
8607 if (bufferImageGranularityConflict)
8608 {
8609 resultOffset = VmaAlignUp(resultOffset, bufferImageGranularity);
8610 }
8611 }
8612
8613 const VkDeviceSize freeSpaceEnd = m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK ?
8614 suballocations2nd.back().offset : blockSize;

Callers

nothing calls this directly

Calls 6

VmaAlignUpFunction · 0.85
VmaBlocksOnSamePageFunction · 0.85
GetSizeFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected