Diligent Engine
Loading...
Searching...
No Matches
Diligent::IFence Struct Referenceabstract

Fence interface. More...

#include <Fence.h>

Inheritance diagram for Diligent::IFence:
Diligent::IDeviceObject Diligent.IObject Diligent::IFenceD3D11 Diligent::IFenceD3D12 Diligent::IFenceGL Diligent::IFenceMtl Diligent::IFenceVk Diligent::IFenceWebGPU

Public Member Functions

virtual const FenceDesc &DILIGENT_CALL_TYPE GetDesc () const override=0
 Returns the fence description used to create the object.
virtual Uint64 DILIGENT_CALL_TYPE GetCompletedValue ()=0
 Returns the last completed value signaled by the GPU.
virtual void DILIGENT_CALL_TYPE Signal (Uint64 Value)=0
 Sets the fence to the specified value.
virtual void DILIGENT_CALL_TYPE Wait (Uint64 Value)=0
 Waits until the fence reaches or exceeds the specified value, on the host.
Public Member Functions inherited from Diligent::IDeviceObject
virtual Int32 DILIGENT_CALL_TYPE GetUniqueID () const =0
 Returns unique identifier assigned to an object.
virtual void DILIGENT_CALL_TYPE SetUserData (IObject *pUserData)=0
 Stores a pointer to the user-provided data object.
virtual IObject *DILIGENT_CALL_TYPE GetUserData () const =0
 Returns a pointer to the user data object previously set with SetUserData() method.
Public Member Functions inherited from Diligent.IObject
virtual void DILIGENT_CALL_TYPE QueryInterface (const INTERFACE_ID &IID, IObject **ppInterface)=0
 Queries the specific interface.
template<typename DerivedType, typename = typename std::enable_if<std::is_base_of<IObject, DerivedType>::value>::type>
void QueryInterface (const INTERFACE_ID &IID, DerivedType **ppInterface)
virtual ReferenceCounterValueType DILIGENT_CALL_TYPE AddRef ()=0
 Increments the number of strong references by 1.
virtual ReferenceCounterValueType DILIGENT_CALL_TYPE Release ()=0
virtual IReferenceCounters *DILIGENT_CALL_TYPE GetReferenceCounters () const =0

Detailed Description

Fence interface.

Defines the methods to manipulate a fence object

When a fence that was previously signaled by IDeviceContext::EnqueueSignal() is destroyed, it may block the GPU until all prior commands have completed execution.

Remarks
In Direct3D12 and Vulkan backends, fence is thread-safe.

Member Function Documentation

◆ GetCompletedValue()

virtual Uint64 DILIGENT_CALL_TYPE Diligent::IFence::GetCompletedValue ( )
pure virtual

Returns the last completed value signaled by the GPU.

Remarks
In Direct3D11 backend, this method is not thread-safe (even if the fence object is protected by a mutex) and must only be called by the same thread that signals the fence via IDeviceContext::EnqueueSignal().

◆ Signal()

virtual void DILIGENT_CALL_TYPE Diligent::IFence::Signal ( Uint64 Value)
pure virtual

Sets the fence to the specified value.

Parameters
[in]Value- New value to set the fence to. The value must be greater than the current value of the fence.

Fence value will be changed immediately on the CPU. Use IDeviceContext::EnqueueSignal to enqueue a signal command that will change the value on the GPU after all previously submitted commands are complete.

Note
The fence must have been created with type Diligent::FENCE_TYPE_GENERAL.

◆ Wait()

virtual void DILIGENT_CALL_TYPE Diligent::IFence::Wait ( Uint64 Value)
pure virtual

Waits until the fence reaches or exceeds the specified value, on the host.

Parameters
[in]Value- The value that the fence is waiting for to reach.

The call normally blocks until the fence reaches Value.

On browser WebGPU, this method requires Asyncify or JSPI. If neither is enabled, it logs an error and returns without waiting. With JSPI, call through a suspension-capable WebAssembly entry point (such as an export wrapped with WebAssembly.promising). A synchronous frame callback can throw WebAssembly.SuspendError if the wait needs to yield. In a synchronous frame callback, poll IFence::GetCompletedValue() on later frames until it reaches or exceeds Value.

A suspended wait yields to the browser event loop. Until the call returns, defer application callbacks that reenter the same operation or modify resources it uses.