Skip to content

Introduction

WebGPU is the next-generation Web graphics API that provides modern GPU access capabilities, supporting high-performance graphics rendering and general-purpose computing.

WebGPU is a modern Web standard that provides:

  • High-performance graphics rendering: Direct access to GPU hardware capabilities
  • Compute shader support: Execute parallel computing tasks on the GPU
  • Modern design: Based on modern graphics APIs like Vulkan, Metal, and D3D12
  • Cross-platform compatibility: Supports desktop and mobile devices
检测 WebGPU 支持中...

Currently, WebGPU is available in the following browsers:

  • Chrome 113+ (enabled by default)
  • Firefox Nightly (requires enabling experimental features)
  • Safari Technology Preview (experimental support)

Let’s create a simple WebGPU application:

// Check if the browser supports WebGPU
if (!navigator.gpu) {
throw new Error('WebGPU is not supported by the current browser');
}
// Request a GPU adapter
const adapter = await navigator.gpu.requestAdapter();
if (!adapter) {
throw new Error('Failed to get WebGPU adapter');
}
// Request a GPU device
const device = await adapter.requestDevice();
console.log('WebGPU device initialized successfully!');