fragment_depth
WGSL language feature
Specification: WGSL § fragment_depth
Check navigator.gpu?.wgslLanguageFeatures?.has('fragment_depth')
before choosing a shader that uses this language feature. It is available automatically
when supported; requires fragment_depth; documents the dependency
and rejects the shader on unsupported implementations. This language token is not a
requiredFeatures entry for requestDevice(); any additional
device requirements are described below.
Writing frag_depth typically stops the GPU from depth-testing a fragment before its shader runs, because the final depth is unknown until then. With this language feature, the output can be declared as @builtin(frag_depth, less) - a promise that the written value is less than or equal to the fragment’s rasterized depth - or @builtin(frag_depth, greater) for greater than or equal.
Depth-correct impostors such as sphere and capsule billboards, parallax occlusion mapping, and decals that nudge depth all move depth in a known direction. Pairing the promise with the depth comparison is what helps: with a "less" compare function, a greater promise means a fragment that already fails the test can never pass after shading, so it can be rejected early.
Breaking the promise is not validated; the spec allows an indeterminate depth value to be used instead, so clamp the written value against @builtin(position).z when in doubt. Plain @builtin(frag_depth) remains valid everywhere, so the fallback is simply to omit the depth mode and accept the slower path.
Availability by month
| Month | With feature | Eligible reports | Availability |
|---|---|---|---|
| 2026-08 | 0 | 238 | 0.0% |
| 2026-09 | 0 | 175 | 0.0% |
| 2026-10 | 1 | 22 | 4.5% |
By browser (last 30 days)
| Browser | Availability | n |
|---|---|---|
| chrome | 0.9% | 113 |
| edge | 0.0% | 13 |
| firefox | 0.0% | 12 |
| safari | 0.0% | 14 |
Availability = share of first-party, non-quarantined reports with WebGPU on a hardware
(non-fallback) adapter
whose browser reports this token in navigator.gpu.wgslLanguageFeatures.
This measures language support in the browser, not a GPU hardware capability.
Developer-leaning sample.
Full methodology.