pub struct PageSuballocator { /* private fields */ }

Implementations§

source§

impl PageSuballocator

source

pub fn for_allocation(allocation: Allocation, page_size_in_bytes: u64) -> Self

Create an allocator which takes memory from an existing allocation.

Params
  • allocation: The allocation to use for suballocations.
  • page_size_in_bytes: The size of each page in the allocation. The trade-off is that larger pages can waste memory for small allocations while small pages will increase allocation time.
Panic

Panics if allocation.size_in_bytes is not a multiple of page_size_in_bytes.

source

pub fn release_allocation(self) -> Allocation

Releases ownership of the underlying allocation.

Safety

Unsafe because:

  • ownership is transferred, regardless of existing suballocations.
  • the application must ensure that no suballocations are in-use after this call.
source

pub fn is_empty(&self) -> bool

Returns true when all suballocations have been freed.

source

pub unsafe fn allocate( &mut self, size_in_bytes: u64, alignment: u64 ) -> Result<Allocation, AllocatorError>

Suballocate a region of memory.

Params
  • size_in_bytes: the required size of the allocation.
  • alignment: the required alignment of the allocation.
Safety

Unsafe because

  • The caller must free the returned allocation
  • The caller is responsible for synchronizing access (CPU and GPU) to the underlying memory
  • The returned memory will always be aligned to the page size relative to the original allocation’s offset.
source

pub unsafe fn free(&mut self, allocation: Allocation)

Free a previously suballocated chunk of memory.

Safety

Unsafe because:

  • The caller must not free the same allocation multiple times.
  • The caller is responsible for synchronizing access to the underlying GPU memory.

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.