Firefox Tomorrow

web api interface

GPUDevice

View on MDN ↗

Secure contextAvailable in workers

The GPUDevice interface of the WebGPU API represents a logical GPU device. This is the main interface through which the majority of WebGPU functionality is accessed.

A GPUDevice object is requested using the requestDevice() method.

Instance properties

Inherits properties from its parent, EventTarget.

  • adapterInfo Read only

    • : A GPUAdapterInfo object containing identifying information about the device’s originating adapter.
  • features Read only

  • label

    • : A string providing a label that can be used to identify the object, for example in GPUError messages or console warnings.
  • limits Read only

  • lost Read only

    • : Contains a Promise that remains pending throughout the device’s lifetime and resolves with a GPUDeviceLostInfo object when the device is lost.
  • queue Read only

    • : Returns the primary GPUQueue for the device.

Instance methods

Inherits methods from its parent, EventTarget.

Events

Examples

async function init() {
  if (!navigator.gpu) {
    throw Error("WebGPU not supported.");
  }

  const adapter = await navigator.gpu.requestAdapter();
  if (!adapter) {
    throw Error("Couldn't request WebGPU adapter.");
  }

  const device = await adapter.requestDevice();

  const shaderModule = device.createShaderModule({
    code: shaders,
  });

  // …
}

See the individual member pages listed above and the following demo sites for a lot more examples of GPUDevice usage:

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also