pub struct FenceSignalFuture<F>where
    F: GpuFuture,{ /* private fields */ }
Expand description

Represents a fence being signaled after a previous event.

Contrary to most other future types, it is possible to block the current thread until the event happens. This is done by calling the wait() function.

This can also be done through Rust’s Async system by simply .awaiting this object. Note though that (due to the Vulkan API fence design) this will spin to check the fence, rather than blocking in the driver. Therefore if you have a long-running task, blocking may be less CPU intense (depending on the driver’s implementation).

Also note that the GpuFuture trait is implemented on Arc<FenceSignalFuture<_>>. This means that you can put this future in an Arc and keep a copy of it somewhere in order to know when the execution reached that point.

use std::sync::Arc;
use vulkano::sync::GpuFuture;

// Assuming you have a chain of operations, like this:
// let future = ...
//      .then_execute(foo)
//      .then_execute(bar)

// You can signal a fence at this point of the chain, and put the future in an `Arc`.
let fence_signal = Arc::new(future.then_signal_fence());

// And then continue the chain:
// fence_signal.clone()
//      .then_execute(baz)
//      .then_execute(qux)

// Later you can wait until you reach the point of `fence_signal`:
fence_signal.wait(None).unwrap();

Implementations§

source§

impl<F> FenceSignalFuture<F>where F: GpuFuture,

source

pub fn is_signaled(&self) -> Result<bool, VulkanError>

Returns true if the fence is signaled by the GPU.

source

pub fn wait( &self, timeout: Option<Duration> ) -> Result<(), Validated<VulkanError>>

Blocks the current thread until the fence is signaled by the GPU. Performs a flush if necessary.

If timeout is None, then the wait is infinite. Otherwise the thread will unblock after the specified timeout has elapsed and an error will be returned.

If the wait is successful, this function also cleans any resource locked by previous submissions.

Trait Implementations§

source§

impl<F> DeviceOwned for FenceSignalFuture<F>where F: GpuFuture,

source§

fn device(&self) -> &Arc<Device>

Returns the device that owns self.
source§

impl<F> Drop for FenceSignalFuture<F>where F: GpuFuture,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<F> Future for FenceSignalFuture<F>where F: GpuFuture,

§

type Output = Result<(), VulkanError>

The type of value produced on completion.
source§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempt to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
source§

impl<F> GpuFuture for FenceSignalFuture<F>where F: GpuFuture,

source§

fn cleanup_finished(&mut self)

If possible, checks whether the submission has finished. If so, gives up ownership of the resources used by these submissions. Read more
source§

unsafe fn build_submission( &self ) -> Result<SubmitAnyBuilder, Validated<VulkanError>>

Builds a submission that, if submitted, makes sure that the event represented by this GpuFuture will happen, and possibly contains extra elements (eg. a semaphore wait or an event wait) that makes the dependency with subsequent operations work. Read more
source§

fn flush(&self) -> Result<(), Validated<VulkanError>>

Flushes the future and submits to the GPU the actions that will permit this future to occur. Read more
source§

unsafe fn signal_finished(&self)

Sets the future to its “complete” state, meaning that it can safely be destroyed. Read more
source§

fn queue_change_allowed(&self) -> bool

Returns true if elements submitted after this future can be submitted to a different queue than the other returned by queue().
source§

fn queue(&self) -> Option<Arc<Queue>>

Returns the queue that triggers the event. Returns None if unknown or irrelevant. Read more
source§

fn check_buffer_access( &self, buffer: &Buffer, range: Range<DeviceSize>, exclusive: bool, queue: &Queue ) -> Result<(), AccessCheckError>

Checks whether submitting something after this future grants access (exclusive or shared, depending on the parameter) to the given buffer on the given queue. Read more
source§

fn check_image_access( &self, image: &Image, range: Range<DeviceSize>, exclusive: bool, expected_layout: ImageLayout, queue: &Queue ) -> Result<(), AccessCheckError>

Checks whether submitting something after this future grants access (exclusive or shared, depending on the parameter) to the given image on the given queue. Read more
source§

fn check_swapchain_image_acquired( &self, swapchain: &Swapchain, image_index: u32, _before: bool ) -> Result<(), AccessCheckError>

Checks whether accessing a swapchain image is permitted. Read more
source§

fn join<F>(self, other: F) -> JoinFuture<Self, F>where Self: Sized, F: GpuFuture,

Joins this future with another one, representing the moment when both events have happened.
source§

fn then_execute( self, queue: Arc<Queue>, command_buffer: Arc<impl PrimaryCommandBufferAbstract + 'static> ) -> Result<CommandBufferExecFuture<Self>, CommandBufferExecError>where Self: Sized,

Executes a command buffer after this future. Read more
source§

fn then_execute_same_queue( self, command_buffer: Arc<impl PrimaryCommandBufferAbstract + 'static> ) -> Result<CommandBufferExecFuture<Self>, CommandBufferExecError>where Self: Sized,

Executes a command buffer after this future, on the same queue as the future. Read more
source§

fn then_signal_semaphore(self) -> SemaphoreSignalFuture<Self>where Self: Sized,

Signals a semaphore after this future. Returns another future that represents the signal. Read more
source§

fn then_signal_semaphore_and_flush( self ) -> Result<SemaphoreSignalFuture<Self>, Validated<VulkanError>>where Self: Sized,

Signals a semaphore after this future and flushes it. Returns another future that represents the moment when the semaphore is signalled. Read more
source§

fn then_signal_fence(self) -> FenceSignalFuture<Self> where Self: Sized,

Signals a fence after this future. Returns another future that represents the signal. Read more
source§

fn then_signal_fence_and_flush( self ) -> Result<FenceSignalFuture<Self>, Validated<VulkanError>>where Self: Sized,

Signals a fence after this future. Returns another future that represents the signal. Read more
source§

fn then_swapchain_present( self, queue: Arc<Queue>, swapchain_info: SwapchainPresentInfo ) -> PresentFuture<Self>where Self: Sized,

Presents a swapchain image after this future. Read more
source§

fn boxed(self) -> Box<dyn GpuFuture>where Self: Sized + 'static,

Turn the current future into a Box<dyn GpuFuture>. Read more

Auto Trait Implementations§

§

impl<F> !RefUnwindSafe for FenceSignalFuture<F>

§

impl<F> Send for FenceSignalFuture<F>where F: Send,

§

impl<F> Sync for FenceSignalFuture<F>where F: Send,

§

impl<F> Unpin for FenceSignalFuture<F>where F: Unpin,

§

impl<F> !UnwindSafe for FenceSignalFuture<F>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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<F> IntoFuture for Fwhere F: Future,

§

type Output = <F as Future>::Output

The output that the future will produce on completion.
§

type IntoFuture = F

Which kind of future are we turning this into?
source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.