SIMD.load
SIMD.js已经从TC39中取消了积极的开发,并从第三阶段中删除了。它不再被网页浏览器所追求。暴露在 web 上的SIMD 操作在 WebAssembly 中正处于积极的发展之中, 其操作基于 SIMD. js 操作。
静态SIMD.%type%.load()方法创建一个新的SIMD数据类型,其中从一个类型数组中加载通道值。
语法
SIMD.Float64x2.load(tarray, index)
SIMD.Float64x2.load1(tarray, index)
SIMD.Float32x4.load(tarray, index)
SIMD.Float32x4.load1(tarray, index)
SIMD.Float32x4.load2(tarray, index)
SIMD.Float32x4.load3(tarray, index)
SIMD.Int32x4.load(tarray, index)
SIMD.Int32x4.load1(tarray, index)
SIMD.Int32x4.load2(tarray, index)
SIMD.Int32x4.load3(tarray, index)
SIMD.Uint32x4.load(tarray, index)
SIMD.Uint32x4.load1(tarray, index)
SIMD.Uint32x4.load2(tarray, index)
SIMD.Uint32x4.load3(tarray, index)
SIMD.Int8x16.load(tarray, index)
SIMD.Int16x8.load(tarray, index)
SIMD.Uint8x16.load(tarray, index)
SIMD.Uint16x8.load(tarray, index)参数
tarray类型数组的一个实例。这可以是以下之一:
Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,或Float64Array。index一个索引号从哪里开始在类型化数组中加载。返回值是一个新的SIMD数据类型。
- 如果
index超出范围,例如SIMD.Int32x4.load(tarray, -1)或大于tarraya 的大小,RangeError则抛出a。
- 如果
tarray不是其中一种类型的数组类型,SIMD.Int32x4.load(tarray.buffer, 0)(数组缓冲区无效),TypeError则抛出a。
描述
SIMD load和store方法与类型数组混合。使用load,您可以将类型化数组传递到SIMD类型,并且store,可以将SIMD数据存储到类型化数组中。
您可以使用加载所有通道值load(),或仅与方法加载一个,两个或三个通道值load1(),load2()或load3()。
例子
以下示例使用Int32Array加载到SIMD.Int32x4数据类型。
加载所有值
var a = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load(a, 0);
// Int32x4[1,2,3,4]
var b = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load(a, 2);
// Int32x4[3,4,5,6]加载一个值
var a = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load1(a, 0);
// Int32x4[1,0,0,0]
var b = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load1(a, 2);
// Int32x4[3,0,0,0]加载两个值
var a = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load2(a, 0);
// Int32x4[1,2,0,0]
var b = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load2(a, 2);
// Int32x4[3,4,0,0]加载三个值
var a = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load3(a, 0);
// Int32x4[1,2,3,0]
var b = new Int32Array([1, 2, 3, 4, 5, 6, 7, 8]);
SIMD.Int32x4.load3(a, 2);
// Int32x4[3,4,5,0]规范
Specification | Status | Comment |
|---|---|---|
SIMDThe definition of 'SIMDConstructor.load' in that specification. | Draft | Initial definition. |
浏览器兼容性
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
Basic support | No support | Nightly build | No support | No support | No support |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
Basic support | No support | No support | Nightly build | No support | No support | No support |
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

