Skip to main content

Adapter

From-v9.1

An Adapter is a factory that creates Device instances for a specific backend (e.g. WebGPU or WebGL). Each GPU backend exports a singleton adapter instance that is used to create devices for that GPU backend.

Adapters can be used directly to create and attach devices, but they are usually imported and used via the luma API through methods like [luma.createDevice].

Note: an adapter may perform asynchronous loading of adapter code, debug libraries, etc before creating the Device.

Usage

Register the WebGL backend, then create a WebGL2 context, auto creating a canvas

import {luma} from '@luma.gl/core';
import {webgl2Adapter} from '@luma.gl/webgl';
luma.registerAdapters([webgl2Adapter]);
const webglDevice = await luma.createDevice({type: 'webgl', createCanvasContext: ...});

Members

type

type: string;

Methods

isSupported()

Checks if this adapter is supported in the current environment/browser.

adapter.isSupported(): boolean;

create()

Creates a device for this adapter's backend.

create(props: DeviceProps): Promise<Device>;

attach()

Attaches a device to a GPU device handle from this backend.

attach?(handle: unknown): Promise<Device>;