← Back to release summary

WebGPU: WGSL Fragment Depth

Category
Graphics
Type
New or changed feature
Status
Proposed (Chrome Proposed)
Intent stage
None

WPT details: WebGPU/WGSL have a conformance test suite (https://github.com/gpuweb/cts) that is regularly pulled into Chromium and part of the testing of Dawn/Tint in Chromium. While the CTS can be embedded in WPT, the WebGPU team opted to keep it separate in Chromium testing to use a customized harness for robustness and performance. * https://github.com/gpuweb/cts/pull/4679 * https://github.com/gpuweb/cts/pull/4689

Summary

Adds the ability to provide a `less` or `greater` modifier to the `@builtin(frag_depth)` in WGSL. The current `@builtin(frag_depth)` can potentially introduce a performance penalty due to disabling the early-Z optimizations on a draw call. The new modifiers allow the explicit setting of the buffer mode and allow the early-Z optimizations to be applied.

Motivation

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. The introduction of a new depth_mode built-in parameter for the @builtin(frag_depth) with modes less, and greater directly addressing this performance limitation by letting the developer express their intent to the hardware.

Standards & signals

Ecosystem

Explainers: https://github.com/gpuweb/gpuweb/blob/main/proposals/fragment-depth.md

View on chromestatus.com