WebGPU โ How Browsers Access the Local GPU Directly
Successor to WebGL โ Vulkan/Metal/DX12-level low-level GPU API arrives in the browser
WebGPU is a browser-built-in API accessed via navigator.gpu. No installation needed โ JavaScript directly controls the local GPU.
How Is It Different from WebGL?
WebGL shipped in 2011. It wraps OpenGL ES 2.0 for browsers โ a 1990s-era design that couldn't leverage modern GPU features. No compute shaders, implicit state management causing driver overhead.
WebGPU arrived starting 2023. Based on post-2015 designs like Vulkan, Metal, and DirectX 12. More direct GPU access, compute shader support, and multi-threaded command preparation.
Browser โ OS Mapping
Calling navigator.gpu.requestAdapter() has the browser internally map to OS-native APIs.
Windows โ DirectX 12
macOS โ Metal
Linux โ Vulkan
Developers don't see this difference. Same JavaScript/WGSL code runs on all OSes.
What Is It Used For?
- Video editing โ per-frame effect compositing via GPU shaders (Tooscut, etc.)
- 3D games/rendering โ Three.js added a WebGPU backend
- AI inference โ running models in-browser (ONNX Runtime Web, etc.)
- Scientific simulation โ massive parallel computation (fluid, particle sims)
CPUs process sequentially with 8-16 cores. GPUs run identical operations across thousands of cores simultaneously. Applying the same function to every pixel is exactly this pattern โ making GPU acceleration highly effective.
Is WebGL Dead?
WebGL runs in nearly all browsers. WebGPU currently supports Chrome/Edge only. Safari and Firefox are incomplete. For 3D graphics alone, WebGL is still the safer compatibility bet. If you need compute shaders or modern GPU features, WebGPU is the only option.
How It Works
navigator.gpu.requestAdapter() โ Request GPU adapter (browser maps to OS-native API)
adapter.requestDevice() โ Acquire GPU device (connection)
device.createShaderModule({ code: WGSL }) โ Compile WGSL shader
device.createRenderPipeline() โ Vertex/fragment shader + blending config
commandEncoder โ renderPass โ draw() โ GPU executes in parallel across thousands of cores
Pros
- ✓ No installation โ GPU access with a single navigator.gpu call
- ✓ Compute shader support โ general-purpose GPU computation, not just graphics
- ✓ Cross-platform โ same WGSL code runs on Windows/macOS/Linux
- ✓ Near-native performance when combined with Rust/WASM
Cons
- ✗ Full support only on Chrome/Edge โ no Safari, Firefox unstable
- ✗ WebGPU 1.0 spec doesn't cover all modern GPU features
- ✗ Steeper learning curve vs WebGL โ pipeline/bind group low-level concepts required
- ✗ Wide GPU performance variance across devices โ integrated vs discrete