typegpu 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/attributes-BdU8hyQq.d.cts +435 -0
  3. package/attributes-CAsvE5Z9.d.ts +435 -0
  4. package/chunk-5PJ3H5OR.js +2 -0
  5. package/chunk-5PJ3H5OR.js.map +1 -0
  6. package/chunk-7UUBX6MC.cjs +4 -0
  7. package/chunk-7UUBX6MC.cjs.map +1 -0
  8. package/chunk-AKBL6GDL.js +4 -0
  9. package/chunk-AKBL6GDL.js.map +1 -0
  10. package/chunk-URJCMUTT.cjs +2 -0
  11. package/chunk-URJCMUTT.cjs.map +1 -0
  12. package/data/index.cjs +1 -1
  13. package/data/index.cjs.map +1 -1
  14. package/data/index.d.cts +51 -4
  15. package/data/index.d.ts +51 -4
  16. package/data/index.js +1 -1
  17. package/index.cjs +17 -17
  18. package/index.cjs.map +1 -1
  19. package/index.d.cts +92 -53
  20. package/index.d.ts +92 -53
  21. package/index.js +17 -17
  22. package/index.js.map +1 -1
  23. package/package.json +2 -2
  24. package/std/index.cjs +1 -1
  25. package/std/index.cjs.map +1 -1
  26. package/std/index.d.cts +141 -33
  27. package/std/index.d.ts +141 -33
  28. package/std/index.js +1 -1
  29. package/std/index.js.map +1 -1
  30. package/{wgslTypes-VtSRoe90.d.ts → wgslTypes-Bh2dG5qv.d.cts} +213 -405
  31. package/{wgslTypes-VtSRoe90.d.cts → wgslTypes-Bh2dG5qv.d.ts} +213 -405
  32. package/attributes-B4JpvOTz.d.ts +0 -159
  33. package/attributes-DSOqT8yA.d.cts +0 -159
  34. package/chunk-3JTP2ATR.cjs +0 -2
  35. package/chunk-3JTP2ATR.cjs.map +0 -1
  36. package/chunk-3QXCKMEJ.cjs +0 -2
  37. package/chunk-3QXCKMEJ.cjs.map +0 -1
  38. package/chunk-DR55IHDD.js +0 -4
  39. package/chunk-DR55IHDD.js.map +0 -1
  40. package/chunk-KVOFUY5A.js +0 -2
  41. package/chunk-KVOFUY5A.js.map +0 -1
  42. package/chunk-QRLTUOBJ.cjs +0 -4
  43. package/chunk-QRLTUOBJ.cjs.map +0 -1
  44. package/chunk-VOFHV4Z6.js +0 -2
  45. package/chunk-VOFHV4Z6.js.map +0 -1
@@ -6,299 +6,7 @@ interface TgpuNamable {
6
6
  $name(label?: string | undefined): this;
7
7
  }
8
8
 
9
- type Default<T, TDefault> = unknown extends T ? TDefault : T extends undefined ? TDefault : T;
10
- type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
11
- type Prettify<T> = {
12
- [K in keyof T]: T[K];
13
- } & {};
14
- /**
15
- * Removes properties from record type that extend `Prop`
16
- */
17
- type OmitProps<T extends Record<string, unknown>, Prop> = Pick<T, {
18
- [Key in keyof T]: T[Key] extends Prop ? never : Key;
19
- }[keyof T]>;
20
- /**
21
- * The opposite of Readonly<T>
22
- */
23
- type Mutable<T> = {
24
- -readonly [P in keyof T]: T[P];
25
- };
26
-
27
- 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"];
28
- type VertexFormat = (typeof vertexFormats)[number];
29
- declare const kindToDefaultFormatMap: {
30
- readonly f32: "float32";
31
- readonly vec2f: "float32x2";
32
- readonly vec3f: "float32x3";
33
- readonly vec4f: "float32x4";
34
- readonly f16: "float16";
35
- readonly vec2h: "float16x2";
36
- readonly vec4h: "float16x4";
37
- readonly u32: "uint32";
38
- readonly vec2u: "uint32x2";
39
- readonly vec3u: "uint32x3";
40
- readonly vec4u: "uint32x4";
41
- readonly i32: "sint32";
42
- readonly vec2i: "sint32x2";
43
- readonly vec3i: "sint32x3";
44
- readonly vec4i: "sint32x4";
45
- };
46
- type KindToDefaultFormatMap = typeof kindToDefaultFormatMap;
47
- interface TgpuVertexAttrib<TFormat extends VertexFormat = VertexFormat> {
48
- readonly format: TFormat;
49
- readonly offset: number;
50
- }
51
- /**
52
- * All vertex attribute formats that can be interpreted as
53
- * an single or multi component u32 in a shader.
54
- * https://www.w3.org/TR/webgpu/#vertex-formats
55
- */
56
- type U32CompatibleFormats = TgpuVertexAttrib<'uint8'> | TgpuVertexAttrib<'uint8x2'> | TgpuVertexAttrib<'uint8x4'> | TgpuVertexAttrib<'uint16'> | TgpuVertexAttrib<'uint16x2'> | TgpuVertexAttrib<'uint16x4'> | TgpuVertexAttrib<'uint32'> | TgpuVertexAttrib<'uint32x2'> | TgpuVertexAttrib<'uint32x3'> | TgpuVertexAttrib<'uint32x4'>;
57
- /**
58
- * All vertex attribute formats that can be interpreted as
59
- * an single or multi component i32 in a shader.
60
- * https://www.w3.org/TR/webgpu/#vertex-formats
61
- */
62
- type I32CompatibleFormats = TgpuVertexAttrib<'sint8'> | TgpuVertexAttrib<'sint8x2'> | TgpuVertexAttrib<'sint8x4'> | TgpuVertexAttrib<'sint16'> | TgpuVertexAttrib<'sint16x2'> | TgpuVertexAttrib<'sint16x4'> | TgpuVertexAttrib<'sint32'> | TgpuVertexAttrib<'sint32x2'> | TgpuVertexAttrib<'sint32x3'> | TgpuVertexAttrib<'sint32x4'>;
63
- /**
64
- * All vertex attribute formats that can be interpreted as
65
- * an single or multi component f32 in a shader.
66
- * https://www.w3.org/TR/webgpu/#vertex-formats
67
- */
68
- 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'>;
69
- /**
70
- * All vertex attribute formats that can be interpreted as
71
- * a single or multi component f16 in a shader. (same as f32 on the shader side)
72
- * https://www.w3.org/TR/webgpu/#vertex-formats
73
- */
74
- type F16CompatibleFormats = F32CompatibleFormats;
75
- type KindToAcceptedAttribMap = {
76
- u32: U32CompatibleFormats;
77
- vec2u: U32CompatibleFormats;
78
- vec3u: U32CompatibleFormats;
79
- vec4u: U32CompatibleFormats;
80
- i32: I32CompatibleFormats;
81
- vec2i: I32CompatibleFormats;
82
- vec3i: I32CompatibleFormats;
83
- vec4i: I32CompatibleFormats;
84
- f16: F16CompatibleFormats;
85
- vec2h: F16CompatibleFormats;
86
- vec3h: F16CompatibleFormats;
87
- vec4h: F16CompatibleFormats;
88
- f32: F32CompatibleFormats;
89
- vec2f: F32CompatibleFormats;
90
- vec3f: F32CompatibleFormats;
91
- vec4f: F32CompatibleFormats;
92
- };
93
-
94
- type FormatToWGSLType<T extends VertexFormat> = (typeof formatToWGSLType)[T];
95
- interface TgpuVertexFormatData<T extends VertexFormat> {
96
- readonly '~repr': Infer<FormatToWGSLType<T>>;
97
- readonly type: T;
98
- }
99
- declare const formatToWGSLType: {
100
- readonly uint8: U32;
101
- readonly uint8x2: Vec2u;
102
- readonly uint8x4: Vec4u;
103
- readonly sint8: I32;
104
- readonly sint8x2: Vec2i;
105
- readonly sint8x4: Vec4i;
106
- readonly unorm8: F32;
107
- readonly unorm8x2: Vec2f;
108
- readonly unorm8x4: Vec4f;
109
- readonly snorm8: F32;
110
- readonly snorm8x2: Vec2f;
111
- readonly snorm8x4: Vec4f;
112
- readonly uint16: U32;
113
- readonly uint16x2: Vec2u;
114
- readonly uint16x4: Vec4u;
115
- readonly sint16: I32;
116
- readonly sint16x2: Vec2i;
117
- readonly sint16x4: Vec4i;
118
- readonly unorm16: F32;
119
- readonly unorm16x2: Vec2f;
120
- readonly unorm16x4: Vec4f;
121
- readonly snorm16: F32;
122
- readonly snorm16x2: Vec2f;
123
- readonly snorm16x4: Vec4f;
124
- readonly float16: F32;
125
- readonly float16x2: Vec2f;
126
- readonly float16x4: Vec4f;
127
- readonly float32: F32;
128
- readonly float32x2: Vec2f;
129
- readonly float32x3: Vec3f;
130
- readonly float32x4: Vec4f;
131
- readonly uint32: U32;
132
- readonly uint32x2: Vec2u;
133
- readonly uint32x3: Vec3u;
134
- readonly uint32x4: Vec4u;
135
- readonly sint32: I32;
136
- readonly sint32x2: Vec2i;
137
- readonly sint32x3: Vec3i;
138
- readonly sint32x4: Vec4i;
139
- readonly 'unorm10-10-10-2': Vec4f;
140
- readonly 'unorm8x4-bgra': Vec4f;
141
- };
142
- declare const packedFormats: string[];
143
- type uint8 = TgpuVertexFormatData<'uint8'>;
144
- declare const uint8: uint8;
145
- type uint8x2 = TgpuVertexFormatData<'uint8x2'>;
146
- declare const uint8x2: uint8x2;
147
- type uint8x4 = TgpuVertexFormatData<'uint8x4'>;
148
- declare const uint8x4: uint8x4;
149
- type sint8 = TgpuVertexFormatData<'sint8'>;
150
- declare const sint8: sint8;
151
- type sint8x2 = TgpuVertexFormatData<'sint8x2'>;
152
- declare const sint8x2: sint8x2;
153
- type sint8x4 = TgpuVertexFormatData<'sint8x4'>;
154
- declare const sint8x4: sint8x4;
155
- type unorm8 = TgpuVertexFormatData<'unorm8'>;
156
- declare const unorm8: unorm8;
157
- type unorm8x2 = TgpuVertexFormatData<'unorm8x2'>;
158
- declare const unorm8x2: unorm8x2;
159
- type unorm8x4 = TgpuVertexFormatData<'unorm8x4'>;
160
- declare const unorm8x4: unorm8x4;
161
- type snorm8 = TgpuVertexFormatData<'snorm8'>;
162
- declare const snorm8: snorm8;
163
- type snorm8x2 = TgpuVertexFormatData<'snorm8x2'>;
164
- declare const snorm8x2: snorm8x2;
165
- type snorm8x4 = TgpuVertexFormatData<'snorm8x4'>;
166
- declare const snorm8x4: snorm8x4;
167
- type uint16 = TgpuVertexFormatData<'uint16'>;
168
- declare const uint16: uint16;
169
- type uint16x2 = TgpuVertexFormatData<'uint16x2'>;
170
- declare const uint16x2: uint16x2;
171
- type uint16x4 = TgpuVertexFormatData<'uint16x4'>;
172
- declare const uint16x4: uint16x4;
173
- type sint16 = TgpuVertexFormatData<'sint16'>;
174
- declare const sint16: sint16;
175
- type sint16x2 = TgpuVertexFormatData<'sint16x2'>;
176
- declare const sint16x2: sint16x2;
177
- type sint16x4 = TgpuVertexFormatData<'sint16x4'>;
178
- declare const sint16x4: sint16x4;
179
- type unorm16 = TgpuVertexFormatData<'unorm16'>;
180
- declare const unorm16: unorm16;
181
- type unorm16x2 = TgpuVertexFormatData<'unorm16x2'>;
182
- declare const unorm16x2: unorm16x2;
183
- type unorm16x4 = TgpuVertexFormatData<'unorm16x4'>;
184
- declare const unorm16x4: unorm16x4;
185
- type snorm16 = TgpuVertexFormatData<'snorm16'>;
186
- declare const snorm16: snorm16;
187
- type snorm16x2 = TgpuVertexFormatData<'snorm16x2'>;
188
- declare const snorm16x2: snorm16x2;
189
- type snorm16x4 = TgpuVertexFormatData<'snorm16x4'>;
190
- declare const snorm16x4: snorm16x4;
191
- type float16 = TgpuVertexFormatData<'float16'>;
192
- declare const float16: float16;
193
- type float16x2 = TgpuVertexFormatData<'float16x2'>;
194
- declare const float16x2: float16x2;
195
- type float16x4 = TgpuVertexFormatData<'float16x4'>;
196
- declare const float16x4: float16x4;
197
- type float32 = TgpuVertexFormatData<'float32'>;
198
- declare const float32: float32;
199
- type float32x2 = TgpuVertexFormatData<'float32x2'>;
200
- declare const float32x2: float32x2;
201
- type float32x3 = TgpuVertexFormatData<'float32x3'>;
202
- declare const float32x3: float32x3;
203
- type float32x4 = TgpuVertexFormatData<'float32x4'>;
204
- declare const float32x4: float32x4;
205
- type uint32 = TgpuVertexFormatData<'uint32'>;
206
- declare const uint32: uint32;
207
- type uint32x2 = TgpuVertexFormatData<'uint32x2'>;
208
- declare const uint32x2: uint32x2;
209
- type uint32x3 = TgpuVertexFormatData<'uint32x3'>;
210
- declare const uint32x3: uint32x3;
211
- type uint32x4 = TgpuVertexFormatData<'uint32x4'>;
212
- declare const uint32x4: uint32x4;
213
- type sint32 = TgpuVertexFormatData<'sint32'>;
214
- declare const sint32: sint32;
215
- type sint32x2 = TgpuVertexFormatData<'sint32x2'>;
216
- declare const sint32x2: sint32x2;
217
- type sint32x3 = TgpuVertexFormatData<'sint32x3'>;
218
- declare const sint32x3: sint32x3;
219
- type sint32x4 = TgpuVertexFormatData<'sint32x4'>;
220
- declare const sint32x4: sint32x4;
221
- type unorm10_10_10_2 = TgpuVertexFormatData<'unorm10-10-10-2'>;
222
- declare const unorm10_10_10_2: unorm10_10_10_2;
223
- type unorm8x4_bgra = TgpuVertexFormatData<'unorm8x4-bgra'>;
224
- declare const unorm8x4_bgra: unorm8x4_bgra;
225
- 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;
226
-
227
- /**
228
- * Array schema constructed via `d.disarrayOf` function.
229
- *
230
- * Useful for defining vertex buffers.
231
- * Elements in the schema are not aligned in respect to their `byteAlignment`,
232
- * unless they are explicitly decorated with the custom align attribute
233
- * via `d.align` function.
234
- */
235
- interface Disarray<TElement extends BaseData = BaseData> {
236
- readonly type: 'disarray';
237
- readonly elementCount: number;
238
- readonly elementType: TElement;
239
- readonly '~repr': Infer<TElement>[];
240
- readonly '~reprPartial': {
241
- idx: number;
242
- value: InferPartial<TElement>;
243
- }[];
244
- }
245
- /**
246
- * Struct schema constructed via `d.unstruct` function.
247
- *
248
- * Useful for defining vertex buffers, as the standard layout restrictions do not apply.
249
- * Members are not aligned in respect to their `byteAlignment`,
250
- * unless they are explicitly decorated with the custom align attribute
251
- * via `d.align` function.
252
- */
253
- interface Unstruct<TProps extends Record<string, BaseData> = Record<string, BaseData>> extends TgpuNamable {
254
- readonly label?: string | undefined;
255
- readonly type: 'unstruct';
256
- readonly propTypes: TProps;
257
- readonly '~repr': Prettify<InferRecord<TProps>>;
258
- readonly '~reprPartial': Prettify<Partial<InferPartialRecord<TProps>>>;
259
- }
260
- interface LooseDecorated<TInner extends BaseData = BaseData, TAttribs extends unknown[] = unknown[]> {
261
- readonly type: 'loose-decorated';
262
- readonly inner: TInner;
263
- readonly attribs: TAttribs;
264
- readonly '~repr': Infer<TInner>;
265
- }
266
- 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"];
267
- type LooseTypeLiteral = (typeof looseTypeLiterals)[number];
268
- type AnyLooseData = Disarray | Unstruct | LooseDecorated | PackedData;
269
- declare function isLooseData(data: unknown): data is AnyLooseData;
270
- /**
271
- * Checks whether the passed in value is a disarray schema,
272
- * as opposed to, e.g., a regular array schema.
273
- *
274
- * Array schemas can be used to describe uniform and storage buffers,
275
- * whereas disarray schemas cannot. Disarrays are useful for
276
- * defining vertex buffers instead.
277
- *
278
- * @example
279
- * isDisarray(d.arrayOf(d.u32, 4)) // false
280
- * isDisarray(d.disarrayOf(d.u32, 4)) // true
281
- * isDisarray(d.vec3f) // false
282
- */
283
- declare function isDisarray<T extends Disarray>(schema: T | unknown): schema is T;
284
- /**
285
- * Checks whether passed in value is a unstruct schema,
286
- * as opposed to, e.g., a struct schema.
287
- *
288
- * Struct schemas can be used to describe uniform and storage buffers,
289
- * whereas unstruct schemas cannot. Unstructs are useful for
290
- * defining vertex buffers instead.
291
- *
292
- * @example
293
- * isUnstruct(d.struct({ a: d.u32 })) // false
294
- * isUnstruct(d.unstruct({ a: d.u32 })) // true
295
- * isUnstruct(d.vec3f) // false
296
- */
297
- declare function isUnstruct<T extends Unstruct>(schema: T | unknown): schema is T;
298
- declare function isLooseDecorated<T extends LooseDecorated>(value: T | unknown): value is T;
299
- declare function isData(value: unknown): value is AnyData;
300
- type AnyData = AnyWgslData | AnyLooseData;
301
-
9
+ declare const $repr: unique symbol;
302
10
  /**
303
11
  * Extracts the inferred representation of a resource.
304
12
  * @example
@@ -306,12 +14,12 @@ type AnyData = AnyWgslData | AnyLooseData;
306
14
  * type B = Infer<WgslArray<F32>> // => number[]
307
15
  */
308
16
  type Infer<T> = T extends {
309
- readonly '~repr': infer TRepr;
17
+ readonly [$repr]: infer TRepr;
310
18
  } ? TRepr : T;
311
19
  type InferPartial<T> = T extends {
312
20
  readonly '~reprPartial': infer TRepr;
313
21
  } ? TRepr : T extends {
314
- readonly '~repr': infer TRepr;
22
+ readonly [$repr]: infer TRepr;
315
23
  } ? TRepr | undefined : T extends Record<string | number | symbol, unknown> ? InferPartialRecord<T> : T;
316
24
  type InferGPU<T> = T extends {
317
25
  readonly '~gpuRepr': infer TRepr;
@@ -326,70 +34,59 @@ type InferGPURecord<T extends Record<string | number | symbol, unknown>> = {
326
34
  [Key in keyof T]: InferGPU<T[Key]>;
327
35
  };
328
36
  type MemIdentity<T> = T extends {
329
- readonly '~memIdent': infer TMemIdent extends AnyData;
37
+ readonly '~memIdent': infer TMemIdent;
330
38
  } ? TMemIdent : T;
331
39
  type MemIdentityRecord<T extends Record<string | number | symbol, unknown>> = {
332
40
  [Key in keyof T]: MemIdentity<T[Key]>;
333
41
  };
334
42
 
43
+ type Default<T, TDefault> = unknown extends T ? TDefault : T extends undefined ? TDefault : T;
44
+ type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
45
+ type Prettify<T> = {
46
+ [K in keyof T]: T[K];
47
+ } & {};
335
48
  /**
336
- * Struct schema constructed via `d.struct` function.
337
- *
338
- * Responsible for handling reading and writing struct values
339
- * between binary and JS representation. Takes into account
340
- * the `byteAlignment` requirement of its members.
49
+ * Removes properties from record type that extend `Prop`
341
50
  */
342
- interface WgslStruct<TProps extends Record<string, BaseData> = Record<string, BaseData>> extends TgpuNamable {
343
- (props: InferRecord<TProps>): InferRecord<TProps>;
344
- readonly type: 'struct';
345
- readonly label?: string | undefined;
346
- readonly propTypes: TProps;
347
- /** Type-token, not available at runtime */
348
- readonly '~repr': Prettify<InferRecord<TProps>>;
349
- /** Type-token, not available at runtime */
350
- readonly '~gpuRepr': InferGPURecord<TProps>;
351
- /** Type-token, not available at runtime */
352
- readonly '~memIdent': WgslStruct<MemIdentityRecord<TProps>>;
353
- /** Type-token, not available at runtime */
354
- readonly '~reprPartial': Prettify<Partial<InferPartialRecord<TProps>>>;
355
- }
356
- type AnyWgslStruct = WgslStruct<any>;
51
+ type OmitProps<T extends Record<string, unknown>, Prop> = Pick<T, {
52
+ [Key in keyof T]: T[Key] extends Prop ? never : Key;
53
+ }[keyof T]>;
357
54
  /**
358
- * Creates a struct schema that can be used to construct GPU buffers.
359
- * Ensures proper alignment and padding of properties (as opposed to a `d.unstruct` schema).
360
- * The order of members matches the passed in properties object.
361
- *
362
- * @example
363
- * const CircleStruct = d.struct({ radius: d.f32, pos: d.vec3f });
364
- *
365
- * @param props Record with `string` keys and `TgpuData` values,
366
- * each entry describing one struct member.
55
+ * The opposite of Readonly<T>
367
56
  */
368
- declare function struct<TProps extends Record<string, AnyWgslData>>(props: TProps): WgslStruct<Prettify<TProps>>;
57
+ type Mutable<T> = {
58
+ -readonly [P in keyof T]: T[P];
59
+ };
369
60
 
370
61
  type DecoratedLocation<T extends BaseData> = Decorated<T, Location<number>[]>;
371
62
  interface NumberArrayView {
372
63
  readonly length: number;
373
64
  [n: number]: number;
374
65
  }
66
+ interface BooleanArrayView {
67
+ readonly length: number;
68
+ [n: number]: boolean;
69
+ }
375
70
  interface BaseData {
376
71
  type: string;
377
72
  /** Type-token, not available at runtime */
378
- readonly '~repr': unknown;
73
+ readonly [$repr]: unknown;
379
74
  }
380
75
  /**
381
76
  * Represents a 64-bit integer.
382
77
  */
383
78
  interface AbstractInt {
384
79
  readonly type: 'abstractInt';
385
- readonly '~repr': number;
80
+ /** Type-token, not available at runtime */
81
+ readonly [$repr]: number;
386
82
  }
387
83
  /**
388
84
  * Represents a 64-bit IEEE 754 floating point number.
389
85
  */
390
86
  interface AbstractFloat {
391
87
  readonly type: 'abstractFloat';
392
- readonly '~repr': number;
88
+ /** Type-token, not available at runtime */
89
+ readonly [$repr]: number;
393
90
  }
394
91
  interface Swizzle2<T2, T3, T4> {
395
92
  readonly xx: T2;
@@ -736,6 +433,16 @@ interface v2u extends NumberArrayView, Swizzle2<v2u, v3u, v4u> {
736
433
  x: number;
737
434
  y: number;
738
435
  }
436
+ /**
437
+ * Interface representing its WGSL vector type counterpart: `vec2<bool>`.
438
+ * A vector with 2 elements of type `bool`
439
+ */
440
+ interface v2b extends BooleanArrayView, Swizzle2<v2b, v3b, v4b> {
441
+ /** use to distinguish between vectors of the same size on the type level */
442
+ readonly kind: 'vec2<bool>';
443
+ x: boolean;
444
+ y: boolean;
445
+ }
739
446
  /**
740
447
  * Interface representing its WGSL vector type counterpart: vec3f or vec3<f32>.
741
448
  * A vector with 3 elements of type f32
@@ -780,6 +487,17 @@ interface v3u extends NumberArrayView, Swizzle3<v2u, v3u, v4u> {
780
487
  y: number;
781
488
  z: number;
782
489
  }
490
+ /**
491
+ * Interface representing its WGSL vector type counterpart: `vec3<bool>`.
492
+ * A vector with 3 elements of type `bool`
493
+ */
494
+ interface v3b extends BooleanArrayView, Swizzle3<v2b, v3b, v4b> {
495
+ /** use to distinguish between vectors of the same size on the type level */
496
+ readonly kind: 'vec3<bool>';
497
+ x: boolean;
498
+ y: boolean;
499
+ z: boolean;
500
+ }
783
501
  /**
784
502
  * Interface representing its WGSL vector type counterpart: vec4f or vec4<f32>.
785
503
  * A vector with 4 elements of type f32
@@ -828,11 +546,28 @@ interface v4u extends NumberArrayView, Swizzle4<v2u, v3u, v4u> {
828
546
  z: number;
829
547
  w: number;
830
548
  }
831
- type AnyVecInstance = v2f | v2h | v2i | v2u | v3f | v3h | v3i | v3u | v4f | v4h | v4i | v4u;
832
- type AnyVec2Instance = v2f | v2h | v2i | v2u;
833
- type AnyVec3Instance = v3f | v3h | v3i | v3u;
834
- type AnyVec4Instance = v4f | v4h | v4i | v4u;
835
- type VecKind = AnyVecInstance['kind'];
549
+ /**
550
+ * Interface representing its WGSL vector type counterpart: `vec4<bool>`.
551
+ * A vector with 4 elements of type `bool`
552
+ */
553
+ interface v4b extends BooleanArrayView, Swizzle4<v2b, v3b, v4b> {
554
+ /** use to distinguish between vectors of the same size on the type level */
555
+ readonly kind: 'vec4<bool>';
556
+ x: boolean;
557
+ y: boolean;
558
+ z: boolean;
559
+ w: boolean;
560
+ }
561
+ type AnyFloatVecInstance = v2f | v2h | v3f | v3h | v4f | v4h;
562
+ type AnyBooleanVecInstance = v2b | v3b | v4b;
563
+ type AnyNumericVec2Instance = v2f | v2h | v2i | v2u;
564
+ type AnyNumericVec3Instance = v3f | v3h | v3i | v3u;
565
+ type AnyNumericVec4Instance = v4f | v4h | v4i | v4u;
566
+ type AnyNumericVecInstance = AnyNumericVec2Instance | AnyNumericVec3Instance | AnyNumericVec4Instance;
567
+ type AnyVec2Instance = v2f | v2h | v2i | v2u | v2b;
568
+ type AnyVec3Instance = v3f | v3h | v3i | v3u | v3b;
569
+ type AnyVec4Instance = v4f | v4h | v4i | v4u | v4b;
570
+ type AnyVecInstance = AnyVec2Instance | AnyVec3Instance | AnyVec4Instance;
836
571
  interface matBase<TColumn> extends NumberArrayView {
837
572
  readonly columns: readonly TColumn[];
838
573
  }
@@ -892,7 +627,7 @@ type vBaseForMat<T extends AnyMatInstance> = T extends m2x2f ? v2f : T extends m
892
627
  */
893
628
  interface Bool {
894
629
  readonly type: 'bool';
895
- readonly '~repr': boolean;
630
+ readonly [$repr]: boolean;
896
631
  }
897
632
  /**
898
633
  * 32-bit float schema representing a single WGSL f32 value.
@@ -900,7 +635,7 @@ interface Bool {
900
635
  interface F32 {
901
636
  readonly type: 'f32';
902
637
  /** Type-token, not available at runtime */
903
- readonly '~repr': number;
638
+ readonly [$repr]: number;
904
639
  (v: number | boolean): number;
905
640
  }
906
641
  /**
@@ -909,7 +644,7 @@ interface F32 {
909
644
  interface F16 {
910
645
  readonly type: 'f16';
911
646
  /** Type-token, not available at runtime */
912
- readonly '~repr': number;
647
+ readonly [$repr]: number;
913
648
  (v: number | boolean): number;
914
649
  }
915
650
  /**
@@ -918,7 +653,7 @@ interface F16 {
918
653
  interface I32 {
919
654
  readonly type: 'i32';
920
655
  /** Type-token, not available at runtime */
921
- readonly '~repr': number;
656
+ readonly [$repr]: number;
922
657
  readonly '~memIdent': I32 | Atomic<I32> | DecoratedLocation<I32>;
923
658
  (v: number | boolean): number;
924
659
  }
@@ -928,7 +663,7 @@ interface I32 {
928
663
  interface U32 {
929
664
  readonly type: 'u32';
930
665
  /** Type-token, not available at runtime */
931
- readonly '~repr': number;
666
+ readonly [$repr]: number;
932
667
  readonly '~memIdent': U32 | Atomic<U32> | DecoratedLocation<U32>;
933
668
  (v: number | boolean): number;
934
669
  }
@@ -938,11 +673,11 @@ interface U32 {
938
673
  interface Vec2f {
939
674
  readonly type: 'vec2f';
940
675
  /** Type-token, not available at runtime */
941
- readonly '~repr': v2f;
676
+ readonly [$repr]: v2f;
942
677
  (x: number, y: number): v2f;
943
678
  (xy: number): v2f;
944
679
  (): v2f;
945
- (v: AnyVec2Instance): v2f;
680
+ (v: AnyNumericVec2Instance): v2f;
946
681
  }
947
682
  /**
948
683
  * Type of the `d.vec2h` object/function: vector data type schema/constructor
@@ -950,11 +685,11 @@ interface Vec2f {
950
685
  interface Vec2h {
951
686
  readonly type: 'vec2h';
952
687
  /** Type-token, not available at runtime */
953
- readonly '~repr': v2h;
688
+ readonly [$repr]: v2h;
954
689
  (x: number, y: number): v2h;
955
690
  (xy: number): v2h;
956
691
  (): v2h;
957
- (v: AnyVec2Instance): v2h;
692
+ (v: AnyNumericVec2Instance): v2h;
958
693
  }
959
694
  /**
960
695
  * Type of the `d.vec2i` object/function: vector data type schema/constructor
@@ -962,11 +697,11 @@ interface Vec2h {
962
697
  interface Vec2i {
963
698
  readonly type: 'vec2i';
964
699
  /** Type-token, not available at runtime */
965
- readonly '~repr': v2i;
700
+ readonly [$repr]: v2i;
966
701
  (x: number, y: number): v2i;
967
702
  (xy: number): v2i;
968
703
  (): v2i;
969
- (v: AnyVec2Instance): v2i;
704
+ (v: AnyNumericVec2Instance): v2i;
970
705
  }
971
706
  /**
972
707
  * Type of the `d.vec2u` object/function: vector data type schema/constructor
@@ -974,11 +709,24 @@ interface Vec2i {
974
709
  interface Vec2u {
975
710
  readonly type: 'vec2u';
976
711
  /** Type-token, not available at runtime */
977
- readonly '~repr': v2u;
712
+ readonly [$repr]: v2u;
978
713
  (x: number, y: number): v2u;
979
714
  (xy: number): v2u;
980
715
  (): v2u;
981
- (v: AnyVec2Instance): v2u;
716
+ (v: AnyNumericVec2Instance): v2u;
717
+ }
718
+ /**
719
+ * Type of the `d.vec2b` object/function: vector data type schema/constructor
720
+ * Cannot be used inside buffers as it is not host-shareable.
721
+ */
722
+ interface Vec2b {
723
+ readonly type: 'vec2<bool>';
724
+ /** Type-token, not available at runtime */
725
+ readonly [$repr]: v2b;
726
+ (x: boolean, y: boolean): v2b;
727
+ (xy: boolean): v2b;
728
+ (): v2b;
729
+ (v: v2b): v2b;
982
730
  }
983
731
  /**
984
732
  * Type of the `d.vec3f` object/function: vector data type schema/constructor
@@ -986,13 +734,13 @@ interface Vec2u {
986
734
  interface Vec3f {
987
735
  readonly type: 'vec3f';
988
736
  /** Type-token, not available at runtime */
989
- readonly '~repr': v3f;
737
+ readonly [$repr]: v3f;
990
738
  (x: number, y: number, z: number): v3f;
991
739
  (xyz: number): v3f;
992
740
  (): v3f;
993
- (v: AnyVec3Instance): v3f;
994
- (v0: AnyVec2Instance, z: number): v3f;
995
- (x: number, v0: AnyVec2Instance): v3f;
741
+ (v: AnyNumericVec3Instance): v3f;
742
+ (v0: AnyNumericVec2Instance, z: number): v3f;
743
+ (x: number, v0: AnyNumericVec2Instance): v3f;
996
744
  }
997
745
  /**
998
746
  * Type of the `d.vec3h` object/function: vector data type schema/constructor
@@ -1000,13 +748,13 @@ interface Vec3f {
1000
748
  interface Vec3h {
1001
749
  readonly type: 'vec3h';
1002
750
  /** Type-token, not available at runtime */
1003
- readonly '~repr': v3h;
751
+ readonly [$repr]: v3h;
1004
752
  (x: number, y: number, z: number): v3h;
1005
753
  (xyz: number): v3h;
1006
754
  (): v3h;
1007
- (v: AnyVec3Instance): v3h;
1008
- (v0: AnyVec2Instance, z: number): v3h;
1009
- (x: number, v0: AnyVec2Instance): v3h;
755
+ (v: AnyNumericVec3Instance): v3h;
756
+ (v0: AnyNumericVec2Instance, z: number): v3h;
757
+ (x: number, v0: AnyNumericVec2Instance): v3h;
1010
758
  }
1011
759
  /**
1012
760
  * Type of the `d.vec3i` object/function: vector data type schema/constructor
@@ -1014,13 +762,13 @@ interface Vec3h {
1014
762
  interface Vec3i {
1015
763
  readonly type: 'vec3i';
1016
764
  /** Type-token, not available at runtime */
1017
- readonly '~repr': v3i;
765
+ readonly [$repr]: v3i;
1018
766
  (x: number, y: number, z: number): v3i;
1019
767
  (xyz: number): v3i;
1020
768
  (): v3i;
1021
- (v: AnyVec3Instance): v3i;
1022
- (v0: AnyVec2Instance, z: number): v3i;
1023
- (x: number, v0: AnyVec2Instance): v3i;
769
+ (v: AnyNumericVec3Instance): v3i;
770
+ (v0: AnyNumericVec2Instance, z: number): v3i;
771
+ (x: number, v0: AnyNumericVec2Instance): v3i;
1024
772
  }
1025
773
  /**
1026
774
  * Type of the `d.vec3u` object/function: vector data type schema/constructor
@@ -1028,13 +776,28 @@ interface Vec3i {
1028
776
  interface Vec3u {
1029
777
  readonly type: 'vec3u';
1030
778
  /** Type-token, not available at runtime */
1031
- readonly '~repr': v3u;
779
+ readonly [$repr]: v3u;
1032
780
  (x: number, y: number, z: number): v3u;
1033
781
  (xyz: number): v3u;
1034
782
  (): v3u;
1035
- (v: AnyVec3Instance): v3u;
1036
- (v0: AnyVec2Instance, z: number): v3u;
1037
- (x: number, v0: AnyVec2Instance): v3u;
783
+ (v: AnyNumericVec3Instance): v3u;
784
+ (v0: AnyNumericVec2Instance, z: number): v3u;
785
+ (x: number, v0: AnyNumericVec2Instance): v3u;
786
+ }
787
+ /**
788
+ * Type of the `d.vec3b` object/function: vector data type schema/constructor
789
+ * Cannot be used inside buffers as it is not host-shareable.
790
+ */
791
+ interface Vec3b {
792
+ readonly type: 'vec3<bool>';
793
+ /** Type-token, not available at runtime */
794
+ readonly [$repr]: v3b;
795
+ (x: boolean, y: boolean, z: boolean): v3b;
796
+ (xyz: boolean): v3b;
797
+ (): v3b;
798
+ (v: v3b): v3b;
799
+ (v0: v2b, z: boolean): v3b;
800
+ (x: boolean, v0: v2b): v3b;
1038
801
  }
1039
802
  /**
1040
803
  * Type of the `d.vec4f` object/function: vector data type schema/constructor
@@ -1042,17 +805,17 @@ interface Vec3u {
1042
805
  interface Vec4f {
1043
806
  readonly type: 'vec4f';
1044
807
  /** Type-token, not available at runtime */
1045
- readonly '~repr': v4f;
808
+ readonly [$repr]: v4f;
1046
809
  (x: number, y: number, z: number, w: number): v4f;
1047
810
  (xyzw: number): v4f;
1048
811
  (): v4f;
1049
- (v: AnyVec4Instance): v4f;
1050
- (v0: AnyVec3Instance, w: number): v4f;
1051
- (x: number, v0: AnyVec3Instance): v4f;
1052
- (v0: AnyVec2Instance, v1: AnyVec2Instance): v4f;
1053
- (v0: AnyVec2Instance, z: number, w: number): v4f;
1054
- (x: number, v0: AnyVec2Instance, z: number): v4f;
1055
- (x: number, y: number, v0: AnyVec2Instance): v4f;
812
+ (v: AnyNumericVec4Instance): v4f;
813
+ (v0: AnyNumericVec3Instance, w: number): v4f;
814
+ (x: number, v0: AnyNumericVec3Instance): v4f;
815
+ (v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4f;
816
+ (v0: AnyNumericVec2Instance, z: number, w: number): v4f;
817
+ (x: number, v0: AnyNumericVec2Instance, z: number): v4f;
818
+ (x: number, y: number, v0: AnyNumericVec2Instance): v4f;
1056
819
  }
1057
820
  /**
1058
821
  * Type of the `d.vec4h` object/function: vector data type schema/constructor
@@ -1060,17 +823,17 @@ interface Vec4f {
1060
823
  interface Vec4h {
1061
824
  readonly type: 'vec4h';
1062
825
  /** Type-token, not available at runtime */
1063
- readonly '~repr': v4h;
826
+ readonly [$repr]: v4h;
1064
827
  (x: number, y: number, z: number, w: number): v4h;
1065
828
  (xyzw: number): v4h;
1066
829
  (): v4h;
1067
- (v: AnyVec4Instance): v4h;
1068
- (v0: AnyVec3Instance, w: number): v4h;
1069
- (x: number, v0: AnyVec3Instance): v4h;
1070
- (v0: AnyVec2Instance, v1: AnyVec2Instance): v4h;
1071
- (v0: AnyVec2Instance, z: number, w: number): v4h;
1072
- (x: number, v0: AnyVec2Instance, z: number): v4h;
1073
- (x: number, y: number, v0: AnyVec2Instance): v4h;
830
+ (v: AnyNumericVec4Instance): v4h;
831
+ (v0: AnyNumericVec3Instance, w: number): v4h;
832
+ (x: number, v0: AnyNumericVec3Instance): v4h;
833
+ (v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4h;
834
+ (v0: AnyNumericVec2Instance, z: number, w: number): v4h;
835
+ (x: number, v0: AnyNumericVec2Instance, z: number): v4h;
836
+ (x: number, y: number, v0: AnyNumericVec2Instance): v4h;
1074
837
  }
1075
838
  /**
1076
839
  * Type of the `d.vec4i` object/function: vector data type schema/constructor
@@ -1078,17 +841,17 @@ interface Vec4h {
1078
841
  interface Vec4i {
1079
842
  readonly type: 'vec4i';
1080
843
  /** Type-token, not available at runtime */
1081
- readonly '~repr': v4i;
844
+ readonly [$repr]: v4i;
1082
845
  (x: number, y: number, z: number, w: number): v4i;
1083
846
  (xyzw: number): v4i;
1084
847
  (): v4i;
1085
- (v: AnyVec4Instance): v4i;
1086
- (v0: AnyVec3Instance, w: number): v4i;
1087
- (x: number, v0: AnyVec3Instance): v4i;
1088
- (v0: AnyVec2Instance, v1: AnyVec2Instance): v4i;
1089
- (v0: AnyVec2Instance, z: number, w: number): v4i;
1090
- (x: number, v0: AnyVec2Instance, z: number): v4i;
1091
- (x: number, y: number, v0: AnyVec2Instance): v4i;
848
+ (v: AnyNumericVec4Instance): v4i;
849
+ (v0: AnyNumericVec3Instance, w: number): v4i;
850
+ (x: number, v0: AnyNumericVec3Instance): v4i;
851
+ (v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4i;
852
+ (v0: AnyNumericVec2Instance, z: number, w: number): v4i;
853
+ (x: number, v0: AnyNumericVec2Instance, z: number): v4i;
854
+ (x: number, y: number, v0: AnyNumericVec2Instance): v4i;
1092
855
  }
1093
856
  /**
1094
857
  * Type of the `d.vec4u` object/function: vector data type schema/constructor
@@ -1096,17 +859,36 @@ interface Vec4i {
1096
859
  interface Vec4u {
1097
860
  readonly type: 'vec4u';
1098
861
  /** Type-token, not available at runtime */
1099
- readonly '~repr': v4u;
862
+ readonly [$repr]: v4u;
1100
863
  (x: number, y: number, z: number, w: number): v4u;
1101
864
  (xyzw: number): v4u;
1102
865
  (): v4u;
1103
- (v: AnyVec4Instance): v4u;
1104
- (v0: AnyVec3Instance, w: number): v4u;
1105
- (x: number, v0: AnyVec3Instance): v4u;
1106
- (v0: AnyVec2Instance, v1: AnyVec2Instance): v4u;
1107
- (v0: AnyVec2Instance, z: number, w: number): v4u;
1108
- (x: number, v0: AnyVec2Instance, z: number): v4u;
1109
- (x: number, y: number, v0: AnyVec2Instance): v4u;
866
+ (v: AnyNumericVec4Instance): v4u;
867
+ (v0: AnyNumericVec3Instance, w: number): v4u;
868
+ (x: number, v0: AnyNumericVec3Instance): v4u;
869
+ (v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4u;
870
+ (v0: AnyNumericVec2Instance, z: number, w: number): v4u;
871
+ (x: number, v0: AnyNumericVec2Instance, z: number): v4u;
872
+ (x: number, y: number, v0: AnyNumericVec2Instance): v4u;
873
+ }
874
+ /**
875
+ * Type of the `d.vec4b` object/function: vector data type schema/constructor
876
+ * Cannot be used inside buffers as it is not host-shareable.
877
+ */
878
+ interface Vec4b {
879
+ readonly type: 'vec4<bool>';
880
+ /** Type-token, not available at runtime */
881
+ readonly [$repr]: v4b;
882
+ (x: boolean, y: boolean, z: boolean, w: boolean): v4b;
883
+ (xyzw: boolean): v4b;
884
+ (): v4b;
885
+ (v: v4b): v4b;
886
+ (v0: v3b, w: boolean): v4b;
887
+ (x: boolean, v0: v3b): v4b;
888
+ (v0: v2b, v1: v2b): v4b;
889
+ (v0: v2b, z: boolean, w: boolean): v4b;
890
+ (x: boolean, v0: v2b, z: boolean): v4b;
891
+ (x: boolean, y: boolean, v0: v2b): v4b;
1110
892
  }
1111
893
  /**
1112
894
  * Type of the `d.mat2x2f` object/function: matrix data type schema/constructor
@@ -1114,7 +896,7 @@ interface Vec4u {
1114
896
  interface Mat2x2f {
1115
897
  readonly type: 'mat2x2f';
1116
898
  /** Type-token, not available at runtime */
1117
- readonly '~repr': m2x2f;
899
+ readonly [$repr]: m2x2f;
1118
900
  (...elements: number[]): m2x2f;
1119
901
  (...columns: v2f[]): m2x2f;
1120
902
  (): m2x2f;
@@ -1125,7 +907,7 @@ interface Mat2x2f {
1125
907
  interface Mat3x3f {
1126
908
  readonly type: 'mat3x3f';
1127
909
  /** Type-token, not available at runtime */
1128
- readonly '~repr': m3x3f;
910
+ readonly [$repr]: m3x3f;
1129
911
  (...elements: number[]): m3x3f;
1130
912
  (...columns: v3f[]): m3x3f;
1131
913
  (): m3x3f;
@@ -1136,7 +918,7 @@ interface Mat3x3f {
1136
918
  interface Mat4x4f {
1137
919
  readonly type: 'mat4x4f';
1138
920
  /** Type-token, not available at runtime */
1139
- readonly '~repr': m4x4f;
921
+ readonly [$repr]: m4x4f;
1140
922
  (...elements: number[]): m4x4f;
1141
923
  (...columns: v4f[]): m4x4f;
1142
924
  (): m4x4f;
@@ -1153,7 +935,7 @@ interface WgslArray<TElement extends BaseData = BaseData> {
1153
935
  readonly elementCount: number;
1154
936
  readonly elementType: TElement;
1155
937
  /** Type-token, not available at runtime */
1156
- readonly '~repr': Infer<TElement>[];
938
+ readonly [$repr]: Infer<TElement>[];
1157
939
  readonly '~gpuRepr': InferGPU<TElement>[];
1158
940
  readonly '~reprPartial': {
1159
941
  idx: number;
@@ -1161,6 +943,31 @@ interface WgslArray<TElement extends BaseData = BaseData> {
1161
943
  }[];
1162
944
  readonly '~memIdent': WgslArray<MemIdentity<TElement>>;
1163
945
  }
946
+ declare const $structTag: unique symbol;
947
+ /**
948
+ * Struct schema constructed via `d.struct` function.
949
+ *
950
+ * Responsible for handling reading and writing struct values
951
+ * between binary and JS representation. Takes into account
952
+ * the `byteAlignment` requirement of its members.
953
+ */
954
+ interface WgslStruct<TProps extends Record<string, BaseData> = Record<string, BaseData>> extends TgpuNamable {
955
+ (props: Prettify<InferRecord<TProps>>): Prettify<InferRecord<TProps>>;
956
+ /** @deprecated */
957
+ readonly type: 'struct';
958
+ readonly label?: string | undefined;
959
+ readonly propTypes: TProps;
960
+ readonly [$structTag]: true;
961
+ /** Type-token, not available at runtime */
962
+ readonly [$repr]: Prettify<InferRecord<TProps>>;
963
+ /** Type-token, not available at runtime */
964
+ readonly '~gpuRepr': Prettify<InferGPURecord<TProps>>;
965
+ /** Type-token, not available at runtime */
966
+ readonly '~memIdent': WgslStruct<MemIdentityRecord<TProps>>;
967
+ /** Type-token, not available at runtime */
968
+ readonly '~reprPartial': Prettify<Partial<InferPartialRecord<TProps>>>;
969
+ }
970
+ type AnyWgslStruct = WgslStruct<any>;
1164
971
  type AddressSpace = 'uniform' | 'storage' | 'workgroup' | 'private' | 'function' | 'handle';
1165
972
  type Access = 'read' | 'write' | 'read-write';
1166
973
  interface Ptr<TAddr extends AddressSpace = AddressSpace, TInner extends BaseData = BaseData, // can also be sampler or texture (╯'□')╯︵ ┻━┻
@@ -1170,7 +977,7 @@ TAccess extends Access = Access> {
1170
977
  readonly addressSpace: TAddr;
1171
978
  readonly access: TAccess;
1172
979
  /** Type-token, not available at runtime */
1173
- readonly '~repr': Infer<TInner>;
980
+ readonly [$repr]: Infer<TInner>;
1174
981
  }
1175
982
  /**
1176
983
  * Schema representing the `atomic<...>` WGSL data type.
@@ -1179,7 +986,7 @@ interface Atomic<TInner extends U32 | I32 = U32 | I32> {
1179
986
  readonly type: 'atomic';
1180
987
  readonly inner: TInner;
1181
988
  /** Type-token, not available at runtime */
1182
- readonly '~repr': Infer<TInner>;
989
+ readonly [$repr]: Infer<TInner>;
1183
990
  readonly '~gpuRepr': TInner extends U32 ? atomicU32 : atomicI32;
1184
991
  readonly '~memIdent': MemIdentity<TInner>;
1185
992
  }
@@ -1217,16 +1024,17 @@ interface Decorated<TInner extends BaseData = BaseData, TAttribs extends unknown
1217
1024
  readonly inner: TInner;
1218
1025
  readonly attribs: TAttribs;
1219
1026
  /** Type-token, not available at runtime */
1220
- readonly '~repr': Infer<TInner>;
1027
+ readonly [$repr]: Infer<TInner>;
1221
1028
  readonly '~gpuRepr': InferGPU<TInner>;
1222
1029
  readonly '~reprPartial': InferPartial<TInner>;
1223
1030
  readonly '~memIdent': TAttribs extends Location<number>[] ? MemIdentity<TInner> | Decorated<MemIdentity<TInner>, TAttribs> : Decorated<MemIdentity<TInner>, TAttribs>;
1224
1031
  }
1225
- declare const wgslTypeLiterals: readonly ["bool", "f32", "f16", "i32", "u32", "vec2f", "vec2h", "vec2i", "vec2u", "vec3f", "vec3h", "vec3i", "vec3u", "vec4f", "vec4h", "vec4i", "vec4u", "mat2x2f", "mat3x3f", "mat4x4f", "struct", "array", "ptr", "atomic", "decorated", "abstractInt", "abstractFloat"];
1032
+ 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"];
1226
1033
  type WgslTypeLiteral = (typeof wgslTypeLiterals)[number];
1227
1034
  type PerspectiveOrLinearInterpolatableData = F32 | F16 | Vec2f | Vec2h | Vec3f | Vec3h | Vec4f | Vec4h;
1228
1035
  type FlatInterpolatableData = PerspectiveOrLinearInterpolatableData | I32 | U32 | Vec2i | Vec2u | Vec3i | Vec3u | Vec4i | Vec4u;
1229
- type AnyWgslData = Bool | F32 | F16 | I32 | U32 | Vec2f | Vec2h | Vec2i | Vec2u | Vec3f | Vec3h | Vec3i | Vec3u | Vec4f | Vec4h | Vec4i | Vec4u | Mat2x2f | Mat3x3f | Mat4x4f | AnyWgslStruct | WgslArray | Ptr | Atomic | Decorated | AbstractInt | AbstractFloat;
1036
+ type ScalarData = Bool | F32 | F16 | I32 | U32 | AbstractInt | AbstractFloat;
1037
+ 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;
1230
1038
  declare function isWgslData(value: unknown): value is AnyWgslData;
1231
1039
  /**
1232
1040
  * Checks whether passed in value is an array schema,
@@ -1277,4 +1085,4 @@ declare function isInterpolateAttrib<T extends Interpolate<InterpolationType>>(v
1277
1085
  declare function isBuiltinAttrib<T extends Builtin<string>>(value: unknown | T): value is T;
1278
1086
  declare function isDecorated<T extends Decorated>(value: unknown | T): value is T;
1279
1087
 
1280
- export { type Atomic as $, type AnyWgslData as A, type BaseData as B, type InferGPU as C, type Decorated as D, type AbstractInt as E, type F32 as F, type AbstractFloat as G, type AnyVecInstance as H, type Infer as I, type AnyMatInstance as J, type KindToDefaultFormatMap as K, type Location as L, type Mutable as M, type Bool as N, type OmitProps as O, type Prettify as P, type Ptr as Q, type Mat2x2f as R, type Mat3x3f as S, type TgpuNamable as T, type U32 as U, type Vec2f as V, type WgslStruct as W, type Mat4x4f as X, type m2x2f as Y, type m3x3f as Z, type m4x4f as _, type F16 as a, float32 as a$, isWgslData as a0, isWgslArray as a1, isWgslStruct as a2, isPtr as a3, isAtomic as a4, isDecorated as a5, isAlignAttrib as a6, isBuiltinAttrib as a7, isLocationAttrib as a8, isInterpolateAttrib as a9, uint8 as aA, uint8x2 as aB, uint8x4 as aC, sint8 as aD, sint8x2 as aE, sint8x4 as aF, unorm8 as aG, unorm8x2 as aH, unorm8x4 as aI, snorm8 as aJ, snorm8x2 as aK, snorm8x4 as aL, uint16 as aM, uint16x2 as aN, uint16x4 as aO, sint16 as aP, sint16x2 as aQ, sint16x4 as aR, unorm16 as aS, unorm16x2 as aT, unorm16x4 as aU, snorm16 as aV, snorm16x2 as aW, snorm16x4 as aX, float16 as aY, float16x2 as aZ, float16x4 as a_, isSizeAttrib as aa, type Size as ab, type Align as ac, type Builtin as ad, type Interpolate as ae, type v2f as af, type v2i as ag, type v2u as ah, type v3f as ai, type v3i as aj, type v3u as ak, type v4f as al, type v4i as am, type v4u as an, struct as ao, type LooseDecorated as ap, type AnyLooseData as aq, isDisarray as ar, isUnstruct as as, isLooseDecorated as at, isData as au, isLooseData as av, type FormatToWGSLType as aw, type TgpuVertexFormatData as ax, formatToWGSLType as ay, packedFormats as az, type I32 as b, float32x2 as b0, float32x3 as b1, float32x4 as b2, uint32 as b3, uint32x2 as b4, uint32x3 as b5, uint32x4 as b6, sint32 as b7, sint32x2 as b8, sint32x3 as b9, sint32x4 as ba, unorm10_10_10_2 as bb, unorm8x4_bgra as bc, type PackedData as bd, type InterpolationType as be, type LooseTypeLiteral as bf, type PerspectiveOrLinearInterpolationType as bg, type PerspectiveOrLinearInterpolatableData as bh, type FlatInterpolationType as bi, type FlatInterpolatableData as bj, type VecKind as bk, type vBaseForMat as bl, type v2h as bm, type v3h as bn, type v4h as bo, type atomicI32 as bp, type atomicU32 as bq, type Vec3f as c, type Vec4f as d, type Vec2h as e, type Vec3h as f, type Vec4h as g, type Vec2i as h, type Vec3i as i, type Vec4i as j, type Vec2u as k, type Vec3u as l, type Vec4u as m, type AnyWgslStruct as n, type Default as o, type UnionToIntersection as p, type WgslArray as q, type Disarray as r, type Unstruct as s, type VertexFormat as t, type TgpuVertexAttrib as u, type KindToAcceptedAttribMap as v, type AnyData as w, type WgslTypeLiteral as x, type InferPartial as y, type MemIdentity as z };
1088
+ export { $repr as $, type AnyWgslData as A, type BaseData as B, type Ptr as C, type Decorated as D, type Vec2b as E, type F32 as F, type Vec3b as G, type Vec4b as H, type Infer as I, type Mat2x2f as J, type Mat3x3f as K, type Location as L, type Mutable as M, type Mat4x4f as N, type OmitProps as O, type Prettify as P, type m2x2f as Q, type m3x3f as R, type m4x4f as S, type TgpuNamable as T, type U32 as U, type Vec2f as V, type WgslStruct as W, type Atomic as X, isWgslData as Y, isWgslArray as Z, isWgslStruct as _, type F16 as a, isPtr as a0, isAtomic as a1, isDecorated as a2, isAlignAttrib as a3, isBuiltinAttrib as a4, isLocationAttrib as a5, isInterpolateAttrib as a6, isSizeAttrib as a7, type Size as a8, type Align as a9, type v4b as aA, type AnyBooleanVecInstance as aB, type ScalarData as aC, type atomicI32 as aD, type atomicU32 as aE, type Builtin as aa, type Interpolate as ab, type v2f as ac, type v2i as ad, type v2u as ae, type v3f as af, type v3i as ag, type v3u as ah, type v4f as ai, type v4i as aj, type v4u as ak, type InferRecord as al, type InferPartialRecord as am, type InterpolationType as an, type PerspectiveOrLinearInterpolationType as ao, type PerspectiveOrLinearInterpolatableData as ap, type FlatInterpolationType as aq, type FlatInterpolatableData as ar, type AnyNumericVecInstance as as, type vBaseForMat as at, type AnyFloatVecInstance as au, type v3h as av, type AnyVec2Instance as aw, type v2b as ax, type AnyVec3Instance as ay, type v3b as az, type I32 as b, type Vec3f as c, type Vec4f as d, type Vec2h as e, type Vec3h as f, type Vec4h as g, type Vec2i as h, type Vec3i as i, type Vec4i as j, type Vec2u as k, type Vec3u as l, type Vec4u as m, type AnyWgslStruct as n, type Default as o, type UnionToIntersection as p, type WgslArray as q, type WgslTypeLiteral as r, type InferPartial as s, type MemIdentity as t, type InferGPU as u, type AbstractInt as v, type AbstractFloat as w, type AnyVecInstance as x, type AnyMatInstance as y, type Bool as z };