waitForFence(_:)
Encodes a command that instructs the GPU to pause the blit pass until another pass updates a fence.
Declaration
func waitForFence(_ fence: any MTLFence)Parameters
- fence:
A fence that the pass waits for before it runs any of its commands.
Discussion
You can synchronize memory operations of a blit pass that access resources with an MTLFence. This method instructs the GPU to wait until another pass updates fence before running the blit pass. The fence indicates when the pass can access those resources without a race condition.
For more information about synchronization with fences, see:
Reuse a fence by waiting first and updating second
When encoding a blit pass that reuses a fence, wait for other passes to update the fence before repurposing that fence to notify subsequent passes with an update:
Call the waitForFence(_:) method before encoding commands that need to wait for other passes.
Call the updateFence(_:) method after encoding commands that later passes depend on.
The GPU driver evaluates the fences that apply to the pass and the commands that depend on those fences when your app commits the enclosing MTLCommandBuffer.