pub(crate) struct PendingSubmission<'a> {
queue: &'a Queue,
command_index_guard: RwLockWriteGuard<'a, CommandIndices>,
snatch_guard: SnatchGuard<'a>,
pub executions: Vec<EncoderInFlight>,
surface_textures: FastHashMap<*const Texture, Arc<Texture>>,
pub index: SubmissionIndex,
}Expand description
A command submission in the process of being assembled.
Within wgpu_core, enqueuing commands for execution on the GPU is a
three-step process:
-
Call
Queue::allocate_submissionto acquire the necessary locks, assign a submission index, wrap them all up as aPendingSubmission, and return it. -
Add the command buffers to be submitted to
executions, and note any surface textures they reference insurface_textures. Contribute toQueue::pending_writesas necessary. -
Acquire the pending writes lock. This may be done at any point between the return from
Queue::allocate_submissionand the call tosubmit. Typically it should be done as late as is possible given any necessary pending writes activity. -
Call the
PendingSubmission’ssubmitmethod (which is a convenience wrapper aroundQueue::submit_pending_submission). Pass the pending writes mutex guard tosubmit.
It is also acceptable to drop the PendingSubmission without submitting;
this frees its locks in the appropriate order. This may be necessary when
those locks are required to access the state that determines whether a
submission is needed at all.
This split allows the various places in wgpu_core that need to submit
commands to the GPU to share the common initial code for locking and final
code for actually submitting the commands to wgpu_hal:
-
Queue::submitjust submits user-constructedCommandBuffers. -
Queue::prepare_surface_texture_for_presentexamines the surface texture being presented, and submits deferred initialization commands and barriers to get it ready. -
Queue::flush_writes_for_bufferandQueue::flush_pending_writessimply submit the operations already staged inQueue::pending_writes.
Returned from Queue::allocate_submission and consumed by submit.
These are internal APIs used in Queue::submit and other places within
wgpu-core that need to submit work.
Fields§
§queue: &'a Queue§command_index_guard: RwLockWriteGuard<'a, CommandIndices>A guard for the lock on Device::command_indices.
snatch_guard: SnatchGuard<'a>A guard for the lock on Device::snatchable_lock.
executions: Vec<EncoderInFlight>Command buffers to be submitted, along with trackers for the resources they use.
surface_textures: FastHashMap<*const Texture, Arc<Texture>>Surface textures referenced by command buffers in this submission.
These need to be passed to wgpu_hal::Queue::submit, which
requires that the list contains no duplicates, so we store them in a
HashMap keyed by SurfaceTexture address.
index: SubmissionIndexThe index this submission has been assigned.
Implementations§
Source§impl<'a> PendingSubmission<'a>
impl<'a> PendingSubmission<'a>
fn submit( self, pending_writes: MutexGuard<'a, PendingWrites>, ) -> Result<SubmissionResult<'a>, DeviceError>
Auto Trait Implementations§
impl<'a> Freeze for PendingSubmission<'a>
impl<'a> !RefUnwindSafe for PendingSubmission<'a>
impl<'a> !Send for PendingSubmission<'a>
impl<'a> !Sync for PendingSubmission<'a>
impl<'a> Unpin for PendingSubmission<'a>
impl<'a> !UnwindSafe for PendingSubmission<'a>
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
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>
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>
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