typegpu 0.7.0 → 0.7.1

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.
@@ -36,6 +36,10 @@ interface TgpuNamable {
36
36
  }
37
37
 
38
38
  declare const $internal: unique symbol;
39
+ /**
40
+ * The getter to the value of this resource, accessible on the GPU
41
+ */
42
+ declare const $gpuValueOf: unique symbol;
39
43
  /**
40
44
  * Marks an object with slot-value bindings
41
45
  */
@@ -99,6 +103,324 @@ type Mutable<T> = {
99
103
  -readonly [P in keyof T]: T[P];
100
104
  };
101
105
 
106
+ interface Snippet {
107
+ readonly value: unknown;
108
+ readonly dataType: AnyData | UnknownData;
109
+ }
110
+ type MapValueToSnippet<T> = {
111
+ [K in keyof T]: Snippet;
112
+ };
113
+
114
+ 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"];
115
+ type VertexFormat = (typeof vertexFormats)[number];
116
+ declare const kindToDefaultFormatMap: {
117
+ readonly f32: "float32";
118
+ readonly vec2f: "float32x2";
119
+ readonly vec3f: "float32x3";
120
+ readonly vec4f: "float32x4";
121
+ readonly f16: "float16";
122
+ readonly vec2h: "float16x2";
123
+ readonly vec4h: "float16x4";
124
+ readonly u32: "uint32";
125
+ readonly vec2u: "uint32x2";
126
+ readonly vec3u: "uint32x3";
127
+ readonly vec4u: "uint32x4";
128
+ readonly i32: "sint32";
129
+ readonly vec2i: "sint32x2";
130
+ readonly vec3i: "sint32x3";
131
+ readonly vec4i: "sint32x4";
132
+ };
133
+ type KindToDefaultFormatMap = typeof kindToDefaultFormatMap;
134
+ interface TgpuVertexAttrib<TFormat extends VertexFormat = VertexFormat> {
135
+ readonly format: TFormat;
136
+ readonly offset: number;
137
+ }
138
+ type AnyVertexAttribs = Record<string, TgpuVertexAttrib> | TgpuVertexAttrib;
139
+ /**
140
+ * All vertex attribute formats that can be interpreted as
141
+ * an single or multi component u32 in a shader.
142
+ * https://www.w3.org/TR/webgpu/#vertex-formats
143
+ */
144
+ type U32CompatibleFormats = TgpuVertexAttrib<'uint8'> | TgpuVertexAttrib<'uint8x2'> | TgpuVertexAttrib<'uint8x4'> | TgpuVertexAttrib<'uint16'> | TgpuVertexAttrib<'uint16x2'> | TgpuVertexAttrib<'uint16x4'> | TgpuVertexAttrib<'uint32'> | TgpuVertexAttrib<'uint32x2'> | TgpuVertexAttrib<'uint32x3'> | TgpuVertexAttrib<'uint32x4'>;
145
+ /**
146
+ * All vertex attribute formats that can be interpreted as
147
+ * an single or multi component i32 in a shader.
148
+ * https://www.w3.org/TR/webgpu/#vertex-formats
149
+ */
150
+ type I32CompatibleFormats = TgpuVertexAttrib<'sint8'> | TgpuVertexAttrib<'sint8x2'> | TgpuVertexAttrib<'sint8x4'> | TgpuVertexAttrib<'sint16'> | TgpuVertexAttrib<'sint16x2'> | TgpuVertexAttrib<'sint16x4'> | TgpuVertexAttrib<'sint32'> | TgpuVertexAttrib<'sint32x2'> | TgpuVertexAttrib<'sint32x3'> | TgpuVertexAttrib<'sint32x4'>;
151
+ /**
152
+ * All vertex attribute formats that can be interpreted as
153
+ * an single or multi component f32 in a shader.
154
+ * https://www.w3.org/TR/webgpu/#vertex-formats
155
+ */
156
+ 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'>;
157
+ /**
158
+ * All vertex attribute formats that can be interpreted as
159
+ * a single or multi component f16 in a shader. (same as f32 on the shader side)
160
+ * https://www.w3.org/TR/webgpu/#vertex-formats
161
+ */
162
+ type F16CompatibleFormats = F32CompatibleFormats;
163
+ type KindToAcceptedAttribMap = {
164
+ u32: U32CompatibleFormats;
165
+ vec2u: U32CompatibleFormats;
166
+ vec3u: U32CompatibleFormats;
167
+ vec4u: U32CompatibleFormats;
168
+ i32: I32CompatibleFormats;
169
+ vec2i: I32CompatibleFormats;
170
+ vec3i: I32CompatibleFormats;
171
+ vec4i: I32CompatibleFormats;
172
+ f16: F16CompatibleFormats;
173
+ vec2h: F16CompatibleFormats;
174
+ vec3h: F16CompatibleFormats;
175
+ vec4h: F16CompatibleFormats;
176
+ f32: F32CompatibleFormats;
177
+ vec2f: F32CompatibleFormats;
178
+ vec3f: F32CompatibleFormats;
179
+ vec4f: F32CompatibleFormats;
180
+ };
181
+
182
+ type FormatToWGSLType<T extends VertexFormat> = (typeof formatToWGSLType)[T];
183
+ interface TgpuVertexFormatData<T extends VertexFormat> extends BaseData {
184
+ readonly type: T;
185
+ readonly [$repr]: Infer<FormatToWGSLType<T>>;
186
+ readonly [$validVertexSchema]: true;
187
+ readonly [$invalidSchemaReason]: 'Vertex formats are not host-shareable, use concrete types instead';
188
+ }
189
+ declare const formatToWGSLType: {
190
+ readonly uint8: U32;
191
+ readonly uint8x2: Vec2u;
192
+ readonly uint8x4: Vec4u;
193
+ readonly sint8: I32;
194
+ readonly sint8x2: Vec2i;
195
+ readonly sint8x4: Vec4i;
196
+ readonly unorm8: F32;
197
+ readonly unorm8x2: Vec2f;
198
+ readonly unorm8x4: Vec4f;
199
+ readonly snorm8: F32;
200
+ readonly snorm8x2: Vec2f;
201
+ readonly snorm8x4: Vec4f;
202
+ readonly uint16: U32;
203
+ readonly uint16x2: Vec2u;
204
+ readonly uint16x4: Vec4u;
205
+ readonly sint16: I32;
206
+ readonly sint16x2: Vec2i;
207
+ readonly sint16x4: Vec4i;
208
+ readonly unorm16: F32;
209
+ readonly unorm16x2: Vec2f;
210
+ readonly unorm16x4: Vec4f;
211
+ readonly snorm16: F32;
212
+ readonly snorm16x2: Vec2f;
213
+ readonly snorm16x4: Vec4f;
214
+ readonly float16: F32;
215
+ readonly float16x2: Vec2f;
216
+ readonly float16x4: Vec4f;
217
+ readonly float32: F32;
218
+ readonly float32x2: Vec2f;
219
+ readonly float32x3: Vec3f;
220
+ readonly float32x4: Vec4f;
221
+ readonly uint32: U32;
222
+ readonly uint32x2: Vec2u;
223
+ readonly uint32x3: Vec3u;
224
+ readonly uint32x4: Vec4u;
225
+ readonly sint32: I32;
226
+ readonly sint32x2: Vec2i;
227
+ readonly sint32x3: Vec3i;
228
+ readonly sint32x4: Vec4i;
229
+ readonly 'unorm10-10-10-2': Vec4f;
230
+ readonly 'unorm8x4-bgra': Vec4f;
231
+ };
232
+ declare const packedFormats: Set<string>;
233
+ type uint8 = TgpuVertexFormatData<'uint8'>;
234
+ declare const uint8: uint8;
235
+ type uint8x2 = TgpuVertexFormatData<'uint8x2'>;
236
+ declare const uint8x2: uint8x2;
237
+ type uint8x4 = TgpuVertexFormatData<'uint8x4'>;
238
+ declare const uint8x4: uint8x4;
239
+ type sint8 = TgpuVertexFormatData<'sint8'>;
240
+ declare const sint8: sint8;
241
+ type sint8x2 = TgpuVertexFormatData<'sint8x2'>;
242
+ declare const sint8x2: sint8x2;
243
+ type sint8x4 = TgpuVertexFormatData<'sint8x4'>;
244
+ declare const sint8x4: sint8x4;
245
+ type unorm8 = TgpuVertexFormatData<'unorm8'>;
246
+ declare const unorm8: unorm8;
247
+ type unorm8x2 = TgpuVertexFormatData<'unorm8x2'>;
248
+ declare const unorm8x2: unorm8x2;
249
+ type unorm8x4 = TgpuVertexFormatData<'unorm8x4'>;
250
+ declare const unorm8x4: unorm8x4;
251
+ type snorm8 = TgpuVertexFormatData<'snorm8'>;
252
+ declare const snorm8: snorm8;
253
+ type snorm8x2 = TgpuVertexFormatData<'snorm8x2'>;
254
+ declare const snorm8x2: snorm8x2;
255
+ type snorm8x4 = TgpuVertexFormatData<'snorm8x4'>;
256
+ declare const snorm8x4: snorm8x4;
257
+ type uint16 = TgpuVertexFormatData<'uint16'>;
258
+ declare const uint16: uint16;
259
+ type uint16x2 = TgpuVertexFormatData<'uint16x2'>;
260
+ declare const uint16x2: uint16x2;
261
+ type uint16x4 = TgpuVertexFormatData<'uint16x4'>;
262
+ declare const uint16x4: uint16x4;
263
+ type sint16 = TgpuVertexFormatData<'sint16'>;
264
+ declare const sint16: sint16;
265
+ type sint16x2 = TgpuVertexFormatData<'sint16x2'>;
266
+ declare const sint16x2: sint16x2;
267
+ type sint16x4 = TgpuVertexFormatData<'sint16x4'>;
268
+ declare const sint16x4: sint16x4;
269
+ type unorm16 = TgpuVertexFormatData<'unorm16'>;
270
+ declare const unorm16: unorm16;
271
+ type unorm16x2 = TgpuVertexFormatData<'unorm16x2'>;
272
+ declare const unorm16x2: unorm16x2;
273
+ type unorm16x4 = TgpuVertexFormatData<'unorm16x4'>;
274
+ declare const unorm16x4: unorm16x4;
275
+ type snorm16 = TgpuVertexFormatData<'snorm16'>;
276
+ declare const snorm16: snorm16;
277
+ type snorm16x2 = TgpuVertexFormatData<'snorm16x2'>;
278
+ declare const snorm16x2: snorm16x2;
279
+ type snorm16x4 = TgpuVertexFormatData<'snorm16x4'>;
280
+ declare const snorm16x4: snorm16x4;
281
+ type float16 = TgpuVertexFormatData<'float16'>;
282
+ declare const float16: float16;
283
+ type float16x2 = TgpuVertexFormatData<'float16x2'>;
284
+ declare const float16x2: float16x2;
285
+ type float16x4 = TgpuVertexFormatData<'float16x4'>;
286
+ declare const float16x4: float16x4;
287
+ type float32 = TgpuVertexFormatData<'float32'>;
288
+ declare const float32: float32;
289
+ type float32x2 = TgpuVertexFormatData<'float32x2'>;
290
+ declare const float32x2: float32x2;
291
+ type float32x3 = TgpuVertexFormatData<'float32x3'>;
292
+ declare const float32x3: float32x3;
293
+ type float32x4 = TgpuVertexFormatData<'float32x4'>;
294
+ declare const float32x4: float32x4;
295
+ type uint32 = TgpuVertexFormatData<'uint32'>;
296
+ declare const uint32: uint32;
297
+ type uint32x2 = TgpuVertexFormatData<'uint32x2'>;
298
+ declare const uint32x2: uint32x2;
299
+ type uint32x3 = TgpuVertexFormatData<'uint32x3'>;
300
+ declare const uint32x3: uint32x3;
301
+ type uint32x4 = TgpuVertexFormatData<'uint32x4'>;
302
+ declare const uint32x4: uint32x4;
303
+ type sint32 = TgpuVertexFormatData<'sint32'>;
304
+ declare const sint32: sint32;
305
+ type sint32x2 = TgpuVertexFormatData<'sint32x2'>;
306
+ declare const sint32x2: sint32x2;
307
+ type sint32x3 = TgpuVertexFormatData<'sint32x3'>;
308
+ declare const sint32x3: sint32x3;
309
+ type sint32x4 = TgpuVertexFormatData<'sint32x4'>;
310
+ declare const sint32x4: sint32x4;
311
+ type unorm10_10_10_2 = TgpuVertexFormatData<'unorm10-10-10-2'>;
312
+ declare const unorm10_10_10_2: unorm10_10_10_2;
313
+ type unorm8x4_bgra = TgpuVertexFormatData<'unorm8x4-bgra'>;
314
+ declare const unorm8x4_bgra: unorm8x4_bgra;
315
+ 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;
316
+ declare function isPackedData(value: unknown): value is PackedData;
317
+
318
+ /**
319
+ * Array schema constructed via `d.disarrayOf` function.
320
+ *
321
+ * Useful for defining vertex buffers.
322
+ * Elements in the schema are not aligned in respect to their `byteAlignment`,
323
+ * unless they are explicitly decorated with the custom align attribute
324
+ * via `d.align` function.
325
+ */
326
+ interface Disarray<TElement extends BaseData = BaseData> extends BaseData {
327
+ <T extends TElement>(elements: Infer<T>[]): Infer<T>[];
328
+ (): Infer<TElement>[];
329
+ readonly type: 'disarray';
330
+ readonly elementCount: number;
331
+ readonly elementType: TElement;
332
+ readonly [$repr]: Infer<TElement>[];
333
+ readonly [$reprPartial]: {
334
+ idx: number;
335
+ value: InferPartial<TElement>;
336
+ }[] | undefined;
337
+ readonly [$validVertexSchema]: IsValidVertexSchema<TElement>;
338
+ readonly [$invalidSchemaReason]: 'Disarrays are not host-shareable, use arrays instead';
339
+ }
340
+ /**
341
+ * Struct schema constructed via `d.unstruct` function.
342
+ *
343
+ * Useful for defining vertex buffers, as the standard layout restrictions do not apply.
344
+ * Members are not aligned in respect to their `byteAlignment`,
345
+ * unless they are explicitly decorated with the custom align attribute
346
+ * via `d.align` function.
347
+ */
348
+ interface Unstruct<TProps extends Record<string, BaseData> = any> extends BaseData, TgpuNamable {
349
+ (props: Prettify<InferRecord<TProps>>): Prettify<InferRecord<TProps>>;
350
+ (): Prettify<InferRecord<TProps>>;
351
+ readonly type: 'unstruct';
352
+ readonly propTypes: TProps;
353
+ readonly [$repr]: Prettify<InferRecord<TProps>>;
354
+ readonly [$gpuRepr]: Prettify<InferGPURecord<TProps>>;
355
+ readonly [$memIdent]: Unstruct<Prettify<MemIdentityRecord<TProps>>>;
356
+ readonly [$reprPartial]: Prettify<Partial<InferPartialRecord<TProps>>> | undefined;
357
+ readonly [$validVertexSchema]: {
358
+ [K in keyof TProps]: IsValidVertexSchema<TProps[K]>;
359
+ }[keyof TProps] extends true ? true : false;
360
+ readonly [$invalidSchemaReason]: 'Unstructs are not host-shareable, use structs instead';
361
+ }
362
+ interface LooseDecorated<TInner extends BaseData = BaseData, TAttribs extends unknown[] = unknown[]> extends BaseData {
363
+ readonly type: 'loose-decorated';
364
+ readonly inner: TInner;
365
+ readonly attribs: TAttribs;
366
+ readonly [$repr]: Infer<TInner>;
367
+ readonly [$invalidSchemaReason]: 'Loosely decorated schemas are not host-shareable';
368
+ readonly [$validVertexSchema]: IsValidVertexSchema<TInner>;
369
+ }
370
+ 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"];
371
+ type LooseTypeLiteral = (typeof looseTypeLiterals)[number];
372
+ type AnyLooseData = Disarray | Unstruct | LooseDecorated | PackedData;
373
+ declare function isLooseData(data: unknown): data is AnyLooseData;
374
+ /**
375
+ * Checks whether the passed in value is a disarray schema,
376
+ * as opposed to, e.g., a regular array schema.
377
+ *
378
+ * Array schemas can be used to describe uniform and storage buffers,
379
+ * whereas disarray schemas cannot. Disarrays are useful for
380
+ * defining vertex buffers instead.
381
+ *
382
+ * @example
383
+ * isDisarray(d.arrayOf(d.u32, 4)) // false
384
+ * isDisarray(d.disarrayOf(d.u32, 4)) // true
385
+ * isDisarray(d.vec3f) // false
386
+ */
387
+ declare function isDisarray<T extends Disarray>(schema: T | unknown): schema is T;
388
+ /**
389
+ * Checks whether passed in value is a unstruct schema,
390
+ * as opposed to, e.g., a struct schema.
391
+ *
392
+ * Struct schemas can be used to describe uniform and storage buffers,
393
+ * whereas unstruct schemas cannot. Unstructs are useful for
394
+ * defining vertex buffers instead.
395
+ *
396
+ * @example
397
+ * isUnstruct(d.struct({ a: d.u32 })) // false
398
+ * isUnstruct(d.unstruct({ a: d.u32 })) // true
399
+ * isUnstruct(d.vec3f) // false
400
+ */
401
+ declare function isUnstruct<T extends Unstruct>(schema: T | unknown): schema is T;
402
+ declare function isLooseDecorated<T extends LooseDecorated>(value: T | unknown): value is T;
403
+ declare function isData(value: unknown): value is AnyData;
404
+ type AnyData = AnyWgslData | AnyLooseData;
405
+ interface UnknownData {
406
+ readonly type: 'unknown';
407
+ }
408
+ declare const UnknownData: UnknownData;
409
+
410
+ /**
411
+ * Type utility to extract the inner type from decorated types.
412
+ */
413
+ type Undecorate<T> = T extends {
414
+ readonly type: 'decorated' | 'loose-decorated';
415
+ readonly inner: infer TInner;
416
+ } ? TInner : T;
417
+ /**
418
+ * Type utility to undecorate all values in a record.
419
+ */
420
+ type UndecorateRecord<T extends Record<string, unknown>> = {
421
+ [Key in keyof T]: Undecorate<T[Key]>;
422
+ };
423
+
102
424
  interface StorageFlag {
103
425
  usableAsStorage: true;
104
426
  }
@@ -191,6 +513,7 @@ interface TgpuBufferUsage<TData extends BaseData = BaseData, TUsage extends Bind
191
513
  readonly resourceType: 'buffer-usage';
192
514
  readonly usage: TUsage;
193
515
  readonly [$repr]: Infer<TData>;
516
+ [$gpuValueOf](ctx: ResolutionCtx): InferGPU<TData>;
194
517
  value: InferGPU<TData>;
195
518
  $: InferGPU<TData>;
196
519
  readonly [$internal]: {
@@ -430,10 +753,6 @@ type TgpuFnShellHeader<Args extends AnyData[], Return extends AnyData> = {
430
753
  */
431
754
  type TgpuFnShell<Args extends AnyData[], Return extends AnyData> = TgpuFnShellHeader<Args, Return> & (<T extends (...args: InferArgs<Args>) => Infer<Return>>(implementation: T) => TgpuFn<Prettify<InheritArgNames<(...args: Args) => Return, T>>['result']>) & ((implementation: string) => TgpuFn<(...args: Args) => Return>) & ((strings: TemplateStringsArray, ...values: unknown[]) => TgpuFn<(...args: Args) => Return>);
432
755
  interface TgpuFnBase<ImplSchema extends AnyFn> extends TgpuNamable {
433
- readonly [$internal]: {
434
- implementation: Implementation<ImplSchema>;
435
- argConversionHint: FnArgsConversionHint;
436
- };
437
756
  readonly resourceType: 'function';
438
757
  readonly shell: TgpuFnShellHeader<Parameters<ImplSchema>, Extract<ReturnType<ImplSchema>, AnyData>>;
439
758
  readonly [$providing]?: Providing | undefined;
@@ -441,7 +760,11 @@ interface TgpuFnBase<ImplSchema extends AnyFn> extends TgpuNamable {
441
760
  with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TgpuFn<ImplSchema>;
442
761
  with<T extends AnyData>(accessor: TgpuAccessor<T>, value: TgpuFn<() => T> | TgpuBufferUsage<T> | Infer<T>): TgpuFn<ImplSchema>;
443
762
  }
444
- type TgpuFn<ImplSchema extends AnyFn = (...args: any[]) => any> = TgpuFnBase<ImplSchema> & InferImplSchema<ImplSchema>;
763
+ type TgpuFn<ImplSchema extends AnyFn = (...args: any[]) => any> = TgpuFnBase<ImplSchema> & InferImplSchema<ImplSchema> & {
764
+ readonly [$internal]: DualFn<InferImplSchema<ImplSchema>>[typeof $internal] & {
765
+ implementation: Implementation<ImplSchema>;
766
+ };
767
+ };
445
768
  declare function fn<Args extends AnyData[] | []>(argTypes: Args, returnType?: undefined): TgpuFnShell<Args, Void>;
446
769
  declare function fn<Args extends AnyData[] | [], Return extends AnyData>(argTypes: Args, returnType: Return): TgpuFnShell<Args, Return>;
447
770
  declare function isTgpuFn<Args extends AnyData[] | [], Return extends AnyData>(value: unknown | TgpuFn<(...args: Args) => Return>): value is TgpuFn<(...args: Args) => Return>;
@@ -449,23 +772,22 @@ declare function isTgpuFn<Args extends AnyData[] | [], Return extends AnyData>(v
449
772
  interface TgpuSlot<T> extends TgpuNamable {
450
773
  readonly [$internal]: true;
451
774
  readonly resourceType: 'slot';
452
- readonly [$repr]: Infer<T>;
453
- readonly [$gpuRepr]: InferGPU<T>;
454
775
  readonly defaultValue: T | undefined;
455
776
  /**
456
777
  * Used to determine if code generated using either value `a` or `b` in place
457
778
  * of the slot will be equivalent. Defaults to `Object.is`.
458
779
  */
459
780
  areEqual(a: T, b: T): boolean;
460
- readonly value: InferGPU<T>;
461
- readonly $: InferGPU<T>;
781
+ [$gpuValueOf](ctx: ResolutionCtx): GPUValueOf<T>;
782
+ readonly value: GPUValueOf<T>;
783
+ readonly $: GPUValueOf<T>;
462
784
  }
463
785
  interface TgpuDerived<T> {
786
+ readonly [$internal]: true;
464
787
  readonly resourceType: 'derived';
465
- readonly value: InferGPU<T>;
466
- readonly $: InferGPU<T>;
467
- readonly [$repr]: Infer<T>;
468
- readonly [$gpuRepr]: InferGPU<T>;
788
+ [$gpuValueOf](ctx: ResolutionCtx): GPUValueOf<T>;
789
+ readonly value: GPUValueOf<T>;
790
+ readonly $: GPUValueOf<T>;
469
791
  readonly [$providing]?: Providing | undefined;
470
792
  with<TValue>(slot: TgpuSlot<TValue>, value: Eventual<TValue>): TgpuDerived<T>;
471
793
  /**
@@ -476,11 +798,10 @@ interface TgpuDerived<T> {
476
798
  interface TgpuAccessor<T extends AnyData = AnyData> extends TgpuNamable {
477
799
  readonly [$internal]: true;
478
800
  readonly resourceType: 'accessor';
479
- readonly [$repr]: Infer<T>;
480
- readonly [$gpuRepr]: InferGPU<T>;
481
801
  readonly schema: T;
482
802
  readonly defaultValue: TgpuFn<() => T> | TgpuBufferUsage<T> | Infer<T> | undefined;
483
803
  readonly slot: TgpuSlot<TgpuFn<() => T> | TgpuBufferUsage<T> | Infer<T>>;
804
+ [$gpuValueOf](ctx: ResolutionCtx): InferGPU<T>;
484
805
  readonly value: InferGPU<T>;
485
806
  readonly $: InferGPU<T>;
486
807
  }
@@ -524,77 +845,9 @@ interface TgpuComputePipeline extends TgpuNamable, SelfResolvable, Timeable {
524
845
  with(bindGroupLayout: TgpuBindGroupLayout, bindGroup: TgpuBindGroup): TgpuComputePipeline;
525
846
  dispatchWorkgroups(x: number, y?: number | undefined, z?: number | undefined): void;
526
847
  }
527
- type TgpuComputePipelinePriors = {
528
- readonly bindGroupLayoutMap?: Map<TgpuBindGroupLayout, TgpuBindGroup>;
529
- } & TimestampWritesPriors;
530
-
531
- 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"];
532
- type VertexFormat = (typeof vertexFormats)[number];
533
- declare const kindToDefaultFormatMap: {
534
- readonly f32: "float32";
535
- readonly vec2f: "float32x2";
536
- readonly vec3f: "float32x3";
537
- readonly vec4f: "float32x4";
538
- readonly f16: "float16";
539
- readonly vec2h: "float16x2";
540
- readonly vec4h: "float16x4";
541
- readonly u32: "uint32";
542
- readonly vec2u: "uint32x2";
543
- readonly vec3u: "uint32x3";
544
- readonly vec4u: "uint32x4";
545
- readonly i32: "sint32";
546
- readonly vec2i: "sint32x2";
547
- readonly vec3i: "sint32x3";
548
- readonly vec4i: "sint32x4";
549
- };
550
- type KindToDefaultFormatMap = typeof kindToDefaultFormatMap;
551
- interface TgpuVertexAttrib<TFormat extends VertexFormat = VertexFormat> {
552
- readonly format: TFormat;
553
- readonly offset: number;
554
- }
555
- type AnyVertexAttribs = Record<string, TgpuVertexAttrib> | TgpuVertexAttrib;
556
- /**
557
- * All vertex attribute formats that can be interpreted as
558
- * an single or multi component u32 in a shader.
559
- * https://www.w3.org/TR/webgpu/#vertex-formats
560
- */
561
- type U32CompatibleFormats = TgpuVertexAttrib<'uint8'> | TgpuVertexAttrib<'uint8x2'> | TgpuVertexAttrib<'uint8x4'> | TgpuVertexAttrib<'uint16'> | TgpuVertexAttrib<'uint16x2'> | TgpuVertexAttrib<'uint16x4'> | TgpuVertexAttrib<'uint32'> | TgpuVertexAttrib<'uint32x2'> | TgpuVertexAttrib<'uint32x3'> | TgpuVertexAttrib<'uint32x4'>;
562
- /**
563
- * All vertex attribute formats that can be interpreted as
564
- * an single or multi component i32 in a shader.
565
- * https://www.w3.org/TR/webgpu/#vertex-formats
566
- */
567
- type I32CompatibleFormats = TgpuVertexAttrib<'sint8'> | TgpuVertexAttrib<'sint8x2'> | TgpuVertexAttrib<'sint8x4'> | TgpuVertexAttrib<'sint16'> | TgpuVertexAttrib<'sint16x2'> | TgpuVertexAttrib<'sint16x4'> | TgpuVertexAttrib<'sint32'> | TgpuVertexAttrib<'sint32x2'> | TgpuVertexAttrib<'sint32x3'> | TgpuVertexAttrib<'sint32x4'>;
568
- /**
569
- * All vertex attribute formats that can be interpreted as
570
- * an single or multi component f32 in a shader.
571
- * https://www.w3.org/TR/webgpu/#vertex-formats
572
- */
573
- 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'>;
574
- /**
575
- * All vertex attribute formats that can be interpreted as
576
- * a single or multi component f16 in a shader. (same as f32 on the shader side)
577
- * https://www.w3.org/TR/webgpu/#vertex-formats
578
- */
579
- type F16CompatibleFormats = F32CompatibleFormats;
580
- type KindToAcceptedAttribMap = {
581
- u32: U32CompatibleFormats;
582
- vec2u: U32CompatibleFormats;
583
- vec3u: U32CompatibleFormats;
584
- vec4u: U32CompatibleFormats;
585
- i32: I32CompatibleFormats;
586
- vec2i: I32CompatibleFormats;
587
- vec3i: I32CompatibleFormats;
588
- vec4i: I32CompatibleFormats;
589
- f16: F16CompatibleFormats;
590
- vec2h: F16CompatibleFormats;
591
- vec3h: F16CompatibleFormats;
592
- vec4h: F16CompatibleFormats;
593
- f32: F32CompatibleFormats;
594
- vec2f: F32CompatibleFormats;
595
- vec3f: F32CompatibleFormats;
596
- vec4f: F32CompatibleFormats;
597
- };
848
+ type TgpuComputePipelinePriors = {
849
+ readonly bindGroupLayoutMap?: Map<TgpuBindGroupLayout, TgpuBindGroup>;
850
+ } & TimestampWritesPriors;
598
851
 
599
852
  type FragmentInConstrained = IORecord<BaseIOData | Decorated<BaseIOData, (Location | Interpolate)[]> | AnyFragmentInputBuiltin>;
600
853
  type FragmentOutConstrained = IOLayout<Vec4f | Decorated<Vec4f, (Location | Interpolate)[]> | AnyFragmentOutputBuiltin>;
@@ -1145,6 +1398,7 @@ type Memo = {
1145
1398
  };
1146
1399
  declare class RenderPipelineCore implements SelfResolvable {
1147
1400
  readonly options: RenderPipelineCoreOptions;
1401
+ readonly [$internal] = true;
1148
1402
  readonly usedVertexLayouts: TgpuVertexLayout[];
1149
1403
  private _memo;
1150
1404
  private readonly _vertexBufferLayouts;
@@ -1337,6 +1591,9 @@ interface TgpuBindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | n
1337
1591
  readonly bound: {
1338
1592
  [K in keyof Entries]: BindLayoutEntry<Entries[K]>;
1339
1593
  };
1594
+ [$gpuValueOf](): {
1595
+ [K in keyof Entries]: InferLayoutEntry<Entries[K]>;
1596
+ };
1340
1597
  readonly value: {
1341
1598
  [K in keyof Entries]: InferLayoutEntry<Entries[K]>;
1342
1599
  };
@@ -1405,6 +1662,7 @@ interface TgpuBufferShorthandBase<TData extends BaseData> extends TgpuNamable {
1405
1662
  write(data: Infer<TData>): void;
1406
1663
  writePartial(data: InferPartial<TData>): void;
1407
1664
  read(): Promise<Infer<TData>>;
1665
+ [$gpuValueOf](ctx: ResolutionCtx): InferGPU<TData>;
1408
1666
  }
1409
1667
  interface TgpuMutable<TData extends BaseData> extends TgpuBufferShorthandBase<TData> {
1410
1668
  readonly resourceType: 'mutable';
@@ -1834,6 +2092,7 @@ interface TgpuExternalTexture {
1834
2092
 
1835
2093
  type VariableScope = 'private' | 'workgroup';
1836
2094
  interface TgpuVar<TScope extends VariableScope = VariableScope, TDataType extends AnyData = AnyData> extends TgpuNamable {
2095
+ [$gpuValueOf](): InferGPU<TDataType>;
1837
2096
  value: InferGPU<TDataType>;
1838
2097
  $: InferGPU<TDataType>;
1839
2098
  readonly [$internal]: {
@@ -1858,14 +2117,6 @@ declare function privateVar<TDataType extends AnyData>(dataType: TDataType, init
1858
2117
  */
1859
2118
  declare function workgroupVar<TDataType extends AnyData>(dataType: TDataType): TgpuVar<'workgroup', TDataType>;
1860
2119
 
1861
- interface Snippet {
1862
- readonly value: unknown;
1863
- readonly dataType: AnyData | UnknownData;
1864
- }
1865
- type MapValueToSnippet<T> = {
1866
- [K in keyof T]: Snippet;
1867
- };
1868
-
1869
2120
  type ResolvableObject = SelfResolvable | TgpuBufferUsage | TgpuConst | TgpuDeclare | TgpuFn | TgpuComputeFn | TgpuFragmentFn | TgpuComputePipeline | TgpuRenderPipeline | TgpuVertexFn | TgpuSampler | TgpuAccessor | TgpuExternalTexture | TgpuTexture | TgpuAnyTextureView | TgpuVar | AnyVecInstance | AnyMatInstance | AnyData | TgpuFn;
1870
2121
  type Wgsl = Eventual<string | number | boolean | ResolvableObject>;
1871
2122
  type TgpuShaderStage = 'compute' | 'vertex' | 'fragment';
@@ -1978,6 +2229,7 @@ interface ResolutionCtx {
1978
2229
  readonly names: NameRegistry;
1979
2230
  readonly mode: ExecState;
1980
2231
  addDeclaration(declaration: string): void;
2232
+ withResetIndentLevel<T>(callback: () => T): T;
1981
2233
  /**
1982
2234
  * Reserves a bind group number, and returns a placeholder that will be replaced
1983
2235
  * with a concrete number at the end of the resolution process.
@@ -1999,8 +2251,7 @@ interface ResolutionCtx {
1999
2251
  * @throws {MissingSlotValueError}
2000
2252
  */
2001
2253
  unwrap<T>(eventual: Eventual<T>): T;
2002
- resolve(item: unknown): string;
2003
- resolveValue<T extends BaseData>(value: Infer<T> | InferGPU<T>, schema: T): string;
2254
+ resolve(item: unknown, schema?: AnyData | UnknownData | undefined): string;
2004
2255
  fnToWgsl(options: FnToWgslOptions): {
2005
2256
  head: Wgsl;
2006
2257
  body: Wgsl;
@@ -2017,6 +2268,7 @@ interface ResolutionCtx {
2017
2268
  * to another mechanism.
2018
2269
  */
2019
2270
  interface SelfResolvable {
2271
+ [$internal]: unknown;
2020
2272
  '~resolve'(ctx: ResolutionCtx): string;
2021
2273
  toString(): string;
2022
2274
  }
@@ -2031,251 +2283,13 @@ type ConversionStrategy = 'keep' | 'unify';
2031
2283
  */
2032
2284
  type FnArgsConversionHint = AnyData[] | ((...args: Snippet[]) => AnyWgslData[]) | ConversionStrategy;
2033
2285
 
2034
- type FormatToWGSLType<T extends VertexFormat> = (typeof formatToWGSLType)[T];
2035
- interface TgpuVertexFormatData<T extends VertexFormat> extends BaseData {
2036
- readonly type: T;
2037
- readonly [$repr]: Infer<FormatToWGSLType<T>>;
2038
- readonly [$validVertexSchema]: true;
2039
- readonly [$invalidSchemaReason]: 'Vertex formats are not host-shareable, use concrete types instead';
2040
- }
2041
- declare const formatToWGSLType: {
2042
- readonly uint8: U32;
2043
- readonly uint8x2: Vec2u;
2044
- readonly uint8x4: Vec4u;
2045
- readonly sint8: I32;
2046
- readonly sint8x2: Vec2i;
2047
- readonly sint8x4: Vec4i;
2048
- readonly unorm8: F32;
2049
- readonly unorm8x2: Vec2f;
2050
- readonly unorm8x4: Vec4f;
2051
- readonly snorm8: F32;
2052
- readonly snorm8x2: Vec2f;
2053
- readonly snorm8x4: Vec4f;
2054
- readonly uint16: U32;
2055
- readonly uint16x2: Vec2u;
2056
- readonly uint16x4: Vec4u;
2057
- readonly sint16: I32;
2058
- readonly sint16x2: Vec2i;
2059
- readonly sint16x4: Vec4i;
2060
- readonly unorm16: F32;
2061
- readonly unorm16x2: Vec2f;
2062
- readonly unorm16x4: Vec4f;
2063
- readonly snorm16: F32;
2064
- readonly snorm16x2: Vec2f;
2065
- readonly snorm16x4: Vec4f;
2066
- readonly float16: F32;
2067
- readonly float16x2: Vec2f;
2068
- readonly float16x4: Vec4f;
2069
- readonly float32: F32;
2070
- readonly float32x2: Vec2f;
2071
- readonly float32x3: Vec3f;
2072
- readonly float32x4: Vec4f;
2073
- readonly uint32: U32;
2074
- readonly uint32x2: Vec2u;
2075
- readonly uint32x3: Vec3u;
2076
- readonly uint32x4: Vec4u;
2077
- readonly sint32: I32;
2078
- readonly sint32x2: Vec2i;
2079
- readonly sint32x3: Vec3i;
2080
- readonly sint32x4: Vec4i;
2081
- readonly 'unorm10-10-10-2': Vec4f;
2082
- readonly 'unorm8x4-bgra': Vec4f;
2083
- };
2084
- declare const packedFormats: Set<string>;
2085
- type uint8 = TgpuVertexFormatData<'uint8'>;
2086
- declare const uint8: uint8;
2087
- type uint8x2 = TgpuVertexFormatData<'uint8x2'>;
2088
- declare const uint8x2: uint8x2;
2089
- type uint8x4 = TgpuVertexFormatData<'uint8x4'>;
2090
- declare const uint8x4: uint8x4;
2091
- type sint8 = TgpuVertexFormatData<'sint8'>;
2092
- declare const sint8: sint8;
2093
- type sint8x2 = TgpuVertexFormatData<'sint8x2'>;
2094
- declare const sint8x2: sint8x2;
2095
- type sint8x4 = TgpuVertexFormatData<'sint8x4'>;
2096
- declare const sint8x4: sint8x4;
2097
- type unorm8 = TgpuVertexFormatData<'unorm8'>;
2098
- declare const unorm8: unorm8;
2099
- type unorm8x2 = TgpuVertexFormatData<'unorm8x2'>;
2100
- declare const unorm8x2: unorm8x2;
2101
- type unorm8x4 = TgpuVertexFormatData<'unorm8x4'>;
2102
- declare const unorm8x4: unorm8x4;
2103
- type snorm8 = TgpuVertexFormatData<'snorm8'>;
2104
- declare const snorm8: snorm8;
2105
- type snorm8x2 = TgpuVertexFormatData<'snorm8x2'>;
2106
- declare const snorm8x2: snorm8x2;
2107
- type snorm8x4 = TgpuVertexFormatData<'snorm8x4'>;
2108
- declare const snorm8x4: snorm8x4;
2109
- type uint16 = TgpuVertexFormatData<'uint16'>;
2110
- declare const uint16: uint16;
2111
- type uint16x2 = TgpuVertexFormatData<'uint16x2'>;
2112
- declare const uint16x2: uint16x2;
2113
- type uint16x4 = TgpuVertexFormatData<'uint16x4'>;
2114
- declare const uint16x4: uint16x4;
2115
- type sint16 = TgpuVertexFormatData<'sint16'>;
2116
- declare const sint16: sint16;
2117
- type sint16x2 = TgpuVertexFormatData<'sint16x2'>;
2118
- declare const sint16x2: sint16x2;
2119
- type sint16x4 = TgpuVertexFormatData<'sint16x4'>;
2120
- declare const sint16x4: sint16x4;
2121
- type unorm16 = TgpuVertexFormatData<'unorm16'>;
2122
- declare const unorm16: unorm16;
2123
- type unorm16x2 = TgpuVertexFormatData<'unorm16x2'>;
2124
- declare const unorm16x2: unorm16x2;
2125
- type unorm16x4 = TgpuVertexFormatData<'unorm16x4'>;
2126
- declare const unorm16x4: unorm16x4;
2127
- type snorm16 = TgpuVertexFormatData<'snorm16'>;
2128
- declare const snorm16: snorm16;
2129
- type snorm16x2 = TgpuVertexFormatData<'snorm16x2'>;
2130
- declare const snorm16x2: snorm16x2;
2131
- type snorm16x4 = TgpuVertexFormatData<'snorm16x4'>;
2132
- declare const snorm16x4: snorm16x4;
2133
- type float16 = TgpuVertexFormatData<'float16'>;
2134
- declare const float16: float16;
2135
- type float16x2 = TgpuVertexFormatData<'float16x2'>;
2136
- declare const float16x2: float16x2;
2137
- type float16x4 = TgpuVertexFormatData<'float16x4'>;
2138
- declare const float16x4: float16x4;
2139
- type float32 = TgpuVertexFormatData<'float32'>;
2140
- declare const float32: float32;
2141
- type float32x2 = TgpuVertexFormatData<'float32x2'>;
2142
- declare const float32x2: float32x2;
2143
- type float32x3 = TgpuVertexFormatData<'float32x3'>;
2144
- declare const float32x3: float32x3;
2145
- type float32x4 = TgpuVertexFormatData<'float32x4'>;
2146
- declare const float32x4: float32x4;
2147
- type uint32 = TgpuVertexFormatData<'uint32'>;
2148
- declare const uint32: uint32;
2149
- type uint32x2 = TgpuVertexFormatData<'uint32x2'>;
2150
- declare const uint32x2: uint32x2;
2151
- type uint32x3 = TgpuVertexFormatData<'uint32x3'>;
2152
- declare const uint32x3: uint32x3;
2153
- type uint32x4 = TgpuVertexFormatData<'uint32x4'>;
2154
- declare const uint32x4: uint32x4;
2155
- type sint32 = TgpuVertexFormatData<'sint32'>;
2156
- declare const sint32: sint32;
2157
- type sint32x2 = TgpuVertexFormatData<'sint32x2'>;
2158
- declare const sint32x2: sint32x2;
2159
- type sint32x3 = TgpuVertexFormatData<'sint32x3'>;
2160
- declare const sint32x3: sint32x3;
2161
- type sint32x4 = TgpuVertexFormatData<'sint32x4'>;
2162
- declare const sint32x4: sint32x4;
2163
- type unorm10_10_10_2 = TgpuVertexFormatData<'unorm10-10-10-2'>;
2164
- declare const unorm10_10_10_2: unorm10_10_10_2;
2165
- type unorm8x4_bgra = TgpuVertexFormatData<'unorm8x4-bgra'>;
2166
- declare const unorm8x4_bgra: unorm8x4_bgra;
2167
- 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;
2168
- declare function isPackedData(value: unknown): value is PackedData;
2169
-
2170
- type TgpuDualFn<TImpl extends (...args: never[]) => unknown> = TImpl & {
2171
- [$internal]: {
2172
- jsImpl: TImpl | string;
2286
+ type DualFn<TImpl extends (...args: never[]) => unknown> = TImpl & {
2287
+ readonly [$internal]: {
2288
+ jsImpl: TImpl;
2173
2289
  gpuImpl: (...args: MapValueToSnippet<Parameters<TImpl>>) => Snippet;
2174
2290
  argConversionHint: FnArgsConversionHint;
2175
2291
  };
2176
2292
  };
2177
- /**
2178
- * Array schema constructed via `d.disarrayOf` function.
2179
- *
2180
- * Useful for defining vertex buffers.
2181
- * Elements in the schema are not aligned in respect to their `byteAlignment`,
2182
- * unless they are explicitly decorated with the custom align attribute
2183
- * via `d.align` function.
2184
- */
2185
- interface Disarray<TElement extends BaseData = BaseData> extends BaseData {
2186
- readonly type: 'disarray';
2187
- readonly elementCount: number;
2188
- readonly elementType: TElement;
2189
- readonly [$repr]: Infer<TElement>[];
2190
- readonly [$reprPartial]: {
2191
- idx: number;
2192
- value: InferPartial<TElement>;
2193
- }[] | undefined;
2194
- readonly [$validVertexSchema]: IsValidVertexSchema<TElement>;
2195
- readonly [$invalidSchemaReason]: 'Disarrays are not host-shareable, use arrays instead';
2196
- }
2197
- /**
2198
- * Struct schema constructed via `d.unstruct` function.
2199
- *
2200
- * Useful for defining vertex buffers, as the standard layout restrictions do not apply.
2201
- * Members are not aligned in respect to their `byteAlignment`,
2202
- * unless they are explicitly decorated with the custom align attribute
2203
- * via `d.align` function.
2204
- */
2205
- interface Unstruct<TProps extends Record<string, BaseData> = any> extends BaseData, TgpuNamable {
2206
- (props: Prettify<InferRecord<TProps>>): Prettify<InferRecord<TProps>>;
2207
- readonly type: 'unstruct';
2208
- readonly propTypes: TProps;
2209
- readonly [$repr]: Prettify<InferRecord<TProps>>;
2210
- readonly [$gpuRepr]: Prettify<InferGPURecord<TProps>>;
2211
- readonly [$memIdent]: Unstruct<Prettify<MemIdentityRecord<TProps>>>;
2212
- readonly [$reprPartial]: Prettify<Partial<InferPartialRecord<TProps>>> | undefined;
2213
- readonly [$validVertexSchema]: {
2214
- [K in keyof TProps]: IsValidVertexSchema<TProps[K]>;
2215
- }[keyof TProps] extends true ? true : false;
2216
- readonly [$invalidSchemaReason]: 'Unstructs are not host-shareable, use structs instead';
2217
- }
2218
- interface LooseDecorated<TInner extends BaseData = BaseData, TAttribs extends unknown[] = unknown[]> extends BaseData {
2219
- readonly type: 'loose-decorated';
2220
- readonly inner: TInner;
2221
- readonly attribs: TAttribs;
2222
- readonly [$repr]: Infer<TInner>;
2223
- readonly [$invalidSchemaReason]: 'Loosely decorated schemas are not host-shareable';
2224
- readonly [$validVertexSchema]: IsValidVertexSchema<TInner>;
2225
- }
2226
- 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"];
2227
- type LooseTypeLiteral = (typeof looseTypeLiterals)[number];
2228
- type AnyLooseData = Disarray | Unstruct | LooseDecorated | PackedData;
2229
- declare function isLooseData(data: unknown): data is AnyLooseData;
2230
- /**
2231
- * Checks whether the passed in value is a disarray schema,
2232
- * as opposed to, e.g., a regular array schema.
2233
- *
2234
- * Array schemas can be used to describe uniform and storage buffers,
2235
- * whereas disarray schemas cannot. Disarrays are useful for
2236
- * defining vertex buffers instead.
2237
- *
2238
- * @example
2239
- * isDisarray(d.arrayOf(d.u32, 4)) // false
2240
- * isDisarray(d.disarrayOf(d.u32, 4)) // true
2241
- * isDisarray(d.vec3f) // false
2242
- */
2243
- declare function isDisarray<T extends Disarray>(schema: T | unknown): schema is T;
2244
- /**
2245
- * Checks whether passed in value is a unstruct schema,
2246
- * as opposed to, e.g., a struct schema.
2247
- *
2248
- * Struct schemas can be used to describe uniform and storage buffers,
2249
- * whereas unstruct schemas cannot. Unstructs are useful for
2250
- * defining vertex buffers instead.
2251
- *
2252
- * @example
2253
- * isUnstruct(d.struct({ a: d.u32 })) // false
2254
- * isUnstruct(d.unstruct({ a: d.u32 })) // true
2255
- * isUnstruct(d.vec3f) // false
2256
- */
2257
- declare function isUnstruct<T extends Unstruct>(schema: T | unknown): schema is T;
2258
- declare function isLooseDecorated<T extends LooseDecorated>(value: T | unknown): value is T;
2259
- declare function isData(value: unknown): value is AnyData;
2260
- type AnyData = AnyWgslData | AnyLooseData;
2261
- interface UnknownData {
2262
- readonly type: 'unknown';
2263
- }
2264
- declare const UnknownData: UnknownData;
2265
-
2266
- /**
2267
- * Type utility to extract the inner type from decorated types.
2268
- */
2269
- type Undecorate<T> = T extends {
2270
- readonly type: 'decorated' | 'loose-decorated';
2271
- readonly inner: infer TInner;
2272
- } ? TInner : T;
2273
- /**
2274
- * Type utility to undecorate all values in a record.
2275
- */
2276
- type UndecorateRecord<T extends Record<string, unknown>> = {
2277
- [Key in keyof T]: Undecorate<T[Key]>;
2278
- };
2279
2293
 
2280
2294
  /**
2281
2295
  * Extracts the inferred representation of a resource.
@@ -2323,6 +2337,9 @@ type InferPartialRecord<T extends Record<string | number | symbol, unknown>> = {
2323
2337
  type InferGPURecord<T extends Record<string | number | symbol, unknown>> = {
2324
2338
  [Key in keyof T]: InferGPU<T[Key]>;
2325
2339
  };
2340
+ type GPUValueOf<T> = T extends {
2341
+ [$gpuValueOf](...args: never[]): infer TValue;
2342
+ } ? TValue : T;
2326
2343
  type MemIdentity<T> = T extends {
2327
2344
  readonly [$memIdent]: infer TMemIdent;
2328
2345
  } ? TMemIdent : T;
@@ -2354,7 +2371,7 @@ type ExtractInvalidSchemaError<T, TPrefix extends string = ''> = [
2354
2371
 
2355
2372
  type DecoratedLocation<T extends BaseData> = Decorated<T, Location[]>;
2356
2373
  interface BaseData {
2357
- readonly [$internal]: true;
2374
+ readonly [$internal]: true | Record<string, any>;
2358
2375
  readonly type: string;
2359
2376
  readonly [$repr]: unknown;
2360
2377
  }
@@ -2905,8 +2922,11 @@ interface v4b extends Tuple4<boolean>, Swizzle4<v2b, v3b, v4b> {
2905
2922
  z: boolean;
2906
2923
  w: boolean;
2907
2924
  }
2925
+ type AnyFloat32VecInstance = v2f | v3f | v4f;
2908
2926
  type AnyFloatVecInstance = v2f | v2h | v3f | v3h | v4f | v4h;
2927
+ type AnyIntegerVecInstance = v2i | v2u | v3i | v3u | v4i | v4u;
2909
2928
  type AnyBooleanVecInstance = v2b | v3b | v4b;
2929
+ type AnySignedVecInstance = v2i | v2f | v2h | v3i | v3f | v3h | v4i | v4f | v4h;
2910
2930
  type AnyNumericVec2Instance = v2f | v2h | v2i | v2u;
2911
2931
  type AnyNumericVec3Instance = v3f | v3h | v3i | v3u;
2912
2932
  type AnyNumericVec4Instance = v4f | v4h | v4i | v4u;
@@ -2981,57 +3001,52 @@ type mBaseForVec<T extends AnyVecInstance> = T extends v2f ? m2x2f : T extends v
2981
3001
  * Boolean schema representing a single WGSL bool value.
2982
3002
  * Cannot be used inside buffers as it is not host-shareable.
2983
3003
  */
2984
- interface Bool extends BaseData {
3004
+ interface Bool extends DualFn<(v?: number | boolean) => boolean> {
2985
3005
  readonly type: 'bool';
2986
3006
  readonly [$repr]: boolean;
2987
3007
  readonly [$invalidSchemaReason]: 'Bool is not host-shareable, use U32 or I32 instead';
2988
- (v?: number | boolean): boolean;
2989
3008
  }
2990
3009
  /**
2991
3010
  * 32-bit float schema representing a single WGSL f32 value.
2992
3011
  */
2993
- interface F32 extends BaseData {
3012
+ interface F32 extends DualFn<(v?: number | boolean) => number> {
2994
3013
  readonly type: 'f32';
2995
3014
  readonly [$repr]: number;
2996
3015
  readonly [$validStorageSchema]: true;
2997
3016
  readonly [$validUniformSchema]: true;
2998
3017
  readonly [$validVertexSchema]: true;
2999
- (v?: number | boolean): number;
3000
3018
  }
3001
3019
  /**
3002
3020
  * 16-bit float schema representing a single WGSL f16 value.
3003
3021
  */
3004
- interface F16 extends BaseData {
3022
+ interface F16 extends DualFn<(v?: number | boolean) => number> {
3005
3023
  readonly type: 'f16';
3006
3024
  readonly [$repr]: number;
3007
3025
  readonly [$validStorageSchema]: true;
3008
3026
  readonly [$validUniformSchema]: true;
3009
3027
  readonly [$validVertexSchema]: true;
3010
- (v?: number | boolean): number;
3011
3028
  }
3012
3029
  /**
3013
3030
  * Signed 32-bit integer schema representing a single WGSL i32 value.
3014
3031
  */
3015
- interface I32 extends BaseData {
3032
+ interface I32 extends DualFn<(v?: number | boolean) => number> {
3016
3033
  readonly type: 'i32';
3017
3034
  readonly [$repr]: number;
3018
3035
  readonly [$memIdent]: I32 | Atomic<I32> | DecoratedLocation<I32>;
3019
3036
  readonly [$validStorageSchema]: true;
3020
3037
  readonly [$validUniformSchema]: true;
3021
3038
  readonly [$validVertexSchema]: true;
3022
- (v?: number | boolean): number;
3023
3039
  }
3024
3040
  /**
3025
3041
  * Unsigned 32-bit integer schema representing a single WGSL u32 value.
3026
3042
  */
3027
- interface U32 extends BaseData {
3043
+ interface U32 extends DualFn<(v?: number | boolean) => number> {
3028
3044
  readonly type: 'u32';
3029
3045
  readonly [$repr]: number;
3030
3046
  readonly [$memIdent]: U32 | Atomic<U32> | DecoratedLocation<U32>;
3031
3047
  readonly [$validStorageSchema]: true;
3032
3048
  readonly [$validUniformSchema]: true;
3033
3049
  readonly [$validVertexSchema]: true;
3034
- (v?: number | boolean): number;
3035
3050
  }
3036
3051
  /**
3037
3052
  * Unsigned 16-bit integer schema used exclusively for index buffer schemas.
@@ -3044,249 +3059,149 @@ interface U16 extends BaseData {
3044
3059
  /**
3045
3060
  * Type of the `d.vec2f` object/function: vector data type schema/constructor
3046
3061
  */
3047
- interface Vec2f extends BaseData {
3062
+ interface Vec2f extends DualFn<((x: number, y: number) => v2f) & ((xy: number) => v2f) & (() => v2f) & ((v: AnyNumericVec2Instance) => v2f)> {
3048
3063
  readonly type: 'vec2f';
3049
3064
  readonly [$repr]: v2f;
3050
3065
  readonly [$validStorageSchema]: true;
3051
3066
  readonly [$validUniformSchema]: true;
3052
3067
  readonly [$validVertexSchema]: true;
3053
- (x: number, y: number): v2f;
3054
- (xy: number): v2f;
3055
- (): v2f;
3056
- (v: AnyNumericVec2Instance): v2f;
3057
3068
  }
3058
3069
  /**
3059
3070
  * Type of the `d.vec2h` object/function: vector data type schema/constructor
3060
3071
  */
3061
- interface Vec2h extends BaseData {
3072
+ interface Vec2h extends DualFn<((x: number, y: number) => v2h) & ((xy: number) => v2h) & (() => v2h) & ((v: AnyNumericVec2Instance) => v2h)> {
3062
3073
  readonly type: 'vec2h';
3063
3074
  readonly [$repr]: v2h;
3064
3075
  readonly [$validStorageSchema]: true;
3065
3076
  readonly [$validUniformSchema]: true;
3066
3077
  readonly [$validVertexSchema]: true;
3067
- (x: number, y: number): v2h;
3068
- (xy: number): v2h;
3069
- (): v2h;
3070
- (v: AnyNumericVec2Instance): v2h;
3071
3078
  }
3072
3079
  /**
3073
3080
  * Type of the `d.vec2i` object/function: vector data type schema/constructor
3074
3081
  */
3075
- interface Vec2i extends BaseData {
3082
+ interface Vec2i extends DualFn<((x: number, y: number) => v2i) & ((xy: number) => v2i) & (() => v2i) & ((v: AnyNumericVec2Instance) => v2i)> {
3076
3083
  readonly type: 'vec2i';
3077
3084
  readonly [$repr]: v2i;
3078
3085
  readonly [$validStorageSchema]: true;
3079
3086
  readonly [$validUniformSchema]: true;
3080
3087
  readonly [$validVertexSchema]: true;
3081
- (x: number, y: number): v2i;
3082
- (xy: number): v2i;
3083
- (): v2i;
3084
- (v: AnyNumericVec2Instance): v2i;
3085
3088
  }
3086
3089
  /**
3087
3090
  * Type of the `d.vec2u` object/function: vector data type schema/constructor
3088
3091
  */
3089
- interface Vec2u extends BaseData {
3092
+ interface Vec2u extends DualFn<((x: number, y: number) => v2u) & ((xy: number) => v2u) & (() => v2u) & ((v: AnyNumericVec2Instance) => v2u)> {
3090
3093
  readonly type: 'vec2u';
3091
3094
  readonly [$repr]: v2u;
3092
3095
  readonly [$validStorageSchema]: true;
3093
3096
  readonly [$validUniformSchema]: true;
3094
3097
  readonly [$validVertexSchema]: true;
3095
- (x: number, y: number): v2u;
3096
- (xy: number): v2u;
3097
- (): v2u;
3098
- (v: AnyNumericVec2Instance): v2u;
3099
3098
  }
3100
3099
  /**
3101
3100
  * Type of the `d.vec2b` object/function: vector data type schema/constructor
3102
3101
  * Cannot be used inside buffers as it is not host-shareable.
3103
3102
  */
3104
- interface Vec2b extends BaseData {
3103
+ interface Vec2b extends DualFn<((x: boolean, y: boolean) => v2b) & ((xy: boolean) => v2b) & (() => v2b) & ((v: v2b) => v2b)> {
3105
3104
  readonly type: 'vec2<bool>';
3106
3105
  readonly [$repr]: v2b;
3107
3106
  readonly [$invalidSchemaReason]: 'Boolean vectors is not host-shareable, use numeric vectors instead';
3108
- (x: boolean, y: boolean): v2b;
3109
- (xy: boolean): v2b;
3110
- (): v2b;
3111
- (v: v2b): v2b;
3112
3107
  }
3113
3108
  /**
3114
3109
  * Type of the `d.vec3f` object/function: vector data type schema/constructor
3115
3110
  */
3116
- interface Vec3f extends BaseData {
3111
+ interface Vec3f extends DualFn<((x: number, y: number, z: number) => v3f) & ((xyz: number) => v3f) & (() => v3f) & ((v: AnyNumericVec3Instance) => v3f) & ((v0: AnyNumericVec2Instance, z: number) => v3f) & ((x: number, v0: AnyNumericVec2Instance) => v3f)> {
3117
3112
  readonly type: 'vec3f';
3118
3113
  readonly [$repr]: v3f;
3119
3114
  readonly [$validStorageSchema]: true;
3120
3115
  readonly [$validUniformSchema]: true;
3121
3116
  readonly [$validVertexSchema]: true;
3122
- (x: number, y: number, z: number): v3f;
3123
- (xyz: number): v3f;
3124
- (): v3f;
3125
- (v: AnyNumericVec3Instance): v3f;
3126
- (v0: AnyNumericVec2Instance, z: number): v3f;
3127
- (x: number, v0: AnyNumericVec2Instance): v3f;
3128
3117
  }
3129
3118
  /**
3130
3119
  * Type of the `d.vec3h` object/function: vector data type schema/constructor
3131
3120
  */
3132
- interface Vec3h extends BaseData {
3121
+ interface Vec3h extends DualFn<((x: number, y: number, z: number) => v3h) & ((xyz: number) => v3h) & (() => v3h) & ((v: AnyNumericVec3Instance) => v3h) & ((v0: AnyNumericVec2Instance, z: number) => v3h) & ((x: number, v0: AnyNumericVec2Instance) => v3h)> {
3133
3122
  readonly type: 'vec3h';
3134
3123
  readonly [$repr]: v3h;
3135
3124
  readonly [$validStorageSchema]: true;
3136
3125
  readonly [$validUniformSchema]: true;
3137
3126
  readonly [$validVertexSchema]: true;
3138
- (x: number, y: number, z: number): v3h;
3139
- (xyz: number): v3h;
3140
- (): v3h;
3141
- (v: AnyNumericVec3Instance): v3h;
3142
- (v0: AnyNumericVec2Instance, z: number): v3h;
3143
- (x: number, v0: AnyNumericVec2Instance): v3h;
3144
3127
  }
3145
3128
  /**
3146
3129
  * Type of the `d.vec3i` object/function: vector data type schema/constructor
3147
3130
  */
3148
- interface Vec3i extends BaseData {
3131
+ interface Vec3i extends DualFn<((x: number, y: number, z: number) => v3i) & ((xyz: number) => v3i) & (() => v3i) & ((v: AnyNumericVec3Instance) => v3i) & ((v0: AnyNumericVec2Instance, z: number) => v3i) & ((x: number, v0: AnyNumericVec2Instance) => v3i)> {
3149
3132
  readonly type: 'vec3i';
3150
3133
  readonly [$repr]: v3i;
3151
3134
  readonly [$validStorageSchema]: true;
3152
3135
  readonly [$validUniformSchema]: true;
3153
3136
  readonly [$validVertexSchema]: true;
3154
- (x: number, y: number, z: number): v3i;
3155
- (xyz: number): v3i;
3156
- (): v3i;
3157
- (v: AnyNumericVec3Instance): v3i;
3158
- (v0: AnyNumericVec2Instance, z: number): v3i;
3159
- (x: number, v0: AnyNumericVec2Instance): v3i;
3160
3137
  }
3161
3138
  /**
3162
3139
  * Type of the `d.vec3u` object/function: vector data type schema/constructor
3163
3140
  */
3164
- interface Vec3u extends BaseData {
3141
+ interface Vec3u extends DualFn<((x: number, y: number, z: number) => v3u) & ((xyz: number) => v3u) & (() => v3u) & ((v: AnyNumericVec3Instance) => v3u) & ((v0: AnyNumericVec2Instance, z: number) => v3u) & ((x: number, v0: AnyNumericVec2Instance) => v3u)> {
3165
3142
  readonly type: 'vec3u';
3166
3143
  readonly [$repr]: v3u;
3167
3144
  readonly [$validStorageSchema]: true;
3168
3145
  readonly [$validUniformSchema]: true;
3169
3146
  readonly [$validVertexSchema]: true;
3170
- (x: number, y: number, z: number): v3u;
3171
- (xyz: number): v3u;
3172
- (): v3u;
3173
- (v: AnyNumericVec3Instance): v3u;
3174
- (v0: AnyNumericVec2Instance, z: number): v3u;
3175
- (x: number, v0: AnyNumericVec2Instance): v3u;
3176
3147
  }
3177
3148
  /**
3178
3149
  * Type of the `d.vec3b` object/function: vector data type schema/constructor
3179
3150
  * Cannot be used inside buffers as it is not host-shareable.
3180
3151
  */
3181
- interface Vec3b extends BaseData {
3152
+ interface Vec3b extends DualFn<((x: boolean, y: boolean, z: boolean) => v3b) & ((xyz: boolean) => v3b) & (() => v3b) & ((v: v3b) => v3b) & ((v0: v2b, z: boolean) => v3b) & ((x: boolean, v0: v2b) => v3b)> {
3182
3153
  readonly type: 'vec3<bool>';
3183
3154
  readonly [$repr]: v3b;
3184
3155
  readonly [$invalidSchemaReason]: 'Boolean vectors is not host-shareable, use numeric vectors instead';
3185
- (x: boolean, y: boolean, z: boolean): v3b;
3186
- (xyz: boolean): v3b;
3187
- (): v3b;
3188
- (v: v3b): v3b;
3189
- (v0: v2b, z: boolean): v3b;
3190
- (x: boolean, v0: v2b): v3b;
3191
3156
  }
3192
3157
  /**
3193
3158
  * Type of the `d.vec4f` object/function: vector data type schema/constructor
3194
3159
  */
3195
- interface Vec4f extends BaseData {
3160
+ interface Vec4f extends DualFn<((x: number, y: number, z: number, w: number) => v4f) & ((xyzw: number) => v4f) & (() => v4f) & ((v: AnyNumericVec4Instance) => v4f) & ((v0: AnyNumericVec3Instance, w: number) => v4f) & ((x: number, v0: AnyNumericVec3Instance) => v4f) & ((v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance) => v4f) & ((v0: AnyNumericVec2Instance, z: number, w: number) => v4f) & ((x: number, v0: AnyNumericVec2Instance, z: number) => v4f) & ((x: number, y: number, v0: AnyNumericVec2Instance) => v4f)> {
3196
3161
  readonly type: 'vec4f';
3197
3162
  readonly [$repr]: v4f;
3198
3163
  readonly [$validStorageSchema]: true;
3199
3164
  readonly [$validUniformSchema]: true;
3200
3165
  readonly [$validVertexSchema]: true;
3201
- (x: number, y: number, z: number, w: number): v4f;
3202
- (xyzw: number): v4f;
3203
- (): v4f;
3204
- (v: AnyNumericVec4Instance): v4f;
3205
- (v0: AnyNumericVec3Instance, w: number): v4f;
3206
- (x: number, v0: AnyNumericVec3Instance): v4f;
3207
- (v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4f;
3208
- (v0: AnyNumericVec2Instance, z: number, w: number): v4f;
3209
- (x: number, v0: AnyNumericVec2Instance, z: number): v4f;
3210
- (x: number, y: number, v0: AnyNumericVec2Instance): v4f;
3211
3166
  }
3212
3167
  /**
3213
3168
  * Type of the `d.vec4h` object/function: vector data type schema/constructor
3214
3169
  */
3215
- interface Vec4h extends BaseData {
3170
+ interface Vec4h extends DualFn<((x: number, y: number, z: number, w: number) => v4h) & ((xyzw: number) => v4h) & (() => v4h) & ((v: AnyNumericVec4Instance) => v4h) & ((v0: AnyNumericVec3Instance, w: number) => v4h) & ((x: number, v0: AnyNumericVec3Instance) => v4h) & ((v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance) => v4h) & ((v0: AnyNumericVec2Instance, z: number, w: number) => v4h) & ((x: number, v0: AnyNumericVec2Instance, z: number) => v4h) & ((x: number, y: number, v0: AnyNumericVec2Instance) => v4h)> {
3216
3171
  readonly type: 'vec4h';
3217
3172
  readonly [$repr]: v4h;
3218
3173
  readonly [$validStorageSchema]: true;
3219
3174
  readonly [$validUniformSchema]: true;
3220
3175
  readonly [$validVertexSchema]: true;
3221
- (x: number, y: number, z: number, w: number): v4h;
3222
- (xyzw: number): v4h;
3223
- (): v4h;
3224
- (v: AnyNumericVec4Instance): v4h;
3225
- (v0: AnyNumericVec3Instance, w: number): v4h;
3226
- (x: number, v0: AnyNumericVec3Instance): v4h;
3227
- (v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4h;
3228
- (v0: AnyNumericVec2Instance, z: number, w: number): v4h;
3229
- (x: number, v0: AnyNumericVec2Instance, z: number): v4h;
3230
- (x: number, y: number, v0: AnyNumericVec2Instance): v4h;
3231
3176
  }
3232
3177
  /**
3233
3178
  * Type of the `d.vec4i` object/function: vector data type schema/constructor
3234
3179
  */
3235
- interface Vec4i extends BaseData {
3180
+ interface Vec4i extends DualFn<((x: number, y: number, z: number, w: number) => v4i) & ((xyzw: number) => v4i) & (() => v4i) & ((v: AnyNumericVec4Instance) => v4i) & ((v0: AnyNumericVec3Instance, w: number) => v4i) & ((x: number, v0: AnyNumericVec3Instance) => v4i) & ((v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance) => v4i) & ((v0: AnyNumericVec2Instance, z: number, w: number) => v4i) & ((x: number, v0: AnyNumericVec2Instance, z: number) => v4i) & ((x: number, y: number, v0: AnyNumericVec2Instance) => v4i)> {
3236
3181
  readonly type: 'vec4i';
3237
3182
  readonly [$repr]: v4i;
3238
3183
  readonly [$validStorageSchema]: true;
3239
3184
  readonly [$validUniformSchema]: true;
3240
3185
  readonly [$validVertexSchema]: true;
3241
- (x: number, y: number, z: number, w: number): v4i;
3242
- (xyzw: number): v4i;
3243
- (): v4i;
3244
- (v: AnyNumericVec4Instance): v4i;
3245
- (v0: AnyNumericVec3Instance, w: number): v4i;
3246
- (x: number, v0: AnyNumericVec3Instance): v4i;
3247
- (v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4i;
3248
- (v0: AnyNumericVec2Instance, z: number, w: number): v4i;
3249
- (x: number, v0: AnyNumericVec2Instance, z: number): v4i;
3250
- (x: number, y: number, v0: AnyNumericVec2Instance): v4i;
3251
3186
  }
3252
3187
  /**
3253
3188
  * Type of the `d.vec4u` object/function: vector data type schema/constructor
3254
3189
  */
3255
- interface Vec4u extends BaseData {
3190
+ interface Vec4u extends DualFn<((x: number, y: number, z: number, w: number) => v4u) & ((xyzw: number) => v4u) & (() => v4u) & ((v: AnyNumericVec4Instance) => v4u) & ((v0: AnyNumericVec3Instance, w: number) => v4u) & ((x: number, v0: AnyNumericVec3Instance) => v4u) & ((v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance) => v4u) & ((v0: AnyNumericVec2Instance, z: number, w: number) => v4u) & ((x: number, v0: AnyNumericVec2Instance, z: number) => v4u) & ((x: number, y: number, v0: AnyNumericVec2Instance) => v4u)> {
3256
3191
  readonly type: 'vec4u';
3257
3192
  readonly [$repr]: v4u;
3258
3193
  readonly [$validStorageSchema]: true;
3259
3194
  readonly [$validUniformSchema]: true;
3260
3195
  readonly [$validVertexSchema]: true;
3261
- (x: number, y: number, z: number, w: number): v4u;
3262
- (xyzw: number): v4u;
3263
- (): v4u;
3264
- (v: AnyNumericVec4Instance): v4u;
3265
- (v0: AnyNumericVec3Instance, w: number): v4u;
3266
- (x: number, v0: AnyNumericVec3Instance): v4u;
3267
- (v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4u;
3268
- (v0: AnyNumericVec2Instance, z: number, w: number): v4u;
3269
- (x: number, v0: AnyNumericVec2Instance, z: number): v4u;
3270
- (x: number, y: number, v0: AnyNumericVec2Instance): v4u;
3271
3196
  }
3272
3197
  /**
3273
3198
  * Type of the `d.vec4b` object/function: vector data type schema/constructor
3274
3199
  * Cannot be used inside buffers as it is not host-shareable.
3275
3200
  */
3276
- interface Vec4b extends BaseData {
3201
+ interface Vec4b extends DualFn<((x: boolean, y: boolean, z: boolean, w: boolean) => v4b) & ((xyzw: boolean) => v4b) & (() => v4b) & ((v: v4b) => v4b) & ((v0: v3b, w: boolean) => v4b) & ((x: boolean, v0: v3b) => v4b) & ((v0: v2b, v1: v2b) => v4b) & ((v0: v2b, z: boolean, w: boolean) => v4b) & ((x: boolean, v0: v2b, z: boolean) => v4b) & ((x: boolean, y: boolean, v0: v2b) => v4b)> {
3277
3202
  readonly type: 'vec4<bool>';
3278
3203
  readonly [$repr]: v4b;
3279
3204
  readonly [$invalidSchemaReason]: 'Boolean vectors is not host-shareable, use numeric vectors instead';
3280
- (x: boolean, y: boolean, z: boolean, w: boolean): v4b;
3281
- (xyzw: boolean): v4b;
3282
- (): v4b;
3283
- (v: v4b): v4b;
3284
- (v0: v3b, w: boolean): v4b;
3285
- (x: boolean, v0: v3b): v4b;
3286
- (v0: v2b, v1: v2b): v4b;
3287
- (v0: v2b, z: boolean, w: boolean): v4b;
3288
- (x: boolean, v0: v2b, z: boolean): v4b;
3289
- (x: boolean, y: boolean, v0: v2b): v4b;
3290
3205
  }
3291
3206
  /**
3292
3207
  * Type of the `d.mat2x2f` object/function: matrix data type schema/constructor
@@ -3365,6 +3280,9 @@ interface WgslArray<TElement extends BaseData = BaseData> extends BaseData {
3365
3280
  * the `byteAlignment` requirement of its members.
3366
3281
  */
3367
3282
  interface WgslStruct<TProps extends Record<string, BaseData> = any> extends BaseData, TgpuNamable {
3283
+ readonly [$internal]: {
3284
+ isAbstruct: boolean;
3285
+ };
3368
3286
  readonly type: 'struct';
3369
3287
  readonly propTypes: TProps;
3370
3288
  (props: Prettify<InferRecord<TProps>>): Prettify<InferRecord<TProps>>;
@@ -3524,6 +3442,7 @@ declare function isBuiltinAttrib<T extends Builtin<string>>(value: unknown | T):
3524
3442
  declare function isDecorated<T extends Decorated>(value: unknown | T): value is T;
3525
3443
 
3526
3444
  interface TgpuConst<TDataType extends AnyWgslData = AnyWgslData> extends TgpuNamable {
3445
+ [$gpuValueOf](): InferGPU<TDataType>;
3527
3446
  readonly value: InferGPU<TDataType>;
3528
3447
  readonly $: InferGPU<TDataType>;
3529
3448
  readonly [$internal]: {
@@ -3536,4 +3455,4 @@ interface TgpuConst<TDataType extends AnyWgslData = AnyWgslData> extends TgpuNam
3536
3455
  */
3537
3456
  declare function constant<TDataType extends AnyWgslData>(dataType: TDataType, value: InferGPU<TDataType>): TgpuConst<TDataType>;
3538
3457
 
3539
- export { type TgpuComputePipeline as $, type AnyData as A, isDerived as B, type Configurable as C, type Disarray as D, isSlot as E, isComparisonSampler as F, isSampler as G, isSampledTextureView as H, type Infer as I, isStorageTextureView as J, isTexture as K, isUsableAsRender as L, isUsableAsSampled as M, isUsableAsStorage as N, isUsableAsUniform as O, isBufferShorthand as P, isTgpuFn as Q, type WithBinding as R, type WithCompute as S, type TgpuBindGroupLayout as T, type WithFragment as U, type ValidateBufferSchema as V, type Wgsl as W, type WithVertex as X, type Storage as Y, type StorageFlag as Z, type TgpuRenderPipeline as _, type TgpuBindGroup as a, type Vec3u as a$, type IndexFlag as a0, type Uniform as a1, type UniformFlag as a2, type ValidUsagesFor as a3, type Vertex as a4, type VertexFlag as a5, type TgpuBufferMutable as a6, type TgpuBufferReadonly as a7, type TgpuBufferUniform as a8, type TgpuMutable as a9, type TgpuLayoutUniform as aA, type TgpuFnShell as aB, type TgpuVertexFn as aC, type TgpuVertexFnShell as aD, type TgpuFragmentFn as aE, type TgpuFragmentFnShell as aF, type TgpuComputeFn as aG, type TgpuComputeFnShell as aH, type TgpuDeclare as aI, type INTERNAL_GlobalExt as aJ, type Bool as aK, type F16 as aL, type F32 as aM, type I32 as aN, type U16 as aO, type U32 as aP, type WgslStruct as aQ, type Ptr as aR, type Vec2b as aS, type Vec2f as aT, type Vec2h as aU, type Vec2i as aV, type Vec2u as aW, type Vec3b as aX, type Vec3f as aY, type Vec3h as aZ, type Vec3i as a_, type TgpuReadonly as aa, type TgpuUniform as ab, type Eventual as ac, type TgpuAnyTextureView as ad, type TgpuMutableTexture as ae, type TgpuReadonlyTexture as af, type TgpuSampledTexture as ag, type TgpuTexture as ah, type TgpuWriteonlyTexture as ai, type TextureProps as aj, type Render as ak, type Sampled as al, type TgpuConst as am, type VariableScope as an, type TgpuSampler as ao, type TgpuQuerySet as ap, type BindLayoutEntry as aq, type ExtractBindGroupInputFromLayout as ar, type LayoutEntryToInput as as, type TgpuLayoutComparisonSampler as at, type TgpuLayoutEntry as au, type TgpuLayoutExternalTexture as av, type TgpuLayoutSampler as aw, type TgpuLayoutStorage as ax, type TgpuLayoutStorageTexture as ay, type TgpuLayoutTexture as az, type TgpuBuffer as b, type AnyBuiltin as b$, type Vec4b as b0, type Vec4f as b1, type Vec4h as b2, type Vec4i as b3, type Vec4u as b4, type BaseData as b5, type Unstruct as b6, type Atomic as b7, isAlignAttrib as b8, isAtomic as b9, type v2i as bA, type v2u as bB, type v3b as bC, type v3f as bD, type v3i as bE, type v3u as bF, type v4b as bG, type v4f as bH, type v4i as bI, type v4u as bJ, type AnyLooseData as bK, type LooseDecorated as bL, align as bM, type AnyAttribute as bN, type HasCustomLocation as bO, interpolate as bP, invariant as bQ, type IsBuiltin as bR, isBuiltin as bS, location as bT, size as bU, isData as bV, isDisarray as bW, isLooseData as bX, isLooseDecorated as bY, isUnstruct as bZ, builtin as b_, isBuiltinAttrib as ba, isDecorated as bb, isInterpolateAttrib as bc, isLocationAttrib as bd, isPtr as be, isSizeAttrib as bf, isWgslArray as bg, isWgslData as bh, isWgslStruct as bi, Void 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 m2x2f as br, type m3x3f as bs, type m4x4f as bt, type Mat2x2f as bu, type Mat3x3f as bv, type Mat4x4f as bw, type Size as bx, type v2b as by, type v2f as bz, type TgpuVar as c, type AnyNumericVecInstance as c$, type BuiltinClipDistances as c0, type BuiltinFragDepth as c1, type BuiltinFrontFacing as c2, type BuiltinGlobalInvocationId as c3, type BuiltinInstanceIndex as c4, type BuiltinLocalInvocationId as c5, type BuiltinLocalInvocationIndex as c6, type BuiltinNumWorkgroups as c7, type BuiltinPosition as c8, type BuiltinSampleIndex as c9, sint16x4 as cA, unorm16 as cB, unorm16x2 as cC, unorm16x4 as cD, snorm16 as cE, snorm16x2 as cF, snorm16x4 as cG, float16 as cH, float16x2 as cI, float16x4 as cJ, float32 as cK, float32x2 as cL, float32x3 as cM, float32x4 as cN, uint32 as cO, uint32x2 as cP, uint32x3 as cQ, uint32x4 as cR, sint32 as cS, sint32x2 as cT, sint32x3 as cU, sint32x4 as cV, unorm10_10_10_2 as cW, unorm8x4_bgra as cX, type PackedData as cY, isPackedData as cZ, type TgpuDualFn as c_, type BuiltinSampleMask as ca, type BuiltinVertexIndex as cb, type BuiltinWorkgroupId as cc, type InferGPU as cd, type InferPartial as ce, type FormatToWGSLType as cf, type TgpuVertexFormatData as cg, formatToWGSLType as ch, packedFormats as ci, uint8 as cj, uint8x2 as ck, uint8x4 as cl, sint8 as cm, sint8x2 as cn, sint8x4 as co, unorm8 as cp, unorm8x2 as cq, unorm8x4 as cr, snorm8 as cs, snorm8x2 as ct, snorm8x4 as cu, uint16 as cv, uint16x2 as cw, uint16x4 as cx, sint16 as cy, sint16x2 as cz, type TgpuRoot as d, type AnyMatInstance as d0, type vBaseForMat as d1, type mBaseForVec as d2, type AnyFloatVecInstance as d3, type v3h as d4, type v2h as d5, type v4h as d6, type AnyVec2Instance as d7, type AnyVec3Instance as d8, type AnyBooleanVecInstance as d9, type atomicI32 as da, type atomicU32 as db, type TgpuStorageTexture as dc, type TexelData as dd, type ChannelData as de, type AnyWgslData as e, type TgpuFn as f, type TgpuBufferUsage as g, type TgpuAccessor as h, type TgpuDerived as i, type TgpuSlot as j, type TgpuVertexLayout as k, type WgslArray as l, fn as m, bindGroupLayout as n, fragmentFn as o, vertexFn as p, computeFn as q, privateVar as r, constant as s, declare as t, sampler as u, vertexLayout as v, workgroupVar as w, comparisonSampler as x, isBuffer as y, isUsableAsVertex as z };
3458
+ export { type TgpuComputePipeline as $, type AnyData as A, isDerived as B, type Configurable as C, type Disarray as D, isSlot as E, isComparisonSampler as F, isSampler as G, isSampledTextureView as H, type Infer as I, isStorageTextureView as J, isTexture as K, isUsableAsRender as L, isUsableAsSampled as M, isUsableAsStorage as N, isUsableAsUniform as O, isBufferShorthand as P, isTgpuFn as Q, type WithBinding as R, type WithCompute as S, type TgpuBindGroupLayout as T, type WithFragment as U, type ValidateBufferSchema as V, type Wgsl as W, type WithVertex as X, type Storage as Y, type StorageFlag as Z, type TgpuRenderPipeline as _, type TgpuBindGroup as a, type Vec3u as a$, type IndexFlag as a0, type Uniform as a1, type UniformFlag as a2, type ValidUsagesFor as a3, type Vertex as a4, type VertexFlag as a5, type TgpuBufferMutable as a6, type TgpuBufferReadonly as a7, type TgpuBufferUniform as a8, type TgpuMutable as a9, type TgpuLayoutUniform as aA, type TgpuFnShell as aB, type TgpuVertexFn as aC, type TgpuVertexFnShell as aD, type TgpuFragmentFn as aE, type TgpuFragmentFnShell as aF, type TgpuComputeFn as aG, type TgpuComputeFnShell as aH, type TgpuDeclare as aI, type INTERNAL_GlobalExt as aJ, type Bool as aK, type F16 as aL, type F32 as aM, type I32 as aN, type U16 as aO, type U32 as aP, type WgslStruct as aQ, type Ptr as aR, type Vec2b as aS, type Vec2f as aT, type Vec2h as aU, type Vec2i as aV, type Vec2u as aW, type Vec3b as aX, type Vec3f as aY, type Vec3h as aZ, type Vec3i as a_, type TgpuReadonly as aa, type TgpuUniform as ab, type Eventual as ac, type TgpuAnyTextureView as ad, type TgpuMutableTexture as ae, type TgpuReadonlyTexture as af, type TgpuSampledTexture as ag, type TgpuTexture as ah, type TgpuWriteonlyTexture as ai, type TextureProps as aj, type Render as ak, type Sampled as al, type TgpuConst as am, type VariableScope as an, type TgpuSampler as ao, type TgpuQuerySet as ap, type BindLayoutEntry as aq, type ExtractBindGroupInputFromLayout as ar, type LayoutEntryToInput as as, type TgpuLayoutComparisonSampler as at, type TgpuLayoutEntry as au, type TgpuLayoutExternalTexture as av, type TgpuLayoutSampler as aw, type TgpuLayoutStorage as ax, type TgpuLayoutStorageTexture as ay, type TgpuLayoutTexture as az, type TgpuBuffer as b, type AnyBuiltin as b$, type Vec4b as b0, type Vec4f as b1, type Vec4h as b2, type Vec4i as b3, type Vec4u as b4, type BaseData as b5, type Unstruct as b6, type Atomic as b7, isAlignAttrib as b8, isAtomic as b9, type v2i as bA, type v2u as bB, type v3b as bC, type v3f as bD, type v3i as bE, type v3u as bF, type v4b as bG, type v4f as bH, type v4i as bI, type v4u as bJ, type AnyLooseData as bK, type LooseDecorated as bL, align as bM, type AnyAttribute as bN, type HasCustomLocation as bO, interpolate as bP, invariant as bQ, type IsBuiltin as bR, isBuiltin as bS, location as bT, size as bU, isData as bV, isDisarray as bW, isLooseData as bX, isLooseDecorated as bY, isUnstruct as bZ, builtin as b_, isBuiltinAttrib as ba, isDecorated as bb, isInterpolateAttrib as bc, isLocationAttrib as bd, isPtr as be, isSizeAttrib as bf, isWgslArray as bg, isWgslData as bh, isWgslStruct as bi, Void 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 m2x2f as br, type m3x3f as bs, type m4x4f as bt, type Mat2x2f as bu, type Mat3x3f as bv, type Mat4x4f as bw, type Size as bx, type v2b as by, type v2f as bz, type TgpuVar as c, type AnyNumericVecInstance as c$, type BuiltinClipDistances as c0, type BuiltinFragDepth as c1, type BuiltinFrontFacing as c2, type BuiltinGlobalInvocationId as c3, type BuiltinInstanceIndex as c4, type BuiltinLocalInvocationId as c5, type BuiltinLocalInvocationIndex as c6, type BuiltinNumWorkgroups as c7, type BuiltinPosition as c8, type BuiltinSampleIndex as c9, sint16x4 as cA, unorm16 as cB, unorm16x2 as cC, unorm16x4 as cD, snorm16 as cE, snorm16x2 as cF, snorm16x4 as cG, float16 as cH, float16x2 as cI, float16x4 as cJ, float32 as cK, float32x2 as cL, float32x3 as cM, float32x4 as cN, uint32 as cO, uint32x2 as cP, uint32x3 as cQ, uint32x4 as cR, sint32 as cS, sint32x2 as cT, sint32x3 as cU, sint32x4 as cV, unorm10_10_10_2 as cW, unorm8x4_bgra as cX, type PackedData as cY, isPackedData as cZ, type DualFn as c_, type BuiltinSampleMask as ca, type BuiltinVertexIndex as cb, type BuiltinWorkgroupId as cc, type InferGPU as cd, type InferPartial as ce, type FormatToWGSLType as cf, type TgpuVertexFormatData as cg, formatToWGSLType as ch, packedFormats as ci, uint8 as cj, uint8x2 as ck, uint8x4 as cl, sint8 as cm, sint8x2 as cn, sint8x4 as co, unorm8 as cp, unorm8x2 as cq, unorm8x4 as cr, snorm8 as cs, snorm8x2 as ct, snorm8x4 as cu, uint16 as cv, uint16x2 as cw, uint16x4 as cx, sint16 as cy, sint16x2 as cz, type TgpuRoot as d, type AnyFloatVecInstance as d0, type AnyIntegerVecInstance as d1, type v3h as d2, type AnyMatInstance as d3, type AbstractFloat as d4, type AbstractInt as d5, type AnyFloat32VecInstance as d6, type AnySignedVecInstance as d7, type vBaseForMat as d8, type mBaseForVec as d9, type AnyVec2Instance as da, type AnyVec3Instance as db, type AnyBooleanVecInstance as dc, type atomicI32 as dd, type atomicU32 as de, type TgpuStorageTexture as df, type TexelData as dg, type ChannelData as dh, type AnyWgslData as e, type TgpuFn as f, type TgpuBufferUsage as g, type TgpuAccessor as h, type TgpuDerived as i, type TgpuSlot as j, type TgpuVertexLayout as k, type WgslArray as l, fn as m, bindGroupLayout as n, fragmentFn as o, vertexFn as p, computeFn as q, privateVar as r, constant as s, declare as t, sampler as u, vertexLayout as v, workgroupVar as w, comparisonSampler as x, isBuffer as y, isUsableAsVertex as z };