Struct vulkano::sync::Fence

source ·
pub struct Fence { /* private fields */ }
Expand description

A two-state synchronization primitive that is signalled by the device and waited on by the host.

Queue-to-host synchronization

The primary use of a fence is to know when execution of a queue has reached a particular point. When adding a command to a queue, a fence can be provided with the command, to be signaled when the operation finishes. You can check for a fence’s current status by calling is_signaled, wait or await on it. If the fence is found to be signaled, that means that the queue has completed the operation that is associated with the fence, and all operations that were submitted before it have been completed as well.

When a queue command accesses a resource, it must be kept alive until the queue command has finished executing, and you may not be allowed to perform certain other operations (or even any) while the resource is in use. By calling is_signaled, wait or await, the queue will be notified when the fence is signaled, so that all resources of the associated queue operation and preceding operations can be released.

Because of this, it is highly recommended to call is_signaled, wait or await on your fences. Otherwise, the queue will hold onto resources indefinitely (using up memory) and resource locks will not be released, which may cause errors when submitting future queue operations. It is not strictly necessary to wait for every fence, as a fence that was signaled later in the queue will automatically clean up resources associated with earlier fences too.

Implementations

Creates a new Fence.

Takes a fence from the vulkano-provided fence pool. If the pool is empty, a new fence will be created. Upon drop, the fence is put back into the pool.

For most applications, using the fence pool should be preferred, in order to avoid creating new fences every frame.

Creates a new Fence from a raw object handle.

Safety
  • handle must be a valid Vulkan object handle created from device.
  • create_info must match the info used to create the object.

Returns true if the fence is signaled.

Waits until the fence is signaled, or at least until the timeout duration has elapsed.

Returns Ok if the fence is now signaled. Returns Err if the timeout was reached instead.

If you pass a duration of 0, then the function will return without blocking.

Waits for multiple fences at once.

Panics
  • Panics if not all fences belong to the same device.

Resets the fence.

The fence must not be in use by a queue operation.

Resets multiple fences at once.

The fences must not be in use by a queue operation.

Panics
  • Panics if not all fences belong to the same device.

Exports the fence into a POSIX file descriptor. The caller owns the returned File.

The khr_external_fence_fd extension must be enabled on the device.

Imports a fence from a POSIX file descriptor.

The khr_external_fence_fd extension must be enabled on the device.

Safety
  • If in import_fence_fd_info, handle_type is ExternalHandleType::OpaqueFd, then file must represent a fence that was exported from Vulkan or a compatible API, with a driver and device UUID equal to those of the device that owns self.

Trait Implementations

Formats the value using the given formatter. Read more
Returns the device that owns Self.
Executes the destructor for this type. Read more
The type of value produced on completion.
Attempt to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
The type of the object.
Returns the raw Vulkan handle of the object.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The output that the future will produce on completion.
Which kind of future are we turning this into?
Creates a future from a value. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.