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

# MTLDepthStencilState

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

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

## Overview

The [`MTLDepthStencilState`](/documentation/Metal/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`](/documentation/Metal/MTLRenderCommandEncoder) uses an [`MTLDepthStencilState`](/documentation/Metal/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`](/documentation/Metal/MTLDepthStencilState) instance.
Instead, you can apply the following steps:

1. Create an [`MTLDepthStencilDescriptor`](/documentation/Metal/MTLDepthStencilDescriptor) instance that defines the operations
   you want the rendering pass to use.
2. Create an [`MTLDepthStencilState`](/documentation/Metal/MTLDepthStencilState) instance by passing the descriptor to an
   [`MTLDevice`](/documentation/Metal/MTLDevice) instance’s [`makeDepthStencilState(descriptor:)`](/documentation/Metal/MTLDevice/makeDepthStencilState(descriptor:)) method.

Typically, you create [`MTLDepthStencilState`](/documentation/Metal/MTLDepthStencilState) instances when your app is first initialized and then reuse them throughout the lifetime of your app.

## Topics

### Identifying properties

[`device`](/documentation/Metal/MTLDepthStencilState/device)

The device from which this state object was created.

[`label`](/documentation/Metal/MTLDepthStencilState/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)