What it does
Stencil Test compares stored screen-space markers to decide where drawing is allowed. Reference supplies the comparison value, ReadMask selects the relevant bits, and the comparison function defines the condition. Stencil write operations can update markers afterward.
How to use it
ReadMask selects the stored/reference bits compared by Comp. WriteMask instead selects bits that operations may update; these roles are different.
A concrete example
ReadMask one, reference one and Equal test the lowest bit. A reader that should not modify data needs the intended Keep/write-mask behavior.
How to check it
- Verify writer-before-reader order, shared stencil target and intervening clears.
Testing and writing are separate settings - Allocate bits deliberately across masks and pipeline features to avoid overwriting unrelated state.
Testing and writing are separate settings
Limitations
Avoid collisions with other masks and pipeline-reserved bits.