---
title: MTLDepthStencilDescriptor
framework: metal
role: symbol
role_heading: Class
path: metal/mtldepthstencildescriptor
---

# MTLDepthStencilDescriptor

An instance that configures new MTLDepthStencilState instances.

## Declaration

```swift
class MTLDepthStencilDescriptor
```

## Overview

Overview An MTLDepthStencilDescriptor instance is used to define a specific configuration of the depth and stencil stages of a rendering pipeline. To create an MTLDepthStencilDescriptor instance, use standard allocation and initialization techniques. To enable writing the depth value to a depth attachment, set the depthWriteEnabled property to 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 is a commonly used value for 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 and 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](metal/mtldepthstencildescriptor/depthcomparefunction.md)
- [isDepthWriteEnabled](metal/mtldepthstencildescriptor/isdepthwriteenabled.md)

### Specifying stencil descriptors for primitives

- [backFaceStencil](metal/mtldepthstencildescriptor/backfacestencil.md)
- [frontFaceStencil](metal/mtldepthstencildescriptor/frontfacestencil.md)

### Identifying properties

- [label](metal/mtldepthstencildescriptor/label.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Depth testing

- [Calculating primitive visibility using depth testing](metal/calculating-primitive-visibility-using-depth-testing.md)
- [MTLDepthStencilState](metal/mtldepthstencilstate.md)
- [MTLStencilDescriptor](metal/mtlstencildescriptor.md)
