| 8555 | } |
| 8556 | |
| 8557 | bool 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; |
nothing calls this directly
no test coverage detected