Instance Method

updateFence(_:after:)

Updates the given fence to capture all GPU work enqueued by the command encoder up to the given render stage.

Required.

Declaration

func updateFence(_ fence: MTLFence, after stages: MTLRenderStages)

Parameters

fence

The fence to update.

stages

The render stage to complete before the fence is evaluated.

Discussion

Fences are manipulated when the command buffer is submitted to the hardware. This maintains global order and prevents deadlock.

Fences are evaluated at command encoder boundaries. Waits occur at the beginning of an encoder and updates occur at the end of the encoder. Therefore, you're not allowed to first update and then wait on the same fence in the same encoder. However, you're allowed to first wait and then update the same fence.

See Also

Synchronizing Command Execution for Untracked Resources

func waitForFence(MTLFence, before: MTLRenderStages)

Prevents further GPU work to be enqueued by the command encoder until the given fence is reached for the given render stage.

Required.

func memoryBarrier(scope: MTLBarrierScope, after: MTLRenderStages, before: MTLRenderStages)

Encodes a barrier so that data written to memory by commands encoded before the barrier is available to commands encoded after the barrier.

Required.

struct MTLRenderStages

The render stages at which a synchronization command is triggered.

struct MTLBarrierScope

Describes the types of resources that a barrier operates on.

func textureBarrier()

Ensures that any texture reads issued after the barrier can safely read from any rendering to those textures performed before the barrier.

Required.

Deprecated