GPUAdapter

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

WebGPU APIGPUAdapter 接口表示 GPU 适配器。这时,你可以请求一个 GPUDevice、适配器信息、特性和限制。

使用 GPU.requestAdapter() 方法去请求 GPUAdapter 对象。

实例属性

features 实验性 只读

一个 GPUSupportedFeatures 对象,其描述了适配器支持的额外的功能。

isFallbackAdapter 实验性 只读

一个布尔值。如果适配器是备用适配器,则返回 true ;如果不是,则返回 false

limits 实验性 只读

一个 GPUSupportedLimits 对象,其描述了适配器支持的限制。

实例方法

requestAdapterInfo() 实验性

返回 Promise,会兑现为一个 GPUAdapterInfo 对象,该对象包含适配器的识别信息。

requestDevice() 实验性

返回 Promise,会兑现为一个 GPUDevice 对象,该对象是与 GPU 通信的主要接口。

示例

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 device = await adapter.requestDevice();

  //...
}

规范

Specification
WebGPU
# gpu-adapter

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
GPUAdapter
Experimental
features
Experimental
info
Experimental
isFallbackAdapter
Experimental
limits
Experimental
requestAdapterInfo
DeprecatedNon-standard
requestDevice
Experimental
Lost GPUDevice returned on duplicate calls.
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
In development. Supported in a pre-release version.
In development. Supported in a pre-release version.
No support
No support
Experimental. Expect behavior to change in the future.
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.
See implementation notes.
User must explicitly enable this feature.
Has more compatibility info.

参见