---
title: stencilFailureOperation
framework: metal
role: symbol
role_heading: Instance Property
path: metal/mtlstencildescriptor/stencilfailureoperation
---

# stencilFailureOperation

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

## Declaration

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

## Discussion

Discussion The default value is MTLStencilOperation.keep, which does not change the current stencil value. For more information on possible values, see MTLStencilOperation. When the stencil test fails for a pixel, its incoming color, depth, or stencil values are discarded.

## See Also

### Related Documentation

- [Metal Shading Language Guide](apple-archive/documentation/Metal/Reference/MetalShadingLanguageGuide/Introduction.md)
- [Metal Programming Guide](apple-archive/documentation/Miscellaneous/Conceptual/MetalProgrammingGuide/Introduction.md)

### Configuring stencil functions and operations

- [depthFailureOperation](metal/mtlstencildescriptor/depthfailureoperation.md)
- [depthStencilPassOperation](metal/mtlstencildescriptor/depthstencilpassoperation.md)
- [stencilCompareFunction](metal/mtlstencildescriptor/stencilcomparefunction.md)
- [MTLStencilOperation](metal/mtlstenciloperation.md)
