Struct vulkano::sync::fence::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 a queue operation has completed executing. 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.

Implementations§

source§

impl Fence

source

pub fn new( device: Arc<Device>, create_info: FenceCreateInfo ) -> Result<Fence, Validated<VulkanError>>

Creates a new Fence.

source

pub fn from_pool(device: Arc<Device>) -> Result<Fence, VulkanError>

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.

source

pub unsafe fn from_handle( device: Arc<Device>, handle: Fence, create_info: FenceCreateInfo ) -> Fence

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.
source

pub fn flags(&self) -> FenceCreateFlags

Returns the flags that the fence was created with.

source

pub fn export_handle_types(&self) -> ExternalFenceHandleTypes

Returns the handle types that can be exported from the fence.

source

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

Returns true if the fence is signaled.

source

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

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

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

source

pub fn multi_wait<'a>( fences: impl IntoIterator<Item = &'a Fence>, timeout: Option<Duration> ) -> Result<(), Validated<VulkanError>>

Waits for multiple fences at once.

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

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

Resets the fence.

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

source

pub fn multi_reset<'a>( fences: impl IntoIterator<Item = &'a Fence> ) -> Result<(), Validated<VulkanError>>

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.
source

pub fn export_fd( &self, handle_type: ExternalFenceHandleType ) -> Result<File, Validated<VulkanError>>

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.

source

pub fn export_win32_handle( &self, handle_type: ExternalFenceHandleType ) -> Result<*mut c_void, Validated<VulkanError>>

Exports the fence into a Win32 handle.

The khr_external_fence_win32 extension must be enabled on the device.

source

pub unsafe fn import_fd( &self, import_fence_fd_info: ImportFenceFdInfo ) -> Result<(), Validated<VulkanError>>

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.
source

pub unsafe fn import_win32_handle( &self, import_fence_win32_handle_info: ImportFenceWin32HandleInfo ) -> Result<(), Validated<VulkanError>>

Imports a fence from a Win32 handle.

The khr_external_fence_win32 extension must be enabled on the device.

Safety
  • In import_fence_win32_handle_info, handle 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§

source§

impl Debug for Fence

source§

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

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

impl DeviceOwned for Fence

source§

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

Returns the device that owns self.
source§

impl Drop for Fence

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Future for Fence

§

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 Hash for Fence

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Fence

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl VulkanObject for Fence

§

type Handle = Fence

The type of the object.
source§

fn handle(&self) -> Self::Handle

Returns the raw Vulkan handle of the object.
source§

impl Eq for Fence

Auto Trait Implementations§

§

impl !RefUnwindSafe for Fence

§

impl Send for Fence

§

impl Sync for Fence

§

impl Unpin for Fence

§

impl !UnwindSafe for Fence

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> DeviceOwnedVulkanObject for Twhere T: DeviceOwned + VulkanObject,

source§

fn set_debug_utils_object_name( &self, object_name: Option<&str> ) -> Result<(), VulkanError>

Assigns a human-readable name to the object for debugging purposes. 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.