sampleCounters(sampleBuffer:sampleIndex:barrier:)
Encodes a command to sample hardware counters, providing performance information.
Declaration
func sampleCounters(sampleBuffer: any MTLCounterSampleBuffer, sampleIndex: Int, barrier: Bool)Parameters
- sampleBuffer:
An Mtlcountersamplebuffer instance that stores the GPU hardware data.
- sampleIndex:
An index within
sampleBufferthe command stores the data to. - barrier:
Whether or not the command inserts a barrier before sampling the counter’s data.
A barrier ensures that the commands you encode before this one complete before the GPU samples the hardware counters, but can negatively impact runtime performance.
Running this command without a barrier means the GPU can sample counters concurrently with other commands from the encoder.
The
barrierparameter for the command has no impact on sampling commands from other passes.
Mentioned in
Discussion
See GPU counters and counter sample buffers, Sampling GPU data into counter sample buffers, and MTLCounter for more information.