<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLRenderCommandEncoder/setStencilStoreAction(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLRenderCommandEncoder(im)setStencilStoreAction:"
  },
  "title" : "setStencilStoreAction(_:)"
}
-->

# setStencilStoreAction(_:)

Configures the store action for the stencil attachment.

```
func setStencilStoreAction(_ storeAction: MTLStoreAction)
```

## Parameters

`storeAction`

A store action for the stencil attachment that can’t be [`MTLStoreAction.unknown`](/documentation/Metal/MTLStoreAction/unknown).

## Discussion

This method changes the render command encoder’s store action for the stencil attachment. You can assign the default store action for the stencil attachment by configuring the [`storeAction`](/documentation/Metal/MTLRenderPassAttachmentDescriptor/storeAction) property of its [`MTLRenderPassStencilAttachmentDescriptor`](/documentation/Metal/MTLRenderPassStencilAttachmentDescriptor) (see [`MTLRenderPassDescriptor`](/documentation/Metal/MTLRenderPassDescriptor) and its [`stencilAttachment`](/documentation/Metal/MTLRenderPassDescriptor/stencilAttachment) property).

> Important:
> You need to call this method before calling the encoder’s ``doc://com.apple.metal/documentation/Metal/MTLCommandEncoder/endEncoding()`` method, but only if the stencil attachment’s ``doc://com.apple.metal/documentation/Metal/MTLRenderPassAttachmentDescriptor/storeAction`` property is equal to ``doc://com.apple.metal/documentation/Metal/MTLStoreAction/unknown``.

---

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)