Chromium's WebGPU implementation and Dawn's API try to closely follow changes to the WebGPU specification. When the WebGPU IDL changes, Chromium and Dawn will try to support both the deprecated and the new version of the IDL at the same time so prototypes can be updated. In JavaScript, uses of the deprecated path will result in a console warning, while when using Dawn directly, the deprecated path will print a warning to stderr.
Note that all changes to Dawn's API make it closer to webgpu.h
that we hope will allow applications to target both Dawn, and wgpu in native before being compiled in WASM. Emscripten will also be updated from the "old" to the "new" API but won't have a smooth transition since developers control which version of emscripten they use.
Items deprecated in this changelog will be removed in the next branched version of Chromium. They will also be removed in Chromium Canary and top of tree Dawn two weeks after this changelog is published in Canary and top of tree Dawn (so starting 2022-01-05).
Previous PSAs / changelogs:
GPUQueue.copyImageBitmapToTexture
-> GPUQueue.copyExternalImageToTexture
copyImageBitmapToTexture
has been deprecated for a while but copyExternalImageToTexture
wasn't a superset until recently. Now it is a superset so copyImageBitmapToTexture
will be removed soon.
In JavaScript copyExternalImageToTexture
is used like so:
There are more options to control many aspects of the copy, including color space conversion, premultiplied alpha, etc. See the relevant section of the spec.
ignore()
is replaced with phony-assignmentThe ignore
builtin was useful to ignore the return value of functions and to statically reference bindings without using them. It has been replaced with the "phony assignement" using _
as an identifier.
WGSL code needs to be updated like the following:
modf
and frexp
overloads taking are deprecatedThese two builtins return a structure containing two members instead of returning one by value and one through a pointer.
WGSL code needs to be updated like the following:
Readonly storage textures are already removed from the API, but it will now become invalid to declare readonly storage textures in WGSL code as well, even if they are not statically used.
isNan
, isInf
, isFinite
and isNormal
are deprecatedWebGPU PR. They will be removed in M101
GPUs don't need to have floating points that are strictly IEE-754 compliant and in particular might not support infinities, NaNs and denormal floating pointer numbers. This means that a driver might optimize isNan
and isInf
(resp isFinite
and isNormal
) to always return true
(resp. false
).
It means that these builtins can't be relied upon and they have been removed.
This is a limitation coming from the Metal Shading Language. The following WGSL now produces an error:
It is no longer possible to shadow a builtin function's name with a user-defined function. The following WGSL now produces an error:
discard
inside a loop continuing
block is an errorThis is aprt of the WGSL behavior rules.
Prviously it was an error to use discard
inside a loop continuing block, and now with the behavior rules it is also an error to call a function that may potentially discard. The following WGSL now produces an error:
GPUAdapter.limits
are now supportedFor portability, WebGPU has conservative values for many limits such as maxTextureDimension2D
. Previously Chromium forced these limits to the minimum required limits in the specification. It now exposes the GPUAdapter
limits on the object and allows configuring them when requesting a device.
Note that for privacy reasons, Chromium doesn't expose the exact limits of every device to JavaScript and instead buckets them. The definition of the buckets or even the bucket mechanism are likely to change in the future but a couple buckets are exposed at the moment for limits such as maxComputeWorkgroupStorageSize
and maxStorageBufferBindingSize
which were very conservative.
In JavaScript requesting limits is done like the following:
When using Dawn's C++ API similar mechanisms are available but they are being reimplemented to match webgpu.h
so they aren't described here.
GPUComputePassEncoder.dispatchIndirect
This method is like GPUComputePassEncoder.dispatch
except that instead of taking the x
, y
, z
arguments directly, it takes them from a GPUBuffer
. It allows previous GPU operations to choose how many workgroups to dispatch without doing a roundtrip to the CPU, allowing more powerful GPU-centric algorithms.
In JavaScript it can be used like so:
Likewise when using Dawn's C++ API:
GPURenderEncoderBase.drawIndexedIndirect
This is very similar to GPUComputePassEncoder.dispatchIndirect
, except that it is the indirect version of GPURenderEncoderBase.drawIndexed
.
When available on the system, Chromium will now expose the texture-compression-etc
and texture-compression-astc
optional features. This means that on all systems, one of the BC, ETC(2) or ASTC optional features are exposed so there is always some form of texture compression available.
These compressed formats are usable like the previously available BC formats. See the list of format support in the WebGPU specification for more information.
depth16unorm
This small depth format is now supported. It is the only non-optional depth format that's supported as both a source and destination of copies (the depth24plus
). See the list of depth stencil format support in the WebGPU specification for more information.
VideoFrame
support in GPUDevice.importTexture
(Web-only)GPUExternalTexture
is an object that provides optimized access to a frame of an external video object. It previously only supported being created from an HTMLVideoElement
. It is now also possible to create a GPUExternalTexture
from a WebCodec VidoFrame
object. This allows working in an optimized manner with WebCodec streams of video.
Note that the implementation isn't completely optimized yet, and that in the future closing the VideoFrame
will destroy the GPUExternalTexture
.
copyExternalImageToTexture
(Web-only)GPUQueue.copyExternalImageToTexture
has been extended to support more destination texture formats. This is what makes it a strict superset of copyImageBitmapToTexture
now.
stripIndexFormat
is validated at draw timestripIndexFormat
was required to be specified for all pipelines that had a strip primitive topology. This is now only required if the pipeline is used in a indexed draw operations. The following JavaScript code used to produce an error but is now value.
<canvas>
readbacksVarious APIs that read the content of canvases now work with WebGPU canvases. For example HTMLCanvasElement.toDataURL
. Note however that due to an implementation issue, the content read back from the canvas may be from some past frame. This is a known issue that requires complex changes in Chromium to fix and won't be solved immediately.
The WGSL specification now has control flow analysis built-in in the behavior rule section. It lifts the requirement that a function returning a value must end with a return, as long as all control flow paths return. For example the following WGSL code used to produce an error but is now valid:
Note that unreachable statements now produce a warning, instead of an error as required by the specification. This allows WGSL code that had the dummy returns to be updated. These warnings may become errors in the future.
textureGather[Compare]
builtinsGiven a component index (0 for R, 1 for G, etc), textureGather(component, texture, sampler, coords)
return the component of the four texels that would be sampled by the a textureSample
operation. It is a common way to reduce memory traffic in shaders that care about a single component of multiple texels. The component
argument must be a compile time constant.
The WGSL example from the specification is:
Previously WebGPU didn't allow shadowing identifiers in an outer scope with identifiers in an inner scope. This is now allowed and makes the following WGSL code valid (one of many other shadowing cases):
But identifiers reserved for the WGSL specification and implementations are now prefixed with double underscores, so these are not allowed. But _my_identifier
is allowed.
WGSL no longer requires that the return value of functions are used. The following WGSL code is now valid:
Matrices can be constructed by giving their scalars in column-major order.
It is not possible to specify [[interpolate(flat)]]
on integral user-defiend IO. It will eventually become an error to define integral user-defined IO without this attribute. For example:
dot
buitin variants for integer vector typesThe dot product builtin can now act on vectors of i32
and u32
, and returns that same type.
any(bool)
and all(bool)
These were missed in the initial implementation and are added from completeness. They just return their argument.