pub struct GpuBufferPool { /* private fields */ }Expand description
A pool allocator that sub-allocates from a large backing buffer.
Implementations§
Source§impl GpuBufferPool
impl GpuBufferPool
Sourcepub fn alloc(
&mut self,
size: usize,
buffer_type: GpuBufferType,
) -> Option<GpuBufferHandle>
pub fn alloc( &mut self, size: usize, buffer_type: GpuBufferType, ) -> Option<GpuBufferHandle>
Allocate size bytes from the pool. Returns None if out of memory.
Sourcepub fn free(&mut self, handle: GpuBufferHandle)
pub fn free(&mut self, handle: GpuBufferHandle)
Free a previously allocated handle.
Sourcepub fn defragment(&mut self)
pub fn defragment(&mut self)
Defragment: compact live allocations to the front of the pool.
Allocations are re-packed in insertion order (by id).
Sourcepub fn write(
&mut self,
handle: &GpuBufferHandle,
offset: usize,
src: &[u8],
) -> usize
pub fn write( &mut self, handle: &GpuBufferHandle, offset: usize, src: &[u8], ) -> usize
Write bytes to a handle’s region.
Sourcepub fn read(
&self,
handle: &GpuBufferHandle,
offset: usize,
dst: &mut [u8],
) -> usize
pub fn read( &self, handle: &GpuBufferHandle, offset: usize, dst: &mut [u8], ) -> usize
Read bytes from a handle’s region.
Sourcepub fn allocation_count(&self) -> usize
pub fn allocation_count(&self) -> usize
Number of live allocations.
Sourcepub fn used_bytes(&self) -> usize
pub fn used_bytes(&self) -> usize
Bytes used (sum of aligned allocations).
Sourcepub fn free_bytes(&self) -> usize
pub fn free_bytes(&self) -> usize
Free bytes remaining (approximate; does not account for freed holes before defrag).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GpuBufferPool
impl RefUnwindSafe for GpuBufferPool
impl Send for GpuBufferPool
impl Sync for GpuBufferPool
impl Unpin for GpuBufferPool
impl UnsafeUnpin for GpuBufferPool
impl UnwindSafe for GpuBufferPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more