WGSL fragment_depth extension
In geometry-intensive render passes, early-Z optimizations are developers' best friend. They provide a massive performance boost by letting the GPU discard hidden pixels before running expensive fragment shaders. If a rasterized depth fails the depth test, the GPU skips the fragment shader entirely, provided the shader doesn't have other side effects.
If you want to read into how hardware handles this, MJP has an excellent write-up on When Does Early-Z Have to be Disabled?.
While custom depth manipulation is useful, doing it in your fragment shader comes with a hidden tax. Writing to @builtin(frag_depth) inside a fragment shader typically forces drivers to disable these early-Z optimizations for the entire draw call. This happens because driver heuristics can't guarantee that the shader's calculated output depth matches the depth interpolated by the rasterizer.
To address this performance penalty, the WGSL extension fragment_depth lets you specify a less or greater depth mode name on @builtin(frag_depth) to explicitly state how the written depth compares to the interpolated depth, enabling the GPU to safely apply early-Z optimizations.
This language extension can be feature-detected in JavaScript using navigator.gpu.wgslLanguageFeatures. It's recommended to use a requires-directive to signal the potential for non-portability with requires fragment_depth; at the top of your WGSL shader code. See the following example and intent to ship.
if (!navigator.gpu.wgslLanguageFeatures.has("fragment_depth")) {
throw new Error(`WGSL fragment depth is not available`);
}
const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();
const shaderModule = device.createShaderModule({ code: `
requires fragment_depth;
@fragment
fn main() -> @builtin(frag_depth, less) f32 {
// Explicitly states that the output fragment depth is less than early-Z depth,
// allowing the GPU to safely preserve early-Z optimizations.
return 0.0f;
}`,
});
Texture compression unaligned
The "texture-compression-unaligned" GPU feature enables the creation of compressed textures with dimensions that aren't integer multiples of the block size (such as 4x4 for BC, ETC2, and ASTC formats). Previously, WebGPU strictly required texture sizes to align with these block boundaries. By removing the need to pad or scale textures to fit block alignments, this feature preserves original compression fidelity without introducing scaling distortion. See the intent to ship.
The following code snippet checks if the adapter supports texture compression unaligned and, if available, requests a device with it.
const adapter = await navigator.gpu.requestAdapter();
if (!adapter.features.has("texture-compression-unaligned")) {
throw new Error("Texture compression unaligned support is not available");
}
// Explicitly request texture compression unaligned support.
const device = await adapter.requestDevice({
requiredFeatures: ["texture-compression-unaligned"],
});
Many thanks to external contributor Ignacio Castaño for driving this feature!
srgb-linear and display-p3-linear color spaces
With the addition of the "srgb-linear" and "display-p3-linear" predefined color spaces, the WebGPU canvas context can now render directly into extended-range linear color spaces to support wide-gamut displays. These color spaces maintain a linear relationship between pixel values and physical luminance. This makes them ideal for physical light rendering in games as well as spatial processing tasks like anti-aliasing, interpolation, and decimation. See the intent to ship and the Particles (HDR) sample PR #574.
const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();
const canvas = document.querySelector("canvas");
const context = canvas.getContext("webgpu");
context.configure({
device,
format: "rgba16float",
colorSpace: "display-p3-linear",
});
Additional snorm10-10-10-2 vertex format
The "snorm10-10-10-2" vertex format is a packed 32-bit format holding four signed normalized values: three 10-bit components (r, g, b) and one 2-bit component (a). With this format, you can efficiently store attributes, like 3D normal vectors with an extra 2-bit scalar, or alignment flag while saving memory bandwidth. See spec PR 6491.
f16 support on Linux for NVIDIA
The optional "shader-f16" feature, which provides support for 16-bit floating-point values in WGSL, is now supported on Linux for recent NVIDIA GPU drivers. See issue chromium:42251215.
Dawn updates
You can now query the LUID of the underlying DXGIAdapter for a given GPU adapter using the WGPUAdapterPropertiesD3D struct. See issue chromium:562849566.
This covers some of the key highlights. Check out the exhaustive list of commits.
What's New in WebGPU
A list of everything that has been covered in the What's New in WebGPU series.
Chrome 155-156
- WGSL fragment_depth extension
- Texture compression unaligned
- srgb-linear and display-p3-linear color spaces
- Additional snorm10-10-10-2 vertex format
- f16 support on Linux for NVIDIA
- Dawn updates
Chrome 153-154
Chrome 151-152
Chrome 149-150
Chrome 147-148
Chrome 146
- Support WebGPU compatibility mode on OpenGL ES 3.1
- Transient attachments
- WGSL texture_and_sampler_let extension
- Dawn updates
Chrome 145
Chrome 144
- WGSL subgroup_id extension
- WGSL uniform_buffer_standard_layout extension
- WebGPU on Linux
- Faster writeBuffer and writeTexture
- Dawn updates
Chrome 143
Chrome 142
Chrome 141
- Tint IR completed
- Integer range analysis in WGSL compiler
- SPIR-V 1.4 update for Vulkan backend
- Dawn updates
Chrome 140
- Device requests consume adapter
- Shorthand for using texture where texture view is used
- WGSL textureSampleLevel supports 1D textures
- Deprecate bgra8unorm read-only storage texture usage
- Remove GPUAdapter isFallbackAdapter attribute
- Dawn updates
Chrome 139
- 3D texture support for BC and ASTC compressed formats
- New "core-features-and-limits" feature
- Origin trial for WebGPU compatibility mode
- Dawn updates
Chrome 138
- Shorthand for using buffer as a binding resource
- Size requirement changes for buffers mapped at creation
- Architecture report for recent GPUs
- Deprecate GPUAdapter isFallbackAdapter attribute
- Dawn updates
Chrome 137
- Use texture view for externalTexture binding
- Buffers copy without specifying offsets and size
- WGSL workgroupUniformLoad using pointer to atomic
- GPUAdapterInfo powerPreference attribute
- Remove GPURequestAdapterOptions compatibilityMode attribute
- Dawn updates
Chrome 136
- GPUAdapterInfo isFallbackAdapter attribute
- Shader compilation time improvements on D3D12
- Save and copy canvas images
- Lift compatibility mode restrictions
- Dawn updates
Chrome 135
- Allow creating pipeline layout with null bind group layout
- Allow viewports to extend past the render targets bounds
- Easier access to the experimental compatibility mode on Android
- Remove maxInterStageShaderComponents limit
- Dawn updates
Chrome 134
- Improve machine-learning workloads with subgroups
- Remove float filterable texture types support as blendable
- Dawn updates
Chrome 133
- Additional unorm8x4-bgra and 1-component vertex formats
- Allow unknown limits to be requested with undefined value
- WGSL alignment rules changes
- WGSL performance gains with discard
- Use VideoFrame displaySize for external textures
- Handle images with non-default orientations using copyExternalImageToTexture
- Improving developer experience
- Enable compatibility mode with featureLevel
- Experimental subgroup features cleanup
- Deprecate maxInterStageShaderComponents limit
- Dawn updates
Chrome 132
- Texture view usage
- 32-bit float textures blending
- GPUDevice adapterInfo attribute
- Configuring canvas context with invalid format throw JavaScript error
- Filtering sampler restrictions on textures
- Extended subgroups experimentation
- Improving developer experience
- Experimental support for 16-bit normalized texture formats
- Dawn updates
Chrome 131
- Clip distances in WGSL
- GPUCanvasContext getConfiguration()
- Point and line primitives must not have depth bias
- Inclusive scan built-in functions for subgroups
- Experimental support for multi-draw indirect
- Shader module compilation option strict math
- Remove GPUAdapter requestAdapterInfo()
- Dawn updates
Chrome 130
- Dual source blending
- Shader compilation time improvements on Metal
- Deprecation of GPUAdapter requestAdapterInfo()
- Dawn updates
Chrome 129
Chrome 128
- Experimenting with subgroups
- Deprecate setting depth bias for lines and points
- Hide uncaptured error DevTools warning if preventDefault
- WGSL interpolate sampling first and either
- Dawn updates
Chrome 127
- Experimental support for OpenGL ES on Android
- GPUAdapter info attribute
- WebAssembly interop improvements
- Improved command encoder errors
- Dawn updates
Chrome 126
- Increase maxTextureArrayLayers limit
- Buffer upload optimization for Vulkan backend
- Shader compilation time improvements
- Submitted command buffers must be unique
- Dawn updates
Chrome 125
Chrome 124
- Read-only and read-write storage textures
- Service workers and shared workers support
- New adapter information attributes
- Bug fixes
- Dawn updates
Chrome 123
- DP4a built-in functions support in WGSL
- Unrestricted pointer parameters in WGSL
- Syntax sugar for dereferencing composites in WGSL
- Separate read-only state for stencil and depth aspects
- Dawn updates
Chrome 122
- Expand reach with compatibility mode (feature in development)
- Increase maxVertexAttributes limit
- Dawn updates
Chrome 121
- Support WebGPU on Android
- Use DXC instead of FXC for shader compilation on Windows
- Timestamp queries in compute and render passes
- Default entry points to shader modules
- Support display-p3 as GPUExternalTexture color space
- Memory heaps info
- Dawn updates
Chrome 120
- Support for 16-bit floating-point values in WGSL
- Push the limits
- Changes to depth-stencil state
- Adapter information updates
- Timestamp queries quantization
- Spring-cleaning features
Chrome 119
- Filterable 32-bit float textures
- unorm10-10-10-2 vertex format
- rgb10a2uint texture format
- Dawn updates
Chrome 118
- HTMLImageElement and ImageData support in
copyExternalImageToTexture() - Experimental support for read-write and read-only storage texture
- Dawn updates
Chrome 117
- Unset vertex buffer
- Unset bind group
- Silence errors from async pipeline creation when device is lost
- SPIR-V shader module creation updates
- Improving developer experience
- Caching pipelines with automatically generated layout
- Dawn updates
Chrome 116
- WebCodecs integration
- Lost device returned by GPUAdapter
requestDevice() - Keep video playback smooth if
importExternalTexture()is called - Spec conformance
- Improving developer experience
- Dawn updates
Chrome 115
- Supported WGSL language extensions
- Experimental support for Direct3D 11
- Get discrete GPU by default on AC power
- Improving developer experience
- Dawn updates
Chrome 114
- Optimize JavaScript
- getCurrentTexture() on unconfigured canvas throws InvalidStateError
- WGSL updates
- Dawn updates