pub struct BufferPool { /* private fields */ }Expand description
Device-aware reusable GPU buffer pool.
Implementations§
Source§impl BufferPool
impl BufferPool
Sourcepub fn acquire(
&self,
device: &Device,
label: &str,
size: u64,
usage: BufferUsages,
) -> Result<PooledBuffer>
pub fn acquire( &self, device: &Device, label: &str, size: u64, usage: BufferUsages, ) -> Result<PooledBuffer>
Acquire a reusable buffer with at least size bytes and exactly usage.
§Errors
Returns Error::Gpu when pool metadata cannot be locked.
Sourcepub fn release(&self, buffer: PooledBuffer)
pub fn release(&self, buffer: PooledBuffer)
Release a buffer to the pool immediately.
Sourcepub fn with_buffer<R>(
&self,
device: &Device,
label: &str,
size: u64,
usage: BufferUsages,
f: impl FnOnce(&Buffer) -> R,
) -> Result<R>
pub fn with_buffer<R>( &self, device: &Device, label: &str, size: u64, usage: BufferUsages, f: impl FnOnce(&Buffer) -> R, ) -> Result<R>
Acquire a buffer for the duration of f and release it afterward.
§Errors
Returns Error::Gpu when buffer acquisition fails.
Trait Implementations§
Source§impl Clone for BufferPool
impl Clone for BufferPool
Source§fn clone(&self) -> BufferPool
fn clone(&self) -> BufferPool
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for BufferPool
impl Default for BufferPool
Source§fn default() -> BufferPool
fn default() -> BufferPool
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for BufferPool
impl RefUnwindSafe for BufferPool
impl Send for BufferPool
impl Sync for BufferPool
impl Unpin for BufferPool
impl UnsafeUnpin for BufferPool
impl UnwindSafe for BufferPool
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