Google announced today that it will enable WebGPU support in its default Chrome browser starting with version 113, which is currently in beta. WebGPU, in development since 2017, is a next generation graphics API that aims to take advantage of low overhead APIs such as Microsoft Direct3D 12, Apple Metal, and Vulkan in web browsers and other applications.
WebGPU support has been available for some time, but is disabled by default in Chrome because the API hasn’t been finalized and things could break from update to update. Google says Mozilla and Apple will eventually support WebGPU in Firefox and Safari, and browsers like Microsoft Edge and Opera that rely on the Chromium browser engine could conceivably enable it, as Google did.
Chrome 113 supports WebGPU on Windows, macOS, and ChromeOS to begin with, while “support for other platforms” like Linux and Android “is coming later this year.” This version of the browser should become available to all Chrome users sometime in May.
Support in Chrome is a big step forward for any new standard, whether it’s a new or updated API, image format, or video codec. According to StatCounter, Chrome accounts for roughly two-thirds of the browser market share worldwide, and nearly 80 percent of the total browser market share if other Chromium-based browsers are included. Once Safari and Firefox add support, virtually all web browsers around the world will be able to run WebGPU code, so it’s worth briefly explaining what WebGPU is and why it exists.
What is Web GPU?
WebGPU is a kind of successor WebGL, a much older API that allows you to display OpenGL-based graphics in your browser without requiring additional third-party plugins such as Adobe Flash. While WebGL was revolutionary when it was announced in 2009, today it suffers from many of the same problems as OpenGL: it doesn’t take full advantage of modern GPUs, it can lose performance due to driver overhead, and it has only limited capabilities. kludgey support for GPU compute workloads.
“While WebGL is primarily designed for drawing images but can be repurposed (with more effort) to perform other kinds of computations, WebGPU has top-notch support for performing general computations on the GPU,” says draft paper explaining why WebGPU exists. The new API will improve graphics in environments like Babylon.js and game engines like Unity; will support GPU-accelerated workloads like those used for machine learning and artificial intelligence; and can make it easier for photo and video web apps (among others) to take advantage of the GPU acceleration that native apps benefit from.
WebGPU is being developed by a working group that includes members from Google, Microsoft, Apple, Mozilla, Intel and many other companies, and as a result the API has been designed with the widest possible compatibility. WebGPU is not a direct implementation of any existing graphics API, but is a native API that sits on top of and interacts with Direct3D 12, Metal, and Vulkan. This explainer from Surma, a Shopify engineer and ex-Google employee, sums it up nicely (our emphasis):
“While WebGL is just a thin wrapper around OpenGL, WebGPU has taken a different approach. It introduces its own abstractions and does not directly reflect any of these native APIs.. This is partly because no single API is available on all systems, and also because many concepts (e.g., extremely low-level memory management) are not idiomatic for web APIs. Instead, the WebGPU was designed to feel “webbed” and to conveniently sit on top of any of the native graphics APIs, abstracting from their features. It’s standardized in the W3C and all the major browser vendors are sitting around the table.”
This has the advantage that WebGPU code becomes very portable – write WebGPU code and as long as users have hardware and a browser that supports it, you should get the same result on a Windows system with Direct3D and on an Android phone with Vulkan. And this avoids some of the hacks that keep WebGL working – for example, WebGL on Windows and macOS doesn’t even use OpenGL directly, but uses a translator called CORNER instead, OpenGL API calls are turned into Direct3D and Metal API calls. With WebGPU, there is no need to start a separate project to write a slow or poorly maintained implementation of OpenGL.
WebGPU also has its own shader language (WGSL), which the Chrome team is still working on supporting – today’s announcement says that Google “plans to provide deeper access to shader cores” via WGSL in a future release. Like the rest of the WebGPU API, WGSL is platform independent and easily translates to the preferred shader language of whatever operating system you use it on.
Finally, despite the word “network” in the name, the WebGPU API is not limited to browsers. V RSPU project is Rust’s version of WebGPU that allows you to write WebGPU applications and run them outside of web browsers.
If you want to experiment with WebGPU right now, Chrome 113 beta is available. Here. A GitHub repository with code samples is available. Hereas well as the official documentation for both WebGPU another WGSL.