---
title: compareFunction
framework: metal
role: symbol
role_heading: Instance Property
path: metal/mtlsamplerdescriptor/comparefunction
---

# compareFunction

The sampler comparison function used when performing a sample compare operation on a depth texture.

## Declaration

```swift
var compareFunction: MTLCompareFunction { get set }
```

## Discussion

Discussion The default value is MTLCompareFunction.never. The MTLFeatureSet.iOS_GPUFamily3_v1 and MTLFeatureSet.iOS_GPUFamily1_v1 feature sets allow you to define a framework-side sampler comparison function for an MTLSamplerState instance. All feature sets support shader-side sampler comparison functions, as described in the Metal Shading Language Specification.

## See Also

### Declaring the depth comparison mode

- [MTLCompareFunction](metal/mtlcomparefunction.md)
