typegpu 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,541 @@
1
+ import { Unwrap, ISchema, Parsed } from 'typed-binary';
2
+
3
+ /**
4
+ * Can be assigned a name. Not to be confused with
5
+ * being able to HAVE a name.
6
+ */
7
+ interface TgpuNamable {
8
+ $name(label?: string | undefined): this;
9
+ }
10
+
11
+ type Getter = <T>(plum: TgpuPlum<T>) => T;
12
+ interface TgpuPlum<TValue = unknown> extends TgpuNamable {
13
+ readonly __brand: 'TgpuPlum';
14
+ /**
15
+ * Computes the value of this plum. Circumvents the store
16
+ * memoization, so use with care.
17
+ */
18
+ compute(get: Getter): TValue;
19
+ }
20
+
21
+ interface TgpuBufferUsage<TData extends AnyTgpuData, TUsage extends BufferUsage = BufferUsage> extends TgpuBindable<TData, TUsage> {
22
+ value: Unwrap<TData>;
23
+ }
24
+
25
+ type AnyTgpuDataTuple = [AnyTgpuData, ...AnyTgpuData[]] | [];
26
+ type UnwrapArgs<T extends AnyTgpuDataTuple> = {
27
+ [Idx in keyof T]: Unwrap<T[Idx]>;
28
+ };
29
+ type UnwrapReturn<T extends AnyTgpuData | undefined> = T extends undefined ? void : Unwrap<T>;
30
+ /**
31
+ * Describes a function signature (its arguments and return type)
32
+ */
33
+ interface TgpuFnShell<Args extends AnyTgpuDataTuple, Return extends AnyTgpuData | undefined> {
34
+ readonly argTypes: Args;
35
+ readonly returnType: Return | undefined;
36
+ /**
37
+ * Creates a type-safe implementation of this signature
38
+ */
39
+ implement(body: (...args: UnwrapArgs<Args>) => UnwrapReturn<Return>): TgpuFn<Args, Return>;
40
+ }
41
+ interface TgpuFnBase<Args extends AnyTgpuDataTuple, Return extends AnyTgpuData | undefined = undefined> extends TgpuResolvable, TgpuNamable {
42
+ readonly shell: TgpuFnShell<Args, Return>;
43
+ /** The JS function body passed as an implementation of a TypeGPU function. */
44
+ readonly body: (...args: UnwrapArgs<Args>) => UnwrapReturn<Return>;
45
+ readonly bodyResolvable: TgpuResolvable;
46
+ $uses(dependencyMap: Record<string, unknown>): this;
47
+ }
48
+ type TgpuFn<Args extends AnyTgpuDataTuple, Return extends AnyTgpuData | undefined = undefined> = TgpuFnBase<Args, Return> & ((...args: UnwrapArgs<Args>) => UnwrapReturn<Return>);
49
+
50
+ type Wgsl = string | number | TgpuResolvable | symbol | boolean;
51
+ /**
52
+ * Passed into each resolvable item. All sibling items share a resolution ctx,
53
+ * and a new resolution ctx is made when going down each level in the tree.
54
+ */
55
+ interface ResolutionCtx {
56
+ addDeclaration(item: TgpuResolvable): void;
57
+ addBinding(bindable: TgpuBindable, identifier: TgpuIdentifier): void;
58
+ addRenderResource(resource: TgpuRenderResource, identifier: TgpuIdentifier): void;
59
+ addBuiltin(builtin: symbol): void;
60
+ nameFor(token: TgpuResolvable): string;
61
+ /**
62
+ * Unwraps all layers of slot indirection and returns the concrete value if available.
63
+ * @throws {MissingSlotValueError}
64
+ */
65
+ unwrap<T>(eventual: Eventual<T>): T;
66
+ resolve(item: Wgsl, slotValueOverrides?: SlotValuePair<unknown>[]): string;
67
+ fnToWgsl(fn: TgpuFn<any, any>, externalMap: Record<string, unknown>): {
68
+ head: Wgsl;
69
+ body: Wgsl;
70
+ };
71
+ }
72
+ interface TgpuResolvable {
73
+ readonly label?: string | undefined;
74
+ resolve(ctx: ResolutionCtx): string;
75
+ }
76
+ interface TgpuIdentifier extends TgpuNamable, TgpuResolvable {
77
+ }
78
+ /**
79
+ * Represents a value that is available at resolution time.
80
+ */
81
+ type Eventual<T> = T | TgpuSlot<T>;
82
+ type SlotValuePair<T> = [TgpuSlot<T>, T];
83
+ interface TgpuBindable<TData extends AnyTgpuData = AnyTgpuData, TUsage extends BufferUsage = BufferUsage> extends TgpuResolvable {
84
+ readonly allocatable: TgpuBuffer<TData>;
85
+ readonly usage: TUsage;
86
+ }
87
+ type TgpuSamplerType = 'sampler' | 'sampler_comparison';
88
+ type TgpuTypedTextureType = 'texture_1d' | 'texture_2d' | 'texture_2d_array' | 'texture_3d' | 'texture_cube' | 'texture_cube_array' | 'texture_multisampled_2d';
89
+ type TgpuDepthTextureType = 'texture_depth_2d' | 'texture_depth_2d_array' | 'texture_depth_cube' | 'texture_depth_cube_array' | 'texture_depth_multisampled_2d';
90
+ type TgpuStorageTextureType = 'texture_storage_1d' | 'texture_storage_2d' | 'texture_storage_2d_array' | 'texture_storage_3d';
91
+ type TgpuExternalTextureType = 'texture_external';
92
+ type TgpuRenderResourceType = TgpuSamplerType | TgpuTypedTextureType | TgpuDepthTextureType | TgpuStorageTextureType | TgpuExternalTextureType;
93
+ interface TgpuRenderResource extends TgpuResolvable {
94
+ readonly type: TgpuRenderResourceType;
95
+ }
96
+ type BufferUsage = 'uniform' | 'readonly' | 'mutable' | 'vertex';
97
+ type ValueOf<T> = T extends TgpuSlot<infer I> ? ValueOf<I> : T extends TgpuBufferUsage<infer D> ? ValueOf<D> : T extends TgpuData<unknown> ? Unwrap<T> : T;
98
+ interface TgpuData<TInner> extends ISchema<TInner>, TgpuResolvable {
99
+ readonly isLoose: false;
100
+ readonly isCustomAligned: boolean;
101
+ readonly byteAlignment: number;
102
+ readonly size: number;
103
+ }
104
+ interface TgpuLooseData<TInner> extends ISchema<TInner>, TgpuResolvable {
105
+ readonly isLoose: true;
106
+ readonly size: number;
107
+ }
108
+ type AnyTgpuData = TgpuData<unknown>;
109
+ type AnyTgpuLooseData = TgpuLooseData<unknown>;
110
+ interface TgpuPointer<TScope extends 'function', TInner extends AnyTgpuData> {
111
+ readonly scope: TScope;
112
+ readonly pointsTo: TInner;
113
+ }
114
+ interface TgpuSlot<T> extends TgpuNamable {
115
+ readonly __brand: 'TgpuSlot';
116
+ readonly defaultValue: T | undefined;
117
+ readonly label?: string | undefined;
118
+ /**
119
+ * Used to determine if code generated using either value `a` or `b` in place
120
+ * of the slot will be equivalent. Defaults to `Object.is`.
121
+ */
122
+ areEqual(a: T, b: T): boolean;
123
+ value: ValueOf<T>;
124
+ }
125
+
126
+ interface Swizzle2<T2, T3, T4> {
127
+ readonly xx: T2;
128
+ readonly xy: T2;
129
+ readonly yx: T2;
130
+ readonly yy: T2;
131
+ readonly xxx: T3;
132
+ readonly xxy: T3;
133
+ readonly xyx: T3;
134
+ readonly xyy: T3;
135
+ readonly yxx: T3;
136
+ readonly yxy: T3;
137
+ readonly yyx: T3;
138
+ readonly yyy: T3;
139
+ readonly xxxx: T4;
140
+ readonly xxxy: T4;
141
+ readonly xxyx: T4;
142
+ readonly xxyy: T4;
143
+ readonly xyxx: T4;
144
+ readonly xyxy: T4;
145
+ readonly xyyx: T4;
146
+ readonly xyyy: T4;
147
+ readonly yxxx: T4;
148
+ readonly yxxy: T4;
149
+ readonly yxyx: T4;
150
+ readonly yxyy: T4;
151
+ readonly yyxx: T4;
152
+ readonly yyxy: T4;
153
+ readonly yyyx: T4;
154
+ readonly yyyy: T4;
155
+ }
156
+ interface Swizzle3<T2, T3, T4> extends Swizzle2<T2, T3, T4> {
157
+ readonly xz: T2;
158
+ readonly yz: T2;
159
+ readonly zx: T2;
160
+ readonly zy: T2;
161
+ readonly zz: T2;
162
+ readonly xxz: T3;
163
+ readonly xyz: T3;
164
+ readonly xzx: T3;
165
+ readonly xzy: T3;
166
+ readonly xzz: T3;
167
+ readonly yxz: T3;
168
+ readonly yyz: T3;
169
+ readonly yzx: T3;
170
+ readonly yzy: T3;
171
+ readonly yzz: T3;
172
+ readonly zxx: T3;
173
+ readonly zxy: T3;
174
+ readonly zxz: T3;
175
+ readonly zyx: T3;
176
+ readonly zyy: T3;
177
+ readonly zyz: T3;
178
+ readonly zzx: T3;
179
+ readonly zzy: T3;
180
+ readonly zzz: T3;
181
+ readonly xxxz: T4;
182
+ readonly xxyz: T4;
183
+ readonly xxzx: T4;
184
+ readonly xxzy: T4;
185
+ readonly xxzz: T4;
186
+ readonly xyxz: T4;
187
+ readonly xyyz: T4;
188
+ readonly xyzx: T4;
189
+ readonly xyzy: T4;
190
+ readonly xyzz: T4;
191
+ readonly xzxx: T4;
192
+ readonly xzxy: T4;
193
+ readonly xzxz: T4;
194
+ readonly xzyx: T4;
195
+ readonly xzyy: T4;
196
+ readonly xzyz: T4;
197
+ readonly xzzx: T4;
198
+ readonly xzzy: T4;
199
+ readonly xzzz: T4;
200
+ readonly yxxz: T4;
201
+ readonly yxyz: T4;
202
+ readonly yxzx: T4;
203
+ readonly yxzy: T4;
204
+ readonly yxzz: T4;
205
+ readonly yyxz: T4;
206
+ readonly yyyz: T4;
207
+ readonly yyzx: T4;
208
+ readonly yyzy: T4;
209
+ readonly yyzz: T4;
210
+ readonly yzxx: T4;
211
+ readonly yzxy: T4;
212
+ readonly yzxz: T4;
213
+ readonly yzyx: T4;
214
+ readonly yzyy: T4;
215
+ readonly yzyz: T4;
216
+ readonly yzzx: T4;
217
+ readonly yzzy: T4;
218
+ readonly yzzz: T4;
219
+ readonly zxxx: T4;
220
+ readonly zxxy: T4;
221
+ readonly zxxz: T4;
222
+ readonly zxyx: T4;
223
+ readonly zxyy: T4;
224
+ readonly zxyz: T4;
225
+ readonly zxzx: T4;
226
+ readonly zxzy: T4;
227
+ readonly zxzz: T4;
228
+ readonly zyxx: T4;
229
+ readonly zyxy: T4;
230
+ readonly zyxz: T4;
231
+ readonly zyyx: T4;
232
+ readonly zyyy: T4;
233
+ readonly zyyz: T4;
234
+ readonly zyzx: T4;
235
+ readonly zyzy: T4;
236
+ readonly zyzz: T4;
237
+ readonly zzxx: T4;
238
+ readonly zzxy: T4;
239
+ readonly zzxz: T4;
240
+ readonly zzyx: T4;
241
+ readonly zzyy: T4;
242
+ readonly zzyz: T4;
243
+ readonly zzzx: T4;
244
+ readonly zzzy: T4;
245
+ readonly zzzz: T4;
246
+ }
247
+ interface Swizzle4<T2, T3, T4> extends Swizzle3<T2, T3, T4> {
248
+ readonly yw: T2;
249
+ readonly zw: T2;
250
+ readonly wx: T2;
251
+ readonly wy: T2;
252
+ readonly wz: T2;
253
+ readonly ww: T2;
254
+ readonly xxw: T3;
255
+ readonly xyw: T3;
256
+ readonly xzw: T3;
257
+ readonly xwx: T3;
258
+ readonly xwy: T3;
259
+ readonly xwz: T3;
260
+ readonly xww: T3;
261
+ readonly yxw: T3;
262
+ readonly yyw: T3;
263
+ readonly yzw: T3;
264
+ readonly ywx: T3;
265
+ readonly ywy: T3;
266
+ readonly ywz: T3;
267
+ readonly yww: T3;
268
+ readonly zxw: T3;
269
+ readonly zyw: T3;
270
+ readonly zzw: T3;
271
+ readonly zwx: T3;
272
+ readonly zwy: T3;
273
+ readonly zwz: T3;
274
+ readonly zww: T3;
275
+ readonly wxx: T3;
276
+ readonly wxz: T3;
277
+ readonly wxy: T3;
278
+ readonly wyy: T3;
279
+ readonly wyz: T3;
280
+ readonly wzz: T3;
281
+ readonly wwx: T3;
282
+ readonly wwy: T3;
283
+ readonly wwz: T3;
284
+ readonly www: T3;
285
+ readonly xxxw: T4;
286
+ readonly xxyw: T4;
287
+ readonly xxzw: T4;
288
+ readonly xxwx: T4;
289
+ readonly xxwy: T4;
290
+ readonly xxwz: T4;
291
+ readonly xxww: T4;
292
+ readonly xyxw: T4;
293
+ readonly xyyw: T4;
294
+ readonly xyzw: T4;
295
+ readonly xywx: T4;
296
+ readonly xywy: T4;
297
+ readonly xywz: T4;
298
+ readonly xyww: T4;
299
+ readonly xzxw: T4;
300
+ readonly xzyw: T4;
301
+ readonly xzzw: T4;
302
+ readonly xzwx: T4;
303
+ readonly xzwy: T4;
304
+ readonly xzwz: T4;
305
+ readonly xzww: T4;
306
+ readonly xwxx: T4;
307
+ readonly xwxy: T4;
308
+ readonly xwxz: T4;
309
+ readonly xwyy: T4;
310
+ readonly xwyz: T4;
311
+ readonly xwzz: T4;
312
+ readonly xwwx: T4;
313
+ readonly xwwy: T4;
314
+ readonly xwwz: T4;
315
+ readonly xwww: T4;
316
+ readonly yxxw: T4;
317
+ readonly yxyw: T4;
318
+ readonly yxzw: T4;
319
+ readonly yxwx: T4;
320
+ readonly yxwy: T4;
321
+ readonly yxwz: T4;
322
+ readonly yxww: T4;
323
+ readonly yyxw: T4;
324
+ readonly yyyw: T4;
325
+ readonly yyzw: T4;
326
+ readonly yywx: T4;
327
+ readonly yywy: T4;
328
+ readonly yywz: T4;
329
+ readonly yyww: T4;
330
+ readonly yzxw: T4;
331
+ readonly yzyw: T4;
332
+ readonly yzzw: T4;
333
+ readonly yzwx: T4;
334
+ readonly yzwy: T4;
335
+ readonly yzwz: T4;
336
+ readonly yzww: T4;
337
+ readonly ywxx: T4;
338
+ readonly ywxy: T4;
339
+ readonly ywxz: T4;
340
+ readonly ywxw: T4;
341
+ readonly ywyy: T4;
342
+ readonly ywyz: T4;
343
+ readonly ywzz: T4;
344
+ readonly ywwx: T4;
345
+ readonly ywwy: T4;
346
+ readonly ywwz: T4;
347
+ readonly ywww: T4;
348
+ readonly zxxw: T4;
349
+ readonly zxyw: T4;
350
+ readonly zxzw: T4;
351
+ readonly zxwx: T4;
352
+ readonly zxwy: T4;
353
+ readonly zxwz: T4;
354
+ readonly zxww: T4;
355
+ readonly zyxw: T4;
356
+ readonly zyyw: T4;
357
+ readonly zyzw: T4;
358
+ readonly zywx: T4;
359
+ readonly zywy: T4;
360
+ readonly zywz: T4;
361
+ readonly zyww: T4;
362
+ readonly zzxw: T4;
363
+ readonly zzyw: T4;
364
+ readonly zzzw: T4;
365
+ readonly zzwx: T4;
366
+ readonly zzwy: T4;
367
+ readonly zzwz: T4;
368
+ readonly zzww: T4;
369
+ readonly zwxx: T4;
370
+ readonly zwxy: T4;
371
+ readonly zwxz: T4;
372
+ readonly zwxw: T4;
373
+ readonly zwyy: T4;
374
+ readonly zwyz: T4;
375
+ readonly zwzz: T4;
376
+ readonly zwwx: T4;
377
+ readonly zwwy: T4;
378
+ readonly zwwz: T4;
379
+ readonly zwww: T4;
380
+ readonly wxxx: T4;
381
+ readonly wxxy: T4;
382
+ readonly wxxz: T4;
383
+ readonly wxxw: T4;
384
+ readonly wxyx: T4;
385
+ readonly wxyy: T4;
386
+ readonly wxyz: T4;
387
+ readonly wxyw: T4;
388
+ readonly wxzx: T4;
389
+ readonly wxzy: T4;
390
+ readonly wxzz: T4;
391
+ readonly wxzw: T4;
392
+ readonly wxwx: T4;
393
+ readonly wxwy: T4;
394
+ readonly wxwz: T4;
395
+ readonly wxww: T4;
396
+ readonly wyxx: T4;
397
+ readonly wyxy: T4;
398
+ readonly wyxz: T4;
399
+ readonly wyxw: T4;
400
+ readonly wyyy: T4;
401
+ readonly wyyz: T4;
402
+ readonly wyzw: T4;
403
+ readonly wywx: T4;
404
+ readonly wywy: T4;
405
+ readonly wywz: T4;
406
+ readonly wyww: T4;
407
+ readonly wzxx: T4;
408
+ readonly wzxy: T4;
409
+ readonly wzxz: T4;
410
+ readonly wzxw: T4;
411
+ readonly wzyy: T4;
412
+ readonly wzyz: T4;
413
+ readonly wzzy: T4;
414
+ readonly wzzw: T4;
415
+ readonly wzwx: T4;
416
+ readonly wzwy: T4;
417
+ readonly wzwz: T4;
418
+ readonly wzww: T4;
419
+ readonly wwxx: T4;
420
+ readonly wwxy: T4;
421
+ readonly wwxz: T4;
422
+ readonly wwxw: T4;
423
+ readonly wwyy: T4;
424
+ readonly wwyz: T4;
425
+ readonly wwzz: T4;
426
+ readonly wwwx: T4;
427
+ readonly wwwy: T4;
428
+ readonly wwwz: T4;
429
+ readonly wwww: T4;
430
+ }
431
+ interface vec2 {
432
+ x: number;
433
+ y: number;
434
+ [Symbol.iterator](): Iterator<number>;
435
+ }
436
+ interface vec3 {
437
+ x: number;
438
+ y: number;
439
+ z: number;
440
+ [Symbol.iterator](): Iterator<number>;
441
+ }
442
+ interface vec4 {
443
+ x: number;
444
+ y: number;
445
+ z: number;
446
+ w: number;
447
+ [Symbol.iterator](): Iterator<number>;
448
+ }
449
+ type VecKind = 'vec2f' | 'vec2i' | 'vec2u' | 'vec3f' | 'vec3i' | 'vec3u' | 'vec4f' | 'vec4i' | 'vec4u';
450
+ interface vecBase {
451
+ kind: VecKind;
452
+ [Symbol.iterator](): Iterator<number>;
453
+ }
454
+ type Vec2f = TgpuData<vec2f> & ((x: number, y: number) => vec2f) & ((xy: number) => vec2f) & (() => vec2f);
455
+ interface vec2f extends vec2, Swizzle2<vec2f, vec3f, vec4f> {
456
+ /** use to distinguish between vectors of the same size on the type level */
457
+ kind: 'vec2f';
458
+ }
459
+ declare const vec2f: Vec2f;
460
+ type Vec2i = TgpuData<vec2i> & ((x: number, y: number) => vec2i) & ((xy: number) => vec2i) & (() => vec2i);
461
+ interface vec2i extends vec2, Swizzle2<vec2i, vec3i, vec4i> {
462
+ /** use to distinguish between vectors of the same size on the type level */
463
+ kind: 'vec2i';
464
+ }
465
+ declare const vec2i: Vec2i;
466
+ type Vec2u = TgpuData<vec2u> & ((x: number, y: number) => vec2u) & ((xy: number) => vec2u) & (() => vec2u);
467
+ interface vec2u extends vec2, Swizzle2<vec2u, vec3u, vec4u> {
468
+ /** use to distinguish between vectors of the same size on the type level */
469
+ kind: 'vec2u';
470
+ }
471
+ declare const vec2u: Vec2u;
472
+ type Vec3f = TgpuData<vec3f> & ((x: number, y: number, z: number) => vec3f) & ((xyz: number) => vec3f) & (() => vec3f);
473
+ interface vec3f extends vec3, Swizzle3<vec2f, vec3f, vec4f> {
474
+ /** use to distinguish between vectors of the same size on the type level */
475
+ kind: 'vec3f';
476
+ }
477
+ declare const vec3f: Vec3f;
478
+ type Vec3i = TgpuData<vec3i> & ((x: number, y: number, z: number) => vec3i) & ((xyz: number) => vec3i) & (() => vec3i);
479
+ interface vec3i extends vec3, Swizzle3<vec2i, vec3i, vec4i> {
480
+ /** use to distinguish between vectors of the same size on the type level */
481
+ kind: 'vec3i';
482
+ }
483
+ declare const vec3i: Vec3i;
484
+ type Vec3u = TgpuData<vec3u> & ((x: number, y: number, z: number) => vec3u) & ((xyz: number) => vec3u) & (() => vec3u);
485
+ interface vec3u extends vec3, Swizzle3<vec2u, vec3u, vec4u> {
486
+ /** use to distinguish between vectors of the same size on the type level */
487
+ kind: 'vec3u';
488
+ }
489
+ declare const vec3u: Vec3u;
490
+ type Vec4f = TgpuData<vec4f> & ((x: number, y: number, z: number, w: number) => vec4f) & ((xyzw: number) => vec4f) & (() => vec4f);
491
+ interface vec4f extends vec4, Swizzle4<vec2f, vec3f, vec4f> {
492
+ /** use to distinguish between vectors of the same size on the type level */
493
+ kind: 'vec4f';
494
+ }
495
+ declare const vec4f: Vec4f;
496
+ type Vec4i = TgpuData<vec4i> & ((x: number, y: number, z: number, w: number) => vec4i) & ((xyzw: number) => vec4i) & (() => vec4i);
497
+ interface vec4i extends vec4, Swizzle4<vec2i, vec3i, vec4i> {
498
+ /** use to distinguish between vectors of the same size on the type level */
499
+ kind: 'vec4i';
500
+ }
501
+ declare const vec4i: Vec4i;
502
+ type Vec4u = TgpuData<vec4u> & ((x: number, y: number, z: number, w: number) => vec4u) & ((xyzw: number) => vec4u) & (() => vec4u);
503
+ interface vec4u extends vec4, Swizzle4<vec2u, vec3u, vec4u> {
504
+ /** use to distinguish between vectors of the same size on the type level */
505
+ kind: 'vec4u';
506
+ }
507
+ declare const vec4u: Vec4u;
508
+
509
+ interface Uniform {
510
+ usableAsUniform: true;
511
+ }
512
+ declare const Uniform: Uniform;
513
+ interface Storage {
514
+ usableAsStorage: true;
515
+ }
516
+ declare const Storage: Storage;
517
+ interface Vertex {
518
+ usableAsVertex: true;
519
+ }
520
+ declare const Vertex: Vertex;
521
+ type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
522
+ interface TgpuBuffer<TData extends AnyTgpuData> extends TgpuNamable {
523
+ readonly resourceType: 'buffer';
524
+ readonly dataType: TData;
525
+ readonly initial?: Parsed<TData> | TgpuPlum<Parsed<TData>> | undefined;
526
+ readonly label: string | undefined;
527
+ readonly buffer: GPUBuffer;
528
+ readonly device: GPUDevice;
529
+ readonly destroyed: boolean;
530
+ $usage<T extends (Uniform | Storage | Vertex)[]>(...usages: T): this & UnionToIntersection<T[number]>;
531
+ $addFlags(flags: GPUBufferUsageFlags): this;
532
+ $device(device: GPUDevice): this;
533
+ write(data: Parsed<TData> | TgpuBuffer<TData>): void;
534
+ read(): Promise<Parsed<TData>>;
535
+ destroy(): void;
536
+ }
537
+ declare function isUsableAsUniform<T extends TgpuBuffer<AnyTgpuData>>(buffer: T): buffer is T & Uniform;
538
+ declare function isUsableAsStorage<T extends TgpuBuffer<AnyTgpuData>>(buffer: T): buffer is T & Storage;
539
+ declare function isUsableAsVertex<T extends TgpuBuffer<AnyTgpuData>>(buffer: T): buffer is T & Vertex;
540
+
541
+ export { type AnyTgpuData as A, type Vec4f as B, type Vec4i as C, type Vec4u as D, type ResolutionCtx as R, Storage as S, type TgpuPlum as T, Uniform as U, Vertex as V, type TgpuBuffer as a, vec3f as b, vec3i as c, vec3u as d, type TgpuData as e, isUsableAsUniform as f, isUsableAsVertex as g, type TgpuNamable as h, isUsableAsStorage as i, vec2f as j, vec4f as k, type TgpuPointer as l, type AnyTgpuLooseData as m, type TgpuLooseData as n, type VecKind as o, vec2i as p, vec2u as q, vec4i as r, vec4u as s, type Vec2f as t, type Vec2i as u, type vecBase as v, type Vec2u as w, type Vec3f as x, type Vec3i as y, type Vec3u as z };
package/chunk-34O2K2PT.js DELETED
@@ -1,2 +0,0 @@
1
- var F=Object.defineProperty;var z=(e,n)=>(n=Symbol[e])?n:Symbol.for("Symbol."+e);var B=(e,n,t)=>n in e?F(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var M=(e,n)=>{for(var t in n)F(e,t,{get:n[t],enumerable:!0})};var a=(e,n,t)=>(B(e,typeof n!="symbol"?n+"":n,t),t);var O=function(e,n){this[0]=e,this[1]=n};var j=e=>{var n=e[z("asyncIterator")],t=!1,r,u={};return n==null?(n=e[z("iterator")](),r=i=>u[i]=s=>n[i](s)):(n=n.call(e),r=i=>u[i]=s=>{if(t){if(t=!1,i==="throw")throw s;return s}return t=!0,{done:!1,value:new O(new Promise(R=>{var I=n[i](s);if(!(I instanceof Object))throw TypeError("Object expected");R(I)}),1)}}),u[z("iterator")]=()=>u,r("next"),"throw"in n?r("throw"):u.throw=i=>{throw i},"return"in n&&r("return"),u};function C(e){return!!e&&(typeof e=="object"||typeof e=="function")&&"resolve"in e}function W(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}var g=class e extends Error{constructor(){super("Recursive types are not supported in WGSL"),Object.setPrototypeOf(this,e.prototype)}};import{Measurer as E,f32 as D,i32 as V,u32 as P}from"typed-binary";var v=class extends Function{constructor(){super("...args","return this._bound._call(...args)");a(this,"_bound");return this._bound=this.bind(this),this._bound}};function U(e,n){let t="size"in e?e.size:e.currentByteOffset,r=n-1,u=t&r;"skipBytes"in e?e.skipBytes(n-u&r):e.add(n-u&r)}var f=U;var o=class extends v{constructor({unitType:t,byteAlignment:r,length:u,label:i,make:s,makeFromScalar:R}){super();a(this,"__unwrapped");a(this,"unitType");a(this,"byteAlignment");a(this,"length");a(this,"size");a(this,"label");a(this,"make");a(this,"makeFromScalar");this.unitType=t,this.byteAlignment=r,this.length=u,this.size=u*4,this.label=i,this.make=s,this.makeFromScalar=R}get expressionCode(){return this.label}_call(...t){var u;let r=t;if(r.length<=1)return this.makeFromScalar((u=r[0])!=null?u:0);if(r.length===this.length)return this.make(...r);throw new Error(`'${this.label}' constructor called with invalid number of arguments.`)}resolveReferences(t){throw new g}write(t,r){f(t,this.byteAlignment);for(let u of r)this.unitType.write(t,u)}read(t){return f(t,this.byteAlignment),this.make(...Array.from({length:this.length}).map(r=>this.unitType.read(t)))}measure(t,r=new E){return f(r,this.byteAlignment),r.add(this.size)}seekProperty(t,r){throw new Error("Method not implemented.")}resolve(){return this.label}},w=class{get xx(){return this.make2(this.x,this.x)}get xy(){return this.make2(this.x,this.y)}get yx(){return this.make2(this.y,this.x)}get yy(){return this.make2(this.y,this.y)}},m=class extends w{constructor(t,r){super();this.x=t;this.y=r}*[Symbol.iterator](){yield this.x,yield this.y}},c=class e extends m{constructor(){super(...arguments);a(this,"kind","vec2f")}make2(t,r){return new e(t,r)}},p=class e extends m{constructor(){super(...arguments);a(this,"kind","vec2i")}make2(t,r){return new e(t,r)}},l=class e extends m{constructor(){super(...arguments);a(this,"kind","vec2u")}make2(t,r){return new e(t,r)}},k=class extends w{},T=class extends k{constructor(t,r,u){super();this.x=t;this.y=r;this.z=u}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},y=class e extends T{constructor(){super(...arguments);a(this,"kind","vec3f")}make2(t,r){return new c(t,r)}make3(t,r,u){return new e(t,r,u)}},b=class e extends T{constructor(){super(...arguments);a(this,"kind","vec3i")}make2(t,r){return new p(t,r)}make3(t,r,u){return new e(t,r,u)}},d=class e extends T{constructor(){super(...arguments);a(this,"kind","vec3u")}make2(t,r){return new l(t,r)}make3(t,r,u){return new e(t,r,u)}},A=class extends k{},x=class extends A{constructor(t,r,u,i){super();this.x=t;this.y=r;this.z=u;this.w=i}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},h=class e extends x{constructor(){super(...arguments);a(this,"kind","vec4f")}make2(t,r){return new c(t,r)}make3(t,r,u){return new y(t,r,u)}make4(t,r,u,i){return new e(t,r,u,i)}},S=class e extends x{constructor(){super(...arguments);a(this,"kind","vec4i")}make2(t,r){return new p(t,r)}make3(t,r,u){return new b(t,r,u)}make4(t,r,u,i){return new e(t,r,u,i)}},_=class e extends x{constructor(){super(...arguments);a(this,"kind","vec4u")}make2(t,r){return new l(t,r)}make3(t,r,u){return new d(t,r,u)}make4(t,r,u,i){return new e(t,r,u,i)}},Y=new o({unitType:D,byteAlignment:8,length:2,label:"vec2f",make:(e,n)=>new c(e,n),makeFromScalar:e=>new c(e,e)}),Z=new o({unitType:V,byteAlignment:8,length:2,label:"vec2i",make:(e,n)=>new p(e,n),makeFromScalar:e=>new p(e,e)}),ee=new o({unitType:P,byteAlignment:8,length:2,label:"vec2u",make:(e,n)=>new l(e,n),makeFromScalar:e=>new l(e,e)}),te=new o({unitType:D,byteAlignment:16,length:3,label:"vec3f",make:(e,n,t)=>new y(e,n,t),makeFromScalar:e=>new y(e,e,e)}),re=new o({unitType:V,byteAlignment:16,length:3,label:"vec3i",make:(e,n,t)=>new b(e,n,t),makeFromScalar:e=>new b(e,e,e)}),ne=new o({unitType:P,byteAlignment:16,length:3,label:"vec3u",make:(e,n,t)=>new d(e,n,t),makeFromScalar:e=>new d(e,e,e)}),ue=new o({unitType:D,byteAlignment:16,length:4,label:"vec4f",make:(e,n,t,r)=>new h(e,n,t,r),makeFromScalar:e=>new h(e,e,e,e)}),ae=new o({unitType:V,byteAlignment:16,length:4,label:"vec4i",make:(e,n,t,r)=>new S(e,n,t,r),makeFromScalar:e=>new S(e,e,e,e)}),ie=new o({unitType:P,byteAlignment:16,length:4,label:"vec4u",make:(e,n,t,r)=>new _(e,n,t,r),makeFromScalar:e=>new _(e,e,e,e)});var ce=(e,n)=>{let t=n-1,r=~t;return e&t?(e&r)+n:e};export{M as a,a as b,j as c,C as d,W as e,ce as f,g,v as h,f as i,Y as j,Z as k,ee as l,te as m,re as n,ne as o,ue as p,ae as q,ie as r};
2
- //# sourceMappingURL=chunk-34O2K2PT.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types.ts","../src/errors.ts","../src/data/vector.ts","../src/callable.ts","../src/data/alignIO.ts","../src/mathUtils.ts"],"sourcesContent":["import type { ISchema, Parsed } from 'typed-binary';\nimport type { F32, I32, U32, Vec4f, Vec4i, Vec4u } from './data';\nimport type { Builtin } from './wgslBuiltin';\nimport type { TgpuIdentifier } from './wgslIdentifier';\nimport type { TgpuPlum } from './wgslPlum';\n\nexport type Wgsl = string | number | TgpuResolvable | symbol | boolean;\n\n/**\n * Passed into each resolvable item. All sibling items share a resolution ctx,\n * and a new resolution ctx is made when going down each level in the tree.\n */\nexport interface ResolutionCtx {\n /**\n * Slots that were used by items resolved by this context.\n */\n readonly usedSlots: Iterable<TgpuSlot<unknown>>;\n\n addDeclaration(item: TgpuResolvable): void;\n addBinding(bindable: TgpuBindable, identifier: TgpuIdentifier): void;\n addRenderResource(\n resource: TgpuRenderResource,\n identifier: TgpuIdentifier,\n ): void;\n addBuiltin(builtin: Builtin): void;\n nameFor(token: TgpuResolvable): string;\n /**\n * Unwraps all layers of slot indirection and returns the concrete value if available.\n * @throws {MissingSlotValueError}\n */\n unwrap<T>(eventual: Eventual<T>): T;\n resolve(item: Wgsl, slotValueOverrides?: SlotValuePair<unknown>[]): string;\n}\n\nexport interface TgpuResolvable {\n readonly label?: string | undefined;\n resolve(ctx: ResolutionCtx): string;\n}\n\n/**\n * Can be assigned a name. Not to be confused with\n * being able to HAVE a name.\n */\nexport interface TgpuNamable {\n $name(label?: string | undefined): this;\n}\n\nexport function isResolvable(value: unknown): value is TgpuResolvable {\n return (\n !!value &&\n (typeof value === 'object' || typeof value === 'function') &&\n 'resolve' in value\n );\n}\n\nexport function isNamable(value: unknown): value is TgpuNamable {\n return (\n !!value &&\n (typeof value === 'object' || typeof value === 'function') &&\n '$name' in value\n );\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 isResolvable(value)\n );\n}\n\nexport interface TgpuSlot<T> extends TgpuNamable {\n readonly __brand: 'TgpuSlot';\n\n readonly defaultValue: T | undefined;\n\n readonly label?: string | undefined;\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\nexport function isSlot<T>(value: unknown | TgpuSlot<T>): value is TgpuSlot<T> {\n return (value as TgpuSlot<T>).__brand === 'TgpuSlot';\n}\n\n/**\n * Represents a value that is available at resolution time.\n */\nexport type Eventual<T> = T | TgpuSlot<T>;\n\nexport type EventualGetter = <T>(value: Eventual<T>) => T;\n\nexport type InlineResolve = (get: EventualGetter) => Wgsl;\n\nexport interface TgpuResolvableSlot<T extends Wgsl>\n extends TgpuResolvable,\n TgpuSlot<T> {}\n\nexport type SlotValuePair<T> = [TgpuSlot<T>, T];\n\nexport interface TgpuAllocatable<TData extends AnyTgpuData = AnyTgpuData> {\n /**\n * The data type this allocatable was constructed with.\n * It informs the size and format of data in both JS and\n * binary.\n */\n readonly dataType: TData;\n readonly initial?: Parsed<TData> | TgpuPlum<Parsed<TData>> | undefined;\n readonly flags: GPUBufferUsageFlags;\n}\n\nexport function isAllocatable(value: unknown): value is TgpuAllocatable {\n return (\n !!value &&\n typeof value === 'object' &&\n 'dataType' in value &&\n 'flags' in value\n );\n}\n\nexport interface TgpuBindable<\n TData extends AnyTgpuData = AnyTgpuData,\n TUsage extends BufferUsage = BufferUsage,\n> extends TgpuResolvable {\n readonly allocatable: TgpuAllocatable<TData>;\n readonly usage: TUsage;\n}\n\nexport type TgpuSamplerType = 'sampler' | 'sampler_comparison';\nexport type TgpuTypedTextureType =\n | 'texture_1d'\n | 'texture_2d'\n | 'texture_2d_array'\n | 'texture_3d'\n | 'texture_cube'\n | 'texture_cube_array'\n | 'texture_multisampled_2d';\nexport type TgpuDepthTextureType =\n | 'texture_depth_2d'\n | 'texture_depth_2d_array'\n | 'texture_depth_cube'\n | 'texture_depth_cube_array'\n | 'texture_depth_multisampled_2d';\nexport type TgpuStorageTextureType =\n | 'texture_storage_1d'\n | 'texture_storage_2d'\n | 'texture_storage_2d_array'\n | 'texture_storage_3d';\nexport type TgpuExternalTextureType = 'texture_external';\n\nexport type TgpuRenderResourceType =\n | TgpuSamplerType\n | TgpuTypedTextureType\n | TgpuDepthTextureType\n | TgpuStorageTextureType\n | TgpuExternalTextureType;\n\nexport interface TgpuRenderResource extends TgpuResolvable {\n readonly type: TgpuRenderResourceType;\n}\n\nexport type BufferUsage = 'uniform' | 'readonly' | 'mutable' | 'vertex';\nexport type TextureUsage = 'sampled' | 'storage';\nexport type StorageTextureAccess = 'read' | 'write' | 'read_write';\n\nexport type StorageTextureParams = {\n type: TgpuStorageTextureType;\n access: StorageTextureAccess;\n descriptor?: GPUTextureViewDescriptor;\n};\nexport type SampledTextureParams = {\n type: TgpuTypedTextureType;\n dataType: TextureScalarFormat;\n descriptor?: GPUTextureViewDescriptor;\n};\n\nexport function isSamplerType(\n type: TgpuRenderResourceType,\n): type is TgpuSamplerType {\n return type === 'sampler' || type === 'sampler_comparison';\n}\n\nexport function isTypedTextureType(\n type: TgpuRenderResourceType,\n): type is TgpuTypedTextureType {\n return [\n 'texture_1d',\n 'texture_2d',\n 'texture_2d_array',\n 'texture_3d',\n 'texture_cube',\n 'texture_cube_array',\n 'texture_multisampled_2d',\n ].includes(type);\n}\n\nexport function isDepthTextureType(\n type: TgpuRenderResourceType,\n): type is TgpuDepthTextureType {\n return [\n 'texture_depth_2d',\n 'texture_depth_2d_array',\n 'texture_depth_cube',\n 'texture_depth_cube_array',\n 'texture_depth_multisampled_2d',\n ].includes(type);\n}\n\nexport function isStorageTextureType(\n type: TgpuRenderResourceType,\n): type is TgpuStorageTextureType {\n return [\n 'texture_storage_1d',\n 'texture_storage_2d',\n 'texture_storage_2d_array',\n 'texture_storage_3d',\n ].includes(type);\n}\n\nexport function isExternalTextureType(\n type: TgpuRenderResourceType,\n): type is TgpuExternalTextureType {\n return type === 'texture_external';\n}\n\nexport interface TgpuData<TInner> extends ISchema<TInner>, TgpuResolvable {\n readonly byteAlignment: number;\n readonly size: number;\n}\n\nexport type AnyTgpuData = TgpuData<unknown>;\nexport type TextureScalarFormat = U32 | I32 | F32;\nexport type TexelFormat = Vec4u | Vec4i | Vec4f;\n\nexport interface TgpuPointer<\n TScope extends 'function',\n TInner extends AnyTgpuData,\n> {\n readonly scope: TScope;\n readonly pointsTo: TInner;\n}\n\n/**\n * A virtual representation of a WGSL value.\n */\nexport type TgpuValue<TDataType> = {\n readonly __dataType: TDataType;\n};\n\nexport type AnyTgpuPointer = TgpuPointer<'function', AnyTgpuData>;\n\nexport type TgpuFnArgument = AnyTgpuPointer | AnyTgpuData;\n\nexport function isPointer(\n value: AnyTgpuPointer | AnyTgpuData,\n): value is AnyTgpuPointer {\n return 'pointsTo' in value;\n}\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","import type { TgpuResolvable, TgpuSlot } from './types';\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: TgpuResolvable[],\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(`Resolution of the following tree failed: \\n${entries.join('\\n')}`);\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, ResolutionError.prototype);\n }\n\n appendToTrace(ancestor: TgpuResolvable): 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 RecursiveDataTypeError extends Error {\n constructor() {\n super('Recursive types are not supported in WGSL');\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, RecursiveDataTypeError.prototype);\n }\n}\n","import {\n type IMeasurer,\n type IRefResolver,\n type ISchema,\n type ISerialInput,\n type ISerialOutput,\n type MaxValue,\n Measurer,\n type Parsed,\n f32,\n i32,\n u32,\n} from 'typed-binary';\nimport { CallableImpl } from '../callable';\nimport { RecursiveDataTypeError } from '../errors';\nimport type { TgpuData } from '../types';\nimport alignIO from './alignIO';\n\n// --------------\n// Implementation\n// --------------\n\ninterface VecSchemaOptions<T> {\n unitType: ISchema<number>;\n byteAlignment: number;\n length: number;\n label: string;\n make: (...args: number[]) => T;\n makeFromScalar: (value: number) => T;\n}\n\nclass VecSchemaImpl<T extends vecBase>\n extends CallableImpl<number[], T>\n implements TgpuData<T>\n{\n readonly __unwrapped!: T; // type-token, not available at runtime\n\n readonly unitType: ISchema<number>;\n readonly byteAlignment;\n readonly length;\n readonly size;\n readonly label;\n public get expressionCode() {\n return this.label;\n }\n readonly make: (...args: number[]) => T;\n readonly makeFromScalar: (value: number) => T;\n\n constructor({\n unitType,\n byteAlignment,\n length,\n label,\n make,\n makeFromScalar,\n }: VecSchemaOptions<T>) {\n super();\n this.unitType = unitType;\n this.byteAlignment = byteAlignment;\n this.length = length;\n this.size = length * 4;\n this.label = label;\n this.make = make;\n this.makeFromScalar = makeFromScalar;\n }\n\n _call(...args: number[]): T {\n const values = args; // TODO: Allow users to pass in vectors that fill part of the values.\n\n if (values.length <= 1) {\n return this.makeFromScalar(values[0] ?? 0);\n }\n\n if (values.length === this.length) {\n return this.make(...values);\n }\n\n throw new Error(\n `'${this.label}' constructor called with invalid number of arguments.`,\n );\n }\n\n resolveReferences(ctx: IRefResolver): void {\n throw new RecursiveDataTypeError();\n }\n\n write(output: ISerialOutput, value: Parsed<T>): void {\n alignIO(output, this.byteAlignment);\n for (const element of value) {\n this.unitType.write(output, element);\n }\n }\n\n read(input: ISerialInput): Parsed<T> {\n alignIO(input, this.byteAlignment);\n return this.make(\n ...Array.from({ length: this.length }).map((_) =>\n this.unitType.read(input),\n ),\n ) as Parsed<T>;\n }\n\n measure(\n _value: Parsed<T> | MaxValue,\n measurer: IMeasurer = new Measurer(),\n ): IMeasurer {\n alignIO(measurer, this.byteAlignment);\n return measurer.add(this.size);\n }\n\n seekProperty(\n reference: Parsed<T> | MaxValue,\n prop: never,\n ): { bufferOffset: number; schema: ISchema<unknown> } | null {\n throw new Error('Method not implemented.');\n }\n\n resolve(): string {\n return this.label;\n }\n}\n\nabstract class Swizzle2Impl<T2> {\n abstract make2(x: number, y: number): T2;\n\n abstract readonly x: number;\n abstract readonly y: number;\n\n get xx(): T2 {\n return this.make2(this.x, this.x);\n }\n\n get xy(): T2 {\n return this.make2(this.x, this.y);\n }\n\n get yx(): T2 {\n return this.make2(this.y, this.x);\n }\n\n get yy(): T2 {\n return this.make2(this.y, this.y);\n }\n}\n\nabstract class vec2Impl<T2> extends Swizzle2Impl<T2> implements vec2 {\n constructor(\n public x: number,\n public y: number,\n ) {\n super();\n }\n\n *[Symbol.iterator]() {\n yield this.x;\n yield this.y;\n }\n}\n\nclass vec2fImpl extends vec2Impl<vec2f> implements vec2f {\n readonly kind = 'vec2f';\n\n make2(x: number, y: number): vec2f {\n return new vec2fImpl(x, y);\n }\n}\n\nclass vec2iImpl extends vec2Impl<vec2i> implements vec2i {\n readonly kind = 'vec2i';\n\n make2(x: number, y: number): vec2i {\n return new vec2iImpl(x, y);\n }\n}\n\nclass vec2uImpl extends vec2Impl<vec2u> implements vec2u {\n readonly kind = 'vec2u';\n\n make2(x: number, y: number): vec2u {\n return new vec2uImpl(x, y);\n }\n}\n\nabstract class Swizzle3Impl<T2, T3> extends Swizzle2Impl<T2> {\n abstract make3(x: number, y: number, z: number): T3;\n\n abstract readonly z: number;\n}\n\nabstract class vec3Impl<T2, T3> extends Swizzle3Impl<T2, T3> implements vec3 {\n constructor(\n public x: number,\n public y: number,\n public z: number,\n ) {\n super();\n }\n\n *[Symbol.iterator]() {\n yield this.x;\n yield this.y;\n yield this.z;\n }\n}\n\nclass vec3fImpl extends vec3Impl<vec2f, vec3f> implements vec3f {\n readonly kind = 'vec3f';\n\n make2(x: number, y: number): vec2f {\n return new vec2fImpl(x, y);\n }\n\n make3(x: number, y: number, z: number): vec3f {\n return new vec3fImpl(x, y, z);\n }\n}\n\nclass vec3iImpl extends vec3Impl<vec2i, vec3i> implements vec3i {\n readonly kind = 'vec3i';\n\n make2(x: number, y: number): vec2i {\n return new vec2iImpl(x, y);\n }\n\n make3(x: number, y: number, z: number): vec3i {\n return new vec3iImpl(x, y, z);\n }\n}\n\nclass vec3uImpl extends vec3Impl<vec2u, vec3u> implements vec3u {\n readonly kind = 'vec3u';\n\n make2(x: number, y: number): vec2u {\n return new vec2uImpl(x, y);\n }\n\n make3(x: number, y: number, z: number): vec3u {\n return new vec3uImpl(x, y, z);\n }\n}\n\nabstract class Swizzle4Impl<T2, T3, T4> extends Swizzle3Impl<T2, T3> {\n abstract make4(x: number, y: number, z: number, w: number): T4;\n\n abstract readonly w: number;\n}\n\nabstract class vec4Impl<T2, T3, T4>\n extends Swizzle4Impl<T2, T3, T4>\n implements vec4\n{\n constructor(\n public x: number,\n public y: number,\n public z: number,\n public w: number,\n ) {\n super();\n }\n\n *[Symbol.iterator]() {\n yield this.x;\n yield this.y;\n yield this.z;\n yield this.w;\n }\n}\n\nclass vec4fImpl extends vec4Impl<vec2f, vec3f, vec4f> implements vec4f {\n readonly kind = 'vec4f';\n\n make2(x: number, y: number): vec2f {\n return new vec2fImpl(x, y);\n }\n\n make3(x: number, y: number, z: number): vec3f {\n return new vec3fImpl(x, y, z);\n }\n\n make4(x: number, y: number, z: number, w: number): vec4f {\n return new vec4fImpl(x, y, z, w);\n }\n}\n\nclass vec4iImpl extends vec4Impl<vec2i, vec3i, vec4i> implements vec4i {\n readonly kind = 'vec4i';\n\n make2(x: number, y: number): vec2i {\n return new vec2iImpl(x, y);\n }\n\n make3(x: number, y: number, z: number): vec3i {\n return new vec3iImpl(x, y, z);\n }\n\n make4(x: number, y: number, z: number, w: number): vec4i {\n return new vec4iImpl(x, y, z, w);\n }\n}\n\nclass vec4uImpl extends vec4Impl<vec2u, vec3u, vec4u> implements vec4u {\n readonly kind = 'vec4u';\n\n make2(x: number, y: number): vec2u {\n return new vec2uImpl(x, y);\n }\n\n make3(x: number, y: number, z: number): vec3u {\n return new vec3uImpl(x, y, z);\n }\n\n make4(x: number, y: number, z: number, w: number): vec4u {\n return new vec4uImpl(x, y, z, w);\n }\n}\n\ninterface Swizzle2<T2> {\n readonly xx: T2; // TODO: Create setter\n readonly xy: T2; // TODO: Create setter\n readonly yx: T2; // TODO: Create setter\n readonly yy: T2; // TODO: Create setter\n}\n\ninterface Swizzle3<T2, T3> extends Swizzle2<T2> {\n // TODO: Implement\n}\n\ninterface Swizzle4<T2, T3, T4> extends Swizzle3<T2, T3> {\n // TODO: Implement\n}\n\ninterface vec2 {\n x: number;\n y: number;\n [Symbol.iterator](): Iterator<number>;\n}\n\ninterface vec3 {\n x: number;\n y: number;\n z: number;\n [Symbol.iterator](): Iterator<number>;\n}\n\ninterface vec4 {\n x: number;\n y: number;\n z: number;\n w: number;\n [Symbol.iterator](): Iterator<number>;\n}\n\n// ----------\n// Public API\n// ----------\n\nexport type VecKind =\n | 'vec2f'\n | 'vec2i'\n | 'vec2u'\n | 'vec3f'\n | 'vec3i'\n | 'vec3u'\n | 'vec4f'\n | 'vec4i'\n | 'vec4u';\n\nexport interface vecBase {\n kind: VecKind;\n [Symbol.iterator](): Iterator<number>;\n}\n\nexport interface vec2f extends vec2, Swizzle2<vec2f> {\n /** use to distinguish between vectors of the same size on the type level */\n kind: 'vec2f';\n}\nexport interface vec2i extends vec2, Swizzle2<vec2i> {\n /** use to distinguish between vectors of the same size on the type level */\n kind: 'vec2i';\n}\nexport interface vec2u extends vec2, Swizzle2<vec2u> {\n /** use to distinguish between vectors of the same size on the type level */\n kind: 'vec2u';\n}\n\nexport interface vec3f extends vec3, Swizzle3<vec2f, vec3f> {\n /** use to distinguish between vectors of the same size on the type level */\n kind: 'vec3f';\n}\nexport interface vec3i extends vec3, Swizzle3<vec2i, vec3i> {\n /** use to distinguish between vectors of the same size on the type level */\n kind: 'vec3i';\n}\nexport interface vec3u extends vec3, Swizzle3<vec2u, vec3u> {\n /** use to distinguish between vectors of the same size on the type level */\n kind: 'vec3u';\n}\n\nexport interface vec4f extends vec4, Swizzle4<vec2f, vec3f, vec4f> {\n /** use to distinguish between vectors of the same size on the type level */\n kind: 'vec4f';\n}\nexport interface vec4i extends vec4, Swizzle4<vec2i, vec3i, vec4i> {\n /** use to distinguish between vectors of the same size on the type level */\n kind: 'vec4i';\n}\nexport interface vec4u extends vec4, Swizzle4<vec2u, vec3u, vec4u> {\n /** use to distinguish between vectors of the same size on the type level */\n kind: 'vec4u';\n}\n\nexport type Vec2f = TgpuData<vec2f> &\n ((x: number, y: number) => vec2f) &\n ((xy: number) => vec2f) &\n (() => vec2f);\n\nexport const vec2f = new VecSchemaImpl({\n unitType: f32,\n byteAlignment: 8,\n length: 2,\n label: 'vec2f',\n make: (x: number, y: number) => new vec2fImpl(x, y),\n makeFromScalar: (x) => new vec2fImpl(x, x),\n}) as unknown as Vec2f;\n\nexport type Vec2i = TgpuData<vec2i> &\n ((x: number, y: number) => vec2i) &\n ((xy: number) => vec2i) &\n (() => vec2i);\n\nexport const vec2i = new VecSchemaImpl({\n unitType: i32,\n byteAlignment: 8,\n length: 2,\n label: 'vec2i',\n make: (x: number, y: number) => new vec2iImpl(x, y),\n makeFromScalar: (x) => new vec2iImpl(x, x),\n}) as unknown as Vec2i;\n\nexport type Vec2u = TgpuData<vec2u> &\n ((x: number, y: number) => vec2u) &\n ((xy: number) => vec2u) &\n (() => vec2u);\n\nexport const vec2u = new VecSchemaImpl({\n unitType: u32,\n byteAlignment: 8,\n length: 2,\n label: 'vec2u',\n make: (x: number, y: number) => new vec2uImpl(x, y),\n makeFromScalar: (x) => new vec2uImpl(x, x),\n}) as unknown as Vec2u;\n\nexport type Vec3f = TgpuData<vec3f> &\n ((x: number, y: number, z: number) => vec3f) &\n ((xyz: number) => vec3f) &\n (() => vec3f);\n\nexport const vec3f = new VecSchemaImpl({\n unitType: f32,\n byteAlignment: 16,\n length: 3,\n label: 'vec3f',\n make: (x, y, z) => new vec3fImpl(x, y, z),\n makeFromScalar: (x) => new vec3fImpl(x, x, x),\n}) as unknown as Vec3f;\n\nexport type Vec3i = TgpuData<vec3i> &\n ((x: number, y: number, z: number) => vec3i) &\n ((xyz: number) => vec3i) &\n (() => vec3i);\n\nexport const vec3i = new VecSchemaImpl({\n unitType: i32,\n byteAlignment: 16,\n length: 3,\n label: 'vec3i',\n make: (x, y, z) => new vec3iImpl(x, y, z),\n makeFromScalar: (x) => new vec3iImpl(x, x, x),\n}) as unknown as Vec3i;\n\nexport type Vec3u = TgpuData<vec3u> &\n ((x: number, y: number, z: number) => vec3u) &\n ((xyz: number) => vec3u) &\n (() => vec3u);\n\nexport const vec3u = new VecSchemaImpl({\n unitType: u32,\n byteAlignment: 16,\n length: 3,\n label: 'vec3u',\n make: (x, y, z) => new vec3uImpl(x, y, z),\n makeFromScalar: (x) => new vec3uImpl(x, x, x),\n}) as unknown as Vec3u;\n\nexport type Vec4f = TgpuData<vec4f> &\n ((x: number, y: number, z: number, w: number) => vec4f) &\n ((xyzw: number) => vec4f) &\n (() => vec4f);\n\nexport const vec4f = new VecSchemaImpl({\n unitType: f32,\n byteAlignment: 16,\n length: 4,\n label: 'vec4f',\n make: (x, y, z, w) => new vec4fImpl(x, y, z, w),\n makeFromScalar: (x) => new vec4fImpl(x, x, x, x),\n}) as unknown as Vec4f;\n\nexport type Vec4i = TgpuData<vec4i> &\n ((x: number, y: number, z: number, w: number) => vec4i) &\n ((xyzw: number) => vec4i) &\n (() => vec4i);\n\nexport const vec4i = new VecSchemaImpl({\n unitType: i32,\n byteAlignment: 16,\n length: 4,\n label: 'vec4i',\n make: (x, y, z, w) => new vec4iImpl(x, y, z, w),\n makeFromScalar: (x) => new vec4iImpl(x, x, x, x),\n}) as unknown as Vec4i;\n\nexport type Vec4u = TgpuData<vec4u> &\n ((x: number, y: number, z: number, w: number) => vec4u) &\n ((xyzw: number) => vec4u) &\n (() => vec4u);\n\nexport const vec4u = new VecSchemaImpl({\n unitType: u32,\n byteAlignment: 16,\n length: 4,\n label: 'vec4u',\n make: (x, y, z, w) => new vec4uImpl(x, y, z, w),\n makeFromScalar: (x) => new vec4uImpl(x, x, x, x),\n}) as unknown as Vec4u;\n","export abstract class CallableImpl<\n TArgs extends [...unknown[]],\n TReturn,\n> extends Function {\n _bound: CallableImpl<TArgs, TReturn>;\n\n constructor() {\n // We create a new Function object using `super`, with a `this` reference\n // to itself (the Function object) provided by binding it to `this`,\n // then returning the bound Function object (which is a wrapper around the\n // the original `this`/Function object). We then also have to store\n // a reference to the bound Function object, as `_bound` on the unbound `this`,\n // so the bound function has access to the new bound object.\n // Pro: Works well, doesn't rely on deprecated features.\n // Con: A little convoluted, and requires wrapping `this` in a bound object.\n\n super('...args', 'return this._bound._call(...args)');\n // Or without the spread/rest operator:\n // super('return this._bound._call.apply(this._bound, arguments)')\n this._bound = this.bind(this);\n\n // biome-ignore lint/correctness/noConstructorReturn: <quirks of creating a custom callable>\n return this._bound;\n }\n\n abstract _call(...args: TArgs): TReturn;\n}\n\nexport type Callable<TArgs extends [...unknown[]], TReturn> = (\n ...args: TArgs\n) => TReturn;\n\nexport type AsCallable<T, TArgs extends [...unknown[]], TReturn> = T &\n Callable<TArgs, TReturn>;\n","import type { IMeasurer, ISerialInput, ISerialOutput } from 'typed-binary';\n\n/**\n * @param io the IO to align\n * @param baseAlignment must be power of 2\n */\nfunction alignIO(\n io: ISerialInput | ISerialOutput | IMeasurer,\n baseAlignment: number,\n) {\n const currentPos = 'size' in io ? io.size : io.currentByteOffset;\n\n const bitMask = baseAlignment - 1;\n const offset = currentPos & bitMask;\n\n if ('skipBytes' in io) {\n io.skipBytes((baseAlignment - offset) & bitMask);\n } else {\n io.add((baseAlignment - offset) & bitMask);\n }\n}\n\nexport default alignIO;\n","/**\n * @param value\n * @param modulo has to be power of 2\n */\nexport const roundUp = (value: number, modulo: number) => {\n const bitMask = modulo - 1;\n const invBitMask = ~bitMask;\n return (value & bitMask) === 0 ? value : (value & invBitMask) + modulo;\n};\n"],"mappings":"0uBA+CO,SAASA,EAAaC,EAAyC,CACpE,MACE,CAAC,CAACA,IACD,OAAOA,GAAU,UAAY,OAAOA,GAAU,aAC/C,YAAaA,CAEjB,CAkNO,SAASC,EAAYC,EAAoC,CAC9D,MACE,CAAC,CAACA,GACF,OAAOA,GAAU,UACjB,mBAAoBA,GACpB,aAAcA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EAAGA,CAAC,CAC9C,CAAC,EAOYkC,GAAQ,IAAI7D,EAAc,CACrC,SAAU0D,EACV,cAAe,GACf,OAAQ,EACR,MAAO,QACP,KAAM,CAAC/B,EAAGC,EAAGS,IAAM,IAAIK,EAAUf,EAAGC,EAAGS,CAAC,EACxC,eAAiBV,GAAM,IAAIe,EAAUf,EAAGA,EAAGA,CAAC,CAC9C,CAAC,EAOYmC,GAAQ,IAAI9D,EAAc,CACrC,SAAUsD,EACV,cAAe,GACf,OAAQ,EACR,MAAO,QACP,KAAM,CAAC3B,EAAGC,EAAGS,EAAGS,IAAM,IAAIC,EAAUpB,EAAGC,EAAGS,EAAGS,CAAC,EAC9C,eAAiBnB,GAAM,IAAIoB,EAAUpB,EAAGA,EAAGA,EAAGA,CAAC,CACjD,CAAC,EAOYoC,GAAQ,IAAI/D,EAAc,CACrC,SAAUwD,EACV,cAAe,GACf,OAAQ,EACR,MAAO,QACP,KAAM,CAAC7B,EAAGC,EAAGS,EAAGS,IAAM,IAAIG,EAAUtB,EAAGC,EAAGS,EAAGS,CAAC,EAC9C,eAAiBnB,GAAM,IAAIsB,EAAUtB,EAAGA,EAAGA,EAAGA,CAAC,CACjD,CAAC,EAOYqC,GAAQ,IAAIhE,EAAc,CACrC,SAAU0D,EACV,cAAe,GACf,OAAQ,EACR,MAAO,QACP,KAAM,CAAC/B,EAAGC,EAAGS,EAAGS,IAAM,IAAIK,EAAUxB,EAAGC,EAAGS,EAAGS,CAAC,EAC9C,eAAiBnB,GAAM,IAAIwB,EAAUxB,EAAGA,EAAGA,EAAGA,CAAC,CACjD,CAAC,EGnhBM,IAAMsC,GAAU,CAACC,EAAeC,IAAmB,CACxD,IAAMC,EAAUD,EAAS,EACnBE,EAAa,CAACD,EACpB,OAAQF,EAAQE,GAA0BF,EAAQG,GAAcF,EAA/BD,CACnC","names":["isResolvable","value","isGPUBuffer","value","RecursiveDataTypeError","_RecursiveDataTypeError","Measurer","f32","i32","u32","CallableImpl","__publicField","alignIO","io","baseAlignment","currentPos","bitMask","offset","alignIO_default","VecSchemaImpl","CallableImpl","unitType","byteAlignment","length","label","make","makeFromScalar","__publicField","args","_a","values","ctx","RecursiveDataTypeError","output","value","alignIO_default","element","input","_","_value","measurer","Measurer","reference","prop","Swizzle2Impl","vec2Impl","x","y","vec2fImpl","_vec2fImpl","vec2iImpl","_vec2iImpl","vec2uImpl","_vec2uImpl","Swizzle3Impl","vec3Impl","z","vec3fImpl","_vec3fImpl","vec3iImpl","_vec3iImpl","vec3uImpl","_vec3uImpl","Swizzle4Impl","vec4Impl","w","vec4fImpl","_vec4fImpl","vec4iImpl","_vec4iImpl","vec4uImpl","_vec4uImpl","vec2f","f32","vec2i","i32","vec2u","u32","vec3f","vec3i","vec3u","vec4f","vec4i","vec4u","roundUp","value","modulo","bitMask","invBitMask"]}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var F=Object.defineProperty;var z=(e,n)=>(n=Symbol[e])?n:Symbol.for("Symbol."+e);var B=(e,n,t)=>n in e?F(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var M=(e,n)=>{for(var t in n)F(e,t,{get:n[t],enumerable:!0})};var a=(e,n,t)=>(B(e,typeof n!="symbol"?n+"":n,t),t);var O=function(e,n){this[0]=e,this[1]=n};var j=e=>{var n=e[z("asyncIterator")],t=!1,r,u={};return n==null?(n=e[z("iterator")](),r=i=>u[i]=s=>n[i](s)):(n=n.call(e),r=i=>u[i]=s=>{if(t){if(t=!1,i==="throw")throw s;return s}return t=!0,{done:!1,value:new O(new Promise(R=>{var I=n[i](s);if(!(I instanceof Object))throw TypeError("Object expected");R(I)}),1)}}),u[z("iterator")]=()=>u,r("next"),"throw"in n?r("throw"):u.throw=i=>{throw i},"return"in n&&r("return"),u};function C(e){return!!e&&(typeof e=="object"||typeof e=="function")&&"resolve"in e}function W(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}var g=class e extends Error{constructor(){super("Recursive types are not supported in WGSL"),Object.setPrototypeOf(this,e.prototype)}};var _typedbinary = require('typed-binary');var v=class extends Function{constructor(){super("...args","return this._bound._call(...args)");a(this,"_bound");return this._bound=this.bind(this),this._bound}};function U(e,n){let t="size"in e?e.size:e.currentByteOffset,r=n-1,u=t&r;"skipBytes"in e?e.skipBytes(n-u&r):e.add(n-u&r)}var f=U;var o=class extends v{constructor({unitType:t,byteAlignment:r,length:u,label:i,make:s,makeFromScalar:R}){super();a(this,"__unwrapped");a(this,"unitType");a(this,"byteAlignment");a(this,"length");a(this,"size");a(this,"label");a(this,"make");a(this,"makeFromScalar");this.unitType=t,this.byteAlignment=r,this.length=u,this.size=u*4,this.label=i,this.make=s,this.makeFromScalar=R}get expressionCode(){return this.label}_call(...t){var u;let r=t;if(r.length<=1)return this.makeFromScalar((u=r[0])!=null?u:0);if(r.length===this.length)return this.make(...r);throw new Error(`'${this.label}' constructor called with invalid number of arguments.`)}resolveReferences(t){throw new g}write(t,r){f(t,this.byteAlignment);for(let u of r)this.unitType.write(t,u)}read(t){return f(t,this.byteAlignment),this.make(...Array.from({length:this.length}).map(r=>this.unitType.read(t)))}measure(t,r=new _typedbinary.Measurer){return f(r,this.byteAlignment),r.add(this.size)}seekProperty(t,r){throw new Error("Method not implemented.")}resolve(){return this.label}},w=class{get xx(){return this.make2(this.x,this.x)}get xy(){return this.make2(this.x,this.y)}get yx(){return this.make2(this.y,this.x)}get yy(){return this.make2(this.y,this.y)}},m=class extends w{constructor(t,r){super();this.x=t;this.y=r}*[Symbol.iterator](){yield this.x,yield this.y}},c=class e extends m{constructor(){super(...arguments);a(this,"kind","vec2f")}make2(t,r){return new e(t,r)}},p=class e extends m{constructor(){super(...arguments);a(this,"kind","vec2i")}make2(t,r){return new e(t,r)}},l=class e extends m{constructor(){super(...arguments);a(this,"kind","vec2u")}make2(t,r){return new e(t,r)}},k=class extends w{},T=class extends k{constructor(t,r,u){super();this.x=t;this.y=r;this.z=u}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},y=class e extends T{constructor(){super(...arguments);a(this,"kind","vec3f")}make2(t,r){return new c(t,r)}make3(t,r,u){return new e(t,r,u)}},b=class e extends T{constructor(){super(...arguments);a(this,"kind","vec3i")}make2(t,r){return new p(t,r)}make3(t,r,u){return new e(t,r,u)}},d=class e extends T{constructor(){super(...arguments);a(this,"kind","vec3u")}make2(t,r){return new l(t,r)}make3(t,r,u){return new e(t,r,u)}},A=class extends k{},x=class extends A{constructor(t,r,u,i){super();this.x=t;this.y=r;this.z=u;this.w=i}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},h=class e extends x{constructor(){super(...arguments);a(this,"kind","vec4f")}make2(t,r){return new c(t,r)}make3(t,r,u){return new y(t,r,u)}make4(t,r,u,i){return new e(t,r,u,i)}},S=class e extends x{constructor(){super(...arguments);a(this,"kind","vec4i")}make2(t,r){return new p(t,r)}make3(t,r,u){return new b(t,r,u)}make4(t,r,u,i){return new e(t,r,u,i)}},_=class e extends x{constructor(){super(...arguments);a(this,"kind","vec4u")}make2(t,r){return new l(t,r)}make3(t,r,u){return new d(t,r,u)}make4(t,r,u,i){return new e(t,r,u,i)}},Y= exports.j =new o({unitType:_typedbinary.f32,byteAlignment:8,length:2,label:"vec2f",make:(e,n)=>new c(e,n),makeFromScalar:e=>new c(e,e)}),Z= exports.k =new o({unitType:_typedbinary.i32,byteAlignment:8,length:2,label:"vec2i",make:(e,n)=>new p(e,n),makeFromScalar:e=>new p(e,e)}),ee= exports.l =new o({unitType:_typedbinary.u32,byteAlignment:8,length:2,label:"vec2u",make:(e,n)=>new l(e,n),makeFromScalar:e=>new l(e,e)}),te= exports.m =new o({unitType:_typedbinary.f32,byteAlignment:16,length:3,label:"vec3f",make:(e,n,t)=>new y(e,n,t),makeFromScalar:e=>new y(e,e,e)}),re= exports.n =new o({unitType:_typedbinary.i32,byteAlignment:16,length:3,label:"vec3i",make:(e,n,t)=>new b(e,n,t),makeFromScalar:e=>new b(e,e,e)}),ne= exports.o =new o({unitType:_typedbinary.u32,byteAlignment:16,length:3,label:"vec3u",make:(e,n,t)=>new d(e,n,t),makeFromScalar:e=>new d(e,e,e)}),ue= exports.p =new o({unitType:_typedbinary.f32,byteAlignment:16,length:4,label:"vec4f",make:(e,n,t,r)=>new h(e,n,t,r),makeFromScalar:e=>new h(e,e,e,e)}),ae= exports.q =new o({unitType:_typedbinary.i32,byteAlignment:16,length:4,label:"vec4i",make:(e,n,t,r)=>new S(e,n,t,r),makeFromScalar:e=>new S(e,e,e,e)}),ie= exports.r =new o({unitType:_typedbinary.u32,byteAlignment:16,length:4,label:"vec4u",make:(e,n,t,r)=>new _(e,n,t,r),makeFromScalar:e=>new _(e,e,e,e)});var ce=(e,n)=>{let t=n-1,r=~t;return e&t?(e&r)+n:e};exports.a = M; exports.b = a; exports.c = j; exports.d = C; exports.e = W; exports.f = ce; exports.g = g; exports.h = v; exports.i = f; exports.j = Y; exports.k = Z; exports.l = ee; exports.m = te; exports.n = re; exports.o = ne; exports.p = ue; exports.q = ae; exports.r = ie;
2
- //# sourceMappingURL=chunk-T3YCU4G4.cjs.map