---
title: MTLCompareFunction
framework: metal
role: symbol
role_heading: Enumeration
path: metal/mtlcomparefunction
---

# MTLCompareFunction

Options used to specify how a sample compare operation should be performed on a depth texture.

## Declaration

```swift
enum MTLCompareFunction
```

## Overview

Overview Whenever the comparison test passes, the incoming fragment is compared to the stored data at the specified location.

## Topics

### Compare function options

- [MTLCompareFunction.never](metal/mtlcomparefunction/never.md)
- [MTLCompareFunction.less](metal/mtlcomparefunction/less.md)
- [MTLCompareFunction.equal](metal/mtlcomparefunction/equal.md)
- [MTLCompareFunction.lessEqual](metal/mtlcomparefunction/lessequal.md)
- [MTLCompareFunction.greater](metal/mtlcomparefunction/greater.md)
- [MTLCompareFunction.notEqual](metal/mtlcomparefunction/notequal.md)
- [MTLCompareFunction.greaterEqual](metal/mtlcomparefunction/greaterequal.md)
- [MTLCompareFunction.always](metal/mtlcomparefunction/always.md)

### Initializers

- [init(rawValue:)](metal/mtlcomparefunction/init(rawvalue:).md)

## Relationships

### Conforms To

- [BitwiseCopyable](swift/bitwisecopyable.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [RawRepresentable](swift/rawrepresentable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Declaring the depth comparison mode

- [compareFunction](metal/mtlsamplerdescriptor/comparefunction.md)
