Limited availability
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 features
read-only property of the GPUAdapter
interface returns a GPUSupportedFeatures
object that describes additional functionality supported by the adapter.
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:
If you are hoping to take advantage of a specific additional feature in a WebGPU app, thorough testing is advised.
ValueA GPUSupportedFeatures
object instance. This is a setlike object.
In the following code we check whether a GPUAdapter
has the texture-compression-astc
feature available. If so, we push it into the array of requiredFeatures
, and request a device with that feature requirement using GPUAdapter.requestDevice()
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 device = await adapter.requestDevice({
requiredFeatures,
});
// â¦
}
Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4