W3cubDocs

/Web APIs

GPU

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Note: This feature is available in Web Workers.

The GPU interface of the WebGPU API is the starting point for using WebGPU. It can be used to return a GPUAdapter from which you can request devices, configure features and limits, and more.

The GPU object for the current context is accessed via the Navigator.gpu or WorkerNavigator.gpu properties.

Instance properties

wgslLanguageFeatures Read only

A WGSLLanguageFeatures object that reports the WGSL language extensions supported by the WebGPU implementation.

Instance methods

requestAdapter()

Returns a Promise that fulfills with a GPUAdapter object instance. From this you can request a GPUDevice, which is the primary interface for using WebGPU functionality.

getPreferredCanvasFormat()

Returns the optimal canvas texture format for displaying 8-bit depth, standard dynamic range content on the current system.

Examples

>

Requesting an adapter and a device

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();

  // …
}

Configuring a GPUCanvasContext with the optimal texture format

const canvas = document.querySelector("#gpuCanvas");
const context = canvas.getContext("webgpu");

context.configure({
  device,
  format: navigator.gpu.getPreferredCanvasFormat(),
  alphaMode: "premultiplied",
});

Specifications

Specification
WebGPU>
# gpu-interface>

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
GPU
113Currently supported on ChromeOS, macOS, and Windows only.
113Currently supported on ChromeOS, macOS, and Windows only.
141Currently supported on Windows only, in all contexts except for service workers.
99Currently supported on ChromeOS, macOS, and Windows only.
26 121 No 81 26 25.0 121 26
getPreferredCanvasFormat
113Currently supported on ChromeOS, macOS, and Windows only.
113Currently supported on ChromeOS, macOS, and Windows only.
141Currently supported on Windows only, in all contexts except for service workers.
99Currently supported on ChromeOS, macOS, and Windows only.
26 121 No 81 26 25.0 121 26
requestAdapter
113Currently supported on ChromeOS, macOS, and Windows only.
113Currently supported on ChromeOS, macOS, and Windows only.
141Currently supported on Windows only, in all contexts except for service workers.
99Currently supported on ChromeOS, macOS, and Windows only.
26 121 No 81 26 25.0 121 26
wgslLanguageFeatures
115Currently supported on ChromeOS, macOS, and Windows only.
115Currently supported on ChromeOS, macOS, and Windows only.
141Currently supported on Windows only, in all contexts except for service workers.
101Currently supported on ChromeOS, macOS, and Windows only.
26 121 No 81 26 25.0 121 26

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/GPU