Skip to content

Commit 455ce32

Browse files
authored
Remove any from frag_depth proposal. (#6290)
Remove the `any` keyword from the frag_depth proposal. `frag_depth(any)` is just another way to write `frag_depth`. The latter is shorter and we have not been adding the 'default' value entries in for other optional values in the spec. Closes #6233
1 parent ea56611 commit 455ce32

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

proposals/fragment-depth.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Fragment depth (less, greater, any)
1+
# Fragment depth (less, greater)
22

33
* Status: [Draft](README.md#status-draft)
44
* Created: 2025-10-08
@@ -10,9 +10,8 @@ The ability for fragment shaders to explicitly write to the depth buffer via the
1010

1111
In the current WGSL specification, the mere act of writing to `@builtin(frag_depth)` often incurs a significant performance penalty because driver heuristics cannot guarantee that the fragment shader output will adhere to the depth written by the rasterizer's interpolated depth. Consequently, writing to `frag_depth` typically forces the GPU to disable crucial early-Z optimizations for the entire draw call.
1212

13-
The introduction of a new `depth_mode` built-in parameter for the `@builtin(frag_depth)` with modes `less`, `greater`, and `any` directly addresses this performance limitation by letting the developer express their intent to the hardware.
13+
The introduction of a new `depth_mode` built-in parameter for the `@builtin(frag_depth)` with modes `less`, and `greater` directly addresses this performance limitation by letting the developer express their intent to the hardware.
1414

15-
* The `any` mode maintains the existing, unconditional behavior of `frag_depth`.
1615
* The `less` and `greater` modes are used when a fragment shader declares it will only write depth values that are guaranteed to be less than (or greater than) the existing depth. The driver can be assured that any fragment whose interpolated depth already fails the declared comparison cannot possibly satisfy the conditional write, allowing it to be rejected early.
1716

1817
## HLSL
@@ -55,11 +54,10 @@ Source: https://usermanual.wiki/Document/Vulkan2BProgramming2BGuide2BThe2BOffici
5554

5655
### Built-in `depth_mode` parameter to `frag_depth`
5756

58-
An optional `depth_mode` parameter declared after the built-in `frag_depth` name is allowed and
59-
defaults to `any`.
57+
An optional `depth_mode` parameter declared after the built-in `frag_depth` name is allowed. Without
58+
providing a `depth_mode` the fragment depth is implicitly `any`.
6059

61-
It can be either `@builtin(frag_depth)`, `@builtin(frag_depth, greater)`,
62-
`@builtin(frag_depth, lesser)`, or `@builtin(frag_depth, any)`.
60+
It can be either `@builtin(frag_depth)`, `@builtin(frag_depth, greater)`, or `@builtin(frag_depth, lesser)`
6361

6462
This applies `depth_mode` on the `frag_depth` built-in output value in a fragment shader.
6563

@@ -70,15 +68,15 @@ requires fragment_depth;
7068
7169
@fragment
7270
fn main() -> @builtin(frag_depth, greater) f32 {
73-
return 1.0f;
71+
return 1.0f;
7472
}
7573
```
7674

7775
### Built-in Value Mappings
7876

7977
| Built-in | SPIR-V | MSL | HLSL | GLSL |
8078
|----------|--------|-----|------|------|
81-
| frag_depth, any | SpvBuiltInFragDepth | depth(any) | SV_Depth | depth_any |
79+
| frag_depth | SpvBuiltInFragDepth | depth(any) | SV_Depth | depth_any |
8280
| frag_depth, greater | SpvBuiltInFragDepth + OpExecutionMode DepthGreater | depth(greater) | SV_DepthGreaterEqual | depth_greater |
8381
| frag_depth, less | SpvBuiltInFragDepth + OpExecutionMode DepthLess | depth(less) | SV_DepthLessEqual | depth_less |
8482

0 commit comments

Comments
 (0)