e01.org

GPUSupportedFeatures

WebGPU API

WebGPU API

The **`GPUSupportedFeatures`** interface of the WebGPU API is a [`Set`-like object](/docs/Web/JavaScript/Reference/Global_Objects/Set#set-like_browser_apis) that describes additional functionality supported by a GPUAdapter.

The `GPUSupportedFeatures` object for the current adapter is accessed via the GPUAdapter.features property — use this to test what features your current setup supports. To create a GPUDevice with a specific feature enabled, you need to specify it in the [`requiredFeatures`](/docs/Web/API/GPUAdapter/requestDevice#requiredfeatures) array of the GPUAdapter.requestDevice() descriptor.

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

The following additional features are defined in WebGPU. Bear in mind that the exact set of features available will vary across implementations and physical devices and will change over time.

| Feature name | Description |
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bgra8unorm-storage` | When enabled, allows `STORAGE_BINDING` [`usage`](/docs/Web/API/GPUDevice/createTexture#usage) of `bgra8unorm`-[`format`](/docs/Web/API/GPUDevice/createTexture#format) GPUTextures. |
| `clip-distances` | When enabled, allows the use of [`clip_distances`](https://gpuweb.github.io/gpuweb/wgsl/#built-in-values-clip_distances) in WGSL. |
| `core-features-and-limits` | When enabled, signifies that the GPUAdapter / GPUDevice is able to use all "core" WebGPU features and limits, which allows applications to support devices that use modern platform graphics APIs. By default, all adapters have the `core-features-and-limits` feature enabled, and therefore support core WebGPU. To create a "compatibility mode" adapter, specify a [`featureLevel`](/docs/Web/API/GPU/requestAdapter#featurelevel) value of `compatibility` in your GPU.requestAdapter() call. Compatibility mode provides support for older graphics APIs (such as Direct3D 11 and OpenGL ES 3.1) at the expense of performance and feature set.<br><br>Note that a compatibility mode adapter will only be created on devices that don't support core WebGPU. On devices that do support core WebGPU, the adapter will support core WebGPU (`core-features-and-limits` will be enabled), and you can go ahead and use modern features (see [Using compatibility mode only if necessary](/docs/Web/API/GPU/requestAdapter#using_compatibility_mode_only_if_necessary) for an example of how this works). |
| `depth-clip-control` | When enabled, allows [depth-clipping](https://gpuweb.github.io/gpuweb/#depth-clipping) to be disabled. If `depth-clip-control` is enabled, the [`unclippedDepth`](/docs/Web/API/GPUDevice/createRenderPipeline#unclippeddepth) property is available on the `primitive` object included as part of the createRenderPipeline() or createRenderPipelineAsync() descriptor when creating a GPURenderPipeline. `primitive` describes how a pipeline constructs and rasterizes primitives from its vertex inputs. Set `unclipped-depth` to `true` to disable depth-clipping. |
| `depth32float-stencil8` | When enabled, allows creation of textures with the format `depth32float-stencil8`. If `depth32float-stencil8` is enabled, the `depth32float-stencil8` value can be used for the [`format`](/docs/Web/API/GPUDevice/createTexture#format) property of the createTexture() descriptor when creating a GPUTexture. |
| `dual-source-blending` | When enabled, allows the use of [`dual_source_blending`](https://gpuweb.github.io/gpuweb/wgsl/#extension-dual_source_blending) in WGSL, which uses both pixel shader outputs (`@blend_src(0)` and `@blend_src(1)`) as inputs to a blending operation with the single color attachment at `@location(0)`. Over in WebGPU, `dual-source-blending` enables the following blend factor operations (specified in the [`dstFactor`](/docs/Web/API/GPUDevice/createRenderPipeline#dstfactor) and [`srcFactor`](/docs/Web/API/GPUDevice/createRenderPipeline#srcfactor) properties of createRenderPipeline() and createRenderPipelineAsync() descriptors): `src1`, `one-minus-src1`, `src1-alpha`, and `one-minus-src1-alpha`. |
| `float32-blendable` | When enabled, allows [blending](/docs/Web/API/GPUDevice/createRenderPipeline#blend) of GPUTextures that use the `r32float`, `rg32float`, or `rgba32float` [`format`](/docs/Web/API/GPUDevice/createTexture#format). |
| `float32-filterable` | When enabled, allows [filtering](/docs/Web/API/GPUDevice/createSampler#magfilter) of GPUTextures that use the `r32float`, `rg32float`, or `rgba32float` [`format`](/docs/Web/API/GPUDevice/createTexture#format). |
| `indirect-first-instance` | When enabled, allows the use of non-zero `firstInstance` values in the `indirectBuffer` property of the `drawIndirect()` and `drawIndexedIndirect()` methods available on GPURenderPassEncoder and GPURenderBundleEncoder instances. |
| `primitive-index` | When enabled, allows the use of the [`primitive_index`](https://gpuweb.github.io/gpuweb/wgsl/#built-in-values-primitive_index) built-in variable in WGSL. This built-in input value provides a per-primitive index to fragment shaders on supported hardware, similar to the existing [`vertex_index`](https://gpuweb.github.io/gpuweb/wgsl/#vertex-index-builtin-value) and [`instance_index`](https://gpuweb.github.io/gpuweb/wgsl/#instance-index-builtin-value) built-ins. The `primitive_index` built-in variable is useful for advanced graphical techniques, such as virtualized geometry. |
| `rg11b10ufloat-renderable` | When enabled, allows `RENDER_ATTACHMENT` [`usage`](/docs/Web/API/GPUDevice/createTexture#usage) of `rg11b10ufloat`-[`format`](/docs/Web/API/GPUDevice/createTexture#format) GPUTextures, as well as their blending and multisampling. |
| `shader-f16` | When enabled, allows the use of the half-precision floating-point type [`f16`](https://gpuweb.github.io/gpuweb/wgsl/#extension-f16) in WGSL. |
| `subgroups` | When enabled, allows the use of [subgroups](https://gpuweb.github.io/gpuweb/wgsl/#extension-subgroups) in WGSL. Subgroups enable SIMD-level parallelism, allowing threads in a workgroup to communicate and execute collective math operations such as calculating a sum of numbers, and offering an efficient method for cross-thread data sharing. Note that the subgroupMinSize and subgroupMaxSize properties can be useful to check if, for example, you have a hardcoded algorithm that requires a subgroup of a certain size. You can use f16 values with subgroups when you request a GPUDevice with both the `shader-f16` and `subgroups` features. When `subgroups` is enabled, it also allows the [`subgroup_id`](/docs/Web/API/WGSLLanguageFeatures#subgroup_id) WGSL language feature to be used. |
| `texture-component-swizzle` | When enabled, allows the [`swizzle`](/docs/Web/API/GPUTexture/createView#swizzle) property to be set when calling `GPUTexture.createView()`. This feature allows a texture's red, green, blue, and alpha channel values to be rearranged or replaced in a texture view when accessed by a shader. |
| `texture-compression-bc` | When enabled, allows creation of two-dimensional BC compressed textures. If `texture-compression-bc` is enabled, the following values can be used for the [`format`](/docs/Web/API/GPUDevice/createTexture#format) property of the createTexture() descriptor when creating a GPUTexture: `bc1-rgba-unorm`, `bc1-rgba-unorm-srgb`, `bc2-rgba-unorm`, `bc2-rgba-unorm-srgb`, `bc3-rgba-unorm`, `bc3-rgba-unorm-srgb`, `bc4-r-unorm`, `bc4-r-snorm`, `bc5-rg-unorm`, `bc5-rg-snorm`, `bc6h-rgb-ufloat`, `bc6h-rgb-float`, `bc7-rgba-unorm`, and `bc7-rgba-unorm-srgb`. |
| `texture-compression-bc-sliced-3d` | When enabled, allows creation of three-dimensional BC compressed textures. If `texture-compression-bc-sliced-3d` is enabled, `texture-compression-bc` must also be enabled, as it enables the BC texture formats to be used (see `texture-compression-bc`, above) in the first two dimensions. `texture-compression-bc-sliced-3d` enables those same textures to be used in the third dimension. |
| `texture-compression-astc` | When enabled, allows creation of two-dimensional ASTC compressed textures. If `texture-compression-astc` is enabled, the following values can be used for the [`format`](/docs/Web/API/GPUDevice/createTexture#format) property of the createTexture() descriptor when creating a GPUTexture: `astc-4x4-unorm`, `astc-4x4-unorm-srgb`, `astc-5x4-unorm`, `astc-5x4-unorm-srgb`, `astc-5x5-unorm`, `astc-5x5-unorm-srgb`, `astc-6x5-unorm`, `astc-6x5-unorm-srgb`, `astc-6x6-unorm`, `astc-6x6-unorm-srgb`, `astc-8x5-unorm`, `astc-8x5-unorm-srgb`, `astc-8x6-unorm`, `astc-8x6-unorm-srgb`, `astc-8x8-unorm`, `astc-8x8-unorm-srgb`, `astc-10x5-unorm`, `astc-10x5-unorm-srgb`, `astc-10x6-unorm`, `astc-10x6-unorm-srgb`, `astc-10x8-unorm`, `astc-10x8-unorm-srgb`, `astc-10x10-unorm`, `astc-10x10-unorm-srgb`, `astc-12x10-unorm`, `astc-12x10-unorm-srgb`, and `astc-12x12-unorm``astc-12x12-unorm-srgb`. |
| `texture-compression-astc-sliced-3d` | When enabled, allows creation of three-dimensional ASTC compressed textures. If `texture-compression-astc-sliced-3d` is enabled, `texture-compression-astc` must also be enabled, as it enables the ASTC texture formats to be used (see `texture-compression-astc`, above) in the first two dimensions. `texture-compression-astc-sliced-3d` enables those same textures to be used in the third dimension. |
| `texture-compression-etc2` | When enabled, allows creation of two-dimensional ETC2 compressed textures. If `texture-compression-etc2` is enabled, the following values can be used for the [`format`](/docs/Web/API/GPUDevice/createTexture#format) property of the createTexture() descriptor when creating a GPUTexture: `etc2-rgb8unorm`, `etc2-rgb8unorm-srgb`, `etc2-rgb8a1unorm`, `etc2-rgb8a1unorm-srgb`, `etc2-rgba8unorm`, `etc2-rgba8unorm-srgb`, `eac-r11unorm`, `eac-r11snorm`, `eac-rg11unorm`, and `eac-rg11snorm`. |
| `texture-formats-tier1` | When enabled, automatically enables the `rg11b10ufloat-renderable` feature, and allows creation of GPUTextures (via GPUDevice.createTexture()) with the formats specified in [Tier 1](/docs/Web/API/GPUDevice/createTexture#tier_1). The Tier 1 set of texture formats is designed to allow developers to port existing content to the web without needing to rewrite it to use WebGPU's lower capabilities. |
| `texture-formats-tier2` | When enabled, automatically enables the `rg11b10ufloat-renderable` and `texture-formats-tier1` features, and allows creation of GPUTextures (via GPUDevice.createTexture()) with the formats specified in [Tier 2](/docs/Web/API/GPUDevice/createTexture#tier2). The Tier 2 set of texture formats supports storage texture formats that don't have support in "core" WebGPU, and are required for advanced usage. |
| `timestamp-query` | When enabled, allows timestamp queries to be run, which measure the time taken to run compute and render passes. If `timestamp-query` is enabled, the `timestamp` value can be set for the [`type`](/docs/Web/API/GPUDevice/createQuerySet#type) property of the createQuerySet() descriptor when creating a GPUQuerySet. In addition, the `timestampWrites` property can be set on the beginComputePass() and beginRenderPass() descriptor when creating a GPUComputePassEncoder and GPURenderPassEncoder, respectively. `GPUQuerySet` objects are referenced within the objects included in the `timestampWrites` property, to specify where timestamps should be written to. |

## Instance properties

The following properties are available to all read-only [`Set`-like objects](/docs/Web/JavaScript/Reference/Global_Objects/Set#set-like_browser_apis) (the links below are to the Set global object reference page).

- size
- : Returns the number of values in the set.

## Instance methods

The following methods are available to all read-only [`Set`-like objects](/docs/Web/JavaScript/Reference/Global_Objects/Set#set-like_browser_apis) (the below links are to the Set global object reference page).

- has()
- : Returns a boolean asserting whether an element is present with the given value in the set or not.
- values()
- : Returns a new iterator object that yields the **values** for each element in the set in insertion order.
- keys()
- : An alias for values().
- entries()
- : Returns a new iterator object that contains **an array of `[value, value]`** for each element in the set, in insertion order.
- forEach()
- : 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

## See also

- The [WebGPU API](/docs/Web/API/WebGPU_API)
- The specification [Feature Index](https://gpuweb.github.io/gpuweb/#feature-index)

source: MDN Web Docs mirror · page

Cite this

"GPUSupportedFeatures". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedFeatures

JSON record · API collection · citation policy