What's New in WebGPU (Chrome 115)

François Beaufort
François Beaufort

Supported WGSL language extensions

The wgslLanguageFeatures member of the GPU object lists the names of supported WGSL language extensions. Supported WGSL language extensions are automatically enabled, therefore you don’t need to explicitly request one. This list is currently empty but you can expect plenty of them in the future (for example, do-while loops). See issue dawn:1777.

if (navigator.gpu.wgslLanguageFeatures?.has("unknown-feature")) {
  // Use unknown-feature in WGSL shader code.
}

Experimental support for Direct3D 11

The Chromium team is working on adding WebGPU support for Direct3D 11. You can now experiment with it locally by running Chrome on Windows with the --enable-unsafe-webgpu --use-webgpu-adapter=d3d11 command-line flags. See issue dawn:1705.

Get discrete GPU by default on AC power

On dual GPU macOS devices, if requestAdapter() is called without a powerPreference option, the discrete GPU is returned when the user’s device is on AC power. Otherwise, the integrated GPU is returned. See change 4499307.

Improving developer experience

New DevTools warnings

If the depth key is used in a GPUExtend3DDict a warning is shown in the DevTools Console since the correct key is depthOrArrayLayers. See issue chromium:1440900.

A warning is also raised if a GPUBlendComponent has a mix of explicit and defaulted members. See issue dawn:1785.

Even though zero-size dispatches and draws are valid, a warning encourages developers to avoid them when possible. See issue dawn:1786.

Better error messages

An improved error message is now provided when using a GPUCommandEncoder if finish() has been called already. See issue dawn:1736.

When submitting command buffers with destroyed objects, the labels of the command buffers that were used in submit() are now visible in the error message. See issue dawn:1747.

The invalid part of the depth stencil state is now specified in the error message when validating depthStencil. See issue dawn:1735.

The minBindingSize validation error message now reports the group and number of the binding that failed validation, as well as the buffer. See issue dawn:1604.

Error messages returned by the mapAsync() method on a GPUBuffer object have been improved to help developers when debugging. See an example below and issue chromium:1431622.

// Create a GPU buffer and map it.
const descriptor = { size: 0, usage: GPUBufferUsage.MAP_READ };
const buffer = device.createBuffer(descriptor);
buffer.mapAsync(GPUMapMode.READ);

// Before it has been mapped, request another mapping.
try {
  await buffer.mapAsync(GPUMapMode.READ);
} catch (error) {
  // New! Error message tells you mapping is already pending.
  console.warn(error.message);
}

Labels in macOS debugging tools

The use_user_defined_labels_in_backend debug toggle allows you to forward object labels to the backend so that they can be seen in platform-specific debugging tools like RenderDoc, PIX, or Instruments. From now on, a better debug experience is provided on macOS when you enable it for debugging. See issue dawn:1784

Screenshot of Instruments app on macOS featuring custom labels coming from WebGPU.
User defined labels in the Instruments app on macOS.

Log HLSL if compilation fails

The dump_shaders debug toggle allows you to log input WGSL shaders and translated backend shaders. From now on, when you enable it for debugging, the HLSL will be dumped if it fails compilation. See issue dawn:1681

Dawn updates

Unset vertex buffer

Passing nullptr rather than a wgpu::Buffer to SetVertexBuffer() on wgpu::RenderPassEncoder or wgpu::RenderBundleEncoder allows you to unset a previously set vertex buffer in a given slot. See issue dawn:1675.

// Set vertex buffer in slot 0.
myRenderPassEncoder.SetVertexBuffer(0, myVertexBuffer);

// Then later, unset vertex buffer in slot 0.
myRenderPassEncoder.SetVertexBuffer(0, nullptr);

Transient attachments

You can create attachments that allow render pass operations to stay in tile memory, avoiding VRAM traffic and potentially avoiding VRAM allocation for the textures by setting the wgpu::TextureUsage::TransientAttachment usage. This feature is supported only for Metal and Vulkan. See issue dawn: 1695.

wgpu::TextureDescriptor desc;
desc.format = wgpu::TextureFormat::RGBA8Unorm;
desc.size = {1, 1, 1};
desc.usage = wgpu::TextureUsage::RenderAttachment |
             wgpu::TextureUsage::TransientAttachment;

auto transientTexture = device.CreateTexture(&desc);

// You can now create views from the texture to serve as transient
// attachments, e.g. as color attachments in a render pipeline.

Building without depot_tools

A new DAWN_FETCH_DEPENDENCIES CMake option allows you to fetch Dawn dependencies using a Python script that reads DEPS files instead of requiring the installation of depot_tools by all projects that depend on it. See change 131750.

What's New in WebGPU

A list of everything that has been covered in the What's New in WebGPU series.

Chrome 122

Chrome 121

Chrome 120

Chrome 119

Chrome 118

Chrome 117

Chrome 116

Chrome 115

Chrome 114

Chrome 113