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

source

pub fn new(create_info: VirtualBlockCreateInfo<'_>) -> VkResult<Self>

Creates new VirtualBlock object.

source

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)
source

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.

source

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!

source

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.

source

pub unsafe fn set_allocation_user_data( &self, allocation: &mut VirtualAllocation, user_data: *mut c_void )

Changes custom pointer associated with given virtual allocation.

Trait Implementations§

source§

impl Drop for VirtualBlock

Custom Drop implementation to clean up internal VirtualBlock instance

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.