Struct vma::VirtualBlock
source · pub struct VirtualBlock { /* private fields */ }
Expand description
Handle to a virtual block object that allows to use core allocation algorithm without allocating any real GPU memory.
For more info: https://gpuopen-librariesandsdks.github.io/VulkanMemoryAllocator/html/virtual_allocator.html
Implementations§
source§impl VirtualBlock
impl VirtualBlock
sourcepub fn new(create_info: VirtualBlockCreateInfo<'_>) -> VkResult<Self>
pub fn new(create_info: VirtualBlockCreateInfo<'_>) -> VkResult<Self>
Creates new VirtualBlock object.
sourcepub unsafe fn allocate(
&mut self,
allocation_info: VirtualAllocationCreateInfo
) -> VkResult<(VirtualAllocation, u64)>
pub unsafe fn allocate( &mut self, allocation_info: VirtualAllocationCreateInfo ) -> VkResult<(VirtualAllocation, u64)>
Allocates new virtual allocation inside given VirtualBlock.
Possible error values:
ash::vk::Result::ERROR_OUT_OF_DEVICE_MEMORY
- Allocation failed due to not enough free space in the virtual block. (despite the function doesn’t ever allocate actual GPU memory)
sourcepub unsafe fn free(&mut self, allocation: &mut VirtualAllocation)
pub unsafe fn free(&mut self, allocation: &mut VirtualAllocation)
Frees virtual allocation inside given VirtualBlock.
It is correct to call this function with allocation == VK_NULL_HANDLE
- it does nothing.
sourcepub unsafe fn clear(&mut self)
pub unsafe fn clear(&mut self)
Frees all virtual allocations inside given VirtualBlock.
You must either call this function or free each virtual allocation individually with vmaVirtualFree() before destroying a virtual block. Otherwise, an assert is called.
If you keep pointer to some additional metadata associated with your virtual allocation in its user_data
,
don’t forget to free it as well.
Any VirtualAllocations created previously in the VirtualBlock will no longer be valid!
sourcepub unsafe fn get_allocation_info(
&self,
allocation: &VirtualAllocation
) -> VkResult<VirtualAllocationInfo>
pub unsafe fn get_allocation_info( &self, allocation: &VirtualAllocation ) -> VkResult<VirtualAllocationInfo>
Returns information about a specific virtual allocation within a virtual block, like its size and user_data pointer.
sourcepub unsafe fn set_allocation_user_data(
&self,
allocation: &mut VirtualAllocation,
user_data: *mut c_void
)
pub unsafe fn set_allocation_user_data( &self, allocation: &mut VirtualAllocation, user_data: *mut c_void )
Changes custom pointer associated with given virtual allocation.