diff --git a/docs/html/group__group__virtual.html b/docs/html/group__group__virtual.html index 8d6a883..79b0eb8 100644 --- a/docs/html/group__group__virtual.html +++ b/docs/html/group__group__virtual.html @@ -610,7 +610,7 @@ Functions

Allocates new virtual allocation inside given VmaVirtualBlock.

-

If the allocation fails due to not enough free space available, VK_ERROR_OUT_OF_DEVICE_MEMORY is returned (despite the function doesn't ever allocate actual GPU memory). pAllocation is then set to VK_NULL_HANDLE AND pOffset, if not null, it set to UINT64_MAX.

+

If the allocation fails due to not enough free space available, VK_ERROR_OUT_OF_DEVICE_MEMORY is returned (despite the function doesn't ever allocate actual GPU memory). pAllocation is then set to VK_NULL_HANDLE and pOffset, if not null, it set to UINT64_MAX.

Parameters
@@ -650,6 +650,7 @@ Functions

Frees virtual allocation inside given VmaVirtualBlock.

+

It is correct to call this function with allocation == VK_NULL_HANDLE - it does nothing.

diff --git a/docs/html/struct_vma_virtual_allocation.html b/docs/html/struct_vma_virtual_allocation.html index bfbfd39..9744aa2 100644 --- a/docs/html/struct_vma_virtual_allocation.html +++ b/docs/html/struct_vma_virtual_allocation.html @@ -72,7 +72,8 @@ $(function() {

#include <vk_mem_alloc.h>

Detailed Description

Represents single memory allocation done inside VmaVirtualBlock.

-

Use it as a unique identifier to virtual allocation within the single block.

+

Use it as a unique identifier to virtual allocation within the single block.

+

Use value VK_NULL_HANDLE to represent a null/invalid allocation.


The documentation for this struct was generated from the following file: diff --git a/include/vk_mem_alloc.h b/include/vk_mem_alloc.h index c210ef7..84e6414 100644 --- a/include/vk_mem_alloc.h +++ b/include/vk_mem_alloc.h @@ -833,6 +833,8 @@ VK_DEFINE_HANDLE(VmaDefragmentationContext) \brief Represents single memory allocation done inside VmaVirtualBlock. Use it as a unique identifier to virtual allocation within the single block. + +Use value `VK_NULL_HANDLE` to represent a null/invalid allocation. */ VK_DEFINE_NON_DISPATCHABLE_HANDLE(VmaVirtualAllocation); @@ -2382,6 +2384,8 @@ VMA_CALL_PRE VkResult VMA_CALL_POST vmaVirtualAllocate( VkDeviceSize* VMA_NULLABLE pOffset); /** \brief Frees virtual allocation inside given #VmaVirtualBlock. + +It is correct to call this function with `allocation == VK_NULL_HANDLE` - it does nothing. */ VMA_CALL_PRE void VMA_CALL_POST vmaVirtualFree( VmaVirtualBlock VMA_NOT_NULL virtualBlock, @@ -6572,7 +6576,7 @@ bool VmaBlockMetadata_Generic::Validate() const { if (!IsVirtual()) { - VMA_VALIDATE((VkDeviceSize)alloc->GetAllocHandle() == subAlloc.offset); + VMA_VALIDATE((VkDeviceSize)alloc->GetAllocHandle() == subAlloc.offset + 1); VMA_VALIDATE(alloc->GetSize() == subAlloc.size); } @@ -7435,7 +7439,7 @@ bool VmaBlockMetadata_Linear::Validate() const { if (!IsVirtual()) { - VMA_VALIDATE((VkDeviceSize)alloc->GetAllocHandle() == suballoc.offset); + VMA_VALIDATE((VkDeviceSize)alloc->GetAllocHandle() == suballoc.offset + 1); VMA_VALIDATE(alloc->GetSize() == suballoc.size); } sumUsedSize += suballoc.size; @@ -7477,7 +7481,7 @@ bool VmaBlockMetadata_Linear::Validate() const { if (!IsVirtual()) { - VMA_VALIDATE((VkDeviceSize)alloc->GetAllocHandle() == suballoc.offset); + VMA_VALIDATE((VkDeviceSize)alloc->GetAllocHandle() == suballoc.offset + 1); VMA_VALIDATE(alloc->GetSize() == suballoc.size); } sumUsedSize += suballoc.size; @@ -7511,7 +7515,7 @@ bool VmaBlockMetadata_Linear::Validate() const { if (!IsVirtual()) { - VMA_VALIDATE((VkDeviceSize)alloc->GetAllocHandle() == suballoc.offset); + VMA_VALIDATE((VkDeviceSize)alloc->GetAllocHandle() == suballoc.offset + 1); VMA_VALIDATE(alloc->GetSize() == suballoc.size); } sumUsedSize += suballoc.size; @@ -17847,7 +17851,7 @@ VMA_CALL_PRE VkResult VMA_CALL_POST vmaVirtualAllocate(VmaVirtualBlock VMA_NOT_N VMA_CALL_PRE void VMA_CALL_POST vmaVirtualFree(VmaVirtualBlock VMA_NOT_NULL virtualBlock, VmaVirtualAllocation allocation) { - if(virtualBlock != VMA_NULL) + if(allocation != VK_NULL_HANDLE) { VMA_ASSERT(virtualBlock != VK_NULL_HANDLE); VMA_DEBUG_LOG("vmaVirtualFree"); diff --git a/src/Tests.cpp b/src/Tests.cpp index 99e6dc8..843fe1d 100644 --- a/src/Tests.cpp +++ b/src/Tests.cpp @@ -2799,6 +2799,9 @@ static void TestVirtualBlocks() vmaVirtualFree(block, allocation0); + // # Test free of null allocation. + vmaVirtualFree(block, VK_NULL_HANDLE); + // # Test alignment {
virtualBlockVirtual block