@zephyr3d/device 0.2.1 → 0.2.2
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/builder/ast.js +3 -5
- package/dist/builder/ast.js.map +1 -1
- package/dist/builder/base.js +30 -4
- package/dist/builder/base.js.map +1 -1
- package/dist/builder/builtinfunc.js +328 -10
- package/dist/builder/builtinfunc.js.map +1 -1
- package/dist/builder/constructors.js +4 -4
- package/dist/builder/programbuilder.js +50 -19
- package/dist/builder/programbuilder.js.map +1 -1
- package/dist/builder/types.js +37 -12
- package/dist/builder/types.js.map +1 -1
- package/dist/device.js +7 -9
- package/dist/device.js.map +1 -1
- package/dist/index.d.ts +103 -19
- package/package.json +2 -2
package/dist/builder/ast.js
CHANGED
|
@@ -532,7 +532,7 @@ function unbracket(e) {
|
|
|
532
532
|
}
|
|
533
533
|
isWritable() {
|
|
534
534
|
const type = this.getType();
|
|
535
|
-
return this.writable || type.isAtomicI32() || type.isAtomicU32() || type.isStructType() && type.
|
|
535
|
+
return this.writable || type.isAtomicI32() || type.isAtomicU32() || type.isStructType() && type.haveAtomicMembers();
|
|
536
536
|
}
|
|
537
537
|
getAddressSpace() {
|
|
538
538
|
switch(this.value.$declareType){
|
|
@@ -1759,13 +1759,11 @@ function unbracket(e) {
|
|
|
1759
1759
|
// prefix = `@location(${this.value.value.$location}) var<out> `;
|
|
1760
1760
|
throw new Error(`Internal error`);
|
|
1761
1761
|
case DeclareType.DECLARE_TYPE_UNIFORM:
|
|
1762
|
-
if (this.group === undefined) {
|
|
1763
|
-
debugger;
|
|
1764
|
-
}
|
|
1765
1762
|
prefix = `@group(${this.group}) @binding(${this.binding}) var${isBlock ? '<uniform>' : ''} `;
|
|
1766
1763
|
break;
|
|
1767
1764
|
case DeclareType.DECLARE_TYPE_STORAGE:
|
|
1768
|
-
prefix = `@group(${this.group}) @binding(${this.binding}) var<storage, ${this.value.isWritable() ? 'read_write' : 'read'
|
|
1765
|
+
prefix = `@group(${this.group}) @binding(${this.binding}) var<storage, ${this.value.value.$readonly ? 'read' : 'read_write' //this.value.isWritable() || this.value.getType().haveAtomicMembers() ? 'read_write' : 'read'
|
|
1766
|
+
}> `;
|
|
1769
1767
|
break;
|
|
1770
1768
|
case DeclareType.DECLARE_TYPE_WORKGROUP:
|
|
1771
1769
|
prefix = `var<workgroup> `;
|
package/dist/builder/ast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ast.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/builder/base.js
CHANGED
|
@@ -23,7 +23,7 @@ const constructorCache = new Map();
|
|
|
23
23
|
}
|
|
24
24
|
let ctor = entries[prop];
|
|
25
25
|
if (!ctor) {
|
|
26
|
-
if (elementType.isPrimitiveType() || elementType.isStructType() || elementType.isArrayType()) {
|
|
26
|
+
if (elementType.isPrimitiveType() || elementType.isStructType() || elementType.isArrayType() || elementType.isAtomicI32() || elementType.isAtomicU32()) {
|
|
27
27
|
if (prop === 'ptr') {
|
|
28
28
|
const pointerType = new PBPointerTypeInfo(elementType, PBAddressSpace.FUNCTION);
|
|
29
29
|
ctor = function pointerCtor(...args) {
|
|
@@ -99,6 +99,8 @@ let uidExp = 0;
|
|
|
99
99
|
/** @internal */ $_group;
|
|
100
100
|
/** @internal */ $declareType;
|
|
101
101
|
/** @internal */ $isBuffer;
|
|
102
|
+
/** @internal */ $readonly;
|
|
103
|
+
/** @internal */ $bindingSize;
|
|
102
104
|
/** @internal */ constructor(str, typeInfo){
|
|
103
105
|
super();
|
|
104
106
|
if (!str && typeInfo.isPointerType()) {
|
|
@@ -119,6 +121,8 @@ let uidExp = 0;
|
|
|
119
121
|
this.$_group = null;
|
|
120
122
|
this.$declareType = DeclareType.DECLARE_TYPE_NONE;
|
|
121
123
|
this.$isBuffer = false;
|
|
124
|
+
this.$bindingSize = 0;
|
|
125
|
+
this.$readonly = false;
|
|
122
126
|
if (typeInfo.isTextureType()) {
|
|
123
127
|
if (typeInfo.isDepthTexture()) {
|
|
124
128
|
this.$sampleType = 'depth';
|
|
@@ -157,13 +161,14 @@ let uidExp = 0;
|
|
|
157
161
|
* Point out that the variable should be an uniform buffer
|
|
158
162
|
* @param group - The bind group index
|
|
159
163
|
* @returns self
|
|
160
|
-
*/ uniformBuffer(group) {
|
|
164
|
+
*/ uniformBuffer(group, bindingSize = 0) {
|
|
161
165
|
if (!this.$typeinfo.isPrimitiveType() && !this.$typeinfo.isArrayType() && !this.$typeinfo.isStructType()) {
|
|
162
166
|
throw new PBASTError(this.$ast, 'only primitive type, array type or structure type can be set as uniform buffer');
|
|
163
167
|
}
|
|
164
168
|
this.$declareType = DeclareType.DECLARE_TYPE_UNIFORM;
|
|
165
169
|
this.$group = group;
|
|
166
170
|
this.$isBuffer = true;
|
|
171
|
+
this.$bindingSize = bindingSize;
|
|
167
172
|
return this;
|
|
168
173
|
}
|
|
169
174
|
/**
|
|
@@ -188,19 +193,40 @@ let uidExp = 0;
|
|
|
188
193
|
this.$declareType = DeclareType.DECLARE_TYPE_STORAGE;
|
|
189
194
|
this.$group = group;
|
|
190
195
|
this.$isBuffer = false;
|
|
196
|
+
this.$readonly = false;
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Point out that the variable is read-only and should be in storage address space
|
|
201
|
+
* @param group - The bind group index
|
|
202
|
+
* @returns self
|
|
203
|
+
*/ storageReadonly(group) {
|
|
204
|
+
this.storage(group);
|
|
205
|
+
this.$readonly = true;
|
|
191
206
|
return this;
|
|
192
207
|
}
|
|
193
208
|
/**
|
|
194
209
|
* Point out that the variable should be a storage buffer
|
|
195
210
|
* @param group - The bind group index
|
|
196
211
|
* @returns self
|
|
197
|
-
*/ storageBuffer(group) {
|
|
198
|
-
if (!this.$typeinfo.isPrimitiveType() && !this.$typeinfo.isArrayType() && !this.$typeinfo.isStructType()) {
|
|
212
|
+
*/ storageBuffer(group, bindingSize = 0) {
|
|
213
|
+
if (!this.$typeinfo.isPrimitiveType() && !this.$typeinfo.isArrayType() && !this.$typeinfo.isStructType() && !this.$typeinfo.isAtomicI32() && !this.$typeinfo.isAtomicU32()) {
|
|
199
214
|
throw new PBASTError(this.$ast, 'only primitive type, array type or structure type can be set as storage buffer');
|
|
200
215
|
}
|
|
201
216
|
this.$declareType = DeclareType.DECLARE_TYPE_STORAGE;
|
|
202
217
|
this.$group = group;
|
|
203
218
|
this.$isBuffer = true;
|
|
219
|
+
this.$bindingSize = bindingSize;
|
|
220
|
+
this.$readonly = false;
|
|
221
|
+
return this;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Point out that the variable is read-only and should be a storage buffer
|
|
225
|
+
* @param group - The bind group index
|
|
226
|
+
* @returns self
|
|
227
|
+
*/ storageBufferReadonly(group, bindingSize = 0) {
|
|
228
|
+
this.storageBuffer(group, bindingSize);
|
|
229
|
+
this.$readonly = true;
|
|
204
230
|
return this;
|
|
205
231
|
}
|
|
206
232
|
inout() {
|
package/dist/builder/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PBPrimitiveType, typeU32, typeF32,
|
|
2
|
-
import {
|
|
1
|
+
import { PBPrimitiveType, typeU32, typeF32, typeI32, typeAtomicI32, typeAtomicU32, typeVoid, PBFunctionTypeInfo, typeF32Vec2, typeF32Vec3, typeF32Vec4, typeI32Vec2, typeI32Vec3, typeI32Vec4, typeU32Vec2, typeU32Vec3, typeU32Vec4, typeMat2, typeMat3x2, typeMat4x2, typeMat2x3, typeMat3, typeMat4x3, typeMat2x4, typeMat3x4, typeMat4, typeFrexpResult, typeFrexpResultVec2, typeFrexpResultVec3, typeFrexpResultVec4, typeBool, typeTex1D, typeITex1D, typeUTex1D, typeTex2D, typeITex2D, typeUTex2D, typeTex2DArray, typeITex2DArray, typeUTex2DArray, typeTex3D, typeITex3D, typeUTex3D, typeTexCube, typeITexCube, typeUTexCube, typeTexCubeArray, typeITexCubeArray, typeUTexCubeArray, typeTexMultisampled2D, typeITexMultisampled2D, typeUTexMultisampled2D, typeTexDepth2D, typeTexDepth2DArray, typeTexDepthCube, typeTexDepthCubeArray, typeTexDepthMultisampled2D, typeTexStorage1D_rgba8unorm, typeTexStorage1D_rgba8snorm, typeTexStorage1D_rgba8uint, typeTexStorage1D_rgba8sint, typeTexStorage1D_rgba16uint, typeTexStorage1D_rgba16sint, typeTexStorage1D_rgba16float, typeTexStorage1D_rgba32uint, typeTexStorage1D_rgba32sint, typeTexStorage1D_rgba32float, typeTexStorage1D_rg32uint, typeTexStorage1D_rg32sint, typeTexStorage1D_rg32float, typeTexStorage1D_r32uint, typeTexStorage1D_r32sint, typeTexStorage1D_r32float, typeTexStorage2D_rgba8unorm, typeTexStorage2D_rgba8snorm, typeTexStorage2D_rgba8uint, typeTexStorage2D_rgba8sint, typeTexStorage2D_rgba16uint, typeTexStorage2D_rgba16sint, typeTexStorage2D_rgba16float, typeTexStorage2D_rgba32uint, typeTexStorage2D_rgba32sint, typeTexStorage2D_rgba32float, typeTexStorage2D_rg32uint, typeTexStorage2D_rg32sint, typeTexStorage2D_rg32float, typeTexStorage2D_r32uint, typeTexStorage2D_r32sint, typeTexStorage2D_r32float, typeTexStorage2DArray_rgba8unorm, typeTexStorage2DArray_rgba8snorm, typeTexStorage2DArray_rgba8uint, typeTexStorage2DArray_rgba8sint, typeTexStorage2DArray_rgba16uint, typeTexStorage2DArray_rgba16sint, typeTexStorage2DArray_rgba16float, typeTexStorage2DArray_rgba32uint, typeTexStorage2DArray_rgba32sint, typeTexStorage2DArray_rgba32float, typeTexStorage2DArray_rg32uint, typeTexStorage2DArray_rg32sint, typeTexStorage2DArray_rg32float, typeTexStorage2DArray_r32uint, typeTexStorage2DArray_r32sint, typeTexStorage2DArray_r32float, typeTexStorage3D_rgba8unorm, typeTexStorage3D_rgba8snorm, typeTexStorage3D_rgba8uint, typeTexStorage3D_rgba8sint, typeTexStorage3D_rgba16uint, typeTexStorage3D_rgba16sint, typeTexStorage3D_rgba16float, typeTexStorage3D_rgba32uint, typeTexStorage3D_rgba32sint, typeTexStorage3D_rgba32float, typeTexStorage3D_rg32uint, typeTexStorage3D_rg32sint, typeTexStorage3D_rg32float, typeTexStorage3D_r32uint, typeTexStorage3D_r32sint, typeTexStorage3D_r32float, typeSampler, typeSamplerComparison, typeTexStorage1D_bgra8unorm, typeTexStorage2D_bgra8unorm, typeTexStorage3D_bgra8unorm, typeTexExternal, typeBVec2, typeBVec3, typeBVec4 } from './types.js';
|
|
2
|
+
import { ASTScalar, ASTAddressOf, ASTFunction, ASTUnaryFunc, ASTBinaryFunc } from './ast.js';
|
|
3
3
|
import { PBShaderExp } from './base.js';
|
|
4
4
|
import { PBParamLengthError, PBDeviceNotSupport, PBParamValueError, PBParamTypeError, PBOverloadingMatchError } from './errors.js';
|
|
5
5
|
|
|
@@ -1682,22 +1682,110 @@ const builtinFunctionsAll = {
|
|
|
1682
1682
|
floatBitsToInt: {
|
|
1683
1683
|
overloads: genType('floatBitsToInt', MASK_WEBGL2, 1, [
|
|
1684
1684
|
0
|
|
1685
|
-
])
|
|
1685
|
+
]),
|
|
1686
|
+
normalizeFunc (pb, name, ...args) {
|
|
1687
|
+
if (args.length !== 1) {
|
|
1688
|
+
throw new PBParamLengthError('floatBitsToInt');
|
|
1689
|
+
}
|
|
1690
|
+
if (!(args[0] instanceof PBShaderExp)) {
|
|
1691
|
+
if (typeof args[0] !== 'number') {
|
|
1692
|
+
throw new PBParamValueError('floatBitsToInt', 'x');
|
|
1693
|
+
}
|
|
1694
|
+
} else {
|
|
1695
|
+
const type = args[0].$ast.getType();
|
|
1696
|
+
if (type.typeId !== typeF32.typeId) {
|
|
1697
|
+
throw new PBParamTypeError('floatBitsToInt', 'x');
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
if (pb.getDevice().type === 'webgpu') {
|
|
1701
|
+
return pb.$callFunctionNoCheck('bitcast<i32>', [
|
|
1702
|
+
args[0] instanceof PBShaderExp ? args[0].$ast : new ASTScalar(args[0], typeF32)
|
|
1703
|
+
], typeI32);
|
|
1704
|
+
} else {
|
|
1705
|
+
return callBuiltin(pb, name, ...args);
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1686
1708
|
},
|
|
1687
1709
|
floatBitsToUint: {
|
|
1688
1710
|
overloads: genType('floatBitsToUint', MASK_WEBGL2, 2, [
|
|
1689
1711
|
0
|
|
1690
|
-
])
|
|
1712
|
+
]),
|
|
1713
|
+
normalizeFunc (pb, name, ...args) {
|
|
1714
|
+
if (args.length !== 1) {
|
|
1715
|
+
throw new PBParamLengthError('floatBitsToUint');
|
|
1716
|
+
}
|
|
1717
|
+
if (!(args[0] instanceof PBShaderExp)) {
|
|
1718
|
+
if (typeof args[0] !== 'number') {
|
|
1719
|
+
throw new PBParamValueError('floatBitsToUint', 'x');
|
|
1720
|
+
}
|
|
1721
|
+
} else {
|
|
1722
|
+
const type = args[0].$ast.getType();
|
|
1723
|
+
if (type.typeId !== typeF32.typeId) {
|
|
1724
|
+
throw new PBParamTypeError('floatBitsToUint', 'x');
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
if (pb.getDevice().type === 'webgpu') {
|
|
1728
|
+
return pb.$callFunctionNoCheck('bitcast<u32>', [
|
|
1729
|
+
args[0] instanceof PBShaderExp ? args[0].$ast : new ASTScalar(args[0], typeF32)
|
|
1730
|
+
], typeU32);
|
|
1731
|
+
} else {
|
|
1732
|
+
return callBuiltin(pb, name, ...args);
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1691
1735
|
},
|
|
1692
1736
|
intBitsToFloat: {
|
|
1693
1737
|
overloads: genType('intBitsToFloat', MASK_WEBGL2, 0, [
|
|
1694
1738
|
1
|
|
1695
|
-
])
|
|
1739
|
+
]),
|
|
1740
|
+
normalizeFunc (pb, name, ...args) {
|
|
1741
|
+
if (args.length !== 1) {
|
|
1742
|
+
throw new PBParamLengthError('intBitsToFloat');
|
|
1743
|
+
}
|
|
1744
|
+
if (!(args[0] instanceof PBShaderExp)) {
|
|
1745
|
+
if (typeof args[0] !== 'number') {
|
|
1746
|
+
throw new PBParamValueError('intBitsToFloat', 'x');
|
|
1747
|
+
}
|
|
1748
|
+
} else {
|
|
1749
|
+
const type = args[0].$ast.getType();
|
|
1750
|
+
if (type.typeId !== typeI32.typeId) {
|
|
1751
|
+
throw new PBParamTypeError('intBitsToFloat', 'x');
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
if (pb.getDevice().type === 'webgpu') {
|
|
1755
|
+
return pb.$callFunctionNoCheck('bitcast<f32>', [
|
|
1756
|
+
args[0] instanceof PBShaderExp ? args[0].$ast : new ASTScalar(args[0], typeI32)
|
|
1757
|
+
], typeF32);
|
|
1758
|
+
} else {
|
|
1759
|
+
return callBuiltin(pb, name, ...args);
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1696
1762
|
},
|
|
1697
1763
|
uintBitsToFloat: {
|
|
1698
1764
|
overloads: genType('uintBitsToFloat', MASK_WEBGL2, 0, [
|
|
1699
1765
|
2
|
|
1700
|
-
])
|
|
1766
|
+
]),
|
|
1767
|
+
normalizeFunc (pb, name, ...args) {
|
|
1768
|
+
if (args.length !== 1) {
|
|
1769
|
+
throw new PBParamLengthError('uintBitsToFloat');
|
|
1770
|
+
}
|
|
1771
|
+
if (!(args[0] instanceof PBShaderExp)) {
|
|
1772
|
+
if (typeof args[0] !== 'number') {
|
|
1773
|
+
throw new PBParamValueError('uintBitsToFloat', 'x');
|
|
1774
|
+
}
|
|
1775
|
+
} else {
|
|
1776
|
+
const type = args[0].$ast.getType();
|
|
1777
|
+
if (type.typeId !== typeU32.typeId) {
|
|
1778
|
+
throw new PBParamTypeError('uintBitsToFloat', 'x');
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
if (pb.getDevice().type === 'webgpu') {
|
|
1782
|
+
return pb.$callFunctionNoCheck('bitcast<f32>', [
|
|
1783
|
+
args[0] instanceof PBShaderExp ? args[0].$ast : new ASTScalar(args[0], typeU32)
|
|
1784
|
+
], typeF32);
|
|
1785
|
+
} else {
|
|
1786
|
+
return callBuiltin(pb, name, ...args);
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1701
1789
|
},
|
|
1702
1790
|
pack4x8snorm: {
|
|
1703
1791
|
overloads: genType('pack4x8snorm', MASK_WEBGPU, typeU32, [
|
|
@@ -2409,6 +2497,74 @@ const builtinFunctionsAll = {
|
|
|
2409
2497
|
typeI32,
|
|
2410
2498
|
typeI32
|
|
2411
2499
|
]),
|
|
2500
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2501
|
+
typeTexStorage1D_bgra8unorm,
|
|
2502
|
+
typeI32
|
|
2503
|
+
]),
|
|
2504
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2505
|
+
typeTexStorage1D_r32float,
|
|
2506
|
+
typeI32
|
|
2507
|
+
]),
|
|
2508
|
+
...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
|
|
2509
|
+
typeTexStorage1D_r32sint,
|
|
2510
|
+
typeI32
|
|
2511
|
+
]),
|
|
2512
|
+
...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
|
|
2513
|
+
typeTexStorage1D_r32uint,
|
|
2514
|
+
typeI32
|
|
2515
|
+
]),
|
|
2516
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2517
|
+
typeTexStorage1D_rg32float,
|
|
2518
|
+
typeI32
|
|
2519
|
+
]),
|
|
2520
|
+
...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
|
|
2521
|
+
typeTexStorage1D_rg32sint,
|
|
2522
|
+
typeI32
|
|
2523
|
+
]),
|
|
2524
|
+
...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
|
|
2525
|
+
typeTexStorage1D_rg32uint,
|
|
2526
|
+
typeI32
|
|
2527
|
+
]),
|
|
2528
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2529
|
+
typeTexStorage1D_rgba16float,
|
|
2530
|
+
typeI32
|
|
2531
|
+
]),
|
|
2532
|
+
...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
|
|
2533
|
+
typeTexStorage1D_rgba16sint,
|
|
2534
|
+
typeI32
|
|
2535
|
+
]),
|
|
2536
|
+
...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
|
|
2537
|
+
typeTexStorage1D_rgba16uint,
|
|
2538
|
+
typeI32
|
|
2539
|
+
]),
|
|
2540
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2541
|
+
typeTexStorage1D_rgba32float,
|
|
2542
|
+
typeI32
|
|
2543
|
+
]),
|
|
2544
|
+
...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
|
|
2545
|
+
typeTexStorage1D_rgba32sint,
|
|
2546
|
+
typeI32
|
|
2547
|
+
]),
|
|
2548
|
+
...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
|
|
2549
|
+
typeTexStorage1D_rgba32uint,
|
|
2550
|
+
typeI32
|
|
2551
|
+
]),
|
|
2552
|
+
...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
|
|
2553
|
+
typeTexStorage1D_rgba8sint,
|
|
2554
|
+
typeI32
|
|
2555
|
+
]),
|
|
2556
|
+
...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
|
|
2557
|
+
typeTexStorage1D_rgba8uint,
|
|
2558
|
+
typeI32
|
|
2559
|
+
]),
|
|
2560
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2561
|
+
typeTexStorage1D_rgba8snorm,
|
|
2562
|
+
typeI32
|
|
2563
|
+
]),
|
|
2564
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2565
|
+
typeTexStorage1D_rgba8unorm,
|
|
2566
|
+
typeI32
|
|
2567
|
+
]),
|
|
2412
2568
|
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2413
2569
|
typeTex2D,
|
|
2414
2570
|
typeI32Vec2,
|
|
@@ -2424,6 +2580,74 @@ const builtinFunctionsAll = {
|
|
|
2424
2580
|
typeI32Vec2,
|
|
2425
2581
|
typeI32
|
|
2426
2582
|
]),
|
|
2583
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2584
|
+
typeTexStorage2D_bgra8unorm,
|
|
2585
|
+
typeI32Vec2
|
|
2586
|
+
]),
|
|
2587
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2588
|
+
typeTexStorage2D_r32float,
|
|
2589
|
+
typeI32Vec2
|
|
2590
|
+
]),
|
|
2591
|
+
...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
|
|
2592
|
+
typeTexStorage2D_r32sint,
|
|
2593
|
+
typeI32Vec2
|
|
2594
|
+
]),
|
|
2595
|
+
...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
|
|
2596
|
+
typeTexStorage2D_r32uint,
|
|
2597
|
+
typeI32Vec2
|
|
2598
|
+
]),
|
|
2599
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2600
|
+
typeTexStorage2D_rg32float,
|
|
2601
|
+
typeI32Vec2
|
|
2602
|
+
]),
|
|
2603
|
+
...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
|
|
2604
|
+
typeTexStorage2D_rg32sint,
|
|
2605
|
+
typeI32Vec2
|
|
2606
|
+
]),
|
|
2607
|
+
...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
|
|
2608
|
+
typeTexStorage2D_rg32uint,
|
|
2609
|
+
typeI32Vec2
|
|
2610
|
+
]),
|
|
2611
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2612
|
+
typeTexStorage2D_rgba16float,
|
|
2613
|
+
typeI32Vec2
|
|
2614
|
+
]),
|
|
2615
|
+
...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
|
|
2616
|
+
typeTexStorage2D_rgba16sint,
|
|
2617
|
+
typeI32Vec2
|
|
2618
|
+
]),
|
|
2619
|
+
...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
|
|
2620
|
+
typeTexStorage2D_rgba16uint,
|
|
2621
|
+
typeI32Vec2
|
|
2622
|
+
]),
|
|
2623
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2624
|
+
typeTexStorage2D_rgba32float,
|
|
2625
|
+
typeI32Vec2
|
|
2626
|
+
]),
|
|
2627
|
+
...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
|
|
2628
|
+
typeTexStorage2D_rgba32sint,
|
|
2629
|
+
typeI32Vec2
|
|
2630
|
+
]),
|
|
2631
|
+
...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
|
|
2632
|
+
typeTexStorage2D_rgba32uint,
|
|
2633
|
+
typeI32Vec2
|
|
2634
|
+
]),
|
|
2635
|
+
...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
|
|
2636
|
+
typeTexStorage2D_rgba8sint,
|
|
2637
|
+
typeI32Vec2
|
|
2638
|
+
]),
|
|
2639
|
+
...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
|
|
2640
|
+
typeTexStorage2D_rgba8uint,
|
|
2641
|
+
typeI32Vec2
|
|
2642
|
+
]),
|
|
2643
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2644
|
+
typeTexStorage2D_rgba8snorm,
|
|
2645
|
+
typeI32Vec2
|
|
2646
|
+
]),
|
|
2647
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2648
|
+
typeTexStorage2D_rgba8unorm,
|
|
2649
|
+
typeI32Vec2
|
|
2650
|
+
]),
|
|
2427
2651
|
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2428
2652
|
typeTex3D,
|
|
2429
2653
|
typeI32Vec3,
|
|
@@ -2439,6 +2663,74 @@ const builtinFunctionsAll = {
|
|
|
2439
2663
|
typeI32Vec3,
|
|
2440
2664
|
typeI32
|
|
2441
2665
|
]),
|
|
2666
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2667
|
+
typeTexStorage3D_bgra8unorm,
|
|
2668
|
+
typeI32Vec3
|
|
2669
|
+
]),
|
|
2670
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2671
|
+
typeTexStorage3D_r32float,
|
|
2672
|
+
typeI32Vec3
|
|
2673
|
+
]),
|
|
2674
|
+
...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
|
|
2675
|
+
typeTexStorage3D_r32sint,
|
|
2676
|
+
typeI32Vec3
|
|
2677
|
+
]),
|
|
2678
|
+
...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
|
|
2679
|
+
typeTexStorage3D_r32uint,
|
|
2680
|
+
typeI32Vec3
|
|
2681
|
+
]),
|
|
2682
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2683
|
+
typeTexStorage3D_rg32float,
|
|
2684
|
+
typeI32Vec3
|
|
2685
|
+
]),
|
|
2686
|
+
...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
|
|
2687
|
+
typeTexStorage3D_rg32sint,
|
|
2688
|
+
typeI32Vec3
|
|
2689
|
+
]),
|
|
2690
|
+
...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
|
|
2691
|
+
typeTexStorage3D_rg32uint,
|
|
2692
|
+
typeI32Vec3
|
|
2693
|
+
]),
|
|
2694
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2695
|
+
typeTexStorage3D_rgba16float,
|
|
2696
|
+
typeI32Vec3
|
|
2697
|
+
]),
|
|
2698
|
+
...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
|
|
2699
|
+
typeTexStorage3D_rgba16sint,
|
|
2700
|
+
typeI32Vec3
|
|
2701
|
+
]),
|
|
2702
|
+
...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
|
|
2703
|
+
typeTexStorage3D_rgba16uint,
|
|
2704
|
+
typeI32Vec3
|
|
2705
|
+
]),
|
|
2706
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2707
|
+
typeTexStorage3D_rgba32float,
|
|
2708
|
+
typeI32Vec3
|
|
2709
|
+
]),
|
|
2710
|
+
...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
|
|
2711
|
+
typeTexStorage3D_rgba32sint,
|
|
2712
|
+
typeI32Vec3
|
|
2713
|
+
]),
|
|
2714
|
+
...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
|
|
2715
|
+
typeTexStorage3D_rgba32uint,
|
|
2716
|
+
typeI32Vec3
|
|
2717
|
+
]),
|
|
2718
|
+
...genType('textureLoad', MASK_WEBGPU, typeI32Vec4, [
|
|
2719
|
+
typeTexStorage3D_rgba8sint,
|
|
2720
|
+
typeI32Vec3
|
|
2721
|
+
]),
|
|
2722
|
+
...genType('textureLoad', MASK_WEBGPU, typeU32Vec4, [
|
|
2723
|
+
typeTexStorage3D_rgba8uint,
|
|
2724
|
+
typeI32Vec3
|
|
2725
|
+
]),
|
|
2726
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2727
|
+
typeTexStorage3D_rgba8snorm,
|
|
2728
|
+
typeI32Vec3
|
|
2729
|
+
]),
|
|
2730
|
+
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2731
|
+
typeTexStorage3D_rgba8unorm,
|
|
2732
|
+
typeI32Vec3
|
|
2733
|
+
]),
|
|
2442
2734
|
...genType('textureLoad', MASK_WEBGPU, typeF32Vec4, [
|
|
2443
2735
|
typeTexMultisampled2D,
|
|
2444
2736
|
typeI32Vec2,
|
|
@@ -2549,8 +2841,13 @@ const builtinFunctionsAll = {
|
|
|
2549
2841
|
}
|
|
2550
2842
|
args[1] = pb.ivec2(args[1], 0);
|
|
2551
2843
|
}
|
|
2552
|
-
} else if (pb.getDevice().type === 'webgpu'
|
|
2553
|
-
|
|
2844
|
+
} else if (pb.getDevice().type === 'webgpu') {
|
|
2845
|
+
if (texType.isExternalTexture()) {
|
|
2846
|
+
args = args.slice(0, 2);
|
|
2847
|
+
}
|
|
2848
|
+
if (texType.isStorageTexture()) {
|
|
2849
|
+
texType.readable = true;
|
|
2850
|
+
}
|
|
2554
2851
|
}
|
|
2555
2852
|
return callBuiltin(pb, name, ...args);
|
|
2556
2853
|
}
|
|
@@ -2765,6 +3062,11 @@ const builtinFunctionsAll = {
|
|
|
2765
3062
|
typeU32Vec2,
|
|
2766
3063
|
typeU32Vec4
|
|
2767
3064
|
]),
|
|
3065
|
+
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
3066
|
+
typeTexStorage2D_r32uint,
|
|
3067
|
+
typeI32Vec2,
|
|
3068
|
+
typeU32Vec4
|
|
3069
|
+
]),
|
|
2768
3070
|
...genType('textureStore', MASK_WEBGPU, typeVoid, [
|
|
2769
3071
|
typeTexStorage2D_r32sint,
|
|
2770
3072
|
typeU32Vec2,
|
|
@@ -2855,7 +3157,19 @@ const builtinFunctionsAll = {
|
|
|
2855
3157
|
typeU32Vec3,
|
|
2856
3158
|
typeF32Vec4
|
|
2857
3159
|
])
|
|
2858
|
-
]
|
|
3160
|
+
],
|
|
3161
|
+
normalizeFunc (pb, name, ...args) {
|
|
3162
|
+
if (pb.getDevice().type === 'webgpu') {
|
|
3163
|
+
const tex = args[0];
|
|
3164
|
+
if (tex instanceof PBShaderExp) {
|
|
3165
|
+
const texType = tex.$ast.getType();
|
|
3166
|
+
if (texType?.isTextureType() && texType.isStorageTexture()) {
|
|
3167
|
+
texType.writable = true;
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
return callBuiltin(pb, name, ...args);
|
|
3172
|
+
}
|
|
2859
3173
|
},
|
|
2860
3174
|
// textureArrayStore(tex: PBShaderExp, coords: PBShaderExp, arrayIndex: number|PBShaderExp, value: PBShaderExp);
|
|
2861
3175
|
textureArrayStore: {
|
|
@@ -3227,6 +3541,9 @@ const builtinFunctionsAll = {
|
|
|
3227
3541
|
throw new PBParamTypeError('textureSample', 'texture');
|
|
3228
3542
|
}
|
|
3229
3543
|
if (pb.getDevice().type === 'webgpu') {
|
|
3544
|
+
if (texType.isStorageTexture()) {
|
|
3545
|
+
throw new PBParamTypeError('textureSample', 'texture');
|
|
3546
|
+
}
|
|
3230
3547
|
const sampler = pb.getDefaultSampler(tex, false);
|
|
3231
3548
|
const coords = args[1];
|
|
3232
3549
|
const ret = callBuiltin(pb, name, tex, sampler, coords);
|
|
@@ -4033,7 +4350,8 @@ for (const name of [
|
|
|
4033
4350
|
'atomicMin',
|
|
4034
4351
|
'atomicAnd',
|
|
4035
4352
|
'atomicOr',
|
|
4036
|
-
'atomicXor'
|
|
4353
|
+
'atomicXor',
|
|
4354
|
+
'atomicExchange'
|
|
4037
4355
|
]){
|
|
4038
4356
|
builtinFunctionsAll[name] = {
|
|
4039
4357
|
overloades: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtinfunc.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"builtinfunc.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -126,7 +126,7 @@ const texStorageCtors = {
|
|
|
126
126
|
Object.keys(texStorageCtors).forEach((k)=>{
|
|
127
127
|
cls.prototype[k] = makeStorageTextureCtor(texStorageCtors[k]);
|
|
128
128
|
});
|
|
129
|
-
cls.prototype['atomic_int'] = function(...args) {
|
|
129
|
+
cls.prototype['atomic_int'] = makeConstructor(function(...args) {
|
|
130
130
|
if (args.length > 1) {
|
|
131
131
|
throw new PBParamLengthError('atomic_int');
|
|
132
132
|
}
|
|
@@ -140,8 +140,8 @@ const texStorageCtors = {
|
|
|
140
140
|
exp.$ast = new ASTShaderExpConstructor(exp.$typeinfo, []);
|
|
141
141
|
return exp;
|
|
142
142
|
}
|
|
143
|
-
};
|
|
144
|
-
cls.prototype['atomic_uint'] = function(...args) {
|
|
143
|
+
}, typeAtomicI32);
|
|
144
|
+
cls.prototype['atomic_uint'] = makeConstructor(function(...args) {
|
|
145
145
|
if (args.length > 1) {
|
|
146
146
|
throw new PBParamLengthError('atomic_uint');
|
|
147
147
|
}
|
|
@@ -161,7 +161,7 @@ const texStorageCtors = {
|
|
|
161
161
|
return exp;
|
|
162
162
|
}
|
|
163
163
|
return null;
|
|
164
|
-
};
|
|
164
|
+
}, typeAtomicU32);
|
|
165
165
|
} /*
|
|
166
166
|
ProgramBuilder.prototype.texStorage1D = makeStorageTextureCtor(typeinfo.PBTextureType.TEX_STORAGE_1D);
|
|
167
167
|
ProgramBuilder.prototype.texStorage2D = makeStorageTextureCtor(typeinfo.PBTextureType.TEX_STORAGE_2D);
|
|
@@ -712,14 +712,19 @@ const output_prefix_fs = 'zFSOutput_';
|
|
|
712
712
|
name,
|
|
713
713
|
new ASTDeclareVar(new ASTPrimitive(variable))
|
|
714
714
|
];
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
715
|
+
for (const prop of [
|
|
716
|
+
name,
|
|
717
|
+
String(location)
|
|
718
|
+
]){
|
|
719
|
+
Object.defineProperty(this._outputScope, prop, {
|
|
720
|
+
get: function() {
|
|
721
|
+
return variable;
|
|
722
|
+
},
|
|
723
|
+
set: function(v) {
|
|
724
|
+
getCurrentProgramBuilder().getCurrentScope().$ast.statements.push(new ASTAssignment(new ASTLValueScalar(variable.$ast), v instanceof PBShaderExp ? v.$ast : v));
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
}
|
|
723
728
|
}
|
|
724
729
|
/** @internal */ getDefaultSampler(t, comparison) {
|
|
725
730
|
const u = this._uniforms.findIndex((val)=>val.texture?.exp === t);
|
|
@@ -1015,6 +1020,8 @@ const output_prefix_fs = 'zFSOutput_';
|
|
|
1015
1020
|
const exp = new PBShaderExp(u.block.exp.$str, u.block.exp.$ast.getType());
|
|
1016
1021
|
exp.$declareType = u.block.exp.$declareType;
|
|
1017
1022
|
exp.$isBuffer = u.block.exp.$isBuffer;
|
|
1023
|
+
exp.$bindingSize = u.block.exp.$bindingSize;
|
|
1024
|
+
exp.$readonly = u.block.exp.$readonly;
|
|
1018
1025
|
uniformList[u.group].push({
|
|
1019
1026
|
member: exp,
|
|
1020
1027
|
uniform: i
|
|
@@ -1054,11 +1061,13 @@ const output_prefix_fs = 'zFSOutput_';
|
|
|
1054
1061
|
const uname = `${nameList[i]}_${k}_${p}`;
|
|
1055
1062
|
const structName = this.generateStructureName();
|
|
1056
1063
|
const t = getCurrentProgramBuilder().internalDefineStruct(structName, types[i], ShaderType.Compute, false, ...allLists[p].map((val)=>val.member));
|
|
1064
|
+
const readonly = i > 0 ? allLists[p].findIndex((val)=>!val.member.$readonly) < 0 : true;
|
|
1057
1065
|
const exp = t();
|
|
1058
1066
|
if (i === 0) {
|
|
1059
|
-
exp.uniformBuffer(Number(k));
|
|
1067
|
+
exp.uniformBuffer(Number(k), p > 0 ? allLists[p][0].member.$bindingSize : 0);
|
|
1060
1068
|
} else {
|
|
1061
|
-
exp.storageBuffer(Number(k));
|
|
1069
|
+
exp.storageBuffer(Number(k), p > 0 ? allLists[p][0].member.$bindingSize : 0);
|
|
1070
|
+
exp.$readonly = readonly;
|
|
1062
1071
|
}
|
|
1063
1072
|
globalScope[uname] = exp;
|
|
1064
1073
|
const index = this._uniforms.findIndex((val)=>val.block?.name === uname);
|
|
@@ -1120,6 +1129,8 @@ const output_prefix_fs = 'zFSOutput_';
|
|
|
1120
1129
|
const exp = new PBShaderExp(u.block.exp.$str, u.block.exp.$ast.getType());
|
|
1121
1130
|
exp.$declareType = u.block.exp.$declareType;
|
|
1122
1131
|
exp.$isBuffer = u.block.exp.$isBuffer;
|
|
1132
|
+
exp.$bindingSize = u.block.exp.$bindingSize;
|
|
1133
|
+
exp.$readonly = u.block.exp.$readonly;
|
|
1123
1134
|
sharedUniformList[u.group].push({
|
|
1124
1135
|
member: exp,
|
|
1125
1136
|
uniform: i
|
|
@@ -1132,6 +1143,8 @@ const output_prefix_fs = 'zFSOutput_';
|
|
|
1132
1143
|
const exp = new PBShaderExp(u.block.exp.$str, u.block.exp.$ast.getType());
|
|
1133
1144
|
exp.$declareType = u.block.exp.$declareType;
|
|
1134
1145
|
exp.$isBuffer = u.block.exp.$isBuffer;
|
|
1146
|
+
exp.$bindingSize = u.block.exp.$bindingSize;
|
|
1147
|
+
exp.$readonly = u.block.exp.$readonly;
|
|
1135
1148
|
vertexUniformList[u.group].push({
|
|
1136
1149
|
member: exp,
|
|
1137
1150
|
uniform: i
|
|
@@ -1144,6 +1157,8 @@ const output_prefix_fs = 'zFSOutput_';
|
|
|
1144
1157
|
const exp = new PBShaderExp(u.block.exp.$str, u.block.exp.$ast.getType());
|
|
1145
1158
|
exp.$declareType = u.block.exp.$declareType;
|
|
1146
1159
|
exp.$isBuffer = u.block.exp.$isBuffer;
|
|
1160
|
+
exp.$bindingSize = u.block.exp.$bindingSize;
|
|
1161
|
+
exp.$readonly = u.block.exp.$readonly;
|
|
1147
1162
|
fragUniformList[u.group].push({
|
|
1148
1163
|
member: exp,
|
|
1149
1164
|
uniform: i
|
|
@@ -1206,21 +1221,27 @@ const output_prefix_fs = 'zFSOutput_';
|
|
|
1206
1221
|
const uname = `${nameList[j][i]}_${k}_${p}`;
|
|
1207
1222
|
const structName = this.generateStructureName();
|
|
1208
1223
|
const t = getCurrentProgramBuilder().internalDefineStruct(structName, layoutList[j], maskList[i], false, ...allLists[p].map((val)=>val.member));
|
|
1224
|
+
const readonly = j > 0 ? allLists[p].findIndex((val)=>!val.member.$readonly) < 0 : true;
|
|
1209
1225
|
if (maskList[i] & ShaderType.Vertex) {
|
|
1210
1226
|
const exp = t();
|
|
1227
|
+
if (j > 0 && !readonly) {
|
|
1228
|
+
throw new Error(`Storage buffer in vertex shader must be read-only`);
|
|
1229
|
+
}
|
|
1211
1230
|
if (j === 0) {
|
|
1212
|
-
exp.uniformBuffer(Number(k));
|
|
1231
|
+
exp.uniformBuffer(Number(k), p > 0 ? allLists[p][0].member.$bindingSize : 0);
|
|
1213
1232
|
} else {
|
|
1214
|
-
exp.storageBuffer(Number(k));
|
|
1233
|
+
exp.storageBuffer(Number(k), p > 0 ? allLists[p][0].member.$bindingSize : 0);
|
|
1234
|
+
exp.$readonly = readonly;
|
|
1215
1235
|
}
|
|
1216
1236
|
globalScopeVertex[uname] = exp;
|
|
1217
1237
|
}
|
|
1218
1238
|
if (maskList[i] & ShaderType.Fragment) {
|
|
1219
1239
|
const exp = t();
|
|
1220
1240
|
if (j === 0) {
|
|
1221
|
-
exp.uniformBuffer(Number(k));
|
|
1241
|
+
exp.uniformBuffer(Number(k), p > 0 ? allLists[p][0].member.$bindingSize : 0);
|
|
1222
1242
|
} else {
|
|
1223
|
-
exp.storageBuffer(Number(k));
|
|
1243
|
+
exp.storageBuffer(Number(k), p > 0 ? allLists[p][0].member.$bindingSize : 0);
|
|
1244
|
+
exp.$readonly = readonly;
|
|
1224
1245
|
}
|
|
1225
1246
|
globalScopeFragmet[uname] = exp;
|
|
1226
1247
|
}
|
|
@@ -1291,6 +1312,12 @@ const output_prefix_fs = 'zFSOutput_';
|
|
|
1291
1312
|
}
|
|
1292
1313
|
/** @internal */ createBindGroupLayouts(label) {
|
|
1293
1314
|
const layouts = [];
|
|
1315
|
+
const dynamicOffsetIndex = [
|
|
1316
|
+
0,
|
|
1317
|
+
0,
|
|
1318
|
+
0,
|
|
1319
|
+
0
|
|
1320
|
+
];
|
|
1294
1321
|
for (const uniformInfo of this._uniforms){
|
|
1295
1322
|
let layout = layouts[uniformInfo.group];
|
|
1296
1323
|
if (!layout) {
|
|
@@ -1313,9 +1340,11 @@ const output_prefix_fs = 'zFSOutput_';
|
|
|
1313
1340
|
entry.type = uniformInfo.block.exp.$typeinfo.clone(this.getBlockName(uniformInfo.block.name));
|
|
1314
1341
|
const isStorage = uniformInfo.block.exp.$declareType === DeclareType.DECLARE_TYPE_STORAGE;
|
|
1315
1342
|
entry.buffer = {
|
|
1316
|
-
type: isStorage ? uniformInfo.block.exp.$
|
|
1317
|
-
|
|
1318
|
-
|
|
1343
|
+
type: isStorage ? uniformInfo.block.exp.$readonly ? 'read-only-storage' : 'storage' : 'uniform',
|
|
1344
|
+
minBindingSize: uniformInfo.block.bindingSize,
|
|
1345
|
+
hasDynamicOffset: !!uniformInfo.block.bindingSize,
|
|
1346
|
+
uniformLayout: entry.type.toBufferLayout(0, entry.type.layout),
|
|
1347
|
+
dynamicOffsetIndex: !!uniformInfo.block.bindingSize ? dynamicOffsetIndex[uniformInfo.group]++ : -1
|
|
1319
1348
|
};
|
|
1320
1349
|
entry.name = uniformInfo.block.name;
|
|
1321
1350
|
} else if (uniformInfo.texture) {
|
|
@@ -1593,7 +1622,7 @@ const output_prefix_fs = 'zFSOutput_';
|
|
|
1593
1622
|
} else {
|
|
1594
1623
|
uniformInfo.block = {
|
|
1595
1624
|
name: name,
|
|
1596
|
-
|
|
1625
|
+
bindingSize: variable.$bindingSize,
|
|
1597
1626
|
exp: variable
|
|
1598
1627
|
};
|
|
1599
1628
|
// throw new Error(`unsupported uniform type: ${name}`);
|
|
@@ -1768,7 +1797,7 @@ const output_prefix_fs = 'zFSOutput_';
|
|
|
1768
1797
|
this[prop] = value;
|
|
1769
1798
|
return true;
|
|
1770
1799
|
}
|
|
1771
|
-
if (!(this.$_scope instanceof PBGlobalScope) && value instanceof PBShaderExp && (value.isConstructor() || value.$typeinfo.isTextureType() && value.$ast instanceof ASTPrimitive && !value.$ast.name) && value.$declareType === DeclareType.DECLARE_TYPE_UNIFORM) {
|
|
1800
|
+
if (!(this.$_scope instanceof PBGlobalScope) && value instanceof PBShaderExp && (value.isConstructor() || value.$typeinfo.isTextureType() && value.$ast instanceof ASTPrimitive && !value.$ast.name) && (value.$declareType === DeclareType.DECLARE_TYPE_UNIFORM || value.$declareType === DeclareType.DECLARE_TYPE_STORAGE)) {
|
|
1772
1801
|
// We are setting uniform a uniform, should invoke in the global scope
|
|
1773
1802
|
this.$g[prop] = value;
|
|
1774
1803
|
return true;
|
|
@@ -1783,6 +1812,8 @@ const output_prefix_fs = 'zFSOutput_';
|
|
|
1783
1812
|
if (value instanceof PBShaderExp && !this.$_scope.$parent) {
|
|
1784
1813
|
exp.$declareType = value.$declareType;
|
|
1785
1814
|
exp.$isBuffer = value.$isBuffer;
|
|
1815
|
+
exp.$bindingSize = value.$bindingSize;
|
|
1816
|
+
exp.$readonly = value.$readonly;
|
|
1786
1817
|
exp.$group = value.$group;
|
|
1787
1818
|
exp.$attrib = value.$attrib;
|
|
1788
1819
|
exp.$sampleType = value.$sampleType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"programbuilder.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"programbuilder.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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HANGED
|
@@ -408,6 +408,9 @@ var PBTypeClass;
|
|
|
408
408
|
/** returns true if this is a primitive type */ isPrimitiveType() {
|
|
409
409
|
return false;
|
|
410
410
|
}
|
|
411
|
+
/** Wether this type have atomic members */ haveAtomicMembers() {
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
411
414
|
/** returns true if this is a struct type */ isStructType() {
|
|
412
415
|
return false;
|
|
413
416
|
}
|
|
@@ -828,6 +831,17 @@ var PBTypeClass;
|
|
|
828
831
|
/** Get member types of the struct type */ get structMembers() {
|
|
829
832
|
return this.detail.structMembers;
|
|
830
833
|
}
|
|
834
|
+
/** Whether this struct has atomic members */ haveAtomicMembers() {
|
|
835
|
+
for (const member of this.structMembers){
|
|
836
|
+
if (member.type.isStructType() && member.type.haveAtomicMembers()) {
|
|
837
|
+
return true;
|
|
838
|
+
} else if (member.type.isArrayType() && member.type.haveAtomicMembers()) {
|
|
839
|
+
return true;
|
|
840
|
+
} else {
|
|
841
|
+
return member.type.isAtomicI32() || member.type.isAtomicU32();
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
831
845
|
/**
|
|
832
846
|
* Creates a new struct type by extending this type
|
|
833
847
|
* @param name - Name of the new struct type
|
|
@@ -873,17 +887,6 @@ var PBTypeClass;
|
|
|
873
887
|
return varName ? `${this.structName} ${varName}` : this.structName;
|
|
874
888
|
}
|
|
875
889
|
}
|
|
876
|
-
/** @internal */ isWritable() {
|
|
877
|
-
for (const member of this.structMembers){
|
|
878
|
-
if (member.type.isAtomicI32() || member.type.isAtomicU32()) {
|
|
879
|
-
return true;
|
|
880
|
-
}
|
|
881
|
-
if (member.type.isStructType() && member.type.isWritable()) {
|
|
882
|
-
return true;
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
return false;
|
|
886
|
-
}
|
|
887
890
|
/** @internal */ getLayoutAlignment(layout) {
|
|
888
891
|
if (layout === 'packed') {
|
|
889
892
|
return 1;
|
|
@@ -997,6 +1000,13 @@ var PBTypeClass;
|
|
|
997
1000
|
/** Get dimension of the array type */ get dimension() {
|
|
998
1001
|
return this.detail.dimension;
|
|
999
1002
|
}
|
|
1003
|
+
/** Wether array have atomic members */ haveAtomicMembers() {
|
|
1004
|
+
if (this.elementType.isStructType() || this.elementType.isArrayType()) {
|
|
1005
|
+
return this.elementType.haveAtomicMembers();
|
|
1006
|
+
} else {
|
|
1007
|
+
return this.elementType.isAtomicI32() || this.elementType.isAtomicU32();
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1000
1010
|
/** {@inheritDoc PBTypeInfo.isArrayType} */ isArrayType() {
|
|
1001
1011
|
return true;
|
|
1002
1012
|
}
|
|
@@ -1087,6 +1097,9 @@ var PBTypeClass;
|
|
|
1087
1097
|
this.id = null;
|
|
1088
1098
|
}
|
|
1089
1099
|
}
|
|
1100
|
+
/** {@inheritDoc PBTypeInfo.haveAtomicMembers} */ haveAtomicMembers() {
|
|
1101
|
+
return this.pointerType.haveAtomicMembers();
|
|
1102
|
+
}
|
|
1090
1103
|
/** {@inheritDoc PBTypeInfo.isPointerType} */ isPointerType() {
|
|
1091
1104
|
return true;
|
|
1092
1105
|
}
|
|
@@ -1121,6 +1134,9 @@ var PBTypeClass;
|
|
|
1121
1134
|
constructor(){
|
|
1122
1135
|
super(PBTypeClass.ATOMIC_I32, null);
|
|
1123
1136
|
}
|
|
1137
|
+
/** {@inheritDoc PBTypeInfo.isPointerType} */ haveAtomicMembers() {
|
|
1138
|
+
return true;
|
|
1139
|
+
}
|
|
1124
1140
|
/** @internal */ isAtomicI32() {
|
|
1125
1141
|
return true;
|
|
1126
1142
|
}
|
|
@@ -1161,6 +1177,9 @@ var PBTypeClass;
|
|
|
1161
1177
|
constructor(){
|
|
1162
1178
|
super(PBTypeClass.ATOMIC_U32, null);
|
|
1163
1179
|
}
|
|
1180
|
+
/** {@inheritDoc PBTypeInfo.isPointerType} */ haveAtomicMembers() {
|
|
1181
|
+
return true;
|
|
1182
|
+
}
|
|
1164
1183
|
/** @internal */ isAtomicU32() {
|
|
1165
1184
|
return true;
|
|
1166
1185
|
}
|
|
@@ -1250,9 +1269,15 @@ var PBTypeClass;
|
|
|
1250
1269
|
/** Returns true if this is a readable storage texture type */ get readable() {
|
|
1251
1270
|
return this.detail.readable;
|
|
1252
1271
|
}
|
|
1272
|
+
set readable(val) {
|
|
1273
|
+
this.detail.readable = !!val;
|
|
1274
|
+
}
|
|
1253
1275
|
/** Returns true if this is a writable storage texture type */ get writable() {
|
|
1254
1276
|
return this.detail.writable;
|
|
1255
1277
|
}
|
|
1278
|
+
set writable(val) {
|
|
1279
|
+
this.detail.writable = !!val;
|
|
1280
|
+
}
|
|
1256
1281
|
/** @internal */ isStorable() {
|
|
1257
1282
|
return true;
|
|
1258
1283
|
}
|
|
@@ -1298,7 +1323,7 @@ var PBTypeClass;
|
|
|
1298
1323
|
if (this.isStorageTexture()) {
|
|
1299
1324
|
const storageTexelFormat = storageTexelFormatMap[this.storageTexelFormat];
|
|
1300
1325
|
// storage textures currently only support 'write' access control
|
|
1301
|
-
const accessMode = 'write'; //this.readable ? (this.writable ? 'read_write' : 'read') : 'write';
|
|
1326
|
+
const accessMode = this.writable ? this.readable ? 'read_write' : 'write' : 'read'; // this.readable ? (this.writable ? 'read_write' : 'read') : 'write';
|
|
1302
1327
|
typename = `${typename}<${storageTexelFormat}, ${accessMode}>`;
|
|
1303
1328
|
}
|
|
1304
1329
|
return varName ? `${varName}: ${typename}` : typename;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/device.js
CHANGED
|
@@ -59,7 +59,8 @@ import { DrawText } from './helpers/drawtext.js';
|
|
|
59
59
|
FPS: 0,
|
|
60
60
|
drawCalls: 0,
|
|
61
61
|
computeCalls: 0,
|
|
62
|
-
nextFrameCall: []
|
|
62
|
+
nextFrameCall: [],
|
|
63
|
+
nextFrameCallNext: []
|
|
63
64
|
};
|
|
64
65
|
this._programBuilder = new ProgramBuilder(this);
|
|
65
66
|
this._cpuTimer = new CPUTimer();
|
|
@@ -222,12 +223,6 @@ import { DrawText } from './helpers/drawtext.js';
|
|
|
222
223
|
this._frameInfo.nextFrameCall.push(f);
|
|
223
224
|
}
|
|
224
225
|
}
|
|
225
|
-
cancelNextFrameCall(f) {
|
|
226
|
-
const index = this._frameInfo.nextFrameCall.indexOf(f);
|
|
227
|
-
if (index >= 0) {
|
|
228
|
-
this._frameInfo.nextFrameCall.splice(index, 1);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
226
|
exitLoop() {
|
|
232
227
|
if (this._runningLoop) {
|
|
233
228
|
cancelAnimationFrame(this._runningLoop);
|
|
@@ -407,10 +402,13 @@ import { DrawText } from './helpers/drawtext.js';
|
|
|
407
402
|
this._frameInfo.elapsedTimeCPU = cpuTime;
|
|
408
403
|
}
|
|
409
404
|
}
|
|
410
|
-
|
|
405
|
+
const tmp = this._frameInfo.nextFrameCall;
|
|
406
|
+
this._frameInfo.nextFrameCall = this._frameInfo.nextFrameCallNext;
|
|
407
|
+
this._frameInfo.nextFrameCallNext = tmp;
|
|
408
|
+
for (const f of this._frameInfo.nextFrameCallNext){
|
|
411
409
|
f();
|
|
412
410
|
}
|
|
413
|
-
this._frameInfo.
|
|
411
|
+
this._frameInfo.nextFrameCallNext.length = 0;
|
|
414
412
|
}
|
|
415
413
|
getGPUObjectList(obj) {
|
|
416
414
|
let list = null;
|
package/dist/device.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"device.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -178,7 +178,7 @@ interface StructTypeDetail {
|
|
|
178
178
|
*/
|
|
179
179
|
interface ArrayTypeDetail {
|
|
180
180
|
/** Type of array elements */
|
|
181
|
-
elementType: PBPrimitiveTypeInfo | PBArrayTypeInfo | PBStructTypeInfo | PBAnyTypeInfo;
|
|
181
|
+
elementType: PBPrimitiveTypeInfo | PBArrayTypeInfo | PBStructTypeInfo | PBAnyTypeInfo | PBAtomicI32TypeInfo | PBAtomicU32TypeInfo;
|
|
182
182
|
/** Array dimension */
|
|
183
183
|
dimension: number;
|
|
184
184
|
}
|
|
@@ -252,6 +252,8 @@ declare abstract class PBTypeInfo<DetailType extends TypeDetailInfo = TypeDetail
|
|
|
252
252
|
isAnyType(): this is PBAnyTypeInfo;
|
|
253
253
|
/** returns true if this is a primitive type */
|
|
254
254
|
isPrimitiveType(): this is PBPrimitiveTypeInfo;
|
|
255
|
+
/** Wether this type have atomic members */
|
|
256
|
+
haveAtomicMembers(): boolean;
|
|
255
257
|
/** returns true if this is a struct type */
|
|
256
258
|
isStructType(): this is PBStructTypeInfo;
|
|
257
259
|
/** returns true if this is an array type */
|
|
@@ -371,6 +373,8 @@ declare class PBStructTypeInfo extends PBTypeInfo<StructTypeDetail> {
|
|
|
371
373
|
/** @internal */
|
|
372
374
|
defaultSize: number;
|
|
373
375
|
}[];
|
|
376
|
+
/** Whether this struct has atomic members */
|
|
377
|
+
haveAtomicMembers(): boolean;
|
|
374
378
|
/**
|
|
375
379
|
* Creates a new struct type by extending this type
|
|
376
380
|
* @param name - Name of the new struct type
|
|
@@ -391,11 +395,13 @@ declare class PBStructTypeInfo extends PBTypeInfo<StructTypeDetail> {
|
|
|
391
395
|
* @public
|
|
392
396
|
*/
|
|
393
397
|
declare class PBArrayTypeInfo extends PBTypeInfo<ArrayTypeDetail> {
|
|
394
|
-
constructor(elementType: PBPrimitiveTypeInfo | PBArrayTypeInfo | PBStructTypeInfo | PBAnyTypeInfo, dimension?: number);
|
|
398
|
+
constructor(elementType: PBPrimitiveTypeInfo | PBArrayTypeInfo | PBStructTypeInfo | PBAnyTypeInfo | PBAtomicI32TypeInfo | PBAtomicU32TypeInfo, dimension?: number);
|
|
395
399
|
/** Get the element type */
|
|
396
|
-
get elementType(): PBPrimitiveTypeInfo | PBArrayTypeInfo | PBStructTypeInfo | PBAnyTypeInfo;
|
|
400
|
+
get elementType(): PBPrimitiveTypeInfo | PBArrayTypeInfo | PBStructTypeInfo | PBAnyTypeInfo | PBAtomicI32TypeInfo | PBAtomicU32TypeInfo;
|
|
397
401
|
/** Get dimension of the array type */
|
|
398
402
|
get dimension(): number;
|
|
403
|
+
/** Wether array have atomic members */
|
|
404
|
+
haveAtomicMembers(): boolean;
|
|
399
405
|
/** {@inheritDoc PBTypeInfo.isArrayType} */
|
|
400
406
|
isArrayType(): this is PBArrayTypeInfo;
|
|
401
407
|
/** {@inheritDoc PBTypeInfo.toBufferLayout} */
|
|
@@ -413,6 +419,8 @@ declare class PBPointerTypeInfo extends PBTypeInfo<PointerTypeDetail> {
|
|
|
413
419
|
/** Get address space of the pointer */
|
|
414
420
|
get addressSpace(): PBAddressSpace;
|
|
415
421
|
set addressSpace(val: PBAddressSpace);
|
|
422
|
+
/** {@inheritDoc PBTypeInfo.haveAtomicMembers} */
|
|
423
|
+
haveAtomicMembers(): boolean;
|
|
416
424
|
/** {@inheritDoc PBTypeInfo.isPointerType} */
|
|
417
425
|
isPointerType(): this is PBPointerTypeInfo;
|
|
418
426
|
/** {@inheritDoc PBTypeInfo.toBufferLayout} */
|
|
@@ -424,6 +432,8 @@ declare class PBPointerTypeInfo extends PBTypeInfo<PointerTypeDetail> {
|
|
|
424
432
|
*/
|
|
425
433
|
declare class PBAtomicI32TypeInfo extends PBTypeInfo<null> {
|
|
426
434
|
constructor();
|
|
435
|
+
/** {@inheritDoc PBTypeInfo.isPointerType} */
|
|
436
|
+
haveAtomicMembers(): boolean;
|
|
427
437
|
/** {@inheritDoc PBTypeInfo.toBufferLayout} */
|
|
428
438
|
toBufferLayout(offset: number): UniformBufferLayout;
|
|
429
439
|
}
|
|
@@ -433,6 +443,8 @@ declare class PBAtomicI32TypeInfo extends PBTypeInfo<null> {
|
|
|
433
443
|
*/
|
|
434
444
|
declare class PBAtomicU32TypeInfo extends PBTypeInfo<null> {
|
|
435
445
|
constructor();
|
|
446
|
+
/** {@inheritDoc PBTypeInfo.isPointerType} */
|
|
447
|
+
haveAtomicMembers(): boolean;
|
|
436
448
|
/** {@inheritDoc PBTypeInfo.toBufferLayout} */
|
|
437
449
|
toBufferLayout(offset: number): UniformBufferLayout;
|
|
438
450
|
}
|
|
@@ -459,8 +471,10 @@ declare class PBTextureTypeInfo extends PBTypeInfo<TextureTypeDetail> {
|
|
|
459
471
|
get storageTexelFormat(): TextureFormat;
|
|
460
472
|
/** Returns true if this is a readable storage texture type */
|
|
461
473
|
get readable(): boolean;
|
|
474
|
+
set readable(val: boolean);
|
|
462
475
|
/** Returns true if this is a writable storage texture type */
|
|
463
476
|
get writable(): boolean;
|
|
477
|
+
set writable(val: boolean);
|
|
464
478
|
/** Returns true if this is a 2D texture type */
|
|
465
479
|
is2DTexture(): boolean;
|
|
466
480
|
/** Returns true if this is a 3D texture type */
|
|
@@ -838,6 +852,8 @@ interface BufferBindingLayout {
|
|
|
838
852
|
uniformLayout: UniformBufferLayout;
|
|
839
853
|
/** minimum binding size of the buffer */
|
|
840
854
|
minBindingSize?: number;
|
|
855
|
+
/** dynamic offset index */
|
|
856
|
+
dynamicOffsetIndex: number;
|
|
841
857
|
}
|
|
842
858
|
/**
|
|
843
859
|
* Binding layout of a sampler
|
|
@@ -1117,6 +1133,7 @@ interface FrameBuffer<T = unknown> extends GPUObject<T> {
|
|
|
1117
1133
|
getWidth(): number;
|
|
1118
1134
|
getHeight(): number;
|
|
1119
1135
|
getSampleCount(): number;
|
|
1136
|
+
getHash(): string;
|
|
1120
1137
|
setColorAttachmentCubeFace(index: number, face: CubeFace): void;
|
|
1121
1138
|
setColorAttachmentMipLevel(index: number, level: number): void;
|
|
1122
1139
|
setColorAttachmentLayer(index: number, layer: number): void;
|
|
@@ -1154,15 +1171,22 @@ type StructuredValue = number | TypedArray | VectorBase | {
|
|
|
1154
1171
|
*/
|
|
1155
1172
|
interface BindGroup extends GPUObject<unknown> {
|
|
1156
1173
|
getLayout(): BindGroupLayout;
|
|
1174
|
+
getDynamicOffsets(): number[];
|
|
1175
|
+
getGPUId(): string;
|
|
1157
1176
|
getBuffer(name: string): GPUDataBuffer;
|
|
1158
1177
|
getTexture(name: string): BaseTexture;
|
|
1159
|
-
setBuffer(name: string, buffer: GPUDataBuffer): void;
|
|
1178
|
+
setBuffer(name: string, buffer: GPUDataBuffer, offset?: number, bindOffset?: number, bindSize?: number): void;
|
|
1160
1179
|
setValue(name: string, value: StructuredValue): any;
|
|
1161
1180
|
setRawData(name: string, byteOffset: number, data: TypedArray, srcPos?: number, srcLength?: number): any;
|
|
1162
1181
|
setTexture(name: string, texture: BaseTexture, sampler?: TextureSampler): any;
|
|
1163
1182
|
setTextureView(name: string, value: BaseTexture, level?: number, face?: number, mipCount?: number, sampler?: TextureSampler): any;
|
|
1164
1183
|
setSampler(name: string, sampler: TextureSampler): any;
|
|
1165
1184
|
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Render bundle
|
|
1187
|
+
* @public
|
|
1188
|
+
*/
|
|
1189
|
+
type RenderBundle = unknown;
|
|
1166
1190
|
/**
|
|
1167
1191
|
* Creates the default name for the type of given gpu object
|
|
1168
1192
|
* @param obj - The gpu object
|
|
@@ -1213,7 +1237,7 @@ declare class PBShaderExp extends Proxiable<PBShaderExp> {
|
|
|
1213
1237
|
* @param group - The bind group index
|
|
1214
1238
|
* @returns self
|
|
1215
1239
|
*/
|
|
1216
|
-
uniformBuffer(group: number): PBShaderExp;
|
|
1240
|
+
uniformBuffer(group: number, bindingSize?: number): PBShaderExp;
|
|
1217
1241
|
/**
|
|
1218
1242
|
* Point out that the variable should be in workgroup address space
|
|
1219
1243
|
*
|
|
@@ -1229,12 +1253,24 @@ declare class PBShaderExp extends Proxiable<PBShaderExp> {
|
|
|
1229
1253
|
* @returns self
|
|
1230
1254
|
*/
|
|
1231
1255
|
storage(group: number): PBShaderExp;
|
|
1256
|
+
/**
|
|
1257
|
+
* Point out that the variable is read-only and should be in storage address space
|
|
1258
|
+
* @param group - The bind group index
|
|
1259
|
+
* @returns self
|
|
1260
|
+
*/
|
|
1261
|
+
storageReadonly(group: number): PBShaderExp;
|
|
1232
1262
|
/**
|
|
1233
1263
|
* Point out that the variable should be a storage buffer
|
|
1234
1264
|
* @param group - The bind group index
|
|
1235
1265
|
* @returns self
|
|
1236
1266
|
*/
|
|
1237
|
-
storageBuffer(group: number): PBShaderExp;
|
|
1267
|
+
storageBuffer(group: number, bindingSize?: number): PBShaderExp;
|
|
1268
|
+
/**
|
|
1269
|
+
* Point out that the variable is read-only and should be a storage buffer
|
|
1270
|
+
* @param group - The bind group index
|
|
1271
|
+
* @returns self
|
|
1272
|
+
*/
|
|
1273
|
+
storageBufferReadonly(group: number, bindingSize?: number): PBShaderExp;
|
|
1238
1274
|
inout(): PBShaderExp;
|
|
1239
1275
|
out(): PBShaderExp;
|
|
1240
1276
|
/**
|
|
@@ -1508,6 +1544,26 @@ interface ProgramBuilder {
|
|
|
1508
1544
|
* @returns the 'referenceOf' expression
|
|
1509
1545
|
*/
|
|
1510
1546
|
referenceOf(ptr: PBShaderExp): PBShaderExp;
|
|
1547
|
+
/** Atomic int type variable constructors */
|
|
1548
|
+
atomic_int: {
|
|
1549
|
+
(): PBShaderExp;
|
|
1550
|
+
(rhs: number): PBShaderExp;
|
|
1551
|
+
(rhs: boolean): PBShaderExp;
|
|
1552
|
+
(rhs: PBShaderExp): PBShaderExp;
|
|
1553
|
+
(name: string): PBShaderExp;
|
|
1554
|
+
ptr: ShaderTypeFunc;
|
|
1555
|
+
[dim: number]: ShaderTypeFunc;
|
|
1556
|
+
};
|
|
1557
|
+
/** Atomic uint type variable constructors */
|
|
1558
|
+
atomic_uint: {
|
|
1559
|
+
(): PBShaderExp;
|
|
1560
|
+
(rhs: number): PBShaderExp;
|
|
1561
|
+
(rhs: boolean): PBShaderExp;
|
|
1562
|
+
(rhs: PBShaderExp): PBShaderExp;
|
|
1563
|
+
(name: string): PBShaderExp;
|
|
1564
|
+
ptr: ShaderTypeFunc;
|
|
1565
|
+
[dim: number]: ShaderTypeFunc;
|
|
1566
|
+
};
|
|
1511
1567
|
/** float type variable constructors */
|
|
1512
1568
|
float: {
|
|
1513
1569
|
(): PBShaderExp;
|
|
@@ -1968,13 +2024,13 @@ interface ProgramBuilder {
|
|
|
1968
2024
|
arrayLength(x: PBShaderExp): PBShaderExp;
|
|
1969
2025
|
/** Same as the select builtin function in WGSL, only valid for WebGPU device */
|
|
1970
2026
|
select(x: number | PBShaderExp, y: number | PBShaderExp, cond: boolean | PBShaderExp): PBShaderExp;
|
|
1971
|
-
/** Same as floatBitsToInt builtin function in GLSL, only valid for WebGL2 device */
|
|
2027
|
+
/** Same as floatBitsToInt builtin function in GLSL, only valid for WebGL2 device and WebGPU device */
|
|
1972
2028
|
floatBitsToInt(x: number | PBShaderExp): PBShaderExp;
|
|
1973
|
-
/** Same as floatBitsToUint builtin function in GLSL, only valid for WebGL2 device */
|
|
2029
|
+
/** Same as floatBitsToUint builtin function in GLSL, only valid for WebGL2 device and WebGPU device */
|
|
1974
2030
|
floatBitsToUint(x: number | PBShaderExp): PBShaderExp;
|
|
1975
|
-
/** Same as intBitsToFloat builtin function in GLSL, only valid for WebGL2 device */
|
|
2031
|
+
/** Same as intBitsToFloat builtin function in GLSL, only valid for WebGL2 device and WebGPU device */
|
|
1976
2032
|
intBitsToFloat(x: number | PBShaderExp): PBShaderExp;
|
|
1977
|
-
/** Same as uintBitsToFloat builtin function in GLSL, only valid for WebGL2 device */
|
|
2033
|
+
/** Same as uintBitsToFloat builtin function in GLSL, only valid for WebGL2 device and WebGPU device */
|
|
1978
2034
|
uintBitsToFloat(x: number | PBShaderExp): PBShaderExp;
|
|
1979
2035
|
/** Same as pack4x8snorm builtin function in WGSL, only valid for WebGPU device */
|
|
1980
2036
|
pack4x8snorm(x: PBShaderExp): PBShaderExp;
|
|
@@ -2088,6 +2144,8 @@ interface ProgramBuilder {
|
|
|
2088
2144
|
atomicOr(ptr: PBShaderExp, value: number | PBShaderExp): PBShaderExp;
|
|
2089
2145
|
/** atomicXor, only valid for WebGPU device */
|
|
2090
2146
|
atomicXor(ptr: PBShaderExp, value: number | PBShaderExp): PBShaderExp;
|
|
2147
|
+
/** atomicExchange, only valid for WebGPU device */
|
|
2148
|
+
atomicExchange(ptr: PBShaderExp, value: number | PBShaderExp): PBShaderExp;
|
|
2091
2149
|
}
|
|
2092
2150
|
/**
|
|
2093
2151
|
* The program builder class
|
|
@@ -2564,7 +2622,9 @@ interface StencilState {
|
|
|
2564
2622
|
* @public
|
|
2565
2623
|
*/
|
|
2566
2624
|
interface RenderStateSet {
|
|
2567
|
-
/** Creates a new RenderStateSet by
|
|
2625
|
+
/** Creates a new RenderStateSet object by deep copy from this object */
|
|
2626
|
+
clone(): RenderStateSet;
|
|
2627
|
+
/** Shallow copy existing RenderStateSet object to this */
|
|
2568
2628
|
copyFrom(stateSet: RenderStateSet): void;
|
|
2569
2629
|
/** Fragment output related render statements or null if the default values should be used */
|
|
2570
2630
|
readonly colorState: ColorState;
|
|
@@ -2898,6 +2958,10 @@ interface ShaderCaps {
|
|
|
2898
2958
|
maxUniformBufferSize: number;
|
|
2899
2959
|
/** The uniform buffer offset alignment */
|
|
2900
2960
|
uniformBufferOffsetAlignment: number;
|
|
2961
|
+
/** The maximum number of bytes of storage buffer */
|
|
2962
|
+
maxStorageBufferSize: number;
|
|
2963
|
+
/** The storage buffer offset alignment */
|
|
2964
|
+
storageBufferOffsetAlignment: number;
|
|
2901
2965
|
}
|
|
2902
2966
|
/**
|
|
2903
2967
|
* Information of a texture format
|
|
@@ -3250,6 +3314,15 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3250
3314
|
* @param options - The creation options
|
|
3251
3315
|
*/
|
|
3252
3316
|
createBuffer(sizeInBytes: number, options: BufferCreationOptions): GPUDataBuffer;
|
|
3317
|
+
/**
|
|
3318
|
+
* Copies a buffer to another buffer
|
|
3319
|
+
* @param sourceBuffer - Source buffer
|
|
3320
|
+
* @param destBuffer - destination buffer
|
|
3321
|
+
* @param srcOffset - Source offset in bytes
|
|
3322
|
+
* @param dstOffset - Destination offset in bytes
|
|
3323
|
+
* @param bytes - How many bytes to be copy
|
|
3324
|
+
*/
|
|
3325
|
+
copyBuffer(sourceBuffer: GPUDataBuffer, destBuffer: GPUDataBuffer, srcOffset: number, dstOffset: number, bytes: number): any;
|
|
3253
3326
|
/**
|
|
3254
3327
|
* Creates an index buffer
|
|
3255
3328
|
* @param data - Data of the index buffer
|
|
@@ -3367,6 +3440,20 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3367
3440
|
* @param buffer - The output buffer
|
|
3368
3441
|
*/
|
|
3369
3442
|
readPixelsToBuffer(index: number, x: number, y: number, w: number, h: number, buffer: GPUDataBuffer): void;
|
|
3443
|
+
/**
|
|
3444
|
+
* Begin capture draw commands
|
|
3445
|
+
*/
|
|
3446
|
+
beginCapture(): void;
|
|
3447
|
+
/**
|
|
3448
|
+
* Executes render bundle
|
|
3449
|
+
* @param renderBundle - RenderBundle to be execute
|
|
3450
|
+
*/
|
|
3451
|
+
executeRenderBundle(renderBundle: RenderBundle): any;
|
|
3452
|
+
/**
|
|
3453
|
+
* End capture draw commands
|
|
3454
|
+
* @returns A RenderBundle that holds the captured draw commands
|
|
3455
|
+
*/
|
|
3456
|
+
endCapture(): RenderBundle;
|
|
3370
3457
|
/** Get the video memory usage in bytes */
|
|
3371
3458
|
videoMemoryUsage: number;
|
|
3372
3459
|
/** Get the current frame information */
|
|
@@ -3450,12 +3537,6 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3450
3537
|
* @param f - The function to be scheduled
|
|
3451
3538
|
*/
|
|
3452
3539
|
runNextFrame(f: () => void): void;
|
|
3453
|
-
/**
|
|
3454
|
-
* Canels a pre scheduled function
|
|
3455
|
-
*
|
|
3456
|
-
* @param f - The function to be cancled
|
|
3457
|
-
*/
|
|
3458
|
-
cancelNextFrameCall(f: () => void): void;
|
|
3459
3540
|
/** Exits from current rendering loop */
|
|
3460
3541
|
exitLoop(): void;
|
|
3461
3542
|
/**
|
|
@@ -3588,6 +3669,7 @@ declare abstract class BaseDevice {
|
|
|
3588
3669
|
abstract createGPUProgram(params: GPUProgramConstructParams): GPUProgram;
|
|
3589
3670
|
abstract createBindGroup(layout: BindGroupLayout): BindGroup;
|
|
3590
3671
|
abstract createBuffer(sizeInBytes: number, options: BufferCreationOptions): GPUDataBuffer;
|
|
3672
|
+
abstract copyBuffer(sourceBuffer: GPUDataBuffer, destBuffer: GPUDataBuffer, srcOffset: number, dstOffset: number, bytes: number): any;
|
|
3591
3673
|
abstract createIndexBuffer(data: Uint16Array | Uint32Array, options?: BufferCreationOptions): IndexBuffer;
|
|
3592
3674
|
abstract createStructuredBuffer(structureType: PBStructTypeInfo, options: BufferCreationOptions, data?: TypedArray): StructuredBuffer;
|
|
3593
3675
|
abstract createVertexLayout(options: VertexLayoutOptions): VertexLayout;
|
|
@@ -3609,6 +3691,9 @@ declare abstract class BaseDevice {
|
|
|
3609
3691
|
abstract flush(): void;
|
|
3610
3692
|
abstract readPixels(index: number, x: number, y: number, w: number, h: number, buffer: TypedArray): Promise<void>;
|
|
3611
3693
|
abstract readPixelsToBuffer(index: number, x: number, y: number, w: number, h: number, buffer: GPUDataBuffer): void;
|
|
3694
|
+
abstract beginCapture(): void;
|
|
3695
|
+
abstract endCapture(): RenderBundle;
|
|
3696
|
+
abstract executeRenderBundle(renderBundle: RenderBundle): any;
|
|
3612
3697
|
abstract looseContext(): void;
|
|
3613
3698
|
abstract restoreContext(): void;
|
|
3614
3699
|
protected abstract _draw(primitiveType: PrimitiveType, first: number, count: number): void;
|
|
@@ -3636,7 +3721,6 @@ declare abstract class BaseDevice {
|
|
|
3636
3721
|
drawInstanced(primitiveType: PrimitiveType, first: number, count: number, numInstances: number): void;
|
|
3637
3722
|
compute(workgroupCountX: any, workgroupCountY: any, workgroupCountZ: any): void;
|
|
3638
3723
|
runNextFrame(f: () => void): void;
|
|
3639
|
-
cancelNextFrameCall(f: () => void): void;
|
|
3640
3724
|
exitLoop(): void;
|
|
3641
3725
|
runLoop(func: (device: AbstractDevice) => void): void;
|
|
3642
3726
|
pushDeviceStates(): void;
|
|
@@ -3879,4 +3963,4 @@ declare class StructuredBufferData {
|
|
|
3879
3963
|
set(name: string, value: StructuredValue): void;
|
|
3880
3964
|
}
|
|
3881
3965
|
|
|
3882
|
-
export { AbstractDevice, ArrayTypeDetail, AtlasInfo, AtomicTypeInfoDetail, BaseCreationOptions, BaseDevice, BaseTexture, BindGroup, BindGroupLayout, BindGroupLayoutEntry, BindPointInfo, BlendEquation, BlendFunc, BlendingState, BufferBindingLayout, BufferCreationOptions, BufferUsage, CPUTimer, ColorState, CompareFunc, ComputeProgramConstructParams, DataType, DepthState, DeviceBackend, DeviceCaps, DeviceEventMap, DeviceGPUObjectAddedEvent, DeviceGPUObjectRemovedEvent, DeviceGPUObjectRenameEvent, DeviceLostEvent, DeviceOptions, DeviceResizeEvent, DeviceRestoreEvent, DeviceViewport, DrawText, ExpValueNonArrayType, ExpValueType, ExternalTextureBindingLayout, FaceMode, FaceWinding, Font, FrameBuffer, FrameBufferOptions, FrameBufferTextureAttachment, FrameInfo, FramebufferCaps, FunctionTypeDetail, GPUDataBuffer, GPUObject, GPUObjectList, GPUProgram, GPUProgramConstructParams, GPUResourceUsageFlags, GlyphManager, ITimer, IndexBuffer, MiscCaps, PBAddressSpace, PBAnyTypeInfo, PBArrayTypeInfo, PBAtomicI32TypeInfo, PBAtomicU32TypeInfo, PBBuiltinScope, PBComputeOptions, PBDoWhileScope, PBForScope, PBFunctionScope, PBFunctionTypeInfo, PBGlobalScope, PBIfScope, PBInputScope, PBInsideFunctionScope, PBLocalScope, PBNakedScope, PBOutputScope, PBPointerTypeInfo, PBPrimitiveType, PBPrimitiveTypeInfo, PBReflection, PBReflectionTagGetter, PBRenderOptions, PBSamplerAccessMode, PBSamplerTypeInfo, PBScope, PBShaderExp, PBStructLayout, PBStructTypeInfo, PBTextureType, PBTextureTypeInfo, PBTypeInfo, PBVoidTypeInfo, PBWhileScope, PointerTypeDetail, PrimitiveType, PrimitiveTypeDetail, ProgramBuilder, Proxiable, RasterizerState, RenderProgramConstructParams, RenderStateSet, SamplerBindingLayout, SamplerOptions, SamplerTypeDetail, ShaderCaps, ShaderExpTagRecord, ShaderExpTagValue, ShaderKind, ShaderType, ShaderTypeFunc, StencilOp, StencilState, StorageTextureBindingLayout, StructTypeDetail, StructuredBuffer, StructuredBufferData, StructuredValue, Texture2D, Texture2DArray, Texture3D, TextureAddressMode, TextureAtlasManager, TextureBindingLayout, TextureCaps, TextureColorSpace, TextureCreationOptions, TextureCube, TextureFilterMode, TextureFormat, TextureFormatInfo, TextureImageElement, TextureMipmapData, TextureMipmapLevelData, TextureSampler, TextureType, TextureTypeDetail, TextureVideo, TypeDetailInfo, UniformBufferLayout, UniformLayout, VertexAttribFormat, VertexBufferInfo, VertexData, VertexLayout, VertexLayoutOptions, VertexSemantic, VertexStepMode, WebGLContext, genDefaultName, getTextureFormatBlockHeight, getTextureFormatBlockSize, getTextureFormatBlockWidth, getVertexAttribFormat, getVertexBufferAttribType, getVertexBufferAttribTypeBySemantic, getVertexBufferLength, getVertexBufferStride, hasAlphaChannel, hasBlueChannel, hasDepthChannel, hasGreenChannel, hasRedChannel, hasStencilChannel, isCompressedTextureFormat, isFloatTextureFormat, isIntegerTextureFormat, isSRGBTextureFormat, isSignedTextureFormat, linearTextureFormatToSRGB, makeVertexBufferType, semanticList };
|
|
3966
|
+
export { AbstractDevice, ArrayTypeDetail, AtlasInfo, AtomicTypeInfoDetail, BaseCreationOptions, BaseDevice, BaseTexture, BindGroup, BindGroupLayout, BindGroupLayoutEntry, BindPointInfo, BlendEquation, BlendFunc, BlendingState, BufferBindingLayout, BufferCreationOptions, BufferUsage, CPUTimer, ColorState, CompareFunc, ComputeProgramConstructParams, DataType, DepthState, DeviceBackend, DeviceCaps, DeviceEventMap, DeviceGPUObjectAddedEvent, DeviceGPUObjectRemovedEvent, DeviceGPUObjectRenameEvent, DeviceLostEvent, DeviceOptions, DeviceResizeEvent, DeviceRestoreEvent, DeviceViewport, DrawText, ExpValueNonArrayType, ExpValueType, ExternalTextureBindingLayout, FaceMode, FaceWinding, Font, FrameBuffer, FrameBufferOptions, FrameBufferTextureAttachment, FrameInfo, FramebufferCaps, FunctionTypeDetail, GPUDataBuffer, GPUObject, GPUObjectList, GPUProgram, GPUProgramConstructParams, GPUResourceUsageFlags, GlyphManager, ITimer, IndexBuffer, MiscCaps, PBAddressSpace, PBAnyTypeInfo, PBArrayTypeInfo, PBAtomicI32TypeInfo, PBAtomicU32TypeInfo, PBBuiltinScope, PBComputeOptions, PBDoWhileScope, PBForScope, PBFunctionScope, PBFunctionTypeInfo, PBGlobalScope, PBIfScope, PBInputScope, PBInsideFunctionScope, PBLocalScope, PBNakedScope, PBOutputScope, PBPointerTypeInfo, PBPrimitiveType, PBPrimitiveTypeInfo, PBReflection, PBReflectionTagGetter, PBRenderOptions, PBSamplerAccessMode, PBSamplerTypeInfo, PBScope, PBShaderExp, PBStructLayout, PBStructTypeInfo, PBTextureType, PBTextureTypeInfo, PBTypeInfo, PBVoidTypeInfo, PBWhileScope, PointerTypeDetail, PrimitiveType, PrimitiveTypeDetail, ProgramBuilder, Proxiable, RasterizerState, RenderBundle, RenderProgramConstructParams, RenderStateSet, SamplerBindingLayout, SamplerOptions, SamplerTypeDetail, ShaderCaps, ShaderExpTagRecord, ShaderExpTagValue, ShaderKind, ShaderType, ShaderTypeFunc, StencilOp, StencilState, StorageTextureBindingLayout, StructTypeDetail, StructuredBuffer, StructuredBufferData, StructuredValue, Texture2D, Texture2DArray, Texture3D, TextureAddressMode, TextureAtlasManager, TextureBindingLayout, TextureCaps, TextureColorSpace, TextureCreationOptions, TextureCube, TextureFilterMode, TextureFormat, TextureFormatInfo, TextureImageElement, TextureMipmapData, TextureMipmapLevelData, TextureSampler, TextureType, TextureTypeDetail, TextureVideo, TypeDetailInfo, UniformBufferLayout, UniformLayout, VertexAttribFormat, VertexBufferInfo, VertexData, VertexLayout, VertexLayoutOptions, VertexSemantic, VertexStepMode, WebGLContext, genDefaultName, getTextureFormatBlockHeight, getTextureFormatBlockSize, getTextureFormatBlockWidth, getVertexAttribFormat, getVertexBufferAttribType, getVertexBufferAttribTypeBySemantic, getVertexBufferLength, getVertexBufferStride, hasAlphaChannel, hasBlueChannel, hasDepthChannel, hasGreenChannel, hasRedChannel, hasStencilChannel, isCompressedTextureFormat, isFloatTextureFormat, isIntegerTextureFormat, isSRGBTextureFormat, isSignedTextureFormat, linearTextureFormatToSRGB, makeVertexBufferType, semanticList };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zephyr3d/device",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Device API for zephyr3d",
|
|
5
5
|
"homepage": "https://github.com/gavinyork/zephyr3d#readme",
|
|
6
6
|
"type": "module",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@types/node": "^18.13.0",
|
|
62
|
-
"@webgpu/types": "^0.1.
|
|
62
|
+
"@webgpu/types": "^0.1.40"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"clean": "shx rm -rf ./dist .tsbuildinfo",
|