GPUSupportedFeatures

Limited availability

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

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

WebGPU APIGPUSupportedFeatures インターフェイスは、GPUAdapter が対応している追加機能を表現する Set 風オブジェクトです。

現在のアダプター用の GPUSupportedFeatures オブジェクトは、GPUAdapter.features 経由で参照できます。

下層のハードウェアで対応していても、対応するすべてのブラウザーの WebGPU ですべての機能が利用できるわけではないことに注意するべきです。これは、たとえば以下の場合など、下層のシステム、ブラウザー、アダプターの制限によるものである可能性があります。

  • 下層のシステムが、あるブラウザーと互換性がある方式で機能を利用可能にする保証ができないかもしれません。
  • ブラウザーのベンダーがある機能への対応を実装するセキュアな方法をまだ見つけていないか、単にまだ実装に手が回っていないかもしれません。

WebGPU アプリケーションにおいて特定の追加機能の恩恵を受けたい場合は、徹底的にテストを行うことを推奨します。

利用可能な機能

実装や物理デバイスによって異なる可能性があり、時間の経過によっても変わる可能性があるので、ここでは WebGPU で使用可能な追加機能の完全な集合を列挙していませんリストは、仕様書内の Feature Index を参照してください。

インスタンスプロパティ

以下のプロパティは、すべての読み取り専用の Set 風オブジェクトで使用可能です。(以下のリンクはグローバルオブジェクト Set のリファレンスページです)

size Experimental

集合に含まれる値の数を返します。

インスタンスメソッド

以下のメソッドは、すべての読み取り専用の Set 風オブジェクトで使用可能です。(以下のリンクはグローバルオブジェクト Set のリファレンスページです)

has() Experimental

指定の値の要素が集合に含まれるか否かを表す論理値を返します。

values() Experimental

集合内の各要素の を挿入した順に出力する新しいイテレーターオブジェクトを返します。

keys() Experimental

values() の別名です。

entries() Experimental

集合内の各要素に対応する 配列 [value, value] が挿入した順に含まれる新しいイテレーターオブジェクトを返します。

forEach() Experimental

集合内の各要素について挿入した順に指定のコールバック関数を 1 度ずつ呼び出します。

js
async function init() {
  if (!navigator.gpu) {
    throw Error("WebGPU に対応していません。");
  }

  const adapter = await navigator.gpu.requestAdapter();
  if (!adapter) {
    throw Error("WebGPU のアダプターを要求できませんでした。");
  }

  const adapterFeatures = adapter.features;

  // 集合のサイズを返す
  console.log(adapterFeatures.size);

  // アダプターがある機能に対応しているかどうかをチェックする
  console.log(adapterFeatures.has("texture-compression-astc"));

  // values() を用いて集合のすべての値を走査する
  const valueIterator = adapterFeatures.values();
  for (const value of valueIterator) {
    console.log(value);
  }

  // keys() を用いて集合のすべての値を走査する
  const keyIterator = adapterFeatures.keys();
  for (const value of keyIterator) {
    console.log(value);
  }

  // entries() を用いて集合のすべての値を走査する
  const entryIterator = adapterFeatures.entries();
  for (const entry of entryIterator) {
    console.log(entry[0]);
  }

  // forEach() を用いて集合のすべての値を走査する
  adapterFeatures.forEach((value) => {
    console.log(value);
  });

  //...
}

仕様書

Specification
WebGPU
# gpu-supportedfeatures

ブラウザーの互換性

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
GPUSupportedFeatures
Experimental
[Symbol.iterator]
Experimental
entries
Experimental
bgra8unorm-storage feature
Experimental
clip-distances feature
Experimental
depth-clip-control feature
Experimental
depth32float-stencil8 feature
Experimental
dual-source-blending feature
Experimental
float32-blendable feature
Experimental
float32-filterable feature
Experimental
indirect-first-instance feature
Experimental
rg11b10ufloat-renderable feature
Experimental
shader-f16 feature
Experimental
texture-compression-astc feature
Experimental
texture-compression-bc feature
Experimental
texture-compression-etc2 feature
Experimental
timestamp-query feature
Experimental
forEach
Experimental
has
Experimental
keys
Experimental
size
Experimental
values
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.
See implementation notes.
User must explicitly enable this feature.
Has more compatibility info.

関連情報