What's New in WebGPU (Chrome 125)

François Beaufort
François Beaufort

The number of WebGPU features might feel a bit sparse this time, but some major advancements are just around the corner! Future releases will include features like shader compilation speed improvements, and changes to the async model of the implementation using WGPUFuture.

Subgroups (feature in development)

The subgroups feature enables SIMD-level parallelism, allowing threads within a group to communicate and perform collective math operations (for example, calculating the sum of 16 numbers). This provides a highly efficient form of cross-thread data sharing.

Subgroup operations are supported by modern GPU APIs, but naming and implementation details vary. The Chrome team has identified the commonalities and is now working to standardize this feature. Check out the proposal and comment if you have questions.

There's a minimal and unstandardized implementation of subgroups behind the "Experimental Web Platform Features" flag at chrome://flags/#enable-experimental-web-platform-features so that developers can give it a try and share feedback as real-world benefits have not been proven yet in the context of WebGPU.

When the "chromium-experimental-subgroups" feature is available in a GPUAdapter, request a GPUDevice with this feature to get experimental subgroups support in WGSL and check its minSubgroupSize and maxSubgroupSize limits.

You also need to explicitly enable this extension in your WGSL code with enable chromium_experimental_subgroups. When enabled, you get access to the following additions:

  • subgroup_invocation_id: A built-in value for the index of the thread within the subgroup.
  • subgroup_size: A built-in value for subgroup size access.
  • subgroupBallot(value): Returns a set of bit fields where the bit corresponding to subgroup_invocation_id is 1 if value is true for that active invocation and 0 otherwise.
  • subgroupBroadcast(value, id): Broadcasts the value from the invocation with subgroup_invocation_id matching id to all invocations within the subgroup. Note: id must be a compile-time constant.

The following code snippet provides a base to tinker with and discover the potential of subgroups.

const adapter = await navigator.gpu.requestAdapter();
if (!adapter.features.has("chromium-experimental-subgroups")) {
  throw new Error("Experimental subgroups support is not available");
}
// Explicitly request experimental subgroups support.
const device = await adapter.requestDevice({
  requiredFeatures: ["chromium-experimental-subgroups"],
});

const shaderModule = device.createShaderModule({ code: `
  enable chromium_experimental_subgroups;

  @compute @workgroup_size(64) fn main(
      @builtin(global_invocation_id) global_id : vec3u,
      @builtin(subgroup_size) sg_size : u32,
      @builtin(subgroup_invocation_id) sg_id : u32) {
    // TODO: Use subgroupBallot() and subgroupBroadcast().
  }`,
});

Render to slice of 3D texture

You can now render directly to slice(s) of 3D textures within render passes, expanding its capabilities beyond common 2D texture rendering, with the new depthSlice member in a GPURenderPassColorAttachment. This addition allows you for example to create voxel-based scenes and effects by rendering directly into 3D texture volumes. See issue dawn:1020.

Dawn updates

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 129

Chrome 128

Chrome 127

Chrome 126

Chrome 125

Chrome 124

Chrome 123

Chrome 122

Chrome 121

Chrome 120

Chrome 119

Chrome 118

Chrome 117

Chrome 116

Chrome 115

Chrome 114

Chrome 113