---
title: MTLDepthStencilState
framework: metal
role: symbol
role_heading: Protocol
path: metal/mtldepthstencilstate
---

# MTLDepthStencilState

A depth and stencil state instance that specifies the depth and stencil configuration and operations used in a render pass.

## Declaration

```swift
protocol MTLDepthStencilState : NSObjectProtocol, Sendable
```

## Overview

Overview The MTLDepthStencilState protocol defines the interface for a lightweight instance used to encode how a graphics rendering pass should perform depth and stencil operations. The MTLRenderCommandEncoder uses an MTLDepthStencilState instance to set the depth and stencil state for a rendering pass. The standard allocation and initialization techniques don’t apply when creating an MTLDepthStencilState instance. Instead, you can apply the following steps: Create an MTLDepthStencilDescriptor instance that defines the operations you want the rendering pass to use. Create an MTLDepthStencilState instance by passing the descriptor to an MTLDevice instance’s makeDepthStencilState(descriptor:) method. Typically, you create MTLDepthStencilState instances when your app is first initialized and then reuse them throughout the lifetime of your app.

## Topics

### Identifying properties

- [device](metal/mtldepthstencilstate/device.md)
- [label](metal/mtldepthstencilstate/label.md)

### Instance Properties

- [gpuResourceID](metal/mtldepthstencilstate/gpuresourceid.md)

## Relationships

### Inherits From

- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Depth testing

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