@zephyr3d/device 0.1.0

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.
Files changed (40) hide show
  1. package/dist/base_types.js +602 -0
  2. package/dist/base_types.js.map +1 -0
  3. package/dist/builder/ast.js +2135 -0
  4. package/dist/builder/ast.js.map +1 -0
  5. package/dist/builder/base.js +477 -0
  6. package/dist/builder/base.js.map +1 -0
  7. package/dist/builder/builtinfunc.js +4101 -0
  8. package/dist/builder/builtinfunc.js.map +1 -0
  9. package/dist/builder/constructors.js +173 -0
  10. package/dist/builder/constructors.js.map +1 -0
  11. package/dist/builder/errors.js +148 -0
  12. package/dist/builder/errors.js.map +1 -0
  13. package/dist/builder/programbuilder.js +2323 -0
  14. package/dist/builder/programbuilder.js.map +1 -0
  15. package/dist/builder/reflection.js +60 -0
  16. package/dist/builder/reflection.js.map +1 -0
  17. package/dist/builder/types.js +1563 -0
  18. package/dist/builder/types.js.map +1 -0
  19. package/dist/device.js +515 -0
  20. package/dist/device.js.map +1 -0
  21. package/dist/gpuobject.js +2047 -0
  22. package/dist/gpuobject.js.map +1 -0
  23. package/dist/helpers/drawtext.js +187 -0
  24. package/dist/helpers/drawtext.js.map +1 -0
  25. package/dist/helpers/font.js +189 -0
  26. package/dist/helpers/font.js.map +1 -0
  27. package/dist/helpers/glyphmanager.js +121 -0
  28. package/dist/helpers/glyphmanager.js.map +1 -0
  29. package/dist/helpers/textureatlas.js +170 -0
  30. package/dist/helpers/textureatlas.js.map +1 -0
  31. package/dist/index.d.ts +3873 -0
  32. package/dist/index.js +16 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/timer.js +38 -0
  35. package/dist/timer.js.map +1 -0
  36. package/dist/uniformdata.js +147 -0
  37. package/dist/uniformdata.js.map +1 -0
  38. package/dist/vertexdata.js +135 -0
  39. package/dist/vertexdata.js.map +1 -0
  40. package/package.json +69 -0
@@ -0,0 +1,1563 @@
1
+ const F16_BITMASK = 1;
2
+ const F32_BITMASK = 2;
3
+ const BOOL_BITMASK = 3;
4
+ const I8_BITMASK = 4;
5
+ const I16_BITMASK = 5;
6
+ const I32_BITMASK = 6;
7
+ const U8_BITMASK = 7;
8
+ const U16_BITMASK = 8;
9
+ const U32_BITMASK = 9;
10
+ const SCALAR_TYPE_BITMASK = 15;
11
+ const ROWS_BITMASK = 7;
12
+ const ROWS_BITSHIFT = 4;
13
+ const COLS_BITMASK = 7;
14
+ const COLS_BITSHIFT = 7;
15
+ const NORM_BITMASK = 1;
16
+ const NORM_BITSHIFT = 10;
17
+ function align(n, alignment) {
18
+ return n + alignment - 1 & ~(alignment - 1);
19
+ }
20
+ function getAlignment(type) {
21
+ if (type.isPrimitiveType()) {
22
+ return type.isScalarType() ? 4 : 1 << Math.min(4, type.cols + 1);
23
+ } else if (type.isAtomicI32() || type.isAtomicU32()) {
24
+ return 4;
25
+ } else if (type.isArrayType()) {
26
+ return type.elementType.isAnyType() ? 1 : getAlignment(type.elementType);
27
+ } else {
28
+ let alignment = 0;
29
+ for (const member of type.structMembers){
30
+ alignment = Math.max(alignment, getAlignment(member.type));
31
+ }
32
+ return Math.max(alignment, 16);
33
+ }
34
+ }
35
+ function getAlignmentPacked(type) {
36
+ return 1;
37
+ }
38
+ function getSize(type) {
39
+ if (type.isPrimitiveType()) {
40
+ return type.isMatrixType() ? type.rows * getAlignment(PBPrimitiveTypeInfo.getCachedTypeInfo(type.resizeType(1, type.cols))) : 4 * type.cols;
41
+ } else if (type.isArrayType()) {
42
+ return type.elementType.isAnyType() ? 0 : type.dimension * align(getSize(type.elementType), getAlignment(type.elementType));
43
+ } else if (type.isAtomicI32() || type.isAtomicU32()) {
44
+ return 4;
45
+ } else {
46
+ let size = 0;
47
+ let structAlignment = 0;
48
+ for (const member of type.structMembers){
49
+ const memberAlignment = getAlignment(member.type);
50
+ size = align(size, memberAlignment);
51
+ size += getSize(member.type);
52
+ structAlignment = Math.max(structAlignment, memberAlignment);
53
+ }
54
+ return align(size, structAlignment);
55
+ }
56
+ }
57
+ function getSizePacked(type) {
58
+ if (type.isPrimitiveType()) {
59
+ let scalarSize;
60
+ switch(type.scalarType){
61
+ case PBPrimitiveType.U8:
62
+ case PBPrimitiveType.U8_NORM:
63
+ case PBPrimitiveType.I8:
64
+ case PBPrimitiveType.I8_NORM:
65
+ scalarSize = 1;
66
+ break;
67
+ case PBPrimitiveType.F16:
68
+ case PBPrimitiveType.I16:
69
+ case PBPrimitiveType.I16_NORM:
70
+ case PBPrimitiveType.U16:
71
+ case PBPrimitiveType.U16_NORM:
72
+ scalarSize = 2;
73
+ break;
74
+ default:
75
+ scalarSize = 4;
76
+ break;
77
+ }
78
+ return type.rows * type.cols * scalarSize;
79
+ } else if (type.isArrayType()) {
80
+ return type.elementType.isAnyType() ? 0 : type.dimension * getSizePacked(type.elementType);
81
+ } else if (type.isAtomicI32() || type.isAtomicU32()) {
82
+ return 4;
83
+ } else {
84
+ let size = 0;
85
+ for (const member of type.structMembers){
86
+ size += getSizePacked(member.type);
87
+ }
88
+ return size;
89
+ }
90
+ }
91
+ function makePrimitiveType(scalarTypeMask, rows, cols, norm) {
92
+ return scalarTypeMask | rows << ROWS_BITSHIFT | cols << COLS_BITSHIFT | norm << NORM_BITSHIFT;
93
+ }
94
+ function typeToTypedArray(type) {
95
+ if (type.isPrimitiveType()) {
96
+ return type.scalarType;
97
+ } else if (type.isArrayType()) {
98
+ return type.elementType.isAnyType() ? null : typeToTypedArray(type.elementType);
99
+ } else {
100
+ return PBPrimitiveType.U8;
101
+ }
102
+ }
103
+ var PBPrimitiveType;
104
+ (function(PBPrimitiveType) {
105
+ PBPrimitiveType[PBPrimitiveType["NONE"] = 0] = "NONE";
106
+ PBPrimitiveType[PBPrimitiveType["F16"] = makePrimitiveType(F16_BITMASK, 1, 1, 0)] = "F16";
107
+ PBPrimitiveType[PBPrimitiveType["F16VEC2"] = makePrimitiveType(F16_BITMASK, 1, 2, 0)] = "F16VEC2";
108
+ PBPrimitiveType[PBPrimitiveType["F16VEC3"] = makePrimitiveType(F16_BITMASK, 1, 3, 0)] = "F16VEC3";
109
+ PBPrimitiveType[PBPrimitiveType["F16VEC4"] = makePrimitiveType(F16_BITMASK, 1, 4, 0)] = "F16VEC4";
110
+ PBPrimitiveType[PBPrimitiveType["F32"] = makePrimitiveType(F32_BITMASK, 1, 1, 0)] = "F32";
111
+ PBPrimitiveType[PBPrimitiveType["F32VEC2"] = makePrimitiveType(F32_BITMASK, 1, 2, 0)] = "F32VEC2";
112
+ PBPrimitiveType[PBPrimitiveType["F32VEC3"] = makePrimitiveType(F32_BITMASK, 1, 3, 0)] = "F32VEC3";
113
+ PBPrimitiveType[PBPrimitiveType["F32VEC4"] = makePrimitiveType(F32_BITMASK, 1, 4, 0)] = "F32VEC4";
114
+ PBPrimitiveType[PBPrimitiveType["BOOL"] = makePrimitiveType(BOOL_BITMASK, 1, 1, 0)] = "BOOL";
115
+ PBPrimitiveType[PBPrimitiveType["BVEC2"] = makePrimitiveType(BOOL_BITMASK, 1, 2, 0)] = "BVEC2";
116
+ PBPrimitiveType[PBPrimitiveType["BVEC3"] = makePrimitiveType(BOOL_BITMASK, 1, 3, 0)] = "BVEC3";
117
+ PBPrimitiveType[PBPrimitiveType["BVEC4"] = makePrimitiveType(BOOL_BITMASK, 1, 4, 0)] = "BVEC4";
118
+ PBPrimitiveType[PBPrimitiveType["I8"] = makePrimitiveType(I8_BITMASK, 1, 1, 0)] = "I8";
119
+ PBPrimitiveType[PBPrimitiveType["I8VEC2"] = makePrimitiveType(I8_BITMASK, 1, 2, 0)] = "I8VEC2";
120
+ PBPrimitiveType[PBPrimitiveType["I8VEC3"] = makePrimitiveType(I8_BITMASK, 1, 3, 0)] = "I8VEC3";
121
+ PBPrimitiveType[PBPrimitiveType["I8VEC4"] = makePrimitiveType(I8_BITMASK, 1, 4, 0)] = "I8VEC4";
122
+ PBPrimitiveType[PBPrimitiveType["I8_NORM"] = makePrimitiveType(I8_BITMASK, 1, 1, 1)] = "I8_NORM";
123
+ PBPrimitiveType[PBPrimitiveType["I8VEC2_NORM"] = makePrimitiveType(I8_BITMASK, 1, 2, 1)] = "I8VEC2_NORM";
124
+ PBPrimitiveType[PBPrimitiveType["I8VEC3_NORM"] = makePrimitiveType(I8_BITMASK, 1, 3, 1)] = "I8VEC3_NORM";
125
+ PBPrimitiveType[PBPrimitiveType["I8VEC4_NORM"] = makePrimitiveType(I8_BITMASK, 1, 4, 1)] = "I8VEC4_NORM";
126
+ PBPrimitiveType[PBPrimitiveType["I16"] = makePrimitiveType(I16_BITMASK, 1, 1, 0)] = "I16";
127
+ PBPrimitiveType[PBPrimitiveType["I16VEC2"] = makePrimitiveType(I16_BITMASK, 1, 2, 0)] = "I16VEC2";
128
+ PBPrimitiveType[PBPrimitiveType["I16VEC3"] = makePrimitiveType(I16_BITMASK, 1, 3, 0)] = "I16VEC3";
129
+ PBPrimitiveType[PBPrimitiveType["I16VEC4"] = makePrimitiveType(I16_BITMASK, 1, 4, 0)] = "I16VEC4";
130
+ PBPrimitiveType[PBPrimitiveType["I16_NORM"] = makePrimitiveType(I16_BITMASK, 1, 1, 1)] = "I16_NORM";
131
+ PBPrimitiveType[PBPrimitiveType["I16VEC2_NORM"] = makePrimitiveType(I16_BITMASK, 1, 2, 1)] = "I16VEC2_NORM";
132
+ PBPrimitiveType[PBPrimitiveType["I16VEC3_NORM"] = makePrimitiveType(I16_BITMASK, 1, 3, 1)] = "I16VEC3_NORM";
133
+ PBPrimitiveType[PBPrimitiveType["I16VEC4_NORM"] = makePrimitiveType(I16_BITMASK, 1, 4, 1)] = "I16VEC4_NORM";
134
+ PBPrimitiveType[PBPrimitiveType["I32"] = makePrimitiveType(I32_BITMASK, 1, 1, 0)] = "I32";
135
+ PBPrimitiveType[PBPrimitiveType["I32VEC2"] = makePrimitiveType(I32_BITMASK, 1, 2, 0)] = "I32VEC2";
136
+ PBPrimitiveType[PBPrimitiveType["I32VEC3"] = makePrimitiveType(I32_BITMASK, 1, 3, 0)] = "I32VEC3";
137
+ PBPrimitiveType[PBPrimitiveType["I32VEC4"] = makePrimitiveType(I32_BITMASK, 1, 4, 0)] = "I32VEC4";
138
+ PBPrimitiveType[PBPrimitiveType["I32_NORM"] = makePrimitiveType(I32_BITMASK, 1, 1, 1)] = "I32_NORM";
139
+ PBPrimitiveType[PBPrimitiveType["I32VEC2_NORM"] = makePrimitiveType(I32_BITMASK, 1, 2, 1)] = "I32VEC2_NORM";
140
+ PBPrimitiveType[PBPrimitiveType["I32VEC3_NORM"] = makePrimitiveType(I32_BITMASK, 1, 3, 1)] = "I32VEC3_NORM";
141
+ PBPrimitiveType[PBPrimitiveType["I32VEC4_NORM"] = makePrimitiveType(I32_BITMASK, 1, 4, 1)] = "I32VEC4_NORM";
142
+ PBPrimitiveType[PBPrimitiveType["U8"] = makePrimitiveType(U8_BITMASK, 1, 1, 0)] = "U8";
143
+ PBPrimitiveType[PBPrimitiveType["U8VEC2"] = makePrimitiveType(U8_BITMASK, 1, 2, 0)] = "U8VEC2";
144
+ PBPrimitiveType[PBPrimitiveType["U8VEC3"] = makePrimitiveType(U8_BITMASK, 1, 3, 0)] = "U8VEC3";
145
+ PBPrimitiveType[PBPrimitiveType["U8VEC4"] = makePrimitiveType(U8_BITMASK, 1, 4, 0)] = "U8VEC4";
146
+ PBPrimitiveType[PBPrimitiveType["U8_NORM"] = makePrimitiveType(U8_BITMASK, 1, 1, 1)] = "U8_NORM";
147
+ PBPrimitiveType[PBPrimitiveType["U8VEC2_NORM"] = makePrimitiveType(U8_BITMASK, 1, 2, 1)] = "U8VEC2_NORM";
148
+ PBPrimitiveType[PBPrimitiveType["U8VEC3_NORM"] = makePrimitiveType(U8_BITMASK, 1, 3, 1)] = "U8VEC3_NORM";
149
+ PBPrimitiveType[PBPrimitiveType["U8VEC4_NORM"] = makePrimitiveType(U8_BITMASK, 1, 4, 1)] = "U8VEC4_NORM";
150
+ PBPrimitiveType[PBPrimitiveType["U16"] = makePrimitiveType(U16_BITMASK, 1, 1, 0)] = "U16";
151
+ PBPrimitiveType[PBPrimitiveType["U16VEC2"] = makePrimitiveType(U16_BITMASK, 1, 2, 0)] = "U16VEC2";
152
+ PBPrimitiveType[PBPrimitiveType["U16VEC3"] = makePrimitiveType(U16_BITMASK, 1, 3, 0)] = "U16VEC3";
153
+ PBPrimitiveType[PBPrimitiveType["U16VEC4"] = makePrimitiveType(U16_BITMASK, 1, 4, 0)] = "U16VEC4";
154
+ PBPrimitiveType[PBPrimitiveType["U16_NORM"] = makePrimitiveType(U16_BITMASK, 1, 1, 1)] = "U16_NORM";
155
+ PBPrimitiveType[PBPrimitiveType["U16VEC2_NORM"] = makePrimitiveType(U16_BITMASK, 1, 2, 1)] = "U16VEC2_NORM";
156
+ PBPrimitiveType[PBPrimitiveType["U16VEC3_NORM"] = makePrimitiveType(U16_BITMASK, 1, 3, 1)] = "U16VEC3_NORM";
157
+ PBPrimitiveType[PBPrimitiveType["U16VEC4_NORM"] = makePrimitiveType(U16_BITMASK, 1, 4, 1)] = "U16VEC4_NORM";
158
+ PBPrimitiveType[PBPrimitiveType["U32"] = makePrimitiveType(U32_BITMASK, 1, 1, 0)] = "U32";
159
+ PBPrimitiveType[PBPrimitiveType["U32VEC2"] = makePrimitiveType(U32_BITMASK, 1, 2, 0)] = "U32VEC2";
160
+ PBPrimitiveType[PBPrimitiveType["U32VEC3"] = makePrimitiveType(U32_BITMASK, 1, 3, 0)] = "U32VEC3";
161
+ PBPrimitiveType[PBPrimitiveType["U32VEC4"] = makePrimitiveType(U32_BITMASK, 1, 4, 0)] = "U32VEC4";
162
+ PBPrimitiveType[PBPrimitiveType["U32_NORM"] = makePrimitiveType(U32_BITMASK, 1, 1, 1)] = "U32_NORM";
163
+ PBPrimitiveType[PBPrimitiveType["U32VEC2_NORM"] = makePrimitiveType(U32_BITMASK, 1, 2, 1)] = "U32VEC2_NORM";
164
+ PBPrimitiveType[PBPrimitiveType["U32VEC3_NORM"] = makePrimitiveType(U32_BITMASK, 1, 3, 1)] = "U32VEC3_NORM";
165
+ PBPrimitiveType[PBPrimitiveType["U32VEC4_NORM"] = makePrimitiveType(U32_BITMASK, 1, 4, 1)] = "U32VEC4_NORM";
166
+ PBPrimitiveType[PBPrimitiveType["MAT2"] = makePrimitiveType(F32_BITMASK, 2, 2, 0)] = "MAT2";
167
+ PBPrimitiveType[PBPrimitiveType["MAT2x3"] = makePrimitiveType(F32_BITMASK, 2, 3, 0)] = "MAT2x3";
168
+ PBPrimitiveType[PBPrimitiveType["MAT2x4"] = makePrimitiveType(F32_BITMASK, 2, 4, 0)] = "MAT2x4";
169
+ PBPrimitiveType[PBPrimitiveType["MAT3x2"] = makePrimitiveType(F32_BITMASK, 3, 2, 0)] = "MAT3x2";
170
+ PBPrimitiveType[PBPrimitiveType["MAT3"] = makePrimitiveType(F32_BITMASK, 3, 3, 0)] = "MAT3";
171
+ PBPrimitiveType[PBPrimitiveType["MAT3x4"] = makePrimitiveType(F32_BITMASK, 3, 4, 0)] = "MAT3x4";
172
+ PBPrimitiveType[PBPrimitiveType["MAT4x2"] = makePrimitiveType(F32_BITMASK, 4, 2, 0)] = "MAT4x2";
173
+ PBPrimitiveType[PBPrimitiveType["MAT4x3"] = makePrimitiveType(F32_BITMASK, 4, 3, 0)] = "MAT4x3";
174
+ PBPrimitiveType[PBPrimitiveType["MAT4"] = makePrimitiveType(F32_BITMASK, 4, 4, 0)] = "MAT4";
175
+ })(PBPrimitiveType || (PBPrimitiveType = {}));
176
+ const primitiveTypeMapWebGL = {
177
+ [PBPrimitiveType.F32]: 'float',
178
+ [PBPrimitiveType.F32VEC2]: 'vec2',
179
+ [PBPrimitiveType.F32VEC3]: 'vec3',
180
+ [PBPrimitiveType.F32VEC4]: 'vec4',
181
+ [PBPrimitiveType.BOOL]: 'bool',
182
+ [PBPrimitiveType.BVEC2]: 'bvec2',
183
+ [PBPrimitiveType.BVEC3]: 'bvec3',
184
+ [PBPrimitiveType.BVEC4]: 'bvec4',
185
+ [PBPrimitiveType.I32]: 'int',
186
+ [PBPrimitiveType.I32VEC2]: 'ivec2',
187
+ [PBPrimitiveType.I32VEC3]: 'ivec3',
188
+ [PBPrimitiveType.I32VEC4]: 'ivec4',
189
+ [PBPrimitiveType.U32]: 'uint',
190
+ [PBPrimitiveType.U32VEC2]: 'uvec2',
191
+ [PBPrimitiveType.U32VEC3]: 'uvec3',
192
+ [PBPrimitiveType.U32VEC4]: 'uvec4',
193
+ [PBPrimitiveType.MAT2]: 'mat2',
194
+ [PBPrimitiveType.MAT2x3]: 'mat2x3',
195
+ [PBPrimitiveType.MAT2x4]: 'mat2x4',
196
+ [PBPrimitiveType.MAT3x2]: 'mat3x2',
197
+ [PBPrimitiveType.MAT3]: 'mat3',
198
+ [PBPrimitiveType.MAT3x4]: 'mat3x4',
199
+ [PBPrimitiveType.MAT4x2]: 'mat4x2',
200
+ [PBPrimitiveType.MAT4x3]: 'mat4x3',
201
+ [PBPrimitiveType.MAT4]: 'mat4'
202
+ };
203
+ const primitiveTypeMapWGSL = {
204
+ [PBPrimitiveType.F32]: 'f32',
205
+ [PBPrimitiveType.F32VEC2]: 'vec2<f32>',
206
+ [PBPrimitiveType.F32VEC3]: 'vec3<f32>',
207
+ [PBPrimitiveType.F32VEC4]: 'vec4<f32>',
208
+ [PBPrimitiveType.BOOL]: 'bool',
209
+ [PBPrimitiveType.BVEC2]: 'vec2<bool>',
210
+ [PBPrimitiveType.BVEC3]: 'vec3<bool>',
211
+ [PBPrimitiveType.BVEC4]: 'vec4<bool>',
212
+ [PBPrimitiveType.I32]: 'i32',
213
+ [PBPrimitiveType.I32VEC2]: 'vec2<i32>',
214
+ [PBPrimitiveType.I32VEC3]: 'vec3<i32>',
215
+ [PBPrimitiveType.I32VEC4]: 'vec4<i32>',
216
+ [PBPrimitiveType.U32]: 'u32',
217
+ [PBPrimitiveType.U32VEC2]: 'vec2<u32>',
218
+ [PBPrimitiveType.U32VEC3]: 'vec3<u32>',
219
+ [PBPrimitiveType.U32VEC4]: 'vec4<u32>',
220
+ [PBPrimitiveType.MAT2]: 'mat2x2<f32>',
221
+ [PBPrimitiveType.MAT2x3]: 'mat2x3<f32>',
222
+ [PBPrimitiveType.MAT2x4]: 'mat2x4<f32>',
223
+ [PBPrimitiveType.MAT3x2]: 'mat3x2<f32>',
224
+ [PBPrimitiveType.MAT3]: 'mat3x3<f32>',
225
+ [PBPrimitiveType.MAT3x4]: 'mat3x4<f32>',
226
+ [PBPrimitiveType.MAT4x2]: 'mat4x2<f32>',
227
+ [PBPrimitiveType.MAT4x3]: 'mat4x3<f32>',
228
+ [PBPrimitiveType.MAT4]: 'mat4x4<f32>'
229
+ };
230
+ const BITFLAG_1D = 1 << 0;
231
+ const BITFLAG_2D = 1 << 1;
232
+ const BITFLAG_3D = 1 << 2;
233
+ const BITFLAG_CUBE = 1 << 3;
234
+ const BITFLAG_ARRAY = 1 << 4;
235
+ const BITFLAG_MULTISAMPLED = 1 << 5;
236
+ const BITFLAG_STORAGE = 1 << 6;
237
+ const BITFLAG_DEPTH = 1 << 7;
238
+ const BITFLAG_FLOAT = 1 << 8;
239
+ const BITFLAG_INT = 1 << 9;
240
+ const BITFLAG_UINT = 1 << 10;
241
+ const BITFLAG_EXTERNAL = 1 << 11;
242
+ var PBTextureType;
243
+ (function(PBTextureType) {
244
+ PBTextureType[PBTextureType["TEX_1D"] = BITFLAG_1D | BITFLAG_FLOAT] = "TEX_1D";
245
+ PBTextureType[PBTextureType["ITEX_1D"] = BITFLAG_1D | BITFLAG_INT] = "ITEX_1D";
246
+ PBTextureType[PBTextureType["UTEX_1D"] = BITFLAG_1D | BITFLAG_UINT] = "UTEX_1D";
247
+ PBTextureType[PBTextureType["TEX_2D"] = BITFLAG_2D | BITFLAG_FLOAT] = "TEX_2D";
248
+ PBTextureType[PBTextureType["ITEX_2D"] = BITFLAG_2D | BITFLAG_INT] = "ITEX_2D";
249
+ PBTextureType[PBTextureType["UTEX_2D"] = BITFLAG_2D | BITFLAG_UINT] = "UTEX_2D";
250
+ PBTextureType[PBTextureType["TEX_2D_ARRAY"] = BITFLAG_2D | BITFLAG_FLOAT | BITFLAG_ARRAY] = "TEX_2D_ARRAY";
251
+ PBTextureType[PBTextureType["ITEX_2D_ARRAY"] = BITFLAG_2D | BITFLAG_INT | BITFLAG_ARRAY] = "ITEX_2D_ARRAY";
252
+ PBTextureType[PBTextureType["UTEX_2D_ARRAY"] = BITFLAG_2D | BITFLAG_UINT | BITFLAG_ARRAY] = "UTEX_2D_ARRAY";
253
+ PBTextureType[PBTextureType["TEX_3D"] = BITFLAG_3D | BITFLAG_FLOAT] = "TEX_3D";
254
+ PBTextureType[PBTextureType["ITEX_3D"] = BITFLAG_3D | BITFLAG_INT] = "ITEX_3D";
255
+ PBTextureType[PBTextureType["UTEX_3D"] = BITFLAG_3D | BITFLAG_UINT] = "UTEX_3D";
256
+ PBTextureType[PBTextureType["TEX_CUBE"] = BITFLAG_CUBE | BITFLAG_FLOAT] = "TEX_CUBE";
257
+ PBTextureType[PBTextureType["ITEX_CUBE"] = BITFLAG_CUBE | BITFLAG_INT] = "ITEX_CUBE";
258
+ PBTextureType[PBTextureType["UTEX_CUBE"] = BITFLAG_CUBE | BITFLAG_UINT] = "UTEX_CUBE";
259
+ PBTextureType[PBTextureType["TEX_CUBE_ARRAY"] = BITFLAG_CUBE | BITFLAG_FLOAT | BITFLAG_ARRAY] = "TEX_CUBE_ARRAY";
260
+ PBTextureType[PBTextureType["ITEX_CUBE_ARRAY"] = BITFLAG_CUBE | BITFLAG_INT | BITFLAG_ARRAY] = "ITEX_CUBE_ARRAY";
261
+ PBTextureType[PBTextureType["UTEX_CUBE_ARRAY"] = BITFLAG_CUBE | BITFLAG_UINT | BITFLAG_ARRAY] = "UTEX_CUBE_ARRAY";
262
+ PBTextureType[PBTextureType["TEX_MULTISAMPLED_2D"] = BITFLAG_2D | BITFLAG_FLOAT | BITFLAG_MULTISAMPLED] = "TEX_MULTISAMPLED_2D";
263
+ PBTextureType[PBTextureType["ITEX_MULTISAMPLED_2D"] = BITFLAG_2D | BITFLAG_INT | BITFLAG_MULTISAMPLED] = "ITEX_MULTISAMPLED_2D";
264
+ PBTextureType[PBTextureType["UTEX_MULTISAMPLED_2D"] = BITFLAG_2D | BITFLAG_UINT | BITFLAG_MULTISAMPLED] = "UTEX_MULTISAMPLED_2D";
265
+ PBTextureType[PBTextureType["TEX_STORAGE_1D"] = BITFLAG_1D | BITFLAG_STORAGE] = "TEX_STORAGE_1D";
266
+ PBTextureType[PBTextureType["TEX_STORAGE_2D"] = BITFLAG_2D | BITFLAG_STORAGE] = "TEX_STORAGE_2D";
267
+ PBTextureType[PBTextureType["TEX_STORAGE_2D_ARRAY"] = BITFLAG_2D | BITFLAG_ARRAY | BITFLAG_STORAGE] = "TEX_STORAGE_2D_ARRAY";
268
+ PBTextureType[PBTextureType["TEX_STORAGE_3D"] = BITFLAG_3D | BITFLAG_STORAGE] = "TEX_STORAGE_3D";
269
+ PBTextureType[PBTextureType["TEX_DEPTH_2D"] = BITFLAG_2D | BITFLAG_DEPTH] = "TEX_DEPTH_2D";
270
+ PBTextureType[PBTextureType["TEX_DEPTH_2D_ARRAY"] = BITFLAG_2D | BITFLAG_ARRAY | BITFLAG_DEPTH] = "TEX_DEPTH_2D_ARRAY";
271
+ PBTextureType[PBTextureType["TEX_DEPTH_CUBE"] = BITFLAG_CUBE | BITFLAG_DEPTH] = "TEX_DEPTH_CUBE";
272
+ PBTextureType[PBTextureType["TEX_DEPTH_CUBE_ARRAY"] = BITFLAG_CUBE | BITFLAG_ARRAY | BITFLAG_DEPTH] = "TEX_DEPTH_CUBE_ARRAY";
273
+ PBTextureType[PBTextureType["TEX_DEPTH_MULTISAMPLED_2D"] = BITFLAG_2D | BITFLAG_MULTISAMPLED | BITFLAG_DEPTH] = "TEX_DEPTH_MULTISAMPLED_2D";
274
+ PBTextureType[PBTextureType["TEX_EXTERNAL"] = BITFLAG_EXTERNAL] = "TEX_EXTERNAL";
275
+ })(PBTextureType || (PBTextureType = {}));
276
+ const textureTypeMapWebGL = {
277
+ [PBTextureType.TEX_1D]: 'highp sampler2D',
278
+ [PBTextureType.TEX_2D]: 'highp sampler2D',
279
+ [PBTextureType.TEX_CUBE]: 'highp samplerCube',
280
+ [PBTextureType.TEX_EXTERNAL]: 'highp sampler2D'
281
+ };
282
+ const textureTypeMapWebGL2 = {
283
+ [PBTextureType.TEX_1D]: 'highp sampler2D',
284
+ [PBTextureType.TEX_2D]: 'highp sampler2D',
285
+ [PBTextureType.ITEX_1D]: 'highp isampler2D',
286
+ [PBTextureType.ITEX_2D]: 'highp isampler2D',
287
+ [PBTextureType.UTEX_1D]: 'highp usampler2D',
288
+ [PBTextureType.UTEX_2D]: 'highp usampler2D',
289
+ [PBTextureType.TEX_2D_ARRAY]: 'highp sampler2DArray',
290
+ [PBTextureType.ITEX_2D_ARRAY]: 'highp isampler2DArray',
291
+ [PBTextureType.UTEX_2D_ARRAY]: 'highp usampler2DArray',
292
+ [PBTextureType.TEX_3D]: 'highp sampler3D',
293
+ [PBTextureType.ITEX_3D]: 'highp isampler3D',
294
+ [PBTextureType.UTEX_3D]: 'highp usampler3D',
295
+ [PBTextureType.TEX_CUBE]: 'highp samplerCube',
296
+ [PBTextureType.ITEX_CUBE]: 'highp isamplerCube',
297
+ [PBTextureType.UTEX_CUBE]: 'highp usamplerCube',
298
+ [PBTextureType.TEX_DEPTH_2D]: 'highp sampler2DShadow',
299
+ [PBTextureType.TEX_DEPTH_2D_ARRAY]: 'highp sampler2DArrayShadow',
300
+ [PBTextureType.TEX_DEPTH_CUBE]: 'highp samplerCubeShadow',
301
+ [PBTextureType.TEX_EXTERNAL]: 'highp sampler2D'
302
+ };
303
+ const textureTypeMapWGSL = {
304
+ [PBTextureType.TEX_1D]: 'texture_1d<f32>',
305
+ [PBTextureType.ITEX_1D]: 'texture_1d<i32>',
306
+ [PBTextureType.UTEX_1D]: 'texture_1d<u32>',
307
+ [PBTextureType.TEX_2D]: 'texture_2d<f32>',
308
+ [PBTextureType.ITEX_2D]: 'texture_2d<i32>',
309
+ [PBTextureType.UTEX_2D]: 'texture_2d<u32>',
310
+ [PBTextureType.TEX_2D_ARRAY]: 'texture_2d_array<f32>',
311
+ [PBTextureType.ITEX_2D_ARRAY]: 'texture_2d_array<i32>',
312
+ [PBTextureType.UTEX_2D_ARRAY]: 'texture_2d_array<u32>',
313
+ [PBTextureType.TEX_3D]: 'texture_3d<f32>',
314
+ [PBTextureType.ITEX_3D]: 'texture_3d<i32>',
315
+ [PBTextureType.UTEX_3D]: 'texture_3d<u32>',
316
+ [PBTextureType.TEX_CUBE]: 'texture_cube<f32>',
317
+ [PBTextureType.ITEX_CUBE]: 'texture_cube<i32>',
318
+ [PBTextureType.UTEX_CUBE]: 'texture_cube<u32>',
319
+ [PBTextureType.TEX_CUBE_ARRAY]: 'texture_cube_array<f32>',
320
+ [PBTextureType.ITEX_CUBE_ARRAY]: 'texture_cube_array<i32>',
321
+ [PBTextureType.UTEX_CUBE_ARRAY]: 'texture_cube_array<u32>',
322
+ [PBTextureType.TEX_MULTISAMPLED_2D]: 'texture_multisampled_2d<f32>',
323
+ [PBTextureType.ITEX_MULTISAMPLED_2D]: 'texture_multisampled_2d<i32>',
324
+ [PBTextureType.UTEX_MULTISAMPLED_2D]: 'texture_multisampled_2d<u32>',
325
+ [PBTextureType.TEX_STORAGE_1D]: 'texture_storage_1d',
326
+ [PBTextureType.TEX_STORAGE_2D]: 'texture_storage_2d',
327
+ [PBTextureType.TEX_STORAGE_2D_ARRAY]: 'texture_storage_2d_array',
328
+ [PBTextureType.TEX_STORAGE_3D]: 'texture_storage_3d',
329
+ [PBTextureType.TEX_DEPTH_2D]: 'texture_depth_2d',
330
+ [PBTextureType.TEX_DEPTH_2D_ARRAY]: 'texture_depth_2d_array',
331
+ [PBTextureType.TEX_DEPTH_CUBE]: 'texture_depth_cube',
332
+ [PBTextureType.TEX_DEPTH_CUBE_ARRAY]: 'texture_depth_cube_array',
333
+ [PBTextureType.TEX_DEPTH_MULTISAMPLED_2D]: 'texture_depth_multisampled_2d',
334
+ [PBTextureType.TEX_EXTERNAL]: 'texture_external'
335
+ };
336
+ const storageTexelFormatMap = {
337
+ 'rgba8unorm': 'rgba8unorm',
338
+ 'rgba8snorm': 'rgba8snorm',
339
+ 'bgra8unorm': 'bgra8unorm',
340
+ 'rgba8ui': 'rgba8uint',
341
+ 'rgba8i': 'rgba8sint',
342
+ 'rgba16ui': 'rgba16uint',
343
+ 'rgba16i': 'rgba16sint',
344
+ 'rgba16f': 'rgba16float',
345
+ 'r32f': 'r32float',
346
+ 'r32ui': 'r32uint',
347
+ 'r32i': 'r32sint',
348
+ 'rg32f': 'rg32float',
349
+ 'rg32ui': 'rg32uint',
350
+ 'rg32i': 'rg32sint',
351
+ 'rgba32f': 'rgba32float',
352
+ 'rgba32ui': 'rgba32uint',
353
+ 'rgba32i': 'rgba32sint'
354
+ };
355
+ var PBSamplerAccessMode;
356
+ (function(PBSamplerAccessMode) {
357
+ PBSamplerAccessMode[PBSamplerAccessMode["UNKNOWN"] = 0] = "UNKNOWN";
358
+ PBSamplerAccessMode[PBSamplerAccessMode["SAMPLE"] = 1] = "SAMPLE";
359
+ PBSamplerAccessMode[PBSamplerAccessMode["COMPARISON"] = 2] = "COMPARISON";
360
+ })(PBSamplerAccessMode || (PBSamplerAccessMode = {}));
361
+ var PBAddressSpace;
362
+ (function(PBAddressSpace) {
363
+ PBAddressSpace["UNKNOWN"] = 'unknown';
364
+ PBAddressSpace["FUNCTION"] = 'function';
365
+ PBAddressSpace["PRIVATE"] = 'private';
366
+ PBAddressSpace["WORKGROUP"] = 'workgroup';
367
+ PBAddressSpace["UNIFORM"] = 'uniform';
368
+ PBAddressSpace["STORAGE"] = 'storage';
369
+ })(PBAddressSpace || (PBAddressSpace = {}));
370
+ var PBTypeClass;
371
+ (function(PBTypeClass) {
372
+ PBTypeClass[PBTypeClass["UNKNOWN"] = 0] = "UNKNOWN";
373
+ PBTypeClass[PBTypeClass["PLAIN"] = 1] = "PLAIN";
374
+ PBTypeClass[PBTypeClass["ARRAY"] = 2] = "ARRAY";
375
+ PBTypeClass[PBTypeClass["POINTER"] = 3] = "POINTER";
376
+ PBTypeClass[PBTypeClass["ATOMIC_I32"] = 4] = "ATOMIC_I32";
377
+ PBTypeClass[PBTypeClass["ATOMIC_U32"] = 5] = "ATOMIC_U32";
378
+ PBTypeClass[PBTypeClass["TEXTURE"] = 6] = "TEXTURE";
379
+ PBTypeClass[PBTypeClass["SAMPLER"] = 7] = "SAMPLER";
380
+ PBTypeClass[PBTypeClass["FUNCTION"] = 8] = "FUNCTION";
381
+ PBTypeClass[PBTypeClass["VOID"] = 9] = "VOID";
382
+ PBTypeClass[PBTypeClass["ANY"] = 10] = "ANY";
383
+ })(PBTypeClass || (PBTypeClass = {}));
384
+ /**
385
+ * Abstract base class for any type
386
+ * @public
387
+ */ class PBTypeInfo {
388
+ /** @internal */ cls;
389
+ /** @internal */ detail;
390
+ /** @internal */ id;
391
+ /** @internal */ constructor(cls, detail){
392
+ this.cls = cls;
393
+ this.detail = detail;
394
+ this.id = null;
395
+ }
396
+ /** Get unique id for this type */ get typeId() {
397
+ if (!this.id) {
398
+ this.id = this.genTypeId();
399
+ }
400
+ return this.id;
401
+ }
402
+ /** returns true if this is a void type */ isVoidType() {
403
+ return false;
404
+ }
405
+ /** returns true if this is an any type */ isAnyType() {
406
+ return false;
407
+ }
408
+ /** returns true if this is a primitive type */ isPrimitiveType() {
409
+ return false;
410
+ }
411
+ /** returns true if this is a struct type */ isStructType() {
412
+ return false;
413
+ }
414
+ /** returns true if this is an array type */ isArrayType() {
415
+ return false;
416
+ }
417
+ /** returns true if this is a pointer type */ isPointerType() {
418
+ return false;
419
+ }
420
+ /** returns true if this is an atomic int type */ isAtomicI32() {
421
+ return false;
422
+ }
423
+ /** returns true if this is an atomic uint type */ isAtomicU32() {
424
+ return false;
425
+ }
426
+ /** returns true if this is a sampler type */ isSamplerType() {
427
+ return false;
428
+ }
429
+ /** returns true if this is a texture type */ isTextureType() {
430
+ return false;
431
+ }
432
+ /** @internal */ isHostSharable() {
433
+ return false;
434
+ }
435
+ /** @internal */ isConstructible() {
436
+ return false;
437
+ }
438
+ /** @internal */ isStorable() {
439
+ return false;
440
+ }
441
+ /** @internal */ getConstructorOverloads(deviceType) {
442
+ return [];
443
+ }
444
+ /**
445
+ * Check whether a given type is compatible with this type
446
+ * @param other - The type to be checked
447
+ * @returns true if the given type is compatible with this type, othewise false
448
+ */ isCompatibleType(other) {
449
+ return other.typeId === this.typeId;
450
+ }
451
+ }
452
+ /**
453
+ * The void type info
454
+ * @public
455
+ */ class PBVoidTypeInfo extends PBTypeInfo {
456
+ constructor(){
457
+ super(PBTypeClass.VOID, null);
458
+ }
459
+ /** {@inheritDoc PBTypeInfo.isVoidType} */ isVoidType() {
460
+ return true;
461
+ }
462
+ /** @internal */ toTypeName(deviceType, varName) {
463
+ return 'void';
464
+ }
465
+ /** @internal */ genTypeId() {
466
+ return 'void';
467
+ }
468
+ /** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(offset) {
469
+ return null;
470
+ }
471
+ }
472
+ /**
473
+ * The void type info
474
+ * @public
475
+ */ class PBAnyTypeInfo extends PBTypeInfo {
476
+ constructor(){
477
+ super(PBTypeClass.ANY, null);
478
+ }
479
+ /** {@inheritDoc PBTypeInfo.isAnyType} */ isAnyType() {
480
+ return true;
481
+ }
482
+ /** @internal */ toTypeName(deviceType, varName) {
483
+ return 'any';
484
+ }
485
+ /** @internal */ genTypeId() {
486
+ return 'any';
487
+ }
488
+ /** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(offset) {
489
+ return null;
490
+ }
491
+ /** {@inheritDoc PBTypeInfo.isCompatibleType} */ isCompatibleType(other) {
492
+ return true;
493
+ }
494
+ }
495
+ /**
496
+ * The primitive type info
497
+ * @public
498
+ */ class PBPrimitiveTypeInfo extends PBTypeInfo {
499
+ /** @internal */ static cachedTypes = {};
500
+ /** @internal */ static cachedCtorOverloads = {};
501
+ constructor(type){
502
+ super(PBTypeClass.PLAIN, {
503
+ primitiveType: type
504
+ });
505
+ }
506
+ /** Get or create a PBPrimitiveTypeInfo instance for a given prmitive type */ static getCachedTypeInfo(primitiveType) {
507
+ let typeinfo = this.cachedTypes[primitiveType];
508
+ if (!typeinfo) {
509
+ typeinfo = new PBPrimitiveTypeInfo(primitiveType);
510
+ this.cachedTypes[primitiveType] = typeinfo;
511
+ }
512
+ return typeinfo;
513
+ }
514
+ /** @internal */ static getCachedOverloads(deviceType, primitiveType) {
515
+ let deviceOverloads = this.cachedCtorOverloads[deviceType];
516
+ if (!deviceOverloads) {
517
+ deviceOverloads = {};
518
+ this.cachedCtorOverloads[deviceType] = deviceOverloads;
519
+ }
520
+ let result = deviceOverloads[primitiveType];
521
+ if (!result) {
522
+ const typeinfo = this.getCachedTypeInfo(primitiveType);
523
+ const name = typeinfo.toTypeName(deviceType);
524
+ result = [
525
+ new PBFunctionTypeInfo(name, typeinfo, [])
526
+ ];
527
+ if (typeinfo.isScalarType()) {
528
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
529
+ {
530
+ type: this.getCachedTypeInfo(PBPrimitiveType.F32)
531
+ }
532
+ ]));
533
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
534
+ {
535
+ type: this.getCachedTypeInfo(PBPrimitiveType.I32)
536
+ }
537
+ ]));
538
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
539
+ {
540
+ type: this.getCachedTypeInfo(PBPrimitiveType.U32)
541
+ }
542
+ ]));
543
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
544
+ {
545
+ type: this.getCachedTypeInfo(PBPrimitiveType.BOOL)
546
+ }
547
+ ]));
548
+ } else if (typeinfo.isVectorType()) {
549
+ const scalarTypeInfo = {
550
+ type: this.getCachedTypeInfo(typeinfo.scalarType)
551
+ };
552
+ const vec2TypeInfo = {
553
+ type: this.getCachedTypeInfo(typeinfo.resizeType(1, 2))
554
+ };
555
+ const vec3TypeInfo = {
556
+ type: this.getCachedTypeInfo(typeinfo.resizeType(1, 3))
557
+ };
558
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
559
+ scalarTypeInfo
560
+ ]));
561
+ switch(typeinfo.cols){
562
+ case 2:
563
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
564
+ scalarTypeInfo,
565
+ scalarTypeInfo
566
+ ]));
567
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
568
+ {
569
+ type: typeF32Vec2
570
+ }
571
+ ]));
572
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
573
+ {
574
+ type: typeI32Vec2
575
+ }
576
+ ]));
577
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
578
+ {
579
+ type: typeU32Vec2
580
+ }
581
+ ]));
582
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
583
+ {
584
+ type: typeBVec2
585
+ }
586
+ ]));
587
+ break;
588
+ case 3:
589
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
590
+ scalarTypeInfo,
591
+ scalarTypeInfo,
592
+ scalarTypeInfo
593
+ ]));
594
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
595
+ scalarTypeInfo,
596
+ vec2TypeInfo
597
+ ]));
598
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
599
+ vec2TypeInfo,
600
+ scalarTypeInfo
601
+ ]));
602
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
603
+ {
604
+ type: typeF32Vec3
605
+ }
606
+ ]));
607
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
608
+ {
609
+ type: typeI32Vec3
610
+ }
611
+ ]));
612
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
613
+ {
614
+ type: typeU32Vec3
615
+ }
616
+ ]));
617
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
618
+ {
619
+ type: typeBVec3
620
+ }
621
+ ]));
622
+ break;
623
+ case 4:
624
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
625
+ scalarTypeInfo,
626
+ scalarTypeInfo,
627
+ scalarTypeInfo,
628
+ scalarTypeInfo
629
+ ]));
630
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
631
+ scalarTypeInfo,
632
+ scalarTypeInfo,
633
+ vec2TypeInfo
634
+ ]));
635
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
636
+ scalarTypeInfo,
637
+ vec2TypeInfo,
638
+ scalarTypeInfo
639
+ ]));
640
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
641
+ vec2TypeInfo,
642
+ scalarTypeInfo,
643
+ scalarTypeInfo
644
+ ]));
645
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
646
+ vec2TypeInfo,
647
+ vec2TypeInfo
648
+ ]));
649
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
650
+ scalarTypeInfo,
651
+ vec3TypeInfo
652
+ ]));
653
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
654
+ vec3TypeInfo,
655
+ scalarTypeInfo
656
+ ]));
657
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
658
+ {
659
+ type: typeF32Vec4
660
+ }
661
+ ]));
662
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
663
+ {
664
+ type: typeI32Vec4
665
+ }
666
+ ]));
667
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
668
+ {
669
+ type: typeU32Vec4
670
+ }
671
+ ]));
672
+ result.push(new PBFunctionTypeInfo(name, typeinfo, [
673
+ {
674
+ type: typeBVec4
675
+ }
676
+ ]));
677
+ }
678
+ } else if (typeinfo.isMatrixType()) {
679
+ const colType = this.getCachedTypeInfo(typeinfo.resizeType(1, typeinfo.cols));
680
+ result.push(new PBFunctionTypeInfo(name, typeinfo, Array.from({
681
+ length: typeinfo.rows
682
+ }).map(()=>({
683
+ type: colType
684
+ }))));
685
+ result.push(new PBFunctionTypeInfo(name, typeinfo, Array.from({
686
+ length: typeinfo.rows * typeinfo.cols
687
+ }).map(()=>({
688
+ type: typeF32
689
+ }))));
690
+ }
691
+ deviceOverloads[primitiveType] = result;
692
+ }
693
+ return result;
694
+ }
695
+ /** Get the primitive type */ get primitiveType() {
696
+ return this.detail.primitiveType;
697
+ }
698
+ /** Whether the type is signed or unsigned integer scalar or vector */ isInteger() {
699
+ const st = this.primitiveType & SCALAR_TYPE_BITMASK;
700
+ return st === I8_BITMASK || st === U8_BITMASK || st === I16_BITMASK || st === U16_BITMASK || st === I32_BITMASK || st === U32_BITMASK;
701
+ }
702
+ /** Get the scalar type */ get scalarType() {
703
+ return this.resizeType(1, 1);
704
+ }
705
+ /** Get number of rows */ get rows() {
706
+ return this.primitiveType >> ROWS_BITSHIFT & ROWS_BITMASK;
707
+ }
708
+ /** Get number of columns */ get cols() {
709
+ return this.primitiveType >> COLS_BITSHIFT & COLS_BITMASK;
710
+ }
711
+ /** Get if this is a normalized primitive type */ get normalized() {
712
+ return !!(this.primitiveType >> NORM_BITSHIFT & NORM_BITMASK);
713
+ }
714
+ /** @internal */ getLayoutAlignment(layout) {
715
+ return layout === 'packed' ? 1 : this.isScalarType() ? 4 : 1 << Math.min(4, this.cols + 1);
716
+ }
717
+ /** @internal */ getLayoutSize() {
718
+ return this.getSize();
719
+ }
720
+ /** @internal */ getSize() {
721
+ let scalarSize;
722
+ switch(this.scalarType){
723
+ case PBPrimitiveType.BOOL:
724
+ case PBPrimitiveType.I32:
725
+ case PBPrimitiveType.I32_NORM:
726
+ case PBPrimitiveType.U32:
727
+ case PBPrimitiveType.U32_NORM:
728
+ case PBPrimitiveType.F32:
729
+ scalarSize = 4;
730
+ break;
731
+ case PBPrimitiveType.F16:
732
+ case PBPrimitiveType.I16:
733
+ case PBPrimitiveType.I16_NORM:
734
+ case PBPrimitiveType.U16:
735
+ case PBPrimitiveType.U16_NORM:
736
+ scalarSize = 2;
737
+ break;
738
+ default:
739
+ scalarSize = 1;
740
+ break;
741
+ }
742
+ return scalarSize * this.cols * this.rows;
743
+ }
744
+ /**
745
+ * Creates a new primitive type info by changing row and column of this type
746
+ * @param rows - The new value of row
747
+ * @param cols - The new value of column
748
+ * @returns The new primitive type
749
+ */ resizeType(rows, cols) {
750
+ return makePrimitiveType(this.primitiveType & SCALAR_TYPE_BITMASK, rows, cols, this.normalized ? 1 : 0);
751
+ }
752
+ /** Returns true if this is a scalar type */ isScalarType() {
753
+ return this.rows === 1 && this.cols === 1;
754
+ }
755
+ /** Returns true if this is a vector type */ isVectorType() {
756
+ return this.rows === 1 && this.cols > 1;
757
+ }
758
+ /** Returns true if this is a matrix type */ isMatrixType() {
759
+ return this.rows > 1 && this.cols > 1;
760
+ }
761
+ /** {@inheritDoc PBTypeInfo.isPrimitiveType} */ isPrimitiveType() {
762
+ return true;
763
+ }
764
+ /** @internal */ isHostSharable() {
765
+ return this.scalarType !== PBPrimitiveType.BOOL;
766
+ }
767
+ /** @internal */ isConstructible() {
768
+ return true;
769
+ }
770
+ /** @internal */ isStorable() {
771
+ return true;
772
+ }
773
+ /** @internal */ getConstructorOverloads(deviceType) {
774
+ return PBPrimitiveTypeInfo.getCachedOverloads(deviceType, this.primitiveType);
775
+ }
776
+ /** @internal */ toTypeName(deviceType, varName) {
777
+ if (deviceType === 'webgpu') {
778
+ const typename = primitiveTypeMapWGSL[this.primitiveType];
779
+ return varName ? `${varName}: ${typename}` : typename;
780
+ } else {
781
+ const typename = primitiveTypeMapWebGL[this.primitiveType];
782
+ return varName ? `${typename} ${varName}` : typename;
783
+ }
784
+ }
785
+ /** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(offset) {
786
+ return null;
787
+ }
788
+ /** @internal */ genTypeId() {
789
+ return `PRIM:${this.primitiveType}`;
790
+ }
791
+ }
792
+ /**
793
+ * The struct type info
794
+ * @public
795
+ */ class PBStructTypeInfo extends PBTypeInfo {
796
+ constructor(name, layout, members){
797
+ super(PBTypeClass.PLAIN, {
798
+ layout: layout || 'default',
799
+ structName: name,
800
+ structMembers: members.map((val)=>{
801
+ const defaultAlignment = getAlignment(val.type);
802
+ const defaultSize = getSize(val.type);
803
+ return {
804
+ name: val.name,
805
+ type: val.type,
806
+ alignment: defaultAlignment,
807
+ size: defaultSize,
808
+ defaultAlignment: defaultAlignment,
809
+ defaultSize: defaultSize
810
+ };
811
+ })
812
+ });
813
+ if (this.layout === 'std140') {
814
+ this.calcAlignmentAndSizeSTD140();
815
+ } else if (this.layout === 'std430') {
816
+ this.calcAlignmentAndSizePacked();
817
+ }
818
+ }
819
+ /** Get the layout type */ get layout() {
820
+ return this.detail.layout;
821
+ }
822
+ /** Get name of the struct type */ get structName() {
823
+ return this.detail.structName;
824
+ }
825
+ set structName(val) {
826
+ this.detail.structName = val;
827
+ }
828
+ /** Get member types of the struct type */ get structMembers() {
829
+ return this.detail.structMembers;
830
+ }
831
+ /**
832
+ * Creates a new struct type by extending this type
833
+ * @param name - Name of the new struct type
834
+ * @param members - additional struct members
835
+ * @returns The new struct type
836
+ */ extends(name, members) {
837
+ const oldMembers = this.structMembers.map((member)=>({
838
+ name: member.name,
839
+ type: member.type
840
+ }));
841
+ return new PBStructTypeInfo(name, this.layout, [
842
+ ...oldMembers,
843
+ ...members
844
+ ]);
845
+ }
846
+ /** {@inheritDoc PBTypeInfo.isStructType} */ isStructType() {
847
+ return true;
848
+ }
849
+ /** @internal */ isHostSharable() {
850
+ return this.detail.structMembers.every((val)=>val.type.isHostSharable());
851
+ }
852
+ /** @internal */ isConstructible() {
853
+ return this.detail.structMembers.every((val)=>val.type.isConstructible());
854
+ }
855
+ /** @internal */ isStorable() {
856
+ return true;
857
+ }
858
+ /** @internal */ getConstructorOverloads() {
859
+ const result = [
860
+ new PBFunctionTypeInfo(this.structName, this, [])
861
+ ];
862
+ if (this.isConstructible()) {
863
+ result.push(new PBFunctionTypeInfo(this.structName, this, this.structMembers.map((val)=>({
864
+ type: val.type
865
+ }))));
866
+ }
867
+ return result;
868
+ }
869
+ /** @internal */ toTypeName(deviceType, varName) {
870
+ if (deviceType === 'webgpu') {
871
+ return varName ? `${varName}: ${this.structName}` : this.structName;
872
+ } else {
873
+ return varName ? `${this.structName} ${varName}` : this.structName;
874
+ }
875
+ }
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
+ /** @internal */ getLayoutAlignment(layout) {
888
+ if (layout === 'packed') {
889
+ return 1;
890
+ }
891
+ let alignment = 0;
892
+ for (const member of this.structMembers){
893
+ alignment = Math.max(alignment, member.type.getLayoutAlignment(layout));
894
+ }
895
+ if (layout === 'std140') {
896
+ alignment = align(alignment, 16);
897
+ }
898
+ return alignment;
899
+ }
900
+ /** @internal */ getLayoutSize(layout) {
901
+ let size = 0;
902
+ let structAlignment = 0;
903
+ for (const member of this.structMembers){
904
+ const memberAlignment = member.type.getLayoutAlignment(layout);
905
+ size = align(size, memberAlignment);
906
+ size += member.type.getLayoutSize(layout);
907
+ structAlignment = Math.max(structAlignment, memberAlignment);
908
+ }
909
+ return align(size, structAlignment);
910
+ }
911
+ /** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(offset, layout) {
912
+ const bufferLayout = {
913
+ byteSize: 0,
914
+ entries: []
915
+ };
916
+ const start = offset;
917
+ for (const member of this.structMembers){
918
+ offset = align(offset, member.type.getLayoutAlignment(layout));
919
+ const size = member.type.getLayoutSize(layout);
920
+ bufferLayout.entries.push({
921
+ name: member.name,
922
+ offset: offset,
923
+ byteSize: size,
924
+ type: typeToTypedArray(member.type),
925
+ subLayout: member.type.isStructType() ? member.type.toBufferLayout(offset, layout) : null,
926
+ arraySize: member.type.isArrayType() ? member.type.dimension : 0
927
+ });
928
+ offset += size;
929
+ }
930
+ bufferLayout.byteSize = layout === 'std140' ? align(offset - start, 16) : offset - start;
931
+ return bufferLayout;
932
+ }
933
+ /** @internal */ clone(newName) {
934
+ return new PBStructTypeInfo(newName || this.structName, this.layout, this.structMembers);
935
+ }
936
+ /** @internal */ reset(name, layout, members) {
937
+ this.detail = {
938
+ layout: layout || 'default',
939
+ structName: name,
940
+ structMembers: members.map((val)=>{
941
+ const defaultAlignment = getAlignment(val.type);
942
+ const defaultSize = getSize(val.type);
943
+ return {
944
+ name: val.name,
945
+ type: val.type,
946
+ alignment: defaultAlignment,
947
+ size: defaultSize,
948
+ defaultAlignment: defaultAlignment,
949
+ defaultSize: defaultSize
950
+ };
951
+ })
952
+ };
953
+ if (this.layout === 'std140') {
954
+ this.calcAlignmentAndSizeSTD140();
955
+ } else if (this.layout === 'std430') {
956
+ this.calcAlignmentAndSizePacked();
957
+ }
958
+ this.id = null;
959
+ }
960
+ /** @internal */ genTypeId() {
961
+ return `STRUCT:${this.structName}:${this.layout}:${this.structMembers.map((val)=>`${val.name}(${val.type.typeId})`).join(':')}`;
962
+ }
963
+ /** @internal */ calcAlignmentAndSizeSTD140() {
964
+ for (const member of this.structMembers){
965
+ if (member.type.isPrimitiveType()) {
966
+ if (member.type.isMatrixType() && member.type.cols === 2) {
967
+ throw new Error(`matrix${member.type.rows}x${member.type.cols} can not be used in std140 layout`);
968
+ }
969
+ } else if (member.type.isArrayType() && (member.type.elementType.isAnyType() || getAlignment(member.type.elementType) !== 16)) {
970
+ throw new Error('array element must be 16 bytes aligned in std140 layout');
971
+ } else if (member.type.isStructType()) {
972
+ member.alignment = 16;
973
+ member.size = align(member.defaultSize, 16);
974
+ }
975
+ }
976
+ }
977
+ /** @internal */ calcAlignmentAndSizePacked() {
978
+ for (const member of this.structMembers){
979
+ member.alignment = getAlignmentPacked(member.type);
980
+ member.size = getSizePacked(member.type);
981
+ }
982
+ }
983
+ }
984
+ /**
985
+ * The array type info
986
+ * @public
987
+ */ class PBArrayTypeInfo extends PBTypeInfo {
988
+ constructor(elementType, dimension){
989
+ super(PBTypeClass.ARRAY, {
990
+ elementType: elementType,
991
+ dimension: Number(dimension) || 0
992
+ });
993
+ }
994
+ /** Get the element type */ get elementType() {
995
+ return this.detail.elementType;
996
+ }
997
+ /** Get dimension of the array type */ get dimension() {
998
+ return this.detail.dimension;
999
+ }
1000
+ /** {@inheritDoc PBTypeInfo.isArrayType} */ isArrayType() {
1001
+ return true;
1002
+ }
1003
+ /** @internal */ isHostSharable() {
1004
+ return this.detail.elementType.isHostSharable();
1005
+ }
1006
+ /** @internal */ isConstructible() {
1007
+ return this.dimension && this.detail.elementType.isConstructible();
1008
+ }
1009
+ /** @internal */ isStorable() {
1010
+ return true;
1011
+ }
1012
+ /** @internal */ getConstructorOverloads(deviceType) {
1013
+ const name = this.toTypeName(deviceType);
1014
+ const result = [
1015
+ new PBFunctionTypeInfo(name, this, [])
1016
+ ];
1017
+ if (deviceType !== 'webgl' && this.isConstructible()) {
1018
+ result.push(new PBFunctionTypeInfo(name, this, Array.from({
1019
+ length: this.dimension
1020
+ }).map(()=>({
1021
+ type: this.elementType
1022
+ }))));
1023
+ }
1024
+ return result;
1025
+ }
1026
+ /** @internal */ toTypeName(deviceType, varName) {
1027
+ if (deviceType === 'webgpu') {
1028
+ const elementTypeName = this.elementType.toTypeName(deviceType);
1029
+ const typename = `array<${elementTypeName}${this.dimension ? ', ' + this.dimension : ''}>`;
1030
+ return varName ? `${varName}: ${typename}` : typename;
1031
+ } else {
1032
+ console.assert(!!this.dimension, 'runtime-sized array not supported for webgl');
1033
+ console.assert(!this.elementType.isArrayType(), 'multi-dimensional arrays not supported for webgl');
1034
+ const elementTypeName = this.elementType.toTypeName(deviceType, varName);
1035
+ return `${elementTypeName}[${this.dimension}]`;
1036
+ }
1037
+ }
1038
+ /** @internal */ getLayoutAlignment(layout) {
1039
+ return layout === 'packed' || this.elementType.isAnyType() ? 1 : layout === 'std430' ? this.elementType.getLayoutAlignment(layout) : align(this.elementType.getLayoutAlignment(layout), 16);
1040
+ }
1041
+ /** @internal */ getLayoutSize(layout) {
1042
+ const elementAlignment = this.elementType.isAnyType() ? 1 : this.elementType.getLayoutAlignment(layout);
1043
+ if (layout === 'std140' && !!(elementAlignment & 15)) {
1044
+ // array element stride of std140 layout must be multiple of 16
1045
+ throw new Error('Error: array element stride of std140 must be multiple of 16');
1046
+ }
1047
+ return this.elementType.isAnyType() ? 0 : this.dimension * align(this.elementType.getLayoutSize(layout), elementAlignment);
1048
+ }
1049
+ /** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(offset) {
1050
+ return null;
1051
+ }
1052
+ isCompatibleType(other) {
1053
+ if (!other.isArrayType()) {
1054
+ return false;
1055
+ }
1056
+ if (this.dimension !== 0 && other.dimension !== this.dimension) {
1057
+ return false;
1058
+ }
1059
+ return this.elementType.isCompatibleType(other.elementType);
1060
+ }
1061
+ /** @internal */ genTypeId() {
1062
+ return `ARRAY:(${this.elementType.typeId})[${this.dimension}]`;
1063
+ }
1064
+ }
1065
+ /**
1066
+ * The pointer type info
1067
+ * @public
1068
+ */ class PBPointerTypeInfo extends PBTypeInfo {
1069
+ /** @internal */ writable;
1070
+ constructor(pointerType, addressSpace){
1071
+ super(PBTypeClass.POINTER, {
1072
+ pointerType,
1073
+ addressSpace
1074
+ });
1075
+ console.assert(pointerType.isStorable(), 'the pointee type must be storable');
1076
+ this.writable = false;
1077
+ }
1078
+ /** Get type of the pointer */ get pointerType() {
1079
+ return this.detail.pointerType;
1080
+ }
1081
+ /** Get address space of the pointer */ get addressSpace() {
1082
+ return this.detail.addressSpace;
1083
+ }
1084
+ set addressSpace(val) {
1085
+ if (this.detail.addressSpace !== val) {
1086
+ this.detail.addressSpace = val;
1087
+ this.id = null;
1088
+ }
1089
+ }
1090
+ /** {@inheritDoc PBTypeInfo.isPointerType} */ isPointerType() {
1091
+ return true;
1092
+ }
1093
+ /** @internal */ toTypeName(device, varName) {
1094
+ if (device === 'webgpu') {
1095
+ const addressSpace = this.addressSpace === PBAddressSpace.UNKNOWN ? PBAddressSpace.FUNCTION : this.addressSpace;
1096
+ /*
1097
+ const mode = addressSpace === PBAddressSpace.UNIFORM || (addressSpace === PBAddressSpace.STORAGE && !this.writable) ? 'read' : 'read_write'
1098
+ const typename = `ptr<${addressSpace}, ${this.pointerType.toTypeName(device)}, ${mode}>`;
1099
+ */ /* WGSL spec:
1100
+ When writing a variable declaration or a pointer type in WGSL source:
1101
+ For the storage address space, the access mode is optional, and defaults to read.
1102
+ For other address spaces, the access mode must not be written.
1103
+ */ const mode = addressSpace === PBAddressSpace.STORAGE && this.writable ? ', read_write' : '';
1104
+ const typename = `ptr<${addressSpace}, ${this.pointerType.toTypeName(device)} ${mode}>`;
1105
+ return varName ? `${varName}: ${typename}` : typename;
1106
+ } else {
1107
+ throw new Error('pointer type not supported for webgl');
1108
+ }
1109
+ }
1110
+ /** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(offset) {
1111
+ return null;
1112
+ }
1113
+ /** @internal */ genTypeId() {
1114
+ return `PTR:(${this.pointerType.typeId})`;
1115
+ }
1116
+ }
1117
+ /**
1118
+ * The atomic int type info
1119
+ * @public
1120
+ */ class PBAtomicI32TypeInfo extends PBTypeInfo {
1121
+ constructor(){
1122
+ super(PBTypeClass.ATOMIC_I32, null);
1123
+ }
1124
+ /** @internal */ isAtomicI32() {
1125
+ return true;
1126
+ }
1127
+ /** @internal */ isHostSharable() {
1128
+ return true;
1129
+ }
1130
+ /** @internal */ isStorable() {
1131
+ return true;
1132
+ }
1133
+ /** @internal */ toTypeName(deviceType, varName) {
1134
+ if (deviceType === 'webgpu') {
1135
+ const typename = 'atomic<i32>';
1136
+ return varName ? `${varName}: ${typename}` : typename;
1137
+ } else {
1138
+ throw new Error('atomic type not supported for webgl');
1139
+ }
1140
+ }
1141
+ /** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(offset) {
1142
+ return null;
1143
+ }
1144
+ /** @internal */ getLayoutAlignment(layout) {
1145
+ return 4;
1146
+ }
1147
+ /** @internal */ getLayoutSize() {
1148
+ return this.getSize();
1149
+ }
1150
+ /** @internal */ getSize() {
1151
+ return 4;
1152
+ }
1153
+ /** @internal */ genTypeId() {
1154
+ return `ATOMICI32`;
1155
+ }
1156
+ }
1157
+ /**
1158
+ * The atomic int type info
1159
+ * @public
1160
+ */ class PBAtomicU32TypeInfo extends PBTypeInfo {
1161
+ constructor(){
1162
+ super(PBTypeClass.ATOMIC_U32, null);
1163
+ }
1164
+ /** @internal */ isAtomicU32() {
1165
+ return true;
1166
+ }
1167
+ /** @internal */ isHostSharable() {
1168
+ return true;
1169
+ }
1170
+ /** @internal */ isStorable() {
1171
+ return true;
1172
+ }
1173
+ /** @internal */ toTypeName(deviceType, varName) {
1174
+ if (deviceType === 'webgpu') {
1175
+ const typename = 'atomic<u32>';
1176
+ return varName ? `${varName}: ${typename}` : typename;
1177
+ } else {
1178
+ throw new Error('atomic type not supported for webgl');
1179
+ }
1180
+ }
1181
+ /** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(offset) {
1182
+ return null;
1183
+ }
1184
+ /** @internal */ getLayoutAlignment(layout) {
1185
+ return 4;
1186
+ }
1187
+ /** @internal */ getLayoutSize() {
1188
+ return this.getSize();
1189
+ }
1190
+ /** @internal */ getSize() {
1191
+ return 4;
1192
+ }
1193
+ /** @internal */ genTypeId() {
1194
+ return `ATOMICU32`;
1195
+ }
1196
+ }
1197
+ /**
1198
+ * The sampler type info
1199
+ * @public
1200
+ */ class PBSamplerTypeInfo extends PBTypeInfo {
1201
+ constructor(accessMode){
1202
+ super(PBTypeClass.SAMPLER, {
1203
+ accessMode: accessMode
1204
+ });
1205
+ }
1206
+ /** Get the access mode */ get accessMode() {
1207
+ return this.detail.accessMode;
1208
+ }
1209
+ /** @internal */ isSamplerType() {
1210
+ return true;
1211
+ }
1212
+ /** @internal */ isStorable() {
1213
+ return true;
1214
+ }
1215
+ /** @internal */ toTypeName(deviceType, varName) {
1216
+ if (deviceType === 'webgpu') {
1217
+ const typename = this.accessMode === PBSamplerAccessMode.SAMPLE ? 'sampler' : 'sampler_comparison';
1218
+ return varName ? `${varName}: ${typename}` : typename;
1219
+ } else {
1220
+ throw new Error('sampler type not supported for webgl');
1221
+ }
1222
+ }
1223
+ /** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(offset) {
1224
+ return null;
1225
+ }
1226
+ /** @internal */ genTypeId() {
1227
+ return `SAMPLER:${this.accessMode}`;
1228
+ }
1229
+ }
1230
+ /**
1231
+ * The texture type info
1232
+ * @public
1233
+ */ class PBTextureTypeInfo extends PBTypeInfo {
1234
+ constructor(textureType, texelFormat, readable, writable){
1235
+ super(PBTypeClass.TEXTURE, {
1236
+ textureType: textureType,
1237
+ readable,
1238
+ writable,
1239
+ storageTexelFormat: texelFormat || null
1240
+ });
1241
+ console.assert(!!textureTypeMapWGSL[textureType], 'unsupported texture type');
1242
+ console.assert(!(textureType & BITFLAG_STORAGE) || !!storageTexelFormatMap[texelFormat], 'invalid texel format for storage texture');
1243
+ }
1244
+ /** Get the texture type */ get textureType() {
1245
+ return this.detail.textureType;
1246
+ }
1247
+ /** Get texture format if this is a storage texture */ get storageTexelFormat() {
1248
+ return this.detail.storageTexelFormat;
1249
+ }
1250
+ /** Returns true if this is a readable storage texture type */ get readable() {
1251
+ return this.detail.readable;
1252
+ }
1253
+ /** Returns true if this is a writable storage texture type */ get writable() {
1254
+ return this.detail.writable;
1255
+ }
1256
+ /** @internal */ isStorable() {
1257
+ return true;
1258
+ }
1259
+ /** @internal */ is1DTexture() {
1260
+ return !!(this.detail.textureType & BITFLAG_1D);
1261
+ }
1262
+ /** Returns true if this is a 2D texture type */ is2DTexture() {
1263
+ return !!(this.detail.textureType & BITFLAG_2D);
1264
+ }
1265
+ /** Returns true if this is a 3D texture type */ is3DTexture() {
1266
+ return !!(this.detail.textureType & BITFLAG_3D);
1267
+ }
1268
+ /** Returns true if this is a cube texture type */ isCubeTexture() {
1269
+ return !!(this.detail.textureType & BITFLAG_CUBE);
1270
+ }
1271
+ /** Returns true if this is an array texture type */ isArrayTexture() {
1272
+ return !!(this.detail.textureType & BITFLAG_ARRAY);
1273
+ }
1274
+ /** Returns true if this is a storage texture type */ isStorageTexture() {
1275
+ return !!(this.detail.textureType & BITFLAG_STORAGE);
1276
+ }
1277
+ /** Return s true if this is a depth texture type */ isDepthTexture() {
1278
+ return !!(this.detail.textureType & BITFLAG_DEPTH);
1279
+ }
1280
+ /** Returns true if this is a multisampled texture type */ isMultisampledTexture() {
1281
+ return !!(this.detail.textureType & BITFLAG_MULTISAMPLED);
1282
+ }
1283
+ /** Returns true if this is an external texture type */ isExternalTexture() {
1284
+ return !!(this.detail.textureType & BITFLAG_EXTERNAL);
1285
+ }
1286
+ /** Returns true if the texture format is of type integer */ isIntTexture() {
1287
+ return !!(this.detail.textureType & BITFLAG_INT);
1288
+ }
1289
+ /** Returns true if the texture format is of type unsigned integer */ isUIntTexture() {
1290
+ return !!(this.detail.textureType & BITFLAG_UINT);
1291
+ }
1292
+ /** @internal */ isTextureType() {
1293
+ return true;
1294
+ }
1295
+ /** @internal */ toTypeName(deviceType, varName) {
1296
+ if (deviceType === 'webgpu') {
1297
+ let typename = textureTypeMapWGSL[this.textureType];
1298
+ if (this.isStorageTexture()) {
1299
+ const storageTexelFormat = storageTexelFormatMap[this.storageTexelFormat];
1300
+ // storage textures currently only support 'write' access control
1301
+ const accessMode = 'write'; //this.readable ? (this.writable ? 'read_write' : 'read') : 'write';
1302
+ typename = `${typename}<${storageTexelFormat}, ${accessMode}>`;
1303
+ }
1304
+ return varName ? `${varName}: ${typename}` : typename;
1305
+ } else {
1306
+ const typename = (deviceType === 'webgl' ? textureTypeMapWebGL : textureTypeMapWebGL2)[this.textureType];
1307
+ console.assert(!!typename, 'unsupported texture type');
1308
+ return varName ? `${typename} ${varName}` : typename;
1309
+ }
1310
+ }
1311
+ /** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(offset) {
1312
+ return null;
1313
+ }
1314
+ /** @internal */ genTypeId() {
1315
+ return `TEXTURE:${this.textureType}`;
1316
+ }
1317
+ }
1318
+ /**
1319
+ * The function type info
1320
+ * @public
1321
+ */ class PBFunctionTypeInfo extends PBTypeInfo {
1322
+ constructor(name, returnType, argTypes){
1323
+ super(PBTypeClass.FUNCTION, {
1324
+ name,
1325
+ returnType,
1326
+ argTypes
1327
+ });
1328
+ }
1329
+ /** Get name of the function */ get name() {
1330
+ return this.detail.name;
1331
+ }
1332
+ /** Get return type of the function */ get returnType() {
1333
+ return this.detail.returnType;
1334
+ }
1335
+ /** Get all the argument types for this function */ get argTypes() {
1336
+ return this.detail.argTypes;
1337
+ }
1338
+ /** Get hash for parameter types */ get argHash() {
1339
+ return this.argTypes.map((val)=>val.type.typeId).join(',');
1340
+ }
1341
+ /** @internal */ genTypeId() {
1342
+ return `fn(${this.argHash}):${this.returnType.typeId}`;
1343
+ }
1344
+ /** {@inheritDoc PBTypeInfo.toBufferLayout} */ toBufferLayout(offset) {
1345
+ return null;
1346
+ }
1347
+ /** @internal */ toTypeName(deviceType, varName) {
1348
+ throw new Error('not supported');
1349
+ }
1350
+ }
1351
+ /** @internal */ const typeF16 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.F16);
1352
+ /** @internal */ const typeF16Vec2 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.F16VEC2);
1353
+ /** @internal */ const typeF16Vec3 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.F16VEC3);
1354
+ /** @internal */ const typeF16Vec4 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.F16VEC4);
1355
+ /** @internal */ const typeF32 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.F32);
1356
+ /** @internal */ const typeF32Vec2 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.F32VEC2);
1357
+ /** @internal */ const typeF32Vec3 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.F32VEC3);
1358
+ /** @internal */ const typeF32Vec4 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.F32VEC4);
1359
+ /** @internal */ const typeI8 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I8);
1360
+ /** @internal */ const typeI8Vec2 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I8VEC2);
1361
+ /** @internal */ const typeI8Vec3 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I8VEC3);
1362
+ /** @internal */ const typeI8Vec4 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I8VEC4);
1363
+ /** @internal */ const typeI8_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I8_NORM);
1364
+ /** @internal */ const typeI8Vec2_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I8VEC2_NORM);
1365
+ /** @internal */ const typeI8Vec3_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I8VEC3_NORM);
1366
+ /** @internal */ const typeI8Vec4_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I8VEC4_NORM);
1367
+ /** @internal */ const typeI16 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I16);
1368
+ /** @internal */ const typeI16Vec2 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I16VEC2);
1369
+ /** @internal */ const typeI16Vec3 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I16VEC3);
1370
+ /** @internal */ const typeI16Vec4 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I16VEC4);
1371
+ /** @internal */ const typeI16_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I16_NORM);
1372
+ /** @internal */ const typeI16Vec2_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I16VEC2_NORM);
1373
+ /** @internal */ const typeI16Vec3_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I16VEC3_NORM);
1374
+ /** @internal */ const typeI16Vec4_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I16VEC4_NORM);
1375
+ /** @internal */ const typeAtomicI32 = new PBAtomicI32TypeInfo();
1376
+ /** @internal */ const typeAtomicU32 = new PBAtomicU32TypeInfo();
1377
+ /** @internal */ const typeI32 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I32);
1378
+ /** @internal */ const typeI32Vec2 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I32VEC2);
1379
+ /** @internal */ const typeI32Vec3 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I32VEC3);
1380
+ /** @internal */ const typeI32Vec4 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I32VEC4);
1381
+ /** @internal */ const typeI32_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I32);
1382
+ /** @internal */ const typeI32Vec2_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I32VEC2_NORM);
1383
+ /** @internal */ const typeI32Vec3_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I32VEC3_NORM);
1384
+ /** @internal */ const typeI32Vec4_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.I32VEC4_NORM);
1385
+ /** @internal */ const typeU8 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U8);
1386
+ /** @internal */ const typeU8Vec2 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U8VEC2);
1387
+ /** @internal */ const typeU8Vec3 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U8VEC3);
1388
+ /** @internal */ const typeU8Vec4 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U8VEC4);
1389
+ /** @internal */ const typeU8_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U8_NORM);
1390
+ /** @internal */ const typeU8Vec2_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U8VEC2_NORM);
1391
+ /** @internal */ const typeU8Vec3_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U8VEC3_NORM);
1392
+ /** @internal */ const typeU8Vec4_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U8VEC4_NORM);
1393
+ /** @internal */ const typeU16 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U16);
1394
+ /** @internal */ const typeU16Vec2 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U16VEC2);
1395
+ /** @internal */ const typeU16Vec3 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U16VEC3);
1396
+ /** @internal */ const typeU16Vec4 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U16VEC4);
1397
+ /** @internal */ const typeU16_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U16_NORM);
1398
+ /** @internal */ const typeU16Vec2_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U16VEC2_NORM);
1399
+ /** @internal */ const typeU16Vec3_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U16VEC3_NORM);
1400
+ /** @internal */ const typeU16Vec4_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U16VEC4_NORM);
1401
+ /** @internal */ const typeU32 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U32);
1402
+ /** @internal */ const typeU32Vec2 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U32VEC2);
1403
+ /** @internal */ const typeU32Vec3 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U32VEC3);
1404
+ /** @internal */ const typeU32Vec4 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U32VEC4);
1405
+ /** @internal */ const typeU32_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U32_NORM);
1406
+ /** @internal */ const typeU32Vec2_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U32VEC2_NORM);
1407
+ /** @internal */ const typeU32Vec3_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U32VEC3_NORM);
1408
+ /** @internal */ const typeU32Vec4_Norm = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.U32VEC4_NORM);
1409
+ /** @internal */ const typeBool = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.BOOL);
1410
+ /** @internal */ const typeBVec2 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.BVEC2);
1411
+ /** @internal */ const typeBVec3 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.BVEC3);
1412
+ /** @internal */ const typeBVec4 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.BVEC4);
1413
+ /** @internal */ const typeMat2 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.MAT2);
1414
+ /** @internal */ const typeMat2x3 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.MAT2x3);
1415
+ /** @internal */ const typeMat2x4 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.MAT2x4);
1416
+ /** @internal */ const typeMat3x2 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.MAT3x2);
1417
+ /** @internal */ const typeMat3 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.MAT3);
1418
+ /** @internal */ const typeMat3x4 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.MAT3x4);
1419
+ /** @internal */ const typeMat4x2 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.MAT4x2);
1420
+ /** @internal */ const typeMat4x3 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.MAT4x3);
1421
+ /** @internal */ const typeMat4 = PBPrimitiveTypeInfo.getCachedTypeInfo(PBPrimitiveType.MAT4);
1422
+ /** @internal */ const typeTex1D = new PBTextureTypeInfo(PBTextureType.TEX_1D);
1423
+ /** @internal */ const typeITex1D = new PBTextureTypeInfo(PBTextureType.ITEX_1D);
1424
+ /** @internal */ const typeUTex1D = new PBTextureTypeInfo(PBTextureType.UTEX_1D);
1425
+ /** @internal */ const typeTex2D = new PBTextureTypeInfo(PBTextureType.TEX_2D);
1426
+ /** @internal */ const typeITex2D = new PBTextureTypeInfo(PBTextureType.ITEX_2D);
1427
+ /** @internal */ const typeUTex2D = new PBTextureTypeInfo(PBTextureType.UTEX_2D);
1428
+ /** @internal */ const typeTex2DArray = new PBTextureTypeInfo(PBTextureType.TEX_2D_ARRAY);
1429
+ /** @internal */ const typeITex2DArray = new PBTextureTypeInfo(PBTextureType.ITEX_2D_ARRAY);
1430
+ /** @internal */ const typeUTex2DArray = new PBTextureTypeInfo(PBTextureType.UTEX_2D_ARRAY);
1431
+ /** @internal */ const typeTex3D = new PBTextureTypeInfo(PBTextureType.TEX_3D);
1432
+ /** @internal */ const typeITex3D = new PBTextureTypeInfo(PBTextureType.ITEX_3D);
1433
+ /** @internal */ const typeUTex3D = new PBTextureTypeInfo(PBTextureType.UTEX_3D);
1434
+ /** @internal */ const typeTexCube = new PBTextureTypeInfo(PBTextureType.TEX_CUBE);
1435
+ /** @internal */ const typeITexCube = new PBTextureTypeInfo(PBTextureType.ITEX_CUBE);
1436
+ /** @internal */ const typeUTexCube = new PBTextureTypeInfo(PBTextureType.UTEX_CUBE);
1437
+ /** @internal */ const typeTexExternal = new PBTextureTypeInfo(PBTextureType.TEX_EXTERNAL);
1438
+ /** @internal */ const typeTexCubeArray = new PBTextureTypeInfo(PBTextureType.TEX_CUBE_ARRAY);
1439
+ /** @internal */ const typeITexCubeArray = new PBTextureTypeInfo(PBTextureType.ITEX_CUBE_ARRAY);
1440
+ /** @internal */ const typeUTexCubeArray = new PBTextureTypeInfo(PBTextureType.UTEX_CUBE_ARRAY);
1441
+ /** @internal */ const typeTexMultisampled2D = new PBTextureTypeInfo(PBTextureType.TEX_MULTISAMPLED_2D);
1442
+ /** @internal */ const typeITexMultisampled2D = new PBTextureTypeInfo(PBTextureType.ITEX_MULTISAMPLED_2D);
1443
+ /** @internal */ const typeUTexMultisampled2D = new PBTextureTypeInfo(PBTextureType.UTEX_MULTISAMPLED_2D);
1444
+ /** @internal */ const typeTexStorage1D_rgba8unorm = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'rgba8unorm');
1445
+ /** @internal */ const typeTexStorage1D_rgba8snorm = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'rgba8snorm');
1446
+ /** @internal */ const typeTexStorage1D_bgra8unorm = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'rgba8unorm');
1447
+ /** @internal */ const typeTexStorage1D_rgba8uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'rgba8ui');
1448
+ /** @internal */ const typeTexStorage1D_rgba8sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'rgba8i');
1449
+ /** @internal */ const typeTexStorage1D_rgba16uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'rgba16ui');
1450
+ /** @internal */ const typeTexStorage1D_rgba16sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'rgba16i');
1451
+ /** @internal */ const typeTexStorage1D_rgba16float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'rgba16f');
1452
+ /** @internal */ const typeTexStorage1D_rgba32uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'rgba32ui');
1453
+ /** @internal */ const typeTexStorage1D_rgba32sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'rgba32i');
1454
+ /** @internal */ const typeTexStorage1D_rgba32float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'rgba32f');
1455
+ /** @internal */ const typeTexStorage1D_rg32uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'rg32ui');
1456
+ /** @internal */ const typeTexStorage1D_rg32sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'rg32i');
1457
+ /** @internal */ const typeTexStorage1D_rg32float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'rg32f');
1458
+ /** @internal */ const typeTexStorage1D_r32uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'r32ui');
1459
+ /** @internal */ const typeTexStorage1D_r32sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'r32i');
1460
+ /** @internal */ const typeTexStorage1D_r32float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_1D, 'r32f');
1461
+ /** @internal */ const typeTexStorage2D_rgba8unorm = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'rgba8unorm');
1462
+ /** @internal */ const typeTexStorage2D_rgba8snorm = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'rgba8snorm');
1463
+ /** @internal */ const typeTexStorage2D_bgra8unorm = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'bgra8unorm');
1464
+ /** @internal */ const typeTexStorage2D_rgba8uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'rgba8ui');
1465
+ /** @internal */ const typeTexStorage2D_rgba8sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'rgba8i');
1466
+ /** @internal */ const typeTexStorage2D_rgba16uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'rgba16ui');
1467
+ /** @internal */ const typeTexStorage2D_rgba16sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'rgba16i');
1468
+ /** @internal */ const typeTexStorage2D_rgba16float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'rgba16f');
1469
+ /** @internal */ const typeTexStorage2D_rgba32uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'rgba32ui');
1470
+ /** @internal */ const typeTexStorage2D_rgba32sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'rgba32i');
1471
+ /** @internal */ const typeTexStorage2D_rgba32float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'rgba32f');
1472
+ /** @internal */ const typeTexStorage2D_rg32uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'rg32ui');
1473
+ /** @internal */ const typeTexStorage2D_rg32sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'rg32i');
1474
+ /** @internal */ const typeTexStorage2D_rg32float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'rg32f');
1475
+ /** @internal */ const typeTexStorage2D_r32uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'r32ui');
1476
+ /** @internal */ const typeTexStorage2D_r32sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'r32i');
1477
+ /** @internal */ const typeTexStorage2D_r32float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D, 'r32f');
1478
+ /** @internal */ const typeTexStorage2DArray_rgba8unorm = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'rgba8unorm');
1479
+ /** @internal */ const typeTexStorage2DArray_rgba8snorm = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'rgba8snorm');
1480
+ /** @internal */ const typeTexStorage2DArray_bgra8unorm = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'bgra8unorm');
1481
+ /** @internal */ const typeTexStorage2DArray_rgba8uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'rgba8ui');
1482
+ /** @internal */ const typeTexStorage2DArray_rgba8sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'rgba8i');
1483
+ /** @internal */ const typeTexStorage2DArray_rgba16uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'rgba16ui');
1484
+ /** @internal */ const typeTexStorage2DArray_rgba16sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'rgba16i');
1485
+ /** @internal */ const typeTexStorage2DArray_rgba16float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'rgba16f');
1486
+ /** @internal */ const typeTexStorage2DArray_rgba32uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'rgba32ui');
1487
+ /** @internal */ const typeTexStorage2DArray_rgba32sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'rgba32i');
1488
+ /** @internal */ const typeTexStorage2DArray_rgba32float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'rgba32f');
1489
+ /** @internal */ const typeTexStorage2DArray_rg32uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'rg32ui');
1490
+ /** @internal */ const typeTexStorage2DArray_rg32sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'rg32i');
1491
+ /** @internal */ const typeTexStorage2DArray_rg32float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'rg32f');
1492
+ /** @internal */ const typeTexStorage2DArray_r32uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'r32ui');
1493
+ /** @internal */ const typeTexStorage2DArray_r32sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'r32i');
1494
+ /** @internal */ const typeTexStorage2DArray_r32float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_2D_ARRAY, 'r32f');
1495
+ /** @internal */ const typeTexStorage3D_rgba8unorm = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'rgba8unorm');
1496
+ /** @internal */ const typeTexStorage3D_rgba8snorm = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'rgba8snorm');
1497
+ /** @internal */ const typeTexStorage3D_bgra8unorm = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'bgra8unorm');
1498
+ /** @internal */ const typeTexStorage3D_rgba8uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'rgba8ui');
1499
+ /** @internal */ const typeTexStorage3D_rgba8sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'rgba8i');
1500
+ /** @internal */ const typeTexStorage3D_rgba16uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'rgba16ui');
1501
+ /** @internal */ const typeTexStorage3D_rgba16sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'rgba16i');
1502
+ /** @internal */ const typeTexStorage3D_rgba16float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'rgba16f');
1503
+ /** @internal */ const typeTexStorage3D_rgba32uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'rgba32ui');
1504
+ /** @internal */ const typeTexStorage3D_rgba32sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'rgba32i');
1505
+ /** @internal */ const typeTexStorage3D_rgba32float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'rgba32f');
1506
+ /** @internal */ const typeTexStorage3D_rg32uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'rg32ui');
1507
+ /** @internal */ const typeTexStorage3D_rg32sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'rg32i');
1508
+ /** @internal */ const typeTexStorage3D_rg32float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'rg32f');
1509
+ /** @internal */ const typeTexStorage3D_r32uint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'r32ui');
1510
+ /** @internal */ const typeTexStorage3D_r32sint = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'r32i');
1511
+ /** @internal */ const typeTexStorage3D_r32float = new PBTextureTypeInfo(PBTextureType.TEX_STORAGE_3D, 'r32f');
1512
+ /** @internal */ const typeTexDepth2D = new PBTextureTypeInfo(PBTextureType.TEX_DEPTH_2D);
1513
+ /** @internal */ const typeTexDepth2DArray = new PBTextureTypeInfo(PBTextureType.TEX_DEPTH_2D_ARRAY);
1514
+ /** @internal */ const typeTexDepthCube = new PBTextureTypeInfo(PBTextureType.TEX_DEPTH_CUBE);
1515
+ /** @internal */ const typeTexDepthCubeArray = new PBTextureTypeInfo(PBTextureType.TEX_DEPTH_CUBE_ARRAY);
1516
+ /** @internal */ const typeTexDepthMultisampled2D = new PBTextureTypeInfo(PBTextureType.TEX_DEPTH_MULTISAMPLED_2D);
1517
+ /** @internal */ const typeSampler = new PBSamplerTypeInfo(PBSamplerAccessMode.SAMPLE);
1518
+ /** @internal */ const typeSamplerComparison = new PBSamplerTypeInfo(PBSamplerAccessMode.COMPARISON);
1519
+ /** @internal */ const typeVoid = new PBVoidTypeInfo();
1520
+ /** @internal */ const typeAny = new PBAnyTypeInfo();
1521
+ /** @internal */ const typeFrexpResult = new PBStructTypeInfo('FrexpResult', 'default', [
1522
+ {
1523
+ name: 'sig',
1524
+ type: typeF32
1525
+ },
1526
+ {
1527
+ name: 'exp',
1528
+ type: typeI32
1529
+ }
1530
+ ]);
1531
+ /** @internal */ const typeFrexpResultVec2 = new PBStructTypeInfo('FrexpResultVec2', 'default', [
1532
+ {
1533
+ name: 'sig',
1534
+ type: typeF32Vec2
1535
+ },
1536
+ {
1537
+ name: 'exp',
1538
+ type: typeI32Vec2
1539
+ }
1540
+ ]);
1541
+ /** @internal */ const typeFrexpResultVec3 = new PBStructTypeInfo('FrexpResultVec3', 'default', [
1542
+ {
1543
+ name: 'sig',
1544
+ type: typeF32Vec3
1545
+ },
1546
+ {
1547
+ name: 'exp',
1548
+ type: typeI32Vec3
1549
+ }
1550
+ ]);
1551
+ /** @internal */ const typeFrexpResultVec4 = new PBStructTypeInfo('FrexpResultVec4', 'default', [
1552
+ {
1553
+ name: 'sig',
1554
+ type: typeF32Vec4
1555
+ },
1556
+ {
1557
+ name: 'exp',
1558
+ type: typeI32Vec4
1559
+ }
1560
+ ]);
1561
+
1562
+ export { PBAddressSpace, PBAnyTypeInfo, PBArrayTypeInfo, PBAtomicI32TypeInfo, PBAtomicU32TypeInfo, PBFunctionTypeInfo, PBPointerTypeInfo, PBPrimitiveType, PBPrimitiveTypeInfo, PBSamplerAccessMode, PBSamplerTypeInfo, PBStructTypeInfo, PBTextureType, PBTextureTypeInfo, PBTypeInfo, PBVoidTypeInfo, typeAny, typeAtomicI32, typeAtomicU32, typeBVec2, typeBVec3, typeBVec4, typeBool, typeF16, typeF16Vec2, typeF16Vec3, typeF16Vec4, typeF32, typeF32Vec2, typeF32Vec3, typeF32Vec4, typeFrexpResult, typeFrexpResultVec2, typeFrexpResultVec3, typeFrexpResultVec4, typeI16, typeI16Vec2, typeI16Vec2_Norm, typeI16Vec3, typeI16Vec3_Norm, typeI16Vec4, typeI16Vec4_Norm, typeI16_Norm, typeI32, typeI32Vec2, typeI32Vec2_Norm, typeI32Vec3, typeI32Vec3_Norm, typeI32Vec4, typeI32Vec4_Norm, typeI32_Norm, typeI8, typeI8Vec2, typeI8Vec2_Norm, typeI8Vec3, typeI8Vec3_Norm, typeI8Vec4, typeI8Vec4_Norm, typeI8_Norm, typeITex1D, typeITex2D, typeITex2DArray, typeITex3D, typeITexCube, typeITexCubeArray, typeITexMultisampled2D, typeMat2, typeMat2x3, typeMat2x4, typeMat3, typeMat3x2, typeMat3x4, typeMat4, typeMat4x2, typeMat4x3, typeSampler, typeSamplerComparison, typeTex1D, typeTex2D, typeTex2DArray, typeTex3D, typeTexCube, typeTexCubeArray, typeTexDepth2D, typeTexDepth2DArray, typeTexDepthCube, typeTexDepthCubeArray, typeTexDepthMultisampled2D, typeTexExternal, typeTexMultisampled2D, typeTexStorage1D_bgra8unorm, typeTexStorage1D_r32float, typeTexStorage1D_r32sint, typeTexStorage1D_r32uint, typeTexStorage1D_rg32float, typeTexStorage1D_rg32sint, typeTexStorage1D_rg32uint, typeTexStorage1D_rgba16float, typeTexStorage1D_rgba16sint, typeTexStorage1D_rgba16uint, typeTexStorage1D_rgba32float, typeTexStorage1D_rgba32sint, typeTexStorage1D_rgba32uint, typeTexStorage1D_rgba8sint, typeTexStorage1D_rgba8snorm, typeTexStorage1D_rgba8uint, typeTexStorage1D_rgba8unorm, typeTexStorage2DArray_bgra8unorm, typeTexStorage2DArray_r32float, typeTexStorage2DArray_r32sint, typeTexStorage2DArray_r32uint, typeTexStorage2DArray_rg32float, typeTexStorage2DArray_rg32sint, typeTexStorage2DArray_rg32uint, typeTexStorage2DArray_rgba16float, typeTexStorage2DArray_rgba16sint, typeTexStorage2DArray_rgba16uint, typeTexStorage2DArray_rgba32float, typeTexStorage2DArray_rgba32sint, typeTexStorage2DArray_rgba32uint, typeTexStorage2DArray_rgba8sint, typeTexStorage2DArray_rgba8snorm, typeTexStorage2DArray_rgba8uint, typeTexStorage2DArray_rgba8unorm, typeTexStorage2D_bgra8unorm, typeTexStorage2D_r32float, typeTexStorage2D_r32sint, typeTexStorage2D_r32uint, typeTexStorage2D_rg32float, typeTexStorage2D_rg32sint, typeTexStorage2D_rg32uint, typeTexStorage2D_rgba16float, typeTexStorage2D_rgba16sint, typeTexStorage2D_rgba16uint, typeTexStorage2D_rgba32float, typeTexStorage2D_rgba32sint, typeTexStorage2D_rgba32uint, typeTexStorage2D_rgba8sint, typeTexStorage2D_rgba8snorm, typeTexStorage2D_rgba8uint, typeTexStorage2D_rgba8unorm, typeTexStorage3D_bgra8unorm, typeTexStorage3D_r32float, typeTexStorage3D_r32sint, typeTexStorage3D_r32uint, typeTexStorage3D_rg32float, typeTexStorage3D_rg32sint, typeTexStorage3D_rg32uint, typeTexStorage3D_rgba16float, typeTexStorage3D_rgba16sint, typeTexStorage3D_rgba16uint, typeTexStorage3D_rgba32float, typeTexStorage3D_rgba32sint, typeTexStorage3D_rgba32uint, typeTexStorage3D_rgba8sint, typeTexStorage3D_rgba8snorm, typeTexStorage3D_rgba8uint, typeTexStorage3D_rgba8unorm, typeU16, typeU16Vec2, typeU16Vec2_Norm, typeU16Vec3, typeU16Vec3_Norm, typeU16Vec4, typeU16Vec4_Norm, typeU16_Norm, typeU32, typeU32Vec2, typeU32Vec2_Norm, typeU32Vec3, typeU32Vec3_Norm, typeU32Vec4, typeU32Vec4_Norm, typeU32_Norm, typeU8, typeU8Vec2, typeU8Vec2_Norm, typeU8Vec3, typeU8Vec3_Norm, typeU8Vec4, typeU8Vec4_Norm, typeU8_Norm, typeUTex1D, typeUTex2D, typeUTex2DArray, typeUTex3D, typeUTexCube, typeUTexCubeArray, typeUTexMultisampled2D, typeVoid };
1563
+ //# sourceMappingURL=types.js.map