Depth, Stencil, & Alpha¶
These three states control the depth, stencil, and alpha tests, used to discard fragments that have passed through the fragment shader.
Traditionally, these three tests have been clumped together in hardware, so they are all stored in one structure.
During actual execution, the order of operations done on fragments is always:
Whether the depth test is enabled.
Whether the depth buffer receives depth writes.
The depth test function. One of PIPE_FUNC.
Whether the stencil test is enabled. For the second stencil, whether the two-sided stencil is enabled. If two-sided stencil is disabled, the other fields for the second array member are not valid.
The stencil test function. One of PIPE_FUNC.
Stencil test value mask; this is ANDed with the value in the stencil buffer and the reference value before doing the stencil comparison test.
Stencil test writemask; this controls which bits of the stencil buffer are written.
The operation to carry out if the stencil test fails. One of PIPE_STENCIL_OP.
The operation to carry out if the stencil test passes but the depth test fails. One of PIPE_STENCIL_OP.
The operation to carry out if the stencil test and depth test both pass. One of PIPE_STENCIL_OP.
Whether the alpha test is enabled.
The alpha test function. One of PIPE_FUNC.
Alpha test reference value; used for certain functions.