WGSLLanguageFeatures

Limited availability

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

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

安全上下文: 此项功能仅在一些支持的浏览器安全上下文(HTTPS)中可用。

WebGPU APIWGSLLanguageFeatures 接口是类集合对象,用于报告 WebGPU 实现支持的 WGSL 语言扩展

WGSLLanguageFeatures 对象可通过 GPU.wgslLanguageFeatures 属性访问。

备注: 并非所有 WGSL 语言扩展在支持 WebGPU API 的所有浏览器中都可用。我们建议你对选择使用的任何扩展程序进行彻底测试。

可用特性

可用的 WGSL 语言扩展可能因实现和物理设备的不同而不同,也可能随着时间的推移而变化;因此,我们没有在此列出。有关完整列表,请参阅 WGSL 规范中的 WGSL 语言扩展

实例属性

以下属性适用于所有只读类集合对象:

size 实验性

返回集合中的值的数量。

实例方法

以下方法适用于所有只读类集合对象:

has() 实验性

返回用于判断集合中是否存在具有给定值的元素的布尔值。

values() 实验性

返回按插入顺序为集合中的每个元素生成的新的迭代器对象。

keys() 实验性

values() 的别名。

entries() 实验性

返回该对象按插入顺序包含集合中每个元素的 [value, value] 的数组的新的迭代器对象。

forEach() 实验性

按插入顺序对集合中的每个值调用一次提供的回调函数。

示例

js
if (!navigator.gpu) {
  throw Error("不支持 WebGPU。");
}

const wgslFeatures = navigator.gpu.wgslLanguageFeatures;

// 返回集合的大小
console.log(wgslFeatures.size);

// 使用 values() 遍历所有集合值
const valueIterator = wgslFeatures.values();
for (const value of valueIterator) {
  console.log(value);
}

// ...

规范

Specification
WebGPU
# gpuwgsllanguagefeatures

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
WGSLLanguageFeatures
Experimental
[Symbol.iterator]
Experimental
entries
Experimental
packed_4x8_integer_dot_product extension
Experimental
readonly_and_readwrite_storage_textures extension
Experimental
unrestricted_pointer_parameters extension
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
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.

参见