pub struct ManagedBuffer { /* private fields */ }Expand description
RAII wrapper for automatic buffer deallocation
Implementations§
Source§impl ManagedBuffer
impl ManagedBuffer
Sourcepub fn new(buffer: GpuBuffer, pool: Arc<MemoryPool>) -> Self
pub fn new(buffer: GpuBuffer, pool: Arc<MemoryPool>) -> Self
Create a new managed buffer
Sourcepub fn buffer(&self) -> &GpuBuffer
pub fn buffer(&self) -> &GpuBuffer
Get a reference to the buffer.
§Panics
Panics if the buffer has already been released via ManagedBuffer::take.
Under normal usage this cannot happen because take() consumes self.
Sourcepub fn try_buffer(&self) -> Result<&GpuBuffer>
pub fn try_buffer(&self) -> Result<&GpuBuffer>
Fallible variant of ManagedBuffer::buffer.
§Errors
Returns GpuError::Internal if the buffer has already been released.
Methods from Deref<Target = GpuBuffer>§
Sourcepub async fn read_async(
&self,
_device: &GpuDevice,
offset: u64,
size: u64,
) -> Result<Vec<u8>>
pub async fn read_async( &self, _device: &GpuDevice, offset: u64, size: u64, ) -> Result<Vec<u8>>
Sourcepub fn buffer_type(&self) -> BufferType
pub fn buffer_type(&self) -> BufferType
Get buffer type
Sourcepub fn copy_to(
&self,
encoder: &mut CommandEncoder,
dst: &Self,
src_offset: u64,
dst_offset: u64,
size: u64,
) -> Result<()>
pub fn copy_to( &self, encoder: &mut CommandEncoder, dst: &Self, src_offset: u64, dst_offset: u64, size: u64, ) -> Result<()>
Copy data from this buffer to another buffer
§Arguments
encoder- Command encoder for recording the copy operationdst- Destination buffersrc_offset- Source offset in bytesdst_offset- Destination offset in bytessize- Number of bytes to copy
§Errors
Returns an error if offsets or size are invalid.
Trait Implementations§
Source§impl Deref for ManagedBuffer
impl Deref for ManagedBuffer
Auto Trait Implementations§
impl Freeze for ManagedBuffer
impl !RefUnwindSafe for ManagedBuffer
impl Send for ManagedBuffer
impl Sync for ManagedBuffer
impl Unpin for ManagedBuffer
impl UnsafeUnpin for ManagedBuffer
impl !UnwindSafe for ManagedBuffer
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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