Allocator

Struct Allocator 

Source
pub struct Allocator<LT: Lifetime> { /* private fields */ }
Expand description

The general purpose memory allocator. Implemented as a segregated list allocator.

Implementations§

Source§

impl<LT: Lifetime> Allocator<LT>

Source

pub unsafe fn new( instance: &Instance, physical_device: PhysicalDevice, descriptor: &AllocatorDescriptor, ) -> Result<Self, AllocatorError>

Creates a new allocator.

§Safety

Caller needs to make sure that the provided instance and device are in a valid state.

Source

pub unsafe fn allocate_memory_for_buffer( &self, device: &Device, buffer: Buffer, location: MemoryLocation, lifetime: LT, ) -> Result<Allocation<LT>, AllocatorError>

Allocates memory for a buffer.

§Safety

Caller needs to make sure that the provided device and buffer are in a valid state.

Source

pub unsafe fn allocate_memory_for_image( &self, device: &Device, image: Image, location: MemoryLocation, lifetime: LT, is_optimal: bool, ) -> Result<Allocation<LT>, AllocatorError>

Allocates memory for an image. is_optimal must be set true if the image is a optimal image (a regular texture).

§Safety

Caller needs to make sure that the provided device and image are in a valid state.

Source

pub unsafe fn allocate( &self, device: &Device, descriptor: &AllocationDescriptor<LT>, ) -> Result<Allocation<LT>, AllocatorError>

Allocates memory on the allocator.

§Safety

Caller needs to make sure that the provided device is in a valid state.

Source

pub unsafe fn deallocate( &self, device: &Device, allocation: &Allocation<LT>, ) -> Result<(), AllocatorError>

Frees the allocation.

§Safety

Caller needs to make sure that the allocation is not in use anymore and will not be used after being deallocated.

Source

pub unsafe fn cleanup(&self, device: &Device)

Releases all memory blocks back to the system. Should be called before drop.

§Safety

Caller needs to make sure that no allocations are used anymore and will not being used after calling this function.

Source

pub fn allocation_count(&self) -> usize

Number of allocations.

Source

pub fn unused_range_count(&self) -> usize

Number of unused ranges between allocations.

Source

pub fn used_bytes(&self) -> DeviceSize

Number of bytes used by the allocations.

Source

pub fn unused_bytes(&self) -> DeviceSize

Number of bytes used by the unused ranges between allocations.

Source

pub fn block_count(&self) -> usize

Number of allocated Vulkan memory blocks.

Trait Implementations§

Source§

impl<LT: Debug + Lifetime> Debug for Allocator<LT>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<LT> !Freeze for Allocator<LT>

§

impl<LT> !RefUnwindSafe for Allocator<LT>

§

impl<LT> Send for Allocator<LT>
where LT: Send,

§

impl<LT> Sync for Allocator<LT>
where LT: Send + Sync,

§

impl<LT> Unpin for Allocator<LT>
where LT: Unpin,

§

impl<LT> UnwindSafe for Allocator<LT>
where LT: UnwindSafe,

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.