简体   繁体   English

如何通过JS代码检测浏览器是否支持SIMD?

[英]How do I detect whether a browser supports SIMD by JS code?

I found a way to detect but it's not work on my computer with the latest chrome enabling simd flag:我找到了一种检测方法,但它在我的计算机上无法使用最新的 chrome 启用 simd 标志:

var simd =  async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 253, 4, 26, 11]));
await simd();

Is there another way to detect?有没有其他检测方法?

There is an opensource library for wasm feature detection here:这里有一个用于 wasm 特征检测的开源库:

https://github.com/GoogleChromeLabs/wasm-feature-detect https://github.com/GoogleChromeLabs/wasm-feature-detect

The way it works is that it attempts to instantiate a wasm module with the given features, catching an error should it arise (which indicates that the feature is not supported).它的工作方式是尝试使用给定的特性实例化一个 wasm 模块,如果出现错误(这表明该特性不受支持),它会捕获一个错误。

Here's the SIMD module it attempts to create:这是它尝试创建的 SIMD 模块:

https://github.com/GoogleChromeLabs/wasm-feature-detect/blob/master/src/detectors/simd/module.wat https://github.com/GoogleChromeLabs/wasm-feature-detect/blob/master/src/detectors/simd/module.wat

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM