<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLCompareFunction",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:@E@MTLCompareFunction"
  },
  "title" : "MTLCompareFunction"
}
-->

# MTLCompareFunction

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

```
enum MTLCompareFunction
```

## 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`](/documentation/Metal/MTLCompareFunction/never)

A new value never passes the comparison test.

[`MTLCompareFunction.less`](/documentation/Metal/MTLCompareFunction/less)

A new value passes the comparison test if it is less than the existing value.

[`MTLCompareFunction.equal`](/documentation/Metal/MTLCompareFunction/equal)

A new value passes the comparison test if it is equal to the existing value.

[`MTLCompareFunction.lessEqual`](/documentation/Metal/MTLCompareFunction/lessEqual)

A new value passes the comparison test if it is less than or equal to the existing value.

[`MTLCompareFunction.greater`](/documentation/Metal/MTLCompareFunction/greater)

A new value passes the comparison test if it is greater than the existing value.

[`MTLCompareFunction.notEqual`](/documentation/Metal/MTLCompareFunction/notEqual)

A new value passes the comparison test if it is not equal to the existing value.

[`MTLCompareFunction.greaterEqual`](/documentation/Metal/MTLCompareFunction/greaterEqual)

A new value passes the comparison test if it is greater than or equal to the existing value.

[`MTLCompareFunction.always`](/documentation/Metal/MTLCompareFunction/always)

A new value always passes the comparison test.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)