@rings-webgpu/core 1.0.46 → 1.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rings.es.js +125 -125
- package/dist/rings.es.js.map +3 -3
- package/dist/rings.es.max.js +40 -71
- package/dist/rings.umd.js +127 -127
- package/dist/rings.umd.js.map +3 -3
- package/dist/rings.umd.max.js +40 -71
- package/dist/types/textures/Float16ArrayTexture.d.ts +5 -6
- package/package.json +1 -1
package/dist/rings.umd.max.js
CHANGED
|
@@ -24312,75 +24312,44 @@ struct InstanceData {
|
|
|
24312
24312
|
}
|
|
24313
24313
|
|
|
24314
24314
|
const _floatView$1 = new Float32Array(1);
|
|
24315
|
-
|
|
24316
|
-
function batchConvertToHalfFloat(src, dst, offset, length) {
|
|
24317
|
-
for (let i = 0; i < length; i++) {
|
|
24318
|
-
const val = src[offset + i];
|
|
24319
|
-
_floatView$1[0] = val;
|
|
24320
|
-
const x = _int32View$1[0];
|
|
24321
|
-
let bits = x >> 16 & 32768;
|
|
24322
|
-
let m = x >> 12 & 2047;
|
|
24323
|
-
const e = x >> 23 & 255;
|
|
24324
|
-
if (e < 103) {
|
|
24325
|
-
dst[offset + i] = bits;
|
|
24326
|
-
continue;
|
|
24327
|
-
}
|
|
24328
|
-
if (e > 142) {
|
|
24329
|
-
bits |= 31744;
|
|
24330
|
-
bits |= (e == 255 ? 1 : 0) && x & 8388607;
|
|
24331
|
-
dst[offset + i] = bits;
|
|
24332
|
-
continue;
|
|
24333
|
-
}
|
|
24334
|
-
if (e < 114) {
|
|
24335
|
-
m |= 2048;
|
|
24336
|
-
bits |= (m >> 114 - e) + (m >> 113 - e & 1);
|
|
24337
|
-
dst[offset + i] = bits;
|
|
24338
|
-
continue;
|
|
24339
|
-
}
|
|
24340
|
-
bits |= e - 112 << 10 | m >> 1;
|
|
24341
|
-
bits += m & 1;
|
|
24342
|
-
dst[offset + i] = bits;
|
|
24343
|
-
}
|
|
24344
|
-
}
|
|
24315
|
+
new Int32Array(_floatView$1.buffer);
|
|
24345
24316
|
class Float16ArrayTexture extends Texture {
|
|
24346
24317
|
uint16Array;
|
|
24347
|
-
floatArray;
|
|
24348
24318
|
_dataBuffer;
|
|
24349
24319
|
/**
|
|
24350
|
-
*
|
|
24320
|
+
* 使用 Uint16Array 填充纹理(Float16 格式),格式为[红0, 绿0, 蓝0, 透明度0, 红1, 绿1, 蓝1, 透明度1...]
|
|
24351
24321
|
* @param width 纹理宽度
|
|
24352
24322
|
* @param height 纹理高度
|
|
24353
|
-
* @param
|
|
24323
|
+
* @param data Float16 数据数组(Uint16Array),每个元素是一个 Float16 值
|
|
24354
24324
|
* @param useMipmap 是否生成Mipmap
|
|
24355
24325
|
* @returns 返回纹理实例
|
|
24356
24326
|
*/
|
|
24357
|
-
create(width, height,
|
|
24358
|
-
if (
|
|
24359
|
-
|
|
24360
|
-
|
|
24361
|
-
|
|
24362
|
-
}
|
|
24327
|
+
create(width, height, data = null, mipmap = true) {
|
|
24328
|
+
if (data == null) {
|
|
24329
|
+
const size = width * height * 4;
|
|
24330
|
+
data = new Uint16Array(size);
|
|
24331
|
+
data.fill(0);
|
|
24363
24332
|
}
|
|
24364
|
-
this.updateTexture(width, height,
|
|
24333
|
+
this.updateTexture(width, height, data, mipmap);
|
|
24365
24334
|
return this;
|
|
24366
24335
|
}
|
|
24367
24336
|
/**
|
|
24368
24337
|
* 更新纹理内容
|
|
24369
24338
|
* @param width 纹理宽度
|
|
24370
24339
|
* @param height 纹理高度
|
|
24371
|
-
* @param
|
|
24340
|
+
* @param data Float16 数据数组(Uint16Array),每个元素是一个 Float16 值
|
|
24372
24341
|
* @param mipmap 是否生成Mipmap
|
|
24373
24342
|
* @param startRow 起始行(部分更新)
|
|
24374
24343
|
* @param rowCount 更新的行数(部分更新)
|
|
24375
24344
|
*/
|
|
24376
|
-
updateTexture(width, height,
|
|
24345
|
+
updateTexture(width, height, data, mipmap = true, startRow, rowCount) {
|
|
24377
24346
|
if (width != this.width || height != this.height) {
|
|
24378
24347
|
this._dataBuffer && this._dataBuffer.destroy();
|
|
24379
24348
|
this._dataBuffer = null;
|
|
24380
24349
|
this.gpuTexture && this.gpuTexture.destroy();
|
|
24381
24350
|
this.gpuTexture = null;
|
|
24382
24351
|
}
|
|
24383
|
-
this.
|
|
24352
|
+
this.uint16Array = data;
|
|
24384
24353
|
let device = webGPUContext.device;
|
|
24385
24354
|
const bytesPerRow = width * 4 * 2;
|
|
24386
24355
|
this.format = GPUTextureFormat.rgba16float;
|
|
@@ -24390,14 +24359,7 @@ struct InstanceData {
|
|
|
24390
24359
|
const updateHeight = rowCount;
|
|
24391
24360
|
const updateOffset = startRow * width * 4;
|
|
24392
24361
|
const updateLength = updateHeight * width * 4;
|
|
24393
|
-
|
|
24394
|
-
if (!this.uint16Array || this.uint16Array.length < numbers.length) {
|
|
24395
|
-
this.uint16Array = new Uint16Array(numbers.length);
|
|
24396
|
-
}
|
|
24397
|
-
}
|
|
24398
|
-
const uint16Array2 = this.uint16Array;
|
|
24399
|
-
batchConvertToHalfFloat(numbers, uint16Array2, updateOffset, updateLength);
|
|
24400
|
-
const updateData = uint16Array2.subarray(updateOffset, updateOffset + updateLength);
|
|
24362
|
+
const updateData = data.subarray(updateOffset, updateOffset + updateLength);
|
|
24401
24363
|
const neededSize2 = updateData.byteLength;
|
|
24402
24364
|
if (!this._dataBuffer || this._dataBuffer.size < neededSize2) {
|
|
24403
24365
|
this._dataBuffer && this._dataBuffer.destroy();
|
|
@@ -24432,11 +24394,7 @@ struct InstanceData {
|
|
|
24432
24394
|
GPUContext.endCommandEncoder(commandEncoder2);
|
|
24433
24395
|
return;
|
|
24434
24396
|
}
|
|
24435
|
-
|
|
24436
|
-
this.uint16Array = new Uint16Array(numbers.length);
|
|
24437
|
-
}
|
|
24438
|
-
const uint16Array = this.uint16Array;
|
|
24439
|
-
batchConvertToHalfFloat(numbers, uint16Array, 0, numbers.length);
|
|
24397
|
+
const uint16Array = data;
|
|
24440
24398
|
const neededSize = uint16Array.byteLength;
|
|
24441
24399
|
if (!this._dataBuffer || this._dataBuffer.size < neededSize) {
|
|
24442
24400
|
this._dataBuffer && this._dataBuffer.destroy();
|
|
@@ -24825,7 +24783,8 @@ struct InstanceData {
|
|
|
24825
24783
|
const h = this.size.y | 0;
|
|
24826
24784
|
const count = asset.count;
|
|
24827
24785
|
const tA = new Uint32Array(w * h * 4);
|
|
24828
|
-
const tB = new
|
|
24786
|
+
const tB = new Uint16Array(w * h * 4);
|
|
24787
|
+
tB.fill(0);
|
|
24829
24788
|
const fb = new ArrayBuffer(4);
|
|
24830
24789
|
const f32 = new Float32Array(fb);
|
|
24831
24790
|
const u32 = new Uint32Array(fb);
|
|
@@ -24899,10 +24858,10 @@ struct InstanceData {
|
|
|
24899
24858
|
const cBy = r01 * r02 + r11 * r12 + r21 * r22;
|
|
24900
24859
|
const cBz = r02 * r02 + r12 * r12 + r22 * r22;
|
|
24901
24860
|
const bidx = idx;
|
|
24902
|
-
tB[bidx + 0] = cAx;
|
|
24903
|
-
tB[bidx + 1] = cAy;
|
|
24904
|
-
tB[bidx + 2] = cAz;
|
|
24905
|
-
tB[bidx + 3] = cBz;
|
|
24861
|
+
tB[bidx + 0] = toHalfFloat(cAx) & 65535;
|
|
24862
|
+
tB[bidx + 1] = toHalfFloat(cAy) & 65535;
|
|
24863
|
+
tB[bidx + 2] = toHalfFloat(cAz) & 65535;
|
|
24864
|
+
tB[bidx + 3] = toHalfFloat(cBz) & 65535;
|
|
24906
24865
|
const hx = toHalfFloat(cBx) & 65535;
|
|
24907
24866
|
const hy = toHalfFloat(cBy) & 65535;
|
|
24908
24867
|
tA[idx + 3] = hx | hy << 16;
|
|
@@ -42374,7 +42333,7 @@ else if (typeof exports === 'object')
|
|
|
42374
42333
|
}
|
|
42375
42334
|
}
|
|
42376
42335
|
|
|
42377
|
-
const version = "1.0.
|
|
42336
|
+
const version = "1.0.46";
|
|
42378
42337
|
|
|
42379
42338
|
class Engine3D {
|
|
42380
42339
|
/**
|
|
@@ -54637,7 +54596,7 @@ fn frag(){
|
|
|
54637
54596
|
_transformAData;
|
|
54638
54597
|
// RGBA32U: count * 4
|
|
54639
54598
|
_transformBData;
|
|
54640
|
-
// RGBA16F: count * 4
|
|
54599
|
+
// RGBA16F: count * 4 (Float16 format)
|
|
54641
54600
|
_orderData;
|
|
54642
54601
|
// R32U: size.x * size.y
|
|
54643
54602
|
_positions;
|
|
@@ -54695,7 +54654,8 @@ fn frag(){
|
|
|
54695
54654
|
this._colorData.fill(0);
|
|
54696
54655
|
this._transformAData = new Uint32Array(total * 4);
|
|
54697
54656
|
this._transformAData.fill(0);
|
|
54698
|
-
this._transformBData = new
|
|
54657
|
+
this._transformBData = new Uint16Array(total * 4);
|
|
54658
|
+
this._transformBData.fill(0);
|
|
54699
54659
|
this._orderData = new Uint32Array(total);
|
|
54700
54660
|
for (let i = 0; i < total; i++) {
|
|
54701
54661
|
this._orderData[i] = i < totalCount ? i : totalCount > 0 ? totalCount - 1 : 0;
|
|
@@ -54845,10 +54805,10 @@ fn frag(){
|
|
|
54845
54805
|
const cBy = r01 * r02 + r11 * r12 + r21 * r22;
|
|
54846
54806
|
const cBz = r02 * r02 + r12 * r12 + r22 * r22;
|
|
54847
54807
|
const bidx = idx;
|
|
54848
|
-
this._transformBData[bidx + 0] = cAx;
|
|
54849
|
-
this._transformBData[bidx + 1] = cAy;
|
|
54850
|
-
this._transformBData[bidx + 2] = cAz;
|
|
54851
|
-
this._transformBData[bidx + 3] = cBz;
|
|
54808
|
+
this._transformBData[bidx + 0] = toHalfFloat(cAx) & 65535;
|
|
54809
|
+
this._transformBData[bidx + 1] = toHalfFloat(cAy) & 65535;
|
|
54810
|
+
this._transformBData[bidx + 2] = toHalfFloat(cAz) & 65535;
|
|
54811
|
+
this._transformBData[bidx + 3] = toHalfFloat(cBz) & 65535;
|
|
54852
54812
|
const hx = toHalfFloat(cBx) & 65535;
|
|
54853
54813
|
const hy = toHalfFloat(cBy) & 65535;
|
|
54854
54814
|
this._transformAData[idx + 3] = hx | hy << 16;
|
|
@@ -71936,14 +71896,19 @@ fn frag(){
|
|
|
71936
71896
|
this.color.b,
|
|
71937
71897
|
this.color.a
|
|
71938
71898
|
);
|
|
71939
|
-
|
|
71899
|
+
const float16Data = new Uint16Array(numbers.length);
|
|
71900
|
+
for (let i = 0; i < numbers.length; i++) {
|
|
71901
|
+
float16Data[i] = toHalfFloat(numbers[i]) & 65535;
|
|
71902
|
+
}
|
|
71903
|
+
this._internalTexture.create(this._minSize, this._minSize, float16Data, false);
|
|
71940
71904
|
this.createFromTexture(this._minSize, this._internalTexture);
|
|
71941
71905
|
return this;
|
|
71942
71906
|
}
|
|
71943
71907
|
changeColor(color) {
|
|
71944
71908
|
this._skyColor = color;
|
|
71909
|
+
const numbers = [];
|
|
71945
71910
|
Engine3D.res.fillColor(
|
|
71946
|
-
|
|
71911
|
+
numbers,
|
|
71947
71912
|
this._minSize,
|
|
71948
71913
|
this._minSize,
|
|
71949
71914
|
this.color.r,
|
|
@@ -71951,10 +71916,14 @@ fn frag(){
|
|
|
71951
71916
|
this.color.b,
|
|
71952
71917
|
this.color.a
|
|
71953
71918
|
);
|
|
71919
|
+
const float16Data = new Uint16Array(numbers.length);
|
|
71920
|
+
for (let i = 0; i < numbers.length; i++) {
|
|
71921
|
+
float16Data[i] = toHalfFloat(numbers[i]) & 65535;
|
|
71922
|
+
}
|
|
71954
71923
|
this._internalTexture.updateTexture(
|
|
71955
71924
|
this._minSize,
|
|
71956
71925
|
this._minSize,
|
|
71957
|
-
|
|
71926
|
+
float16Data,
|
|
71958
71927
|
false
|
|
71959
71928
|
);
|
|
71960
71929
|
this._faceData.uploadTexture(0, this._internalTexture);
|
|
@@ -6,25 +6,24 @@ import { Texture } from "../gfx/graphics/webGpu/core/texture/Texture";
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class Float16ArrayTexture extends Texture {
|
|
8
8
|
uint16Array: Uint16Array;
|
|
9
|
-
floatArray: number[];
|
|
10
9
|
private _dataBuffer;
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
11
|
+
* 使用 Uint16Array 填充纹理(Float16 格式),格式为[红0, 绿0, 蓝0, 透明度0, 红1, 绿1, 蓝1, 透明度1...]
|
|
13
12
|
* @param width 纹理宽度
|
|
14
13
|
* @param height 纹理高度
|
|
15
|
-
* @param
|
|
14
|
+
* @param data Float16 数据数组(Uint16Array),每个元素是一个 Float16 值
|
|
16
15
|
* @param useMipmap 是否生成Mipmap
|
|
17
16
|
* @returns 返回纹理实例
|
|
18
17
|
*/
|
|
19
|
-
create(width: number, height: number,
|
|
18
|
+
create(width: number, height: number, data?: Uint16Array | null, mipmap?: boolean): this;
|
|
20
19
|
/**
|
|
21
20
|
* 更新纹理内容
|
|
22
21
|
* @param width 纹理宽度
|
|
23
22
|
* @param height 纹理高度
|
|
24
|
-
* @param
|
|
23
|
+
* @param data Float16 数据数组(Uint16Array),每个元素是一个 Float16 值
|
|
25
24
|
* @param mipmap 是否生成Mipmap
|
|
26
25
|
* @param startRow 起始行(部分更新)
|
|
27
26
|
* @param rowCount 更新的行数(部分更新)
|
|
28
27
|
*/
|
|
29
|
-
updateTexture(width: number, height: number,
|
|
28
|
+
updateTexture(width: number, height: number, data: Uint16Array, mipmap?: boolean, startRow?: number, rowCount?: number): void;
|
|
30
29
|
}
|