Struct SwapchainAcquireSemaphore

Source
struct SwapchainAcquireSemaphore {
    acquire: Semaphore,
    should_wait_for_acquire: bool,
    previously_used_submission_index: FenceValue,
}
Available on vulkan only.
Expand description

Semaphore used to acquire a swapchain image.

Fields§

§acquire: Semaphore

A semaphore that is signaled when this image is safe for us to modify.

When vkAcquireNextImageKHR returns the index of the next swapchain image that we should use, that image may actually still be in use by the presentation engine, and is not yet safe to modify. However, that function does accept a semaphore that it will signal when the image is indeed safe to begin messing with.

This semaphore is:

  • waited for by the first queue submission to operate on this image since it was acquired, and

  • signaled by vkAcquireNextImageKHR when the acquired image is ready for us to use.

§should_wait_for_acquire: bool

True if the next command submission operating on this image should wait for acquire.

We must wait for acquire before drawing to this swapchain image, but because wgpu-hal queue submissions are always strongly ordered, only the first submission that works with a swapchain image actually needs to wait. We set this flag when this image is acquired, and clear it the first time it’s passed to Queue::submit as a surface texture.

Additionally, semaphores can only be waited on once, so we need to ensure that we only actually pass this semaphore to the first submission that uses that image.

§previously_used_submission_index: FenceValue

The fence value of the last command submission that wrote to this image.

The next time we try to acquire this image, we’ll block until this submission finishes, proving that acquire is ready to pass to vkAcquireNextImageKHR again.

Implementations§

Source§

impl SwapchainAcquireSemaphore

Source

fn new(device: &DeviceShared, index: usize) -> Result<Self, DeviceError>

Source

fn set_used_fence_value(&mut self, value: FenceValue)

Sets the fence value which the next acquire will wait for. This prevents the semaphore from being used while the previous submission is still in flight.

Source

fn get_acquire_wait_semaphore(&mut self) -> Option<Semaphore>

Return the semaphore that commands drawing to this image should wait for, if any.

This only returns Some once per acquisition; see SwapchainAcquireSemaphore::should_wait_for_acquire for details.

Source

fn end_semaphore_usage(&mut self)

Indicates the cpu-side usage of this semaphore has finished for the frame, so reset internal state to be ready for the next frame.

Source

unsafe fn destroy(&self, device: &Device)

Trait Implementations§

Source§

impl Debug for SwapchainAcquireSemaphore

Source§

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

Formats the value using the given formatter. 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
§

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, 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>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,