PendingSubmission

Struct PendingSubmission 

Source
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:

  1. Call Queue::allocate_submission to acquire the necessary locks, assign a submission index, wrap them all up as a PendingSubmission, and return it.

  2. Add the command buffers to be submitted to executions, and note any surface textures they reference in surface_textures. Contribute to Queue::pending_writes as necessary.

  3. Acquire the pending writes lock. This may be done at any point between the return from Queue::allocate_submission and the call to submit. Typically it should be done as late as is possible given any necessary pending writes activity.

  4. Call the PendingSubmission’s submit method (which is a convenience wrapper around Queue::submit_pending_submission). Pass the pending writes mutex guard to submit.

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:

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: SubmissionIndex

The index this submission has been assigned.

Implementations§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,