---
title: GPU counters and counter sample buffers
framework: metal
role: collectionGroup
role_heading: API Collection
path: metal/gpu-counters-and-counter-sample-buffers
---

# GPU counters and counter sample buffers

Retrieve runtime data from a GPU device by sampling one or more of its counters.

## Overview

Overview A GPU counter (MTLCounter) is typically a hardware feature that tracks a specific performance metric, such as timestamps before and after an important rendering stage. A counter set (MTLCounterSet) is a collection of related counters. A counter sample buffer (MTLCounterSampleBuffer) represents the memory where a GPU device stores the data for a specific counter set. You can retrieve and inspect data from a GPU’s counter set with the following steps: Inspect which GPU counter sets a GPU device supports (see Confirming which counters and counter sets a GPU supports). Make a counter sample buffer to store the data (see Creating a counter sample buffer to store a GPU’s counter data during a pass). Instruct the GPU to save the counter set data to the buffer during a pass or an immediate mode command (see Sampling GPU data into counter sample buffers). Transform the counter set data into a standard type (see Converting a GPU’s counter data into a readable format). If you’re sampling data from a timestamp counter set (timestamp), you may need to convert the timestamps from the GPU’s clock to the CPU’s clock. See Converting GPU timestamps into CPU time for more information.

## Topics

### Counters and counter sets

- [Confirming which counters and counter sets a GPU supports](metal/confirming-which-counters-and-counter-sets-a-gpu-supports.md)
- [MTLCounterSet](metal/mtlcounterset.md)
- [MTLCommonCounterSet](metal/mtlcommoncounterset.md)
- [MTLCounter](metal/mtlcounter.md)
- [MTLCommonCounter](metal/mtlcommoncounter.md)

### Counter sample buffers

- [Creating a counter sample buffer to store a GPU’s counter data during a pass](metal/creating-a-counter-sample-buffer-to-store-a-gpus-counter-data-during-a-pass.md)
- [MTLCounterSampleBufferDescriptor](metal/mtlcountersamplebufferdescriptor.md)
- [MTLCounterSampleBuffer](metal/mtlcountersamplebuffer.md)
- [Sampling GPU data into counter sample buffers](metal/sampling-gpu-data-into-counter-sample-buffers.md)
- [MTLCounterDontSample](metal/mtlcounterdontsample.md)

### Counter sample data output

- [Converting a GPU’s counter data into a readable format](metal/converting-a-gpus-counter-data-into-a-readable-format.md)
- [MTLCounterResultTimestamp](metal/mtlcounterresulttimestamp.md)
- [MTLCounterResultStatistic](metal/mtlcounterresultstatistic.md)
- [MTLCounterResultStageUtilization](metal/mtlcounterresultstageutilization.md)
- [MTLCounterErrorValue](metal/mtlcountererrorvalue.md)

### Timestamp data

- [Converting GPU timestamps into CPU time](metal/converting-gpu-timestamps-into-cpu-time.md)
- [MTLTimestamp](metal/mtltimestamp.md)

### Counter sample buffer errors

- [MTLCounterSampleBufferError](metal/mtlcountersamplebuffererror-swift.struct.md)

## See Also

### Developer tools

- [Supporting Simulator in a Metal app](metal/supporting-simulator-in-a-metal-app.md)
- [Capturing Metal commands programmatically](metal/capturing-metal-commands-programmatically.md)
- [Logging shader debug messages](metal/logging-shader-debug-messages.md)
- [Developing Metal apps that run in Simulator](metal/developing-metal-apps-that-run-in-simulator.md)
- [Improving your game’s graphics performance and settings](metal/improving-your-games-graphics-performance-and-settings.md)
- [Metal debugger](xcode/metal-debugger.md)
- [Metal developer workflows](xcode/metal-developer-workflows.md)
- [Metal debugging types](metal/metal-debugging-types.md)
