Navigator: gpu プロパティ

Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。

Navigator.gpu は読み取り専用のプロパティで、 WebGPU API のエントリーポイントである現在の閲覧コンテキストの GPU オブジェクトを返します。

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
# navigator-gpu

ブラウザーの互換性

BCD tables only load in the browser

関連情報