typegpu 0.5.3 → 0.5.5
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.
- package/README.md +1 -1
- package/{attributes-DSOqT8yA.d.cts → attributes-BcDZsQCE.d.cts} +1 -1
- package/{attributes-B4JpvOTz.d.ts → attributes-DsIdcdq4.d.ts} +1 -1
- package/chunk-A6AAWPBU.cjs +2 -0
- package/chunk-A6AAWPBU.cjs.map +1 -0
- package/chunk-HZAXWB4J.js +2 -0
- package/chunk-HZAXWB4J.js.map +1 -0
- package/chunk-T5Y2EQPZ.js +4 -0
- package/chunk-T5Y2EQPZ.js.map +1 -0
- package/chunk-VUYQ2ZIK.cjs +4 -0
- package/chunk-VUYQ2ZIK.cjs.map +1 -0
- package/data/index.cjs +1 -1
- package/data/index.cjs.map +1 -1
- package/data/index.d.cts +50 -4
- package/data/index.d.ts +50 -4
- package/data/index.js +1 -1
- package/{wgslTypes-VtSRoe90.d.ts → dataTypes-ts2Ccted.d.cts} +608 -506
- package/{wgslTypes-VtSRoe90.d.cts → dataTypes-ts2Ccted.d.ts} +608 -506
- package/index.cjs +19 -19
- package/index.cjs.map +1 -1
- package/index.d.cts +110 -443
- package/index.d.ts +110 -443
- package/index.js +19 -19
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/sampler-CPNwYXSH.d.ts +369 -0
- package/sampler-DeX4AnIZ.d.cts +369 -0
- package/std/index.cjs +1 -1
- package/std/index.cjs.map +1 -1
- package/std/index.d.cts +190 -47
- package/std/index.d.ts +190 -47
- package/std/index.js +1 -1
- package/std/index.js.map +1 -1
- package/chunk-DVZNNZFQ.js +0 -2
- package/chunk-DVZNNZFQ.js.map +0 -1
- package/chunk-FM3TKZFZ.cjs +0 -2
- package/chunk-FM3TKZFZ.cjs.map +0 -1
- package/chunk-M4VUFFPZ.cjs +0 -4
- package/chunk-M4VUFFPZ.cjs.map +0 -1
- package/chunk-RMXVIINO.js +0 -2
- package/chunk-RMXVIINO.js.map +0 -1
- package/chunk-UHU5Z2IS.js +0 -4
- package/chunk-UHU5Z2IS.js.map +0 -1
- package/chunk-UPPJES6W.cjs +0 -2
- package/chunk-UPPJES6W.cjs.map +0 -1
@@ -6,299 +6,7 @@ interface TgpuNamable {
|
|
6
6
|
$name(label?: string | undefined): this;
|
7
7
|
}
|
8
8
|
|
9
|
-
|
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
|
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
|
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,71 +34,65 @@ 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
|
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
|
-
*
|
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
|
-
|
343
|
-
|
344
|
-
|
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
|
-
*
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
88
|
+
/** Type-token, not available at runtime */
|
89
|
+
readonly [$repr]: number;
|
90
|
+
}
|
91
|
+
interface Void {
|
92
|
+
readonly type: 'void';
|
93
|
+
readonly [$repr]: undefined;
|
393
94
|
}
|
95
|
+
declare const Void: Void;
|
394
96
|
interface Swizzle2<T2, T3, T4> {
|
395
97
|
readonly xx: T2;
|
396
98
|
readonly xy: T2;
|
@@ -736,6 +438,16 @@ interface v2u extends NumberArrayView, Swizzle2<v2u, v3u, v4u> {
|
|
736
438
|
x: number;
|
737
439
|
y: number;
|
738
440
|
}
|
441
|
+
/**
|
442
|
+
* Interface representing its WGSL vector type counterpart: `vec2<bool>`.
|
443
|
+
* A vector with 2 elements of type `bool`
|
444
|
+
*/
|
445
|
+
interface v2b extends BooleanArrayView, Swizzle2<v2b, v3b, v4b> {
|
446
|
+
/** use to distinguish between vectors of the same size on the type level */
|
447
|
+
readonly kind: 'vec2<bool>';
|
448
|
+
x: boolean;
|
449
|
+
y: boolean;
|
450
|
+
}
|
739
451
|
/**
|
740
452
|
* Interface representing its WGSL vector type counterpart: vec3f or vec3<f32>.
|
741
453
|
* A vector with 3 elements of type f32
|
@@ -780,6 +492,17 @@ interface v3u extends NumberArrayView, Swizzle3<v2u, v3u, v4u> {
|
|
780
492
|
y: number;
|
781
493
|
z: number;
|
782
494
|
}
|
495
|
+
/**
|
496
|
+
* Interface representing its WGSL vector type counterpart: `vec3<bool>`.
|
497
|
+
* A vector with 3 elements of type `bool`
|
498
|
+
*/
|
499
|
+
interface v3b extends BooleanArrayView, Swizzle3<v2b, v3b, v4b> {
|
500
|
+
/** use to distinguish between vectors of the same size on the type level */
|
501
|
+
readonly kind: 'vec3<bool>';
|
502
|
+
x: boolean;
|
503
|
+
y: boolean;
|
504
|
+
z: boolean;
|
505
|
+
}
|
783
506
|
/**
|
784
507
|
* Interface representing its WGSL vector type counterpart: vec4f or vec4<f32>.
|
785
508
|
* A vector with 4 elements of type f32
|
@@ -828,11 +551,28 @@ interface v4u extends NumberArrayView, Swizzle4<v2u, v3u, v4u> {
|
|
828
551
|
z: number;
|
829
552
|
w: number;
|
830
553
|
}
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
554
|
+
/**
|
555
|
+
* Interface representing its WGSL vector type counterpart: `vec4<bool>`.
|
556
|
+
* A vector with 4 elements of type `bool`
|
557
|
+
*/
|
558
|
+
interface v4b extends BooleanArrayView, Swizzle4<v2b, v3b, v4b> {
|
559
|
+
/** use to distinguish between vectors of the same size on the type level */
|
560
|
+
readonly kind: 'vec4<bool>';
|
561
|
+
x: boolean;
|
562
|
+
y: boolean;
|
563
|
+
z: boolean;
|
564
|
+
w: boolean;
|
565
|
+
}
|
566
|
+
type AnyFloatVecInstance = v2f | v2h | v3f | v3h | v4f | v4h;
|
567
|
+
type AnyBooleanVecInstance = v2b | v3b | v4b;
|
568
|
+
type AnyNumericVec2Instance = v2f | v2h | v2i | v2u;
|
569
|
+
type AnyNumericVec3Instance = v3f | v3h | v3i | v3u;
|
570
|
+
type AnyNumericVec4Instance = v4f | v4h | v4i | v4u;
|
571
|
+
type AnyNumericVecInstance = AnyNumericVec2Instance | AnyNumericVec3Instance | AnyNumericVec4Instance;
|
572
|
+
type AnyVec2Instance = v2f | v2h | v2i | v2u | v2b;
|
573
|
+
type AnyVec3Instance = v3f | v3h | v3i | v3u | v3b;
|
574
|
+
type AnyVec4Instance = v4f | v4h | v4i | v4u | v4b;
|
575
|
+
type AnyVecInstance = AnyVec2Instance | AnyVec3Instance | AnyVec4Instance;
|
836
576
|
interface matBase<TColumn> extends NumberArrayView {
|
837
577
|
readonly columns: readonly TColumn[];
|
838
578
|
}
|
@@ -892,7 +632,7 @@ type vBaseForMat<T extends AnyMatInstance> = T extends m2x2f ? v2f : T extends m
|
|
892
632
|
*/
|
893
633
|
interface Bool {
|
894
634
|
readonly type: 'bool';
|
895
|
-
readonly
|
635
|
+
readonly [$repr]: boolean;
|
896
636
|
}
|
897
637
|
/**
|
898
638
|
* 32-bit float schema representing a single WGSL f32 value.
|
@@ -900,7 +640,7 @@ interface Bool {
|
|
900
640
|
interface F32 {
|
901
641
|
readonly type: 'f32';
|
902
642
|
/** Type-token, not available at runtime */
|
903
|
-
readonly
|
643
|
+
readonly [$repr]: number;
|
904
644
|
(v: number | boolean): number;
|
905
645
|
}
|
906
646
|
/**
|
@@ -909,7 +649,7 @@ interface F32 {
|
|
909
649
|
interface F16 {
|
910
650
|
readonly type: 'f16';
|
911
651
|
/** Type-token, not available at runtime */
|
912
|
-
readonly
|
652
|
+
readonly [$repr]: number;
|
913
653
|
(v: number | boolean): number;
|
914
654
|
}
|
915
655
|
/**
|
@@ -918,7 +658,7 @@ interface F16 {
|
|
918
658
|
interface I32 {
|
919
659
|
readonly type: 'i32';
|
920
660
|
/** Type-token, not available at runtime */
|
921
|
-
readonly
|
661
|
+
readonly [$repr]: number;
|
922
662
|
readonly '~memIdent': I32 | Atomic<I32> | DecoratedLocation<I32>;
|
923
663
|
(v: number | boolean): number;
|
924
664
|
}
|
@@ -928,7 +668,7 @@ interface I32 {
|
|
928
668
|
interface U32 {
|
929
669
|
readonly type: 'u32';
|
930
670
|
/** Type-token, not available at runtime */
|
931
|
-
readonly
|
671
|
+
readonly [$repr]: number;
|
932
672
|
readonly '~memIdent': U32 | Atomic<U32> | DecoratedLocation<U32>;
|
933
673
|
(v: number | boolean): number;
|
934
674
|
}
|
@@ -938,11 +678,11 @@ interface U32 {
|
|
938
678
|
interface Vec2f {
|
939
679
|
readonly type: 'vec2f';
|
940
680
|
/** Type-token, not available at runtime */
|
941
|
-
readonly
|
681
|
+
readonly [$repr]: v2f;
|
942
682
|
(x: number, y: number): v2f;
|
943
683
|
(xy: number): v2f;
|
944
684
|
(): v2f;
|
945
|
-
(v:
|
685
|
+
(v: AnyNumericVec2Instance): v2f;
|
946
686
|
}
|
947
687
|
/**
|
948
688
|
* Type of the `d.vec2h` object/function: vector data type schema/constructor
|
@@ -950,11 +690,11 @@ interface Vec2f {
|
|
950
690
|
interface Vec2h {
|
951
691
|
readonly type: 'vec2h';
|
952
692
|
/** Type-token, not available at runtime */
|
953
|
-
readonly
|
693
|
+
readonly [$repr]: v2h;
|
954
694
|
(x: number, y: number): v2h;
|
955
695
|
(xy: number): v2h;
|
956
696
|
(): v2h;
|
957
|
-
(v:
|
697
|
+
(v: AnyNumericVec2Instance): v2h;
|
958
698
|
}
|
959
699
|
/**
|
960
700
|
* Type of the `d.vec2i` object/function: vector data type schema/constructor
|
@@ -962,11 +702,11 @@ interface Vec2h {
|
|
962
702
|
interface Vec2i {
|
963
703
|
readonly type: 'vec2i';
|
964
704
|
/** Type-token, not available at runtime */
|
965
|
-
readonly
|
705
|
+
readonly [$repr]: v2i;
|
966
706
|
(x: number, y: number): v2i;
|
967
707
|
(xy: number): v2i;
|
968
708
|
(): v2i;
|
969
|
-
(v:
|
709
|
+
(v: AnyNumericVec2Instance): v2i;
|
970
710
|
}
|
971
711
|
/**
|
972
712
|
* Type of the `d.vec2u` object/function: vector data type schema/constructor
|
@@ -974,11 +714,24 @@ interface Vec2i {
|
|
974
714
|
interface Vec2u {
|
975
715
|
readonly type: 'vec2u';
|
976
716
|
/** Type-token, not available at runtime */
|
977
|
-
readonly
|
717
|
+
readonly [$repr]: v2u;
|
978
718
|
(x: number, y: number): v2u;
|
979
719
|
(xy: number): v2u;
|
980
720
|
(): v2u;
|
981
|
-
(v:
|
721
|
+
(v: AnyNumericVec2Instance): v2u;
|
722
|
+
}
|
723
|
+
/**
|
724
|
+
* Type of the `d.vec2b` object/function: vector data type schema/constructor
|
725
|
+
* Cannot be used inside buffers as it is not host-shareable.
|
726
|
+
*/
|
727
|
+
interface Vec2b {
|
728
|
+
readonly type: 'vec2<bool>';
|
729
|
+
/** Type-token, not available at runtime */
|
730
|
+
readonly [$repr]: v2b;
|
731
|
+
(x: boolean, y: boolean): v2b;
|
732
|
+
(xy: boolean): v2b;
|
733
|
+
(): v2b;
|
734
|
+
(v: v2b): v2b;
|
982
735
|
}
|
983
736
|
/**
|
984
737
|
* Type of the `d.vec3f` object/function: vector data type schema/constructor
|
@@ -986,13 +739,13 @@ interface Vec2u {
|
|
986
739
|
interface Vec3f {
|
987
740
|
readonly type: 'vec3f';
|
988
741
|
/** Type-token, not available at runtime */
|
989
|
-
readonly
|
742
|
+
readonly [$repr]: v3f;
|
990
743
|
(x: number, y: number, z: number): v3f;
|
991
744
|
(xyz: number): v3f;
|
992
745
|
(): v3f;
|
993
|
-
(v:
|
994
|
-
(v0:
|
995
|
-
(x: number, v0:
|
746
|
+
(v: AnyNumericVec3Instance): v3f;
|
747
|
+
(v0: AnyNumericVec2Instance, z: number): v3f;
|
748
|
+
(x: number, v0: AnyNumericVec2Instance): v3f;
|
996
749
|
}
|
997
750
|
/**
|
998
751
|
* Type of the `d.vec3h` object/function: vector data type schema/constructor
|
@@ -1000,13 +753,13 @@ interface Vec3f {
|
|
1000
753
|
interface Vec3h {
|
1001
754
|
readonly type: 'vec3h';
|
1002
755
|
/** Type-token, not available at runtime */
|
1003
|
-
readonly
|
756
|
+
readonly [$repr]: v3h;
|
1004
757
|
(x: number, y: number, z: number): v3h;
|
1005
758
|
(xyz: number): v3h;
|
1006
759
|
(): v3h;
|
1007
|
-
(v:
|
1008
|
-
(v0:
|
1009
|
-
(x: number, v0:
|
760
|
+
(v: AnyNumericVec3Instance): v3h;
|
761
|
+
(v0: AnyNumericVec2Instance, z: number): v3h;
|
762
|
+
(x: number, v0: AnyNumericVec2Instance): v3h;
|
1010
763
|
}
|
1011
764
|
/**
|
1012
765
|
* Type of the `d.vec3i` object/function: vector data type schema/constructor
|
@@ -1014,13 +767,13 @@ interface Vec3h {
|
|
1014
767
|
interface Vec3i {
|
1015
768
|
readonly type: 'vec3i';
|
1016
769
|
/** Type-token, not available at runtime */
|
1017
|
-
readonly
|
770
|
+
readonly [$repr]: v3i;
|
1018
771
|
(x: number, y: number, z: number): v3i;
|
1019
772
|
(xyz: number): v3i;
|
1020
773
|
(): v3i;
|
1021
|
-
(v:
|
1022
|
-
(v0:
|
1023
|
-
(x: number, v0:
|
774
|
+
(v: AnyNumericVec3Instance): v3i;
|
775
|
+
(v0: AnyNumericVec2Instance, z: number): v3i;
|
776
|
+
(x: number, v0: AnyNumericVec2Instance): v3i;
|
1024
777
|
}
|
1025
778
|
/**
|
1026
779
|
* Type of the `d.vec3u` object/function: vector data type schema/constructor
|
@@ -1028,13 +781,28 @@ interface Vec3i {
|
|
1028
781
|
interface Vec3u {
|
1029
782
|
readonly type: 'vec3u';
|
1030
783
|
/** Type-token, not available at runtime */
|
1031
|
-
readonly
|
784
|
+
readonly [$repr]: v3u;
|
1032
785
|
(x: number, y: number, z: number): v3u;
|
1033
786
|
(xyz: number): v3u;
|
1034
787
|
(): v3u;
|
1035
|
-
(v:
|
1036
|
-
(v0:
|
1037
|
-
(x: number, v0:
|
788
|
+
(v: AnyNumericVec3Instance): v3u;
|
789
|
+
(v0: AnyNumericVec2Instance, z: number): v3u;
|
790
|
+
(x: number, v0: AnyNumericVec2Instance): v3u;
|
791
|
+
}
|
792
|
+
/**
|
793
|
+
* Type of the `d.vec3b` object/function: vector data type schema/constructor
|
794
|
+
* Cannot be used inside buffers as it is not host-shareable.
|
795
|
+
*/
|
796
|
+
interface Vec3b {
|
797
|
+
readonly type: 'vec3<bool>';
|
798
|
+
/** Type-token, not available at runtime */
|
799
|
+
readonly [$repr]: v3b;
|
800
|
+
(x: boolean, y: boolean, z: boolean): v3b;
|
801
|
+
(xyz: boolean): v3b;
|
802
|
+
(): v3b;
|
803
|
+
(v: v3b): v3b;
|
804
|
+
(v0: v2b, z: boolean): v3b;
|
805
|
+
(x: boolean, v0: v2b): v3b;
|
1038
806
|
}
|
1039
807
|
/**
|
1040
808
|
* Type of the `d.vec4f` object/function: vector data type schema/constructor
|
@@ -1042,17 +810,17 @@ interface Vec3u {
|
|
1042
810
|
interface Vec4f {
|
1043
811
|
readonly type: 'vec4f';
|
1044
812
|
/** Type-token, not available at runtime */
|
1045
|
-
readonly
|
813
|
+
readonly [$repr]: v4f;
|
1046
814
|
(x: number, y: number, z: number, w: number): v4f;
|
1047
815
|
(xyzw: number): v4f;
|
1048
816
|
(): v4f;
|
1049
|
-
(v:
|
1050
|
-
(v0:
|
1051
|
-
(x: number, v0:
|
1052
|
-
(v0:
|
1053
|
-
(v0:
|
1054
|
-
(x: number, v0:
|
1055
|
-
(x: number, y: number, v0:
|
817
|
+
(v: AnyNumericVec4Instance): v4f;
|
818
|
+
(v0: AnyNumericVec3Instance, w: number): v4f;
|
819
|
+
(x: number, v0: AnyNumericVec3Instance): v4f;
|
820
|
+
(v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4f;
|
821
|
+
(v0: AnyNumericVec2Instance, z: number, w: number): v4f;
|
822
|
+
(x: number, v0: AnyNumericVec2Instance, z: number): v4f;
|
823
|
+
(x: number, y: number, v0: AnyNumericVec2Instance): v4f;
|
1056
824
|
}
|
1057
825
|
/**
|
1058
826
|
* Type of the `d.vec4h` object/function: vector data type schema/constructor
|
@@ -1060,17 +828,17 @@ interface Vec4f {
|
|
1060
828
|
interface Vec4h {
|
1061
829
|
readonly type: 'vec4h';
|
1062
830
|
/** Type-token, not available at runtime */
|
1063
|
-
readonly
|
831
|
+
readonly [$repr]: v4h;
|
1064
832
|
(x: number, y: number, z: number, w: number): v4h;
|
1065
833
|
(xyzw: number): v4h;
|
1066
834
|
(): v4h;
|
1067
|
-
(v:
|
1068
|
-
(v0:
|
1069
|
-
(x: number, v0:
|
1070
|
-
(v0:
|
1071
|
-
(v0:
|
1072
|
-
(x: number, v0:
|
1073
|
-
(x: number, y: number, v0:
|
835
|
+
(v: AnyNumericVec4Instance): v4h;
|
836
|
+
(v0: AnyNumericVec3Instance, w: number): v4h;
|
837
|
+
(x: number, v0: AnyNumericVec3Instance): v4h;
|
838
|
+
(v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4h;
|
839
|
+
(v0: AnyNumericVec2Instance, z: number, w: number): v4h;
|
840
|
+
(x: number, v0: AnyNumericVec2Instance, z: number): v4h;
|
841
|
+
(x: number, y: number, v0: AnyNumericVec2Instance): v4h;
|
1074
842
|
}
|
1075
843
|
/**
|
1076
844
|
* Type of the `d.vec4i` object/function: vector data type schema/constructor
|
@@ -1078,17 +846,17 @@ interface Vec4h {
|
|
1078
846
|
interface Vec4i {
|
1079
847
|
readonly type: 'vec4i';
|
1080
848
|
/** Type-token, not available at runtime */
|
1081
|
-
readonly
|
849
|
+
readonly [$repr]: v4i;
|
1082
850
|
(x: number, y: number, z: number, w: number): v4i;
|
1083
851
|
(xyzw: number): v4i;
|
1084
852
|
(): v4i;
|
1085
|
-
(v:
|
1086
|
-
(v0:
|
1087
|
-
(x: number, v0:
|
1088
|
-
(v0:
|
1089
|
-
(v0:
|
1090
|
-
(x: number, v0:
|
1091
|
-
(x: number, y: number, v0:
|
853
|
+
(v: AnyNumericVec4Instance): v4i;
|
854
|
+
(v0: AnyNumericVec3Instance, w: number): v4i;
|
855
|
+
(x: number, v0: AnyNumericVec3Instance): v4i;
|
856
|
+
(v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4i;
|
857
|
+
(v0: AnyNumericVec2Instance, z: number, w: number): v4i;
|
858
|
+
(x: number, v0: AnyNumericVec2Instance, z: number): v4i;
|
859
|
+
(x: number, y: number, v0: AnyNumericVec2Instance): v4i;
|
1092
860
|
}
|
1093
861
|
/**
|
1094
862
|
* Type of the `d.vec4u` object/function: vector data type schema/constructor
|
@@ -1096,17 +864,36 @@ interface Vec4i {
|
|
1096
864
|
interface Vec4u {
|
1097
865
|
readonly type: 'vec4u';
|
1098
866
|
/** Type-token, not available at runtime */
|
1099
|
-
readonly
|
867
|
+
readonly [$repr]: v4u;
|
1100
868
|
(x: number, y: number, z: number, w: number): v4u;
|
1101
869
|
(xyzw: number): v4u;
|
1102
870
|
(): v4u;
|
1103
|
-
(v:
|
1104
|
-
(v0:
|
1105
|
-
(x: number, v0:
|
1106
|
-
(v0:
|
1107
|
-
(v0:
|
1108
|
-
(x: number, v0:
|
1109
|
-
(x: number, y: number, v0:
|
871
|
+
(v: AnyNumericVec4Instance): v4u;
|
872
|
+
(v0: AnyNumericVec3Instance, w: number): v4u;
|
873
|
+
(x: number, v0: AnyNumericVec3Instance): v4u;
|
874
|
+
(v0: AnyNumericVec2Instance, v1: AnyNumericVec2Instance): v4u;
|
875
|
+
(v0: AnyNumericVec2Instance, z: number, w: number): v4u;
|
876
|
+
(x: number, v0: AnyNumericVec2Instance, z: number): v4u;
|
877
|
+
(x: number, y: number, v0: AnyNumericVec2Instance): v4u;
|
878
|
+
}
|
879
|
+
/**
|
880
|
+
* Type of the `d.vec4b` object/function: vector data type schema/constructor
|
881
|
+
* Cannot be used inside buffers as it is not host-shareable.
|
882
|
+
*/
|
883
|
+
interface Vec4b {
|
884
|
+
readonly type: 'vec4<bool>';
|
885
|
+
/** Type-token, not available at runtime */
|
886
|
+
readonly [$repr]: v4b;
|
887
|
+
(x: boolean, y: boolean, z: boolean, w: boolean): v4b;
|
888
|
+
(xyzw: boolean): v4b;
|
889
|
+
(): v4b;
|
890
|
+
(v: v4b): v4b;
|
891
|
+
(v0: v3b, w: boolean): v4b;
|
892
|
+
(x: boolean, v0: v3b): v4b;
|
893
|
+
(v0: v2b, v1: v2b): v4b;
|
894
|
+
(v0: v2b, z: boolean, w: boolean): v4b;
|
895
|
+
(x: boolean, v0: v2b, z: boolean): v4b;
|
896
|
+
(x: boolean, y: boolean, v0: v2b): v4b;
|
1110
897
|
}
|
1111
898
|
/**
|
1112
899
|
* Type of the `d.mat2x2f` object/function: matrix data type schema/constructor
|
@@ -1114,7 +901,7 @@ interface Vec4u {
|
|
1114
901
|
interface Mat2x2f {
|
1115
902
|
readonly type: 'mat2x2f';
|
1116
903
|
/** Type-token, not available at runtime */
|
1117
|
-
readonly
|
904
|
+
readonly [$repr]: m2x2f;
|
1118
905
|
(...elements: number[]): m2x2f;
|
1119
906
|
(...columns: v2f[]): m2x2f;
|
1120
907
|
(): m2x2f;
|
@@ -1125,7 +912,7 @@ interface Mat2x2f {
|
|
1125
912
|
interface Mat3x3f {
|
1126
913
|
readonly type: 'mat3x3f';
|
1127
914
|
/** Type-token, not available at runtime */
|
1128
|
-
readonly
|
915
|
+
readonly [$repr]: m3x3f;
|
1129
916
|
(...elements: number[]): m3x3f;
|
1130
917
|
(...columns: v3f[]): m3x3f;
|
1131
918
|
(): m3x3f;
|
@@ -1136,145 +923,460 @@ interface Mat3x3f {
|
|
1136
923
|
interface Mat4x4f {
|
1137
924
|
readonly type: 'mat4x4f';
|
1138
925
|
/** Type-token, not available at runtime */
|
1139
|
-
readonly
|
926
|
+
readonly [$repr]: m4x4f;
|
1140
927
|
(...elements: number[]): m4x4f;
|
1141
928
|
(...columns: v4f[]): m4x4f;
|
1142
929
|
(): m4x4f;
|
1143
930
|
}
|
1144
931
|
/**
|
1145
|
-
* Array schema constructed via `d.arrayOf` function.
|
932
|
+
* Array schema constructed via `d.arrayOf` function.
|
933
|
+
*
|
934
|
+
* Responsible for handling reading and writing array values
|
935
|
+
* between binary and JS representation. Takes into account
|
936
|
+
* the `byteAlignment` requirement of its elementType.
|
937
|
+
*/
|
938
|
+
interface WgslArray<TElement extends BaseData = BaseData> {
|
939
|
+
readonly type: 'array';
|
940
|
+
readonly elementCount: number;
|
941
|
+
readonly elementType: TElement;
|
942
|
+
/** Type-token, not available at runtime */
|
943
|
+
readonly [$repr]: Infer<TElement>[];
|
944
|
+
readonly '~gpuRepr': InferGPU<TElement>[];
|
945
|
+
readonly '~reprPartial': {
|
946
|
+
idx: number;
|
947
|
+
value: InferPartial<TElement>;
|
948
|
+
}[];
|
949
|
+
readonly '~memIdent': WgslArray<MemIdentity<TElement>>;
|
950
|
+
}
|
951
|
+
declare const $structTag: unique symbol;
|
952
|
+
/**
|
953
|
+
* Struct schema constructed via `d.struct` function.
|
954
|
+
*
|
955
|
+
* Responsible for handling reading and writing struct values
|
956
|
+
* between binary and JS representation. Takes into account
|
957
|
+
* the `byteAlignment` requirement of its members.
|
958
|
+
*/
|
959
|
+
interface WgslStruct<TProps extends Record<string, BaseData> = Record<string, BaseData>> extends TgpuNamable {
|
960
|
+
(props: Prettify<InferRecord<TProps>>): Prettify<InferRecord<TProps>>;
|
961
|
+
/** @deprecated */
|
962
|
+
readonly type: 'struct';
|
963
|
+
readonly label?: string | undefined;
|
964
|
+
readonly propTypes: TProps;
|
965
|
+
readonly [$structTag]: true;
|
966
|
+
/** Type-token, not available at runtime */
|
967
|
+
readonly [$repr]: Prettify<InferRecord<TProps>>;
|
968
|
+
/** Type-token, not available at runtime */
|
969
|
+
readonly '~gpuRepr': Prettify<InferGPURecord<TProps>>;
|
970
|
+
/** Type-token, not available at runtime */
|
971
|
+
readonly '~memIdent': WgslStruct<Prettify<MemIdentityRecord<TProps>>>;
|
972
|
+
/** Type-token, not available at runtime */
|
973
|
+
readonly '~reprPartial': Prettify<Partial<InferPartialRecord<TProps>>>;
|
974
|
+
}
|
975
|
+
type AnyWgslStruct = WgslStruct<any>;
|
976
|
+
type AddressSpace = 'uniform' | 'storage' | 'workgroup' | 'private' | 'function' | 'handle';
|
977
|
+
type Access = 'read' | 'write' | 'read-write';
|
978
|
+
interface Ptr<TAddr extends AddressSpace = AddressSpace, TInner extends BaseData = BaseData, // can also be sampler or texture (╯'□')╯︵ ┻━┻
|
979
|
+
TAccess extends Access = Access> {
|
980
|
+
readonly type: 'ptr';
|
981
|
+
readonly inner: TInner;
|
982
|
+
readonly addressSpace: TAddr;
|
983
|
+
readonly access: TAccess;
|
984
|
+
/** Type-token, not available at runtime */
|
985
|
+
readonly [$repr]: Infer<TInner>;
|
986
|
+
}
|
987
|
+
/**
|
988
|
+
* Schema representing the `atomic<...>` WGSL data type.
|
989
|
+
*/
|
990
|
+
interface Atomic<TInner extends U32 | I32 = U32 | I32> {
|
991
|
+
readonly type: 'atomic';
|
992
|
+
readonly inner: TInner;
|
993
|
+
/** Type-token, not available at runtime */
|
994
|
+
readonly [$repr]: Infer<TInner>;
|
995
|
+
readonly '~gpuRepr': TInner extends U32 ? atomicU32 : atomicI32;
|
996
|
+
readonly '~memIdent': MemIdentity<TInner>;
|
997
|
+
}
|
998
|
+
interface atomicU32 {
|
999
|
+
type: 'atomicU32';
|
1000
|
+
}
|
1001
|
+
interface atomicI32 {
|
1002
|
+
type: 'atomicI32';
|
1003
|
+
}
|
1004
|
+
interface Align<T extends number> {
|
1005
|
+
readonly type: '@align';
|
1006
|
+
readonly value: T;
|
1007
|
+
}
|
1008
|
+
interface Size<T extends number> {
|
1009
|
+
readonly type: '@size';
|
1010
|
+
readonly value: T;
|
1011
|
+
}
|
1012
|
+
interface Location<T extends number> {
|
1013
|
+
readonly type: '@location';
|
1014
|
+
readonly value: T;
|
1015
|
+
}
|
1016
|
+
type PerspectiveOrLinearInterpolationType = `${'perspective' | 'linear'}${'' | ', center' | ', centroid' | ', sample'}`;
|
1017
|
+
type FlatInterpolationType = `flat${'' | ', first' | ', either'}`;
|
1018
|
+
type InterpolationType = PerspectiveOrLinearInterpolationType | FlatInterpolationType;
|
1019
|
+
interface Interpolate<T extends InterpolationType> {
|
1020
|
+
readonly type: '@interpolate';
|
1021
|
+
readonly value: T;
|
1022
|
+
}
|
1023
|
+
interface Builtin<T extends string> {
|
1024
|
+
readonly type: '@builtin';
|
1025
|
+
readonly value: T;
|
1026
|
+
}
|
1027
|
+
interface Decorated<TInner extends BaseData = BaseData, TAttribs extends unknown[] = unknown[]> {
|
1028
|
+
readonly type: 'decorated';
|
1029
|
+
readonly inner: TInner;
|
1030
|
+
readonly attribs: TAttribs;
|
1031
|
+
/** Type-token, not available at runtime */
|
1032
|
+
readonly [$repr]: Infer<TInner>;
|
1033
|
+
readonly '~gpuRepr': InferGPU<TInner>;
|
1034
|
+
readonly '~reprPartial': InferPartial<TInner>;
|
1035
|
+
readonly '~memIdent': TAttribs extends Location<number>[] ? MemIdentity<TInner> | Decorated<MemIdentity<TInner>, TAttribs> : Decorated<MemIdentity<TInner>, TAttribs>;
|
1036
|
+
}
|
1037
|
+
declare const wgslTypeLiterals: readonly ["bool", "f32", "f16", "i32", "u32", "vec2f", "vec2h", "vec2i", "vec2u", "vec2<bool>", "vec3f", "vec3h", "vec3i", "vec3u", "vec3<bool>", "vec4f", "vec4h", "vec4i", "vec4u", "vec4<bool>", "mat2x2f", "mat3x3f", "mat4x4f", "struct", "array", "ptr", "atomic", "decorated", "abstractInt", "abstractFloat", "void"];
|
1038
|
+
type WgslTypeLiteral = (typeof wgslTypeLiterals)[number];
|
1039
|
+
type PerspectiveOrLinearInterpolatableBaseType = F32 | F16 | Vec2f | Vec2h | Vec3f | Vec3h | Vec4f | Vec4h;
|
1040
|
+
type PerspectiveOrLinearInterpolatableData = PerspectiveOrLinearInterpolatableBaseType | Decorated<PerspectiveOrLinearInterpolatableBaseType>;
|
1041
|
+
type FlatInterpolatableAdditionalBaseType = I32 | U32 | Vec2i | Vec2u | Vec3i | Vec3u | Vec4i | Vec4u;
|
1042
|
+
type FlatInterpolatableData = PerspectiveOrLinearInterpolatableData | FlatInterpolatableAdditionalBaseType | Decorated<FlatInterpolatableAdditionalBaseType>;
|
1043
|
+
type ScalarData = Bool | F32 | F16 | I32 | U32 | AbstractInt | AbstractFloat;
|
1044
|
+
type AnyWgslData = Bool | F32 | F16 | I32 | U32 | Vec2f | Vec2h | Vec2i | Vec2u | Vec2b | Vec3f | Vec3h | Vec3i | Vec3u | Vec3b | Vec4f | Vec4h | Vec4i | Vec4u | Vec4b | Mat2x2f | Mat3x3f | Mat4x4f | AnyWgslStruct | WgslArray | Ptr | Atomic | Decorated | AbstractInt | AbstractFloat | Void;
|
1045
|
+
declare function isWgslData(value: unknown): value is AnyWgslData;
|
1046
|
+
/**
|
1047
|
+
* Checks whether passed in value is an array schema,
|
1048
|
+
* as opposed to, e.g., a disarray schema.
|
1049
|
+
*
|
1050
|
+
* Array schemas can be used to describe uniform and storage buffers,
|
1051
|
+
* whereas disarray schemas cannot.
|
1052
|
+
*
|
1053
|
+
* @example
|
1054
|
+
* isWgslArray(d.arrayOf(d.u32, 4)) // true
|
1055
|
+
* isWgslArray(d.disarray(d.u32, 4)) // false
|
1056
|
+
* isWgslArray(d.vec3f) // false
|
1057
|
+
*/
|
1058
|
+
declare function isWgslArray<T extends WgslArray>(schema: T | unknown): schema is T;
|
1059
|
+
/**
|
1060
|
+
* Checks whether passed in value is a struct schema,
|
1061
|
+
* as opposed to, e.g., an unstruct schema.
|
1062
|
+
*
|
1063
|
+
* Struct schemas can be used to describe uniform and storage buffers,
|
1064
|
+
* whereas unstruct schemas cannot.
|
1065
|
+
*
|
1066
|
+
* @example
|
1067
|
+
* isWgslStruct(d.struct({ a: d.u32 })) // true
|
1068
|
+
* isWgslStruct(d.unstruct({ a: d.u32 })) // false
|
1069
|
+
* isWgslStruct(d.vec3f) // false
|
1070
|
+
*/
|
1071
|
+
declare function isWgslStruct<T extends WgslStruct>(schema: T | unknown): schema is T;
|
1072
|
+
/**
|
1073
|
+
* Checks whether passed in value is a pointer ('function' scope) schema.
|
1074
|
+
*
|
1075
|
+
* @example
|
1076
|
+
* isPtrFn(d.ptrFn(d.f32)) // true
|
1077
|
+
* isPtrFn(d.f32) // false
|
1078
|
+
*/
|
1079
|
+
declare function isPtr<T extends Ptr>(schema: T | unknown): schema is T;
|
1080
|
+
/**
|
1081
|
+
* Checks whether the passed in value is an atomic schema.
|
1082
|
+
*
|
1083
|
+
* @example
|
1084
|
+
* isAtomic(d.atomic(d.u32)) // true
|
1085
|
+
* isAtomic(d.u32) // false
|
1086
|
+
*/
|
1087
|
+
declare function isAtomic<T extends Atomic<U32 | I32>>(schema: T | unknown): schema is T;
|
1088
|
+
declare function isAlignAttrib<T extends Align<number>>(value: unknown | T): value is T;
|
1089
|
+
declare function isSizeAttrib<T extends Size<number>>(value: unknown | T): value is T;
|
1090
|
+
declare function isLocationAttrib<T extends Location<number>>(value: unknown | T): value is T;
|
1091
|
+
declare function isInterpolateAttrib<T extends Interpolate<InterpolationType>>(value: unknown | T): value is T;
|
1092
|
+
declare function isBuiltinAttrib<T extends Builtin<string>>(value: unknown | T): value is T;
|
1093
|
+
declare function isDecorated<T extends Decorated>(value: unknown | T): value is T;
|
1094
|
+
|
1095
|
+
declare const $internal: unique symbol;
|
1096
|
+
|
1097
|
+
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"];
|
1098
|
+
type VertexFormat = (typeof vertexFormats)[number];
|
1099
|
+
declare const kindToDefaultFormatMap: {
|
1100
|
+
readonly f32: "float32";
|
1101
|
+
readonly vec2f: "float32x2";
|
1102
|
+
readonly vec3f: "float32x3";
|
1103
|
+
readonly vec4f: "float32x4";
|
1104
|
+
readonly f16: "float16";
|
1105
|
+
readonly vec2h: "float16x2";
|
1106
|
+
readonly vec4h: "float16x4";
|
1107
|
+
readonly u32: "uint32";
|
1108
|
+
readonly vec2u: "uint32x2";
|
1109
|
+
readonly vec3u: "uint32x3";
|
1110
|
+
readonly vec4u: "uint32x4";
|
1111
|
+
readonly i32: "sint32";
|
1112
|
+
readonly vec2i: "sint32x2";
|
1113
|
+
readonly vec3i: "sint32x3";
|
1114
|
+
readonly vec4i: "sint32x4";
|
1115
|
+
};
|
1116
|
+
type KindToDefaultFormatMap = typeof kindToDefaultFormatMap;
|
1117
|
+
interface TgpuVertexAttrib<TFormat extends VertexFormat = VertexFormat> {
|
1118
|
+
readonly format: TFormat;
|
1119
|
+
readonly offset: number;
|
1120
|
+
}
|
1121
|
+
/**
|
1122
|
+
* All vertex attribute formats that can be interpreted as
|
1123
|
+
* an single or multi component u32 in a shader.
|
1124
|
+
* https://www.w3.org/TR/webgpu/#vertex-formats
|
1125
|
+
*/
|
1126
|
+
type U32CompatibleFormats = TgpuVertexAttrib<'uint8'> | TgpuVertexAttrib<'uint8x2'> | TgpuVertexAttrib<'uint8x4'> | TgpuVertexAttrib<'uint16'> | TgpuVertexAttrib<'uint16x2'> | TgpuVertexAttrib<'uint16x4'> | TgpuVertexAttrib<'uint32'> | TgpuVertexAttrib<'uint32x2'> | TgpuVertexAttrib<'uint32x3'> | TgpuVertexAttrib<'uint32x4'>;
|
1127
|
+
/**
|
1128
|
+
* All vertex attribute formats that can be interpreted as
|
1129
|
+
* an single or multi component i32 in a shader.
|
1130
|
+
* https://www.w3.org/TR/webgpu/#vertex-formats
|
1131
|
+
*/
|
1132
|
+
type I32CompatibleFormats = TgpuVertexAttrib<'sint8'> | TgpuVertexAttrib<'sint8x2'> | TgpuVertexAttrib<'sint8x4'> | TgpuVertexAttrib<'sint16'> | TgpuVertexAttrib<'sint16x2'> | TgpuVertexAttrib<'sint16x4'> | TgpuVertexAttrib<'sint32'> | TgpuVertexAttrib<'sint32x2'> | TgpuVertexAttrib<'sint32x3'> | TgpuVertexAttrib<'sint32x4'>;
|
1133
|
+
/**
|
1134
|
+
* All vertex attribute formats that can be interpreted as
|
1135
|
+
* an single or multi component f32 in a shader.
|
1136
|
+
* https://www.w3.org/TR/webgpu/#vertex-formats
|
1137
|
+
*/
|
1138
|
+
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'>;
|
1139
|
+
/**
|
1140
|
+
* All vertex attribute formats that can be interpreted as
|
1141
|
+
* a single or multi component f16 in a shader. (same as f32 on the shader side)
|
1142
|
+
* https://www.w3.org/TR/webgpu/#vertex-formats
|
1143
|
+
*/
|
1144
|
+
type F16CompatibleFormats = F32CompatibleFormats;
|
1145
|
+
type KindToAcceptedAttribMap = {
|
1146
|
+
u32: U32CompatibleFormats;
|
1147
|
+
vec2u: U32CompatibleFormats;
|
1148
|
+
vec3u: U32CompatibleFormats;
|
1149
|
+
vec4u: U32CompatibleFormats;
|
1150
|
+
i32: I32CompatibleFormats;
|
1151
|
+
vec2i: I32CompatibleFormats;
|
1152
|
+
vec3i: I32CompatibleFormats;
|
1153
|
+
vec4i: I32CompatibleFormats;
|
1154
|
+
f16: F16CompatibleFormats;
|
1155
|
+
vec2h: F16CompatibleFormats;
|
1156
|
+
vec3h: F16CompatibleFormats;
|
1157
|
+
vec4h: F16CompatibleFormats;
|
1158
|
+
f32: F32CompatibleFormats;
|
1159
|
+
vec2f: F32CompatibleFormats;
|
1160
|
+
vec3f: F32CompatibleFormats;
|
1161
|
+
vec4f: F32CompatibleFormats;
|
1162
|
+
};
|
1163
|
+
|
1164
|
+
type FormatToWGSLType<T extends VertexFormat> = (typeof formatToWGSLType)[T];
|
1165
|
+
interface TgpuVertexFormatData<T extends VertexFormat> {
|
1166
|
+
readonly type: T;
|
1167
|
+
/** Type-token, not available at runtime */
|
1168
|
+
readonly [$repr]: Infer<FormatToWGSLType<T>>;
|
1169
|
+
}
|
1170
|
+
declare const formatToWGSLType: {
|
1171
|
+
readonly uint8: U32;
|
1172
|
+
readonly uint8x2: Vec2u;
|
1173
|
+
readonly uint8x4: Vec4u;
|
1174
|
+
readonly sint8: I32;
|
1175
|
+
readonly sint8x2: Vec2i;
|
1176
|
+
readonly sint8x4: Vec4i;
|
1177
|
+
readonly unorm8: F32;
|
1178
|
+
readonly unorm8x2: Vec2f;
|
1179
|
+
readonly unorm8x4: Vec4f;
|
1180
|
+
readonly snorm8: F32;
|
1181
|
+
readonly snorm8x2: Vec2f;
|
1182
|
+
readonly snorm8x4: Vec4f;
|
1183
|
+
readonly uint16: U32;
|
1184
|
+
readonly uint16x2: Vec2u;
|
1185
|
+
readonly uint16x4: Vec4u;
|
1186
|
+
readonly sint16: I32;
|
1187
|
+
readonly sint16x2: Vec2i;
|
1188
|
+
readonly sint16x4: Vec4i;
|
1189
|
+
readonly unorm16: F32;
|
1190
|
+
readonly unorm16x2: Vec2f;
|
1191
|
+
readonly unorm16x4: Vec4f;
|
1192
|
+
readonly snorm16: F32;
|
1193
|
+
readonly snorm16x2: Vec2f;
|
1194
|
+
readonly snorm16x4: Vec4f;
|
1195
|
+
readonly float16: F32;
|
1196
|
+
readonly float16x2: Vec2f;
|
1197
|
+
readonly float16x4: Vec4f;
|
1198
|
+
readonly float32: F32;
|
1199
|
+
readonly float32x2: Vec2f;
|
1200
|
+
readonly float32x3: Vec3f;
|
1201
|
+
readonly float32x4: Vec4f;
|
1202
|
+
readonly uint32: U32;
|
1203
|
+
readonly uint32x2: Vec2u;
|
1204
|
+
readonly uint32x3: Vec3u;
|
1205
|
+
readonly uint32x4: Vec4u;
|
1206
|
+
readonly sint32: I32;
|
1207
|
+
readonly sint32x2: Vec2i;
|
1208
|
+
readonly sint32x3: Vec3i;
|
1209
|
+
readonly sint32x4: Vec4i;
|
1210
|
+
readonly 'unorm10-10-10-2': Vec4f;
|
1211
|
+
readonly 'unorm8x4-bgra': Vec4f;
|
1212
|
+
};
|
1213
|
+
declare const packedFormats: string[];
|
1214
|
+
type uint8 = TgpuVertexFormatData<'uint8'>;
|
1215
|
+
declare const uint8: uint8;
|
1216
|
+
type uint8x2 = TgpuVertexFormatData<'uint8x2'>;
|
1217
|
+
declare const uint8x2: uint8x2;
|
1218
|
+
type uint8x4 = TgpuVertexFormatData<'uint8x4'>;
|
1219
|
+
declare const uint8x4: uint8x4;
|
1220
|
+
type sint8 = TgpuVertexFormatData<'sint8'>;
|
1221
|
+
declare const sint8: sint8;
|
1222
|
+
type sint8x2 = TgpuVertexFormatData<'sint8x2'>;
|
1223
|
+
declare const sint8x2: sint8x2;
|
1224
|
+
type sint8x4 = TgpuVertexFormatData<'sint8x4'>;
|
1225
|
+
declare const sint8x4: sint8x4;
|
1226
|
+
type unorm8 = TgpuVertexFormatData<'unorm8'>;
|
1227
|
+
declare const unorm8: unorm8;
|
1228
|
+
type unorm8x2 = TgpuVertexFormatData<'unorm8x2'>;
|
1229
|
+
declare const unorm8x2: unorm8x2;
|
1230
|
+
type unorm8x4 = TgpuVertexFormatData<'unorm8x4'>;
|
1231
|
+
declare const unorm8x4: unorm8x4;
|
1232
|
+
type snorm8 = TgpuVertexFormatData<'snorm8'>;
|
1233
|
+
declare const snorm8: snorm8;
|
1234
|
+
type snorm8x2 = TgpuVertexFormatData<'snorm8x2'>;
|
1235
|
+
declare const snorm8x2: snorm8x2;
|
1236
|
+
type snorm8x4 = TgpuVertexFormatData<'snorm8x4'>;
|
1237
|
+
declare const snorm8x4: snorm8x4;
|
1238
|
+
type uint16 = TgpuVertexFormatData<'uint16'>;
|
1239
|
+
declare const uint16: uint16;
|
1240
|
+
type uint16x2 = TgpuVertexFormatData<'uint16x2'>;
|
1241
|
+
declare const uint16x2: uint16x2;
|
1242
|
+
type uint16x4 = TgpuVertexFormatData<'uint16x4'>;
|
1243
|
+
declare const uint16x4: uint16x4;
|
1244
|
+
type sint16 = TgpuVertexFormatData<'sint16'>;
|
1245
|
+
declare const sint16: sint16;
|
1246
|
+
type sint16x2 = TgpuVertexFormatData<'sint16x2'>;
|
1247
|
+
declare const sint16x2: sint16x2;
|
1248
|
+
type sint16x4 = TgpuVertexFormatData<'sint16x4'>;
|
1249
|
+
declare const sint16x4: sint16x4;
|
1250
|
+
type unorm16 = TgpuVertexFormatData<'unorm16'>;
|
1251
|
+
declare const unorm16: unorm16;
|
1252
|
+
type unorm16x2 = TgpuVertexFormatData<'unorm16x2'>;
|
1253
|
+
declare const unorm16x2: unorm16x2;
|
1254
|
+
type unorm16x4 = TgpuVertexFormatData<'unorm16x4'>;
|
1255
|
+
declare const unorm16x4: unorm16x4;
|
1256
|
+
type snorm16 = TgpuVertexFormatData<'snorm16'>;
|
1257
|
+
declare const snorm16: snorm16;
|
1258
|
+
type snorm16x2 = TgpuVertexFormatData<'snorm16x2'>;
|
1259
|
+
declare const snorm16x2: snorm16x2;
|
1260
|
+
type snorm16x4 = TgpuVertexFormatData<'snorm16x4'>;
|
1261
|
+
declare const snorm16x4: snorm16x4;
|
1262
|
+
type float16 = TgpuVertexFormatData<'float16'>;
|
1263
|
+
declare const float16: float16;
|
1264
|
+
type float16x2 = TgpuVertexFormatData<'float16x2'>;
|
1265
|
+
declare const float16x2: float16x2;
|
1266
|
+
type float16x4 = TgpuVertexFormatData<'float16x4'>;
|
1267
|
+
declare const float16x4: float16x4;
|
1268
|
+
type float32 = TgpuVertexFormatData<'float32'>;
|
1269
|
+
declare const float32: float32;
|
1270
|
+
type float32x2 = TgpuVertexFormatData<'float32x2'>;
|
1271
|
+
declare const float32x2: float32x2;
|
1272
|
+
type float32x3 = TgpuVertexFormatData<'float32x3'>;
|
1273
|
+
declare const float32x3: float32x3;
|
1274
|
+
type float32x4 = TgpuVertexFormatData<'float32x4'>;
|
1275
|
+
declare const float32x4: float32x4;
|
1276
|
+
type uint32 = TgpuVertexFormatData<'uint32'>;
|
1277
|
+
declare const uint32: uint32;
|
1278
|
+
type uint32x2 = TgpuVertexFormatData<'uint32x2'>;
|
1279
|
+
declare const uint32x2: uint32x2;
|
1280
|
+
type uint32x3 = TgpuVertexFormatData<'uint32x3'>;
|
1281
|
+
declare const uint32x3: uint32x3;
|
1282
|
+
type uint32x4 = TgpuVertexFormatData<'uint32x4'>;
|
1283
|
+
declare const uint32x4: uint32x4;
|
1284
|
+
type sint32 = TgpuVertexFormatData<'sint32'>;
|
1285
|
+
declare const sint32: sint32;
|
1286
|
+
type sint32x2 = TgpuVertexFormatData<'sint32x2'>;
|
1287
|
+
declare const sint32x2: sint32x2;
|
1288
|
+
type sint32x3 = TgpuVertexFormatData<'sint32x3'>;
|
1289
|
+
declare const sint32x3: sint32x3;
|
1290
|
+
type sint32x4 = TgpuVertexFormatData<'sint32x4'>;
|
1291
|
+
declare const sint32x4: sint32x4;
|
1292
|
+
type unorm10_10_10_2 = TgpuVertexFormatData<'unorm10-10-10-2'>;
|
1293
|
+
declare const unorm10_10_10_2: unorm10_10_10_2;
|
1294
|
+
type unorm8x4_bgra = TgpuVertexFormatData<'unorm8x4-bgra'>;
|
1295
|
+
declare const unorm8x4_bgra: unorm8x4_bgra;
|
1296
|
+
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;
|
1297
|
+
|
1298
|
+
type TgpuDualFn<TImpl extends (...args: unknown[]) => unknown> = TImpl & {
|
1299
|
+
[$internal]: {
|
1300
|
+
implementation: TImpl | string;
|
1301
|
+
};
|
1302
|
+
};
|
1303
|
+
/**
|
1304
|
+
* Array schema constructed via `d.disarrayOf` function.
|
1146
1305
|
*
|
1147
|
-
*
|
1148
|
-
*
|
1149
|
-
*
|
1306
|
+
* Useful for defining vertex buffers.
|
1307
|
+
* Elements in the schema are not aligned in respect to their `byteAlignment`,
|
1308
|
+
* unless they are explicitly decorated with the custom align attribute
|
1309
|
+
* via `d.align` function.
|
1150
1310
|
*/
|
1151
|
-
interface
|
1152
|
-
readonly type: '
|
1311
|
+
interface Disarray<TElement extends BaseData = BaseData> {
|
1312
|
+
readonly type: 'disarray';
|
1153
1313
|
readonly elementCount: number;
|
1154
1314
|
readonly elementType: TElement;
|
1155
|
-
|
1156
|
-
readonly '~repr': Infer<TElement>[];
|
1157
|
-
readonly '~gpuRepr': InferGPU<TElement>[];
|
1315
|
+
readonly [$repr]: Infer<TElement>[];
|
1158
1316
|
readonly '~reprPartial': {
|
1159
1317
|
idx: number;
|
1160
1318
|
value: InferPartial<TElement>;
|
1161
1319
|
}[];
|
1162
|
-
readonly '~memIdent': WgslArray<MemIdentity<TElement>>;
|
1163
|
-
}
|
1164
|
-
type AddressSpace = 'uniform' | 'storage' | 'workgroup' | 'private' | 'function' | 'handle';
|
1165
|
-
type Access = 'read' | 'write' | 'read-write';
|
1166
|
-
interface Ptr<TAddr extends AddressSpace = AddressSpace, TInner extends BaseData = BaseData, // can also be sampler or texture (╯'□')╯︵ ┻━┻
|
1167
|
-
TAccess extends Access = Access> {
|
1168
|
-
readonly type: 'ptr';
|
1169
|
-
readonly inner: TInner;
|
1170
|
-
readonly addressSpace: TAddr;
|
1171
|
-
readonly access: TAccess;
|
1172
|
-
/** Type-token, not available at runtime */
|
1173
|
-
readonly '~repr': Infer<TInner>;
|
1174
1320
|
}
|
1175
1321
|
/**
|
1176
|
-
*
|
1322
|
+
* Struct schema constructed via `d.unstruct` function.
|
1323
|
+
*
|
1324
|
+
* Useful for defining vertex buffers, as the standard layout restrictions do not apply.
|
1325
|
+
* Members are not aligned in respect to their `byteAlignment`,
|
1326
|
+
* unless they are explicitly decorated with the custom align attribute
|
1327
|
+
* via `d.align` function.
|
1177
1328
|
*/
|
1178
|
-
interface
|
1179
|
-
|
1180
|
-
readonly
|
1181
|
-
|
1182
|
-
readonly
|
1183
|
-
readonly
|
1184
|
-
readonly '~
|
1185
|
-
|
1186
|
-
|
1187
|
-
type: 'atomicU32';
|
1188
|
-
}
|
1189
|
-
interface atomicI32 {
|
1190
|
-
type: 'atomicI32';
|
1191
|
-
}
|
1192
|
-
interface Align<T extends number> {
|
1193
|
-
readonly type: '@align';
|
1194
|
-
readonly value: T;
|
1195
|
-
}
|
1196
|
-
interface Size<T extends number> {
|
1197
|
-
readonly type: '@size';
|
1198
|
-
readonly value: T;
|
1199
|
-
}
|
1200
|
-
interface Location<T extends number> {
|
1201
|
-
readonly type: '@location';
|
1202
|
-
readonly value: T;
|
1203
|
-
}
|
1204
|
-
type PerspectiveOrLinearInterpolationType = `${'perspective' | 'linear'}${'' | ', center' | ', centroid' | ', sample'}`;
|
1205
|
-
type FlatInterpolationType = `flat${'' | ', first' | ', either'}`;
|
1206
|
-
type InterpolationType = PerspectiveOrLinearInterpolationType | FlatInterpolationType;
|
1207
|
-
interface Interpolate<T extends InterpolationType> {
|
1208
|
-
readonly type: '@interpolate';
|
1209
|
-
readonly value: T;
|
1210
|
-
}
|
1211
|
-
interface Builtin<T extends string> {
|
1212
|
-
readonly type: '@builtin';
|
1213
|
-
readonly value: T;
|
1329
|
+
interface Unstruct<TProps extends Record<string, BaseData> = Record<string, BaseData>> extends TgpuNamable {
|
1330
|
+
(props: Prettify<InferRecord<TProps>>): Prettify<InferRecord<TProps>>;
|
1331
|
+
readonly label?: string | undefined;
|
1332
|
+
readonly type: 'unstruct';
|
1333
|
+
readonly propTypes: TProps;
|
1334
|
+
readonly [$repr]: Prettify<InferRecord<TProps>>;
|
1335
|
+
readonly '~gpuRepr': Prettify<InferGPURecord<TProps>>;
|
1336
|
+
readonly '~memIdent': Unstruct<Prettify<MemIdentityRecord<TProps>>>;
|
1337
|
+
readonly '~reprPartial': Prettify<Partial<InferPartialRecord<TProps>>>;
|
1214
1338
|
}
|
1215
|
-
|
1216
|
-
|
1339
|
+
type AnyUnstruct = Unstruct<any>;
|
1340
|
+
interface LooseDecorated<TInner extends BaseData = BaseData, TAttribs extends unknown[] = unknown[]> {
|
1341
|
+
readonly type: 'loose-decorated';
|
1217
1342
|
readonly inner: TInner;
|
1218
1343
|
readonly attribs: TAttribs;
|
1219
|
-
|
1220
|
-
readonly '~repr': Infer<TInner>;
|
1221
|
-
readonly '~gpuRepr': InferGPU<TInner>;
|
1222
|
-
readonly '~reprPartial': InferPartial<TInner>;
|
1223
|
-
readonly '~memIdent': TAttribs extends Location<number>[] ? MemIdentity<TInner> | Decorated<MemIdentity<TInner>, TAttribs> : Decorated<MemIdentity<TInner>, TAttribs>;
|
1344
|
+
readonly [$repr]: Infer<TInner>;
|
1224
1345
|
}
|
1225
|
-
declare const
|
1226
|
-
type
|
1227
|
-
type
|
1228
|
-
|
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;
|
1230
|
-
declare function isWgslData(value: unknown): value is AnyWgslData;
|
1346
|
+
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"];
|
1347
|
+
type LooseTypeLiteral = (typeof looseTypeLiterals)[number];
|
1348
|
+
type AnyLooseData = Disarray | AnyUnstruct | LooseDecorated | PackedData;
|
1349
|
+
declare function isLooseData(data: unknown): data is AnyLooseData;
|
1231
1350
|
/**
|
1232
|
-
* Checks whether passed in value is
|
1233
|
-
* as opposed to, e.g., a
|
1351
|
+
* Checks whether the passed in value is a disarray schema,
|
1352
|
+
* as opposed to, e.g., a regular array schema.
|
1234
1353
|
*
|
1235
1354
|
* Array schemas can be used to describe uniform and storage buffers,
|
1236
|
-
* whereas disarray schemas cannot.
|
1355
|
+
* whereas disarray schemas cannot. Disarrays are useful for
|
1356
|
+
* defining vertex buffers instead.
|
1237
1357
|
*
|
1238
1358
|
* @example
|
1239
|
-
*
|
1240
|
-
*
|
1241
|
-
*
|
1359
|
+
* isDisarray(d.arrayOf(d.u32, 4)) // false
|
1360
|
+
* isDisarray(d.disarrayOf(d.u32, 4)) // true
|
1361
|
+
* isDisarray(d.vec3f) // false
|
1242
1362
|
*/
|
1243
|
-
declare function
|
1363
|
+
declare function isDisarray<T extends Disarray>(schema: T | unknown): schema is T;
|
1244
1364
|
/**
|
1245
|
-
* Checks whether passed in value is a
|
1246
|
-
* as opposed to, e.g.,
|
1365
|
+
* Checks whether passed in value is a unstruct schema,
|
1366
|
+
* as opposed to, e.g., a struct schema.
|
1247
1367
|
*
|
1248
1368
|
* Struct schemas can be used to describe uniform and storage buffers,
|
1249
|
-
* whereas unstruct schemas cannot.
|
1250
|
-
*
|
1251
|
-
* @example
|
1252
|
-
* isWgslStruct(d.struct({ a: d.u32 })) // true
|
1253
|
-
* isWgslStruct(d.unstruct({ a: d.u32 })) // false
|
1254
|
-
* isWgslStruct(d.vec3f) // false
|
1255
|
-
*/
|
1256
|
-
declare function isWgslStruct<T extends WgslStruct>(schema: T | unknown): schema is T;
|
1257
|
-
/**
|
1258
|
-
* Checks whether passed in value is a pointer ('function' scope) schema.
|
1259
|
-
*
|
1260
|
-
* @example
|
1261
|
-
* isPtrFn(d.ptrFn(d.f32)) // true
|
1262
|
-
* isPtrFn(d.f32) // false
|
1263
|
-
*/
|
1264
|
-
declare function isPtr<T extends Ptr>(schema: T | unknown): schema is T;
|
1265
|
-
/**
|
1266
|
-
* Checks whether the passed in value is an atomic schema.
|
1369
|
+
* whereas unstruct schemas cannot. Unstructs are useful for
|
1370
|
+
* defining vertex buffers instead.
|
1267
1371
|
*
|
1268
1372
|
* @example
|
1269
|
-
*
|
1270
|
-
*
|
1373
|
+
* isUnstruct(d.struct({ a: d.u32 })) // false
|
1374
|
+
* isUnstruct(d.unstruct({ a: d.u32 })) // true
|
1375
|
+
* isUnstruct(d.vec3f) // false
|
1271
1376
|
*/
|
1272
|
-
declare function
|
1273
|
-
declare function
|
1274
|
-
declare function
|
1275
|
-
|
1276
|
-
declare function isInterpolateAttrib<T extends Interpolate<InterpolationType>>(value: unknown | T): value is T;
|
1277
|
-
declare function isBuiltinAttrib<T extends Builtin<string>>(value: unknown | T): value is T;
|
1278
|
-
declare function isDecorated<T extends Decorated>(value: unknown | T): value is T;
|
1377
|
+
declare function isUnstruct<T extends Unstruct>(schema: T | unknown): schema is T;
|
1378
|
+
declare function isLooseDecorated<T extends LooseDecorated>(value: T | unknown): value is T;
|
1379
|
+
declare function isData(value: unknown): value is AnyData;
|
1380
|
+
type AnyData = AnyWgslData | AnyLooseData;
|
1279
1381
|
|
1280
|
-
export {
|
1382
|
+
export { $internal as $, type AnyWgslData as A, type BaseData as B, type Default as C, type Decorated as D, type InferGPU as E, type F32 as F, type AnyVecInstance as G, type AnyMatInstance as H, type Infer as I, type Bool as J, type KindToDefaultFormatMap as K, type Location as L, type Mutable as M, type Ptr as N, type OmitProps as O, type Prettify as P, type Vec2b as Q, type Vec3b as R, type Vec4b as S, type TgpuNamable as T, type U32 as U, type Vec2f as V, type WgslStruct as W, type Unstruct as X, type Mat2x2f as Y, type Mat3x3f as Z, type Mat4x4f as _, type F16 as a, float16 as a$, type m2x2f as a0, type m3x3f as a1, type m4x4f as a2, type Atomic as a3, isWgslData as a4, isWgslArray as a5, isWgslStruct as a6, isPtr as a7, isAtomic as a8, isDecorated as a9, type TgpuVertexFormatData as aA, formatToWGSLType as aB, packedFormats as aC, uint8 as aD, uint8x2 as aE, uint8x4 as aF, sint8 as aG, sint8x2 as aH, sint8x4 as aI, unorm8 as aJ, unorm8x2 as aK, unorm8x4 as aL, snorm8 as aM, snorm8x2 as aN, snorm8x4 as aO, uint16 as aP, uint16x2 as aQ, uint16x4 as aR, sint16 as aS, sint16x2 as aT, sint16x4 as aU, unorm16 as aV, unorm16x2 as aW, unorm16x4 as aX, snorm16 as aY, snorm16x2 as aZ, snorm16x4 as a_, isAlignAttrib as aa, isBuiltinAttrib as ab, isLocationAttrib as ac, isInterpolateAttrib as ad, isSizeAttrib as ae, type Size as af, type Align as ag, type Builtin as ah, type Interpolate as ai, type v2f as aj, type v2i as ak, type v2u as al, type v3f as am, type v3i as an, type v3u as ao, type v4f as ap, type v4i as aq, type v4u as ar, type LooseDecorated as as, type AnyLooseData as at, isDisarray as au, isUnstruct as av, isLooseDecorated as aw, isData as ax, isLooseData as ay, type FormatToWGSLType as az, type I32 as b, float16x2 as b0, float16x4 as b1, float32 as b2, float32x2 as b3, float32x3 as b4, float32x4 as b5, uint32 as b6, uint32x2 as b7, uint32x3 as b8, uint32x4 as b9, type atomicU32 as bA, sint32 as ba, sint32x2 as bb, sint32x3 as bc, sint32x4 as bd, unorm10_10_10_2 as be, unorm8x4_bgra as bf, type PackedData as bg, type InterpolationType as bh, type LooseTypeLiteral as bi, type PerspectiveOrLinearInterpolationType as bj, type PerspectiveOrLinearInterpolatableData as bk, type FlatInterpolationType as bl, type FlatInterpolatableData as bm, type TgpuDualFn as bn, type AnyNumericVecInstance as bo, type vBaseForMat as bp, type AnyFloatVecInstance as bq, type v3h as br, type AnyVec2Instance as bs, type v2b as bt, type AnyVec3Instance as bu, type v3b as bv, type v4b as bw, type AnyBooleanVecInstance as bx, type ScalarData as by, type atomicI32 as bz, 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, $repr as o, type WgslArray as p, type Disarray as q, type AnyUnstruct as r, type VertexFormat as s, type TgpuVertexAttrib as t, type KindToAcceptedAttribMap as u, type AnyData as v, type WgslTypeLiteral as w, type UnionToIntersection as x, type InferPartial as y, type MemIdentity as z };
|