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

# stencilFailureOperation

The operation that is performed to update the values in the stencil attachment when the stencil test fails.

```
var stencilFailureOperation: MTLStencilOperation { get set }
```

## Discussion

The default value is [`MTLStencilOperation.keep`](/documentation/Metal/MTLStencilOperation/keep), which does not change the current stencil value. For more information on possible values, see [`MTLStencilOperation`](/documentation/Metal/MTLStencilOperation).

When the stencil test fails for a pixel, its incoming color, depth, or stencil values are discarded.

## See Also

  [Metal Shading Language Guide](https://developer.apple.com/library/archive/documentation/Metal/Reference/MetalShadingLanguageGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40014364)

  [Metal Programming Guide](https://developer.apple.com/library/archive/documentation/Miscellaneous/Conceptual/MetalProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40014221)



---

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)