typegpu 0.5.2 → 0.5.4

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 (45) hide show
  1. package/README.md +1 -1
  2. package/attributes-BdU8hyQq.d.cts +435 -0
  3. package/attributes-CAsvE5Z9.d.ts +435 -0
  4. package/chunk-5PJ3H5OR.js +2 -0
  5. package/chunk-5PJ3H5OR.js.map +1 -0
  6. package/chunk-7UUBX6MC.cjs +4 -0
  7. package/chunk-7UUBX6MC.cjs.map +1 -0
  8. package/chunk-AKBL6GDL.js +4 -0
  9. package/chunk-AKBL6GDL.js.map +1 -0
  10. package/chunk-URJCMUTT.cjs +2 -0
  11. package/chunk-URJCMUTT.cjs.map +1 -0
  12. package/data/index.cjs +1 -1
  13. package/data/index.cjs.map +1 -1
  14. package/data/index.d.cts +51 -4
  15. package/data/index.d.ts +51 -4
  16. package/data/index.js +1 -1
  17. package/index.cjs +17 -17
  18. package/index.cjs.map +1 -1
  19. package/index.d.cts +92 -53
  20. package/index.d.ts +92 -53
  21. package/index.js +17 -17
  22. package/index.js.map +1 -1
  23. package/package.json +2 -2
  24. package/std/index.cjs +1 -1
  25. package/std/index.cjs.map +1 -1
  26. package/std/index.d.cts +141 -33
  27. package/std/index.d.ts +141 -33
  28. package/std/index.js +1 -1
  29. package/std/index.js.map +1 -1
  30. package/{wgslTypes-VtSRoe90.d.ts → wgslTypes-Bh2dG5qv.d.cts} +213 -405
  31. package/{wgslTypes-VtSRoe90.d.cts → wgslTypes-Bh2dG5qv.d.ts} +213 -405
  32. package/attributes-B4JpvOTz.d.ts +0 -159
  33. package/attributes-DSOqT8yA.d.cts +0 -159
  34. package/chunk-3JTP2ATR.cjs +0 -2
  35. package/chunk-3JTP2ATR.cjs.map +0 -1
  36. package/chunk-3QXCKMEJ.cjs +0 -2
  37. package/chunk-3QXCKMEJ.cjs.map +0 -1
  38. package/chunk-DR55IHDD.js +0 -4
  39. package/chunk-DR55IHDD.js.map +0 -1
  40. package/chunk-KVOFUY5A.js +0 -2
  41. package/chunk-KVOFUY5A.js.map +0 -1
  42. package/chunk-QRLTUOBJ.cjs +0 -4
  43. package/chunk-QRLTUOBJ.cjs.map +0 -1
  44. package/chunk-VOFHV4Z6.js +0 -2
  45. package/chunk-VOFHV4Z6.js.map +0 -1
@@ -0,0 +1,435 @@
1
+ import { D as Decorated, l as Vec3u, aa as Builtin, U as U32, d as Vec4f, q as WgslArray, F as F32, B as BaseData, $ as $repr, I as Infer, k as Vec2u, m as Vec4u, b as I32, h as Vec2i, j as Vec4i, V as Vec2f, c as Vec3f, i as Vec3i, A as AnyWgslData, s as InferPartial, T as TgpuNamable, P as Prettify, al as InferRecord, am as InferPartialRecord, a9 as Align, a8 as Size, L as Location, ab as Interpolate, an as InterpolationType, r as WgslTypeLiteral, ao as PerspectiveOrLinearInterpolationType, ap as PerspectiveOrLinearInterpolatableData, aq as FlatInterpolationType, ar as FlatInterpolatableData } from './wgslTypes-Bh2dG5qv.js';
2
+
3
+ type BuiltinVertexIndex = Decorated<U32, [Builtin<'vertex_index'>]>;
4
+ type BuiltinInstanceIndex = Decorated<U32, [Builtin<'instance_index'>]>;
5
+ type BuiltinPosition = Decorated<Vec4f, [Builtin<'position'>]>;
6
+ type BuiltinClipDistances = Decorated<WgslArray<U32>, [
7
+ Builtin<'clip_distances'>
8
+ ]>;
9
+ type BuiltinFrontFacing = Decorated<F32, [Builtin<'front_facing'>]>;
10
+ type BuiltinFragDepth = Decorated<F32, [Builtin<'frag_depth'>]>;
11
+ type BuiltinSampleIndex = Decorated<U32, [Builtin<'sample_index'>]>;
12
+ type BuiltinSampleMask = Decorated<U32, [Builtin<'sample_mask'>]>;
13
+ type BuiltinLocalInvocationId = Decorated<Vec3u, [
14
+ Builtin<'local_invocation_id'>
15
+ ]>;
16
+ type BuiltinLocalInvocationIndex = Decorated<U32, [
17
+ Builtin<'local_invocation_index'>
18
+ ]>;
19
+ type BuiltinGlobalInvocationId = Decorated<Vec3u, [
20
+ Builtin<'global_invocation_id'>
21
+ ]>;
22
+ type BuiltinWorkgroupId = Decorated<Vec3u, [Builtin<'workgroup_id'>]>;
23
+ type BuiltinNumWorkgroups = Decorated<Vec3u, [
24
+ Builtin<'num_workgroups'>
25
+ ]>;
26
+ type BuiltinSubgroupInvocationId = Decorated<U32, [
27
+ Builtin<'subgroup_invocation_id'>
28
+ ]>;
29
+ type BuiltinSubgroupSize = Decorated<U32, [Builtin<'subgroup_size'>]>;
30
+ declare const builtin: {
31
+ readonly vertexIndex: BuiltinVertexIndex;
32
+ readonly instanceIndex: BuiltinInstanceIndex;
33
+ readonly position: BuiltinPosition;
34
+ readonly clipDistances: BuiltinClipDistances;
35
+ readonly frontFacing: BuiltinFrontFacing;
36
+ readonly fragDepth: BuiltinFragDepth;
37
+ readonly sampleIndex: BuiltinSampleIndex;
38
+ readonly sampleMask: BuiltinSampleMask;
39
+ readonly localInvocationId: BuiltinLocalInvocationId;
40
+ readonly localInvocationIndex: BuiltinLocalInvocationIndex;
41
+ readonly globalInvocationId: BuiltinGlobalInvocationId;
42
+ readonly workgroupId: BuiltinWorkgroupId;
43
+ readonly numWorkgroups: BuiltinNumWorkgroups;
44
+ readonly subgroupInvocationId: BuiltinSubgroupInvocationId;
45
+ readonly subgroupSize: BuiltinSubgroupSize;
46
+ };
47
+ type AnyBuiltin = (typeof builtin)[keyof typeof builtin];
48
+ type AnyComputeBuiltin = BuiltinLocalInvocationId | BuiltinLocalInvocationIndex | BuiltinGlobalInvocationId | BuiltinWorkgroupId | BuiltinNumWorkgroups | BuiltinSubgroupInvocationId | BuiltinSubgroupSize;
49
+ type AnyFragmentInputBuiltin = BuiltinPosition | BuiltinFrontFacing | BuiltinSampleIndex | BuiltinSampleMask | BuiltinSubgroupInvocationId | BuiltinSubgroupSize;
50
+ type AnyFragmentOutputBuiltin = BuiltinFragDepth | BuiltinSampleMask;
51
+ type OmitBuiltins<S> = S extends AnyBuiltin ? never : S extends BaseData ? S : {
52
+ [Key in keyof S as S[Key] extends AnyBuiltin ? never : Key]: S[Key];
53
+ };
54
+
55
+ declare const vertexFormats: readonly ["uint8", "uint8x2", "uint8x4", "sint8", "sint8x2", "sint8x4", "unorm8", "unorm8x2", "unorm8x4", "snorm8", "snorm8x2", "snorm8x4", "uint16", "uint16x2", "uint16x4", "sint16", "sint16x2", "sint16x4", "unorm16", "unorm16x2", "unorm16x4", "snorm16", "snorm16x2", "snorm16x4", "float16", "float16x2", "float16x4", "float32", "float32x2", "float32x3", "float32x4", "uint32", "uint32x2", "uint32x3", "uint32x4", "sint32", "sint32x2", "sint32x3", "sint32x4", "unorm10-10-10-2", "unorm8x4-bgra"];
56
+ type VertexFormat = (typeof vertexFormats)[number];
57
+ declare const kindToDefaultFormatMap: {
58
+ readonly f32: "float32";
59
+ readonly vec2f: "float32x2";
60
+ readonly vec3f: "float32x3";
61
+ readonly vec4f: "float32x4";
62
+ readonly f16: "float16";
63
+ readonly vec2h: "float16x2";
64
+ readonly vec4h: "float16x4";
65
+ readonly u32: "uint32";
66
+ readonly vec2u: "uint32x2";
67
+ readonly vec3u: "uint32x3";
68
+ readonly vec4u: "uint32x4";
69
+ readonly i32: "sint32";
70
+ readonly vec2i: "sint32x2";
71
+ readonly vec3i: "sint32x3";
72
+ readonly vec4i: "sint32x4";
73
+ };
74
+ type KindToDefaultFormatMap = typeof kindToDefaultFormatMap;
75
+ interface TgpuVertexAttrib<TFormat extends VertexFormat = VertexFormat> {
76
+ readonly format: TFormat;
77
+ readonly offset: number;
78
+ }
79
+ /**
80
+ * All vertex attribute formats that can be interpreted as
81
+ * an single or multi component u32 in a shader.
82
+ * https://www.w3.org/TR/webgpu/#vertex-formats
83
+ */
84
+ type U32CompatibleFormats = TgpuVertexAttrib<'uint8'> | TgpuVertexAttrib<'uint8x2'> | TgpuVertexAttrib<'uint8x4'> | TgpuVertexAttrib<'uint16'> | TgpuVertexAttrib<'uint16x2'> | TgpuVertexAttrib<'uint16x4'> | TgpuVertexAttrib<'uint32'> | TgpuVertexAttrib<'uint32x2'> | TgpuVertexAttrib<'uint32x3'> | TgpuVertexAttrib<'uint32x4'>;
85
+ /**
86
+ * All vertex attribute formats that can be interpreted as
87
+ * an single or multi component i32 in a shader.
88
+ * https://www.w3.org/TR/webgpu/#vertex-formats
89
+ */
90
+ type I32CompatibleFormats = TgpuVertexAttrib<'sint8'> | TgpuVertexAttrib<'sint8x2'> | TgpuVertexAttrib<'sint8x4'> | TgpuVertexAttrib<'sint16'> | TgpuVertexAttrib<'sint16x2'> | TgpuVertexAttrib<'sint16x4'> | TgpuVertexAttrib<'sint32'> | TgpuVertexAttrib<'sint32x2'> | TgpuVertexAttrib<'sint32x3'> | TgpuVertexAttrib<'sint32x4'>;
91
+ /**
92
+ * All vertex attribute formats that can be interpreted as
93
+ * an single or multi component f32 in a shader.
94
+ * https://www.w3.org/TR/webgpu/#vertex-formats
95
+ */
96
+ type F32CompatibleFormats = TgpuVertexAttrib<'unorm8'> | TgpuVertexAttrib<'unorm8x2'> | TgpuVertexAttrib<'unorm8x4'> | TgpuVertexAttrib<'snorm8'> | TgpuVertexAttrib<'snorm8x2'> | TgpuVertexAttrib<'snorm8x4'> | TgpuVertexAttrib<'unorm16'> | TgpuVertexAttrib<'unorm16x2'> | TgpuVertexAttrib<'unorm16x4'> | TgpuVertexAttrib<'snorm16'> | TgpuVertexAttrib<'snorm16x2'> | TgpuVertexAttrib<'snorm16x4'> | TgpuVertexAttrib<'float16'> | TgpuVertexAttrib<'float16x2'> | TgpuVertexAttrib<'float16x4'> | TgpuVertexAttrib<'float32'> | TgpuVertexAttrib<'float32x2'> | TgpuVertexAttrib<'float32x3'> | TgpuVertexAttrib<'float32x4'> | TgpuVertexAttrib<'unorm10-10-10-2'> | TgpuVertexAttrib<'unorm8x4-bgra'>;
97
+ /**
98
+ * All vertex attribute formats that can be interpreted as
99
+ * a single or multi component f16 in a shader. (same as f32 on the shader side)
100
+ * https://www.w3.org/TR/webgpu/#vertex-formats
101
+ */
102
+ type F16CompatibleFormats = F32CompatibleFormats;
103
+ type KindToAcceptedAttribMap = {
104
+ u32: U32CompatibleFormats;
105
+ vec2u: U32CompatibleFormats;
106
+ vec3u: U32CompatibleFormats;
107
+ vec4u: U32CompatibleFormats;
108
+ i32: I32CompatibleFormats;
109
+ vec2i: I32CompatibleFormats;
110
+ vec3i: I32CompatibleFormats;
111
+ vec4i: I32CompatibleFormats;
112
+ f16: F16CompatibleFormats;
113
+ vec2h: F16CompatibleFormats;
114
+ vec3h: F16CompatibleFormats;
115
+ vec4h: F16CompatibleFormats;
116
+ f32: F32CompatibleFormats;
117
+ vec2f: F32CompatibleFormats;
118
+ vec3f: F32CompatibleFormats;
119
+ vec4f: F32CompatibleFormats;
120
+ };
121
+
122
+ type FormatToWGSLType<T extends VertexFormat> = (typeof formatToWGSLType)[T];
123
+ interface TgpuVertexFormatData<T extends VertexFormat> {
124
+ readonly type: T;
125
+ /** Type-token, not available at runtime */
126
+ readonly [$repr]: Infer<FormatToWGSLType<T>>;
127
+ }
128
+ declare const formatToWGSLType: {
129
+ readonly uint8: U32;
130
+ readonly uint8x2: Vec2u;
131
+ readonly uint8x4: Vec4u;
132
+ readonly sint8: I32;
133
+ readonly sint8x2: Vec2i;
134
+ readonly sint8x4: Vec4i;
135
+ readonly unorm8: F32;
136
+ readonly unorm8x2: Vec2f;
137
+ readonly unorm8x4: Vec4f;
138
+ readonly snorm8: F32;
139
+ readonly snorm8x2: Vec2f;
140
+ readonly snorm8x4: Vec4f;
141
+ readonly uint16: U32;
142
+ readonly uint16x2: Vec2u;
143
+ readonly uint16x4: Vec4u;
144
+ readonly sint16: I32;
145
+ readonly sint16x2: Vec2i;
146
+ readonly sint16x4: Vec4i;
147
+ readonly unorm16: F32;
148
+ readonly unorm16x2: Vec2f;
149
+ readonly unorm16x4: Vec4f;
150
+ readonly snorm16: F32;
151
+ readonly snorm16x2: Vec2f;
152
+ readonly snorm16x4: Vec4f;
153
+ readonly float16: F32;
154
+ readonly float16x2: Vec2f;
155
+ readonly float16x4: Vec4f;
156
+ readonly float32: F32;
157
+ readonly float32x2: Vec2f;
158
+ readonly float32x3: Vec3f;
159
+ readonly float32x4: Vec4f;
160
+ readonly uint32: U32;
161
+ readonly uint32x2: Vec2u;
162
+ readonly uint32x3: Vec3u;
163
+ readonly uint32x4: Vec4u;
164
+ readonly sint32: I32;
165
+ readonly sint32x2: Vec2i;
166
+ readonly sint32x3: Vec3i;
167
+ readonly sint32x4: Vec4i;
168
+ readonly 'unorm10-10-10-2': Vec4f;
169
+ readonly 'unorm8x4-bgra': Vec4f;
170
+ };
171
+ declare const packedFormats: string[];
172
+ type uint8 = TgpuVertexFormatData<'uint8'>;
173
+ declare const uint8: uint8;
174
+ type uint8x2 = TgpuVertexFormatData<'uint8x2'>;
175
+ declare const uint8x2: uint8x2;
176
+ type uint8x4 = TgpuVertexFormatData<'uint8x4'>;
177
+ declare const uint8x4: uint8x4;
178
+ type sint8 = TgpuVertexFormatData<'sint8'>;
179
+ declare const sint8: sint8;
180
+ type sint8x2 = TgpuVertexFormatData<'sint8x2'>;
181
+ declare const sint8x2: sint8x2;
182
+ type sint8x4 = TgpuVertexFormatData<'sint8x4'>;
183
+ declare const sint8x4: sint8x4;
184
+ type unorm8 = TgpuVertexFormatData<'unorm8'>;
185
+ declare const unorm8: unorm8;
186
+ type unorm8x2 = TgpuVertexFormatData<'unorm8x2'>;
187
+ declare const unorm8x2: unorm8x2;
188
+ type unorm8x4 = TgpuVertexFormatData<'unorm8x4'>;
189
+ declare const unorm8x4: unorm8x4;
190
+ type snorm8 = TgpuVertexFormatData<'snorm8'>;
191
+ declare const snorm8: snorm8;
192
+ type snorm8x2 = TgpuVertexFormatData<'snorm8x2'>;
193
+ declare const snorm8x2: snorm8x2;
194
+ type snorm8x4 = TgpuVertexFormatData<'snorm8x4'>;
195
+ declare const snorm8x4: snorm8x4;
196
+ type uint16 = TgpuVertexFormatData<'uint16'>;
197
+ declare const uint16: uint16;
198
+ type uint16x2 = TgpuVertexFormatData<'uint16x2'>;
199
+ declare const uint16x2: uint16x2;
200
+ type uint16x4 = TgpuVertexFormatData<'uint16x4'>;
201
+ declare const uint16x4: uint16x4;
202
+ type sint16 = TgpuVertexFormatData<'sint16'>;
203
+ declare const sint16: sint16;
204
+ type sint16x2 = TgpuVertexFormatData<'sint16x2'>;
205
+ declare const sint16x2: sint16x2;
206
+ type sint16x4 = TgpuVertexFormatData<'sint16x4'>;
207
+ declare const sint16x4: sint16x4;
208
+ type unorm16 = TgpuVertexFormatData<'unorm16'>;
209
+ declare const unorm16: unorm16;
210
+ type unorm16x2 = TgpuVertexFormatData<'unorm16x2'>;
211
+ declare const unorm16x2: unorm16x2;
212
+ type unorm16x4 = TgpuVertexFormatData<'unorm16x4'>;
213
+ declare const unorm16x4: unorm16x4;
214
+ type snorm16 = TgpuVertexFormatData<'snorm16'>;
215
+ declare const snorm16: snorm16;
216
+ type snorm16x2 = TgpuVertexFormatData<'snorm16x2'>;
217
+ declare const snorm16x2: snorm16x2;
218
+ type snorm16x4 = TgpuVertexFormatData<'snorm16x4'>;
219
+ declare const snorm16x4: snorm16x4;
220
+ type float16 = TgpuVertexFormatData<'float16'>;
221
+ declare const float16: float16;
222
+ type float16x2 = TgpuVertexFormatData<'float16x2'>;
223
+ declare const float16x2: float16x2;
224
+ type float16x4 = TgpuVertexFormatData<'float16x4'>;
225
+ declare const float16x4: float16x4;
226
+ type float32 = TgpuVertexFormatData<'float32'>;
227
+ declare const float32: float32;
228
+ type float32x2 = TgpuVertexFormatData<'float32x2'>;
229
+ declare const float32x2: float32x2;
230
+ type float32x3 = TgpuVertexFormatData<'float32x3'>;
231
+ declare const float32x3: float32x3;
232
+ type float32x4 = TgpuVertexFormatData<'float32x4'>;
233
+ declare const float32x4: float32x4;
234
+ type uint32 = TgpuVertexFormatData<'uint32'>;
235
+ declare const uint32: uint32;
236
+ type uint32x2 = TgpuVertexFormatData<'uint32x2'>;
237
+ declare const uint32x2: uint32x2;
238
+ type uint32x3 = TgpuVertexFormatData<'uint32x3'>;
239
+ declare const uint32x3: uint32x3;
240
+ type uint32x4 = TgpuVertexFormatData<'uint32x4'>;
241
+ declare const uint32x4: uint32x4;
242
+ type sint32 = TgpuVertexFormatData<'sint32'>;
243
+ declare const sint32: sint32;
244
+ type sint32x2 = TgpuVertexFormatData<'sint32x2'>;
245
+ declare const sint32x2: sint32x2;
246
+ type sint32x3 = TgpuVertexFormatData<'sint32x3'>;
247
+ declare const sint32x3: sint32x3;
248
+ type sint32x4 = TgpuVertexFormatData<'sint32x4'>;
249
+ declare const sint32x4: sint32x4;
250
+ type unorm10_10_10_2 = TgpuVertexFormatData<'unorm10-10-10-2'>;
251
+ declare const unorm10_10_10_2: unorm10_10_10_2;
252
+ type unorm8x4_bgra = TgpuVertexFormatData<'unorm8x4-bgra'>;
253
+ declare const unorm8x4_bgra: unorm8x4_bgra;
254
+ type PackedData = uint8 | uint8x2 | uint8x4 | sint8 | sint8x2 | sint8x4 | unorm8 | unorm8x2 | unorm8x4 | snorm8 | snorm8x2 | snorm8x4 | uint16 | uint16x2 | uint16x4 | sint16 | sint16x2 | sint16x4 | unorm16 | unorm16x2 | unorm16x4 | snorm16 | snorm16x2 | snorm16x4 | float16 | float16x2 | float16x4 | float32 | float32x2 | float32x3 | float32x4 | uint32 | uint32x2 | uint32x3 | uint32x4 | sint32 | sint32x2 | sint32x3 | sint32x4 | unorm10_10_10_2 | unorm8x4_bgra;
255
+
256
+ /**
257
+ * Array schema constructed via `d.disarrayOf` function.
258
+ *
259
+ * Useful for defining vertex buffers.
260
+ * Elements in the schema are not aligned in respect to their `byteAlignment`,
261
+ * unless they are explicitly decorated with the custom align attribute
262
+ * via `d.align` function.
263
+ */
264
+ interface Disarray<TElement extends BaseData = BaseData> {
265
+ readonly type: 'disarray';
266
+ readonly elementCount: number;
267
+ readonly elementType: TElement;
268
+ readonly [$repr]: Infer<TElement>[];
269
+ readonly '~reprPartial': {
270
+ idx: number;
271
+ value: InferPartial<TElement>;
272
+ }[];
273
+ }
274
+ /**
275
+ * Struct schema constructed via `d.unstruct` function.
276
+ *
277
+ * Useful for defining vertex buffers, as the standard layout restrictions do not apply.
278
+ * Members are not aligned in respect to their `byteAlignment`,
279
+ * unless they are explicitly decorated with the custom align attribute
280
+ * via `d.align` function.
281
+ */
282
+ interface Unstruct<TProps extends Record<string, BaseData> = Record<string, BaseData>> extends TgpuNamable {
283
+ readonly label?: string | undefined;
284
+ readonly type: 'unstruct';
285
+ readonly propTypes: TProps;
286
+ readonly [$repr]: Prettify<InferRecord<TProps>>;
287
+ readonly '~reprPartial': Prettify<Partial<InferPartialRecord<TProps>>>;
288
+ }
289
+ interface LooseDecorated<TInner extends BaseData = BaseData, TAttribs extends unknown[] = unknown[]> {
290
+ readonly type: 'loose-decorated';
291
+ readonly inner: TInner;
292
+ readonly attribs: TAttribs;
293
+ readonly [$repr]: Infer<TInner>;
294
+ }
295
+ declare const looseTypeLiterals: readonly ["unstruct", "disarray", "loose-decorated", "uint8", "uint8x2", "uint8x4", "sint8", "sint8x2", "sint8x4", "unorm8", "unorm8x2", "unorm8x4", "snorm8", "snorm8x2", "snorm8x4", "uint16", "uint16x2", "uint16x4", "sint16", "sint16x2", "sint16x4", "unorm16", "unorm16x2", "unorm16x4", "snorm16", "snorm16x2", "snorm16x4", "float16", "float16x2", "float16x4", "float32", "float32x2", "float32x3", "float32x4", "uint32", "uint32x2", "uint32x3", "uint32x4", "sint32", "sint32x2", "sint32x3", "sint32x4", "unorm10-10-10-2", "unorm8x4-bgra"];
296
+ type LooseTypeLiteral = (typeof looseTypeLiterals)[number];
297
+ type AnyLooseData = Disarray | Unstruct | LooseDecorated | PackedData;
298
+ declare function isLooseData(data: unknown): data is AnyLooseData;
299
+ /**
300
+ * Checks whether the passed in value is a disarray schema,
301
+ * as opposed to, e.g., a regular array schema.
302
+ *
303
+ * Array schemas can be used to describe uniform and storage buffers,
304
+ * whereas disarray schemas cannot. Disarrays are useful for
305
+ * defining vertex buffers instead.
306
+ *
307
+ * @example
308
+ * isDisarray(d.arrayOf(d.u32, 4)) // false
309
+ * isDisarray(d.disarrayOf(d.u32, 4)) // true
310
+ * isDisarray(d.vec3f) // false
311
+ */
312
+ declare function isDisarray<T extends Disarray>(schema: T | unknown): schema is T;
313
+ /**
314
+ * Checks whether passed in value is a unstruct schema,
315
+ * as opposed to, e.g., a struct schema.
316
+ *
317
+ * Struct schemas can be used to describe uniform and storage buffers,
318
+ * whereas unstruct schemas cannot. Unstructs are useful for
319
+ * defining vertex buffers instead.
320
+ *
321
+ * @example
322
+ * isUnstruct(d.struct({ a: d.u32 })) // false
323
+ * isUnstruct(d.unstruct({ a: d.u32 })) // true
324
+ * isUnstruct(d.vec3f) // false
325
+ */
326
+ declare function isUnstruct<T extends Unstruct>(schema: T | unknown): schema is T;
327
+ declare function isLooseDecorated<T extends LooseDecorated>(value: T | unknown): value is T;
328
+ declare function isData(value: unknown): value is AnyData;
329
+ type AnyData = AnyWgslData | AnyLooseData;
330
+
331
+ declare const builtinNames: readonly ["vertex_index", "instance_index", "position", "clip_distances", "front_facing", "frag_depth", "sample_index", "sample_mask", "fragment", "local_invocation_id", "local_invocation_index", "global_invocation_id", "workgroup_id", "num_workgroups", "subgroup_invocation_id", "subgroup_size"];
332
+ type BuiltinName = (typeof builtinNames)[number];
333
+ type AnyAttribute<AllowedBuiltins extends Builtin<BuiltinName> = Builtin<BuiltinName>> = Align<number> | Size<number> | Location<number> | Interpolate<InterpolationType> | AllowedBuiltins;
334
+ type ExtractAttributes<T> = T extends {
335
+ readonly attribs: unknown[];
336
+ } ? T['attribs'] : [];
337
+ type Undecorate<T> = T extends {
338
+ readonly inner: infer TInner;
339
+ } ? TInner : T;
340
+ /**
341
+ * Decorates a data-type `TData` with an attribute `TAttrib`.
342
+ *
343
+ * - if `TData` is loose
344
+ * - if `TData` is already `LooseDecorated`
345
+ * - Prepend `TAttrib` to the existing attribute tuple.
346
+ * - else
347
+ * - Wrap `TData` with `LooseDecorated` and a single attribute `[TAttrib]`
348
+ * - else
349
+ * - if `TData` is already `Decorated`
350
+ * - Prepend `TAttrib` to the existing attribute tuple.
351
+ * - else
352
+ * - Wrap `TData` with `Decorated` and a single attribute `[TAttrib]`
353
+ */
354
+ type Decorate<TData extends BaseData, TAttrib extends AnyAttribute> = TData['type'] extends WgslTypeLiteral ? Decorated<Undecorate<TData>, [TAttrib, ...ExtractAttributes<TData>]> : TData['type'] extends LooseTypeLiteral ? LooseDecorated<Undecorate<TData>, [TAttrib, ...ExtractAttributes<TData>]> : never;
355
+ type IsBuiltin<T> = ExtractAttributes<T>[number] extends [] ? false : ExtractAttributes<T>[number] extends Builtin<BuiltinName> ? true : false;
356
+ type HasCustomLocation<T> = ExtractAttributes<T>[number] extends [] ? false : ExtractAttributes<T>[number] extends Location<number> ? true : false;
357
+ /**
358
+ * Gives the wrapped data-type a custom byte alignment. Useful in order to
359
+ * fulfill uniform alignment requirements.
360
+ *
361
+ * @example
362
+ * const Data = d.struct({
363
+ * a: u32, // takes up 4 bytes
364
+ * // 12 bytes of padding, because `b` is custom aligned to multiples of 16 bytes
365
+ * b: d.align(16, u32),
366
+ * });
367
+ *
368
+ * @param alignment The multiple of bytes this data should align itself to.
369
+ * @param data The data-type to align.
370
+ */
371
+ declare function align<TAlign extends number, TData extends AnyData>(alignment: TAlign, data: TData): Decorate<TData, Align<TAlign>>;
372
+ /**
373
+ * Adds padding bytes after the wrapped data-type, until the whole value takes up `size` bytes.
374
+ *
375
+ * @example
376
+ * const Data = d.struct({
377
+ * a: d.size(16, u32), // takes up 16 bytes, instead of 4
378
+ * b: u32, // starts at byte 16, because `a` has a custom size
379
+ * });
380
+ *
381
+ * @param size The amount of bytes that should be reserved for this data-type.
382
+ * @param data The data-type to wrap.
383
+ */
384
+ declare function size<TSize extends number, TData extends AnyData>(size: TSize, data: TData): Decorate<TData, Size<TSize>>;
385
+ /**
386
+ * Assigns an explicit numeric location to a struct member or a parameter that has this type.
387
+ *
388
+ * @example
389
+ * const VertexOutput = {
390
+ * a: d.u32, // has implicit location 0
391
+ * b: d.location(5, d.u32),
392
+ * c: d.u32, // has implicit location 6
393
+ * };
394
+ *
395
+ * @param location The explicit numeric location.
396
+ * @param data The data-type to wrap.
397
+ */
398
+ declare function location<TLocation extends number, TData extends AnyData>(location: TLocation, data: TData): Decorate<TData, Location<TLocation>>;
399
+ /**
400
+ * Specifies how user-defined vertex shader output (fragment shader input)
401
+ * must be interpolated.
402
+ *
403
+ * Tip: Integer outputs cannot be interpolated.
404
+ *
405
+ * @example
406
+ * const VertexOutput = {
407
+ * a: d.f32, // has implicit 'perspective, center' interpolation
408
+ * b: d.interpolate('linear, sample', d.f32),
409
+ * };
410
+ *
411
+ * @param interpolationType How data should be interpolated.
412
+ * @param data The data-type to wrap.
413
+ */
414
+ declare function interpolate<TInterpolation extends PerspectiveOrLinearInterpolationType, TData extends PerspectiveOrLinearInterpolatableData>(interpolationType: TInterpolation, data: TData): Decorate<TData, Interpolate<TInterpolation>>;
415
+ /**
416
+ * Specifies how user-defined vertex shader output (fragment shader input)
417
+ * must be interpolated.
418
+ *
419
+ * Tip: Default sampling method of `flat` is `first`. Unless you specifically
420
+ * need deterministic behavior provided by `'flat, first'`, prefer explicit
421
+ * `'flat, either'` as it could be slightly faster in hardware.
422
+ *
423
+ * @example
424
+ * const VertexOutput = {
425
+ * a: d.f32, // has implicit 'perspective, center' interpolation
426
+ * b: d.interpolate('flat, either', d.u32), // integer outputs cannot interpolate
427
+ * };
428
+ *
429
+ * @param interpolationType How data should be interpolated.
430
+ * @param data The data-type to wrap.
431
+ */
432
+ declare function interpolate<TInterpolation extends FlatInterpolationType, TData extends FlatInterpolatableData>(interpolationType: TInterpolation, data: TData): Decorate<TData, Interpolate<TInterpolation>>;
433
+ declare function isBuiltin<T extends Decorated<AnyWgslData, AnyAttribute[]> | LooseDecorated<AnyLooseData, AnyAttribute[]>>(value: T | unknown): value is T;
434
+
435
+ export { unorm8x2 as $, type AnyAttribute as A, type BuiltinVertexIndex as B, type BuiltinLocalInvocationIndex as C, type Decorate as D, type BuiltinGlobalInvocationId as E, type BuiltinWorkgroupId as F, type BuiltinNumWorkgroups as G, type HasCustomLocation as H, type IsBuiltin as I, type AnyBuiltin as J, type KindToDefaultFormatMap as K, type LooseDecorated as L, type FormatToWGSLType as M, type TgpuVertexFormatData as N, type OmitBuiltins as O, formatToWGSLType as P, packedFormats as Q, uint8 as R, uint8x2 as S, type TgpuVertexAttrib as T, type Unstruct as U, type VertexFormat as V, uint8x4 as W, sint8 as X, sint8x2 as Y, sint8x4 as Z, unorm8 as _, type AnyComputeBuiltin as a, unorm8x4 as a0, snorm8 as a1, snorm8x2 as a2, snorm8x4 as a3, uint16 as a4, uint16x2 as a5, uint16x4 as a6, sint16 as a7, sint16x2 as a8, sint16x4 as a9, unorm16 as aa, unorm16x2 as ab, unorm16x4 as ac, snorm16 as ad, snorm16x2 as ae, snorm16x4 as af, float16 as ag, float16x2 as ah, float16x4 as ai, float32 as aj, float32x2 as ak, float32x3 as al, float32x4 as am, uint32 as an, uint32x2 as ao, uint32x3 as ap, uint32x4 as aq, sint32 as ar, sint32x2 as as, sint32x3 as at, sint32x4 as au, unorm10_10_10_2 as av, unorm8x4_bgra as aw, type PackedData as ax, type AnyFragmentInputBuiltin as b, type AnyFragmentOutputBuiltin as c, type Disarray as d, type KindToAcceptedAttribMap as e, type AnyData as f, type AnyLooseData as g, align as h, interpolate as i, isBuiltin as j, isDisarray as k, location as l, isUnstruct as m, isLooseDecorated as n, isData as o, isLooseData as p, builtin as q, type BuiltinInstanceIndex as r, size as s, type BuiltinPosition as t, type BuiltinClipDistances as u, type BuiltinFrontFacing as v, type BuiltinFragDepth as w, type BuiltinSampleIndex as x, type BuiltinSampleMask as y, type BuiltinLocalInvocationId as z };
@@ -0,0 +1,2 @@
1
+ import{W as t}from"./chunk-AKBL6GDL.js";function n(e){return e?.resourceType==="slot"}function r(e){return e?.resourceType==="derived"}function o(e){return e?.["~providing"]!==void 0}function u(e){return e?.resourceType==="accessor"}var p=Symbol("internal");var y={type:"unknown"},f={type:"void"};function a(e){return typeof e?.["~resolve"]=="function"}function c(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||a(e)||t(e)||n(e)||r(e)||o(e)}function d(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}function m(e){return e?.resourceType==="buffer-usage"}function x(e){return!!e&&typeof e=="object"&&!!e?.[p]?.dataType}export{p as a,n as b,r as c,o as d,u as e,y as f,f as g,a as h,c as i,d as j,m as k,x as l};
2
+ //# sourceMappingURL=chunk-5PJ3H5OR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/slot/slotTypes.ts","../src/shared/symbols.ts","../src/types.ts"],"sourcesContent":["import type { AnyWgslData } from '../../data';\nimport type { TgpuNamable } from '../../namable';\nimport type { $repr, Infer } from '../../shared/repr.js';\nimport type { Labelled } from '../../types';\nimport type { TgpuFn } from '../function/tgpuFn';\nimport type { TgpuBufferUsage } from './../buffer/bufferUsage';\n\nexport interface TgpuSlot<T> extends TgpuNamable, Labelled {\n readonly resourceType: 'slot';\n [$repr]: Infer<T>;\n\n readonly defaultValue: T | undefined;\n\n /**\n * Used to determine if code generated using either value `a` or `b` in place\n * of the slot will be equivalent. Defaults to `Object.is`.\n */\n areEqual(a: T, b: T): boolean;\n\n readonly value: Infer<T>;\n}\n\nexport interface TgpuDerived<T> {\n readonly resourceType: 'derived';\n readonly value: Infer<T>;\n [$repr]: Infer<T>;\n readonly '~providing'?: Providing | undefined;\n\n with<TValue>(slot: TgpuSlot<TValue>, value: Eventual<TValue>): TgpuDerived<T>;\n\n /**\n * @internal\n */\n '~compute'(): T;\n}\n\nexport interface TgpuAccessor<T extends AnyWgslData = AnyWgslData>\n extends TgpuNamable,\n Labelled {\n readonly resourceType: 'accessor';\n [$repr]: Infer<T>;\n\n readonly schema: T;\n readonly defaultValue:\n | TgpuFn<[], T>\n | TgpuBufferUsage<T>\n | Infer<T>\n | undefined;\n readonly slot: TgpuSlot<TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>>;\n\n readonly value: Infer<T>;\n}\n\n/**\n * Represents a value that is available at resolution time.\n */\nexport type Eventual<T> = T | TgpuSlot<T> | TgpuDerived<T>;\n\nexport type SlotValuePair<T = unknown> = [TgpuSlot<T>, T];\n\nexport type Providing = {\n inner: unknown;\n pairs: SlotValuePair[];\n};\n\nexport function isSlot<T>(value: unknown | TgpuSlot<T>): value is TgpuSlot<T> {\n return (value as TgpuSlot<T>)?.resourceType === 'slot';\n}\n\nexport function isDerived<T extends TgpuDerived<unknown>>(\n value: T | unknown,\n): value is T {\n return (value as T)?.resourceType === 'derived';\n}\n\nexport function isProviding(\n value: unknown,\n): value is { '~providing': Providing } {\n return (value as { '~providing': Providing })?.['~providing'] !== undefined;\n}\n\nexport function isAccessor<T extends AnyWgslData>(\n value: unknown | TgpuAccessor<T>,\n): value is TgpuAccessor<T> {\n return (value as TgpuAccessor<T>)?.resourceType === 'accessor';\n}\n","export const $internal = Symbol('internal');\n","import type { ArgNames, Block } from 'tinyest';\nimport type {\n TgpuBufferMutable,\n TgpuBufferReadonly,\n TgpuBufferUniform,\n TgpuBufferUsage,\n} from './core/buffer/bufferUsage';\nimport type { TgpuConst } from './core/constant/tgpuConstant';\nimport type { TgpuDeclare } from './core/declare/tgpuDeclare';\nimport type { TgpuComputeFn } from './core/function/tgpuComputeFn';\nimport type { TgpuFn } from './core/function/tgpuFn';\nimport type { TgpuFragmentFn } from './core/function/tgpuFragmentFn';\nimport type { TgpuVertexFn } from './core/function/tgpuVertexFn';\nimport type { TgpuComputePipeline } from './core/pipeline/computePipeline';\nimport type { TgpuRenderPipeline } from './core/pipeline/renderPipeline';\nimport type { TgpuSampler } from './core/sampler/sampler';\nimport {\n type Eventual,\n type SlotValuePair,\n type TgpuAccessor,\n type TgpuSlot,\n isDerived,\n isProviding,\n isSlot,\n} from './core/slot/slotTypes';\nimport type { TgpuExternalTexture } from './core/texture/externalTexture';\nimport type { TgpuAnyTextureView, TgpuTexture } from './core/texture/texture';\nimport type { TgpuVar } from './core/variable/tgpuVariable';\nimport type { AnyData } from './data';\nimport {\n type AbstractFloat,\n type AbstractInt,\n type AnyMatInstance,\n type AnyVecInstance,\n type AnyWgslData,\n type BaseData,\n isWgslData,\n} from './data/wgslTypes';\nimport type { NameRegistry } from './nameRegistry';\nimport type { Infer } from './shared/repr';\nimport { $internal } from './shared/symbols';\nimport type {\n TgpuBindGroupLayout,\n TgpuLayoutEntry,\n} from './tgpuBindGroupLayout';\n\nexport type ResolvableObject =\n | SelfResolvable\n | TgpuBufferUsage\n | TgpuConst\n | TgpuDeclare\n | TgpuFn\n | TgpuComputeFn\n | TgpuFragmentFn\n | TgpuComputePipeline\n | TgpuRenderPipeline\n | TgpuVertexFn\n | TgpuSampler\n | TgpuAccessor\n | TgpuExternalTexture\n | TgpuTexture\n | TgpuAnyTextureView\n | TgpuVar\n | AnyVecInstance\n | AnyMatInstance\n | AnyData\n // biome-ignore lint/suspicious/noExplicitAny: <has to be more permissive than unknown>\n | TgpuFn<any, any>;\n\nexport type Wgsl = Eventual<string | number | boolean | ResolvableObject>;\n\nexport const UnknownData = {\n type: 'unknown',\n};\nexport type UnknownData = typeof UnknownData;\nexport const Void = {\n type: 'void' as const,\n};\nexport type Void = typeof Void;\n\nexport type Resource = {\n value: unknown;\n dataType: AnyWgslData | UnknownData | AbstractInt | AbstractFloat | Void;\n};\n\nexport type TgpuShaderStage = 'compute' | 'vertex' | 'fragment';\n\nexport interface FnToWgslOptions {\n args: Resource[];\n returnType: AnyWgslData;\n body: Block;\n externalMap: Record<string, unknown>;\n}\n\nexport type ItemLayer = {\n type: 'item';\n usedSlots: Set<TgpuSlot<unknown>>;\n};\n\nexport interface ItemStateStack {\n readonly itemDepth: number;\n readonly topItem: ItemLayer;\n\n pushItem(): void;\n popItem(): void;\n pushSlotBindings(pairs: SlotValuePair<unknown>[]): void;\n popSlotBindings(): void;\n pushFunctionScope(\n args: Resource[],\n returnType: AnyWgslData | undefined,\n externalMap: Record<string, unknown>,\n ): void;\n popFunctionScope(): void;\n pushBlockScope(): void;\n popBlockScope(): void;\n pop(type?: 'functionScope' | 'blockScope' | 'slotBinding' | 'item'): void;\n readSlot<T>(slot: TgpuSlot<T>): T | undefined;\n getResourceById(id: string): Resource | undefined;\n defineBlockVariable(id: string, type: AnyWgslData | UnknownData): Resource;\n}\n\n/**\n * Passed into each resolvable item. All items in a tree share a resolution ctx,\n * but there can be layers added and removed from the item stack when going down\n * and up the tree.\n */\nexport interface ResolutionCtx {\n readonly names: NameRegistry;\n\n addDeclaration(declaration: string): void;\n\n /**\n * Reserves a bind group number, and returns a placeholder that will be replaced\n * with a concrete number at the end of the resolution process.\n */\n allocateLayoutEntry(layout: TgpuBindGroupLayout): string;\n\n /**\n * Reserves a spot in the catch-all bind group, without the indirection of a bind-group.\n * This means the resource is 'fixed', and cannot be swapped between code execution.\n */\n allocateFixedEntry(\n layoutEntry: TgpuLayoutEntry,\n resource: object,\n ): {\n group: string;\n binding: number;\n };\n\n withSlots<T>(pairs: SlotValuePair<unknown>[], callback: () => T): T;\n\n /**\n * Unwraps all layers of slot/derived indirection and returns the concrete value if available.\n * @throws {MissingSlotValueError}\n */\n unwrap<T>(eventual: Eventual<T>): T;\n\n resolve(item: unknown): string;\n resolveValue<T extends BaseData>(value: Infer<T>, schema: T): string;\n\n transpileFn(fn: string): {\n argNames: ArgNames;\n body: Block;\n externalNames: string[];\n };\n fnToWgsl(options: FnToWgslOptions): {\n head: Wgsl;\n body: Wgsl;\n };\n\n [$internal]: {\n itemStateStack: ItemStateStack;\n };\n}\n\n/**\n * Houses a method '~resolve` that returns a code string\n * representing it, as opposed to offloading the resolution\n * to another mechanism.\n */\nexport interface SelfResolvable {\n '~resolve'(ctx: ResolutionCtx): string;\n toString(): string;\n}\n\nexport interface Labelled {\n readonly label?: string | undefined;\n}\n\nexport function isSelfResolvable(value: unknown): value is SelfResolvable {\n return typeof (value as SelfResolvable)?.['~resolve'] === 'function';\n}\n\nexport function isWgsl(value: unknown): value is Wgsl {\n return (\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n typeof value === 'string' ||\n isSelfResolvable(value) ||\n isWgslData(value) ||\n isSlot(value) ||\n isDerived(value) ||\n isProviding(value)\n );\n}\n\nexport type BindableBufferUsage = 'uniform' | 'readonly' | 'mutable';\nexport type BufferUsage = 'uniform' | 'readonly' | 'mutable' | 'vertex';\n\nexport function isGPUBuffer(value: unknown): value is GPUBuffer {\n return (\n !!value &&\n typeof value === 'object' &&\n 'getMappedRange' in value &&\n 'mapAsync' in value\n );\n}\n\nexport function isBufferUsage<\n T extends\n | TgpuBufferUniform<BaseData>\n | TgpuBufferReadonly<BaseData>\n | TgpuBufferMutable<BaseData>,\n>(value: T | unknown): value is T {\n return (value as T)?.resourceType === 'buffer-usage';\n}\n\nexport function hasInternalDataType(\n value: unknown,\n): value is { [$internal]: { dataType: BaseData } } {\n return (\n !!value &&\n typeof value === 'object' &&\n !!(value as { [$internal]: { dataType: BaseData } })?.[$internal]?.dataType\n );\n}\n"],"mappings":"wCAiEO,SAASA,EAAUC,EAAoD,CAC5E,OAAQA,GAAuB,eAAiB,MAClD,CAEO,SAASC,EACdD,EACY,CACZ,OAAQA,GAAa,eAAiB,SACxC,CAEO,SAASE,EACdF,EACsC,CACtC,OAAQA,IAAwC,YAAY,IAAM,MACpE,CAEO,SAASG,EACdH,EAC0B,CAC1B,OAAQA,GAA2B,eAAiB,UACtD,CCrFO,IAAMI,EAAY,OAAO,UAAU,ECuEnC,IAAMC,EAAc,CACzB,KAAM,SACR,EAEaC,EAAO,CAClB,KAAM,MACR,EAgHO,SAASC,EAAiBC,EAAyC,CACxE,OAAO,OAAQA,IAA2B,UAAU,GAAM,UAC5D,CAEO,SAASC,EAAOD,EAA+B,CACpD,OACE,OAAOA,GAAU,UACjB,OAAOA,GAAU,WACjB,OAAOA,GAAU,UACjBD,EAAiBC,CAAK,GACtBE,EAAWF,CAAK,GAChBG,EAAOH,CAAK,GACZI,EAAUJ,CAAK,GACfK,EAAYL,CAAK,CAErB,CAKO,SAASM,EAAYN,EAAoC,CAC9D,MACE,CAAC,CAACA,GACF,OAAOA,GAAU,UACjB,mBAAoBA,GACpB,aAAcA,CAElB,CAEO,SAASO,EAKdP,EAAgC,CAChC,OAAQA,GAAa,eAAiB,cACxC,CAEO,SAASQ,EACdR,EACkD,CAClD,MACE,CAAC,CAACA,GACF,OAAOA,GAAU,UACjB,CAAC,CAAEA,IAAoDS,CAAS,GAAG,QAEvE","names":["isSlot","value","isDerived","isProviding","isAccessor","$internal","UnknownData","Void","isSelfResolvable","value","isWgsl","isWgslData","isSlot","isDerived","isProviding","isGPUBuffer","isBufferUsage","hasInternalDataType","$internal"]}
@@ -0,0 +1,4 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12;var _typedbinary = require('typed-binary'); var _typedbinary2 = _interopRequireDefault(_typedbinary);var xe="Invariant failed";function le(e,t){if(e)return;throw new Error(xe)}var Se=class e extends Error{constructor(n,i){let s=i.map(a=>`- ${a}`);s.length>20&&(s=[...s.slice(0,11),"...",...s.slice(-10)]);super(`Resolution of the following tree failed:
2
+ ${s.join(`
3
+ `)}: ${n&&typeof n=="object"&&"message"in n?n.message:n}`);this.cause=n;this.trace=i;Object.setPrototypeOf(this,e.prototype)}appendToTrace(n){let i=[n,...this.trace];return new e(this.cause,i)}},Be= exports.c =class e extends Error{constructor(n){super(`Missing value for '${n}'`);this.slot=n;Object.setPrototypeOf(this,e.prototype)}},ke= exports.d =class e extends Error{constructor(t){super(`Buffer '${_nullishCoalesce(t.label, () => ("<unnamed>"))}' is not bindable as a uniform. Use .$usage('uniform') to allow it.`),Object.setPrototypeOf(this,e.prototype)}},Fe= exports.e =class e extends Error{constructor(t,n){super(`The function '${_nullishCoalesce(t, () => ("<unnamed>"))}' is missing links to the following external values: ${n}.`),Object.setPrototypeOf(this,e.prototype)}},Pe= exports.f =class e extends Error{constructor(t){super(`Missing bind groups for layouts: '${[...t].map(n=>_nullishCoalesce(n.label, () => ("<unnamed>"))).join(", ")}'. Please provide it using pipeline.with(layout, bindGroup).(...)`),Object.setPrototypeOf(this,e.prototype)}},Ce= exports.g =class e extends Error{constructor(t){super(`Missing vertex buffers for layouts: '${[...t].map(n=>_nullishCoalesce(n.label, () => ("<unnamed>"))).join(", ")}'. Please provide it using pipeline.with(layout, buffer).(...)`),Object.setPrototypeOf(this,e.prototype)}};var re=null,qe=Symbol("CPU"),Qe=Symbol("GPU"),Xe= exports.h ={CPU:qe,GPU:Qe},Q=[];function Qt(e,t){le(re===null,"Cannot nest context providers"),re=e;try{return t()}finally{re=null}}function Xt(){return re}function Yt(e){Q.push(e)}function Zt(e){let t=Q.pop();e!==void 0&&le(t===e,"Unexpected mode")}var $e=()=>Q.length>0&&Q[Q.length-1]===Xe.GPU;function*nn(e){let t=0;for(;;)e.has(t)||(yield t),t++}function w(e,t){return(...n)=>$e()?t(...n):e(...n)}var an={type:"abstractInt"},un= exports.K ={type:"abstractFloat"},Ye= exports.L ={type:"bool"},Ze=w(e=>typeof e=="boolean"?e?1:0:Number.isInteger(e)?((e<0||e>4294967295)&&console.warn(`u32 value ${e} overflowed`),(e&4294967295)>>>0):Math.max(0,Math.min(4294967295,Math.floor(e))),e=>({value:`u32(${e.value})`,dataType:u})),u= exports.M =Object.assign(Ze,{type:"u32"}),et=w(e=>{if(typeof e=="boolean")return e?1:0;if(Number.isInteger(e))return(e<-2147483648||e>2147483647)&&console.warn(`i32 value ${e} overflowed`),(e|0)&4294967295;let t=e<0?Math.ceil(e):Math.floor(e);return Math.max(-2147483648,Math.min(2147483647,t))},e=>({value:`i32(${e.value})`,dataType:z})),z= exports.N =Object.assign(et,{type:"i32"}),tt=w(e=>{if(typeof e=="boolean")return e?1:0;let t=new Float32Array(1);return t[0]=e,t[0]},e=>({value:`f32(${e.value})`,dataType:c})),c= exports.O =Object.assign(tt,{type:"f32"}),nt=w(e=>{if(typeof e=="boolean")return e?1:0;let t=new ArrayBuffer(2);return _typedbinary2.default.f16.write(new _typedbinary2.default.BufferWriter(t),e),_typedbinary2.default.f16.read(new _typedbinary2.default.BufferReader(t))},e=>({value:`f16(${e.value})`,dataType:Ne})),Ne= exports.P =Object.assign(nt,{type:"f16"});var pe=Symbol("Tag for struct schemas"),rt=["bool","f32","f16","i32","u32","vec2f","vec2h","vec2i","vec2u","vec2<bool>","vec3f","vec3h","vec3i","vec3u","vec3<bool>","vec4f","vec4h","vec4i","vec4u","vec4<bool>","mat2x2f","mat3x3f","mat4x4f","struct","array","ptr","atomic","decorated","abstractInt","abstractFloat"];function it(e){return _optionalChain([e, 'optionalAccess', _2 => _2.type, 'access', _3 => _3.startsWith, 'call', _4 => _4("vec2")])}function st(e){return _optionalChain([e, 'optionalAccess', _5 => _5.type, 'access', _6 => _6.startsWith, 'call', _7 => _7("vec3")])}function ot(e){return _optionalChain([e, 'optionalAccess', _8 => _8.type, 'access', _9 => _9.startsWith, 'call', _10 => _10("vec4")])}function yn(e){return it(e)||st(e)||ot(e)}function at(e){return _optionalChain([e, 'optionalAccess', _11 => _11.type])==="mat2x2f"}function ut(e){return _optionalChain([e, 'optionalAccess', _12 => _12.type])==="mat3x3f"}function ht(e){return _optionalChain([e, 'optionalAccess', _13 => _13.type])==="mat4x4f"}function cn(e){return at(e)||ut(e)||ht(e)}function X(e){return rt.includes(_optionalChain([e, 'optionalAccess', _14 => _14.type]))}function Y(e){return _optionalChain([e, 'optionalAccess', _15 => _15.type])==="array"}function Z(e){return!!_optionalChain([e, 'optionalAccess', _16 => _16[pe]])}function yt(e){return _optionalChain([e, 'optionalAccess', _17 => _17.type])==="ptr"}function ct(e){return _optionalChain([e, 'optionalAccess', _18 => _18.type])==="atomic"}function ee(e){return _optionalChain([e, 'optionalAccess', _19 => _19.type])==="@align"}function te(e){return _optionalChain([e, 'optionalAccess', _20 => _20.type])==="@size"}function me(e){return _optionalChain([e, 'optionalAccess', _21 => _21.type])==="@location"}function xt(e){return _optionalChain([e, 'optionalAccess', _22 => _22.type])==="@interpolate"}function we(e){return _optionalChain([e, 'optionalAccess', _23 => _23.type])==="@builtin"}function d(e){return _optionalChain([e, 'optionalAccess', _24 => _24.type])==="decorated"}function pt(e){let t=n=>n;return Object.setPrototypeOf(t,mt),t.propTypes=e,t}var mt={type:"struct",[pe]:!0,_label:void 0,get label(){return this._label},$name(e){return this._label=e,this},toString(){return`struct:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}};var v=(e,t)=>{let n=t-1,i=~n;return(e&n)===0?e:(e&i)+t};var Le=["uint8","uint8x2","uint8x4","sint8","sint8x2","sint8x4","unorm8","unorm8x2","unorm8x4","snorm8","snorm8x2","snorm8x4","uint16","uint16x2","uint16x4","sint16","sint16x2","sint16x4","unorm16","unorm16x2","unorm16x4","snorm16","snorm16x2","snorm16x4","float16","float16x2","float16x4","float32","float32x2","float32x3","float32x4","uint32","uint32x2","uint32x3","uint32x4","sint32","sint32x2","sint32x3","sint32x4","unorm10-10-10-2","unorm8x4-bgra"],mn= exports.ga ={f32:"float32",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",f16:"float16",vec2h:"float16x2",vec4h:"float16x4",u32:"uint32",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",i32:"sint32",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4"};var wt=["unstruct","disarray","loose-decorated",...Le];function se(e){return wt.includes(_optionalChain([e, 'optionalAccess', _25 => _25.type]))}function _(e){return _optionalChain([e, 'optionalAccess', _26 => _26.type])==="disarray"}function A(e){return _optionalChain([e, 'optionalAccess', _27 => _27.type])==="unstruct"}function m(e){return _optionalChain([e, 'optionalAccess', _28 => _28.type])==="loose-decorated"}function I(e){return _optionalChain([e, 'access', _29 => _29.attribs, 'optionalAccess', _30 => _30.find, 'call', _31 => _31(ee), 'optionalAccess', _32 => _32.value])}function Me(e){return _optionalChain([e, 'access', _33 => _33.attribs, 'optionalAccess', _34 => _34.find, 'call', _35 => _35(te), 'optionalAccess', _36 => _36.value])}function fn(e){return _optionalChain([e, 'access', _37 => _37.attribs, 'optionalAccess', _38 => _38.find, 'call', _39 => _39(me), 'optionalAccess', _40 => _40.value])}function dt(e){return X(e)||se(e)}var oe=Symbol("Type token for the inferred (CPU & GPU) representation of a resource");var ne=class extends Array{"~resolve"(){return`${this.kind}(${this.join(", ")})`}toString(){return this["~resolve"]()}get xx(){return new this._Vec2(this[0],this[0])}get xy(){return new this._Vec2(this[0],this[1])}get xz(){return new this._Vec2(this[0],this[2])}get xw(){return new this._Vec2(this[0],this[3])}get yx(){return new this._Vec2(this[1],this[0])}get yy(){return new this._Vec2(this[1],this[1])}get yz(){return new this._Vec2(this[1],this[2])}get yw(){return new this._Vec2(this[1],this[3])}get zx(){return new this._Vec2(this[2],this[0])}get zy(){return new this._Vec2(this[2],this[1])}get zz(){return new this._Vec2(this[2],this[2])}get zw(){return new this._Vec2(this[2],this[3])}get wx(){return new this._Vec2(this[3],this[0])}get wy(){return new this._Vec2(this[3],this[1])}get wz(){return new this._Vec2(this[3],this[2])}get ww(){return new this._Vec2(this[3],this[3])}get xxx(){return new this._Vec3(this[0],this[0],this[0])}get xxy(){return new this._Vec3(this[0],this[0],this[1])}get xxz(){return new this._Vec3(this[0],this[0],this[2])}get xxw(){return new this._Vec3(this[0],this[0],this[3])}get xyx(){return new this._Vec3(this[0],this[1],this[0])}get xyy(){return new this._Vec3(this[0],this[1],this[1])}get xyz(){return new this._Vec3(this[0],this[1],this[2])}get xyw(){return new this._Vec3(this[0],this[1],this[3])}get xzx(){return new this._Vec3(this[0],this[2],this[0])}get xzy(){return new this._Vec3(this[0],this[2],this[1])}get xzz(){return new this._Vec3(this[0],this[2],this[2])}get xzw(){return new this._Vec3(this[0],this[2],this[3])}get xwx(){return new this._Vec3(this[0],this[3],this[0])}get xwy(){return new this._Vec3(this[0],this[3],this[1])}get xwz(){return new this._Vec3(this[0],this[3],this[2])}get xww(){return new this._Vec3(this[0],this[3],this[3])}get yxx(){return new this._Vec3(this[1],this[0],this[0])}get yxy(){return new this._Vec3(this[1],this[0],this[1])}get yxz(){return new this._Vec3(this[1],this[0],this[2])}get yxw(){return new this._Vec3(this[1],this[0],this[3])}get yyx(){return new this._Vec3(this[1],this[1],this[0])}get yyy(){return new this._Vec3(this[1],this[1],this[1])}get yyz(){return new this._Vec3(this[1],this[1],this[2])}get yyw(){return new this._Vec3(this[1],this[1],this[3])}get yzx(){return new this._Vec3(this[1],this[2],this[0])}get yzy(){return new this._Vec3(this[1],this[2],this[1])}get yzz(){return new this._Vec3(this[1],this[2],this[2])}get yzw(){return new this._Vec3(this[1],this[2],this[3])}get ywx(){return new this._Vec3(this[1],this[3],this[0])}get ywy(){return new this._Vec3(this[1],this[3],this[1])}get ywz(){return new this._Vec3(this[1],this[3],this[2])}get yww(){return new this._Vec3(this[1],this[3],this[3])}get zxx(){return new this._Vec3(this[2],this[0],this[0])}get zxy(){return new this._Vec3(this[2],this[0],this[1])}get zxz(){return new this._Vec3(this[2],this[0],this[2])}get zxw(){return new this._Vec3(this[2],this[0],this[3])}get zyx(){return new this._Vec3(this[2],this[1],this[0])}get zyy(){return new this._Vec3(this[2],this[1],this[1])}get zyz(){return new this._Vec3(this[2],this[1],this[2])}get zyw(){return new this._Vec3(this[2],this[1],this[3])}get zzx(){return new this._Vec3(this[2],this[2],this[0])}get zzy(){return new this._Vec3(this[2],this[2],this[1])}get zzz(){return new this._Vec3(this[2],this[2],this[2])}get zzw(){return new this._Vec3(this[2],this[2],this[3])}get zwx(){return new this._Vec3(this[2],this[3],this[0])}get zwy(){return new this._Vec3(this[2],this[3],this[1])}get zwz(){return new this._Vec3(this[2],this[3],this[2])}get zww(){return new this._Vec3(this[2],this[3],this[3])}get wxx(){return new this._Vec3(this[3],this[0],this[0])}get wxy(){return new this._Vec3(this[3],this[0],this[1])}get wxz(){return new this._Vec3(this[3],this[0],this[2])}get wxw(){return new this._Vec3(this[3],this[0],this[3])}get wyx(){return new this._Vec3(this[3],this[1],this[0])}get wyy(){return new this._Vec3(this[3],this[1],this[1])}get wyz(){return new this._Vec3(this[3],this[1],this[2])}get wyw(){return new this._Vec3(this[3],this[1],this[3])}get wzx(){return new this._Vec3(this[3],this[2],this[0])}get wzy(){return new this._Vec3(this[3],this[2],this[1])}get wzz(){return new this._Vec3(this[3],this[2],this[2])}get wzw(){return new this._Vec3(this[3],this[2],this[3])}get wwx(){return new this._Vec3(this[3],this[3],this[0])}get wwy(){return new this._Vec3(this[3],this[3],this[1])}get wwz(){return new this._Vec3(this[3],this[3],this[2])}get www(){return new this._Vec3(this[3],this[3],this[3])}get xxxx(){return new this._Vec4(this[0],this[0],this[0],this[0])}get xxxy(){return new this._Vec4(this[0],this[0],this[0],this[1])}get xxxz(){return new this._Vec4(this[0],this[0],this[0],this[2])}get xxxw(){return new this._Vec4(this[0],this[0],this[0],this[3])}get xxyx(){return new this._Vec4(this[0],this[0],this[1],this[0])}get xxyy(){return new this._Vec4(this[0],this[0],this[1],this[1])}get xxyz(){return new this._Vec4(this[0],this[0],this[1],this[2])}get xxyw(){return new this._Vec4(this[0],this[0],this[1],this[3])}get xxzx(){return new this._Vec4(this[0],this[0],this[2],this[0])}get xxzy(){return new this._Vec4(this[0],this[0],this[2],this[1])}get xxzz(){return new this._Vec4(this[0],this[0],this[2],this[2])}get xxzw(){return new this._Vec4(this[0],this[0],this[2],this[3])}get xxwx(){return new this._Vec4(this[0],this[0],this[3],this[0])}get xxwy(){return new this._Vec4(this[0],this[0],this[3],this[1])}get xxwz(){return new this._Vec4(this[0],this[0],this[3],this[2])}get xxww(){return new this._Vec4(this[0],this[0],this[3],this[3])}get xyxx(){return new this._Vec4(this[0],this[1],this[0],this[0])}get xyxy(){return new this._Vec4(this[0],this[1],this[0],this[1])}get xyxz(){return new this._Vec4(this[0],this[1],this[0],this[2])}get xyxw(){return new this._Vec4(this[0],this[1],this[0],this[3])}get xyyx(){return new this._Vec4(this[0],this[1],this[1],this[0])}get xyyy(){return new this._Vec4(this[0],this[1],this[1],this[1])}get xyyz(){return new this._Vec4(this[0],this[1],this[1],this[2])}get xyyw(){return new this._Vec4(this[0],this[1],this[1],this[3])}get xyzx(){return new this._Vec4(this[0],this[1],this[2],this[0])}get xyzy(){return new this._Vec4(this[0],this[1],this[2],this[1])}get xyzz(){return new this._Vec4(this[0],this[1],this[2],this[2])}get xyzw(){return new this._Vec4(this[0],this[1],this[2],this[3])}get xywx(){return new this._Vec4(this[0],this[1],this[3],this[0])}get xywy(){return new this._Vec4(this[0],this[1],this[3],this[1])}get xywz(){return new this._Vec4(this[0],this[1],this[3],this[2])}get xyww(){return new this._Vec4(this[0],this[1],this[3],this[3])}get xzxx(){return new this._Vec4(this[0],this[2],this[0],this[0])}get xzxy(){return new this._Vec4(this[0],this[2],this[0],this[1])}get xzxz(){return new this._Vec4(this[0],this[2],this[0],this[2])}get xzxw(){return new this._Vec4(this[0],this[2],this[0],this[3])}get xzyx(){return new this._Vec4(this[0],this[2],this[1],this[0])}get xzyy(){return new this._Vec4(this[0],this[2],this[1],this[1])}get xzyz(){return new this._Vec4(this[0],this[2],this[1],this[2])}get xzyw(){return new this._Vec4(this[0],this[2],this[1],this[3])}get xzzx(){return new this._Vec4(this[0],this[2],this[2],this[0])}get xzzy(){return new this._Vec4(this[0],this[2],this[2],this[1])}get xzzz(){return new this._Vec4(this[0],this[2],this[2],this[2])}get xzzw(){return new this._Vec4(this[0],this[2],this[2],this[3])}get xzwx(){return new this._Vec4(this[0],this[2],this[3],this[0])}get xzwy(){return new this._Vec4(this[0],this[2],this[3],this[1])}get xzwz(){return new this._Vec4(this[0],this[2],this[3],this[2])}get xzww(){return new this._Vec4(this[0],this[2],this[3],this[3])}get xwxx(){return new this._Vec4(this[0],this[3],this[0],this[0])}get xwxy(){return new this._Vec4(this[0],this[3],this[0],this[1])}get xwxz(){return new this._Vec4(this[0],this[3],this[0],this[2])}get xwxw(){return new this._Vec4(this[0],this[3],this[0],this[3])}get xwyx(){return new this._Vec4(this[0],this[3],this[1],this[0])}get xwyy(){return new this._Vec4(this[0],this[3],this[1],this[1])}get xwyz(){return new this._Vec4(this[0],this[3],this[1],this[2])}get xwyw(){return new this._Vec4(this[0],this[3],this[1],this[3])}get xwzx(){return new this._Vec4(this[0],this[3],this[2],this[0])}get xwzy(){return new this._Vec4(this[0],this[3],this[2],this[1])}get xwzz(){return new this._Vec4(this[0],this[3],this[2],this[2])}get xwzw(){return new this._Vec4(this[0],this[3],this[2],this[3])}get xwwx(){return new this._Vec4(this[0],this[3],this[3],this[0])}get xwwy(){return new this._Vec4(this[0],this[3],this[3],this[1])}get xwwz(){return new this._Vec4(this[0],this[3],this[3],this[2])}get xwww(){return new this._Vec4(this[0],this[3],this[3],this[3])}get yxxx(){return new this._Vec4(this[1],this[0],this[0],this[0])}get yxxy(){return new this._Vec4(this[1],this[0],this[0],this[1])}get yxxz(){return new this._Vec4(this[1],this[0],this[0],this[2])}get yxxw(){return new this._Vec4(this[1],this[0],this[0],this[3])}get yxyx(){return new this._Vec4(this[1],this[0],this[1],this[0])}get yxyy(){return new this._Vec4(this[1],this[0],this[1],this[1])}get yxyz(){return new this._Vec4(this[1],this[0],this[1],this[2])}get yxyw(){return new this._Vec4(this[1],this[0],this[1],this[3])}get yxzx(){return new this._Vec4(this[1],this[0],this[2],this[0])}get yxzy(){return new this._Vec4(this[1],this[0],this[2],this[1])}get yxzz(){return new this._Vec4(this[1],this[0],this[2],this[2])}get yxzw(){return new this._Vec4(this[1],this[0],this[2],this[3])}get yxwx(){return new this._Vec4(this[1],this[0],this[3],this[0])}get yxwy(){return new this._Vec4(this[1],this[0],this[3],this[1])}get yxwz(){return new this._Vec4(this[1],this[0],this[3],this[2])}get yxww(){return new this._Vec4(this[1],this[0],this[3],this[3])}get yyxx(){return new this._Vec4(this[1],this[1],this[0],this[0])}get yyxy(){return new this._Vec4(this[1],this[1],this[0],this[1])}get yyxz(){return new this._Vec4(this[1],this[1],this[0],this[2])}get yyxw(){return new this._Vec4(this[1],this[1],this[0],this[3])}get yyyx(){return new this._Vec4(this[1],this[1],this[1],this[0])}get yyyy(){return new this._Vec4(this[1],this[1],this[1],this[1])}get yyyz(){return new this._Vec4(this[1],this[1],this[1],this[2])}get yyyw(){return new this._Vec4(this[1],this[1],this[1],this[3])}get yyzx(){return new this._Vec4(this[1],this[1],this[2],this[0])}get yyzy(){return new this._Vec4(this[1],this[1],this[2],this[1])}get yyzz(){return new this._Vec4(this[1],this[1],this[2],this[2])}get yyzw(){return new this._Vec4(this[1],this[1],this[2],this[3])}get yywx(){return new this._Vec4(this[1],this[1],this[3],this[0])}get yywy(){return new this._Vec4(this[1],this[1],this[3],this[1])}get yywz(){return new this._Vec4(this[1],this[1],this[3],this[2])}get yyww(){return new this._Vec4(this[1],this[1],this[3],this[3])}get yzxx(){return new this._Vec4(this[1],this[2],this[0],this[0])}get yzxy(){return new this._Vec4(this[1],this[2],this[0],this[1])}get yzxz(){return new this._Vec4(this[1],this[2],this[0],this[2])}get yzxw(){return new this._Vec4(this[1],this[2],this[0],this[3])}get yzyx(){return new this._Vec4(this[1],this[2],this[1],this[0])}get yzyy(){return new this._Vec4(this[1],this[2],this[1],this[1])}get yzyz(){return new this._Vec4(this[1],this[2],this[1],this[2])}get yzyw(){return new this._Vec4(this[1],this[2],this[1],this[3])}get yzzx(){return new this._Vec4(this[1],this[2],this[2],this[0])}get yzzy(){return new this._Vec4(this[1],this[2],this[2],this[1])}get yzzz(){return new this._Vec4(this[1],this[2],this[2],this[2])}get yzzw(){return new this._Vec4(this[1],this[2],this[2],this[3])}get yzwx(){return new this._Vec4(this[1],this[2],this[3],this[0])}get yzwy(){return new this._Vec4(this[1],this[2],this[3],this[1])}get yzwz(){return new this._Vec4(this[1],this[2],this[3],this[2])}get yzww(){return new this._Vec4(this[1],this[2],this[3],this[3])}get ywxx(){return new this._Vec4(this[1],this[3],this[0],this[0])}get ywxy(){return new this._Vec4(this[1],this[3],this[0],this[1])}get ywxz(){return new this._Vec4(this[1],this[3],this[0],this[2])}get ywxw(){return new this._Vec4(this[1],this[3],this[0],this[3])}get ywyx(){return new this._Vec4(this[1],this[3],this[1],this[0])}get ywyy(){return new this._Vec4(this[1],this[3],this[1],this[1])}get ywyz(){return new this._Vec4(this[1],this[3],this[1],this[2])}get ywyw(){return new this._Vec4(this[1],this[3],this[1],this[3])}get ywzx(){return new this._Vec4(this[1],this[3],this[2],this[0])}get ywzy(){return new this._Vec4(this[1],this[3],this[2],this[1])}get ywzz(){return new this._Vec4(this[1],this[3],this[2],this[2])}get ywzw(){return new this._Vec4(this[1],this[3],this[2],this[3])}get ywwx(){return new this._Vec4(this[1],this[3],this[3],this[0])}get ywwy(){return new this._Vec4(this[1],this[3],this[3],this[1])}get ywwz(){return new this._Vec4(this[1],this[3],this[3],this[2])}get ywww(){return new this._Vec4(this[1],this[3],this[3],this[3])}get zxxx(){return new this._Vec4(this[2],this[0],this[0],this[0])}get zxxy(){return new this._Vec4(this[2],this[0],this[0],this[1])}get zxxz(){return new this._Vec4(this[2],this[0],this[0],this[2])}get zxxw(){return new this._Vec4(this[2],this[0],this[0],this[3])}get zxyx(){return new this._Vec4(this[2],this[0],this[1],this[0])}get zxyy(){return new this._Vec4(this[2],this[0],this[1],this[1])}get zxyz(){return new this._Vec4(this[2],this[0],this[1],this[2])}get zxyw(){return new this._Vec4(this[2],this[0],this[1],this[3])}get zxzx(){return new this._Vec4(this[2],this[0],this[2],this[0])}get zxzy(){return new this._Vec4(this[2],this[0],this[2],this[1])}get zxzz(){return new this._Vec4(this[2],this[0],this[2],this[2])}get zxzw(){return new this._Vec4(this[2],this[0],this[2],this[3])}get zxwx(){return new this._Vec4(this[2],this[0],this[3],this[0])}get zxwy(){return new this._Vec4(this[2],this[0],this[3],this[1])}get zxwz(){return new this._Vec4(this[2],this[0],this[3],this[2])}get zxww(){return new this._Vec4(this[2],this[0],this[3],this[3])}get zyxx(){return new this._Vec4(this[2],this[1],this[0],this[0])}get zyxy(){return new this._Vec4(this[2],this[1],this[0],this[1])}get zyxz(){return new this._Vec4(this[2],this[1],this[0],this[2])}get zyxw(){return new this._Vec4(this[2],this[1],this[0],this[3])}get zyyx(){return new this._Vec4(this[2],this[1],this[1],this[0])}get zyyy(){return new this._Vec4(this[2],this[1],this[1],this[1])}get zyyz(){return new this._Vec4(this[2],this[1],this[1],this[2])}get zyyw(){return new this._Vec4(this[2],this[1],this[1],this[3])}get zyzx(){return new this._Vec4(this[2],this[1],this[2],this[0])}get zyzy(){return new this._Vec4(this[2],this[1],this[2],this[1])}get zyzz(){return new this._Vec4(this[2],this[1],this[2],this[2])}get zyzw(){return new this._Vec4(this[2],this[1],this[2],this[3])}get zywx(){return new this._Vec4(this[2],this[1],this[3],this[0])}get zywy(){return new this._Vec4(this[2],this[1],this[3],this[1])}get zywz(){return new this._Vec4(this[2],this[1],this[3],this[2])}get zyww(){return new this._Vec4(this[2],this[1],this[3],this[3])}get zzxx(){return new this._Vec4(this[2],this[2],this[0],this[0])}get zzxy(){return new this._Vec4(this[2],this[2],this[0],this[1])}get zzxz(){return new this._Vec4(this[2],this[2],this[0],this[2])}get zzxw(){return new this._Vec4(this[2],this[2],this[0],this[3])}get zzyx(){return new this._Vec4(this[2],this[2],this[1],this[0])}get zzyy(){return new this._Vec4(this[2],this[2],this[1],this[1])}get zzyz(){return new this._Vec4(this[2],this[2],this[1],this[2])}get zzyw(){return new this._Vec4(this[2],this[2],this[1],this[3])}get zzzx(){return new this._Vec4(this[2],this[2],this[2],this[0])}get zzzy(){return new this._Vec4(this[2],this[2],this[2],this[1])}get zzzz(){return new this._Vec4(this[2],this[2],this[2],this[2])}get zzzw(){return new this._Vec4(this[2],this[2],this[2],this[3])}get zzwx(){return new this._Vec4(this[2],this[2],this[3],this[0])}get zzwy(){return new this._Vec4(this[2],this[2],this[3],this[1])}get zzwz(){return new this._Vec4(this[2],this[2],this[3],this[2])}get zzww(){return new this._Vec4(this[2],this[2],this[3],this[3])}get zwxx(){return new this._Vec4(this[2],this[3],this[0],this[0])}get zwxy(){return new this._Vec4(this[2],this[3],this[0],this[1])}get zwxz(){return new this._Vec4(this[2],this[3],this[0],this[2])}get zwxw(){return new this._Vec4(this[2],this[3],this[0],this[3])}get zwyx(){return new this._Vec4(this[2],this[3],this[1],this[0])}get zwyy(){return new this._Vec4(this[2],this[3],this[1],this[1])}get zwyz(){return new this._Vec4(this[2],this[3],this[1],this[2])}get zwyw(){return new this._Vec4(this[2],this[3],this[1],this[3])}get zwzx(){return new this._Vec4(this[2],this[3],this[2],this[0])}get zwzy(){return new this._Vec4(this[2],this[3],this[2],this[1])}get zwzz(){return new this._Vec4(this[2],this[3],this[2],this[2])}get zwzw(){return new this._Vec4(this[2],this[3],this[2],this[3])}get zwwx(){return new this._Vec4(this[2],this[3],this[3],this[0])}get zwwy(){return new this._Vec4(this[2],this[3],this[3],this[1])}get zwwz(){return new this._Vec4(this[2],this[3],this[3],this[2])}get zwww(){return new this._Vec4(this[2],this[3],this[3],this[3])}get wxxx(){return new this._Vec4(this[3],this[0],this[0],this[0])}get wxxy(){return new this._Vec4(this[3],this[0],this[0],this[1])}get wxxz(){return new this._Vec4(this[3],this[0],this[0],this[2])}get wxxw(){return new this._Vec4(this[3],this[0],this[0],this[3])}get wxyx(){return new this._Vec4(this[3],this[0],this[1],this[0])}get wxyy(){return new this._Vec4(this[3],this[0],this[1],this[1])}get wxyz(){return new this._Vec4(this[3],this[0],this[1],this[2])}get wxyw(){return new this._Vec4(this[3],this[0],this[1],this[3])}get wxzx(){return new this._Vec4(this[3],this[0],this[2],this[0])}get wxzy(){return new this._Vec4(this[3],this[0],this[2],this[1])}get wxzz(){return new this._Vec4(this[3],this[0],this[2],this[2])}get wxzw(){return new this._Vec4(this[3],this[0],this[2],this[3])}get wxwx(){return new this._Vec4(this[3],this[0],this[3],this[0])}get wxwy(){return new this._Vec4(this[3],this[0],this[3],this[1])}get wxwz(){return new this._Vec4(this[3],this[0],this[3],this[2])}get wxww(){return new this._Vec4(this[3],this[0],this[3],this[3])}get wyxx(){return new this._Vec4(this[3],this[1],this[0],this[0])}get wyxy(){return new this._Vec4(this[3],this[1],this[0],this[1])}get wyxz(){return new this._Vec4(this[3],this[1],this[0],this[2])}get wyxw(){return new this._Vec4(this[3],this[1],this[0],this[3])}get wyyx(){return new this._Vec4(this[3],this[1],this[1],this[0])}get wyyy(){return new this._Vec4(this[3],this[1],this[1],this[1])}get wyyz(){return new this._Vec4(this[3],this[1],this[1],this[2])}get wyyw(){return new this._Vec4(this[3],this[1],this[1],this[3])}get wyzx(){return new this._Vec4(this[3],this[1],this[2],this[0])}get wyzy(){return new this._Vec4(this[3],this[1],this[2],this[1])}get wyzz(){return new this._Vec4(this[3],this[1],this[2],this[2])}get wyzw(){return new this._Vec4(this[3],this[1],this[2],this[3])}get wywx(){return new this._Vec4(this[3],this[1],this[3],this[0])}get wywy(){return new this._Vec4(this[3],this[1],this[3],this[1])}get wywz(){return new this._Vec4(this[3],this[1],this[3],this[2])}get wyww(){return new this._Vec4(this[3],this[1],this[3],this[3])}get wzxx(){return new this._Vec4(this[3],this[2],this[0],this[0])}get wzxy(){return new this._Vec4(this[3],this[2],this[0],this[1])}get wzxz(){return new this._Vec4(this[3],this[2],this[0],this[2])}get wzxw(){return new this._Vec4(this[3],this[2],this[0],this[3])}get wzyx(){return new this._Vec4(this[3],this[2],this[1],this[0])}get wzyy(){return new this._Vec4(this[3],this[2],this[1],this[1])}get wzyz(){return new this._Vec4(this[3],this[2],this[1],this[2])}get wzyw(){return new this._Vec4(this[3],this[2],this[1],this[3])}get wzzx(){return new this._Vec4(this[3],this[2],this[2],this[0])}get wzzy(){return new this._Vec4(this[3],this[2],this[2],this[1])}get wzzz(){return new this._Vec4(this[3],this[2],this[2],this[2])}get wzzw(){return new this._Vec4(this[3],this[2],this[2],this[3])}get wzwx(){return new this._Vec4(this[3],this[2],this[3],this[0])}get wzwy(){return new this._Vec4(this[3],this[2],this[3],this[1])}get wzwz(){return new this._Vec4(this[3],this[2],this[3],this[2])}get wzww(){return new this._Vec4(this[3],this[2],this[3],this[3])}get wwxx(){return new this._Vec4(this[3],this[3],this[0],this[0])}get wwxy(){return new this._Vec4(this[3],this[3],this[0],this[1])}get wwxz(){return new this._Vec4(this[3],this[3],this[0],this[2])}get wwxw(){return new this._Vec4(this[3],this[3],this[0],this[3])}get wwyx(){return new this._Vec4(this[3],this[3],this[1],this[0])}get wwyy(){return new this._Vec4(this[3],this[3],this[1],this[1])}get wwyz(){return new this._Vec4(this[3],this[3],this[1],this[2])}get wwyw(){return new this._Vec4(this[3],this[3],this[1],this[3])}get wwzx(){return new this._Vec4(this[3],this[3],this[2],this[0])}get wwzy(){return new this._Vec4(this[3],this[3],this[2],this[1])}get wwzz(){return new this._Vec4(this[3],this[3],this[2],this[2])}get wwzw(){return new this._Vec4(this[3],this[3],this[2],this[3])}get wwwx(){return new this._Vec4(this[3],this[3],this[3],this[0])}get wwwy(){return new this._Vec4(this[3],this[3],this[3],this[1])}get wwwz(){return new this._Vec4(this[3],this[3],this[3],this[2])}get wwww(){return new this._Vec4(this[3],this[3],this[3],this[3])}},T=class extends ne{constructor(t,n){super(2),this[0]=_nullishCoalesce(t, () => (this.getDefaultValue())),this[1]=_nullishCoalesce(_nullishCoalesce(n, () => (t)), () => (this.getDefaultValue()))}get x(){return this[0]}get y(){return this[1]}set x(t){this[0]=t}set y(t){this[1]=t}},g=class extends ne{constructor(t,n,i){super(3),this[0]=_nullishCoalesce(t, () => (this.getDefaultValue())),this[1]=_nullishCoalesce(_nullishCoalesce(n, () => (t)), () => (this.getDefaultValue())),this[2]=_nullishCoalesce(_nullishCoalesce(i, () => (t)), () => (this.getDefaultValue()))}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(t){this[0]=t}set y(t){this[1]=t}set z(t){this[2]=t}},b=class extends ne{constructor(t,n,i,s){super(4),this[0]=_nullishCoalesce(t, () => (this.getDefaultValue())),this[1]=_nullishCoalesce(_nullishCoalesce(n, () => (t)), () => (this.getDefaultValue())),this[2]=_nullishCoalesce(_nullishCoalesce(i, () => (t)), () => (this.getDefaultValue())),this[3]=_nullishCoalesce(_nullishCoalesce(s, () => (t)), () => (this.getDefaultValue()))}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}get w(){return this[3]}set x(t){this[0]=t}set y(t){this[1]=t}set z(t){this[2]=t}set w(t){this[3]=t}},D=class e extends T{getDefaultValue(){return 0}get kind(){return"vec2f"}get _Vec2(){return e}get _Vec3(){return P}get _Vec4(){return M}},S=class e extends T{getDefaultValue(){return 0}get kind(){return"vec2h"}get _Vec2(){return e}get _Vec3(){return C}get _Vec4(){return U}},B=class e extends T{getDefaultValue(){return 0}get kind(){return"vec2i"}get _Vec2(){return e}get _Vec3(){return $}get _Vec4(){return W}},k=class e extends T{getDefaultValue(){return 0}get kind(){return"vec2u"}get _Vec2(){return e}get _Vec3(){return N}get _Vec4(){return R}},F=class e extends T{getDefaultValue(){return!1}get kind(){return"vec2<bool>"}get _Vec2(){return e}get _Vec3(){return L}get _Vec4(){return O}},P=class e extends g{getDefaultValue(){return 0}get kind(){return"vec3f"}get _Vec2(){return D}get _Vec3(){return e}get _Vec4(){return M}},C=class e extends g{getDefaultValue(){return 0}get kind(){return"vec3h"}get _Vec2(){return S}get _Vec3(){return e}get _Vec4(){return U}},$=class e extends g{getDefaultValue(){return 0}get kind(){return"vec3i"}get _Vec2(){return B}get _Vec3(){return e}get _Vec4(){return W}},N=class e extends g{getDefaultValue(){return 0}get kind(){return"vec3u"}get _Vec2(){return k}get _Vec3(){return e}get _Vec4(){return R}},L=class e extends g{getDefaultValue(){return!1}get kind(){return"vec3<bool>"}get _Vec2(){return F}get _Vec3(){return e}get _Vec4(){return O}},M=class e extends b{getDefaultValue(){return 0}get kind(){return"vec4f"}get _Vec2(){return D}get _Vec3(){return P}get _Vec4(){return e}},U=class e extends b{getDefaultValue(){return 0}get kind(){return"vec4h"}get _Vec2(){return S}get _Vec3(){return C}get _Vec4(){return e}},W=class e extends b{getDefaultValue(){return 0}get kind(){return"vec4i"}get _Vec2(){return B}get _Vec3(){return $}get _Vec4(){return e}},R=class e extends b{getDefaultValue(){return 0}get kind(){return"vec4u"}get _Vec2(){return k}get _Vec3(){return N}get _Vec4(){return e}},O=class e extends b{getDefaultValue(){return!1}get kind(){return"vec4<bool>"}get _Vec2(){return F}get _Vec3(){return L}get _Vec4(){return e}};var x=y(D),Ue= exports.r =y(S),E= exports.s =y(B),j= exports.t =y(k),We= exports.u =y(F),G= exports.v =y(P),Re= exports.w =y(C),ae= exports.x =y($),f= exports.y =y(N),Oe= exports.z =y(L),h= exports.A =y(M),Ee= exports.B =y(U),K= exports.C =y(W),H= exports.D =y(R),je= exports.E =y(O),ft={vec2f:x,vec2h:Ue,vec2i:E,vec2u:j,"vec2<bool>":We,vec3f:G,vec3h:Re,vec3i:ae,vec3u:f,"vec3<bool>":Oe,vec4f:h,vec4h:Ee,vec4i:K,vec4u:H,"vec4<bool>":je};function y(e){let{kind:t,length:n}=new e,i=w((...s)=>{let a=new Array(s.length),V=0;for(let q of s)if(typeof q=="number"||typeof q=="boolean")a[V++]=q;else for(let ce=0;ce<q.length;++ce)a[V++]=q[ce];if(a.length<=1||a.length===n)return new e(...a);throw new Error(`'${t}' constructor called with invalid number of arguments.`)},(...s)=>({value:`${t}(${s.map(a=>a.value).join(", ")})`,dataType:ft[t]}));return Object.assign(i,{type:t,[oe]:void 0})}var r=class{constructor(t){this.type=t}},Tt= exports.na ={uint8:u,uint8x2:j,uint8x4:H,sint8:z,sint8x2:E,sint8x4:K,unorm8:c,unorm8x2:x,unorm8x4:h,snorm8:c,snorm8x2:x,snorm8x4:h,uint16:u,uint16x2:j,uint16x4:H,sint16:z,sint16x2:E,sint16x4:K,unorm16:c,unorm16x2:x,unorm16x4:h,snorm16:c,snorm16x2:x,snorm16x4:h,float16:c,float16x2:x,float16x4:h,float32:c,float32x2:x,float32x3:G,float32x4:h,uint32:u,uint32x2:j,uint32x3:f,uint32x4:H,sint32:z,sint32x2:E,sint32x3:ae,sint32x4:K,"unorm10-10-10-2":h,"unorm8x4-bgra":h},Ge= exports.oa =Object.keys(Tt),Dn= exports.pa =new r("uint8"),Sn= exports.qa =new r("uint8x2"),Bn= exports.ra =new r("uint8x4"),kn= exports.sa =new r("sint8"),Fn= exports.ta =new r("sint8x2"),Pn= exports.ua =new r("sint8x4"),Cn= exports.va =new r("unorm8"),$n= exports.wa =new r("unorm8x2"),Nn= exports.xa =new r("unorm8x4"),Ln= exports.ya =new r("snorm8"),Mn= exports.za =new r("snorm8x2"),Un= exports.Aa =new r("snorm8x4"),Wn= exports.Ba =new r("uint16"),Rn= exports.Ca =new r("uint16x2"),On= exports.Da =new r("uint16x4"),En= exports.Ea =new r("sint16"),jn= exports.Fa =new r("sint16x2"),Gn= exports.Ga =new r("sint16x4"),Kn= exports.Ha =new r("unorm16"),Hn= exports.Ia =new r("unorm16x2"),Jn= exports.Ja =new r("unorm16x4"),qn= exports.Ka =new r("snorm16"),Qn= exports.La =new r("snorm16x2"),Xn= exports.Ma =new r("snorm16x4"),Yn= exports.Na =new r("float16"),Zn= exports.Oa =new r("float16x2"),er= exports.Pa =new r("float16x4"),tr= exports.Qa =new r("float32"),nr= exports.Ra =new r("float32x2"),rr= exports.Sa =new r("float32x3"),ir= exports.Ta =new r("float32x4"),sr= exports.Ua =new r("uint32"),or= exports.Va =new r("uint32x2"),ar= exports.Wa =new r("uint32x3"),ur= exports.Xa =new r("uint32x4"),hr= exports.Ya =new r("sint32"),yr= exports.Za =new r("sint32x2"),cr= exports._a =new r("sint32x3"),xr= exports.$a =new r("sint32x4"),lr= exports.ab =new r("unorm10-10-10-2"),pr= exports.bb =new r("unorm8x4-bgra");var gt={f32:4,f16:2,i32:4,u32:4,vec2f:8,vec2h:4,vec2i:8,vec2u:8,vec3f:16,vec3h:8,vec3i:16,vec3u:16,vec4f:16,vec4h:8,vec4i:16,vec4u:16,mat2x2f:8,mat3x3f:16,mat4x4f:16,atomic:4};function bt(e){let t=_optionalChain([e, 'optionalAccess', _41 => _41.type]),n=gt[t];if(n!==void 0)return n;if(Z(e))return Object.values(e.propTypes).map(l).reduce((i,s)=>i>s?i:s);if(Y(e))return l(e.elementType);if(A(e)){let i=Object.values(e.propTypes)[0];return i?_nullishCoalesce(I(i), () => (1)):1}if(_(e))return _nullishCoalesce(I(e.elementType), () => (1));if(d(e)||m(e))return _nullishCoalesce(I(e), () => (l(e.inner)));if(Ge.includes(t))return 1;throw new Error(`Cannot determine alignment of data: ${JSON.stringify(e)}`)}function Vt(e){if(A(e)){let t=Object.values(e.propTypes)[0];return t?J(t):1}return _(e)?J(e.elementType):m(e)?_nullishCoalesce(I(e), () => (J(e.inner))):_nullishCoalesce(I(e), () => (1))}var Ke=new WeakMap,He=new WeakMap;function l(e){let t=Ke.get(e);return t===void 0&&(t=bt(e),Ke.set(e,t)),t}function J(e){let t=He.get(e);return t===void 0&&(t=Vt(e),He.set(e,t)),t}function zt(e){return l(e)}var vt={f32:4,f16:2,i32:4,u32:4,vec2f:8,vec2h:4,vec2i:8,vec2u:8,vec3f:12,vec3h:6,vec3i:12,vec3u:12,vec4f:16,vec4h:8,vec4i:16,vec4u:16,mat2x2f:16,mat3x3f:48,mat4x4f:64,uint8:1,uint8x2:2,uint8x4:4,sint8:1,sint8x2:2,sint8x4:4,unorm8:1,unorm8x2:2,unorm8x4:4,snorm8:1,snorm8x2:2,snorm8x4:4,uint16:2,uint16x2:4,uint16x4:8,sint16:2,sint16x2:4,sint16x4:8,unorm16:2,unorm16x2:4,unorm16x4:8,snorm16:2,snorm16x2:4,snorm16x4:8,float16:2,float16x2:4,float16x4:8,float32:4,float32x2:8,float32x3:12,float32x4:16,uint32:4,uint32x2:8,uint32x3:12,uint32x4:16,sint32:4,sint32x2:8,sint32x3:12,sint32x4:16,"unorm10-10-10-2":4,"unorm8x4-bgra":4,atomic:4};function _t(e){let t=0;for(let n of Object.values(e.propTypes)){if(Number.isNaN(t))throw new Error("Only the last property of a struct can be unbounded");if(t=v(t,l(n)),t+=p(n),Number.isNaN(t)&&n.type!=="array")throw new Error("Cannot nest unbounded struct within another struct")}return v(t,l(e))}function At(e){let t=0;for(let n of Object.values(e.propTypes)){let i=J(n);t=v(t,i),t+=p(n)}return t}function It(e){let t=vt[_optionalChain([e, 'optionalAccess', _42 => _42.type])];if(t!==void 0)return t;if(Z(e))return _t(e);if(A(e))return At(e);if(Y(e)){if(e.elementCount===0)return Number.NaN;let n=l(e.elementType);return v(p(e.elementType),n)*e.elementCount}if(_(e)){let n=J(e.elementType);return v(p(e.elementType),n)*e.elementCount}if(d(e)||m(e))return _nullishCoalesce(Me(e), () => (p(e.inner)));throw new Error(`Cannot determine size of data: ${e}`)}var Je=new WeakMap;function p(e){let t=Je.get(e);return t===void 0&&(t=It(e),Je.set(e,t)),t}function Dt(e){return p(e)}function fe(e,t){return new de(e,t)}var de= (_class =class{constructor(t,n){;_class.prototype.__init.call(this);this.elementType=t;this.elementCount=n;if(Number.isNaN(p(t)))throw new Error("Cannot nest runtime sized arrays.");if(!Number.isInteger(n)||n<0)throw new Error(`Cannot create array schema with invalid element count: ${n}.`)}__init() {this.type="array"}toString(){return`arrayOf(${this.elementType})`}}, _class);function St(e){return{type:"ptr",inner:e,addressSpace:"function",access:"read-write"}}function Bt(e){return{type:"ptr",inner:e,addressSpace:"private",access:"read-write"}}function kt(e){return{type:"ptr",inner:e,addressSpace:"workgroup",access:"read-write"}}function Ft(e,t="read"){return{type:"ptr",inner:e,addressSpace:"storage",access:t}}function Pt(e){return{type:"ptr",inner:e,addressSpace:"uniform",access:"read"}}function Ct(e){return{type:"ptr",inner:e,addressSpace:"handle",access:"read"}}function $t(e,t){return new Te(e,t)}var Te= (_class2 =class{constructor(t,n){;_class2.prototype.__init2.call(this);this.elementType=t;this.elementCount=n;if(!Number.isInteger(n)||n<0)throw new Error(`Cannot create disarray schema with invalid element count: ${n}.`)}__init2() {this.type="disarray"}}, _class2);function Nt(e){return new ge(e)}var ge= (_class3 =class{constructor(t){;_class3.prototype.__init3.call(this);this.propTypes=t}__init3() {this.type="unstruct"}get label(){return this._label}$name(t){return this._label=t,this}}, _class3);function Ie(e){let t={[oe]:void 0,type:e.type,label:e.type},n=w((...i)=>{let s=[];for(let a of i)if(typeof a=="number")s.push(a);else for(let V=0;V<a.length;++V)s.push(a[V]);for(let a=s.length;a<e.columns*e.rows;++a)s.push(0);return e.makeFromElements(...s)},(...i)=>({value:`${t.type}(${i.map(s=>s.value).join(", ")})`,dataType:t}));return Object.assign(n,t)}var be= (_class4 =class{__init4() {this.length=4}constructor(...t){;_class4.prototype.__init4.call(this);this.columns=[this.makeColumn(t[0],t[1]),this.makeColumn(t[2],t[3])]}get 0(){return this.columns[0].x}get 1(){return this.columns[0].y}get 2(){return this.columns[1].x}get 3(){return this.columns[1].y}set 0(t){this.columns[0].x=t}set 1(t){this.columns[0].y=t}set 2(t){this.columns[1].x=t}set 3(t){this.columns[1].y=t}"~resolve"(){return`${this.kind}(${Array.from({length:this.length}).map((t,n)=>this[n]).join(", ")})`}}, _class4),Ve= (_class5 =class extends be{constructor(...args) { super(...args); _class5.prototype.__init5.call(this); }__init5() {this.kind="mat2x2f"}makeColumn(t,n){return x(t,n)}}, _class5),ze= (_class6 =class{__init6() {this.length=12}constructor(...t){;_class6.prototype.__init6.call(this);this.columns=[this.makeColumn(t[0],t[1],t[2]),this.makeColumn(t[3],t[4],t[5]),this.makeColumn(t[6],t[7],t[8])]}get 0(){return this.columns[0].x}get 1(){return this.columns[0].y}get 2(){return this.columns[0].z}get 3(){return 0}get 4(){return this.columns[1].x}get 5(){return this.columns[1].y}get 6(){return this.columns[1].z}get 7(){return 0}get 8(){return this.columns[2].x}get 9(){return this.columns[2].y}get 10(){return this.columns[2].z}get 11(){return 0}set 0(t){this.columns[0].x=t}set 1(t){this.columns[0].y=t}set 2(t){this.columns[0].z=t}set 3(t){}set 4(t){this.columns[1].x=t}set 5(t){this.columns[1].y=t}set 6(t){this.columns[1].z=t}set 7(t){}set 8(t){this.columns[2].x=t}set 9(t){this.columns[2].y=t}set 10(t){this.columns[2].z=t}set 11(t){}"~resolve"(){return`${this.kind}(${this[0]}, ${this[1]}, ${this[2]}, ${this[4]}, ${this[5]}, ${this[6]}, ${this[8]}, ${this[9]}, ${this[10]})`}}, _class6),ve= (_class7 =class extends ze{constructor(...args2) { super(...args2); _class7.prototype.__init7.call(this); }__init7() {this.kind="mat3x3f"}makeColumn(t,n,i){return G(t,n,i)}}, _class7),_e= (_class8 =class{constructor(...t){;_class8.prototype.__init8.call(this);this.columns=[this.makeColumn(t[0],t[1],t[2],t[3]),this.makeColumn(t[4],t[5],t[6],t[7]),this.makeColumn(t[8],t[9],t[10],t[11]),this.makeColumn(t[12],t[13],t[14],t[15])]}__init8() {this.length=16}get 0(){return this.columns[0].x}get 1(){return this.columns[0].y}get 2(){return this.columns[0].z}get 3(){return this.columns[0].w}get 4(){return this.columns[1].x}get 5(){return this.columns[1].y}get 6(){return this.columns[1].z}get 7(){return this.columns[1].w}get 8(){return this.columns[2].x}get 9(){return this.columns[2].y}get 10(){return this.columns[2].z}get 11(){return this.columns[2].w}get 12(){return this.columns[3].x}get 13(){return this.columns[3].y}get 14(){return this.columns[3].z}get 15(){return this.columns[3].w}set 0(t){this.columns[0].x=t}set 1(t){this.columns[0].y=t}set 2(t){this.columns[0].z=t}set 3(t){this.columns[0].w=t}set 4(t){this.columns[1].x=t}set 5(t){this.columns[1].y=t}set 6(t){this.columns[1].z=t}set 7(t){this.columns[1].w=t}set 8(t){this.columns[2].x=t}set 9(t){this.columns[2].y=t}set 10(t){this.columns[2].z=t}set 11(t){this.columns[2].w=t}set 12(t){this.columns[3].x=t}set 13(t){this.columns[3].y=t}set 14(t){this.columns[3].z=t}set 15(t){this.columns[3].w=t}"~resolve"(){return`${this.kind}(${Array.from({length:this.length}).map((t,n)=>this[n]).join(", ")})`}}, _class8),Ae= (_class9 =class extends _e{constructor(...args3) { super(...args3); _class9.prototype.__init9.call(this); }__init9() {this.kind="mat4x4f"}makeColumn(t,n,i,s){return h(t,n,i,s)}}, _class9),Lt= exports.F =Ie({type:"mat2x2f",rows:2,columns:2,makeFromElements:(...e)=>new Ve(...e)}),Mt= exports.G =Ie({type:"mat3x3f",rows:3,columns:3,makeFromElements:(...e)=>new ve(...e)}),Ut= exports.H =Ie({type:"mat4x4f",rows:4,columns:4,makeFromElements:(...e)=>new Ae(...e)});function Wt(e){return e.kind==="mat3x3f"?[e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]]:Array.from({length:e.length}).map((t,n)=>e[n])}function Rt(e){return new De(e)}var De= (_class10 =class{constructor(t){;_class10.prototype.__init10.call(this);this.inner=t}__init10() {this.type="atomic"}}, _class10);function o(e,t){return d(e)?new he(e.inner,[t,...e.attribs]):m(e)?new ye(e.inner,[t,...e.attribs]):se(e)?new ye(e,[t]):new he(e,[t])}function Ot(e,t){return o(t,{type:"@align",value:e})}function Et(e,t){return o(t,{type:"@size",value:e})}function jt(e,t){return o(t,{type:"@location",value:e})}function Gt(e,t){return o(t,{type:"@interpolate",value:e})}function Kt(e){return(d(e)||m(e))&&e.attribs.find(we)!==void 0}function Ur(e){return!d(e)&&!m(e)?"":e.attribs.map(t=>`${t.type}(${t.value}) `).join("")}var ue=class{constructor(t,n){this.inner=t;this.attribs=n;let i=_optionalChain([n, 'access', _43 => _43.find, 'call', _44 => _44(ee), 'optionalAccess', _45 => _45.value]),s=_optionalChain([n, 'access', _46 => _46.find, 'call', _47 => _47(te), 'optionalAccess', _48 => _48.value]);if(i!==void 0){if(i<=0)throw new Error(`Custom data alignment must be a positive number, got: ${i}.`);if(Math.log2(i)%1!==0)throw new Error(`Alignment has to be a power of 2, got: ${i}.`);if(X(this.inner)&&i%l(this.inner)!==0)throw new Error(`Custom alignment has to be a multiple of the standard data alignment. Got: ${i}, expected multiple of: ${l(this.inner)}.`)}if(s!==void 0){if(s<p(this.inner))throw new Error(`Custom data size cannot be smaller then the standard data size. Got: ${s}, expected at least: ${p(this.inner)}.`);if(s<=0)throw new Error(`Custom data size must be a positive number. Got: ${s}.`)}}},he= (_class11 =class extends ue{constructor(...args4) { super(...args4); _class11.prototype.__init11.call(this); }__init11() {this.type="decorated"}}, _class11),ye= (_class12 =class extends ue{constructor(...args5) { super(...args5); _class12.prototype.__init12.call(this); }__init12() {this.type="loose-decorated"}}, _class12);var Ht={vertexIndex:o(u,{type:"@builtin",value:"vertex_index"}),instanceIndex:o(u,{type:"@builtin",value:"instance_index"}),position:o(h,{type:"@builtin",value:"position"}),clipDistances:o(fe(u,8),{type:"@builtin",value:"clip_distances"}),frontFacing:o(c,{type:"@builtin",value:"front_facing"}),fragDepth:o(c,{type:"@builtin",value:"frag_depth"}),sampleIndex:o(u,{type:"@builtin",value:"sample_index"}),sampleMask:o(u,{type:"@builtin",value:"sample_mask"}),localInvocationId:o(f,{type:"@builtin",value:"local_invocation_id"}),localInvocationIndex:o(u,{type:"@builtin",value:"local_invocation_index"}),globalInvocationId:o(f,{type:"@builtin",value:"global_invocation_id"}),workgroupId:o(f,{type:"@builtin",value:"workgroup_id"}),numWorkgroups:o(f,{type:"@builtin",value:"num_workgroups"}),subgroupInvocationId:o(u,{type:"@builtin",value:"subgroup_invocation_id"}),subgroupSize:o(u,{type:"@builtin",value:"subgroup_size"})};exports.a = le; exports.b = Se; exports.c = Be; exports.d = ke; exports.e = Fe; exports.f = Pe; exports.g = Ce; exports.h = Xe; exports.i = Qt; exports.j = Xt; exports.k = Yt; exports.l = Zt; exports.m = $e; exports.n = nn; exports.o = w; exports.p = oe; exports.q = x; exports.r = Ue; exports.s = E; exports.t = j; exports.u = We; exports.v = G; exports.w = Re; exports.x = ae; exports.y = f; exports.z = Oe; exports.A = h; exports.B = Ee; exports.C = K; exports.D = H; exports.E = je; exports.F = Lt; exports.G = Mt; exports.H = Ut; exports.I = Wt; exports.J = an; exports.K = un; exports.L = Ye; exports.M = u; exports.N = z; exports.O = c; exports.P = Ne; exports.Q = it; exports.R = st; exports.S = yn; exports.T = at; exports.U = ut; exports.V = cn; exports.W = X; exports.X = Y; exports.Y = Z; exports.Z = yt; exports._ = ct; exports.$ = ee; exports.aa = te; exports.ba = me; exports.ca = xt; exports.da = we; exports.ea = d; exports.fa = Le; exports.ga = mn; exports.ha = se; exports.ia = _; exports.ja = A; exports.ka = m; exports.la = fn; exports.ma = dt; exports.na = Tt; exports.oa = Ge; exports.pa = Dn; exports.qa = Sn; exports.ra = Bn; exports.sa = kn; exports.ta = Fn; exports.ua = Pn; exports.va = Cn; exports.wa = $n; exports.xa = Nn; exports.ya = Ln; exports.za = Mn; exports.Aa = Un; exports.Ba = Wn; exports.Ca = Rn; exports.Da = On; exports.Ea = En; exports.Fa = jn; exports.Ga = Gn; exports.Ha = Kn; exports.Ia = Hn; exports.Ja = Jn; exports.Ka = qn; exports.La = Qn; exports.Ma = Xn; exports.Na = Yn; exports.Oa = Zn; exports.Pa = er; exports.Qa = tr; exports.Ra = nr; exports.Sa = rr; exports.Ta = ir; exports.Ua = sr; exports.Va = or; exports.Wa = ar; exports.Xa = ur; exports.Ya = hr; exports.Za = yr; exports._a = cr; exports.$a = xr; exports.ab = lr; exports.bb = pr; exports.cb = l; exports.db = J; exports.eb = zt; exports.fb = v; exports.gb = p; exports.hb = Dt; exports.ib = o; exports.jb = Ot; exports.kb = Et; exports.lb = jt; exports.mb = Gt; exports.nb = Kt; exports.ob = Ur; exports.pb = pt; exports.qb = fe; exports.rb = St; exports.sb = Bt; exports.tb = kt; exports.ub = Ft; exports.vb = Pt; exports.wb = Ct; exports.xb = $t; exports.yb = Nt; exports.zb = Rt; exports.Ab = Ht;
4
+ //# sourceMappingURL=chunk-7UUBX6MC.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/data/numeric.ts","../src/errors.ts"],"names":["prefix","invariant","condition","message","ResolutionError","_ResolutionError","cause","trace","entries","ancestor"],"mappings":"AAAA,ohCAAgB,ICOVA,EAAAA,CAAS,kBAAA,CAKR,SAASC,EAAAA,CACdC,CAAAA,CACAC,CAAAA,CACmB,CACnB,EAAA,CAAID,CAAAA,CAEF,MAAA,CAKA,MAAM,IAAI,KAAA,CAAMF,EAAM,CAa1B,CASO,IAAMI,EAAAA,CAAN,MAAMC,EAAAA,QAAwB,KAAM,CACzC,WAAA,CACkBC,CAAAA,CACAC,CAAAA,CAChB,CACA,IAAIC,CAAAA,CAAUD,CAAAA,CAAM,GAAA,CAAKE,CAAAA,EAAa,CAAA,EAAA,EAAKA,CAAQ,CAAA,CAAA;AAQU;AAU7D","file":"/Users/iwo/Projects/wigsill/packages/typegpu/dist/chunk-7UUBX6MC.cjs","sourcesContent":["import bin from 'typed-binary';\nimport { createDualImpl } from '../shared/generators';\nimport type {\n AbstractFloat,\n AbstractInt,\n Bool,\n F16,\n F32,\n I32,\n U32,\n} from './wgslTypes';\n\nexport const abstractInt = {\n type: 'abstractInt',\n} as AbstractInt;\n\nexport const abstractFloat = {\n type: 'abstractFloat',\n} as AbstractFloat;\n\n/**\n * A schema that represents a boolean value. (equivalent to `bool` in WGSL)\n */\nexport const bool: Bool = {\n type: 'bool',\n} as Bool;\n\nconst u32Cast = createDualImpl(\n // CPU implementation\n (v: number | boolean) => {\n if (typeof v === 'boolean') {\n return v ? 1 : 0;\n }\n if (Number.isInteger(v)) {\n if (v < 0 || v > 0xffffffff) {\n console.warn(`u32 value ${v} overflowed`);\n }\n const value = v & 0xffffffff;\n return value >>> 0;\n }\n return Math.max(0, Math.min(0xffffffff, Math.floor(v)));\n },\n // GPU implementation\n (v) => {\n return { value: `u32(${v.value})`, dataType: u32 };\n },\n);\n\n/**\n * A schema that represents an unsigned 32-bit integer value. (equivalent to `u32` in WGSL)\n *\n * Can also be called to cast a value to an u32 in accordance with WGSL casting rules.\n *\n * @example\n * const value = u32(3.14); // 3\n * @example\n * const value = u32(-1); // 4294967295\n * @example\n * const value = u32(-3.1); // 0\n */\nexport const u32: U32 = Object.assign(u32Cast, {\n type: 'u32',\n}) as U32;\n\nconst i32Cast = createDualImpl(\n // CPU implementation\n (v: number | boolean) => {\n if (typeof v === 'boolean') {\n return v ? 1 : 0;\n }\n if (Number.isInteger(v)) {\n if (v < -0x80000000 || v > 0x7fffffff) {\n console.warn(`i32 value ${v} overflowed`);\n }\n const value = v | 0;\n return value & 0xffffffff;\n }\n // round towards zero\n const value = v < 0 ? Math.ceil(v) : Math.floor(v);\n return Math.max(-0x80000000, Math.min(0x7fffffff, value));\n },\n // GPU implementation\n (v) => {\n return { value: `i32(${v.value})`, dataType: i32 };\n },\n);\n\n/**\n * A schema that represents a signed 32-bit integer value. (equivalent to `i32` in WGSL)\n *\n * Can also be called to cast a value to an i32 in accordance with WGSL casting rules.\n *\n * @example\n * const value = i32(3.14); // 3\n * @example\n * const value = i32(-3.9); // -3\n * @example\n * const value = i32(10000000000) // 1410065408\n */\nexport const i32: I32 = Object.assign(i32Cast, {\n type: 'i32',\n}) as I32;\n\nconst f32Cast = createDualImpl(\n // CPU implementation\n (v: number | boolean) => {\n if (typeof v === 'boolean') {\n return v ? 1 : 0;\n }\n const arr = new Float32Array(1);\n arr[0] = v;\n return arr[0];\n },\n // GPU implementation\n (v) => {\n return { value: `f32(${v.value})`, dataType: f32 };\n },\n);\n\n/**\n * A schema that represents a 32-bit float value. (equivalent to `f32` in WGSL)\n *\n * Can also be called to cast a value to an f32.\n *\n * @example\n * const value = f32(true); // 1\n */\nexport const f32: F32 = Object.assign(f32Cast, {\n type: 'f32',\n}) as F32;\n\nconst f16Cast = createDualImpl(\n // CPU implementation\n (v: number | boolean) => {\n if (typeof v === 'boolean') {\n return v ? 1 : 0;\n }\n const arr = new ArrayBuffer(2);\n bin.f16.write(new bin.BufferWriter(arr), v);\n return bin.f16.read(new bin.BufferReader(arr));\n },\n // GPU implementation\n // TODO: make usage of f16() in GPU mode check for feature availability and throw if not available\n (v) => {\n return { value: `f16(${v.value})`, dataType: f16 };\n },\n);\n\n/**\n * A schema that represents a 16-bit float value. (equivalent to `f16` in WGSL)\n *\n * Can also be called to cast a value to an f16.\n *\n * @example\n * const value = f16(true); // 1\n * @example\n * const value = f16(21877.5); // 21872\n */\nexport const f16: F16 = Object.assign(f16Cast, {\n type: 'f16',\n}) as F16;\n","import type { TgpuBuffer } from './core/buffer/buffer';\nimport type { TgpuSlot } from './core/slot/slotTypes';\nimport type { TgpuVertexLayout } from './core/vertexLayout/vertexLayout';\nimport type { AnyData, Disarray } from './data/dataTypes';\nimport type { WgslArray } from './data/wgslTypes';\nimport type { TgpuBindGroupLayout } from './tgpuBindGroupLayout';\n\nconst prefix = 'Invariant failed';\n\n/**\n * Inspired by: https://github.com/alexreardon/tiny-invariant/blob/master/src/tiny-invariant.ts\n */\nexport function invariant(\n condition: unknown,\n message?: string | (() => string),\n): asserts condition {\n if (condition) {\n // Condition passed\n return;\n }\n\n // In production we strip the message but still throw\n if (process.env.NODE_ENV === 'production') {\n throw new Error(prefix);\n }\n\n // When not in production we allow the message to pass through\n // *This block will be removed in production builds*\n\n const provided = typeof message === 'function' ? message() : message;\n\n // Options:\n // 1. message provided: `${prefix}: ${provided}`\n // 2. message not provided: prefix\n const value = provided ? `${prefix}: ${provided}` : prefix;\n throw new Error(value);\n}\n\n/**\n * An error that happens during resolution of WGSL code.\n * Contains a trace of all ancestor resolvables in\n * which this error originated.\n *\n * @category Errors\n */\nexport class ResolutionError extends Error {\n constructor(\n public readonly cause: unknown,\n public readonly trace: unknown[],\n ) {\n let entries = trace.map((ancestor) => `- ${ancestor}`);\n\n // Showing only the root and leaf nodes.\n if (entries.length > 20) {\n entries = [...entries.slice(0, 11), '...', ...entries.slice(-10)];\n }\n\n super(\n `Resolution of the following tree failed: \\n${entries.join('\\n')}: ${cause && typeof cause === 'object' && 'message' in cause ? cause.message : cause}`,\n );\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, ResolutionError.prototype);\n }\n\n appendToTrace(ancestor: unknown): ResolutionError {\n const newTrace = [ancestor, ...this.trace];\n\n return new ResolutionError(this.cause, newTrace);\n }\n}\n\n/**\n * @category Errors\n */\nexport class MissingSlotValueError extends Error {\n constructor(public readonly slot: TgpuSlot<unknown>) {\n super(`Missing value for '${slot}'`);\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, MissingSlotValueError.prototype);\n }\n}\n\n/**\n * @category Errors\n */\nexport class NotUniformError extends Error {\n constructor(value: TgpuBuffer<AnyData>) {\n super(\n `Buffer '${value.label ?? '<unnamed>'}' is not bindable as a uniform. Use .$usage('uniform') to allow it.`,\n );\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, NotUniformError.prototype);\n }\n}\n\nexport class MissingLinksError extends Error {\n constructor(fnLabel: string | undefined, externalNames: string[]) {\n super(\n `The function '${fnLabel ?? '<unnamed>'}' is missing links to the following external values: ${externalNames}.`,\n );\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, MissingLinksError.prototype);\n }\n}\n\nexport class MissingBindGroupsError extends Error {\n constructor(layouts: Iterable<TgpuBindGroupLayout>) {\n super(\n `Missing bind groups for layouts: '${[...layouts].map((layout) => layout.label ?? '<unnamed>').join(', ')}'. Please provide it using pipeline.with(layout, bindGroup).(...)`,\n );\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, MissingBindGroupsError.prototype);\n }\n}\n\nexport class MissingVertexBuffersError extends Error {\n constructor(layouts: Iterable<TgpuVertexLayout<WgslArray | Disarray>>) {\n super(\n `Missing vertex buffers for layouts: '${[...layouts].map((layout) => layout.label ?? '<unnamed>').join(', ')}'. Please provide it using pipeline.with(layout, buffer).(...)`,\n );\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, MissingVertexBuffersError.prototype);\n }\n}\n"]}