Contents

writeTimestamp(granularity:counterHeap:index:)

Writes a GPU timestamp into a heap.

Declaration

func writeTimestamp(granularity: MTL4TimestampGranularity, counterHeap: any MTL4CounterHeap, index: Int)

Parameters

  • granularity:

    Mtl4timestampgranularity hint to Metal about acceptable the level of precision.

  • counterHeap:

    Mtl4counterheap to write timestamps into.

  • index:

    The index value into which Metal writes the timestamp.

Discussion

The method ensures that any prior work finishes, but doesn’t delay any subsequent work.

You can alter this command’s behavior through the granularity parameter.

  • Pass MTL4TimestampGranularity.relaxed to allow Metal to provide timestamps with minimal impact to runtime performance, but with less detail. For example, the command may group all timestamps for a pass together.

  • Pass MTL4TimestampGranularity.precise to request that Metal provides timestamps with the most detail. This can affect runtime performance.