ID3D12Fence Interface
Namespace: Microsoft.DirectX.Graphics.D3D12
Represents a GPU-synchronized signal that allows the CPU to wait for the GPU to complete certain work.
Interface Definition
interface ID3D12Fence : ID3D12Object
{
HRESULT SetEventOnCompletion(
UINT64 Value,
HANDLE Event
);
HRESULT Signal(
UINT64 Value
);
UINT64 GetCompletedValue();
}
Members
Methods
-
SetEventOnCompletion
Associates a CPU-visible event handle with a fence value. The event is signaled when the fence value has been reached or exceeded by the GPU.
-
Signal
Sets the fence to a specific value. The GPU will eventually reach this value.
-
GetCompletedValue
Retrieves the current completed value of the fence.
SetEventOnCompletion
HRESULT SetEventOnCompletion( UINT64 Value, HANDLE Event );
Parameters
Value: The fence value to wait for.Event: A handle to a CPU-visible event object.
Return Value
If the method succeeds, the return value is S_OK. Otherwise, it is one of the Direct3D 12 return codes.
Signal
HRESULT Signal( UINT64 Value );
Parameters
Value: The fence value to set.
Return Value
If the method succeeds, the return value is S_OK. Otherwise, it is one of the Direct3D 12 return codes.
GetCompletedValue
UINT64 GetCompletedValue();
Return Value
Returns the current completed value of the fence.
Remarks
Fences are essential for managing asynchronous operations between the CPU and the GPU. They provide a mechanism for the CPU to know when the GPU has finished processing a particular set of commands, allowing for proper synchronization and preventing race conditions.
You create a fence by calling ID3D12Device::CreateFence. Fences can be used for intra-adapter and inter-adapter synchronization.