Unlock the Potential of AI and Immersive Web Applications with WebGPU

author-image

By

WebGPU is a new API that exposes modern GPU rendering and compute capabilities to the Web. Based on graphics APIs including Direct3D* 12, Vulkan*, and Metal*, WebGPU delivers a significant performance boost compared to its predecessor, WebGL*. It brings web computations and graphics into a new era, enabling AI-generated content workloads, high-profile games, and immersive experiences on the Web. It’s powering top web AI frameworks, including Tensorflow.js*, ONNX Runtime Web*, and TVM*, and popular web graphics libraries, including Three.js* and Babylon.js*. Leading game engines, including Unity*, Cocos*, and PlayCanvas*, are bringing in a WebGPU port. Key applications, including Google Meet*, Google Earth*, and Sketchfab*, are moving towards using WebGPU.

Why is this a big deal?

WebGPU allows browsers to render graphics and run machine learning models faster.

Major companies, including Google, Microsoft, Mozilla Foundation, Apple, and Intel, have contributed to WebGPU as members of the W3C’s GPU for the Web Working Group. Following the initial design in 2017 and six years of development (90 contributors, 2000 commits, and 3000 issues), the first implementation is available in Chrome* 113, with support coming soon in Firefox* and Safari*. WebGPU has the most complex specification on the Web, with 100+ APIs and a new shading language.
This initial release of WebGPU will provide the foundation for future updates and enhancements.

WebGPU What is it?

WebGPU unlocks new GPU workloads for rendering and compute. Features such as compute allow new classes of algorithms to be ported to the GPU, enabling high-performance data-parallel computations for AI and making possible more dynamic detail to scenes and simulation of physical phenomena. It provides a more flexible GPU programming model than WebGL and access to advanced GPU features not available there. Designed from the ground up to efficiently map to native GPU APIs, WebGPU offers significant advantages over previous web graphics APIs, including a reduced JavaScript workload for the same graphics and a brand-new shading language, WebGPU Shading Language (WGSL). Workloads that previously could only be done in JavaScript can now move to the GPU.

With the evolution of GPUs in recent years, an increasing number of tasks run much faster on GPU than on CPU. For example, many machine learning applications are switching to GPU as hardware features specific to machine learning are added to GPU architecture.

Where WebGPU shines

Key usages for WebGPU include AI and immersive applications.

AI

WebGPU accelerates machine learning on the GPU, where creative developers have repurposed WebGL’s rendering API to perform machine learning computations. WebGL requires drawing pixels of triangles to initiate computations, then packing and unpacking tensor data in texture form rather than through general-purpose memory accesses.

Support for massively parallel computations in WebGPU enables compute shaders to offer a flexible programming model to perform compute operations. Compute shaders allow sharing of data and computation results within groups of shader operations for better efficiency, leading to significant gains over previous attempts to use WebGL for machine learning.

In performance testing on a variety of web platform hardware, the initial port from WebGL to WebGPU of a TensorFlow.js stable diffusion model showed a 3x performance gain. See the Chrome Developers blog WebGPU: Unlocking modern GPU access in the browser for more information.

GPU is a very powerful accelerator for AI. WebGPU unleashes the GPU compute capability to the Web for the first time, thus making the Web AI ready. WebGPU will make AI accessible to everyone.

Immersive applications

WebGPU enables web applications to create immersive and interactive virtual worlds and experiences on the Web, making high-end 3D experiences more accessible, rich, and comprehensive. It supports large-scale scenes and environments, complex animations and interactions, realistic lighting and materials, spatial audio, haptics, and more, supporting complex visual effects that were not practical before. For example, view a demo of the ocean surface being simulated entirely on the GPU, created in the popular Babylon.js.

WebGPU contributes significantly to the metaverse trend by enabling immersive browser-based experiences, making them more accessible without downloading an app or buying expensive gaming hardware. It allows easy access to and engagement with these experiences on mobile devices and other devices with web browsers.

As the number of mobile devices and AR headsets continues to rise, 3D technology is becoming increasingly relevant. The high accessibility and easy maintainability of web technology make it an ideal platform for delivering immersive experiences, enabling developers to create web applications that are more engaging, social, and fun.

Ready for developers

Developers will find it easy to get started with WebGPU by using development frameworks that already support the technology. These include smaller and larger frameworks with different features and concepts, including machine learning libraries like Tensorflow.js.

Ecosystem Adoption

Many early adopters are experimenting with or have integrated WebGPU into their solutions:
 

  • AI frameworks: TensorFlow.js, ONNX Runtime, TVM, and IREE*
  • Rendering frameworks: Three.js, Babylon.js, and Orillusion*
  • Game engines: Unity, Cocos, PlayCanvas, and Construct 3*
  • Others: Node.js*, Deno*, Google Meet, Google Earth, Adobe Photoshop* Web, and Sketchfab

Here’s a diagram showing the structure of a web application using WebGPU:

WebGPU is an extensive API that unlocks amazing performance if you invest in it. We encourage you to start your hands-on exploration of WebGPU and see the benefits for yourself.

Intel’s role in WebGPU development

Intel joined the WC3 GPU for the Web Community Group in 2018 and was a founding member of the W3C GPU for the Web Working Group, where it has been a technology leader, contributing over 2,000 patches in the WebGPU specification, Conformance Test Suite, and Chrome browser implementation.

In addition to core WebGPU development, Intel has been working on Web AI frameworks based on WebGPU for four years. Together with the Google TensorFlow.js team, Intel made key contributions to the TensorFlow.js WebGPU backend, which was officially released in May 2023. In the video What’s new with WebML in 2023, Jason Mayes, Web AI Lead at Google, stated, ”None of the performance would be possible without the amazing collaboration between the TensorFlow.js team and Intel’s web graphics team, who contributed some tremendous optimizations to our WebGPU backend.”

Now, we’re extending our Web AI efforts to ONNX Runtime Web and TVM.

Intel GPU has close to 70% of market share on the client side. To better serve hundreds of millions of users on Intel platforms, we have been integrating up-to-date WebGL and the WebGPU test harness with graphics driver CI for more than five years, allowing overall conformance on existing and pre-production hardware.

Conclusion

WebGPU unlocks many GPU programming possibilities in the browser. It reflects how modern GPU hardware works and serves as a foundation for more advanced GPU capabilities in the future. The evolution of web technology is driving innovation and creating new opportunities for businesses and individuals alike. With WebGPU, we can expect to see even more AI, immersive, and accessible browser-based applications.

The future of the Web is exciting! Let’s get started!

Resources

We recommend the following resources to learn more:
 

If there’s a feature you’d like to see in WebGPU, make your request on the W3C GPU for the Web Working Group GitHub.

About the Author

Yang Gu is the Software Engineering Manager of the Intel Web Graphics and AI Team. He joined Intel in 2004 and has led the Web Graphics and Web AI efforts at Intel for the past ten years, including WebGL 1.0, WebGL 2.0, WebGPU, TensorFlow.js, ONNX Runtime, etc. He’s currently serving as the Intel Representative of the W3C WebGPU Working Group. Yang holds a Bachelor’s degree from Chu Kochen Honors College and a Master of Computer Science from Zhejiang University in China.