W3cubDocs

/Web APIs

GPUSupportedFeatures

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The GPUSupportedFeatures interface of the WebGPU API is a Set-like object that describes additional functionality supported by a GPUAdapter.

The GPUSupportedFeatures object for the current adapter is accessed via the GPUAdapter.features property.

You should note that not all features will be available to WebGPU in all browsers that support it, even if the features are supported by the underlying hardware. This could be due to constraints in the underlying system, browser, or adapter. For example:

  • The underlying system might not be able to guarantee exposure of a feature in a way that is compatible with a certain browser.
  • The browser vendor might not have found a secure way to implement support for that feature, or might just not have gotten round to it yet.

If you are hoping to take advantage of a specific additional feature in a WebGPU app, thorough testing is advised.

Available features

We have not listed the exact set of additional features available to be used in WebGPU, as it will vary between implementations and physical devices, and will change over time. For a list, refer to the Feature Index in the specification.

Instance properties

The following properties are available to all read-only Set-like objects (the links below are to the Set global object reference page).

size Experimental

Returns the number of values in the set.

Instance methods

The following methods are available to all read-only Set-like objects (the below links are to the Set global object reference page).

has() Experimental

Returns a boolean asserting whether an element is present with the given value in the set or not.

values() Experimental

Returns a new iterator object that yields the values for each element in the set in insertion order.

keys() Experimental

An alias for values().

entries() Experimental

Returns a new iterator object that contains [value, value] for each element in the set, in insertion order.

forEach() Experimental

Calls a provided callback function once for each value present in the set, in insertion order.

Examples

js

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 adapterFeatures = adapter.features;

  // Return the size of the set
  console.log(adapterFeatures.size);

  // Check whether a feature is supported by the adapter
  console.log(adapterFeatures.has("texture-compression-astc"));

  // Iterate through all the set values using values()
  const valueIterator = adapterFeatures.values();
  for (const value of valueIterator) {
    console.log(value);
  }

  // Iterate through all the set values using keys()
  const keyIterator = adapterFeatures.keys();
  for (const value of keyIterator) {
    console.log(value);
  }

  // Iterate through all the set values using entries()
  const entryIterator = adapterFeatures.entries();
  for (const entry of entryIterator) {
    console.log(entry[0]);
  }

  // Iterate through all the set values using forEach()
  adapterFeatures.forEach((value) => {
    console.log(value);
  });

  //...
}

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
@@iterator 113 113 No No 99 No No No No No No No
GPUSupportedFeatures
113Currently supported on ChromeOS, macOS, and Windows only.
113Currently supported on ChromeOS, macOS, and Windows only.
previewCurrently supported on Linux and Windows only.
No
99Currently supported on ChromeOS, macOS, and Windows only.
No No No No No No No
entries 113 113 No No 99 No No No No No No No
forEach 113 113 No No 99 No No No No No No No
has 113 113 No No 99 No No No No No No No
keys 113 113 No No 99 No No No No No No No
size 113 113 No No 99 No No No No No No No
values 113 113 No No 99 No No No No No No No

See also

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