10LOC

#webgpu

Chrome APIsadvanced

A minimal WebGPU compute shader

// No @webgpu/types in this repo's tsconfig, so these casts stand in for the
// missing ambient types. Swap them for the real types in a project that has
// @webgpu/types installed.
export const doubleOnGpu = async (input: Float32Array): Promise<Float32Array> => {
  const gpu = (navigator as any).gpu;

WebGPU's compute pipeline runs a WGSL kernel across GPU threads in parallel from a buffer you own — general-purpose GPU compute, not just triangles.