struct SwapchainAcquireSemaphore {
acquire: Semaphore,
should_wait_for_acquire: bool,
previously_used_submission_index: FenceValue,
}
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
impl SwapchainAcquireSemaphore
fn new(device: &DeviceShared, index: usize) -> Result<Self, DeviceError>
Sourcefn set_used_fence_value(&mut self, value: FenceValue)
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.
Sourcefn get_acquire_wait_semaphore(&mut self) -> Option<Semaphore>
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.
Sourcefn end_semaphore_usage(&mut self)
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.