---
title: "makeCounterSampleBuffer(descriptor:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtldevice/makecountersamplebuffer(descriptor:)"
---

# makeCounterSampleBuffer(descriptor:)

Creates a counter sample buffer.

## Declaration

```swift
func makeCounterSampleBuffer(descriptor: MTLCounterSampleBufferDescriptor) throws -> any MTLCounterSampleBuffer
```

## Parameters

- `descriptor`: An doc://com.apple.metal/documentation/Metal/MTLCounterSampleBufferDescriptor instance.

## Mentioned in

Creating a counter sample buffer to store a GPU’s counter data during a pass

## Return Value

Return Value A new MTLCounterSampleBuffer instance if the method completes successfully; otherwise Swift throws an error and Objective-C returns nil.

## Discussion

Discussion The method may produce an error if the GPU driver has exhausted its underlying resources for counter sample buffers.

## See Also

### Sampling a GPU device’s counters

- [counterSets](metal/mtldevice/countersets.md)
- [supportsCounterSampling(_:)](metal/mtldevice/supportscountersampling(_:).md)
- [MTLCounterSamplingPoint](metal/mtlcountersamplingpoint.md)
