typegpu 0.5.6 → 0.5.7

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.
@@ -0,0 +1,3042 @@
1
+ import * as tinyest from 'tinyest';
2
+ import { ArgNames, Block } from 'tinyest';
3
+
4
+ /**
5
+ * Can be assigned a name. Not to be confused with
6
+ * being able to HAVE a name.
7
+ * The `$name` function should use `setName` to rename the object itself,
8
+ * or rename the object `$getNameForward` symbol points to instead if applicable.
9
+ */
10
+ interface TgpuNamable {
11
+ $name(label: string): this;
12
+ }
13
+
14
+ declare const $repr: unique symbol;
15
+ /**
16
+ * Extracts the inferred representation of a resource.
17
+ * For inferring types as seen by the GPU, see {@link InferGPU}
18
+ *
19
+ * @example
20
+ * type A = Infer<F32> // => number
21
+ * type B = Infer<WgslArray<F32>> // => number[]
22
+ * type C = Infer<Atomic<U32>> // => number
23
+ */
24
+ type Infer<T> = T extends {
25
+ readonly [$repr]: infer TRepr;
26
+ } ? TRepr : T;
27
+ /**
28
+ * Extracts a sparse/partial inferred representation of a resource.
29
+ * Used by the `buffer.writePartial` API.
30
+ *
31
+ * @example
32
+ * type A = InferPartial<F32> // => number | undefined
33
+ * type B = InferPartial<WgslStruct<{ a: F32 }>> // => { a?: number | undefined }
34
+ * type C = InferPartial<WgslArray<F32>> // => { idx: number; value: number | undefined }[] | undefined
35
+ */
36
+ type InferPartial<T> = T extends {
37
+ readonly '~reprPartial': infer TRepr;
38
+ } ? TRepr : T extends {
39
+ readonly [$repr]: infer TRepr;
40
+ } ? TRepr | undefined : T;
41
+ /**
42
+ * Extracts the inferred representation of a resource (as seen by the GPU).
43
+ *
44
+ * @example
45
+ * type A = InferGPU<F32> // => number
46
+ * type B = InferGPU<WgslArray<F32>> // => number[]
47
+ * type C = Infer<Atomic<U32>> // => atomicU32
48
+ */
49
+ type InferGPU<T> = T extends {
50
+ readonly '~gpuRepr': infer TRepr;
51
+ } ? TRepr : Infer<T>;
52
+ type InferRecord<T extends Record<string | number | symbol, unknown>> = {
53
+ [Key in keyof T]: Infer<T[Key]>;
54
+ };
55
+ type InferPartialRecord<T extends Record<string | number | symbol, unknown>> = {
56
+ [Key in keyof T]?: InferPartial<T[Key]>;
57
+ };
58
+ type InferGPURecord<T extends Record<string | number | symbol, unknown>> = {
59
+ [Key in keyof T]: InferGPU<T[Key]>;
60
+ };
61
+ type MemIdentity<T> = T extends {
62
+ readonly '~memIdent': infer TMemIdent;
63
+ } ? TMemIdent : T;
64
+ type MemIdentityRecord<T extends Record<string | number | symbol, unknown>> = {
65
+ [Key in keyof T]: MemIdentity<T[Key]>;
66
+ };
67
+
68
+ declare const $internal: unique symbol;
69
+
70
+ type Default<T, TDefault> = unknown extends T ? TDefault : T extends undefined ? TDefault : T;
71
+ type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
72
+ type Prettify<T> = {
73
+ [K in keyof T]: T[K];
74
+ } & {};
75
+ /**
76
+ * Removes properties from record type that extend `Prop`
77
+ */
78
+ type OmitProps<T extends Record<string, unknown>, Prop> = Pick<T, {
79
+ [Key in keyof T]: T[Key] extends Prop ? never : Key;
80
+ }[keyof T]>;
81
+ /**
82
+ * The opposite of Readonly<T>
83
+ */
84
+ type Mutable<T> = {
85
+ -readonly [P in keyof T]: T[P];
86
+ };
87
+
88
+ type DecoratedLocation<T extends BaseData> = Decorated<T, Location<number>[]>;
89
+ interface NumberArrayView {
90
+ readonly length: number;
91
+ [n: number]: number;
92
+ [Symbol.iterator]: () => Iterator<number>;
93
+ }
94
+ interface BaseData {
95
+ readonly [$internal]: true;
96
+ readonly type: string;
97
+ readonly [$repr]: unknown;
98
+ }
99
+ /**
100
+ * Represents a 64-bit integer.
101
+ */
102
+ interface AbstractInt {
103
+ readonly [$internal]: true;
104
+ readonly type: 'abstractInt';
105
+ readonly [$repr]: number;
106
+ }
107
+ /**
108
+ * Represents a 64-bit IEEE 754 floating point number.
109
+ */
110
+ interface AbstractFloat {
111
+ readonly [$internal]: true;
112
+ readonly type: 'abstractFloat';
113
+ readonly [$repr]: number;
114
+ }
115
+ interface Void {
116
+ readonly [$internal]: true;
117
+ readonly type: 'void';
118
+ readonly [$repr]: void;
119
+ }
120
+ declare const Void: Void;
121
+ interface Swizzle2<T2, T3, T4> {
122
+ readonly xx: T2;
123
+ readonly xy: T2;
124
+ readonly yx: T2;
125
+ readonly yy: T2;
126
+ readonly xxx: T3;
127
+ readonly xxy: T3;
128
+ readonly xyx: T3;
129
+ readonly xyy: T3;
130
+ readonly yxx: T3;
131
+ readonly yxy: T3;
132
+ readonly yyx: T3;
133
+ readonly yyy: T3;
134
+ readonly xxxx: T4;
135
+ readonly xxxy: T4;
136
+ readonly xxyx: T4;
137
+ readonly xxyy: T4;
138
+ readonly xyxx: T4;
139
+ readonly xyxy: T4;
140
+ readonly xyyx: T4;
141
+ readonly xyyy: T4;
142
+ readonly yxxx: T4;
143
+ readonly yxxy: T4;
144
+ readonly yxyx: T4;
145
+ readonly yxyy: T4;
146
+ readonly yyxx: T4;
147
+ readonly yyxy: T4;
148
+ readonly yyyx: T4;
149
+ readonly yyyy: T4;
150
+ }
151
+ interface Swizzle3<T2, T3, T4> extends Swizzle2<T2, T3, T4> {
152
+ readonly xz: T2;
153
+ readonly yz: T2;
154
+ readonly zx: T2;
155
+ readonly zy: T2;
156
+ readonly zz: T2;
157
+ readonly xxz: T3;
158
+ readonly xyz: T3;
159
+ readonly xzx: T3;
160
+ readonly xzy: T3;
161
+ readonly xzz: T3;
162
+ readonly yxz: T3;
163
+ readonly yyz: T3;
164
+ readonly yzx: T3;
165
+ readonly yzy: T3;
166
+ readonly yzz: T3;
167
+ readonly zxx: T3;
168
+ readonly zxy: T3;
169
+ readonly zxz: T3;
170
+ readonly zyx: T3;
171
+ readonly zyy: T3;
172
+ readonly zyz: T3;
173
+ readonly zzx: T3;
174
+ readonly zzy: T3;
175
+ readonly zzz: T3;
176
+ readonly xxxz: T4;
177
+ readonly xxyz: T4;
178
+ readonly xxzx: T4;
179
+ readonly xxzy: T4;
180
+ readonly xxzz: T4;
181
+ readonly xyxz: T4;
182
+ readonly xyyz: T4;
183
+ readonly xyzx: T4;
184
+ readonly xyzy: T4;
185
+ readonly xyzz: T4;
186
+ readonly xzxx: T4;
187
+ readonly xzxy: T4;
188
+ readonly xzxz: T4;
189
+ readonly xzyx: T4;
190
+ readonly xzyy: T4;
191
+ readonly xzyz: T4;
192
+ readonly xzzx: T4;
193
+ readonly xzzy: T4;
194
+ readonly xzzz: T4;
195
+ readonly yxxz: T4;
196
+ readonly yxyz: T4;
197
+ readonly yxzx: T4;
198
+ readonly yxzy: T4;
199
+ readonly yxzz: T4;
200
+ readonly yyxz: T4;
201
+ readonly yyyz: T4;
202
+ readonly yyzx: T4;
203
+ readonly yyzy: T4;
204
+ readonly yyzz: T4;
205
+ readonly yzxx: T4;
206
+ readonly yzxy: T4;
207
+ readonly yzxz: T4;
208
+ readonly yzyx: T4;
209
+ readonly yzyy: T4;
210
+ readonly yzyz: T4;
211
+ readonly yzzx: T4;
212
+ readonly yzzy: T4;
213
+ readonly yzzz: T4;
214
+ readonly zxxx: T4;
215
+ readonly zxxy: T4;
216
+ readonly zxxz: T4;
217
+ readonly zxyx: T4;
218
+ readonly zxyy: T4;
219
+ readonly zxyz: T4;
220
+ readonly zxzx: T4;
221
+ readonly zxzy: T4;
222
+ readonly zxzz: T4;
223
+ readonly zyxx: T4;
224
+ readonly zyxy: T4;
225
+ readonly zyxz: T4;
226
+ readonly zyyx: T4;
227
+ readonly zyyy: T4;
228
+ readonly zyyz: T4;
229
+ readonly zyzx: T4;
230
+ readonly zyzy: T4;
231
+ readonly zyzz: T4;
232
+ readonly zzxx: T4;
233
+ readonly zzxy: T4;
234
+ readonly zzxz: T4;
235
+ readonly zzyx: T4;
236
+ readonly zzyy: T4;
237
+ readonly zzyz: T4;
238
+ readonly zzzx: T4;
239
+ readonly zzzy: T4;
240
+ readonly zzzz: T4;
241
+ }
242
+ interface Swizzle4<T2, T3, T4> extends Swizzle3<T2, T3, T4> {
243
+ readonly yw: T2;
244
+ readonly zw: T2;
245
+ readonly wx: T2;
246
+ readonly wy: T2;
247
+ readonly wz: T2;
248
+ readonly ww: T2;
249
+ readonly xxw: T3;
250
+ readonly xyw: T3;
251
+ readonly xzw: T3;
252
+ readonly xwx: T3;
253
+ readonly xwy: T3;
254
+ readonly xwz: T3;
255
+ readonly xww: T3;
256
+ readonly yxw: T3;
257
+ readonly yyw: T3;
258
+ readonly yzw: T3;
259
+ readonly ywx: T3;
260
+ readonly ywy: T3;
261
+ readonly ywz: T3;
262
+ readonly yww: T3;
263
+ readonly zxw: T3;
264
+ readonly zyw: T3;
265
+ readonly zzw: T3;
266
+ readonly zwx: T3;
267
+ readonly zwy: T3;
268
+ readonly zwz: T3;
269
+ readonly zww: T3;
270
+ readonly wxx: T3;
271
+ readonly wxz: T3;
272
+ readonly wxy: T3;
273
+ readonly wyy: T3;
274
+ readonly wyz: T3;
275
+ readonly wzz: T3;
276
+ readonly wwx: T3;
277
+ readonly wwy: T3;
278
+ readonly wwz: T3;
279
+ readonly www: T3;
280
+ readonly xxxw: T4;
281
+ readonly xxyw: T4;
282
+ readonly xxzw: T4;
283
+ readonly xxwx: T4;
284
+ readonly xxwy: T4;
285
+ readonly xxwz: T4;
286
+ readonly xxww: T4;
287
+ readonly xyxw: T4;
288
+ readonly xyyw: T4;
289
+ readonly xyzw: T4;
290
+ readonly xywx: T4;
291
+ readonly xywy: T4;
292
+ readonly xywz: T4;
293
+ readonly xyww: T4;
294
+ readonly xzxw: T4;
295
+ readonly xzyw: T4;
296
+ readonly xzzw: T4;
297
+ readonly xzwx: T4;
298
+ readonly xzwy: T4;
299
+ readonly xzwz: T4;
300
+ readonly xzww: T4;
301
+ readonly xwxx: T4;
302
+ readonly xwxy: T4;
303
+ readonly xwxz: T4;
304
+ readonly xwyy: T4;
305
+ readonly xwyz: T4;
306
+ readonly xwzz: T4;
307
+ readonly xwwx: T4;
308
+ readonly xwwy: T4;
309
+ readonly xwwz: T4;
310
+ readonly xwww: T4;
311
+ readonly yxxw: T4;
312
+ readonly yxyw: T4;
313
+ readonly yxzw: T4;
314
+ readonly yxwx: T4;
315
+ readonly yxwy: T4;
316
+ readonly yxwz: T4;
317
+ readonly yxww: T4;
318
+ readonly yyxw: T4;
319
+ readonly yyyw: T4;
320
+ readonly yyzw: T4;
321
+ readonly yywx: T4;
322
+ readonly yywy: T4;
323
+ readonly yywz: T4;
324
+ readonly yyww: T4;
325
+ readonly yzxw: T4;
326
+ readonly yzyw: T4;
327
+ readonly yzzw: T4;
328
+ readonly yzwx: T4;
329
+ readonly yzwy: T4;
330
+ readonly yzwz: T4;
331
+ readonly yzww: T4;
332
+ readonly ywxx: T4;
333
+ readonly ywxy: T4;
334
+ readonly ywxz: T4;
335
+ readonly ywxw: T4;
336
+ readonly ywyy: T4;
337
+ readonly ywyz: T4;
338
+ readonly ywzz: T4;
339
+ readonly ywwx: T4;
340
+ readonly ywwy: T4;
341
+ readonly ywwz: T4;
342
+ readonly ywww: T4;
343
+ readonly zxxw: T4;
344
+ readonly zxyw: T4;
345
+ readonly zxzw: T4;
346
+ readonly zxwx: T4;
347
+ readonly zxwy: T4;
348
+ readonly zxwz: T4;
349
+ readonly zxww: T4;
350
+ readonly zyxw: T4;
351
+ readonly zyyw: T4;
352
+ readonly zyzw: T4;
353
+ readonly zywx: T4;
354
+ readonly zywy: T4;
355
+ readonly zywz: T4;
356
+ readonly zyww: T4;
357
+ readonly zzxw: T4;
358
+ readonly zzyw: T4;
359
+ readonly zzzw: T4;
360
+ readonly zzwx: T4;
361
+ readonly zzwy: T4;
362
+ readonly zzwz: T4;
363
+ readonly zzww: T4;
364
+ readonly zwxx: T4;
365
+ readonly zwxy: T4;
366
+ readonly zwxz: T4;
367
+ readonly zwxw: T4;
368
+ readonly zwyy: T4;
369
+ readonly zwyz: T4;
370
+ readonly zwzz: T4;
371
+ readonly zwwx: T4;
372
+ readonly zwwy: T4;
373
+ readonly zwwz: T4;
374
+ readonly zwww: T4;
375
+ readonly wxxx: T4;
376
+ readonly wxxy: T4;
377
+ readonly wxxz: T4;
378
+ readonly wxxw: T4;
379
+ readonly wxyx: T4;
380
+ readonly wxyy: T4;
381
+ readonly wxyz: T4;
382
+ readonly wxyw: T4;
383
+ readonly wxzx: T4;
384
+ readonly wxzy: T4;
385
+ readonly wxzz: T4;
386
+ readonly wxzw: T4;
387
+ readonly wxwx: T4;
388
+ readonly wxwy: T4;
389
+ readonly wxwz: T4;
390
+ readonly wxww: T4;
391
+ readonly wyxx: T4;
392
+ readonly wyxy: T4;
393
+ readonly wyxz: T4;
394
+ readonly wyxw: T4;
395
+ readonly wyyy: T4;
396
+ readonly wyyz: T4;
397
+ readonly wyzw: T4;
398
+ readonly wywx: T4;
399
+ readonly wywy: T4;
400
+ readonly wywz: T4;
401
+ readonly wyww: T4;
402
+ readonly wzxx: T4;
403
+ readonly wzxy: T4;
404
+ readonly wzxz: T4;
405
+ readonly wzxw: T4;
406
+ readonly wzyy: T4;
407
+ readonly wzyz: T4;
408
+ readonly wzzy: T4;
409
+ readonly wzzw: T4;
410
+ readonly wzwx: T4;
411
+ readonly wzwy: T4;
412
+ readonly wzwz: T4;
413
+ readonly wzww: T4;
414
+ readonly wwxx: T4;
415
+ readonly wwxy: T4;
416
+ readonly wwxz: T4;
417
+ readonly wwxw: T4;
418
+ readonly wwyy: T4;
419
+ readonly wwyz: T4;
420
+ readonly wwzz: T4;
421
+ readonly wwwx: T4;
422
+ readonly wwwy: T4;
423
+ readonly wwwz: T4;
424
+ readonly wwww: T4;
425
+ }
426
+ type Tuple2<S> = [S, S];
427
+ type Tuple3<S> = [S, S, S];
428
+ type Tuple4<S> = [S, S, S, S];
429
+ /**
430
+ * Interface representing its WGSL vector type counterpart: vec2f or vec2<f32>.
431
+ * A vector with 2 elements of type f32
432
+ */
433
+ interface v2f extends Tuple2<number>, Swizzle2<v2f, v3f, v4f> {
434
+ readonly [$internal]: true;
435
+ /** use to distinguish between vectors of the same size on the type level */
436
+ readonly kind: 'vec2f';
437
+ x: number;
438
+ y: number;
439
+ }
440
+ /**
441
+ * Interface representing its WGSL vector type counterpart: vec2h or vec2<f16>.
442
+ * A vector with 2 elements of type f16
443
+ */
444
+ interface v2h extends Tuple2<number>, Swizzle2<v2h, v3h, v4h> {
445
+ readonly [$internal]: true;
446
+ /** use to distinguish between vectors of the same size on the type level */
447
+ readonly kind: 'vec2h';
448
+ x: number;
449
+ y: number;
450
+ }
451
+ /**
452
+ * Interface representing its WGSL vector type counterpart: vec2i or vec2<i32>.
453
+ * A vector with 2 elements of type i32
454
+ */
455
+ interface v2i extends Tuple2<number>, Swizzle2<v2i, v3i, v4i> {
456
+ readonly [$internal]: true;
457
+ /** use to distinguish between vectors of the same size on the type level */
458
+ readonly kind: 'vec2i';
459
+ x: number;
460
+ y: number;
461
+ }
462
+ /**
463
+ * Interface representing its WGSL vector type counterpart: vec2u or vec2<u32>.
464
+ * A vector with 2 elements of type u32
465
+ */
466
+ interface v2u extends Tuple2<number>, Swizzle2<v2u, v3u, v4u> {
467
+ readonly [$internal]: true;
468
+ /** use to distinguish between vectors of the same size on the type level */
469
+ readonly kind: 'vec2u';
470
+ x: number;
471
+ y: number;
472
+ }
473
+ /**
474
+ * Interface representing its WGSL vector type counterpart: `vec2<bool>`.
475
+ * A vector with 2 elements of type `bool`
476
+ */
477
+ interface v2b extends Tuple2<boolean>, Swizzle2<v2b, v3b, v4b> {
478
+ readonly [$internal]: true;
479
+ /** use to distinguish between vectors of the same size on the type level */
480
+ readonly kind: 'vec2<bool>';
481
+ x: boolean;
482
+ y: boolean;
483
+ }
484
+ /**
485
+ * Interface representing its WGSL vector type counterpart: vec3f or vec3<f32>.
486
+ * A vector with 3 elements of type f32
487
+ */
488
+ interface v3f extends Tuple3<number>, Swizzle3<v2f, v3f, v4f> {
489
+ readonly [$internal]: true;
490
+ /** use to distinguish between vectors of the same size on the type level */
491
+ readonly kind: 'vec3f';
492
+ x: number;
493
+ y: number;
494
+ z: number;
495
+ }
496
+ /**
497
+ * Interface representing its WGSL vector type counterpart: vec3h or vec3<f16>.
498
+ * A vector with 3 elements of type f16
499
+ */
500
+ interface v3h extends Tuple3<number>, Swizzle3<v2h, v3h, v4h> {
501
+ readonly [$internal]: true;
502
+ /** use to distinguish between vectors of the same size on the type level */
503
+ readonly kind: 'vec3h';
504
+ x: number;
505
+ y: number;
506
+ z: number;
507
+ }
508
+ /**
509
+ * Interface representing its WGSL vector type counterpart: vec3i or vec3<i32>.
510
+ * A vector with 3 elements of type i32
511
+ */
512
+ interface v3i extends Tuple3<number>, Swizzle3<v2i, v3i, v4i> {
513
+ readonly [$internal]: true;
514
+ /** use to distinguish between vectors of the same size on the type level */
515
+ readonly kind: 'vec3i';
516
+ x: number;
517
+ y: number;
518
+ z: number;
519
+ }
520
+ /**
521
+ * Interface representing its WGSL vector type counterpart: vec3u or vec3<u32>.
522
+ * A vector with 3 elements of type u32
523
+ */
524
+ interface v3u extends Tuple3<number>, Swizzle3<v2u, v3u, v4u> {
525
+ readonly [$internal]: true;
526
+ /** use to distinguish between vectors of the same size on the type level */
527
+ readonly kind: 'vec3u';
528
+ x: number;
529
+ y: number;
530
+ z: number;
531
+ }
532
+ /**
533
+ * Interface representing its WGSL vector type counterpart: `vec3<bool>`.
534
+ * A vector with 3 elements of type `bool`
535
+ */
536
+ interface v3b extends Tuple3<boolean>, Swizzle3<v2b, v3b, v4b> {
537
+ readonly [$internal]: true;
538
+ /** use to distinguish between vectors of the same size on the type level */
539
+ readonly kind: 'vec3<bool>';
540
+ x: boolean;
541
+ y: boolean;
542
+ z: boolean;
543
+ }
544
+ /**
545
+ * Interface representing its WGSL vector type counterpart: vec4f or vec4<f32>.
546
+ * A vector with 4 elements of type f32
547
+ */
548
+ interface v4f extends Tuple4<number>, Swizzle4<v2f, v3f, v4f> {
549
+ readonly [$internal]: true;
550
+ /** use to distinguish between vectors of the same size on the type level */
551
+ readonly kind: 'vec4f';
552
+ x: number;
553
+ y: number;
554
+ z: number;
555
+ w: number;
556
+ }
557
+ /**
558
+ * Interface representing its WGSL vector type counterpart: vec4h or vec4<f16>.
559
+ * A vector with 4 elements of type f16
560
+ */
561
+ interface v4h extends Tuple4<number>, Swizzle4<v2h, v3h, v4h> {
562
+ readonly [$internal]: true;
563
+ /** use to distinguish between vectors of the same size on the type level */
564
+ readonly kind: 'vec4h';
565
+ x: number;
566
+ y: number;
567
+ z: number;
568
+ w: number;
569
+ }
570
+ /**
571
+ * Interface representing its WGSL vector type counterpart: vec4i or vec4<i32>.
572
+ * A vector with 4 elements of type i32
573
+ */
574
+ interface v4i extends Tuple4<number>, Swizzle4<v2i, v3i, v4i> {
575
+ readonly [$internal]: true;
576
+ /** use to distinguish between vectors of the same size on the type level */
577
+ readonly kind: 'vec4i';
578
+ x: number;
579
+ y: number;
580
+ z: number;
581
+ w: number;
582
+ }
583
+ /**
584
+ * Interface representing its WGSL vector type counterpart: vec4u or vec4<u32>.
585
+ * A vector with 4 elements of type u32
586
+ */
587
+ interface v4u extends Tuple4<number>, Swizzle4<v2u, v3u, v4u> {
588
+ readonly [$internal]: true;
589
+ /** use to distinguish between vectors of the same size on the type level */
590
+ readonly kind: 'vec4u';
591
+ x: number;
592
+ y: number;
593
+ z: number;
594
+ w: number;
595
+ }
596
+ /**
597
+ * Interface representing its WGSL vector type counterpart: `vec4<bool>`.
598
+ * A vector with 4 elements of type `bool`
599
+ */
600
+ interface v4b extends Tuple4<boolean>, Swizzle4<v2b, v3b, v4b> {
601
+ readonly [$internal]: true;
602
+ /** use to distinguish between vectors of the same size on the type level */
603
+ readonly kind: 'vec4<bool>';
604
+ x: boolean;
605
+ y: boolean;
606
+ z: boolean;
607
+ w: boolean;
608
+ }
609
+ type AnyFloatVecInstance = v2f | v2h | v3f | v3h | v4f | v4h;
610
+ type AnyBooleanVecInstance = v2b | v3b | v4b;
611
+ type AnyNumericVec2Instance = v2f | v2h | v2i | v2u;
612
+ type AnyNumericVec3Instance = v3f | v3h | v3i | v3u;
613
+ type AnyNumericVec4Instance = v4f | v4h | v4i | v4u;
614
+ type AnyNumericVecInstance = AnyNumericVec2Instance | AnyNumericVec3Instance | AnyNumericVec4Instance;
615
+ type AnyVec2Instance = v2f | v2h | v2i | v2u | v2b;
616
+ type AnyVec3Instance = v3f | v3h | v3i | v3u | v3b;
617
+ type AnyVec4Instance = v4f | v4h | v4i | v4u | v4b;
618
+ type AnyVecInstance = AnyVec2Instance | AnyVec3Instance | AnyVec4Instance;
619
+ interface matBase<TColumn> extends NumberArrayView {
620
+ readonly [$internal]: true;
621
+ readonly columns: readonly TColumn[];
622
+ }
623
+ /**
624
+ * Interface representing its WGSL matrix type counterpart: mat2x2
625
+ * A matrix with 2 rows and 2 columns, with elements of type `TColumn`
626
+ */
627
+ interface mat2x2<TColumn> extends matBase<TColumn> {
628
+ readonly length: 4;
629
+ readonly kind: string;
630
+ [n: number]: number;
631
+ }
632
+ /**
633
+ * Interface representing its WGSL matrix type counterpart: mat2x2f or mat2x2<f32>
634
+ * A matrix with 2 rows and 2 columns, with elements of type d.f32
635
+ */
636
+ interface m2x2f extends mat2x2<v2f> {
637
+ readonly kind: 'mat2x2f';
638
+ }
639
+ /**
640
+ * Interface representing its WGSL matrix type counterpart: mat3x3
641
+ * A matrix with 3 rows and 3 columns, with elements of type `TColumn`
642
+ */
643
+ interface mat3x3<TColumn> extends matBase<TColumn> {
644
+ readonly length: 12;
645
+ readonly kind: string;
646
+ [n: number]: number;
647
+ }
648
+ /**
649
+ * Interface representing its WGSL matrix type counterpart: mat3x3f or mat3x3<f32>
650
+ * A matrix with 3 rows and 3 columns, with elements of type d.f32
651
+ */
652
+ interface m3x3f extends mat3x3<v3f> {
653
+ readonly kind: 'mat3x3f';
654
+ }
655
+ /**
656
+ * Interface representing its WGSL matrix type counterpart: mat4x4
657
+ * A matrix with 4 rows and 4 columns, with elements of type `TColumn`
658
+ */
659
+ interface mat4x4<TColumn> extends matBase<TColumn> {
660
+ readonly length: 16;
661
+ readonly kind: string;
662
+ [n: number]: number;
663
+ }
664
+ /**
665
+ * Interface representing its WGSL matrix type counterpart: mat4x4f or mat4x4<f32>
666
+ * A matrix with 4 rows and 4 columns, with elements of type d.f32
667
+ */
668
+ interface m4x4f extends mat4x4<v4f> {
669
+ readonly kind: 'mat4x4f';
670
+ }
671
+ type AnyMatInstance = m2x2f | m3x3f | m4x4f;
672
+ type vBaseForMat<T extends AnyMatInstance> = T extends m2x2f ? v2f : T extends m3x3f ? v3f : v4f;
673
+ /**
674
+ * Boolean schema representing a single WGSL bool value.
675
+ * Cannot be used inside buffers as it is not host-shareable.
676
+ */
677
+ interface Bool {
678
+ readonly [$internal]: true;
679
+ readonly type: 'bool';
680
+ readonly [$repr]: boolean;
681
+ }
682
+ /**
683
+ * 32-bit float schema representing a single WGSL f32 value.
684
+ */
685
+ interface F32 {
686
+ readonly [$internal]: true;
687
+ readonly type: 'f32';
688
+ readonly [$repr]: number;
689
+ (v: number | boolean): number;
690
+ }
691
+ /**
692
+ * 16-bit float schema representing a single WGSL f16 value.
693
+ */
694
+ interface F16 {
695
+ readonly [$internal]: true;
696
+ readonly type: 'f16';
697
+ readonly [$repr]: number;
698
+ (v: number | boolean): number;
699
+ }
700
+ /**
701
+ * Signed 32-bit integer schema representing a single WGSL i32 value.
702
+ */
703
+ interface I32 {
704
+ readonly [$internal]: true;
705
+ readonly type: 'i32';
706
+ readonly [$repr]: number;
707
+ readonly '~memIdent': I32 | Atomic<I32> | DecoratedLocation<I32>;
708
+ (v: number | boolean): number;
709
+ }
710
+ /**
711
+ * Unsigned 32-bit integer schema representing a single WGSL u32 value.
712
+ */
713
+ interface U32 {
714
+ readonly [$internal]: true;
715
+ readonly type: 'u32';
716
+ readonly [$repr]: number;
717
+ readonly '~memIdent': U32 | Atomic<U32> | DecoratedLocation<U32>;
718
+ (v: number | boolean): number;
719
+ }
720
+ /**
721
+ * Type of the `d.vec2f` object/function: vector data type schema/constructor
722
+ */
723
+ interface Vec2f {
724
+ readonly [$internal]: true;
725
+ readonly type: 'vec2f';
726
+ readonly [$repr]: v2f;
727
+ (x: number, y: number): v2f;
728
+ (xy: number): v2f;
729
+ (): v2f;
730
+ (v: AnyNumericVec2Instance): v2f;
731
+ }
732
+ /**
733
+ * Type of the `d.vec2h` object/function: vector data type schema/constructor
734
+ */
735
+ interface Vec2h {
736
+ readonly [$internal]: true;
737
+ readonly type: 'vec2h';
738
+ readonly [$repr]: v2h;
739
+ (x: number, y: number): v2h;
740
+ (xy: number): v2h;
741
+ (): v2h;
742
+ (v: AnyNumericVec2Instance): v2h;
743
+ }
744
+ /**
745
+ * Type of the `d.vec2i` object/function: vector data type schema/constructor
746
+ */
747
+ interface Vec2i {
748
+ readonly [$internal]: true;
749
+ readonly type: 'vec2i';
750
+ readonly [$repr]: v2i;
751
+ (x: number, y: number): v2i;
752
+ (xy: number): v2i;
753
+ (): v2i;
754
+ (v: AnyNumericVec2Instance): v2i;
755
+ }
756
+ /**
757
+ * Type of the `d.vec2u` object/function: vector data type schema/constructor
758
+ */
759
+ interface Vec2u {
760
+ readonly [$internal]: true;
761
+ readonly type: 'vec2u';
762
+ readonly [$repr]: v2u;
763
+ (x: number, y: number): v2u;
764
+ (xy: number): v2u;
765
+ (): v2u;
766
+ (v: AnyNumericVec2Instance): v2u;
767
+ }
768
+ /**
769
+ * Type of the `d.vec2b` object/function: vector data type schema/constructor
770
+ * Cannot be used inside buffers as it is not host-shareable.
771
+ */
772
+ interface Vec2b {
773
+ readonly [$internal]: true;
774
+ readonly type: 'vec2<bool>';
775
+ readonly [$repr]: v2b;
776
+ (x: boolean, y: boolean): v2b;
777
+ (xy: boolean): v2b;
778
+ (): v2b;
779
+ (v: v2b): v2b;
780
+ }
781
+ /**
782
+ * Type of the `d.vec3f` object/function: vector data type schema/constructor
783
+ */
784
+ interface Vec3f {
785
+ readonly [$internal]: true;
786
+ readonly type: 'vec3f';
787
+ readonly [$repr]: v3f;
788
+ (x: number, y: number, z: number): v3f;
789
+ (xyz: number): v3f;
790
+ (): v3f;
791
+ (v: AnyNumericVec3Instance): v3f;
792
+ (v0: AnyNumericVec2Instance, z: number): v3f;
793
+ (x: number, v0: AnyNumericVec2Instance): v3f;
794
+ }
795
+ /**
796
+ * Type of the `d.vec3h` object/function: vector data type schema/constructor
797
+ */
798
+ interface Vec3h {
799
+ readonly [$internal]: true;
800
+ readonly type: 'vec3h';
801
+ readonly [$repr]: v3h;
802
+ (x: number, y: number, z: number): v3h;
803
+ (xyz: number): v3h;
804
+ (): v3h;
805
+ (v: AnyNumericVec3Instance): v3h;
806
+ (v0: AnyNumericVec2Instance, z: number): v3h;
807
+ (x: number, v0: AnyNumericVec2Instance): v3h;
808
+ }
809
+ /**
810
+ * Type of the `d.vec3i` object/function: vector data type schema/constructor
811
+ */
812
+ interface Vec3i {
813
+ readonly [$internal]: true;
814
+ readonly type: 'vec3i';
815
+ readonly [$repr]: v3i;
816
+ (x: number, y: number, z: number): v3i;
817
+ (xyz: number): v3i;
818
+ (): v3i;
819
+ (v: AnyNumericVec3Instance): v3i;
820
+ (v0: AnyNumericVec2Instance, z: number): v3i;
821
+ (x: number, v0: AnyNumericVec2Instance): v3i;
822
+ }
823
+ /**
824
+ * Type of the `d.vec3u` object/function: vector data type schema/constructor
825
+ */
826
+ interface Vec3u {
827
+ readonly [$internal]: true;
828
+ readonly type: 'vec3u';
829
+ readonly [$repr]: v3u;
830
+ (x: number, y: number, z: number): v3u;
831
+ (xyz: number): v3u;
832
+ (): v3u;
833
+ (v: AnyNumericVec3Instance): v3u;
834
+ (v0: AnyNumericVec2Instance, z: number): v3u;
835
+ (x: number, v0: AnyNumericVec2Instance): v3u;
836
+ }
837
+ /**
838
+ * Type of the `d.vec3b` object/function: vector data type schema/constructor
839
+ * Cannot be used inside buffers as it is not host-shareable.
840
+ */
841
+ interface Vec3b {
842
+ readonly [$internal]: true;
843
+ readonly type: 'vec3<bool>';
844
+ readonly [$repr]: v3b;
845
+ (x: boolean, y: boolean, z: boolean): v3b;
846
+ (xyz: boolean): v3b;
847
+ (): v3b;
848
+ (v: v3b): v3b;
849
+ (v0: v2b, z: boolean): v3b;
850
+ (x: boolean, v0: v2b): v3b;
851
+ }
852
+ /**
853
+ * Type of the `d.vec4f` object/function: vector data type schema/constructor
854
+ */
855
+ interface Vec4f {
856
+ readonly [$internal]: true;
857
+ readonly type: 'vec4f';
858
+ readonly [$repr]: v4f;
859
+ (x: number, y: number, z: number, w: number): v4f;
860
+ (xyzw: number): v4f;
861
+ (): v4f;
862
+ (v: AnyNumericVec4Instance): v4f;
863
+ (v0: AnyNumericVec3Instance, w: number): v4f;
864
+ (x: number, v0: AnyNumericVec3Instance): v4f;
865
+ (v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4f;
866
+ (v0: AnyNumericVec2Instance, z: number, w: number): v4f;
867
+ (x: number, v0: AnyNumericVec2Instance, z: number): v4f;
868
+ (x: number, y: number, v0: AnyNumericVec2Instance): v4f;
869
+ }
870
+ /**
871
+ * Type of the `d.vec4h` object/function: vector data type schema/constructor
872
+ */
873
+ interface Vec4h {
874
+ readonly [$internal]: true;
875
+ readonly type: 'vec4h';
876
+ readonly [$repr]: v4h;
877
+ (x: number, y: number, z: number, w: number): v4h;
878
+ (xyzw: number): v4h;
879
+ (): v4h;
880
+ (v: AnyNumericVec4Instance): v4h;
881
+ (v0: AnyNumericVec3Instance, w: number): v4h;
882
+ (x: number, v0: AnyNumericVec3Instance): v4h;
883
+ (v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4h;
884
+ (v0: AnyNumericVec2Instance, z: number, w: number): v4h;
885
+ (x: number, v0: AnyNumericVec2Instance, z: number): v4h;
886
+ (x: number, y: number, v0: AnyNumericVec2Instance): v4h;
887
+ }
888
+ /**
889
+ * Type of the `d.vec4i` object/function: vector data type schema/constructor
890
+ */
891
+ interface Vec4i {
892
+ readonly [$internal]: true;
893
+ readonly type: 'vec4i';
894
+ readonly [$repr]: v4i;
895
+ (x: number, y: number, z: number, w: number): v4i;
896
+ (xyzw: number): v4i;
897
+ (): v4i;
898
+ (v: AnyNumericVec4Instance): v4i;
899
+ (v0: AnyNumericVec3Instance, w: number): v4i;
900
+ (x: number, v0: AnyNumericVec3Instance): v4i;
901
+ (v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4i;
902
+ (v0: AnyNumericVec2Instance, z: number, w: number): v4i;
903
+ (x: number, v0: AnyNumericVec2Instance, z: number): v4i;
904
+ (x: number, y: number, v0: AnyNumericVec2Instance): v4i;
905
+ }
906
+ /**
907
+ * Type of the `d.vec4u` object/function: vector data type schema/constructor
908
+ */
909
+ interface Vec4u {
910
+ readonly [$internal]: true;
911
+ readonly type: 'vec4u';
912
+ readonly [$repr]: v4u;
913
+ (x: number, y: number, z: number, w: number): v4u;
914
+ (xyzw: number): v4u;
915
+ (): v4u;
916
+ (v: AnyNumericVec4Instance): v4u;
917
+ (v0: AnyNumericVec3Instance, w: number): v4u;
918
+ (x: number, v0: AnyNumericVec3Instance): v4u;
919
+ (v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4u;
920
+ (v0: AnyNumericVec2Instance, z: number, w: number): v4u;
921
+ (x: number, v0: AnyNumericVec2Instance, z: number): v4u;
922
+ (x: number, y: number, v0: AnyNumericVec2Instance): v4u;
923
+ }
924
+ /**
925
+ * Type of the `d.vec4b` object/function: vector data type schema/constructor
926
+ * Cannot be used inside buffers as it is not host-shareable.
927
+ */
928
+ interface Vec4b {
929
+ readonly [$internal]: true;
930
+ readonly type: 'vec4<bool>';
931
+ readonly [$repr]: v4b;
932
+ (x: boolean, y: boolean, z: boolean, w: boolean): v4b;
933
+ (xyzw: boolean): v4b;
934
+ (): v4b;
935
+ (v: v4b): v4b;
936
+ (v0: v3b, w: boolean): v4b;
937
+ (x: boolean, v0: v3b): v4b;
938
+ (v0: v2b, v1: v2b): v4b;
939
+ (v0: v2b, z: boolean, w: boolean): v4b;
940
+ (x: boolean, v0: v2b, z: boolean): v4b;
941
+ (x: boolean, y: boolean, v0: v2b): v4b;
942
+ }
943
+ /**
944
+ * Type of the `d.mat2x2f` object/function: matrix data type schema/constructor
945
+ */
946
+ interface Mat2x2f {
947
+ readonly [$internal]: true;
948
+ readonly type: 'mat2x2f';
949
+ readonly [$repr]: m2x2f;
950
+ (...elements: number[]): m2x2f;
951
+ (...columns: v2f[]): m2x2f;
952
+ (): m2x2f;
953
+ }
954
+ /**
955
+ * Type of the `d.mat3x3f` object/function: matrix data type schema/constructor
956
+ */
957
+ interface Mat3x3f {
958
+ readonly [$internal]: true;
959
+ readonly type: 'mat3x3f';
960
+ readonly [$repr]: m3x3f;
961
+ (...elements: number[]): m3x3f;
962
+ (...columns: v3f[]): m3x3f;
963
+ (): m3x3f;
964
+ }
965
+ /**
966
+ * Type of the `d.mat4x4f` object/function: matrix data type schema/constructor
967
+ */
968
+ interface Mat4x4f {
969
+ readonly [$internal]: true;
970
+ readonly type: 'mat4x4f';
971
+ readonly [$repr]: m4x4f;
972
+ (...elements: number[]): m4x4f;
973
+ (...columns: v4f[]): m4x4f;
974
+ (): m4x4f;
975
+ }
976
+ /**
977
+ * Array schema constructed via `d.arrayOf` function.
978
+ *
979
+ * Responsible for handling reading and writing array values
980
+ * between binary and JS representation. Takes into account
981
+ * the `byteAlignment` requirement of its elementType.
982
+ */
983
+ interface WgslArray<TElement extends BaseData = BaseData> {
984
+ readonly [$internal]: true;
985
+ readonly type: 'array';
986
+ readonly elementCount: number;
987
+ readonly elementType: TElement;
988
+ readonly [$repr]: Infer<TElement>[];
989
+ readonly '~gpuRepr': InferGPU<TElement>[];
990
+ readonly '~reprPartial': {
991
+ idx: number;
992
+ value: InferPartial<TElement>;
993
+ }[] | undefined;
994
+ readonly '~memIdent': WgslArray<MemIdentity<TElement>>;
995
+ }
996
+ /**
997
+ * Struct schema constructed via `d.struct` function.
998
+ *
999
+ * Responsible for handling reading and writing struct values
1000
+ * between binary and JS representation. Takes into account
1001
+ * the `byteAlignment` requirement of its members.
1002
+ */
1003
+ interface WgslStruct<TProps extends Record<string, BaseData> = Record<string, BaseData>> extends TgpuNamable {
1004
+ (props: Prettify<InferRecord<TProps>>): Prettify<InferRecord<TProps>>;
1005
+ readonly [$internal]: true;
1006
+ readonly type: 'struct';
1007
+ readonly propTypes: TProps;
1008
+ readonly [$repr]: Prettify<InferRecord<TProps>>;
1009
+ /** Type-token, not available at runtime */
1010
+ readonly '~gpuRepr': Prettify<InferGPURecord<TProps>>;
1011
+ /** Type-token, not available at runtime */
1012
+ readonly '~memIdent': WgslStruct<Prettify<MemIdentityRecord<TProps>>>;
1013
+ /** Type-token, not available at runtime */
1014
+ readonly '~reprPartial': Prettify<Partial<InferPartialRecord<TProps>>> | undefined;
1015
+ }
1016
+ type AnyWgslStruct = WgslStruct<any>;
1017
+ type AddressSpace = 'uniform' | 'storage' | 'workgroup' | 'private' | 'function' | 'handle';
1018
+ type Access = 'read' | 'write' | 'read-write';
1019
+ interface Ptr<TAddr extends AddressSpace = AddressSpace, TInner extends BaseData = BaseData, // can also be sampler or texture (╯'□')╯︵ ┻━┻
1020
+ TAccess extends Access = Access> {
1021
+ readonly [$internal]: true;
1022
+ readonly type: 'ptr';
1023
+ readonly inner: TInner;
1024
+ readonly addressSpace: TAddr;
1025
+ readonly access: TAccess;
1026
+ readonly [$repr]: Infer<TInner>;
1027
+ }
1028
+ /**
1029
+ * Schema representing the `atomic<...>` WGSL data type.
1030
+ */
1031
+ interface Atomic<TInner extends U32 | I32 = U32 | I32> {
1032
+ readonly [$internal]: true;
1033
+ readonly type: 'atomic';
1034
+ readonly inner: TInner;
1035
+ readonly [$repr]: Infer<TInner>;
1036
+ readonly '~gpuRepr': TInner extends U32 ? atomicU32 : atomicI32;
1037
+ readonly '~memIdent': MemIdentity<TInner>;
1038
+ }
1039
+ interface atomicU32 {
1040
+ readonly [$internal]: true;
1041
+ readonly type: 'atomicU32';
1042
+ }
1043
+ interface atomicI32 {
1044
+ readonly [$internal]: true;
1045
+ readonly type: 'atomicI32';
1046
+ }
1047
+ interface Align<T extends number> {
1048
+ readonly [$internal]: true;
1049
+ readonly type: '@align';
1050
+ readonly value: T;
1051
+ }
1052
+ interface Size<T extends number> {
1053
+ readonly [$internal]: true;
1054
+ readonly type: '@size';
1055
+ readonly value: T;
1056
+ }
1057
+ interface Location<T extends number> {
1058
+ readonly [$internal]: true;
1059
+ readonly type: '@location';
1060
+ readonly value: T;
1061
+ }
1062
+ type PerspectiveOrLinearInterpolationType = `${'perspective' | 'linear'}${'' | ', center' | ', centroid' | ', sample'}`;
1063
+ type FlatInterpolationType = `flat${'' | ', first' | ', either'}`;
1064
+ type InterpolationType = PerspectiveOrLinearInterpolationType | FlatInterpolationType;
1065
+ interface Interpolate<T extends InterpolationType> {
1066
+ readonly [$internal]: true;
1067
+ readonly type: '@interpolate';
1068
+ readonly value: T;
1069
+ }
1070
+ interface Builtin<T extends string> {
1071
+ readonly [$internal]: true;
1072
+ readonly type: '@builtin';
1073
+ readonly value: T;
1074
+ }
1075
+ interface Decorated<TInner extends BaseData = BaseData, TAttribs extends unknown[] = unknown[]> {
1076
+ readonly [$internal]: true;
1077
+ readonly type: 'decorated';
1078
+ readonly inner: TInner;
1079
+ readonly attribs: TAttribs;
1080
+ readonly [$repr]: Infer<TInner>;
1081
+ readonly '~gpuRepr': InferGPU<TInner>;
1082
+ readonly '~reprPartial': InferPartial<TInner>;
1083
+ readonly '~memIdent': TAttribs extends Location<number>[] ? MemIdentity<TInner> | Decorated<MemIdentity<TInner>, TAttribs> : Decorated<MemIdentity<TInner>, TAttribs>;
1084
+ }
1085
+ declare const wgslTypeLiterals: readonly ["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", "void"];
1086
+ type WgslTypeLiteral = (typeof wgslTypeLiterals)[number];
1087
+ type PerspectiveOrLinearInterpolatableBaseType = F32 | F16 | Vec2f | Vec2h | Vec3f | Vec3h | Vec4f | Vec4h;
1088
+ type PerspectiveOrLinearInterpolatableData = PerspectiveOrLinearInterpolatableBaseType | Decorated<PerspectiveOrLinearInterpolatableBaseType>;
1089
+ type FlatInterpolatableAdditionalBaseType = I32 | U32 | Vec2i | Vec2u | Vec3i | Vec3u | Vec4i | Vec4u;
1090
+ type FlatInterpolatableData = PerspectiveOrLinearInterpolatableData | FlatInterpolatableAdditionalBaseType | Decorated<FlatInterpolatableAdditionalBaseType>;
1091
+ type AnyWgslData = Bool | F32 | F16 | I32 | U32 | Vec2f | Vec2h | Vec2i | Vec2u | Vec2b | Vec3f | Vec3h | Vec3i | Vec3u | Vec3b | Vec4f | Vec4h | Vec4i | Vec4u | Vec4b | Mat2x2f | Mat3x3f | Mat4x4f | AnyWgslStruct | WgslArray | Ptr | Atomic | Decorated | AbstractInt | AbstractFloat | Void;
1092
+ declare function isWgslData(value: unknown): value is AnyWgslData;
1093
+ /**
1094
+ * Checks whether passed in value is an array schema,
1095
+ * as opposed to, e.g., a disarray schema.
1096
+ *
1097
+ * Array schemas can be used to describe uniform and storage buffers,
1098
+ * whereas disarray schemas cannot.
1099
+ *
1100
+ * @example
1101
+ * isWgslArray(d.arrayOf(d.u32, 4)) // true
1102
+ * isWgslArray(d.disarray(d.u32, 4)) // false
1103
+ * isWgslArray(d.vec3f) // false
1104
+ */
1105
+ declare function isWgslArray<T extends WgslArray>(schema: T | unknown): schema is T;
1106
+ /**
1107
+ * Checks whether passed in value is a struct schema,
1108
+ * as opposed to, e.g., an unstruct schema.
1109
+ *
1110
+ * Struct schemas can be used to describe uniform and storage buffers,
1111
+ * whereas unstruct schemas cannot.
1112
+ *
1113
+ * @example
1114
+ * isWgslStruct(d.struct({ a: d.u32 })) // true
1115
+ * isWgslStruct(d.unstruct({ a: d.u32 })) // false
1116
+ * isWgslStruct(d.vec3f) // false
1117
+ */
1118
+ declare function isWgslStruct<T extends WgslStruct>(schema: T | unknown): schema is T;
1119
+ /**
1120
+ * Checks whether passed in value is a pointer ('function' scope) schema.
1121
+ *
1122
+ * @example
1123
+ * isPtrFn(d.ptrFn(d.f32)) // true
1124
+ * isPtrFn(d.f32) // false
1125
+ */
1126
+ declare function isPtr<T extends Ptr>(schema: T | unknown): schema is T;
1127
+ /**
1128
+ * Checks whether the passed in value is an atomic schema.
1129
+ *
1130
+ * @example
1131
+ * isAtomic(d.atomic(d.u32)) // true
1132
+ * isAtomic(d.u32) // false
1133
+ */
1134
+ declare function isAtomic<T extends Atomic<U32 | I32>>(schema: T | unknown): schema is T;
1135
+ declare function isAlignAttrib<T extends Align<number>>(value: unknown | T): value is T;
1136
+ declare function isSizeAttrib<T extends Size<number>>(value: unknown | T): value is T;
1137
+ declare function isLocationAttrib<T extends Location<number>>(value: unknown | T): value is T;
1138
+ declare function isInterpolateAttrib<T extends Interpolate<InterpolationType>>(value: unknown | T): value is T;
1139
+ declare function isBuiltinAttrib<T extends Builtin<string>>(value: unknown | T): value is T;
1140
+ declare function isDecorated<T extends Decorated>(value: unknown | T): value is T;
1141
+
1142
+ interface TgpuConst<TDataType extends AnyWgslData = AnyWgslData> extends TgpuNamable {
1143
+ readonly value: Infer<TDataType>;
1144
+ readonly [$internal]: {
1145
+ readonly dataType: TDataType;
1146
+ };
1147
+ }
1148
+ /**
1149
+ * Creates a module constant with specified value.
1150
+ */
1151
+ declare function constant<TDataType extends AnyWgslData>(dataType: TDataType, value: Infer<TDataType>): TgpuConst<TDataType>;
1152
+
1153
+ /**
1154
+ * Extra declaration that shall be included in final WGSL code,
1155
+ * when resolving objects that use it.
1156
+ */
1157
+ interface TgpuDeclare {
1158
+ $uses(dependencyMap: Record<string, unknown>): this;
1159
+ }
1160
+ /**
1161
+ * Allows defining extra declarations that shall be included in the final WGSL code,
1162
+ * when resolving objects that use them.
1163
+ *
1164
+ * Using this API is generally discouraged, as it shouldn't be necessary in any common scenario.
1165
+ * It was developed to ensure full compatibility of TypeGPU programs with current and future versions of WGSL.
1166
+ */
1167
+ declare function declare(declaration: string): TgpuDeclare;
1168
+
1169
+ type BuiltinVertexIndex = Decorated<U32, [Builtin<'vertex_index'>]>;
1170
+ type BuiltinInstanceIndex = Decorated<U32, [Builtin<'instance_index'>]>;
1171
+ type BuiltinPosition = Decorated<Vec4f, [Builtin<'position'>]>;
1172
+ type BuiltinClipDistances = Decorated<WgslArray<U32>, [
1173
+ Builtin<'clip_distances'>
1174
+ ]>;
1175
+ type BuiltinFrontFacing = Decorated<F32, [Builtin<'front_facing'>]>;
1176
+ type BuiltinFragDepth = Decorated<F32, [Builtin<'frag_depth'>]>;
1177
+ type BuiltinSampleIndex = Decorated<U32, [Builtin<'sample_index'>]>;
1178
+ type BuiltinSampleMask = Decorated<U32, [Builtin<'sample_mask'>]>;
1179
+ type BuiltinLocalInvocationId = Decorated<Vec3u, [
1180
+ Builtin<'local_invocation_id'>
1181
+ ]>;
1182
+ type BuiltinLocalInvocationIndex = Decorated<U32, [
1183
+ Builtin<'local_invocation_index'>
1184
+ ]>;
1185
+ type BuiltinGlobalInvocationId = Decorated<Vec3u, [
1186
+ Builtin<'global_invocation_id'>
1187
+ ]>;
1188
+ type BuiltinWorkgroupId = Decorated<Vec3u, [Builtin<'workgroup_id'>]>;
1189
+ type BuiltinNumWorkgroups = Decorated<Vec3u, [
1190
+ Builtin<'num_workgroups'>
1191
+ ]>;
1192
+ type BuiltinSubgroupInvocationId = Decorated<U32, [
1193
+ Builtin<'subgroup_invocation_id'>
1194
+ ]>;
1195
+ type BuiltinSubgroupSize = Decorated<U32, [Builtin<'subgroup_size'>]>;
1196
+ declare const builtin: {
1197
+ readonly vertexIndex: BuiltinVertexIndex;
1198
+ readonly instanceIndex: BuiltinInstanceIndex;
1199
+ readonly position: BuiltinPosition;
1200
+ readonly clipDistances: BuiltinClipDistances;
1201
+ readonly frontFacing: BuiltinFrontFacing;
1202
+ readonly fragDepth: BuiltinFragDepth;
1203
+ readonly sampleIndex: BuiltinSampleIndex;
1204
+ readonly sampleMask: BuiltinSampleMask;
1205
+ readonly localInvocationId: BuiltinLocalInvocationId;
1206
+ readonly localInvocationIndex: BuiltinLocalInvocationIndex;
1207
+ readonly globalInvocationId: BuiltinGlobalInvocationId;
1208
+ readonly workgroupId: BuiltinWorkgroupId;
1209
+ readonly numWorkgroups: BuiltinNumWorkgroups;
1210
+ readonly subgroupInvocationId: BuiltinSubgroupInvocationId;
1211
+ readonly subgroupSize: BuiltinSubgroupSize;
1212
+ };
1213
+ type AnyBuiltin = (typeof builtin)[keyof typeof builtin];
1214
+ type AnyComputeBuiltin = BuiltinLocalInvocationId | BuiltinLocalInvocationIndex | BuiltinGlobalInvocationId | BuiltinWorkgroupId | BuiltinNumWorkgroups | BuiltinSubgroupInvocationId | BuiltinSubgroupSize;
1215
+ type AnyFragmentInputBuiltin = BuiltinPosition | BuiltinFrontFacing | BuiltinSampleIndex | BuiltinSampleMask | BuiltinSubgroupInvocationId | BuiltinSubgroupSize;
1216
+ type AnyFragmentOutputBuiltin = BuiltinFragDepth | BuiltinSampleMask;
1217
+ type OmitBuiltins<S> = S extends AnyBuiltin ? never : S extends BaseData ? S : {
1218
+ [Key in keyof S as S[Key] extends AnyBuiltin ? never : Key]: S[Key];
1219
+ };
1220
+
1221
+ interface StorageFlag {
1222
+ usableAsStorage: true;
1223
+ }
1224
+ /**
1225
+ * @deprecated Use StorageFlag instead.
1226
+ */
1227
+ type Storage = StorageFlag;
1228
+ declare function isUsableAsStorage<T>(value: T): value is T & StorageFlag;
1229
+
1230
+ /**
1231
+ * Used to transpile JS resources into tinyest on demand.
1232
+ */
1233
+ interface JitTranspiler {
1234
+ transpileFn(rawJs: string): TranspilationResult;
1235
+ }
1236
+
1237
+ interface NameRegistry {
1238
+ /**
1239
+ * Creates a valid WGSL identifier, each guaranteed to be unique
1240
+ * in the lifetime of a single resolution process.
1241
+ * @param primer Used in the generation process, makes the identifier more recognizable.
1242
+ */
1243
+ makeUnique(primer?: string): string;
1244
+ }
1245
+ declare class RandomNameRegistry implements NameRegistry {
1246
+ private lastUniqueId;
1247
+ makeUnique(primer?: string | undefined): string;
1248
+ }
1249
+ declare class StrictNameRegistry implements NameRegistry {
1250
+ /**
1251
+ * Allows to provide a good fallback for instances of the
1252
+ * same function that are bound to different slot values.
1253
+ */
1254
+ private readonly _usedNames;
1255
+ makeUnique(primer?: string | undefined): string;
1256
+ }
1257
+
1258
+ /**
1259
+ * Describes a function signature (its arguments and return type)
1260
+ */
1261
+ type TgpuFnShellHeader<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = AnyWgslData | undefined> = {
1262
+ readonly [$internal]: true;
1263
+ readonly argTypes: Args;
1264
+ readonly returnType: Return | undefined;
1265
+ readonly isEntry: false;
1266
+ };
1267
+ /**
1268
+ * Describes a function signature (its arguments and return type).
1269
+ * Allows creating tgpu functions by calling this shell
1270
+ * and passing the implementation (as WGSL string or JS function) as the argument.
1271
+ */
1272
+ type TgpuFnShell<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = AnyWgslData | undefined> = TgpuFnShellHeader<Args, Return> & ((implementation: (...args: Args extends AnyWgslData[] ? InferArgs<Args> : [InferIO<Args>]) => InferReturn<Return>) => TgpuFn<Args, Return>) & ((implementation: string) => TgpuFn<Args, Return>) & ((strings: TemplateStringsArray, ...values: unknown[]) => TgpuFn<Args, Return>) & {
1273
+ /**
1274
+ * @deprecated Invoke the shell as a function instead.
1275
+ */
1276
+ does: ((implementation: (...args: Args extends AnyWgslData[] ? InferArgs<Args> : [InferIO<Args>]) => InferReturn<Return>) => TgpuFn<Args, Return>) & ((implementation: string) => TgpuFn<Args, Return>);
1277
+ };
1278
+ interface TgpuFnBase<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = undefined> extends TgpuNamable {
1279
+ readonly [$internal]: {
1280
+ implementation: Implementation<Args, Return>;
1281
+ argTypes: FnArgsConversionHint;
1282
+ };
1283
+ readonly resourceType: 'function';
1284
+ readonly shell: TgpuFnShellHeader<Args, Return>;
1285
+ readonly '~providing'?: Providing | undefined;
1286
+ $uses(dependencyMap: Record<string, unknown>): this;
1287
+ with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TgpuFn<Args, Return>;
1288
+ with<T extends AnyWgslData>(accessor: TgpuAccessor<T>, value: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>): TgpuFn<Args, Return>;
1289
+ }
1290
+ type TgpuFn<Args extends AnyWgslData[] | Record<string, AnyWgslData> = AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = AnyWgslData | undefined> = TgpuFnBase<Args, Return> & ((...args: Args extends AnyWgslData[] ? InferArgs<Args> : Args extends Record<string, never> ? [] : [InferIO<Args>]) => InferReturn<Return>);
1291
+ declare function fn<Args extends AnyWgslData[] | Record<string, AnyWgslData> | []>(argTypes: Args, returnType?: undefined): TgpuFnShell<Args, undefined>;
1292
+ declare function fn<Args extends AnyWgslData[] | Record<string, AnyWgslData> | [], Return extends AnyWgslData>(argTypes: Args, returnType: Return): TgpuFnShell<Args, Return>;
1293
+ declare function isTgpuFn<Args extends AnyWgslData[], Return extends AnyWgslData | undefined = undefined>(value: unknown | TgpuFn<Args, Return>): value is TgpuFn<Args, Return>;
1294
+
1295
+ interface TgpuSlot<T> extends TgpuNamable {
1296
+ readonly resourceType: 'slot';
1297
+ [$repr]: Infer<T>;
1298
+ readonly defaultValue: T | undefined;
1299
+ /**
1300
+ * Used to determine if code generated using either value `a` or `b` in place
1301
+ * of the slot will be equivalent. Defaults to `Object.is`.
1302
+ */
1303
+ areEqual(a: T, b: T): boolean;
1304
+ readonly value: Infer<T>;
1305
+ }
1306
+ interface TgpuDerived<T> {
1307
+ readonly resourceType: 'derived';
1308
+ readonly value: Infer<T>;
1309
+ [$repr]: Infer<T>;
1310
+ readonly '~providing'?: Providing | undefined;
1311
+ with<TValue>(slot: TgpuSlot<TValue>, value: Eventual<TValue>): TgpuDerived<T>;
1312
+ /**
1313
+ * @internal
1314
+ */
1315
+ '~compute'(): T;
1316
+ }
1317
+ interface TgpuAccessor<T extends AnyWgslData = AnyWgslData> extends TgpuNamable {
1318
+ readonly resourceType: 'accessor';
1319
+ [$repr]: Infer<T>;
1320
+ readonly schema: T;
1321
+ readonly defaultValue: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T> | undefined;
1322
+ readonly slot: TgpuSlot<TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>>;
1323
+ readonly value: Infer<T>;
1324
+ }
1325
+ /**
1326
+ * Represents a value that is available at resolution time.
1327
+ */
1328
+ type Eventual<T> = T | TgpuSlot<T> | TgpuDerived<T>;
1329
+ type SlotValuePair<T = unknown> = [TgpuSlot<T>, T];
1330
+ type Providing = {
1331
+ inner: unknown;
1332
+ pairs: SlotValuePair[];
1333
+ };
1334
+ declare function isSlot<T>(value: unknown | TgpuSlot<T>): value is TgpuSlot<T>;
1335
+ declare function isDerived<T extends TgpuDerived<unknown>>(value: T | unknown): value is T;
1336
+
1337
+ interface ComputePipelineInternals {
1338
+ readonly rawPipeline: GPUComputePipeline;
1339
+ }
1340
+ interface TgpuComputePipeline extends TgpuNamable {
1341
+ readonly [$internal]: ComputePipelineInternals;
1342
+ readonly resourceType: 'compute-pipeline';
1343
+ with(bindGroupLayout: TgpuBindGroupLayout, bindGroup: TgpuBindGroup): TgpuComputePipeline;
1344
+ dispatchWorkgroups(x: number, y?: number | undefined, z?: number | undefined): void;
1345
+ }
1346
+
1347
+ 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"];
1348
+ type VertexFormat = (typeof vertexFormats)[number];
1349
+ declare const kindToDefaultFormatMap: {
1350
+ readonly f32: "float32";
1351
+ readonly vec2f: "float32x2";
1352
+ readonly vec3f: "float32x3";
1353
+ readonly vec4f: "float32x4";
1354
+ readonly f16: "float16";
1355
+ readonly vec2h: "float16x2";
1356
+ readonly vec4h: "float16x4";
1357
+ readonly u32: "uint32";
1358
+ readonly vec2u: "uint32x2";
1359
+ readonly vec3u: "uint32x3";
1360
+ readonly vec4u: "uint32x4";
1361
+ readonly i32: "sint32";
1362
+ readonly vec2i: "sint32x2";
1363
+ readonly vec3i: "sint32x3";
1364
+ readonly vec4i: "sint32x4";
1365
+ };
1366
+ type KindToDefaultFormatMap = typeof kindToDefaultFormatMap;
1367
+ interface TgpuVertexAttrib<TFormat extends VertexFormat = VertexFormat> {
1368
+ readonly format: TFormat;
1369
+ readonly offset: number;
1370
+ }
1371
+ type AnyVertexAttribs = Record<string, TgpuVertexAttrib> | TgpuVertexAttrib;
1372
+ /**
1373
+ * All vertex attribute formats that can be interpreted as
1374
+ * an single or multi component u32 in a shader.
1375
+ * https://www.w3.org/TR/webgpu/#vertex-formats
1376
+ */
1377
+ type U32CompatibleFormats = TgpuVertexAttrib<'uint8'> | TgpuVertexAttrib<'uint8x2'> | TgpuVertexAttrib<'uint8x4'> | TgpuVertexAttrib<'uint16'> | TgpuVertexAttrib<'uint16x2'> | TgpuVertexAttrib<'uint16x4'> | TgpuVertexAttrib<'uint32'> | TgpuVertexAttrib<'uint32x2'> | TgpuVertexAttrib<'uint32x3'> | TgpuVertexAttrib<'uint32x4'>;
1378
+ /**
1379
+ * All vertex attribute formats that can be interpreted as
1380
+ * an single or multi component i32 in a shader.
1381
+ * https://www.w3.org/TR/webgpu/#vertex-formats
1382
+ */
1383
+ type I32CompatibleFormats = TgpuVertexAttrib<'sint8'> | TgpuVertexAttrib<'sint8x2'> | TgpuVertexAttrib<'sint8x4'> | TgpuVertexAttrib<'sint16'> | TgpuVertexAttrib<'sint16x2'> | TgpuVertexAttrib<'sint16x4'> | TgpuVertexAttrib<'sint32'> | TgpuVertexAttrib<'sint32x2'> | TgpuVertexAttrib<'sint32x3'> | TgpuVertexAttrib<'sint32x4'>;
1384
+ /**
1385
+ * All vertex attribute formats that can be interpreted as
1386
+ * an single or multi component f32 in a shader.
1387
+ * https://www.w3.org/TR/webgpu/#vertex-formats
1388
+ */
1389
+ 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'>;
1390
+ /**
1391
+ * All vertex attribute formats that can be interpreted as
1392
+ * a single or multi component f16 in a shader. (same as f32 on the shader side)
1393
+ * https://www.w3.org/TR/webgpu/#vertex-formats
1394
+ */
1395
+ type F16CompatibleFormats = F32CompatibleFormats;
1396
+ type KindToAcceptedAttribMap = {
1397
+ u32: U32CompatibleFormats;
1398
+ vec2u: U32CompatibleFormats;
1399
+ vec3u: U32CompatibleFormats;
1400
+ vec4u: U32CompatibleFormats;
1401
+ i32: I32CompatibleFormats;
1402
+ vec2i: I32CompatibleFormats;
1403
+ vec3i: I32CompatibleFormats;
1404
+ vec4i: I32CompatibleFormats;
1405
+ f16: F16CompatibleFormats;
1406
+ vec2h: F16CompatibleFormats;
1407
+ vec3h: F16CompatibleFormats;
1408
+ vec4h: F16CompatibleFormats;
1409
+ f32: F32CompatibleFormats;
1410
+ vec2f: F32CompatibleFormats;
1411
+ vec3f: F32CompatibleFormats;
1412
+ vec4f: F32CompatibleFormats;
1413
+ };
1414
+
1415
+ type WithLocations<T extends IORecord> = {
1416
+ [Key in keyof T]: IsBuiltin<T[Key]> extends true ? T[Key] : HasCustomLocation<T[Key]> extends true ? T[Key] : Decorate<T[Key], Location<number>>;
1417
+ };
1418
+ type IOLayoutToSchema<T extends IOLayout> = T extends BaseData ? Decorate<T, Location<0>> : T extends IORecord ? WgslStruct<WithLocations<T>> : T extends {
1419
+ type: 'void';
1420
+ } ? void : never;
1421
+
1422
+ type FragmentOutConstrained = Void | Vec4f | Decorated<Vec4f, [Location<number>]> | AnyFragmentOutputBuiltin | IORecord<Vec4f | Decorated<Vec4f, [Location<number>]> | AnyFragmentOutputBuiltin>;
1423
+ type FragmentInConstrained = IORecord<BaseIOData | Decorated<BaseIOData, AnyAttribute<never>[]> | AnyFragmentInputBuiltin>;
1424
+ /**
1425
+ * Describes a fragment entry function signature (its arguments, return type and targets)
1426
+ */
1427
+ type TgpuFragmentFnShellHeader<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = {
1428
+ readonly argTypes: [AnyWgslStruct] | [];
1429
+ readonly targets: FragmentOut;
1430
+ readonly returnType: FragmentOut;
1431
+ readonly isEntry: true;
1432
+ };
1433
+ /**
1434
+ * Describes a fragment entry function signature (its arguments, return type and targets).
1435
+ * Allows creating tgpu fragment functions by calling this shell
1436
+ * and passing the implementation (as WGSL string or JS function) as the argument.
1437
+ */
1438
+ type TgpuFragmentFnShell<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = TgpuFragmentFnShellHeader<FragmentIn, FragmentOut> /**
1439
+ * Creates a type-safe implementation of this signature
1440
+ */ & ((implementation: (input: InferIO<FragmentIn>) => InferIO<FragmentOut>) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) & /**
1441
+ * @param implementation
1442
+ * Raw WGSL function implementation with header and body
1443
+ * without `fn` keyword and function name
1444
+ * e.g. `"(x: f32) -> f32 { return x; }"`;
1445
+ */ ((implementation: string) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) & ((strings: TemplateStringsArray, ...values: unknown[]) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) & {
1446
+ /**
1447
+ * @deprecated Invoke the shell as a function instead.
1448
+ */
1449
+ does: ((implementation: (input: InferIO<FragmentIn>) => InferIO<FragmentOut>) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) & /**
1450
+ * @param implementation
1451
+ * Raw WGSL function implementation with header and body
1452
+ * without `fn` keyword and function name
1453
+ * e.g. `"(x: f32) -> f32 { return x; }"`;
1454
+ */ ((implementation: string) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>);
1455
+ };
1456
+ interface TgpuFragmentFn<Varying extends FragmentInConstrained = FragmentInConstrained, Output extends FragmentOutConstrained = FragmentOutConstrained> extends TgpuNamable {
1457
+ readonly shell: TgpuFragmentFnShellHeader<Varying, Output>;
1458
+ readonly outputType: IOLayoutToSchema<Output>;
1459
+ $uses(dependencyMap: Record<string, unknown>): this;
1460
+ }
1461
+ declare function fragmentFn<FragmentOut extends FragmentOutConstrained>(options: {
1462
+ out: FragmentOut;
1463
+ }): TgpuFragmentFnShell<{}, FragmentOut>;
1464
+ declare function fragmentFn<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained>(options: {
1465
+ in: FragmentIn;
1466
+ out: FragmentOut;
1467
+ }): TgpuFragmentFnShell<FragmentIn, FragmentOut>;
1468
+
1469
+ /**
1470
+ * Describes a vertex entry function signature (its arguments, return type and attributes)
1471
+ */
1472
+ type TgpuVertexFnShellHeader<VertexIn extends IOLayout, VertexOut extends IOLayout> = {
1473
+ readonly argTypes: [AnyWgslStruct] | [];
1474
+ readonly returnType: VertexOut;
1475
+ readonly attributes: [VertexIn];
1476
+ readonly isEntry: true;
1477
+ };
1478
+ /**
1479
+ * Describes a vertex entry function signature (its arguments, return type and attributes).
1480
+ * Allows creating tgpu vertex functions by calling this shell
1481
+ * and passing the implementation (as WGSL string or JS function) as the argument.
1482
+ */
1483
+ type TgpuVertexFnShell<VertexIn extends IOLayout, VertexOut extends IOLayout> = TgpuVertexFnShellHeader<VertexIn, VertexOut> & ((implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & ((implementation: string) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & ((strings: TemplateStringsArray, ...values: unknown[]) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & {
1484
+ /**
1485
+ * @deprecated Invoke the shell as a function instead.
1486
+ */
1487
+ does: ((implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & ((implementation: string) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>);
1488
+ };
1489
+ interface TgpuVertexFn<VertexIn extends IOLayout = IOLayout, VertexOut extends IOLayout = IOLayout> extends TgpuNamable {
1490
+ readonly shell: TgpuVertexFnShellHeader<VertexIn, VertexOut>;
1491
+ readonly outputType: IOLayoutToSchema<VertexOut>;
1492
+ readonly inputType: IOLayoutToSchema<VertexIn>;
1493
+ $uses(dependencyMap: Record<string, unknown>): this;
1494
+ }
1495
+ declare function vertexFn<VertexOut extends IORecord>(options: {
1496
+ out: VertexOut;
1497
+ }): TgpuVertexFnShell<{}, VertexOut>;
1498
+ declare function vertexFn<VertexIn extends IORecord, VertexOut extends IORecord>(options: {
1499
+ in: VertexIn;
1500
+ out: VertexOut;
1501
+ }): TgpuVertexFnShell<VertexIn, VertexOut>;
1502
+
1503
+ type TextureProps = {
1504
+ size: readonly number[];
1505
+ format: GPUTextureFormat;
1506
+ viewFormats?: GPUTextureFormat[] | undefined;
1507
+ dimension?: GPUTextureDimension | undefined;
1508
+ mipLevelCount?: number | undefined;
1509
+ sampleCount?: number | undefined;
1510
+ };
1511
+
1512
+ declare const texelFormatToChannelType: {
1513
+ r8unorm: F32;
1514
+ r8snorm: F32;
1515
+ r8uint: U32;
1516
+ r8sint: I32;
1517
+ r16uint: U32;
1518
+ r16sint: I32;
1519
+ r16float: F32;
1520
+ rg8unorm: F32;
1521
+ rg8snorm: F32;
1522
+ rg8uint: U32;
1523
+ rg8sint: I32;
1524
+ r32uint: U32;
1525
+ r32sint: I32;
1526
+ r32float: F32;
1527
+ rg16uint: U32;
1528
+ rg16sint: I32;
1529
+ rg16float: F32;
1530
+ rgba8unorm: F32;
1531
+ 'rgba8unorm-srgb': F32;
1532
+ rgba8snorm: F32;
1533
+ rgba8uint: U32;
1534
+ rgba8sint: I32;
1535
+ bgra8unorm: F32;
1536
+ 'bgra8unorm-srgb': F32;
1537
+ rgb9e5ufloat: F32;
1538
+ rgb10a2uint: U32;
1539
+ rgb10a2unorm: F32;
1540
+ rg11b10ufloat: F32;
1541
+ rg32uint: U32;
1542
+ rg32sint: I32;
1543
+ rg32float: F32;
1544
+ rgba16uint: U32;
1545
+ rgba16sint: I32;
1546
+ rgba16float: F32;
1547
+ rgba32uint: U32;
1548
+ rgba32sint: I32;
1549
+ rgba32float: F32;
1550
+ stencil8: F32;
1551
+ depth16unorm: F32;
1552
+ depth24plus: F32;
1553
+ 'depth24plus-stencil8': F32;
1554
+ depth32float: F32;
1555
+ 'depth32float-stencil8': F32;
1556
+ 'bc1-rgba-unorm': F32;
1557
+ 'bc1-rgba-unorm-srgb': F32;
1558
+ 'bc2-rgba-unorm': F32;
1559
+ 'bc2-rgba-unorm-srgb': F32;
1560
+ 'bc3-rgba-unorm': F32;
1561
+ 'bc3-rgba-unorm-srgb': F32;
1562
+ 'bc4-r-unorm': F32;
1563
+ 'bc4-r-snorm': F32;
1564
+ 'bc5-rg-unorm': F32;
1565
+ 'bc5-rg-snorm': F32;
1566
+ 'bc6h-rgb-ufloat': F32;
1567
+ 'bc6h-rgb-float': F32;
1568
+ 'bc7-rgba-unorm': F32;
1569
+ 'bc7-rgba-unorm-srgb': F32;
1570
+ 'etc2-rgb8unorm': F32;
1571
+ 'etc2-rgb8unorm-srgb': F32;
1572
+ 'etc2-rgb8a1unorm': F32;
1573
+ 'etc2-rgb8a1unorm-srgb': F32;
1574
+ 'etc2-rgba8unorm': F32;
1575
+ 'etc2-rgba8unorm-srgb': F32;
1576
+ 'eac-r11unorm': F32;
1577
+ 'eac-r11snorm': F32;
1578
+ 'eac-rg11unorm': F32;
1579
+ 'eac-rg11snorm': F32;
1580
+ 'astc-4x4-unorm': F32;
1581
+ 'astc-4x4-unorm-srgb': F32;
1582
+ 'astc-5x4-unorm': F32;
1583
+ 'astc-5x4-unorm-srgb': F32;
1584
+ 'astc-5x5-unorm': F32;
1585
+ 'astc-5x5-unorm-srgb': F32;
1586
+ 'astc-6x5-unorm': F32;
1587
+ 'astc-6x5-unorm-srgb': F32;
1588
+ 'astc-6x6-unorm': F32;
1589
+ 'astc-6x6-unorm-srgb': F32;
1590
+ 'astc-8x5-unorm': F32;
1591
+ 'astc-8x5-unorm-srgb': F32;
1592
+ 'astc-8x6-unorm': F32;
1593
+ 'astc-8x6-unorm-srgb': F32;
1594
+ 'astc-8x8-unorm': F32;
1595
+ 'astc-8x8-unorm-srgb': F32;
1596
+ 'astc-10x5-unorm': F32;
1597
+ 'astc-10x5-unorm-srgb': F32;
1598
+ 'astc-10x6-unorm': F32;
1599
+ 'astc-10x6-unorm-srgb': F32;
1600
+ 'astc-10x8-unorm': F32;
1601
+ 'astc-10x8-unorm-srgb': F32;
1602
+ 'astc-10x10-unorm': F32;
1603
+ 'astc-10x10-unorm-srgb': F32;
1604
+ 'astc-12x10-unorm': F32;
1605
+ 'astc-12x10-unorm-srgb': F32;
1606
+ 'astc-12x12-unorm': F32;
1607
+ 'astc-12x12-unorm-srgb': F32;
1608
+ };
1609
+ type TexelFormatToChannelType = typeof texelFormatToChannelType;
1610
+ type TexelFormatToStringChannels = {
1611
+ [Key in keyof TexelFormatToChannelType]: TexelFormatToChannelType[Key]['type'];
1612
+ };
1613
+ type KeysWithValue<T extends Record<string, unknown>, TValue> = keyof {
1614
+ [Key in keyof T as T[Key] extends TValue ? Key : never]: Key;
1615
+ };
1616
+ type ChannelTypeToLegalFormats = {
1617
+ [Key in TexelFormatToChannelType[keyof TexelFormatToChannelType]['type']]: KeysWithValue<TexelFormatToStringChannels, Key>;
1618
+ };
1619
+ type SampleTypeToStringChannelType = {
1620
+ float: 'f32';
1621
+ 'unfilterable-float': 'f32';
1622
+ depth: 'f32';
1623
+ sint: 'i32';
1624
+ uint: 'u32';
1625
+ };
1626
+ type ViewDimensionToDimension = {
1627
+ '1d': '1d';
1628
+ '2d': '2d';
1629
+ '2d-array': '2d';
1630
+ '3d': '3d';
1631
+ cube: '2d';
1632
+ 'cube-array': '2d';
1633
+ };
1634
+ /**
1635
+ * https://www.w3.org/TR/WGSL/#storage-texel-formats
1636
+ */
1637
+ type StorageTextureTexelFormat = 'rgba8unorm' | 'rgba8snorm' | 'rgba8uint' | 'rgba8sint' | 'rgba16uint' | 'rgba16sint' | 'rgba16float' | 'r32uint' | 'r32sint' | 'r32float' | 'rg32uint' | 'rg32sint' | 'rg32float' | 'rgba32uint' | 'rgba32sint' | 'rgba32float' | 'bgra8unorm';
1638
+ declare const texelFormatToDataType: {
1639
+ readonly rgba8unorm: Vec4f;
1640
+ readonly rgba8snorm: Vec4f;
1641
+ readonly rgba8uint: Vec4u;
1642
+ readonly rgba8sint: Vec4i;
1643
+ readonly rgba16uint: Vec4u;
1644
+ readonly rgba16sint: Vec4i;
1645
+ readonly rgba16float: Vec4f;
1646
+ readonly r32uint: Vec4u;
1647
+ readonly r32sint: Vec4i;
1648
+ readonly r32float: Vec4f;
1649
+ readonly rg32uint: Vec4u;
1650
+ readonly rg32sint: Vec4i;
1651
+ readonly rg32float: Vec4f;
1652
+ readonly rgba32uint: Vec4u;
1653
+ readonly rgba32sint: Vec4i;
1654
+ readonly rgba32float: Vec4f;
1655
+ readonly bgra8unorm: Vec4f;
1656
+ };
1657
+ declare const channelFormatToSchema: {
1658
+ float: F32;
1659
+ 'unfilterable-float': F32;
1660
+ uint: U32;
1661
+ sint: I32;
1662
+ depth: F32;
1663
+ };
1664
+ type ChannelFormatToSchema = typeof channelFormatToSchema;
1665
+ type TexelFormatToDataType = typeof texelFormatToDataType;
1666
+ type TexelFormatToDataTypeOrNever<T> = T extends keyof TexelFormatToDataType ? TexelFormatToDataType[T] : never;
1667
+ /**
1668
+ * Represents what formats a storage view can choose from based on its owner texture's props.
1669
+ */
1670
+ type StorageFormatOptions<TProps extends TextureProps> = Extract<TProps['format'] | Default<TProps['viewFormats'], []>[number], StorageTextureTexelFormat>;
1671
+ /**
1672
+ * Represents what formats a sampled view can choose from based on its owner texture's props.
1673
+ */
1674
+ type SampledFormatOptions<TProps extends TextureProps> = TProps['format'] | Default<TProps['viewFormats'], []>[number];
1675
+
1676
+ interface Sampled {
1677
+ usableAsSampled: true;
1678
+ }
1679
+ interface Render {
1680
+ usableAsRender: true;
1681
+ }
1682
+ type LiteralToExtensionMap = {
1683
+ storage: StorageFlag;
1684
+ sampled: Sampled;
1685
+ render: Render;
1686
+ };
1687
+ type AllowedUsages<TProps extends TextureProps> = 'sampled' | 'render' | (TProps['format'] extends StorageTextureTexelFormat ? 'storage' : never);
1688
+ declare function isUsableAsSampled<T>(value: T): value is T & Sampled;
1689
+ declare function isUsableAsRender<T>(value: T): value is T & Render;
1690
+
1691
+ type ResolveStorageDimension<TDimension extends GPUTextureViewDimension, TProps extends TextureProps> = StorageTextureDimension extends TDimension ? Default<TProps['dimension'], '2d'> : TDimension extends StorageTextureDimension ? TDimension : '2d';
1692
+ type ViewUsages$1<TProps extends TextureProps, TTexture extends TgpuTexture<TProps>> = boolean extends TTexture['usableAsSampled'] ? boolean extends TTexture['usableAsStorage'] ? never : 'readonly' | 'writeonly' | 'mutable' : boolean extends TTexture['usableAsStorage'] ? 'sampled' : 'readonly' | 'writeonly' | 'mutable' | 'sampled';
1693
+ interface TextureInternals {
1694
+ unwrap(): GPUTexture;
1695
+ }
1696
+ interface TextureViewInternals {
1697
+ readonly unwrap?: (() => GPUTextureView) | undefined;
1698
+ }
1699
+ type ChannelData = U32 | I32 | F32;
1700
+ type TexelData = Vec4u | Vec4i | Vec4f;
1701
+ /**
1702
+ * @param TProps all properties that distinguish this texture apart from other textures on the type level.
1703
+ */
1704
+ interface TgpuTexture<TProps extends TextureProps = TextureProps> extends TgpuNamable {
1705
+ readonly [$internal]: TextureInternals;
1706
+ readonly resourceType: 'texture';
1707
+ readonly props: TProps;
1708
+ readonly usableAsStorage: boolean;
1709
+ readonly usableAsSampled: boolean;
1710
+ readonly usableAsRender: boolean;
1711
+ $usage<T extends AllowedUsages<TProps>[]>(...usages: T): this & UnionToIntersection<LiteralToExtensionMap[T[number]]>;
1712
+ createView<TUsage extends ViewUsages$1<TProps, this>, TDimension extends 'sampled' extends TUsage ? GPUTextureViewDimension : StorageTextureDimension, TFormat extends 'sampled' extends TUsage ? SampledFormatOptions<TProps> : StorageFormatOptions<TProps>>(access: TUsage, params?: TextureViewParams<TDimension, TFormat>): {
1713
+ mutable: TgpuMutableTexture<ResolveStorageDimension<TDimension, TProps>, TexelFormatToDataTypeOrNever<StorageFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat>>;
1714
+ readonly: TgpuReadonlyTexture<ResolveStorageDimension<TDimension, TProps>, TexelFormatToDataTypeOrNever<StorageFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat>>;
1715
+ writeonly: TgpuWriteonlyTexture<ResolveStorageDimension<TDimension, TProps>, TexelFormatToDataTypeOrNever<StorageFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat>>;
1716
+ sampled: TgpuSampledTexture<GPUTextureViewDimension extends TDimension ? Default<TProps['dimension'], '2d'> : TDimension, TexelFormatToChannelType[SampledFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat]>;
1717
+ }[TUsage];
1718
+ destroy(): void;
1719
+ }
1720
+ type StorageTextureAccess = 'readonly' | 'writeonly' | 'mutable';
1721
+ /**
1722
+ * Based on @see GPUTextureViewDimension
1723
+ * https://www.w3.org/TR/WGSL/#texture-depth
1724
+ */
1725
+ type StorageTextureDimension = '1d' | '2d' | '2d-array' | '3d';
1726
+ type TextureViewParams<TDimension extends GPUTextureViewDimension | undefined, TFormat extends GPUTextureFormat | undefined> = {
1727
+ format?: TFormat;
1728
+ dimension?: TDimension;
1729
+ aspect?: GPUTextureAspect;
1730
+ baseMipLevel?: number;
1731
+ mipLevelCount?: number;
1732
+ baseArrayLayout?: number;
1733
+ arrayLayerCount?: number;
1734
+ };
1735
+ interface TgpuStorageTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> {
1736
+ readonly [$internal]: TextureViewInternals;
1737
+ readonly resourceType: 'texture-storage-view';
1738
+ readonly dimension: TDimension;
1739
+ readonly texelDataType: TData;
1740
+ readonly access: StorageTextureAccess;
1741
+ }
1742
+ /**
1743
+ * A texture accessed as "readonly" storage on the GPU.
1744
+ */
1745
+ interface TgpuReadonlyTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> extends TgpuStorageTexture<TDimension, TData> {
1746
+ readonly access: 'readonly';
1747
+ }
1748
+ /**
1749
+ * A texture accessed as "writeonly" storage on the GPU.
1750
+ */
1751
+ interface TgpuWriteonlyTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> extends TgpuStorageTexture<TDimension, TData> {
1752
+ readonly access: 'writeonly';
1753
+ }
1754
+ /**
1755
+ * A texture accessed as "mutable" (or read_write) storage on the GPU.
1756
+ */
1757
+ interface TgpuMutableTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> extends TgpuStorageTexture<TDimension, TData> {
1758
+ readonly access: 'mutable';
1759
+ }
1760
+ /**
1761
+ * A texture accessed as sampled on the GPU.
1762
+ */
1763
+ interface TgpuSampledTexture<TDimension extends GPUTextureViewDimension = GPUTextureViewDimension, TData extends ChannelData = ChannelData> {
1764
+ readonly [$internal]: TextureViewInternals;
1765
+ readonly resourceType: 'texture-sampled-view';
1766
+ readonly dimension: TDimension;
1767
+ readonly channelDataType: TData;
1768
+ }
1769
+ declare function isTexture<T extends TgpuTexture>(value: unknown | T): value is T;
1770
+ declare function isStorageTextureView<T extends TgpuReadonlyTexture | TgpuWriteonlyTexture | TgpuMutableTexture>(value: unknown | T): value is T;
1771
+ declare function isSampledTextureView<T extends TgpuSampledTexture>(value: unknown | T): value is T;
1772
+ type TgpuAnyTextureView = TgpuReadonlyTexture | TgpuWriteonlyTexture | TgpuMutableTexture | TgpuSampledTexture;
1773
+
1774
+ /**
1775
+ * The array can hold T, where T is a single/multi-component numeric, or a struct with members of type T.
1776
+ * Examples of valid array members:
1777
+ * - Vec3f,
1778
+ * - unorm8x2
1779
+ * - WgslStruct<{ a: Vec3f, b: unorm8x2 }>
1780
+ * - WgslStruct<{ nested: WgslStruct<{ a: Vec3f }> }>
1781
+ */
1782
+ type DataToContainedAttribs<T> = T extends AnyWgslStruct | AnyUnstruct ? {
1783
+ [Key in keyof T['propTypes']]: DataToContainedAttribs<T['propTypes'][Key]>;
1784
+ } : T extends {
1785
+ type: VertexFormat;
1786
+ } ? TgpuVertexAttrib<T['type']> : T extends {
1787
+ type: keyof KindToDefaultFormatMap;
1788
+ } ? TgpuVertexAttrib<KindToDefaultFormatMap[T['type']]> : T extends Decorated<infer TInner> ? DataToContainedAttribs<TInner> : never;
1789
+ /**
1790
+ * Interprets an array as a set of vertex attributes.
1791
+ */
1792
+ type ArrayToContainedAttribs<T extends WgslArray | Disarray> = DataToContainedAttribs<T['elementType']>;
1793
+ type LayoutToAllowedAttribs<T> = T extends {
1794
+ type: keyof KindToAcceptedAttribMap;
1795
+ } ? KindToAcceptedAttribMap[T['type']] : T extends Record<string, unknown> ? {
1796
+ [Key in keyof T]: LayoutToAllowedAttribs<T[Key]>;
1797
+ } : never;
1798
+
1799
+ interface TgpuVertexLayout<TData extends WgslArray | Disarray = WgslArray | Disarray> extends TgpuNamable {
1800
+ readonly resourceType: 'vertex-layout';
1801
+ readonly stride: number;
1802
+ readonly stepMode: 'vertex' | 'instance';
1803
+ readonly attrib: ArrayToContainedAttribs<TData>;
1804
+ readonly vertexLayout: GPUVertexBufferLayout;
1805
+ schemaForCount(n: number): TData;
1806
+ }
1807
+ declare function vertexLayout<TData extends WgslArray | Disarray>(schemaForCount: (count: number) => TData, stepMode?: 'vertex' | 'instance'): TgpuVertexLayout<TData>;
1808
+
1809
+ interface RenderPipelineInternals {
1810
+ readonly core: RenderPipelineCore;
1811
+ readonly priors: TgpuRenderPipelinePriors;
1812
+ }
1813
+ interface TgpuRenderPipeline<Output extends IOLayout = IOLayout> extends TgpuNamable {
1814
+ readonly [$internal]: RenderPipelineInternals;
1815
+ readonly resourceType: 'render-pipeline';
1816
+ with<TData extends WgslArray | Disarray>(vertexLayout: TgpuVertexLayout<TData>, buffer: TgpuBuffer<TData> & VertexFlag): TgpuRenderPipeline<IOLayout>;
1817
+ with<Entries extends Record<string, TgpuLayoutEntry | null>>(bindGroupLayout: TgpuBindGroupLayout<Entries>, bindGroup: TgpuBindGroup<Entries>): TgpuRenderPipeline<IOLayout>;
1818
+ withColorAttachment(attachment: FragmentOutToColorAttachment<Output>): TgpuRenderPipeline<IOLayout>;
1819
+ withDepthStencilAttachment(attachment: DepthStencilAttachment): TgpuRenderPipeline<IOLayout>;
1820
+ draw(vertexCount: number, instanceCount?: number, firstVertex?: number, firstInstance?: number): void;
1821
+ }
1822
+ type FragmentOutToTargets<T extends IOLayout> = T extends IOData ? GPUColorTargetState : T extends Record<string, unknown> ? {
1823
+ [Key in keyof T]: GPUColorTargetState;
1824
+ } : T extends {
1825
+ type: 'void';
1826
+ } ? Record<string, never> : never;
1827
+ type FragmentOutToColorAttachment<T extends IOLayout> = T extends IOData ? ColorAttachment : T extends Record<string, unknown> ? {
1828
+ [Key in keyof T]: ColorAttachment;
1829
+ } : never;
1830
+ type AnyFragmentTargets = GPUColorTargetState | Record<string, GPUColorTargetState>;
1831
+ interface ColorAttachment {
1832
+ /**
1833
+ * A {@link GPUTextureView} describing the texture subresource that will be output to for this
1834
+ * color attachment.
1835
+ */
1836
+ view: (TgpuTexture & Render) | GPUTextureView;
1837
+ /**
1838
+ * Indicates the depth slice index of {@link GPUTextureViewDimension#"3d"} {@link GPURenderPassColorAttachment#view}
1839
+ * that will be output to for this color attachment.
1840
+ */
1841
+ depthSlice?: GPUIntegerCoordinate;
1842
+ /**
1843
+ * A {@link GPUTextureView} describing the texture subresource that will receive the resolved
1844
+ * output for this color attachment if {@link GPURenderPassColorAttachment#view} is
1845
+ * multisampled.
1846
+ */
1847
+ resolveTarget?: GPUTextureView;
1848
+ /**
1849
+ * Indicates the value to clear {@link GPURenderPassColorAttachment#view} to prior to executing the
1850
+ * render pass. If not map/exist|provided, defaults to `{r: 0, g: 0, b: 0, a: 0}`. Ignored
1851
+ * if {@link GPURenderPassColorAttachment#loadOp} is not {@link GPULoadOp#"clear"}.
1852
+ * The components of {@link GPURenderPassColorAttachment#clearValue} are all double values.
1853
+ * They are converted to a texel value of texture format matching the render attachment.
1854
+ * If conversion fails, a validation error is generated.
1855
+ */
1856
+ clearValue?: GPUColor;
1857
+ /**
1858
+ * Indicates the load operation to perform on {@link GPURenderPassColorAttachment#view} prior to
1859
+ * executing the render pass.
1860
+ * Note: It is recommended to prefer clearing; see {@link GPULoadOp#"clear"} for details.
1861
+ */
1862
+ loadOp: GPULoadOp;
1863
+ /**
1864
+ * The store operation to perform on {@link GPURenderPassColorAttachment#view}
1865
+ * after executing the render pass.
1866
+ */
1867
+ storeOp: GPUStoreOp;
1868
+ }
1869
+ interface DepthStencilAttachment {
1870
+ /**
1871
+ * A {@link GPUTextureView} | ({@link TgpuTexture} & {@link Render}) describing the texture subresource that will be output to
1872
+ * and read from for this depth/stencil attachment.
1873
+ */
1874
+ view: (TgpuTexture & Render) | GPUTextureView;
1875
+ /**
1876
+ * Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s depth component
1877
+ * to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#depthLoadOp}
1878
+ * is not {@link GPULoadOp#"clear"}. Must be between 0.0 and 1.0, inclusive (unless unrestricted depth is enabled).
1879
+ */
1880
+ depthClearValue?: number;
1881
+ /**
1882
+ * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
1883
+ * depth component prior to executing the render pass.
1884
+ * Note: It is recommended to prefer clearing; see {@link GPULoadOp#"clear"} for details.
1885
+ */
1886
+ depthLoadOp?: GPULoadOp;
1887
+ /**
1888
+ * The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
1889
+ * depth component after executing the render pass.
1890
+ */
1891
+ depthStoreOp?: GPUStoreOp;
1892
+ /**
1893
+ * Indicates that the depth component of {@link GPURenderPassDepthStencilAttachment#view}
1894
+ * is read only.
1895
+ */
1896
+ depthReadOnly?: boolean;
1897
+ /**
1898
+ * Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s stencil component
1899
+ * to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#stencilLoadOp}
1900
+ * is not {@link GPULoadOp#"clear"}.
1901
+ * The value will be converted to the type of the stencil aspect of `view` by taking the same
1902
+ * number of LSBs as the number of bits in the stencil aspect of one texel block|texel of `view`.
1903
+ */
1904
+ stencilClearValue?: GPUStencilValue;
1905
+ /**
1906
+ * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
1907
+ * stencil component prior to executing the render pass.
1908
+ * Note: It is recommended to prefer clearing; see {@link GPULoadOp#"clear"} for details.
1909
+ */
1910
+ stencilLoadOp?: GPULoadOp;
1911
+ /**
1912
+ * The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
1913
+ * stencil component after executing the render pass.
1914
+ */
1915
+ stencilStoreOp?: GPUStoreOp;
1916
+ /**
1917
+ * Indicates that the stencil component of {@link GPURenderPassDepthStencilAttachment#view}
1918
+ * is read only.
1919
+ */
1920
+ stencilReadOnly?: boolean;
1921
+ }
1922
+ type AnyFragmentColorAttachment = ColorAttachment | Record<string, ColorAttachment>;
1923
+ type RenderPipelineCoreOptions = {
1924
+ branch: ExperimentalTgpuRoot;
1925
+ slotBindings: [TgpuSlot<unknown>, unknown][];
1926
+ vertexAttribs: AnyVertexAttribs;
1927
+ vertexFn: TgpuVertexFn;
1928
+ fragmentFn: TgpuFragmentFn;
1929
+ primitiveState: GPUPrimitiveState | undefined;
1930
+ depthStencilState: GPUDepthStencilState | undefined;
1931
+ targets: AnyFragmentTargets;
1932
+ multisampleState: GPUMultisampleState | undefined;
1933
+ };
1934
+ type TgpuRenderPipelinePriors = {
1935
+ readonly vertexLayoutMap?: Map<TgpuVertexLayout, TgpuBuffer<AnyWgslData> & VertexFlag> | undefined;
1936
+ readonly bindGroupLayoutMap?: Map<TgpuBindGroupLayout, TgpuBindGroup> | undefined;
1937
+ readonly colorAttachment?: AnyFragmentColorAttachment | undefined;
1938
+ readonly depthStencilAttachment?: DepthStencilAttachment | undefined;
1939
+ };
1940
+ type Memo = {
1941
+ pipeline: GPURenderPipeline;
1942
+ bindGroupLayouts: TgpuBindGroupLayout[];
1943
+ catchall: [number, TgpuBindGroup] | null;
1944
+ };
1945
+ declare class RenderPipelineCore {
1946
+ readonly options: RenderPipelineCoreOptions;
1947
+ readonly usedVertexLayouts: TgpuVertexLayout[];
1948
+ private _memo;
1949
+ private readonly _vertexBufferLayouts;
1950
+ private readonly _targets;
1951
+ constructor(options: RenderPipelineCoreOptions);
1952
+ unwrap(): Memo;
1953
+ }
1954
+
1955
+ interface SamplerInternals {
1956
+ readonly unwrap?: ((branch: Unwrapper) => GPUSampler) | undefined;
1957
+ }
1958
+ interface SamplerProps {
1959
+ addressModeU?: GPUAddressMode;
1960
+ addressModeV?: GPUAddressMode;
1961
+ /**
1962
+ * Specifies the address modes for the texture width, height, and depth
1963
+ * coordinates, respectively.
1964
+ */
1965
+ addressModeW?: GPUAddressMode;
1966
+ /**
1967
+ * Specifies the sampling behavior when the sample footprint is smaller than or equal to one
1968
+ * texel.
1969
+ */
1970
+ magFilter?: GPUFilterMode;
1971
+ /**
1972
+ * Specifies the sampling behavior when the sample footprint is larger than one texel.
1973
+ */
1974
+ minFilter?: GPUFilterMode;
1975
+ /**
1976
+ * Specifies behavior for sampling between mipmap levels.
1977
+ */
1978
+ mipmapFilter?: GPUMipmapFilterMode;
1979
+ lodMinClamp?: number;
1980
+ /**
1981
+ * Specifies the minimum and maximum levels of detail, respectively, used internally when
1982
+ * sampling a texture.
1983
+ */
1984
+ lodMaxClamp?: number;
1985
+ /**
1986
+ * Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is
1987
+ * enabled when {@link GPUSamplerDescriptor.maxAnisotropy} is > 1 and the implementation supports it.
1988
+ * Anisotropic filtering improves the image quality of textures sampled at oblique viewing
1989
+ * angles. Higher {@link GPUSamplerDescriptor.maxAnisotropy} values indicate the maximum ratio of
1990
+ * anisotropy supported when filtering.
1991
+ *
1992
+ * Most implementations support {@link GPUSamplerDescriptor.maxAnisotropy} values in range
1993
+ * between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor.maxAnisotropy}
1994
+ * will be clamped to the maximum value that the platform supports.
1995
+ * The precise filtering behavior is implementation-dependent.
1996
+ */
1997
+ maxAnisotropy?: number;
1998
+ }
1999
+ interface ComparisonSamplerProps {
2000
+ compare: GPUCompareFunction;
2001
+ addressModeU?: GPUAddressMode;
2002
+ addressModeV?: GPUAddressMode;
2003
+ /**
2004
+ * Specifies the address modes for the texture width, height, and depth
2005
+ * coordinates, respectively.
2006
+ */
2007
+ addressModeW?: GPUAddressMode;
2008
+ /**
2009
+ * Specifies the sampling behavior when the sample footprint is smaller than or equal to one
2010
+ * texel.
2011
+ */
2012
+ magFilter?: GPUFilterMode;
2013
+ /**
2014
+ * Specifies the sampling behavior when the sample footprint is larger than one texel.
2015
+ */
2016
+ minFilter?: GPUFilterMode;
2017
+ /**
2018
+ * Specifies behavior for sampling between mipmap levels.
2019
+ */
2020
+ mipmapFilter?: GPUMipmapFilterMode;
2021
+ lodMinClamp?: number;
2022
+ /**
2023
+ * Specifies the minimum and maximum levels of detail, respectively, used internally when
2024
+ * sampling a texture.
2025
+ */
2026
+ lodMaxClamp?: number;
2027
+ /**
2028
+ * Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is
2029
+ * enabled when {@link GPUSamplerDescriptor.maxAnisotropy} is > 1 and the implementation supports it.
2030
+ * Anisotropic filtering improves the image quality of textures sampled at oblique viewing
2031
+ * angles. Higher {@link GPUSamplerDescriptor.maxAnisotropy} values indicate the maximum ratio of
2032
+ * anisotropy supported when filtering.
2033
+ *
2034
+ * Most implementations support {@link GPUSamplerDescriptor.maxAnisotropy} values in range
2035
+ * between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor.maxAnisotropy}
2036
+ * will be clamped to the maximum value that the platform supports.
2037
+ * The precise filtering behavior is implementation-dependent.
2038
+ */
2039
+ maxAnisotropy?: number;
2040
+ }
2041
+ interface TgpuSampler {
2042
+ readonly [$internal]: SamplerInternals;
2043
+ readonly resourceType: 'sampler';
2044
+ }
2045
+ interface TgpuComparisonSampler {
2046
+ readonly [$internal]: SamplerInternals;
2047
+ readonly resourceType: 'sampler-comparison';
2048
+ }
2049
+ declare function sampler(props: SamplerProps): TgpuSampler;
2050
+ declare function comparisonSampler(props: ComparisonSamplerProps): TgpuComparisonSampler;
2051
+ declare function isSampler(resource: unknown): resource is TgpuSampler;
2052
+ declare function isComparisonSampler(resource: unknown): resource is TgpuComparisonSampler;
2053
+
2054
+ interface Unwrapper {
2055
+ readonly device: GPUDevice;
2056
+ unwrap(resource: TgpuComputePipeline): GPUComputePipeline;
2057
+ unwrap(resource: TgpuRenderPipeline): GPURenderPipeline;
2058
+ unwrap(resource: TgpuBindGroupLayout): GPUBindGroupLayout;
2059
+ unwrap(resource: TgpuBindGroup): GPUBindGroup;
2060
+ unwrap(resource: TgpuBuffer<AnyData>): GPUBuffer;
2061
+ unwrap(resource: TgpuTexture): GPUTexture;
2062
+ unwrap(resource: TgpuReadonlyTexture | TgpuWriteonlyTexture | TgpuMutableTexture | TgpuSampledTexture): GPUTextureView;
2063
+ unwrap(resource: TgpuVertexLayout): GPUVertexBufferLayout;
2064
+ unwrap(resource: TgpuSampler): GPUSampler;
2065
+ unwrap(resource: TgpuComparisonSampler): GPUSampler;
2066
+ }
2067
+
2068
+ interface WithCompute {
2069
+ createPipeline(): TgpuComputePipeline;
2070
+ }
2071
+ type ValidateFragmentIn<VertexOut extends IORecord, FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = FragmentIn extends Partial<VertexOut> ? VertexOut extends FragmentIn ? [
2072
+ entryFn: TgpuFragmentFn<FragmentIn, FragmentOut>,
2073
+ targets: FragmentOutToTargets<FragmentOut>
2074
+ ] : [
2075
+ entryFn: 'n/a',
2076
+ targets: 'n/a',
2077
+ MissingFromVertexOutput: {
2078
+ [Key in Exclude<keyof FragmentIn, keyof VertexOut>]: FragmentIn[Key];
2079
+ }
2080
+ ] : [
2081
+ entryFn: 'n/a',
2082
+ targets: 'n/a',
2083
+ MismatchedVertexOutput: {
2084
+ [Key in keyof FragmentIn & keyof VertexOut as FragmentIn[Key] extends VertexOut[Key] ? never : Key]: [got: VertexOut[Key], expecting: FragmentIn[Key]];
2085
+ }
2086
+ ];
2087
+ interface WithVertex<VertexOut extends IORecord = IORecord> {
2088
+ withFragment<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained>(...args: ValidateFragmentIn<VertexOut, FragmentIn, FragmentOut>): WithFragment<FragmentOut>;
2089
+ }
2090
+ interface WithFragment<Output extends FragmentOutConstrained = FragmentOutConstrained> {
2091
+ withPrimitive(primitiveState: GPUPrimitiveState | undefined): WithFragment<Output>;
2092
+ withDepthStencil(depthStencilState: GPUDepthStencilState | undefined): WithFragment<Output>;
2093
+ withMultisample(multisampleState: GPUMultisampleState | undefined): WithFragment<Output>;
2094
+ createPipeline(): TgpuRenderPipeline<Output>;
2095
+ }
2096
+ interface WithBinding {
2097
+ with<T>(slot: TgpuSlot<T>, value: Eventual<T>): WithBinding;
2098
+ with<T extends AnyWgslData>(accessor: TgpuAccessor<T>, value: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>): WithBinding;
2099
+ withCompute(entryFn: TgpuComputeFn): WithCompute;
2100
+ withVertex<VertexIn extends IOLayout, VertexOut extends IORecord>(entryFn: TgpuVertexFn<VertexIn, VertexOut>, attribs: LayoutToAllowedAttribs<OmitBuiltins<VertexIn>>): WithVertex<VertexOut>;
2101
+ }
2102
+ type CreateTextureOptions<TSize, TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormat extends GPUTextureFormat, TDimension extends GPUTextureDimension> = {
2103
+ /**
2104
+ * The width, height, and depth or layer count of the texture.
2105
+ */
2106
+ size: TSize;
2107
+ /**
2108
+ * The format of the texture.
2109
+ */
2110
+ format: TFormat;
2111
+ /**
2112
+ * The number of mip levels the texture will contain.
2113
+ * @default 1
2114
+ */
2115
+ mipLevelCount?: TMipLevelCount | undefined;
2116
+ /**
2117
+ * The sample count of the texture. A sampleCount > 1 indicates a multisampled texture.
2118
+ * @default 1
2119
+ */
2120
+ sampleCount?: TSampleCount | undefined;
2121
+ /**
2122
+ * Specifies extra formats (in addition to the texture's actual format) that can be used
2123
+ * when creating views of this texture.
2124
+ * @default []
2125
+ */
2126
+ viewFormats?: TViewFormat[] | undefined;
2127
+ /**
2128
+ * Whether the texture is one-dimensional, an array of two-dimensional layers, or three-dimensional.
2129
+ * @default '2d'
2130
+ */
2131
+ dimension?: TDimension | undefined;
2132
+ };
2133
+ type CreateTextureResult<TSize extends readonly number[], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormat extends GPUTextureFormat, TDimension extends GPUTextureDimension> = Prettify<{
2134
+ size: Mutable<TSize>;
2135
+ format: TFormat;
2136
+ } & OmitProps<{
2137
+ dimension: GPUTextureDimension extends TDimension ? undefined : TDimension extends '2d' ? undefined : TDimension;
2138
+ mipLevelCount: number extends TMipLevelCount ? undefined : TMipLevelCount extends 1 ? undefined : TMipLevelCount;
2139
+ sampleCount: number extends TSampleCount ? undefined : TSampleCount extends 1 ? undefined : TSampleCount;
2140
+ viewFormats: GPUTextureFormat extends TViewFormat ? undefined : TViewFormat[] extends never[] ? undefined : TViewFormat[];
2141
+ }, undefined>>;
2142
+ interface RenderPass {
2143
+ /**
2144
+ * Sets the viewport used during the rasterization stage to linearly map from
2145
+ * NDC (i.e., normalized device coordinates) to viewport coordinates.
2146
+ * @param x - Minimum X value of the viewport in pixels.
2147
+ * @param y - Minimum Y value of the viewport in pixels.
2148
+ * @param width - Width of the viewport in pixels.
2149
+ * @param height - Height of the viewport in pixels.
2150
+ * @param minDepth - Minimum depth value of the viewport.
2151
+ * @param maxDepth - Maximum depth value of the viewport.
2152
+ */
2153
+ setViewport(x: number, y: number, width: number, height: number, minDepth: number, maxDepth: number): void;
2154
+ /**
2155
+ * Sets the scissor rectangle used during the rasterization stage.
2156
+ * After transformation into viewport coordinates any fragments which fall outside the scissor
2157
+ * rectangle will be discarded.
2158
+ * @param x - Minimum X value of the scissor rectangle in pixels.
2159
+ * @param y - Minimum Y value of the scissor rectangle in pixels.
2160
+ * @param width - Width of the scissor rectangle in pixels.
2161
+ * @param height - Height of the scissor rectangle in pixels.
2162
+ */
2163
+ setScissorRect(x: number, y: number, width: number, height: number): void;
2164
+ /**
2165
+ * Sets the constant blend color and alpha values used with {@link GPUBlendFactor#constant}
2166
+ * and {@link GPUBlendFactor#"one-minus-constant"} {@link GPUBlendFactor}s.
2167
+ * @param color - The color to use when blending.
2168
+ */
2169
+ setBlendConstant(color: GPUColor): void;
2170
+ /**
2171
+ * Sets the {@link RenderState#[[stencilReference]]} value used during stencil tests with
2172
+ * the {@link GPUStencilOperation#"replace"} {@link GPUStencilOperation}.
2173
+ * @param reference - The new stencil reference value.
2174
+ */
2175
+ setStencilReference(reference: GPUStencilValue): undefined;
2176
+ /**
2177
+ * @param queryIndex - The index of the query in the query set.
2178
+ */
2179
+ beginOcclusionQuery(queryIndex: GPUSize32): undefined;
2180
+ endOcclusionQuery(): undefined;
2181
+ /**
2182
+ * Executes the commands previously recorded into the given {@link GPURenderBundle}s as part of
2183
+ * this render pass.
2184
+ * When a {@link GPURenderBundle} is executed, it does not inherit the render pass's pipeline, bind
2185
+ * groups, or vertex and index buffers. After a {@link GPURenderBundle} has executed, the render
2186
+ * pass's pipeline, bind group, and vertex/index buffer state is cleared
2187
+ * (to the initial, empty values).
2188
+ * Note: The state is cleared, not restored to the previous state.
2189
+ * This occurs even if zero {@link GPURenderBundle|GPURenderBundles} are executed.
2190
+ * @param bundles - List of render bundles to execute.
2191
+ */
2192
+ executeBundles(bundles: Iterable<GPURenderBundle>): undefined;
2193
+ setPipeline(pipeline: TgpuRenderPipeline): void;
2194
+ /**
2195
+ * Sets the current index buffer.
2196
+ * @param buffer - Buffer containing index data to use for subsequent drawing commands.
2197
+ * @param indexFormat - Format of the index data contained in `buffer`.
2198
+ * @param offset - Offset in bytes into `buffer` where the index data begins. Defaults to `0`.
2199
+ * @param size - Size in bytes of the index data in `buffer`.
2200
+ * Defaults to the size of the buffer minus the offset.
2201
+ */
2202
+ setIndexBuffer<TData extends WgslArray | Disarray>(buffer: TgpuBuffer<TData> | GPUBuffer, indexFormat: GPUIndexFormat, offset?: GPUSize64, size?: GPUSize64): void;
2203
+ setVertexBuffer<TData extends WgslArray | Disarray>(vertexLayout: TgpuVertexLayout<TData>, buffer: (TgpuBuffer<TData> & VertexFlag) | GPUBuffer, offset?: GPUSize64, size?: GPUSize64): void;
2204
+ setBindGroup<Entries extends Record<string, TgpuLayoutEntry | null>>(bindGroupLayout: TgpuBindGroupLayout<Entries>, bindGroup: TgpuBindGroup<Entries> | GPUBindGroup): void;
2205
+ /**
2206
+ * Draws primitives.
2207
+ * @param vertexCount - The number of vertices to draw.
2208
+ * @param instanceCount - The number of instances to draw.
2209
+ * @param firstVertex - Offset into the vertex buffers, in vertices, to begin drawing from.
2210
+ * @param firstInstance - First instance to draw.
2211
+ */
2212
+ draw(vertexCount: number, instanceCount?: number | undefined, firstVertex?: number | undefined, firstInstance?: number | undefined): void;
2213
+ /**
2214
+ * Draws indexed primitives.
2215
+ * @param indexCount - The number of indices to draw.
2216
+ * @param instanceCount - The number of instances to draw.
2217
+ * @param firstIndex - Offset into the index buffer, in indices, begin drawing from.
2218
+ * @param baseVertex - Added to each index value before indexing into the vertex buffers.
2219
+ * @param firstInstance - First instance to draw.
2220
+ */
2221
+ drawIndexed(indexCount: number, instanceCount?: number | undefined, firstIndex?: number | undefined, baseVertex?: number | undefined, firstInstance?: number | undefined): void;
2222
+ /**
2223
+ * Draws primitives using parameters read from a {@link GPUBuffer}.
2224
+ * Packed block of **four 32-bit unsigned integer values (16 bytes total)**, given in the same
2225
+ * order as the arguments for {@link GPURenderEncoderBase#draw}. For example:
2226
+ * @param indirectBuffer - Buffer containing the indirect draw parameters.
2227
+ * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.
2228
+ */
2229
+ drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): undefined;
2230
+ /**
2231
+ * Draws indexed primitives using parameters read from a {@link GPUBuffer}.
2232
+ * Tightly packed block of **five 32-bit unsigned integer values (20 bytes total)**, given in
2233
+ * the same order as the arguments for {@link GPURenderEncoderBase#drawIndexed}. For example:
2234
+ * @param indirectBuffer - Buffer containing the indirect drawIndexed parameters.
2235
+ * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.
2236
+ */
2237
+ drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): undefined;
2238
+ }
2239
+ interface TgpuRoot extends Unwrapper {
2240
+ /**
2241
+ * The GPU device associated with this root.
2242
+ */
2243
+ readonly device: GPUDevice;
2244
+ /**
2245
+ * Allocates memory on the GPU, allows passing data between host and shader.
2246
+ *
2247
+ * @remarks
2248
+ * Typed wrapper around a GPUBuffer.
2249
+ *
2250
+ * @param typeSchema The type of data that this buffer will hold.
2251
+ * @param initial The initial value of the buffer. (optional)
2252
+ */
2253
+ createBuffer<TData extends AnyData>(typeSchema: TData, initial?: Infer<TData> | undefined): TgpuBuffer<TData>;
2254
+ /**
2255
+ * Allocates memory on the GPU, allows passing data between host and shader.
2256
+ *
2257
+ * @remarks
2258
+ * Typed wrapper around a GPUBuffer.
2259
+ *
2260
+ * @param typeSchema The type of data that this buffer will hold.
2261
+ * @param gpuBuffer A vanilla WebGPU buffer.
2262
+ */
2263
+ createBuffer<TData extends AnyData>(typeSchema: TData, gpuBuffer: GPUBuffer): TgpuBuffer<TData>;
2264
+ /**
2265
+ * Creates a group of resources that can be bound to a shader based on a specified layout.
2266
+ *
2267
+ * @remarks
2268
+ * Typed wrapper around a GPUBindGroup.
2269
+ *
2270
+ * @example
2271
+ * const fooLayout = tgpu.bindGroupLayout({
2272
+ * foo: { uniform: d.vec3f },
2273
+ * bar: { texture: 'float' },
2274
+ * });
2275
+ *
2276
+ * const fooBuffer = ...;
2277
+ * const barTexture = ...;
2278
+ *
2279
+ * const fooBindGroup = root.createBindGroup(fooLayout, {
2280
+ * foo: fooBuffer,
2281
+ * bar: barTexture,
2282
+ * });
2283
+ *
2284
+ * @param layout Layout describing the bind group to be created.
2285
+ * @param entries A record with values being the resources populating the bind group
2286
+ * and keys being their associated names, matching the layout keys.
2287
+ */
2288
+ createBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>>(layout: TgpuBindGroupLayout<Entries>, entries: {
2289
+ [K in keyof OmitProps<Entries, null>]: LayoutEntryToInput<Entries[K]>;
2290
+ }): TgpuBindGroup<Entries>;
2291
+ /**
2292
+ * Destroys all underlying resources (i.e. buffers...) created through this root object.
2293
+ * If the object is created via `tgpu.init` instead of `tgpu.initFromDevice`,
2294
+ * then the inner GPU device is destroyed as well.
2295
+ */
2296
+ destroy(): void;
2297
+ '~unstable': Omit<ExperimentalTgpuRoot, keyof TgpuRoot>;
2298
+ }
2299
+ interface ExperimentalTgpuRoot extends TgpuRoot, WithBinding {
2300
+ readonly jitTranspiler?: JitTranspiler | undefined;
2301
+ readonly nameRegistry: NameRegistry;
2302
+ /**
2303
+ * The current command encoder. This property will
2304
+ * hold the same value until `flush()` is called.
2305
+ */
2306
+ readonly commandEncoder: GPUCommandEncoder;
2307
+ createUniform<TData extends AnyWgslData>(typeSchema: TData, initialOrBuffer?: Infer<TData> | GPUBuffer): TgpuBufferUniform<TData> & TgpuFixedBufferUsage<TData>;
2308
+ createMutable<TData extends AnyWgslData>(typeSchema: TData, initialOrBuffer?: Infer<TData> | GPUBuffer): TgpuBufferMutable<TData> & TgpuFixedBufferUsage<TData>;
2309
+ createReadonly<TData extends AnyWgslData>(typeSchema: TData, initialOrBuffer?: Infer<TData> | GPUBuffer): TgpuBufferReadonly<TData> & TgpuFixedBufferUsage<TData>;
2310
+ createTexture<TWidth extends number, THeight extends number, TDepth extends number, TSize extends readonly [TWidth] | readonly [TWidth, THeight] | readonly [TWidth, THeight, TDepth], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormat extends GPUTextureFormat, TDimension extends GPUTextureDimension>(props: CreateTextureOptions<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormat, TDimension>): TgpuTexture<CreateTextureResult<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormat, TDimension>>;
2311
+ beginRenderPass(descriptor: GPURenderPassDescriptor, callback: (pass: RenderPass) => void): void;
2312
+ /**
2313
+ * Causes all commands enqueued by pipelines to be
2314
+ * submitted to the GPU.
2315
+ */
2316
+ flush(): void;
2317
+ }
2318
+
2319
+ interface UniformFlag {
2320
+ usableAsUniform: true;
2321
+ }
2322
+ /**
2323
+ * @deprecated Use UniformFlag instead.
2324
+ */
2325
+ type Uniform = UniformFlag;
2326
+ interface VertexFlag {
2327
+ usableAsVertex: true;
2328
+ }
2329
+ /**
2330
+ * @deprecated Use VertexFlag instead.
2331
+ */
2332
+ type Vertex = VertexFlag;
2333
+ type LiteralToUsageType<T extends 'uniform' | 'storage' | 'vertex'> = T extends 'uniform' ? UniformFlag : T extends 'storage' ? StorageFlag : T extends 'vertex' ? VertexFlag : never;
2334
+ type ViewUsages<TBuffer extends TgpuBuffer<BaseData>> = (boolean extends TBuffer['usableAsUniform'] ? never : 'uniform') | (boolean extends TBuffer['usableAsStorage'] ? never : 'readonly' | 'mutable');
2335
+ type UsageTypeToBufferUsage<TData extends BaseData> = {
2336
+ uniform: TgpuBufferUniform<TData> & TgpuFixedBufferUsage<TData>;
2337
+ mutable: TgpuBufferMutable<TData> & TgpuFixedBufferUsage<TData>;
2338
+ readonly: TgpuBufferReadonly<TData> & TgpuFixedBufferUsage<TData>;
2339
+ };
2340
+ interface TgpuBuffer<TData extends BaseData> extends TgpuNamable {
2341
+ readonly resourceType: 'buffer';
2342
+ readonly dataType: TData;
2343
+ readonly initial?: Infer<TData> | undefined;
2344
+ readonly buffer: GPUBuffer;
2345
+ readonly destroyed: boolean;
2346
+ usableAsUniform: boolean;
2347
+ usableAsStorage: boolean;
2348
+ usableAsVertex: boolean;
2349
+ $usage<T extends RestrictVertexUsages<TData>>(...usages: T): this & UnionToIntersection<LiteralToUsageType<T[number]>>;
2350
+ $addFlags(flags: GPUBufferUsageFlags): this;
2351
+ as<T extends ViewUsages<this>>(usage: T): UsageTypeToBufferUsage<TData>[T];
2352
+ compileWriter(): void;
2353
+ write(data: Infer<TData>): void;
2354
+ writePartial(data: InferPartial<TData>): void;
2355
+ copyFrom(srcBuffer: TgpuBuffer<MemIdentity<TData>>): void;
2356
+ read(): Promise<Infer<TData>>;
2357
+ destroy(): void;
2358
+ }
2359
+ declare function isBuffer<T extends TgpuBuffer<AnyData>>(value: T | unknown): value is T;
2360
+ declare function isUsableAsVertex<T extends TgpuBuffer<AnyData>>(buffer: T): buffer is T & VertexFlag;
2361
+ type RestrictVertexUsages<TData extends BaseData> = TData extends {
2362
+ readonly type: WgslTypeLiteral;
2363
+ } ? ('uniform' | 'storage' | 'vertex')[] : 'vertex'[];
2364
+
2365
+ type TgpuLayoutEntryBase = {
2366
+ /**
2367
+ * Limits this resource's visibility to specific shader stages.
2368
+ *
2369
+ * By default, each resource is visible to all shader stage types, but
2370
+ * depending on the underlying implementation, this may have performance implications.
2371
+ *
2372
+ * @default ['compute'] for mutable resources
2373
+ * @default ['compute','vertex','fragment'] for everything else
2374
+ */
2375
+ visibility?: TgpuShaderStage[];
2376
+ };
2377
+ type TgpuLayoutUniform = TgpuLayoutEntryBase & {
2378
+ uniform: AnyWgslData;
2379
+ };
2380
+ type TgpuLayoutStorage = TgpuLayoutEntryBase & {
2381
+ storage: AnyWgslData | ((arrayLength: number) => AnyWgslData);
2382
+ /** @default 'readonly' */
2383
+ access?: 'mutable' | 'readonly';
2384
+ };
2385
+ type TgpuLayoutSampler = TgpuLayoutEntryBase & {
2386
+ sampler: 'filtering' | 'non-filtering';
2387
+ };
2388
+ type TgpuLayoutComparisonSampler = TgpuLayoutEntryBase & {
2389
+ sampler: 'comparison';
2390
+ };
2391
+ type TgpuLayoutTexture<TSampleType extends GPUTextureSampleType = GPUTextureSampleType> = TgpuLayoutEntryBase & {
2392
+ /**
2393
+ * - 'float' - f32
2394
+ * - 'unfilterable-float' - f32, cannot be used with filtering samplers
2395
+ * - 'depth' - f32
2396
+ * - 'sint' - i32
2397
+ * - 'uint' - u32
2398
+ */
2399
+ texture: TSampleType;
2400
+ /**
2401
+ * @default '2d'
2402
+ */
2403
+ viewDimension?: GPUTextureViewDimension;
2404
+ /**
2405
+ * @default false
2406
+ */
2407
+ multisampled?: boolean;
2408
+ };
2409
+ type TgpuLayoutStorageTexture<TFormat extends StorageTextureTexelFormat = StorageTextureTexelFormat> = TgpuLayoutEntryBase & {
2410
+ storageTexture: TFormat;
2411
+ /** @default 'writeonly' */
2412
+ access?: 'readonly' | 'writeonly' | 'mutable';
2413
+ /** @default '2d' */
2414
+ viewDimension?: StorageTextureDimension;
2415
+ };
2416
+ type TgpuLayoutExternalTexture = TgpuLayoutEntryBase & {
2417
+ externalTexture: Record<string, never>;
2418
+ };
2419
+ type TgpuLayoutEntry = TgpuLayoutUniform | TgpuLayoutStorage | TgpuLayoutSampler | TgpuLayoutComparisonSampler | TgpuLayoutTexture | TgpuLayoutStorageTexture | TgpuLayoutExternalTexture;
2420
+ type UnwrapRuntimeConstructorInner<T extends BaseData | ((_: number) => BaseData)> = T extends (_: number) => BaseData ? ReturnType<T> : T;
2421
+ type UnwrapRuntimeConstructor<T extends AnyData | ((_: number) => AnyData)> = T extends unknown ? UnwrapRuntimeConstructorInner<T> : never;
2422
+ interface TgpuBindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>> extends TgpuNamable {
2423
+ readonly resourceType: 'bind-group-layout';
2424
+ readonly entries: Entries;
2425
+ readonly bound: {
2426
+ [K in keyof Entries]: BindLayoutEntry<Entries[K]>;
2427
+ };
2428
+ readonly value: {
2429
+ [K in keyof Entries]: InferLayoutEntry<Entries[K]>;
2430
+ };
2431
+ readonly $: {
2432
+ [K in keyof Entries]: InferLayoutEntry<Entries[K]>;
2433
+ };
2434
+ /**
2435
+ * An explicit numeric index assigned to this bind group layout. If undefined, a unique
2436
+ * index is assigned automatically during resolution. This can be changed with the
2437
+ * `.$idx()` method.
2438
+ */
2439
+ readonly index: number | undefined;
2440
+ /**
2441
+ * Associates this bind group layout with an explicit numeric index. When a call to this
2442
+ * method is omitted, a unique numeric index is assigned to it automatically.
2443
+ *
2444
+ * Used when generating WGSL code: `@group(${index}) @binding(...) ...;`
2445
+ */
2446
+ $idx(index?: number): this;
2447
+ /**
2448
+ * Creates a raw WebGPU resource based on the typed descriptor.
2449
+ * NOTE: This creates a new resource every time, better to use `root.unwrap(...)` instead.
2450
+ * @param unwrapper Used to unwrap any resources that this resource depends on.
2451
+ */
2452
+ unwrap(unwrapper: Unwrapper): GPUBindGroupLayout;
2453
+ }
2454
+ type StorageUsageForEntry<T extends TgpuLayoutStorage> = T extends {
2455
+ access?: infer Access;
2456
+ } ? 'mutable' | 'readonly' extends Access ? TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>> | TgpuBufferMutable<UnwrapRuntimeConstructor<T['storage']>> : 'readonly' extends Access ? TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>> : 'mutable' extends Access ? TgpuBufferMutable<UnwrapRuntimeConstructor<T['storage']>> : TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>> | TgpuBufferMutable<UnwrapRuntimeConstructor<T['storage']>> : TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>>;
2457
+ type GetUsageForStorageTexture<T extends TgpuLayoutStorageTexture, TAccess extends 'readonly' | 'writeonly' | 'mutable'> = {
2458
+ mutable: TgpuMutableTexture<Default<GetDimension<T['viewDimension']>, '2d'>, TexelFormatToDataType[T['storageTexture']]>;
2459
+ readonly: TgpuReadonlyTexture<Default<GetDimension<T['viewDimension']>, '2d'>, TexelFormatToDataType[T['storageTexture']]>;
2460
+ writeonly: TgpuWriteonlyTexture<Default<GetDimension<T['viewDimension']>, '2d'>, TexelFormatToDataType[T['storageTexture']]>;
2461
+ }[TAccess];
2462
+ type StorageTextureUsageForEntry<T extends TgpuLayoutStorageTexture> = T extends unknown ? GetUsageForStorageTexture<T, Default<T['access'], 'writeonly'>> : never;
2463
+ type GetDimension<T extends GPUTextureViewDimension | undefined> = T extends keyof ViewDimensionToDimension ? ViewDimensionToDimension[T] : undefined;
2464
+ type GetTextureRestriction<T extends TgpuLayoutTexture> = Default<GetDimension<T['viewDimension']>, '2d'> extends infer Dimension ? Dimension extends '2d' ? {
2465
+ format: ChannelTypeToLegalFormats[SampleTypeToStringChannelType[T['texture']]];
2466
+ dimension?: Dimension;
2467
+ } : {
2468
+ format: ChannelTypeToLegalFormats[SampleTypeToStringChannelType[T['texture']]];
2469
+ dimension: Dimension;
2470
+ } : never;
2471
+ type GetStorageTextureRestriction<T extends TgpuLayoutStorageTexture> = Default<GetDimension<T['viewDimension']>, '2d'> extends infer Dimension ? Dimension extends '2d' ? {
2472
+ format: T['storageTexture'];
2473
+ dimension?: Dimension;
2474
+ } : {
2475
+ format: T['storageTexture'];
2476
+ dimension: Dimension;
2477
+ } : never;
2478
+ type LayoutEntryToInput<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? (TgpuBuffer<UnwrapRuntimeConstructor<T['uniform']>> & UniformFlag) | GPUBuffer : T extends TgpuLayoutStorage ? (TgpuBuffer<UnwrapRuntimeConstructor<T['storage']>> & StorageFlag) | GPUBuffer : T extends TgpuLayoutSampler ? TgpuSampler | GPUSampler : T extends TgpuLayoutComparisonSampler ? TgpuComparisonSampler | GPUSampler : T extends TgpuLayoutTexture ? GPUTextureView | (Sampled & TgpuTexture<Prettify<TextureProps & GetTextureRestriction<T>>>) | TgpuSampledTexture<Default<T['viewDimension'], '2d'>, ChannelFormatToSchema[T['texture']]> : T extends TgpuLayoutStorageTexture ? GPUTextureView | (StorageFlag & TgpuTexture<Prettify<TextureProps & GetStorageTextureRestriction<T>>>) | StorageTextureUsageForEntry<T> : T extends TgpuLayoutExternalTexture ? GPUExternalTexture : never;
2479
+ type BindLayoutEntry<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? TgpuBufferUniform<T['uniform']> : T extends TgpuLayoutStorage ? StorageUsageForEntry<T> : T extends TgpuLayoutSampler ? TgpuSampler : T extends TgpuLayoutComparisonSampler ? TgpuComparisonSampler : T extends TgpuLayoutTexture ? TgpuSampledTexture<Default<T['viewDimension'], '2d'>, ChannelFormatToSchema[T['texture']]> : T extends TgpuLayoutStorageTexture ? StorageTextureUsageForEntry<T> : never;
2480
+ type InferLayoutEntry<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? Infer<T['uniform']> : T extends TgpuLayoutStorage ? Infer<UnwrapRuntimeConstructor<T['storage']>> : T extends TgpuLayoutSampler ? TgpuSampler : T extends TgpuLayoutComparisonSampler ? TgpuComparisonSampler : T extends TgpuLayoutTexture ? TgpuSampledTexture<Default<T['viewDimension'], '2d'>, ChannelFormatToSchema[T['texture']]> : T extends TgpuLayoutStorageTexture ? StorageTextureUsageForEntry<T> : never;
2481
+ type ExtractBindGroupInputFromLayout<T extends Record<string, TgpuLayoutEntry | null>> = {
2482
+ [K in keyof T]: LayoutEntryToInput<T[K]>;
2483
+ };
2484
+ type TgpuBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>> = {
2485
+ readonly resourceType: 'bind-group';
2486
+ readonly layout: TgpuBindGroupLayout<Entries>;
2487
+ unwrap(unwrapper: Unwrapper): GPUBindGroup;
2488
+ };
2489
+ declare function bindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | null>>(entries: Entries): TgpuBindGroupLayout<Prettify<Entries>>;
2490
+
2491
+ interface TgpuBufferUsage<TData extends BaseData = BaseData, TUsage extends BindableBufferUsage = BindableBufferUsage> {
2492
+ readonly resourceType: 'buffer-usage';
2493
+ readonly usage: TUsage;
2494
+ readonly [$repr]: Infer<TData>;
2495
+ value: InferGPU<TData>;
2496
+ readonly [$internal]: {
2497
+ readonly dataType: TData;
2498
+ };
2499
+ }
2500
+ interface TgpuBufferUniform<TData extends BaseData> extends TgpuBufferUsage<TData, 'uniform'> {
2501
+ readonly value: InferGPU<TData>;
2502
+ }
2503
+ interface TgpuBufferReadonly<TData extends BaseData> extends TgpuBufferUsage<TData, 'readonly'> {
2504
+ readonly value: InferGPU<TData>;
2505
+ }
2506
+ interface TgpuFixedBufferUsage<TData extends BaseData> extends TgpuNamable {
2507
+ readonly buffer: TgpuBuffer<TData>;
2508
+ write(data: Infer<TData>): void;
2509
+ }
2510
+ interface TgpuBufferMutable<TData extends BaseData> extends TgpuBufferUsage<TData, 'mutable'> {
2511
+ }
2512
+ declare function isUsableAsUniform<T extends TgpuBuffer<AnyData>>(buffer: T): buffer is T & UniformFlag;
2513
+ /**
2514
+ * @deprecated Use buffer.as('mutable') instead.
2515
+ */
2516
+ declare function asMutable<TData extends AnyWgslData>(buffer: TgpuBuffer<TData> & StorageFlag): TgpuBufferMutable<TData> & TgpuFixedBufferUsage<TData>;
2517
+ /**
2518
+ * @deprecated Use buffer.as('readonly') instead.
2519
+ */
2520
+ declare function asReadonly<TData extends AnyWgslData>(buffer: TgpuBuffer<TData> & StorageFlag): TgpuBufferReadonly<TData> & TgpuFixedBufferUsage<TData>;
2521
+ /**
2522
+ * @deprecated Use buffer.as('uniform') instead.
2523
+ */
2524
+ declare function asUniform<TData extends AnyWgslData>(buffer: TgpuBuffer<TData> & UniformFlag): TgpuBufferUniform<TData> & TgpuFixedBufferUsage<TData>;
2525
+
2526
+ interface TgpuExternalTexture {
2527
+ readonly resourceType: 'external-texture';
2528
+ }
2529
+
2530
+ type VariableScope = 'private' | 'workgroup';
2531
+ interface TgpuVar<TScope extends VariableScope = VariableScope, TDataType extends AnyWgslData = AnyWgslData> extends TgpuNamable {
2532
+ value: Infer<TDataType>;
2533
+ readonly scope: TScope;
2534
+ }
2535
+ /**
2536
+ * Defines a variable scoped to each entry function (private).
2537
+ *
2538
+ * @param dataType The schema of the held data's type
2539
+ * @param initialValue If not provided, the variable will be initialized to the dataType's "zero-value".
2540
+ */
2541
+ declare function privateVar<TDataType extends AnyWgslData>(dataType: TDataType, initialValue?: Infer<TDataType>): TgpuVar<'private', TDataType>;
2542
+ /**
2543
+ * Defines a variable scoped to the whole workgroup, shared between entry functions
2544
+ * of the same invocation.
2545
+ *
2546
+ * @param dataType The schema of the held data's type
2547
+ */
2548
+ declare function workgroupVar<TDataType extends AnyWgslData>(dataType: TDataType): TgpuVar<'workgroup', TDataType>;
2549
+
2550
+ type ResolvableObject = SelfResolvable | TgpuBufferUsage | TgpuConst | TgpuDeclare | TgpuFn | TgpuComputeFn | TgpuFragmentFn | TgpuComputePipeline | TgpuRenderPipeline | TgpuVertexFn | TgpuSampler | TgpuAccessor | TgpuExternalTexture | TgpuTexture | TgpuAnyTextureView | TgpuVar | AnyVecInstance | AnyMatInstance | AnyData | TgpuFn<any, any>;
2551
+ type Wgsl = Eventual<string | number | boolean | ResolvableObject>;
2552
+ declare const UnknownData: {
2553
+ type: "unknown";
2554
+ };
2555
+ type UnknownData = typeof UnknownData;
2556
+ type Snippet = {
2557
+ value: unknown;
2558
+ dataType: AnyData | UnknownData;
2559
+ };
2560
+ type TgpuShaderStage = 'compute' | 'vertex' | 'fragment';
2561
+ interface FnToWgslOptions {
2562
+ args: Snippet[];
2563
+ returnType: AnyWgslData;
2564
+ body: Block;
2565
+ externalMap: Record<string, unknown>;
2566
+ }
2567
+ type ItemLayer = {
2568
+ type: 'item';
2569
+ usedSlots: Set<TgpuSlot<unknown>>;
2570
+ };
2571
+ interface ItemStateStack {
2572
+ readonly itemDepth: number;
2573
+ readonly topItem: ItemLayer;
2574
+ pushItem(): void;
2575
+ popItem(): void;
2576
+ pushSlotBindings(pairs: SlotValuePair<unknown>[]): void;
2577
+ popSlotBindings(): void;
2578
+ pushFunctionScope(args: Snippet[], returnType: AnyWgslData | undefined, externalMap: Record<string, unknown>): void;
2579
+ popFunctionScope(): void;
2580
+ pushBlockScope(): void;
2581
+ popBlockScope(): void;
2582
+ pop(type?: 'functionScope' | 'blockScope' | 'slotBinding' | 'item'): void;
2583
+ readSlot<T>(slot: TgpuSlot<T>): T | undefined;
2584
+ getSnippetById(id: string): Snippet | undefined;
2585
+ defineBlockVariable(id: string, type: AnyWgslData | UnknownData): Snippet;
2586
+ }
2587
+ /**
2588
+ * Passed into each resolvable item. All items in a tree share a resolution ctx,
2589
+ * but there can be layers added and removed from the item stack when going down
2590
+ * and up the tree.
2591
+ */
2592
+ interface ResolutionCtx {
2593
+ readonly names: NameRegistry;
2594
+ addDeclaration(declaration: string): void;
2595
+ /**
2596
+ * Reserves a bind group number, and returns a placeholder that will be replaced
2597
+ * with a concrete number at the end of the resolution process.
2598
+ */
2599
+ allocateLayoutEntry(layout: TgpuBindGroupLayout): string;
2600
+ /**
2601
+ * Reserves a spot in the catch-all bind group, without the indirection of a bind-group.
2602
+ * This means the resource is 'fixed', and cannot be swapped between code execution.
2603
+ */
2604
+ allocateFixedEntry(layoutEntry: TgpuLayoutEntry, resource: object): {
2605
+ group: string;
2606
+ binding: number;
2607
+ };
2608
+ withSlots<T>(pairs: SlotValuePair<unknown>[], callback: () => T): T;
2609
+ /**
2610
+ * Unwraps all layers of slot/derived indirection and returns the concrete value if available.
2611
+ * @throws {MissingSlotValueError}
2612
+ */
2613
+ unwrap<T>(eventual: Eventual<T>): T;
2614
+ resolve(item: unknown): string;
2615
+ resolveValue<T extends BaseData>(value: Infer<T>, schema: T): string;
2616
+ transpileFn(fn: string): {
2617
+ argNames: ArgNames;
2618
+ body: Block;
2619
+ externalNames: string[];
2620
+ };
2621
+ fnToWgsl(options: FnToWgslOptions): {
2622
+ head: Wgsl;
2623
+ body: Wgsl;
2624
+ };
2625
+ [$internal]: {
2626
+ itemStateStack: ItemStateStack;
2627
+ };
2628
+ }
2629
+ /**
2630
+ * Houses a method '~resolve` that returns a code string
2631
+ * representing it, as opposed to offloading the resolution
2632
+ * to another mechanism.
2633
+ */
2634
+ interface SelfResolvable {
2635
+ '~resolve'(ctx: ResolutionCtx): string;
2636
+ toString(): string;
2637
+ }
2638
+ type BindableBufferUsage = 'uniform' | 'readonly' | 'mutable';
2639
+ type DefaultConversionStrategy = 'keep' | 'coerce';
2640
+ type FnArgsConversionHint = AnyWgslData[] | Record<string, AnyWgslData> | ((...args: Snippet[]) => AnyWgslData[]) | DefaultConversionStrategy | undefined;
2641
+
2642
+ type FormatToWGSLType<T extends VertexFormat> = (typeof formatToWGSLType)[T];
2643
+ interface TgpuVertexFormatData<T extends VertexFormat> {
2644
+ readonly [$internal]: true;
2645
+ readonly type: T;
2646
+ readonly [$repr]: Infer<FormatToWGSLType<T>>;
2647
+ }
2648
+ declare const formatToWGSLType: {
2649
+ readonly uint8: U32;
2650
+ readonly uint8x2: Vec2u;
2651
+ readonly uint8x4: Vec4u;
2652
+ readonly sint8: I32;
2653
+ readonly sint8x2: Vec2i;
2654
+ readonly sint8x4: Vec4i;
2655
+ readonly unorm8: F32;
2656
+ readonly unorm8x2: Vec2f;
2657
+ readonly unorm8x4: Vec4f;
2658
+ readonly snorm8: F32;
2659
+ readonly snorm8x2: Vec2f;
2660
+ readonly snorm8x4: Vec4f;
2661
+ readonly uint16: U32;
2662
+ readonly uint16x2: Vec2u;
2663
+ readonly uint16x4: Vec4u;
2664
+ readonly sint16: I32;
2665
+ readonly sint16x2: Vec2i;
2666
+ readonly sint16x4: Vec4i;
2667
+ readonly unorm16: F32;
2668
+ readonly unorm16x2: Vec2f;
2669
+ readonly unorm16x4: Vec4f;
2670
+ readonly snorm16: F32;
2671
+ readonly snorm16x2: Vec2f;
2672
+ readonly snorm16x4: Vec4f;
2673
+ readonly float16: F32;
2674
+ readonly float16x2: Vec2f;
2675
+ readonly float16x4: Vec4f;
2676
+ readonly float32: F32;
2677
+ readonly float32x2: Vec2f;
2678
+ readonly float32x3: Vec3f;
2679
+ readonly float32x4: Vec4f;
2680
+ readonly uint32: U32;
2681
+ readonly uint32x2: Vec2u;
2682
+ readonly uint32x3: Vec3u;
2683
+ readonly uint32x4: Vec4u;
2684
+ readonly sint32: I32;
2685
+ readonly sint32x2: Vec2i;
2686
+ readonly sint32x3: Vec3i;
2687
+ readonly sint32x4: Vec4i;
2688
+ readonly 'unorm10-10-10-2': Vec4f;
2689
+ readonly 'unorm8x4-bgra': Vec4f;
2690
+ };
2691
+ declare const packedFormats: string[];
2692
+ type uint8 = TgpuVertexFormatData<'uint8'>;
2693
+ declare const uint8: uint8;
2694
+ type uint8x2 = TgpuVertexFormatData<'uint8x2'>;
2695
+ declare const uint8x2: uint8x2;
2696
+ type uint8x4 = TgpuVertexFormatData<'uint8x4'>;
2697
+ declare const uint8x4: uint8x4;
2698
+ type sint8 = TgpuVertexFormatData<'sint8'>;
2699
+ declare const sint8: sint8;
2700
+ type sint8x2 = TgpuVertexFormatData<'sint8x2'>;
2701
+ declare const sint8x2: sint8x2;
2702
+ type sint8x4 = TgpuVertexFormatData<'sint8x4'>;
2703
+ declare const sint8x4: sint8x4;
2704
+ type unorm8 = TgpuVertexFormatData<'unorm8'>;
2705
+ declare const unorm8: unorm8;
2706
+ type unorm8x2 = TgpuVertexFormatData<'unorm8x2'>;
2707
+ declare const unorm8x2: unorm8x2;
2708
+ type unorm8x4 = TgpuVertexFormatData<'unorm8x4'>;
2709
+ declare const unorm8x4: unorm8x4;
2710
+ type snorm8 = TgpuVertexFormatData<'snorm8'>;
2711
+ declare const snorm8: snorm8;
2712
+ type snorm8x2 = TgpuVertexFormatData<'snorm8x2'>;
2713
+ declare const snorm8x2: snorm8x2;
2714
+ type snorm8x4 = TgpuVertexFormatData<'snorm8x4'>;
2715
+ declare const snorm8x4: snorm8x4;
2716
+ type uint16 = TgpuVertexFormatData<'uint16'>;
2717
+ declare const uint16: uint16;
2718
+ type uint16x2 = TgpuVertexFormatData<'uint16x2'>;
2719
+ declare const uint16x2: uint16x2;
2720
+ type uint16x4 = TgpuVertexFormatData<'uint16x4'>;
2721
+ declare const uint16x4: uint16x4;
2722
+ type sint16 = TgpuVertexFormatData<'sint16'>;
2723
+ declare const sint16: sint16;
2724
+ type sint16x2 = TgpuVertexFormatData<'sint16x2'>;
2725
+ declare const sint16x2: sint16x2;
2726
+ type sint16x4 = TgpuVertexFormatData<'sint16x4'>;
2727
+ declare const sint16x4: sint16x4;
2728
+ type unorm16 = TgpuVertexFormatData<'unorm16'>;
2729
+ declare const unorm16: unorm16;
2730
+ type unorm16x2 = TgpuVertexFormatData<'unorm16x2'>;
2731
+ declare const unorm16x2: unorm16x2;
2732
+ type unorm16x4 = TgpuVertexFormatData<'unorm16x4'>;
2733
+ declare const unorm16x4: unorm16x4;
2734
+ type snorm16 = TgpuVertexFormatData<'snorm16'>;
2735
+ declare const snorm16: snorm16;
2736
+ type snorm16x2 = TgpuVertexFormatData<'snorm16x2'>;
2737
+ declare const snorm16x2: snorm16x2;
2738
+ type snorm16x4 = TgpuVertexFormatData<'snorm16x4'>;
2739
+ declare const snorm16x4: snorm16x4;
2740
+ type float16 = TgpuVertexFormatData<'float16'>;
2741
+ declare const float16: float16;
2742
+ type float16x2 = TgpuVertexFormatData<'float16x2'>;
2743
+ declare const float16x2: float16x2;
2744
+ type float16x4 = TgpuVertexFormatData<'float16x4'>;
2745
+ declare const float16x4: float16x4;
2746
+ type float32 = TgpuVertexFormatData<'float32'>;
2747
+ declare const float32: float32;
2748
+ type float32x2 = TgpuVertexFormatData<'float32x2'>;
2749
+ declare const float32x2: float32x2;
2750
+ type float32x3 = TgpuVertexFormatData<'float32x3'>;
2751
+ declare const float32x3: float32x3;
2752
+ type float32x4 = TgpuVertexFormatData<'float32x4'>;
2753
+ declare const float32x4: float32x4;
2754
+ type uint32 = TgpuVertexFormatData<'uint32'>;
2755
+ declare const uint32: uint32;
2756
+ type uint32x2 = TgpuVertexFormatData<'uint32x2'>;
2757
+ declare const uint32x2: uint32x2;
2758
+ type uint32x3 = TgpuVertexFormatData<'uint32x3'>;
2759
+ declare const uint32x3: uint32x3;
2760
+ type uint32x4 = TgpuVertexFormatData<'uint32x4'>;
2761
+ declare const uint32x4: uint32x4;
2762
+ type sint32 = TgpuVertexFormatData<'sint32'>;
2763
+ declare const sint32: sint32;
2764
+ type sint32x2 = TgpuVertexFormatData<'sint32x2'>;
2765
+ declare const sint32x2: sint32x2;
2766
+ type sint32x3 = TgpuVertexFormatData<'sint32x3'>;
2767
+ declare const sint32x3: sint32x3;
2768
+ type sint32x4 = TgpuVertexFormatData<'sint32x4'>;
2769
+ declare const sint32x4: sint32x4;
2770
+ type unorm10_10_10_2 = TgpuVertexFormatData<'unorm10-10-10-2'>;
2771
+ declare const unorm10_10_10_2: unorm10_10_10_2;
2772
+ type unorm8x4_bgra = TgpuVertexFormatData<'unorm8x4-bgra'>;
2773
+ declare const unorm8x4_bgra: unorm8x4_bgra;
2774
+ 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;
2775
+
2776
+ type TgpuDualFn<TImpl extends (...args: unknown[]) => unknown> = TImpl & {
2777
+ [$internal]: {
2778
+ implementation: TImpl | string;
2779
+ argTypes: FnArgsConversionHint;
2780
+ };
2781
+ };
2782
+ /**
2783
+ * Array schema constructed via `d.disarrayOf` function.
2784
+ *
2785
+ * Useful for defining vertex buffers.
2786
+ * Elements in the schema are not aligned in respect to their `byteAlignment`,
2787
+ * unless they are explicitly decorated with the custom align attribute
2788
+ * via `d.align` function.
2789
+ */
2790
+ interface Disarray<TElement extends BaseData = BaseData> {
2791
+ readonly [$internal]: true;
2792
+ readonly type: 'disarray';
2793
+ readonly elementCount: number;
2794
+ readonly elementType: TElement;
2795
+ readonly [$repr]: Infer<TElement>[];
2796
+ readonly '~reprPartial': {
2797
+ idx: number;
2798
+ value: InferPartial<TElement>;
2799
+ }[] | undefined;
2800
+ }
2801
+ /**
2802
+ * Struct schema constructed via `d.unstruct` function.
2803
+ *
2804
+ * Useful for defining vertex buffers, as the standard layout restrictions do not apply.
2805
+ * Members are not aligned in respect to their `byteAlignment`,
2806
+ * unless they are explicitly decorated with the custom align attribute
2807
+ * via `d.align` function.
2808
+ */
2809
+ interface Unstruct<TProps extends Record<string, BaseData> = Record<string, BaseData>> extends TgpuNamable {
2810
+ readonly [$internal]: true;
2811
+ (props: Prettify<InferRecord<TProps>>): Prettify<InferRecord<TProps>>;
2812
+ readonly type: 'unstruct';
2813
+ readonly propTypes: TProps;
2814
+ readonly [$repr]: Prettify<InferRecord<TProps>>;
2815
+ readonly '~gpuRepr': Prettify<InferGPURecord<TProps>>;
2816
+ readonly '~memIdent': Unstruct<Prettify<MemIdentityRecord<TProps>>>;
2817
+ readonly '~reprPartial': Prettify<Partial<InferPartialRecord<TProps>>> | undefined;
2818
+ }
2819
+ type AnyUnstruct = Unstruct<any>;
2820
+ interface LooseDecorated<TInner extends BaseData = BaseData, TAttribs extends unknown[] = unknown[]> {
2821
+ readonly [$internal]: true;
2822
+ readonly type: 'loose-decorated';
2823
+ readonly inner: TInner;
2824
+ readonly attribs: TAttribs;
2825
+ readonly [$repr]: Infer<TInner>;
2826
+ }
2827
+ 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"];
2828
+ type LooseTypeLiteral = (typeof looseTypeLiterals)[number];
2829
+ type AnyLooseData = Disarray | AnyUnstruct | LooseDecorated | PackedData;
2830
+ declare function isLooseData(data: unknown): data is AnyLooseData;
2831
+ /**
2832
+ * Checks whether the passed in value is a disarray schema,
2833
+ * as opposed to, e.g., a regular array schema.
2834
+ *
2835
+ * Array schemas can be used to describe uniform and storage buffers,
2836
+ * whereas disarray schemas cannot. Disarrays are useful for
2837
+ * defining vertex buffers instead.
2838
+ *
2839
+ * @example
2840
+ * isDisarray(d.arrayOf(d.u32, 4)) // false
2841
+ * isDisarray(d.disarrayOf(d.u32, 4)) // true
2842
+ * isDisarray(d.vec3f) // false
2843
+ */
2844
+ declare function isDisarray<T extends Disarray>(schema: T | unknown): schema is T;
2845
+ /**
2846
+ * Checks whether passed in value is a unstruct schema,
2847
+ * as opposed to, e.g., a struct schema.
2848
+ *
2849
+ * Struct schemas can be used to describe uniform and storage buffers,
2850
+ * whereas unstruct schemas cannot. Unstructs are useful for
2851
+ * defining vertex buffers instead.
2852
+ *
2853
+ * @example
2854
+ * isUnstruct(d.struct({ a: d.u32 })) // false
2855
+ * isUnstruct(d.unstruct({ a: d.u32 })) // true
2856
+ * isUnstruct(d.vec3f) // false
2857
+ */
2858
+ declare function isUnstruct<T extends Unstruct>(schema: T | unknown): schema is T;
2859
+ declare function isLooseDecorated<T extends LooseDecorated>(value: T | unknown): value is T;
2860
+ declare function isData(value: unknown): value is AnyData;
2861
+ type AnyData = AnyWgslData | AnyLooseData;
2862
+
2863
+ 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"];
2864
+ type BuiltinName = (typeof builtinNames)[number];
2865
+ type AnyAttribute<AllowedBuiltins extends Builtin<BuiltinName> = Builtin<BuiltinName>> = Align<number> | Size<number> | Location<number> | Interpolate<InterpolationType> | AllowedBuiltins;
2866
+ type ExtractAttributes<T> = T extends {
2867
+ readonly attribs: unknown[];
2868
+ } ? T['attribs'] : [];
2869
+ type Undecorate<T> = T extends {
2870
+ readonly inner: infer TInner;
2871
+ } ? TInner : T;
2872
+ /**
2873
+ * Decorates a data-type `TData` with an attribute `TAttrib`.
2874
+ *
2875
+ * - if `TData` is loose
2876
+ * - if `TData` is already `LooseDecorated`
2877
+ * - Prepend `TAttrib` to the existing attribute tuple.
2878
+ * - else
2879
+ * - Wrap `TData` with `LooseDecorated` and a single attribute `[TAttrib]`
2880
+ * - else
2881
+ * - if `TData` is already `Decorated`
2882
+ * - Prepend `TAttrib` to the existing attribute tuple.
2883
+ * - else
2884
+ * - Wrap `TData` with `Decorated` and a single attribute `[TAttrib]`
2885
+ */
2886
+ 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;
2887
+ type IsBuiltin<T> = ExtractAttributes<T>[number] extends [] ? false : ExtractAttributes<T>[number] extends Builtin<BuiltinName> ? true : false;
2888
+ type HasCustomLocation<T> = ExtractAttributes<T>[number] extends [] ? false : ExtractAttributes<T>[number] extends Location<number> ? true : false;
2889
+ /**
2890
+ * Gives the wrapped data-type a custom byte alignment. Useful in order to
2891
+ * fulfill uniform alignment requirements.
2892
+ *
2893
+ * @example
2894
+ * const Data = d.struct({
2895
+ * a: u32, // takes up 4 bytes
2896
+ * // 12 bytes of padding, because `b` is custom aligned to multiples of 16 bytes
2897
+ * b: d.align(16, u32),
2898
+ * });
2899
+ *
2900
+ * @param alignment The multiple of bytes this data should align itself to.
2901
+ * @param data The data-type to align.
2902
+ */
2903
+ declare function align<TAlign extends number, TData extends AnyData>(alignment: TAlign, data: TData): Decorate<TData, Align<TAlign>>;
2904
+ /**
2905
+ * Adds padding bytes after the wrapped data-type, until the whole value takes up `size` bytes.
2906
+ *
2907
+ * @example
2908
+ * const Data = d.struct({
2909
+ * a: d.size(16, u32), // takes up 16 bytes, instead of 4
2910
+ * b: u32, // starts at byte 16, because `a` has a custom size
2911
+ * });
2912
+ *
2913
+ * @param size The amount of bytes that should be reserved for this data-type.
2914
+ * @param data The data-type to wrap.
2915
+ */
2916
+ declare function size<TSize extends number, TData extends AnyData>(size: TSize, data: TData): Decorate<TData, Size<TSize>>;
2917
+ /**
2918
+ * Assigns an explicit numeric location to a struct member or a parameter that has this type.
2919
+ *
2920
+ * @example
2921
+ * const VertexOutput = {
2922
+ * a: d.u32, // has implicit location 0
2923
+ * b: d.location(5, d.u32),
2924
+ * c: d.u32, // has implicit location 6
2925
+ * };
2926
+ *
2927
+ * @param location The explicit numeric location.
2928
+ * @param data The data-type to wrap.
2929
+ */
2930
+ declare function location<TLocation extends number, TData extends AnyData>(location: TLocation, data: TData): Decorate<TData, Location<TLocation>>;
2931
+ /**
2932
+ * Specifies how user-defined vertex shader output (fragment shader input)
2933
+ * must be interpolated.
2934
+ *
2935
+ * Tip: Integer outputs cannot be interpolated.
2936
+ *
2937
+ * @example
2938
+ * const VertexOutput = {
2939
+ * a: d.f32, // has implicit 'perspective, center' interpolation
2940
+ * b: d.interpolate('linear, sample', d.f32),
2941
+ * };
2942
+ *
2943
+ * @param interpolationType How data should be interpolated.
2944
+ * @param data The data-type to wrap.
2945
+ */
2946
+ declare function interpolate<TInterpolation extends PerspectiveOrLinearInterpolationType, TData extends PerspectiveOrLinearInterpolatableData>(interpolationType: TInterpolation, data: TData): Decorate<TData, Interpolate<TInterpolation>>;
2947
+ /**
2948
+ * Specifies how user-defined vertex shader output (fragment shader input)
2949
+ * must be interpolated.
2950
+ *
2951
+ * Tip: Default sampling method of `flat` is `first`. Unless you specifically
2952
+ * need deterministic behavior provided by `'flat, first'`, prefer explicit
2953
+ * `'flat, either'` as it could be slightly faster in hardware.
2954
+ *
2955
+ * @example
2956
+ * const VertexOutput = {
2957
+ * a: d.f32, // has implicit 'perspective, center' interpolation
2958
+ * b: d.interpolate('flat, either', d.u32), // integer outputs cannot interpolate
2959
+ * };
2960
+ *
2961
+ * @param interpolationType How data should be interpolated.
2962
+ * @param data The data-type to wrap.
2963
+ */
2964
+ declare function interpolate<TInterpolation extends FlatInterpolationType, TData extends FlatInterpolatableData>(interpolationType: TInterpolation, data: TData): Decorate<TData, Interpolate<TInterpolation>>;
2965
+ declare function isBuiltin<T extends Decorated<AnyWgslData, AnyAttribute[]> | LooseDecorated<AnyLooseData, AnyAttribute[]>>(value: T | unknown): value is T;
2966
+
2967
+ /**
2968
+ * Information extracted from transpiling a JS function.
2969
+ */
2970
+ type TranspilationResult = {
2971
+ argNames: tinyest.ArgNames;
2972
+ body: tinyest.Block;
2973
+ /**
2974
+ * All identifiers found in the function code that are not declared in the
2975
+ * function itself, or in the block that is accessing that identifier.
2976
+ */
2977
+ externalNames: string[];
2978
+ };
2979
+ type InferArgs<T extends unknown[]> = {
2980
+ [Idx in keyof T]: Infer<T[Idx]>;
2981
+ };
2982
+ type InferReturn<T> = T extends undefined ? void : Infer<T>;
2983
+ type JsImplementation<Args extends unknown[] | Record<string, unknown> = unknown[] | Record<string, unknown>, Return = unknown> = (...args: Args extends unknown[] ? InferArgs<Args> : Args extends Record<string, never> ? [] : [InferIO<Args>]) => InferReturn<Return>;
2984
+ type Implementation<Args extends unknown[] | Record<string, unknown> = unknown[] | Record<string, unknown>, Return = unknown> = string | JsImplementation<Args, Return>;
2985
+ type BaseIOData = F32 | F16 | I32 | U32 | Vec2f | Vec3f | Vec4f | Vec2h | Vec3h | Vec4h | Vec2i | Vec3i | Vec4i | Vec2u | Vec3u | Vec4u;
2986
+ type IOData = BaseIOData | Decorated<BaseIOData, AnyAttribute[]>;
2987
+ type IORecord<TElementType extends IOData = IOData> = Record<string, TElementType>;
2988
+ /**
2989
+ * Used for I/O definitions of entry functions.
2990
+ */
2991
+ type IOLayout<TElementType extends IOData = IOData> = TElementType | IORecord<TElementType> | Void;
2992
+ type InferIO<T> = T extends {
2993
+ type: string;
2994
+ } ? Infer<T> : T extends Record<string, unknown> ? {
2995
+ [K in keyof T]: Infer<T[K]>;
2996
+ } : T;
2997
+
2998
+ /**
2999
+ * Describes a compute entry function signature (its arguments, return type and workgroup size)
3000
+ */
3001
+ type TgpuComputeFnShellHeader<ComputeIn extends Record<string, AnyComputeBuiltin>> = {
3002
+ readonly argTypes: [AnyWgslStruct] | [];
3003
+ readonly returnType: undefined;
3004
+ readonly workgroupSize: [number, number, number];
3005
+ readonly isEntry: true;
3006
+ };
3007
+ /**
3008
+ * Describes a compute entry function signature (its arguments, return type and workgroup size).
3009
+ * Allows creating tgpu compute functions by calling this shell
3010
+ * and passing the implementation (as WGSL string or JS function) as the argument.
3011
+ */
3012
+ type TgpuComputeFnShell<ComputeIn extends Record<string, AnyComputeBuiltin>> = TgpuComputeFnShellHeader<ComputeIn> /**
3013
+ * Creates a type-safe implementation of this signature
3014
+ */ & ((implementation: (input: InferIO<ComputeIn>) => undefined) => TgpuComputeFn<ComputeIn>) & /**
3015
+ * @param implementation
3016
+ * Raw WGSL function implementation with header and body
3017
+ * without `fn` keyword and function name
3018
+ * e.g. `"(x: f32) -> f32 { return x; }"`;
3019
+ */ ((implementation: string) => TgpuComputeFn<ComputeIn>) & ((strings: TemplateStringsArray, ...values: unknown[]) => TgpuComputeFn<ComputeIn>) & {
3020
+ /**
3021
+ * @deprecated Invoke the shell as a function instead.
3022
+ */
3023
+ does: ((implementation: (input: InferIO<ComputeIn>) => undefined) => TgpuComputeFn<ComputeIn>) & /**
3024
+ * @param implementation
3025
+ * Raw WGSL function implementation with header and body
3026
+ * without `fn` keyword and function name
3027
+ * e.g. `"(x: f32) -> f32 { return x; }"`;
3028
+ */ ((implementation: string) => TgpuComputeFn<ComputeIn>);
3029
+ };
3030
+ interface TgpuComputeFn<ComputeIn extends Record<string, AnyComputeBuiltin> = Record<string, AnyComputeBuiltin>> extends TgpuNamable {
3031
+ readonly shell: TgpuComputeFnShell<ComputeIn>;
3032
+ $uses(dependencyMap: Record<string, unknown>): this;
3033
+ }
3034
+ declare function computeFn(options: {
3035
+ workgroupSize: number[];
3036
+ }): TgpuComputeFnShell<{}>;
3037
+ declare function computeFn<ComputeIn extends Record<string, AnyComputeBuiltin>>(options: {
3038
+ in: ComputeIn;
3039
+ workgroupSize: number[];
3040
+ }): TgpuComputeFnShell<ComputeIn>;
3041
+
3042
+ export { type TgpuRenderPipeline as $, type AnyWgslData as A, isComparisonSampler as B, isSampler as C, type Disarray as D, isSampledTextureView as E, isStorageTextureView as F, isTexture as G, isUsableAsRender as H, type Infer as I, type JitTranspiler as J, isUsableAsSampled as K, isUsableAsStorage as L, asMutable as M, asReadonly as N, asUniform as O, isUsableAsUniform as P, isTgpuFn as Q, RandomNameRegistry as R, StrictNameRegistry as S, type TgpuRoot as T, type WithBinding as U, type WithCompute as V, type Wgsl as W, type WithFragment as X, type WithVertex as Y, type Storage as Z, type StorageFlag as _, type TgpuFn as a, type Vec4u as a$, type TgpuComputePipeline as a0, type Uniform as a1, type UniformFlag as a2, type Vertex as a3, type VertexFlag as a4, type TgpuBufferMutable as a5, type TgpuBufferReadonly as a6, type TgpuBufferUniform as a7, type Eventual as a8, type TgpuAnyTextureView as a9, type TgpuVertexFnShell as aA, type TgpuFragmentFn as aB, type TgpuFragmentFnShell as aC, type TgpuComputeFn as aD, type TgpuComputeFnShell as aE, type TgpuDeclare as aF, type Bool as aG, type F16 as aH, type F32 as aI, type I32 as aJ, type U32 as aK, type WgslStruct as aL, type Ptr as aM, type Vec2b as aN, type Vec2f as aO, type Vec2h as aP, type Vec2i as aQ, type Vec2u as aR, type Vec3b as aS, type Vec3f as aT, type Vec3h as aU, type Vec3i as aV, type Vec3u as aW, type Vec4b as aX, type Vec4f as aY, type Vec4h as aZ, type Vec4i as a_, type TgpuMutableTexture as aa, type TgpuReadonlyTexture as ab, type TgpuSampledTexture as ac, type TgpuTexture as ad, type TgpuWriteonlyTexture as ae, type TextureProps as af, type Render as ag, type Sampled as ah, type TgpuConst as ai, type TgpuVar as aj, type VariableScope as ak, type TgpuSampler as al, type BindLayoutEntry as am, type ExtractBindGroupInputFromLayout as an, type LayoutEntryToInput as ao, type TgpuBindGroup as ap, type TgpuLayoutComparisonSampler as aq, type TgpuLayoutEntry as ar, type TgpuLayoutExternalTexture as as, type TgpuLayoutSampler as at, type TgpuLayoutStorage as au, type TgpuLayoutStorageTexture as av, type TgpuLayoutTexture as aw, type TgpuLayoutUniform as ax, type TgpuFnShell as ay, type TgpuVertexFn as az, type TgpuBufferUsage as b, type BuiltinLocalInvocationIndex as b$, type BaseData as b0, type Unstruct as b1, type Mat2x2f as b2, type Mat3x3f as b3, type Mat4x4f as b4, type m2x2f as b5, type m3x3f as b6, type m4x4f as b7, type Atomic as b8, isAlignAttrib as b9, type v4b as bA, type v4f as bB, type v4i as bC, type v4u as bD, type AnyLooseData as bE, type LooseDecorated as bF, align as bG, type AnyAttribute as bH, type HasCustomLocation as bI, interpolate as bJ, type IsBuiltin as bK, isBuiltin as bL, location as bM, size as bN, isData as bO, isDisarray as bP, isLooseData as bQ, isLooseDecorated as bR, isUnstruct as bS, builtin as bT, type AnyBuiltin as bU, type BuiltinClipDistances as bV, type BuiltinFragDepth as bW, type BuiltinFrontFacing as bX, type BuiltinGlobalInvocationId as bY, type BuiltinInstanceIndex as bZ, type BuiltinLocalInvocationId as b_, isAtomic as ba, isBuiltinAttrib as bb, isDecorated as bc, isInterpolateAttrib as bd, isLocationAttrib as be, isPtr as bf, isSizeAttrib as bg, isWgslArray as bh, isWgslData as bi, isWgslStruct as bj, type Align as bk, type AnyVecInstance as bl, type AnyWgslStruct as bm, type Builtin as bn, type Decorated as bo, type Interpolate as bp, type Location as bq, type Size as br, type v2b as bs, type v2f as bt, type v2i as bu, type v2u as bv, type v3b as bw, type v3f as bx, type v3i as by, type v3u as bz, type TgpuAccessor as c, type AnyVec3Instance as c$, type BuiltinNumWorkgroups as c0, type BuiltinPosition as c1, type BuiltinSampleIndex as c2, type BuiltinSampleMask as c3, type BuiltinVertexIndex as c4, type BuiltinWorkgroupId as c5, type InferGPU as c6, type InferPartial as c7, type FormatToWGSLType as c8, type TgpuVertexFormatData as c9, float16 as cA, float16x2 as cB, float16x4 as cC, float32 as cD, float32x2 as cE, float32x3 as cF, float32x4 as cG, uint32 as cH, uint32x2 as cI, uint32x3 as cJ, uint32x4 as cK, sint32 as cL, sint32x2 as cM, sint32x3 as cN, sint32x4 as cO, unorm10_10_10_2 as cP, unorm8x4_bgra as cQ, type PackedData as cR, type TgpuDualFn as cS, type AnyNumericVecInstance as cT, type AnyMatInstance as cU, type vBaseForMat as cV, type AnyFloatVecInstance as cW, type v3h as cX, type v2h as cY, type v4h as cZ, type AnyVec2Instance as c_, formatToWGSLType as ca, packedFormats as cb, uint8 as cc, uint8x2 as cd, uint8x4 as ce, sint8 as cf, sint8x2 as cg, sint8x4 as ch, unorm8 as ci, unorm8x2 as cj, unorm8x4 as ck, snorm8 as cl, snorm8x2 as cm, snorm8x4 as cn, uint16 as co, uint16x2 as cp, uint16x4 as cq, sint16 as cr, sint16x2 as cs, sint16x4 as ct, unorm16 as cu, unorm16x2 as cv, unorm16x4 as cw, snorm16 as cx, snorm16x2 as cy, snorm16x4 as cz, type TgpuDerived as d, type AnyBooleanVecInstance as d0, type atomicI32 as d1, type atomicU32 as d2, type TgpuStorageTexture as d3, type TexelData as d4, type ChannelData as d5, type TgpuSlot as e, type TgpuBindGroupLayout as f, type TgpuVertexLayout as g, type WgslArray as h, type TgpuBuffer as i, type AnyData as j, bindGroupLayout as k, fn as l, fragmentFn as m, vertexFn as n, computeFn as o, privateVar as p, constant as q, declare as r, sampler as s, comparisonSampler as t, isBuffer as u, vertexLayout as v, workgroupVar as w, isUsableAsVertex as x, isDerived as y, isSlot as z };