Stencil buffer to track the same state

I can't get my stencil buffer to track one state for back and front facing triangles. Assigning the same descriptor as suggested in the headers does not work:

MTLDepthStencilDescriptor *depthDescriptor = [[MTLDepthStencilDescriptor alloc] init];
[... asigning values to back stencil]
depthDescriptor.backFaceStencil = depthDescriptor.frontFaceStencil;

Creating a stencil yourself and assigning it to both back and front also doesn't work. The backFaceStencil (and front) property is marked as copy so assigning them yourself will inevitably lead to two different objects. So if equality is evaluated purely on the pointer basis of the descriptor - I don't think it's possible to assign the same descriptor here. Is this a bug or am I missing sth?

You can use [depthDescriptor.backFaceStencil isEqual:depthDescriptor.frontFaceStencil]; to verify that they are tracking the same state. The comparison is not done by pointer, but by comparing their properties such as stencilCompareFunction.

Thank you! The problem was actually related to a misunderstanding on my part on some stencil buffer operations. Works now as expected!

Stencil buffer to track the same state
 
 
Q