<!--
{
  "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/MTLDepthStencilDescriptor",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(cs)MTLDepthStencilDescriptor"
  },
  "title" : "MTLDepthStencilDescriptor"
}
-->

# MTLDepthStencilDescriptor

An instance that configures new [`MTLDepthStencilState`](/documentation/Metal/MTLDepthStencilState) instances.

```
class MTLDepthStencilDescriptor
```

## Overview

An [`MTLDepthStencilDescriptor`](/documentation/Metal/MTLDepthStencilDescriptor) instance is used to define a specific configuration of the depth and stencil stages of a rendering pipeline. To create an [`MTLDepthStencilDescriptor`](/documentation/Metal/MTLDepthStencilDescriptor) instance, use standard allocation and initialization techniques.

To enable writing the depth value to a depth attachment, set the depthWriteEnabled property to <doc://com.apple.documentation/documentation/Swift/true>.

The depthCompareFunction property specifies how the depth test is performed. If a fragment’s depth value fails the depth test, the fragment is discarded. [`MTLCompareFunction.less`](/documentation/Metal/MTLCompareFunction/less) is a commonly used value for [`depthCompareFunction`](/documentation/Metal/MTLDepthStencilDescriptor/depthCompareFunction), because fragment values that are farther away from the viewer than the pixel depth value (a previously written fragment) fail the depth test and are considered occluded by the earlier depth value.

The [`frontFaceStencil`](/documentation/Metal/MTLDepthStencilDescriptor/frontFaceStencil) and [`backFaceStencil`](/documentation/Metal/MTLDepthStencilDescriptor/backFaceStencil) properties define two independent stencil descriptors: one for front-facing primitives and the other for back-facing primitives, respectively. Both properties can be set to the same MTLStencilDescriptor instance.

## Topics

### Specifying depth operations

[`depthCompareFunction`](/documentation/Metal/MTLDepthStencilDescriptor/depthCompareFunction)

The comparison that is performed between a fragment’s depth value and the depth value in the attachment, which determines whether to discard the fragment.

[`isDepthWriteEnabled`](/documentation/Metal/MTLDepthStencilDescriptor/isDepthWriteEnabled)

A Boolean value that indicates whether depth values can be written to the depth attachment.

### Specifying stencil descriptors for primitives

[`backFaceStencil`](/documentation/Metal/MTLDepthStencilDescriptor/backFaceStencil)

The stencil descriptor for back-facing primitives.

[`frontFaceStencil`](/documentation/Metal/MTLDepthStencilDescriptor/frontFaceStencil)

The stencil descriptor for front-facing primitives.

### Identifying properties

[`label`](/documentation/Metal/MTLDepthStencilDescriptor/label)

A string that identifies this object.



---

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)