Skip to main content


WebGPU Device Adapter

This module contains the WebGPU adapter for the "abstract" API (

Simply importing installs the adapter and enables WebGPU devices to be created using luma.createDevice(...):

import {luma} from '';
import ''; // Installs the WebGPUDevice adapter

const device = await luma.createDevice({type: 'webgpu', canvas: ...});

// Resources can now be created
const buffer = device.createBuffer(...);

To use a WebGPU Device with raw WebGPU calls, the application needs to access the GPUDevice. The raw WebGPU handle is available on the WebGPUDevice subclass:

// @ts-expect-error
const gl = device.handle;

With a bit more work, typescript users can retrieve the WebGLRenderingContext without ignoring type errors:

import {Device, cast} from '';
import {WebGPUDevice} from ''; // Installs the WebGPUDevice adapter

function f(device: Device) {
const webgpuDevice = device as WebGPUDevice;
const gpuDevice: GPUDevice = webgpuDevice.handle; // Get underlying WebGPU device