GPUAdapter
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
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.
Giao diện GPUAdapter của WebGPU API đại diện cho một bộ điều hợp GPU. Từ đây bạn có thể yêu cầu GPUDevice, thông tin bộ điều hợp, tính năng và giới hạn.
Một đối tượng GPUAdapter được yêu cầu bằng phương thức GPU.requestAdapter().
Thuộc tính phiên bản
featuresRead only-
Một đối tượng
GPUSupportedFeaturesmô tả các chức năng bổ sung được bộ điều hợp hỗ trợ. infoRead only-
Một đối tượng
GPUAdapterInfochứa thông tin nhận diện về bộ điều hợp. limitsRead only-
Một đối tượng
GPUSupportedLimitsmô tả các giới hạn được bộ điều hợp hỗ trợ.
Thuộc tính đã lỗi thời
isFallbackAdapterRead only Deprecated Non-standard-
Giá trị boolean. Trả về
truenếu bộ điều hợp là fallback adapter, vàfalsenếu không. Thuộc tính này đã bị xóa khỏi nền tảng web. Hãy dùngGPUAdapterInfo.isFallbackAdapterthay thế.
Phương thức phiên bản
requestAdapterInfo()Deprecated Non-standard-
Trả về một
Promisephân giải thành một đối tượngGPUAdapterInfochứa thông tin nhận diện về bộ điều hợp. requestDevice()-
Trả về một
Promisephân giải thành một đối tượngGPUDevice, là giao diện chính để giao tiếp với GPU.
Ví dụ
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();
// …
}
Thông số kỹ thuật
| Specification |
|---|
| WebGPU> # gpuadapter> |