Skip to main content

PendingUpload

Struct PendingUpload 

Source
pub struct PendingUpload { /* private fields */ }
Expand description

An UploadBatch submitted by submit_deferred and not yet known to have run: what it still owns, and the timeline value that says when it may go.

§Why the textures may be sampled before it retires

The batch’s last barrier on each image leaves it in ResourceState::ShaderRead, and what reads it next is a frame submitted to the same queue after it. That is ordered without a host wait on every backend here:

  • Vulkan: a pipeline barrier’s second synchronisation scope is every command later in submission order on the queue, which spans later vkQueueSubmits, and the image’s layout is a property of the image, not of the command buffer that transitioned it.
  • D3D12: a resource barrier’s state persists past its command list, and command lists on one queue run in ExecuteCommandLists order. An image explicitly transitioned does not decay; a buffer does, to COMMON, the same as it does after UploadBatch::submit’s wait.
  • Metal: every resource crcbl-mtl allocates is hazard-tracked, and the driver orders tracked hazards between command buffers committed to one queue.
  • WebGPU: never reaches here — UploadBatch::submit_deferred waits on a device without timeline semaphores, which is every browser’s — and queue.submit order is WebGPU’s own guarantee anyway.

Another queue has none of these guarantees, which is why the batch’s queue must be the one its readers submit to.

§What it still owns

The staging and zero buffers the copies read, the command buffer (Device::destroy_command_buffer may not run before its submission completes) and the semaphore. poll releases them once the semaphore has reached LANDED, without blocking; wait blocks for it. One of the two must have released them before the device is destroyed: dropping a pending upload leaks them, and says so in the log, because releasing a buffer the GPU may still be reading is the worse failure.

Implementations§

Source§

impl PendingUpload

Source

pub const LANDED: u64 = 1

The value the submission signals its semaphore to once its copies have run. The semaphore is the upload’s own, so it is the first value.

Source

pub const fn is_retired(&self) -> bool

Whether everything has been released — at once for an upload that waited at its submit.

Source

pub fn poll(&mut self, device: &dyn Device) -> Result<bool, HalError>

Releases everything if the copies have run, without blocking, and says whether it is now retired.

§Errors

HalError from reading the semaphore — a lost device. Nothing is released then.

Source

pub fn wait(&mut self, device: &dyn Device) -> Result<(), HalError>

Blocks until the copies have run, then releases everything. Returns at once for one already retired.

No timeout, like the Device::wait_idle it replaces: a GPU that never finishes is a lost device, which the wait reports.

§Errors

HalError from the wait. Nothing is released then.

Trait Implementations§

Source§

impl Debug for PendingUpload

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Drop for PendingUpload

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HalThreadSafe for T
where T: Send + Sync,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.