pub struct AsyncBufferSlice<'a>where
Self: WasmNotSend,{ /* private fields */ }
Expand description
A smart-pointer wrapper around a wgpu::BufferSlice
, offering a map_async
method than can be await
ed.
Implementations§
Source§impl AsyncBufferSlice<'_>
impl AsyncBufferSlice<'_>
Sourcepub fn map_async(
&self,
mode: MapMode,
) -> WgpuFuture<Result<(), BufferAsyncError>> ⓘ
pub fn map_async( &self, mode: MapMode, ) -> WgpuFuture<Result<(), BufferAsyncError>> ⓘ
An awaitable version of [wgpu::Buffer::map_async
].
Methods from Deref<Target = BufferSlice<'a>>§
Sourcepub fn map_async(
&self,
mode: MapMode,
callback: impl FnOnce(Result<(), BufferAsyncError>) + WasmNotSend + 'static,
)
pub fn map_async( &self, mode: MapMode, callback: impl FnOnce(Result<(), BufferAsyncError>) + WasmNotSend + 'static, )
Map the buffer. Buffer is ready to map once the callback is called.
For the callback to complete, either queue.submit(..)
, instance.poll_all(..)
, or device.poll(..)
must be called elsewhere in the runtime, possibly integrated into an event loop or run on a separate thread.
The callback will be called on the thread that first calls the above functions after the gpu work has completed. There are no restrictions on the code you can run in the callback, however on native the call to the function will not complete until the callback returns, so prefer keeping callbacks short and used to set flags, send messages, etc.
Sourcepub fn get_mapped_range(&self) -> BufferView<'a>
pub fn get_mapped_range(&self) -> BufferView<'a>
Gain read-only access to the bytes of a mapped Buffer
.
Return a BufferView
referring to the buffer range represented by
self
. See the documentation for BufferView
for details.
§Panics
-
This panics if the buffer to which
self
refers is not currently mapped. -
If you try to create overlapping views of a buffer, mutable or otherwise,
get_mapped_range
will panic.
Sourcepub fn get_mapped_range_mut(&self) -> BufferViewMut<'a>
pub fn get_mapped_range_mut(&self) -> BufferViewMut<'a>
Gain write access to the bytes of a mapped Buffer
.
Return a BufferViewMut
referring to the buffer range represented by
self
. See the documentation for BufferViewMut
for more details.
§Panics
-
This panics if the buffer to which
self
refers is not currently mapped. -
If you try to create overlapping views of a buffer, mutable or otherwise,
get_mapped_range_mut
will panic.