GPUAdapter
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("WebGPU API")}}{{SecureContext_Header}}{{AvailableInWorkers}}
The **GPUAdapter** interface of the {{domxref("WebGPU API", "WebGPU API", "", "nocode")}} represents a GPU adapter. From this you can request a {{domxref("GPUDevice")}}, adapter info, features, and limits.
A GPUAdapter object is requested using the {{domxref("GPU.requestAdapter()")}} method.
{{InheritanceDiagram}}
Instance properties
- {{domxref("GPUAdapter.features", "features")}} {{ReadOnlyInline}}
- : A {{domxref("GPUSupportedFeatures")}} object that describes additional functionality supported by the adapter.
- {{domxref("GPUAdapter.info", "info")}} {{ReadOnlyInline}}
- : A {{domxref("GPUAdapterInfo")}} object containing identifying information about the adapter.
- {{domxref("GPUAdapter.limits", "limits")}} {{ReadOnlyInline}}
- : A {{domxref("GPUSupportedLimits")}} object that describes the limits supported by the adapter.
Deprecated properties
- {{domxref("GPUAdapter.isFallbackAdapter", "isFallbackAdapter")}} {{ReadOnlyInline}} {{deprecated_inline}} {{non-standard_inline}}
- : A boolean value. Returns
trueif the adapter is a fallback adapter, andfalseif not. This property has been removed from the web platform. Use {{domxref("GPUAdapterInfo.isFallbackAdapter")}} instead.
Instance methods
- {{domxref("GPUAdapter.requestAdapterInfo", "requestAdapterInfo()")}} {{deprecated_inline}} {{non-standard_inline}}
- : Returns a {{jsxref("Promise")}} that fulfills with a {{domxref("GPUAdapterInfo")}} object containing identifying information about the adapter.
- {{domxref("GPUAdapter.requestDevice", "requestDevice()")}}
- : Returns a {{jsxref("Promise")}} that fulfills with a {{domxref("GPUDevice")}} object, which is the primary interface for communicating with the GPU.
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 device = await adapter.requestDevice();
// …
}Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- The WebGPU API