Struct wgpu_async::AsyncQueue
source · pub struct AsyncQueue { /* private fields */ }Expand description
A wrapper around a wgpu::Queue which shadows some methods to allow for callback-and-poll
methods to be made async, such as AsyncQueue::submit.
Implementations§
source§impl AsyncQueue
impl AsyncQueue
sourcepub fn submit<I: IntoIterator<Item = CommandBuffer> + Send>(
&self,
command_buffers: I
) -> WgpuFuture<()> ⓘ
pub fn submit<I: IntoIterator<Item = CommandBuffer> + Send>( &self, command_buffers: I ) -> WgpuFuture<()> ⓘ
This is an async version of wgpu::Queue::submit.
Just like wgpu::Queue::submit, a call to this method starts the given work immediately,
however this method returns a future that can be awaited giving the completion of the submitted work.
sourcepub fn device(&self) -> &AsyncDevice
pub fn device(&self) -> &AsyncDevice
Gets the device associated with this queue.
Methods from Deref<Target = Queue>§
sourcepub fn write_buffer(&self, buffer: &Buffer, offset: u64, data: &[u8])
pub fn write_buffer(&self, buffer: &Buffer, offset: u64, data: &[u8])
Schedule a data write into buffer starting at offset.
This method is intended to have low performance costs.
As such, the write is not immediately submitted, and instead enqueued
internally to happen at the start of the next submit() call.
This method fails if data overruns the size of buffer starting at offset.
sourcepub fn write_buffer_with<'a>(
&'a self,
buffer: &'a Buffer,
offset: u64,
size: NonZeroU64
) -> Option<QueueWriteBufferView<'a>>
pub fn write_buffer_with<'a>( &'a self, buffer: &'a Buffer, offset: u64, size: NonZeroU64 ) -> Option<QueueWriteBufferView<'a>>
Schedule a data write into buffer starting at offset via the returned
QueueWriteBufferView.
Reading from this buffer is slow and will not yield the actual contents of the buffer.
This method is intended to have low performance costs.
As such, the write is not immediately submitted, and instead enqueued
internally to happen at the start of the next submit() call.
This method fails if size is greater than the size of buffer starting at offset.
sourcepub fn write_texture(
&self,
texture: ImageCopyTexture<&Texture>,
data: &[u8],
data_layout: ImageDataLayout,
size: Extent3d
)
pub fn write_texture( &self, texture: ImageCopyTexture<&Texture>, data: &[u8], data_layout: ImageDataLayout, size: Extent3d )
Schedule a write of some data into a texture.
datacontains the texels to be written, which must be in the same format as the texture.data_layoutdescribes the memory layout ofdata, which does not necessarily have to have tightly packed rows.texturespecifies the texture to write into, and the location within the texture (coordinate offset, mip level) that will be overwritten.sizeis the size, in texels, of the region to be written.
This method is intended to have low performance costs.
As such, the write is not immediately submitted, and instead enqueued
internally to happen at the start of the next submit() call.
However, data will be immediately copied into staging memory; so the caller may
discard it any time after this call completes.
This method fails if size overruns the size of texture, or if data is too short.
sourcepub fn submit<I>(&self, command_buffers: I) -> SubmissionIndexwhere
I: IntoIterator<Item = CommandBuffer>,
pub fn submit<I>(&self, command_buffers: I) -> SubmissionIndexwhere I: IntoIterator<Item = CommandBuffer>,
Submits a series of finished command buffers for execution.
sourcepub fn get_timestamp_period(&self) -> f32
pub fn get_timestamp_period(&self) -> f32
Gets the amount of nanoseconds each tick of a timestamp query represents.
Returns zero if timestamp queries are unsupported.
sourcepub fn on_submitted_work_done(&self, callback: impl FnOnce() + Send + 'static)
pub fn on_submitted_work_done(&self, callback: impl FnOnce() + Send + 'static)
Registers a callback when the previous call to submit finishes running on the gpu. This callback being called implies that all mapped buffer callbacks attached to the same submission have also been 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.
Trait Implementations§
source§impl<T> AsRef<T> for AsyncQueuewhere
T: ?Sized,
<AsyncQueue as Deref>::Target: AsRef<T>,
impl<T> AsRef<T> for AsyncQueuewhere T: ?Sized, <AsyncQueue as Deref>::Target: AsRef<T>,
source§impl Clone for AsyncQueue
impl Clone for AsyncQueue
source§fn clone(&self) -> AsyncQueue
fn clone(&self) -> AsyncQueue
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more