pub struct MemoryPool { /* private fields */ }Expand description
Memory pool for reusing GPU buffers
Implementations§
Source§impl MemoryPool
impl MemoryPool
Sourcepub fn allocate(
&self,
device: &GpuDevice,
size: u64,
buffer_type: BufferType,
) -> Result<GpuBuffer>
pub fn allocate( &self, device: &GpuDevice, size: u64, buffer_type: BufferType, ) -> Result<GpuBuffer>
Allocate a buffer from the pool
If a buffer of the requested size is available in the pool, it will be reused. Otherwise, a new buffer will be allocated.
§Arguments
device- GPU devicesize- Buffer size in bytesbuffer_type- Type of buffer to allocate
§Errors
Returns an error if buffer allocation fails.
Sourcepub fn deallocate(&self, buffer: GpuBuffer)
pub fn deallocate(&self, buffer: GpuBuffer)
Sourcepub fn stats(&self) -> MemoryStats
pub fn stats(&self) -> MemoryStats
Get memory statistics
Sourcepub fn allocator(&self) -> &Arc<MemoryAllocator>
pub fn allocator(&self) -> &Arc<MemoryAllocator>
Get the allocator
Auto Trait Implementations§
impl !Freeze for MemoryPool
impl !RefUnwindSafe for MemoryPool
impl Send for MemoryPool
impl Sync for MemoryPool
impl Unpin for MemoryPool
impl UnsafeUnpin for MemoryPool
impl !UnwindSafe for MemoryPool
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