WebGPU: Unlocking modern GPU access in the browser - Chrome Developers (2024)

The new WebGPU API unlocks massive performance gains in graphics and machine learning workloads. This article explores how WebGPU is an improvement over the current solution of WebGL, with a sneak peek at future developments. But first, let’s provide some context for why WebGPU was developed.

# Context on WebGPU

WebGL landed in Chrome in 2011. By allowing web applications to take advantage of GPUs, WebGL enables amazing experiences on the web—from Google Earth, to interactive music videos, to 3D real-estate walkthroughs and more. WebGL was based on the OpenGL family of APIs first developed in 1992. That's a long time ago! And you can imagine that GPU hardware has evolved significantly since that time.

To keep up with this evolution, a new breed of APIs were developed to more efficiently interact with modern GPU hardware. APIs like Direct3D 12, Metal, and Vulkan. These new APIs have supported new and demanding use cases for GPU programming such as the explosion in machine learning and advances in rendering algorithms. WebGPU is the successor to WebGL bringing the advancements of this new class of modern APIs to the Web.

WebGPU unlocks a lot of new GPU programming possibilities in the browser. It better reflects how modern GPU hardware works, while also laying a foundation for more advanced GPU capabilities in the future. The API has been baking in the W3C’s "GPU for the Web" group since 2017, and is a collaboration between many companies such as Apple, Google, Mozilla, Microsoft, and Intel. And now after 6 years of work, we’re excited to announce that one of the biggest additions to the Web platform is finally available!

WebGPU is available today in Chrome113 on ChromeOS, macOS, and Windows, with other platforms coming soon. A huge thank you to other Chromium contributors and Intel in particular who helped make this happen.

Now let’s take a look at some of the exciting use cases WebGPU enables.

# Unlocking new GPU workloads for rendering

WebGPU features such as compute shaders enable new classes of algorithms to be ported on the GPU. For example, algorithms that can add more dynamic details to scenes, simulate physical phenomenons, and more! There are even workloads that previously could only be done in JavaScript that can now be moved to the GPU.

The following video shows the marching cubes algorithm being used to triangulate the surface of these metaballs. In the first 20 seconds of the video, the algorithm, when it's running in JavaScript, struggles to keep up with the page only running at 8 FPS resulting in janky animation. To keep it performant in JavaScript we would need to lower the level of details a lot.

It's a night and day difference when we move the same algorithm to a compute shader, which is seen in the video after 20 seconds. The performance improves dramatically with the page now running at a smooth 60 FPS and there's still a lot of performance headroom for other effects. In addition the page’s main JavaScript loop is completely freed up for other tasks, ensuring that interactions with the page stay responsive.

WebGPU also enables complex visual effects that were not practical before. In the following example, created in the popular Babylon.js library, the ocean surface is being simulated entirely on the GPU. The realistic dynamics are created from many independent waves being added to each other. But simulating each wave directly would be too expensive.

That's why the demo uses an advanced algorithm called Fast Fourier Transform. Instead of representing all the waves as complex positional data, this uses the spectral data which is much more efficient to perform computations. Then each frame uses the Fourier Transform to convert from spectral data to the positional data that represents the height of the waves.

# Faster ML inference

WebGPU is also useful to accelerate machine learning, which has become a major use of GPUs in recent years.

For a long time, creative developers have been repurposing WebGL's rendering API to perform non-rendering operations such as machine learning computations. However, this requires drawing the pixels of triangles as a way to initiate the computations, and carefully packing and unpacking tensor data in texture instead of more general purpose memory accesses.

WebGPU: Unlocking modern GPU access in the browser - Chrome Developers (1)

Using WebGL in this way requires developers to awkwardly conform their code to the expectations of an API designed only for drawing. Combined with the lack of basic features like shared memory access between computations, this leads to duplicate work and suboptimal performance.

Compute shaders are WebGPU's primary new feature and remove these pain points. Compute shaders offer a more flexible programming model that takes advantage of the GPU's massively parallel nature while not being constrained by the strict structure of rendering operations.

WebGPU: Unlocking modern GPU access in the browser - Chrome Developers (2)

Compute shaders give more opportunity for sharing data and computation results within groups of shader work for better efficiency. This can lead to significant gains over previous attempts to use WebGL for the same purpose.

As an example of the efficiency gains this can bring, an initial port of an image diffusion model in TensorFlow.js shows a 3x performance gain on a variety of hardware when moved from WebGL to WebGPU. On some of the hardware tested the image was rendered in under 10 seconds. And because this was an early port, we believe there are even more improvements possible in both WebGPU and TensorFlow.js! Check out What’s new with Web ML in 2023? Google I/O session.

But WebGPU is not only about bringing GPU features to the web.

# Designed for JavaScript first

The features that enable these use cases have been available to platform-specific desktop and mobile developers for a while, and it’s been our challenge to expose them in a way that feels like a natural part of the web platform.

WebGPU was developed with the benefit of hindsight from over a decade of developers doing amazing work with WebGL. We were able to take the problems they encountered, the bottlenecks they hit, and the issues they raised and funneled all of that feedback into this new API.

We saw that WebGL’s global state model made creating robust, composable libraries and applications difficult and fragile. So WebGPU dramatically reduces the amount of state that developers need to keep track of while sending the GPU commands.

We heard that debugging WebGL applications was a pain, so WebGPU includes more flexible error handling mechanisms that don’t tank your performance. And we’ve gone out of our way to ensure that every message you get back from the API is easy to understand and actionable.

We also saw that frequently the overhead of making too many JavaScript calls was a bottleneck for complex WebGL applications. As a result, the WebGPU API is less chatty, so you can accomplish more with fewer function calls. We focus on performing heavyweight validation up front, keeping the critical draw loop as lean as possible. And we offer new APIs like Render Bundles, which allow you to record large numbers of drawing commands in advance and replay them with a single call.

To demonstrate what a dramatic difference a feature like render bundles can make, here’s another demo from Babylon.js. Their WebGL 2 renderer can execute all the JavaScript calls to render this art gallery scene about 500 times a second. Which is pretty good!

Their WebGPU renderer, however, enables a feature they call Snapshot Rendering. Built on top of WebGPUs render bundles, this feature allows the same scene to be submitted more than 10x faster. This significantly reduced overhead allows WebGPU to render more complex scenes, while also allowing applications to do more with JavaScript in parallel.

Modern graphics APIs have a reputation for complexity, trading simplicity for extreme optimization opportunities. WebGPU, on the other hand, is focused on cross-platform compatibility, handling traditionally difficult topics like resource synchronization automatically in most cases.

This has the happy side effect that WebGPU is easy to learn and use. It relies on existing features of the web platform for things like image and video loading, and leans into well-known JavaScript patterns like Promises for asynchronous operations. This helps keep the amount of boilerplate code needed to a minimum. You can get your first triangle on-screen in under 50 lines of code.

<canvas id="canvas" width="512" height="512"></canvas>
<script type="module">
const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();

const context = canvas.getContext("webgpu");
const format = navigator.gpu.getPreferredCanvasFormat();
context.configure({ device, format });

const code = `
@vertex fn vertexMain(@builtin(vertex_index) i : u32) ->
@builtin(position) vec4f {
const pos = array(vec2f(0, 1), vec2f(-1, -1), vec2f(1, -1));
return vec4f(pos[i], 0, 1);
}
@fragment fn fragmentMain() -> @location(0) vec4f {
return vec4f(1, 0, 0, 1);
}
`
;
const shaderModule = device.createShaderModule({ code });
const pipeline = device.createRenderPipeline({
layout: "auto",
vertex: {
module: shaderModule,
entryPoint: "vertexMain",
},
fragment: {
module: shaderModule,
entryPoint: "fragmentMain",
targets: [{ format }],
},
});
const commandEncoder = device.createCommandEncoder();
const colorAttachments = [
{
view: context.getCurrentTexture().createView(),
loadOp: "clear",
storeOp: "store",
},
];
const passEncoder = commandEncoder.beginRenderPass({ colorAttachments });
passEncoder.setPipeline(pipeline);
passEncoder.draw(3);
passEncoder.end();
device.queue.submit([commandEncoder.finish()]);

</script>

# Conclusion

It's exciting to see all the new possibilities that WebGPU brings to the web platform and we're looking forward to seeing all the cool new use cases that you will find for WebGPU!

A vibrant ecosystem of libraries and frameworks has been built around WebGL, and that same ecosystem is eager to embrace WebGPU. Support for WebGPU is in-progress or already complete in many popular Javascript WebGL libraries, and in some cases taking advantage of the benefits of WebGPU might be as simple as changing a single flag!

WebGPU: Unlocking modern GPU access in the browser - Chrome Developers (3)

And this first release in Chrome 113 is just a start. While our initial release is for Windows, ChromeOS, and MacOS, we plan to bring WebGPU to the remaining platforms like Android and Linux in the near future.

And it’s not just the Chrome team that’s been working on launching WebGPU. Implementations are also in-progress in Firefox and WebKit as well.

Additionally, new features are already being designed at the W3C that can be exposed when available in hardware. For example: In Chrome we plan to enable support for 16 bit floating point numbers in shaders and the DP4 class of instructions soon for even more machine learning performance improvements.

WebGPU is an extensive API that unlocks amazing performance if you invest in it. Today we could only cover its benefits at a high level, but if you'd like to get a hands-on start with WebGPU, please check out our introductory Codelab, Your first WebGPU app, where you’ll build a GPU version of the classic Conway’s Game of Life. This codelab will walk you through the process step-by-step, so you can try it out even if it’s your first time doing GPU development.

The WebGPU samples are also a good place to get a feel for the API. They range from the traditional "hello triangle" to more complete rendering and compute pipelines, demonstrating a variety of techniques. Finally, check out our other resources.

WebGPU: Unlocking modern GPU access in the browser - Chrome Developers (2024)

FAQs

Does WebGPU work on Chrome? ›

After years of development, the Chrome team ships WebGPU which allows high-performance 3D graphics and data-parallel computation on the web. The Chrome team is thrilled to announce that WebGPU is now available by default in Chrome 113, which is currently in the Beta channel.

How much faster is WebGPU? ›

Built on top of WebGPUs render bundles, this feature allows the same scene to be submitted more than 10x faster. This significantly reduced overhead allows WebGPU to render more complex scenes, while also allowing applications to do more with JavaScript in parallel.

What is WebGPU Chrome? ›

WebGPU is the successor to WebGL, providing better compatibility with modern GPUs, support for general-purpose GPU computations, faster operations, and access to more advanced GPU features.

How do I enable WebGPU flag in Chrome? ›

You can enable it at chrome://flags/#enable-unsafe-webgpu . The API is constantly changing and currently unsafe. As GPU sandboxing isn't implemented yet for the WebGPU API, it is possible to read GPU data for other processes! Don't browse the web with it enabled.

Can I make Chrome use my GPU? ›

To force acceleration, enter chrome://flags in the search bar. Under Override software rendering list, set to Enabled, then select Relaunch. You can check whether hardware acceleration is turned on in Chrome by typing chrome://gpu into the address bar at the top of the browser.

Does Chrome use GPU rendering? ›

Chrome: GPU Usage

Obviously, Chrome uses the GPU not only for video decoding but also for 2D rendering. Especially during video playback, but also with a regular website such as Boxtrolls the GPU is still used extensively.

Which is the faster GPU in the world? ›

Nvidia RTX 4090 appears to be the fastest GPU ever tested | Digital Trends.

Should I learn WebGPU or WebGL? ›

"Whereas WebGL is mostly for drawing images but can be repurposed (with great effort) to do other kinds of computations, WebGPU has first-class support for performing general computations on the GPU," says the draft document explaining why WebGPU exists.

Does a GPU make Chrome faster? ›

Use Hardware Acceleration

However, the graphics card processor (GPU) is usually much faster. With this option you allow Chrome to use the GPU for completing certain tasks to make it faster. For maximum performance make sure the option is turned on.

Is WebGPU faster? ›

WebGPU does, which allows it to render graphics faster. “WebGPU is a new web graphics API that offers significant benefits such as greatly reduced JavaScript workload for the same graphics,” Google engineers François Beaufort and Corentin Wallez detailed in a blog post.

How do I stop Chrome from using my GPU? ›

Disable hardware acceleration in Chrome
  1. Open Chrome.
  2. Click the horizontal ellipsis menu button in the top-right corner and click on Settings.
  3. Click on System.
  4. Under the “System” section, turn off the “Use hardware acceleration when available” toggle switch.
  5. Click the Relaunch button.
Oct 25, 2022

How do I know if Chrome uses my GPU? ›

Open Google Chrome, type “chrome://gpu” in the address bar on the top, and then press Enter. After you execute the command, Chrome should display a list of various data about the software. For hardware acceleration, you should only pay attention to the Graphics Feature Status section.

How do I force Chrome to run desktop mode from flags? ›

Method 1: Enable Desktop Site on Mobile Browser

Launch the Chrome web browser on Android. You can use desktop mode for any website you want to view. Tap on the 3 vertical dots for the menu. The desktop site can be enabled by selecting the checkbox.

What is the Chrome flag that enable developer mode? ›

There is no flag to enable developer mode. But you can force developer mode to be enabled for new Chrome profiles by setting extensions. ui. developer_mode to true in the master preference file.

How do I enable unsafe WebGPU? ›

i just tried,its ok!
  1. download the latest version of Chrome Canary ,now its 106.
  2. chrome://flags/,enabled #temporarily unexpire M104 flags & temporarily unexpire M105 flags.
  3. search “webgpu”,and you will find the #enable-unsafe-webgpu.
Mar 20, 2022

What does Chrome GPU process do? ›

The Chrome GPU process is a hardware acceleration process that is used by Chrome to handle graphics and visual processing. This process is necessary for Chrome to display web pages correctly, but it can sometimes use a lot of memory, particularly on older computers or if you have a lot of tabs and windows open.

Should I turn off hardware acceleration Chrome? ›

As everyone's computer is slightly different, the issue could lie in the GPU or driver associated with it. If you suspect hardware acceleration is the culprit, the best thing to do is to disable it and see if that fixes the problem.

Should I enable hardware acceleration in Chrome? ›

Using hardware acceleration in Google Chrome allows you to consume media and browse through your daily routine much smoother. That's another thing: if it starts causing freezing and crashing issues and you may need to disable hardware acceleration.

Is it better to use software rendering instead of GPU rendering? ›

The advantage to GPU Rendering is two fold. GPU Rendering takes almost no processing power from your workstation, meaning you will have greater performance for other tasks while rendering. GPU Rendering is usually more tuned for faster rendering.

Should I use GPU rendering? ›

However, as a general guide, GPU rendering is best if you want a faster render time or a more realistic image. CPU rendering is better for larger scenes, more accurate results, and access to more features and plugins. To save money on hardware, GPU rendering is the way to go.

What is the weakest GPU ever? ›

GeForce GTX 480

Although Nvidia has been in business for over 20 years now, there's really only one GPU the company has ever put out that was truly terrible on a technological level, and it's the GTX 480.

What is the most powerful GPU ever made? ›

NVIDIA TITAN V has the power of 12 GB HBM2 memory and 640 Tensor Cores, delivering 110 TeraFLOPS of performance.
...
Groundbreaking Capability.
NVIDIA TITAN V
ArchitectureNVIDIA Volta
Frame Buffer12 GB HBM2
Boost Clock1455 MHz
Tensor Cores640
1 more row

Is it safe to enable WebGL on Chrome? ›

Yes, WebGL is indeed a potential security risk, though the magnitude of the risk is hard to assess and open to debate. There are some tricky issues here.

Is WebGL obsolete? ›

In version 2021.2, Unity marked support for the WebGL 1 Graphics API as deprecated. In Unity 2021.2, there are no changes in behavior and Unity still includes the WebGL 1 Graphics API if you enable the Auto Graphics API Player Setting.

What is the usage of WebGPU? ›

A WebGPU implementation translates the workloads issued by the user into API commands specific to the target platform. Native APIs specify the valid usage for the commands (for example, see vkCreateDescriptorSetLayout) and generally don't guarantee any outcome if the valid usage rules are not followed.

How do I force GPU acceleration in Chrome? ›

From the upper-right of your Chrome browser, click the three dots icon. Select Settings. Click Advanced and select System. Enable Use hardware acceleration when available.

Will more RAM make Chrome faster? ›

While RAM will help the Web browser run, it won't have a direct impact on Internet speed. Whether or not an upgrade in RAM will make the browser work better depends on how much memory is already in the system. If you already have more than enough memory to run the browser, an upgrade will have little to no effect.

How do I optimize Chrome for speed? ›

Speed up Google Chrome
  1. Step 1: Update Chrome. Chrome works best when you're on the latest version. ...
  2. Step 2: Close unused tabs. The more tabs you have open, the harder Chrome has to work. ...
  3. Step 3: Turn off or stop unwanted processes.
  4. Step 4: Configure your preload settings.

Why is WebGPU better than WebGL? ›

While WebGL was a thin wrapper over OpenGL, WebGPU is an abstraction that can drive Vulkan, Metal, or DirectX 12 — all popular ways to talk to a GPU, depending on your operating system. The post is long and covers topics like shaders, pipelines, and staging buffers.

Is WebGPU easier than WebGL? ›

No, WebGPU will be easier to use than WebGL, because it doesn't have the global ... | Hacker News. No, WebGPU will be easier to use than WebGL, because it doesn't have the global state. Global state is the worst thing about OpenGL and requires a lot of code to get it under control.

What is the difference between WebGPU and Wgpu? ›

Wgpu is a Rust implementation of the WebGPU API spec . WebGPU is a specification published by the GPU for the Web Community Group. It aims to allow web code access to GPU functions in a safe and reliable manner.

What does turning off hardware acceleration do? ›

Without hardware acceleration, most of these pages will stutter and freeze. Once you turn hardware acceleration on, you can enjoy digital fireworks, play around with a blob, or try solving a 3D Rubik's cube. Letting your CPU process and perform all tasks by itself greatly slows down your computer.

How do I stop my browser from using my GPU? ›

To disable hardware acceleration, follow these steps:
  1. Select Start, and then select Internet Explorer.
  2. Select the Tools icon in the upper-right corner, and then select Internet Options.
  3. Select the Advanced tab, and then select the Use software rendering instead of GPU rendering check box under Accelerated graphics.
Jan 24, 2022

How can I tell if someone is using my GPU? ›

Right click on the desktop and select [NVIDIA Control Panel]. Select [View] or [Desktop] (the option varies by driver version) in the tool bar then check [Display GPU Activity Icon in Notification Area]. In Windows taskbar, mouse over the "GPU Activity" icon to check the list.

How do I know if my computer is detecting my GPU? ›

In your PC's Start menu, type "Device Manager," and press Enter to launch the Control Panel. Click the drop-down arrow next to Display adapters, and it should list your GPU right there.

Does Chrome support Web Assembly? ›

WebAssembly on Chrome is fully supported on 57-114, partially supported on None of the versions, and not supported on 4-56 Chrome versions. WebAssembly on Safari is fully supported on 11-16.4, partially supported on None of the versions, and not supported on 3.2-10.1 Safari versions.

Does WebGL work with Chrome? ›

Google Chrome is a very customizable browser, allowing you to to change many of your settings to your liking. One of the options that you can choose to enable is WebGL, or Web Graphics Library. WebGL is a JavaScript API that allows you to render 3D and 2D computer within your browser.

Does Chrome still support WebGL? ›

WebGL 1.0 is supported in the stable releases of most major browsers on both desktop and mobile platforms. Chrome, Firefox, Internet Explorer, Opera, and Safari are all known to have good WebGL support on both desktop and mobile browsers.

Why won t Chrome run WebGL? ›

Go to chrome://settings in your address bar, or click the three dots in the upper-right corner of the browser window and select Settings. Scroll to the bottom of the page and click Advanced. In the System section, toggle Use hardware acceleration when available to the ON position (the button should be blue).

Is Chrome blocking JavaScript? ›

On Google Chrome, JavaScript is enabled by default, but you can verify if it works through the Settings menu. To reveal the Settings menu, simply click on three tiny black dots at the top-right corner of your Chrome window. Next, click on the Settings option to access a search box labeled Search settings.

What web engine does Chrome use? ›

Google originally used WebKit for its Chrome browser but eventually forked it to create the Blink engine. All Chromium-based browsers use Blink, as do applications built with CEF, Electron, or any other framework that embeds Chromium.

What operating system runs Chrome? ›

ChromeOS is built on top of the Linux kernel. Originally based on Ubuntu, its base was changed to Gentoo Linux in February 2010.

Does WebGL require gpu? ›

Your computer hardware needs to have a minimum of 2 GB system memory and a video graphics card that supports WebGL. It is recommended that you have at least 4 GB of system memory. Your hardware should have a nonmobile graphics card with at least 512 MB of video memory.

Is WebGL still relevant? ›

Created by KhronosGroup, the WebGL technology is a direct descendant of OpenGL ES, used for 3D visualizations in games and VR. This innovative technology is currently utilized in 3D web design, interactive games, physics simulations, data visualization, and artwork.

What gpu supports WebGL? ›

WebGL is enabled on NVIDIA GPUs with proprietary NVIDIA drivers newer than 295. WebGL is always disabled on NVIDIA Quadro FX 1500.

Is it safe to enable WebGL? ›

The WebGL specification defines security measures for every possible kind of out-of-range indexing operation in the OpenGL ES API, and the conformance suite guarantees secure operation. The security measures preventing out-of-range memory accesses may, in some cases, reduce overall performance.

Is WebGL just OpenGL? ›

WebGL enables web content to use an API based on OpenGL ES 2.0 to perform 2D and 3D rendering in an HTML canvas in browsers that support it without the use of plug-ins. WebGL programs consist of control code written in JavaScript and shader code (GLSL) that is executed on a computer's Graphics Processing Unit (GPU).

Does Windows support WebGL? ›

Support for WebGL is present in later versions of Firefox, Google Chrome, Safari , and Microsoft Edge; however, the user's device must also have hardware that supports these features.

How do I enable hardware acceleration in Chrome? ›

From the upper-right of your Chrome browser, click the three dots icon. Select Settings. Click Advanced and select System. Enable Use hardware acceleration when available.

Why disable WebGL? ›

WebGL can be a threat to your device security and online anonymity. How to be protected? You can disable WebGL manually in the browser Settings, or with a special plugins (e.g., "Disable WebGL" for Chrome).

Top Articles
Latest Posts
Article information

Author: Rev. Porsche Oberbrunner

Last Updated:

Views: 6670

Rating: 4.2 / 5 (53 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Rev. Porsche Oberbrunner

Birthday: 1994-06-25

Address: Suite 153 582 Lubowitz Walks, Port Alfredoborough, IN 72879-2838

Phone: +128413562823324

Job: IT Strategist

Hobby: Video gaming, Basketball, Web surfing, Book restoration, Jogging, Shooting, Fishing

Introduction: My name is Rev. Porsche Oberbrunner, I am a zany, graceful, talented, witty, determined, shiny, enchanting person who loves writing and wants to share my knowledge and understanding with you.