WebGPU is the successor to WebGL, a well-adopted modern API standard for interfacing with GPUs.
WebGPU offers the following benefits:
WebGPU is a render hardware interface built on top of various backend APIs such as Vulkan, DirectX, and Metal, though this is OS-dependent.
WebGPU is available through web browsers using the webgpu.h header file.
The high-level view of WebGPU is shown below in Figure 1:
WebGPU uses lessons learned from earlier standards such as WebGL and OpenGL to develop an improved offering, and provides the following benefits:
It is important to note that WebGPU is a standard, and not a true API, so the implementation can be adopted and developed as an interface between native applications developed in any programming language.
The performance requirements for web pages are the same as for native applications.
When designing an API for the Web, the two key constraints are portability and privacy.
Any limitations of the API caused by privacy constraints can be disabled when using WebGPU as a native API.
The initial focus for WebGPU was JavaScript. The initial webgpu.h
header file is written in C.
This Learning Path uses C++ rather than JavaScript or C, for the following reasons:
Since WebGPU is a standard and not an implementation itself, there are various possible options for implementation.
Dawn
is an open-source, cross-platform implementation of the WebGPU standard. It implements the WebGPU functionality specified in webgpu.h
.
Dawn is designed to be integrated as part of a larger system such as Chromium or a native Android Application.
Dawn provides several WebGPU building blocks:
As it is written in C++, Dawn provides enhanced error message reporting and logging. The fact that it is open source, also means that it is easier to inspect stack traces when applications crash.
Dawn is usually ahead of wgpu-native
, another WebGPU implementation, in terms of new functionality developments and standards changes.