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 requestDevice() method of the GPUAdapter interface returns a Promise that fulfills with a GPUDevice object, which is the primary interface for communicating with the GPU.
requestDevice() requestDevice(descriptor)
descriptor OptionalAn object containing the following properties:
defaultQueue OptionalAn object that provides information for the device's default GPUQueue (as returned by GPUDevice.queue). This object has a single property — label — which provides the default queue with a label value. If no value is provided, this defaults to an empty object, and the default queue's label will be an empty string.
label OptionalA string providing a label that can be used to identify the GPUDevice, for example in GPUError messages or console warnings.
requiredFeatures OptionalAn array of strings representing additional functionality that you want supported by the returned GPUDevice. The requestDevice() call will fail if the GPUAdapter cannot provide these features. See GPUSupportedFeatures for a full list of possible features. This defaults to an empty array if no value is provided.
requiredLimits OptionalAn object containing properties representing the limits that you want supported by the returned GPUDevice. The requestDevice() call will fail if the GPUAdapter cannot provide these limits. Each key with a non-undefined value must be the name of a member of GPUSupportedLimits.
Note: You can request unknown limits when requesting a GPU device without causing an error. Such limits will be undefined. This is useful because it makes WebGPU code less brittle — a codebase won't stop working because a limit no longer exists in the adapter.
Not all features and limits will be available to WebGPU in all browsers that support it, even if they are supported by the underlying hardware. See the features and limits pages for more information.
A Promise that fulfills with a GPUDevice object instance.
If you make a duplicate call, i.e., call requestDevice() on a GPUAdapter that requestDevice() was already called on, the promise fulfills with a device that is immediately lost. You can then get information on how the device was lost via GPUDevice.lost.
OperationError DOMException
The promise rejects with an OperationError if the limits included in the requiredLimits property are not supported by the GPUAdapter, either because they are not valid limits, or because their values are higher than the adapter's values for those limits.
TypeError DOMException
The promise rejects with a TypeError if the features included in the requiredFeatures property are not supported by the GPUAdapter.
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();
// …
}
In the following code we:
GPUAdapter has the texture-compression-astc feature available. If so, we push it into the array of requiredFeatures.GPUAdapter.limits value of maxBindGroups to see if it is equal to or greater than 6. Our theoretical example app ideally needs 6 bind groups, so if the returned value is >= 6, we add a maximum limit of 6 to the requiredLimits object.defaultQueue label.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 requiredFeatures = [];
if (adapter.features.has("texture-compression-astc")) {
requiredFeatures.push("texture-compression-astc");
}
const requiredLimits = {};
// App ideally needs 6 bind groups, so we'll try to request what the app needs
if (adapter.limits.maxBindGroups >= 6) {
requiredLimits.maxBindGroups = 6;
}
const device = await adapter.requestDevice({
defaultQueue: {
label: "my_queue",
},
requiredFeatures,
requiredLimits,
});
// …
}
| Specification |
|---|
| WebGPU> # dom-gpuadapter-requestdevice> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
requestDevice |
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 |
lost_device_on_duplicate |
116 | 116 | No | 102 | 26 | 121 | No | 81 | 26 | 25.0 | 121 | 26 |
undefined_limits |
133Currently supported on ChromeOS, macOS, and Windows only. |
133Currently supported on ChromeOS, macOS, and Windows only. |
No | 118Currently supported on ChromeOS, macOS, and Windows only. |
No | 133 | No | 88 | No | No | 133 | No |
© 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/GPUAdapter/requestDevice