Navigator: thuộc tính gpu

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.

Thuộc tính chỉ đọc Navigator.gpu trả về đối tượng GPU cho ngữ cảnh duyệt hiện tại, đây là điểm vào cho WebGPU API.

Giá trị

Đối tượng GPU.

Ví dụ

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();

  // …
}

Thông số kỹ thuật

Specification
WebGPU
# navigator-gpu

Khả năng tương thích của trình duyệt

Xem thêm