Contents

Confirming which counters and counter sets a GPU supports

Check whether a GPU produces the runtime performance data you want to sample.

Overview

You can check to see which counters a GPU device supports before attempting to programmatically sample data from them. A GPU counter is typically a hardware feature that tracks a specific performance metric, such as timestamps before and after an important rendering stage. Checking which counters a GPU supports at runtime avoids assumptions that may trigger an error or a crash on a person’s device.

A counter set is a collection of related counters. The MTLCommonCounterSet type defines the name of each set, and the MTLCommonCounter type defines the name of each individual counter. Check which counter sets an MTLDevice instance supports before you request one by checking its counterSets property.

The method iterates through each counter set the device supports, and compares its name to the MTLCommonCounterSet parameter.

Even though a GPU device supports a counter set, it may only support some of the counters in that set. You can check which individual counters a device supports by checking the elements of a counter set’s counters property.

The method iterates through each counter in the device’s counter set, and compares its name to the MTLCommonCounter property.

When you know a GPU supports a counter, your app can create and safely use an MTLCounterSampleBuffer instance to store that counter’s data. See Creating a counter sample buffer to store a GPU’s counter data during a pass for more information and next steps.

See Also

Counters and counter sets