v154 · frag_depth modifiers
The three shader forms
The same shader written three ways. If this machine has a GPU the demo compiles each one and shows the WGSL compiler's own diagnostics; if it does not, it says so rather than inventing a verdict.
Compile all three
What each modifier promises
| form | the promise | early-Z | if you break it |
|---|---|---|---|
| no modifier | none | disabled for the draw call | nothing to break |
greater | the written depth is never nearer than the interpolated one | kept — a fragment already behind stays behind | undefined results, not an error |
less | the written depth is never further than the interpolated one | kept, for the reversed-depth setup | undefined results, not an error |
Nothing checks the promise at runtime — that is the trade. You get the optimisation because the hardware trusts you, and a shader that lies produces artefacts that will not reproduce on the machine you debug on. Use the modifier when the maths guarantees the direction, not when it usually holds.