Struct wgpu_async::AsyncBuffer
source · pub struct AsyncBufferwhere
Self: WasmNotSend,{ /* private fields */ }Expand description
A wrapper around a wgpu::Buffer which shadows some methods to allow for async
mapping using Rust’s async API.
Implementations§
source§impl AsyncBuffer
impl AsyncBuffer
sourcepub fn slice<S: RangeBounds<BufferAddress>>(
&self,
bounds: S,
) -> AsyncBufferSlice<'_>
pub fn slice<S: RangeBounds<BufferAddress>>( &self, bounds: S, ) -> AsyncBufferSlice<'_>
Takes a slice of this buffer, in the same way a call to wgpu::Buffer::slice would,
except wraps the result in an AsyncBufferSlice so that the map_async method can be
awaited.
Methods from Deref<Target = Buffer>§
sourcepub fn as_entire_binding(&self) -> BindingResource<'_>
pub fn as_entire_binding(&self) -> BindingResource<'_>
Return the binding view of the entire buffer.
sourcepub fn as_entire_buffer_binding(&self) -> BufferBinding<'_>
pub fn as_entire_buffer_binding(&self) -> BufferBinding<'_>
Return the binding view of the entire buffer.
sourcepub unsafe fn as_hal<A, F, R>(&self, hal_buffer_callback: F) -> R
pub unsafe fn as_hal<A, F, R>(&self, hal_buffer_callback: F) -> R
Returns the inner hal Buffer using a callback. The hal buffer will be None if the
backend type argument does not match with this wgpu Buffer
§Safety
- The raw handle obtained from the hal Buffer must not be manually destroyed
sourcepub fn slice<S>(&self, bounds: S) -> BufferSlice<'_>where
S: RangeBounds<u64>,
pub fn slice<S>(&self, bounds: S) -> BufferSlice<'_>where
S: RangeBounds<u64>,
Return a slice of a Buffer’s bytes.
Return a BufferSlice referring to the portion of self’s contents
indicated by bounds. Regardless of what sort of data self stores,
bounds start and end are given in bytes.
A BufferSlice can be used to supply vertex and index data, or to map
buffer contents for access from the CPU. See the BufferSlice
documentation for details.
The range argument can be half or fully unbounded: for example,
buffer.slice(..) refers to the entire buffer, and buffer.slice(n..)
refers to the portion starting at the nth byte and extending to the
end of the buffer.
sourcepub fn unmap(&self)
pub fn unmap(&self)
Flushes any pending write operations and unmaps the buffer from host memory.
sourcepub fn size(&self) -> u64
pub fn size(&self) -> u64
Returns the length of the buffer allocation in bytes.
This is always equal to the size that was specified when creating the buffer.
sourcepub fn usage(&self) -> BufferUsages
pub fn usage(&self) -> BufferUsages
Returns the allowed usages for this Buffer.
This is always equal to the usage that was specified when creating the buffer.