Struct 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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.