W3cubDocs

/Web APIs

WGSLLanguageFeatures

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

The WGSLLanguageFeatures interface of the WebGPU API is a setlike object that reports the WGSL language extensions supported by the WebGPU implementation.

The WGSLLanguageFeatures object is accessed via the GPU.wgslLanguageFeatures property.

Note: Not all WGSL language extensions are available to WebGPU in all browsers that support the API. We recommend you thoroughly test any extensions you choose to use.

Available features

The available WGSL language extensions can vary across implementations and physical devices and may also change over time; we have therefore not listed them here. For a complete list, refer to WGSL language extensions in the WGSL specification.

Instance properties

The following property is available to all read-only setlike objects:

size Experimental

Returns the number of values in the set.

Instance methods

The following methods are available to all read-only setlike objects:

has() Experimental

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

values() Experimental

Returns a new iterator object that yields 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 the provided callback function once for each value present in the set in insertion order.

Examples

js

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

const wgslFeatures = navigator.gpu.wgslLanguageFeatures;

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

// Iterate through all the set values using values()
const valueIterator = wgslFeatures.values();
for (const value of valueIterator) {
  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 115 115 No No 101 No No No No No No No
WGSLLanguageFeatures
115Currently supported on ChromeOS, macOS, and Windows only.
115Currently supported on ChromeOS, macOS, and Windows only.
No No
101Currently supported on ChromeOS, macOS, and Windows only.
No No No No No No No
entries 115 115 No No 101 No No No No No No No
forEach 115 115 No No 101 No No No No No No No
has 115 115 No No 101 No No No No No No No
keys 115 115 No No 101 No No No No No No No
size 115 115 No No 101 No No No No No No No
values 115 115 No No 101 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/WGSLLanguageFeatures