sampleCounters(sampleBuffer:sampleIndex:barrier:)
Encodes a command that samples the GPU’s hardware counters during a blit pass and stores the data in a counter sample buffer.
Declaration
func sampleCounters(sampleBuffer: any MTLCounterSampleBuffer, sampleIndex: Int, barrier: Bool)Parameters
- sampleBuffer:
A counter sample buffer where the command stores the sample data.
- sampleIndex:
A location within
sampleBufferwhere the command stores the sample data. - barrier:
A Boolean value that indicates whether the command inserts a barrier before taking the sample.
Mentioned in
Discussion
Inserting a barrier ensures that any work you encode with this encoder is complete before the GPU samples the hardware counters. If you don’t insert a barrier, the GPU can sample the counters concurrently with other commands you encode with this encoder. Using a barrier can help the counter results be more predictable and repeatable, but it may adversely affect your app’s runtime performance.