typegpu 0.5.3 → 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.
- package/README.md +1 -1
- package/attributes-BdU8hyQq.d.cts +435 -0
- package/attributes-CAsvE5Z9.d.ts +435 -0
- package/{chunk-RMXVIINO.js → chunk-5PJ3H5OR.js} +2 -2
- package/chunk-5PJ3H5OR.js.map +1 -0
- package/chunk-7UUBX6MC.cjs +4 -0
- package/chunk-7UUBX6MC.cjs.map +1 -0
- package/chunk-AKBL6GDL.js +4 -0
- package/chunk-AKBL6GDL.js.map +1 -0
- package/{chunk-FM3TKZFZ.cjs → chunk-URJCMUTT.cjs} +2 -2
- package/chunk-URJCMUTT.cjs.map +1 -0
- package/data/index.cjs +1 -1
- package/data/index.cjs.map +1 -1
- package/data/index.d.cts +51 -4
- package/data/index.d.ts +51 -4
- package/data/index.js +1 -1
- package/index.cjs +16 -16
- package/index.cjs.map +1 -1
- package/index.d.cts +92 -53
- package/index.d.ts +92 -53
- package/index.js +16 -16
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/std/index.cjs +1 -1
- package/std/index.cjs.map +1 -1
- package/std/index.d.cts +141 -33
- package/std/index.d.ts +141 -33
- package/std/index.js +1 -1
- package/std/index.js.map +1 -1
- package/{wgslTypes-VtSRoe90.d.cts → wgslTypes-Bh2dG5qv.d.cts} +213 -405
- package/{wgslTypes-VtSRoe90.d.ts → wgslTypes-Bh2dG5qv.d.ts} +213 -405
- package/attributes-B4JpvOTz.d.ts +0 -159
- package/attributes-DSOqT8yA.d.cts +0 -159
- package/chunk-DVZNNZFQ.js +0 -2
- package/chunk-DVZNNZFQ.js.map +0 -1
- package/chunk-FM3TKZFZ.cjs.map +0 -1
- package/chunk-M4VUFFPZ.cjs +0 -4
- package/chunk-M4VUFFPZ.cjs.map +0 -1
- 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
package/index.d.cts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import { A as AnyWgslData, T as TgpuNamable, I as Infer, F as F32, a as F16, b as I32, U as U32, V as Vec2f, c as Vec3f, d as Vec4f, e as Vec2h, f as Vec3h, g as Vec4h, h as Vec2i, i as Vec3i, j as Vec4i, k as Vec2u, l as Vec3u, m as Vec4u, D as Decorated, n as AnyWgslStruct, B as BaseData, L as Location, W as WgslStruct, o as Default, p as UnionToIntersection, q as WgslArray,
|
2
|
-
import { A as AnyAttribute, a as AnyComputeBuiltin, D as Decorate, I as IsBuiltin, H as HasCustomLocation, b as AnyFragmentInputBuiltin, c as AnyFragmentOutputBuiltin, O as OmitBuiltins } from './attributes-
|
1
|
+
import { A as AnyWgslData, T as TgpuNamable, I as Infer, F as F32, a as F16, b as I32, U as U32, V as Vec2f, c as Vec3f, d as Vec4f, e as Vec2h, f as Vec3h, g as Vec4h, h as Vec2i, i as Vec3i, j as Vec4i, k as Vec2u, l as Vec3u, m as Vec4u, D as Decorated, n as AnyWgslStruct, $ as $repr, B as BaseData, L as Location, W as WgslStruct, o as Default, p as UnionToIntersection, q as WgslArray, O as OmitProps, P as Prettify, M as Mutable, r as WgslTypeLiteral, s as InferPartial, t as MemIdentity, u as InferGPU, v as AbstractInt, w as AbstractFloat, x as AnyVecInstance, y as AnyMatInstance } from './wgslTypes-Bh2dG5qv.cjs';
|
2
|
+
import { A as AnyAttribute, a as AnyComputeBuiltin, D as Decorate, I as IsBuiltin, H as HasCustomLocation, b as AnyFragmentInputBuiltin, c as AnyFragmentOutputBuiltin, O as OmitBuiltins, d as Disarray, U as Unstruct, V as VertexFormat, T as TgpuVertexAttrib, K as KindToDefaultFormatMap, e as KindToAcceptedAttribMap, f as AnyData } from './attributes-BdU8hyQq.cjs';
|
3
3
|
import * as smol from 'tinyest';
|
4
|
-
import { Block } from 'tinyest';
|
4
|
+
import { ArgNames, Block } from 'tinyest';
|
5
5
|
|
6
6
|
declare const $internal: unique symbol;
|
7
7
|
|
@@ -36,7 +36,7 @@ declare function declare(declaration: string): TgpuDeclare;
|
|
36
36
|
* Information extracted from transpiling a JS function.
|
37
37
|
*/
|
38
38
|
type TranspilationResult = {
|
39
|
-
argNames:
|
39
|
+
argNames: smol.ArgNames;
|
40
40
|
body: smol.Block;
|
41
41
|
/**
|
42
42
|
* All identifiers found in the function code that are not declared in the
|
@@ -63,24 +63,40 @@ type InferIO<T> = T extends {
|
|
63
63
|
} : T;
|
64
64
|
|
65
65
|
/**
|
66
|
-
* Describes a compute entry function signature (its arguments and
|
66
|
+
* Describes a compute entry function signature (its arguments, return type and workgroup size)
|
67
67
|
*/
|
68
|
-
|
68
|
+
type TgpuComputeFnShellHeader<ComputeIn extends Record<string, AnyComputeBuiltin>> = {
|
69
69
|
readonly argTypes: [AnyWgslStruct];
|
70
70
|
readonly returnType: undefined;
|
71
71
|
readonly workgroupSize: [number, number, number];
|
72
|
+
};
|
73
|
+
/**
|
74
|
+
* Describes a compute entry function signature (its arguments, return type and workgroup size).
|
75
|
+
* Allows creating tgpu compute functions by calling this shell
|
76
|
+
* and passing the implementation (as WGSL string or JS function) as the argument.
|
77
|
+
*/
|
78
|
+
type TgpuComputeFnShell<ComputeIn extends Record<string, AnyComputeBuiltin>> = TgpuComputeFnShellHeader<ComputeIn> /**
|
79
|
+
* Creates a type-safe implementation of this signature
|
80
|
+
*/ & ((implementation: (input: InferIO<ComputeIn>) => undefined) => TgpuComputeFn<ComputeIn>) &
|
81
|
+
/**
|
82
|
+
* @param implementation
|
83
|
+
* Raw WGSL function implementation with header and body
|
84
|
+
* without `fn` keyword and function name
|
85
|
+
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
86
|
+
*/
|
87
|
+
((implementation: string) => TgpuComputeFn<ComputeIn>) & {
|
72
88
|
/**
|
73
|
-
*
|
89
|
+
* @deprecated Invoke the shell as a function instead.
|
74
90
|
*/
|
75
|
-
does(implementation: (input: InferIO<ComputeIn>) => undefined)
|
91
|
+
does: ((implementation: (input: InferIO<ComputeIn>) => undefined) => TgpuComputeFn<ComputeIn>) &
|
76
92
|
/**
|
77
93
|
* @param implementation
|
78
94
|
* Raw WGSL function implementation with header and body
|
79
95
|
* without `fn` keyword and function name
|
80
96
|
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
81
97
|
*/
|
82
|
-
|
83
|
-
}
|
98
|
+
((implementation: string) => TgpuComputeFn<ComputeIn>);
|
99
|
+
};
|
84
100
|
interface TgpuComputeFn<ComputeIn extends Record<string, AnyComputeBuiltin> = Record<string, AnyComputeBuiltin>> extends TgpuNamable {
|
85
101
|
readonly shell: TgpuComputeFnShell<ComputeIn>;
|
86
102
|
$uses(dependencyMap: Record<string, unknown>): this;
|
@@ -132,7 +148,7 @@ declare class StrictNameRegistry implements NameRegistry {
|
|
132
148
|
|
133
149
|
interface TgpuSlot<T> extends TgpuNamable, Labelled {
|
134
150
|
readonly resourceType: 'slot';
|
135
|
-
|
151
|
+
[$repr]: Infer<T>;
|
136
152
|
readonly defaultValue: T | undefined;
|
137
153
|
/**
|
138
154
|
* Used to determine if code generated using either value `a` or `b` in place
|
@@ -144,7 +160,7 @@ interface TgpuSlot<T> extends TgpuNamable, Labelled {
|
|
144
160
|
interface TgpuDerived<T> {
|
145
161
|
readonly resourceType: 'derived';
|
146
162
|
readonly value: Infer<T>;
|
147
|
-
|
163
|
+
[$repr]: Infer<T>;
|
148
164
|
readonly '~providing'?: Providing | undefined;
|
149
165
|
with<TValue>(slot: TgpuSlot<TValue>, value: Eventual<TValue>): TgpuDerived<T>;
|
150
166
|
/**
|
@@ -154,7 +170,7 @@ interface TgpuDerived<T> {
|
|
154
170
|
}
|
155
171
|
interface TgpuAccessor<T extends AnyWgslData = AnyWgslData> extends TgpuNamable, Labelled {
|
156
172
|
readonly resourceType: 'accessor';
|
157
|
-
|
173
|
+
[$repr]: Infer<T>;
|
158
174
|
readonly schema: T;
|
159
175
|
readonly defaultValue: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T> | undefined;
|
160
176
|
readonly slot: TgpuSlot<TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>>;
|
@@ -187,26 +203,42 @@ type IOLayoutToSchema<T extends IOLayout> = T extends BaseData ? Decorate<T, Loc
|
|
187
203
|
type FragmentOutConstrained = Vec4f | Decorated<Vec4f, [Location<number>]> | AnyFragmentOutputBuiltin | IORecord<Vec4f | Decorated<Vec4f, [Location<number>]> | AnyFragmentOutputBuiltin>;
|
188
204
|
type FragmentInConstrained = IORecord<BaseIOData | Decorated<BaseIOData, AnyAttribute<never>[]> | AnyFragmentInputBuiltin>;
|
189
205
|
/**
|
190
|
-
* Describes a fragment entry function signature (its arguments
|
206
|
+
* Describes a fragment entry function signature (its arguments, return type and targets)
|
191
207
|
*/
|
192
|
-
|
208
|
+
type TgpuFragmentFnShellHeader<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = {
|
193
209
|
readonly argTypes: [AnyWgslStruct];
|
194
210
|
readonly targets: FragmentOut;
|
195
211
|
readonly returnType: FragmentOut;
|
212
|
+
};
|
213
|
+
/**
|
214
|
+
* Describes a fragment entry function signature (its arguments, return type and targets).
|
215
|
+
* Allows creating tgpu fragment functions by calling this shell
|
216
|
+
* and passing the implementation (as WGSL string or JS function) as the argument.
|
217
|
+
*/
|
218
|
+
type TgpuFragmentFnShell<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = TgpuFragmentFnShellHeader<FragmentIn, FragmentOut> /**
|
219
|
+
* Creates a type-safe implementation of this signature
|
220
|
+
*/ & ((implementation: (input: InferIO<FragmentIn>) => InferIO<FragmentOut>) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) &
|
221
|
+
/**
|
222
|
+
* @param implementation
|
223
|
+
* Raw WGSL function implementation with header and body
|
224
|
+
* without `fn` keyword and function name
|
225
|
+
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
226
|
+
*/
|
227
|
+
((implementation: string) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) & {
|
196
228
|
/**
|
197
|
-
*
|
229
|
+
* @deprecated Invoke the shell as a function instead.
|
198
230
|
*/
|
199
|
-
does(implementation: (input: InferIO<FragmentIn>) => InferIO<FragmentOut>)
|
231
|
+
does: ((implementation: (input: InferIO<FragmentIn>) => InferIO<FragmentOut>) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) &
|
200
232
|
/**
|
201
233
|
* @param implementation
|
202
234
|
* Raw WGSL function implementation with header and body
|
203
235
|
* without `fn` keyword and function name
|
204
236
|
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
205
237
|
*/
|
206
|
-
|
207
|
-
}
|
238
|
+
((implementation: string) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>);
|
239
|
+
};
|
208
240
|
interface TgpuFragmentFn<Varying extends FragmentInConstrained = FragmentInConstrained, Output extends FragmentOutConstrained = FragmentOutConstrained> extends TgpuNamable {
|
209
|
-
readonly shell:
|
241
|
+
readonly shell: TgpuFragmentFnShellHeader<Varying, Output>;
|
210
242
|
readonly outputType: IOLayoutToSchema<Output>;
|
211
243
|
$uses(dependencyMap: Record<string, unknown>): this;
|
212
244
|
}
|
@@ -219,26 +251,26 @@ declare function fragmentFn<FragmentIn extends FragmentInConstrained, FragmentOu
|
|
219
251
|
}): TgpuFragmentFnShell<FragmentIn, FragmentOut>;
|
220
252
|
|
221
253
|
/**
|
222
|
-
* Describes a vertex entry function signature (its arguments
|
254
|
+
* Describes a vertex entry function signature (its arguments, return type and attributes)
|
223
255
|
*/
|
224
|
-
|
256
|
+
type TgpuVertexFnShellHeader<VertexIn extends IOLayout, VertexOut extends IOLayout> = {
|
225
257
|
readonly argTypes: [AnyWgslStruct];
|
226
258
|
readonly returnType: VertexOut;
|
227
259
|
readonly attributes: [VertexIn];
|
260
|
+
};
|
261
|
+
/**
|
262
|
+
* Describes a vertex entry function signature (its arguments, return type and attributes).
|
263
|
+
* Allows creating tgpu vertex functions by calling this shell
|
264
|
+
* and passing the implementation (as WGSL string or JS function) as the argument.
|
265
|
+
*/
|
266
|
+
type TgpuVertexFnShell<VertexIn extends IOLayout, VertexOut extends IOLayout> = TgpuVertexFnShellHeader<VertexIn, VertexOut> & ((implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & ((implementation: string) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & {
|
228
267
|
/**
|
229
|
-
*
|
230
|
-
*/
|
231
|
-
does(implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>): TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>;
|
232
|
-
/**
|
233
|
-
* @param implementation
|
234
|
-
* Raw WGSL function implementation with header and body
|
235
|
-
* without `fn` keyword and function name
|
236
|
-
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
268
|
+
* @deprecated Invoke the shell as a function instead.
|
237
269
|
*/
|
238
|
-
does(implementation:
|
239
|
-
}
|
270
|
+
does: ((implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & ((implementation: string) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>);
|
271
|
+
};
|
240
272
|
interface TgpuVertexFn<VertexIn extends IOLayout = IOLayout, VertexOut extends IOLayout = IOLayout> extends TgpuNamable {
|
241
|
-
readonly shell:
|
273
|
+
readonly shell: TgpuVertexFnShellHeader<VertexIn, VertexOut>;
|
242
274
|
readonly outputType: IOLayoutToSchema<VertexOut>;
|
243
275
|
readonly inputType: IOLayoutToSchema<VertexIn>;
|
244
276
|
$uses(dependencyMap: Record<string, unknown>): this;
|
@@ -1126,6 +1158,12 @@ interface TgpuBindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | n
|
|
1126
1158
|
readonly bound: {
|
1127
1159
|
[K in keyof Entries]: BindLayoutEntry<Entries[K]>;
|
1128
1160
|
};
|
1161
|
+
readonly value: {
|
1162
|
+
[K in keyof Entries]: InferLayoutEntry<Entries[K]>;
|
1163
|
+
};
|
1164
|
+
readonly $: {
|
1165
|
+
[K in keyof Entries]: InferLayoutEntry<Entries[K]>;
|
1166
|
+
};
|
1129
1167
|
/**
|
1130
1168
|
* An explicit numeric index assigned to this bind group layout. If undefined, a unique
|
1131
1169
|
* index is assigned automatically during resolution. This can be changed with the
|
@@ -1177,7 +1215,8 @@ type GetStorageTextureRestriction<T extends TgpuLayoutStorageTexture> = Default<
|
|
1177
1215
|
dimension: Dimension;
|
1178
1216
|
} : never;
|
1179
1217
|
type LayoutEntryToInput<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? (TgpuBuffer<UnwrapRuntimeConstructor<T['uniform']>> & UniformFlag) | GPUBuffer : T extends TgpuLayoutStorage ? (TgpuBuffer<UnwrapRuntimeConstructor<T['storage']>> & StorageFlag) | GPUBuffer : T extends TgpuLayoutSampler ? TgpuSampler | GPUSampler : T extends TgpuLayoutComparisonSampler ? TgpuComparisonSampler | GPUSampler : T extends TgpuLayoutTexture ? GPUTextureView | (Sampled & TgpuTexture<Prettify<TextureProps & GetTextureRestriction<T>>>) | TgpuSampledTexture<Default<T['viewDimension'], '2d'>, ChannelFormatToSchema[T['texture']]> : T extends TgpuLayoutStorageTexture ? GPUTextureView | (StorageFlag & TgpuTexture<Prettify<TextureProps & GetStorageTextureRestriction<T>>>) | StorageTextureUsageForEntry<T> : T extends TgpuLayoutExternalTexture ? GPUExternalTexture : never;
|
1180
|
-
type BindLayoutEntry<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? TgpuBufferUniform<
|
1218
|
+
type BindLayoutEntry<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? TgpuBufferUniform<T['uniform']> : T extends TgpuLayoutStorage ? StorageUsageForEntry<T> : T extends TgpuLayoutSampler ? TgpuSampler : T extends TgpuLayoutComparisonSampler ? TgpuComparisonSampler : T extends TgpuLayoutTexture ? TgpuSampledTexture<Default<GetDimension<T['viewDimension']>, '2d'>, ChannelFormatToSchema[T['texture']]> : T extends TgpuLayoutStorageTexture ? StorageTextureUsageForEntry<T> : never;
|
1219
|
+
type InferLayoutEntry<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? Infer<T['uniform']> : T extends TgpuLayoutStorage ? Infer<UnwrapRuntimeConstructor<T['storage']>> : T extends TgpuLayoutSampler ? TgpuSampler : T extends TgpuLayoutComparisonSampler ? TgpuComparisonSampler : T extends TgpuLayoutTexture ? TgpuSampledTexture<Default<GetDimension<T['viewDimension']>, '2d'>, ChannelFormatToSchema[T['texture']]> : T extends TgpuLayoutStorageTexture ? StorageTextureUsageForEntry<T> : never;
|
1181
1220
|
type TgpuBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>> = {
|
1182
1221
|
readonly resourceType: 'bind-group';
|
1183
1222
|
readonly layout: TgpuBindGroupLayout<Entries>;
|
@@ -1188,7 +1227,7 @@ declare function bindGroupLayout<Entries extends Record<string, TgpuLayoutEntry
|
|
1188
1227
|
interface TgpuBufferUsage<TData extends BaseData = BaseData, TUsage extends BindableBufferUsage = BindableBufferUsage> {
|
1189
1228
|
readonly resourceType: 'buffer-usage';
|
1190
1229
|
readonly usage: TUsage;
|
1191
|
-
readonly
|
1230
|
+
readonly [$repr]: Infer<TData>;
|
1192
1231
|
value: InferGPU<TData>;
|
1193
1232
|
readonly [$internal]: {
|
1194
1233
|
readonly dataType: TData;
|
@@ -1315,7 +1354,7 @@ interface ResolutionCtx {
|
|
1315
1354
|
resolve(item: unknown): string;
|
1316
1355
|
resolveValue<T extends BaseData>(value: Infer<T>, schema: T): string;
|
1317
1356
|
transpileFn(fn: string): {
|
1318
|
-
argNames:
|
1357
|
+
argNames: ArgNames;
|
1319
1358
|
body: Block;
|
1320
1359
|
externalNames: string[];
|
1321
1360
|
};
|
@@ -1344,36 +1383,36 @@ type BindableBufferUsage = 'uniform' | 'readonly' | 'mutable';
|
|
1344
1383
|
/**
|
1345
1384
|
* Describes a function signature (its arguments and return type)
|
1346
1385
|
*/
|
1347
|
-
|
1386
|
+
type TgpuFnShellHeader<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = AnyWgslData | undefined> = {
|
1348
1387
|
readonly argTypes: Args;
|
1349
1388
|
readonly returnType: Return | undefined;
|
1389
|
+
};
|
1390
|
+
/**
|
1391
|
+
* Describes a function signature (its arguments and return type).
|
1392
|
+
* Allows creating tgpu functions by calling this shell
|
1393
|
+
* and passing the implementation (as WGSL string or JS function) as the argument.
|
1394
|
+
*/
|
1395
|
+
type TgpuFnShell<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = AnyWgslData | undefined> = TgpuFnShellHeader<Args, Return> & ((implementation: (...args: Args extends AnyWgslData[] ? InferArgs<Args> : [InferIO<Args>]) => InferReturn<Return>) => TgpuFn<Args, Return>) & ((implementation: string) => TgpuFn<Args, Return>) & {
|
1350
1396
|
/**
|
1351
|
-
*
|
1352
|
-
*/
|
1353
|
-
does(implementation: (...args: InferArgs<Args>) => InferReturn<Return>): TgpuFn<Args, Return>;
|
1354
|
-
/**
|
1355
|
-
* @param implementation
|
1356
|
-
* Raw WGSL function implementation with header and body
|
1357
|
-
* without `fn` keyword and function name
|
1358
|
-
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
1397
|
+
* @deprecated Invoke the shell as a function instead.
|
1359
1398
|
*/
|
1360
|
-
does(implementation:
|
1361
|
-
}
|
1362
|
-
interface TgpuFnBase<Args extends AnyWgslData[], Return extends AnyWgslData | undefined = undefined> extends TgpuNamable, Labelled {
|
1399
|
+
does: ((implementation: (...args: Args extends AnyWgslData[] ? InferArgs<Args> : [InferIO<Args>]) => InferReturn<Return>) => TgpuFn<Args, Return>) & ((implementation: string) => TgpuFn<Args, Return>);
|
1400
|
+
};
|
1401
|
+
interface TgpuFnBase<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = undefined> extends TgpuNamable, Labelled {
|
1363
1402
|
readonly resourceType: 'function';
|
1364
|
-
readonly shell:
|
1403
|
+
readonly shell: TgpuFnShellHeader<Args, Return>;
|
1365
1404
|
readonly '~providing'?: Providing | undefined;
|
1366
1405
|
$uses(dependencyMap: Record<string, unknown>): this;
|
1367
1406
|
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TgpuFn<Args, Return>;
|
1368
1407
|
with<T extends AnyWgslData>(accessor: TgpuAccessor<T>, value: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>): TgpuFn<Args, Return>;
|
1369
1408
|
}
|
1370
|
-
type TgpuFn<Args extends AnyWgslData[] = AnyWgslData[], Return extends AnyWgslData | undefined = AnyWgslData | undefined> = TgpuFnBase<Args, Return> & ((...args: InferArgs<Args>) => InferReturn<Return>) & {
|
1409
|
+
type TgpuFn<Args extends AnyWgslData[] | Record<string, AnyWgslData> = AnyWgslData[], Return extends AnyWgslData | undefined = AnyWgslData | undefined> = TgpuFnBase<Args, Return> & ((...args: Args extends AnyWgslData[] ? InferArgs<Args> : Args extends Record<string, never> ? [] : [InferIO<Args>]) => InferReturn<Return>) & {
|
1371
1410
|
readonly [$internal]: {
|
1372
|
-
implementation: Implementation<InferArgs<Args
|
1411
|
+
implementation: Implementation<Args extends AnyWgslData[] ? InferArgs<Args> : Args extends Record<string, never> ? [] : [InferIO<Args>], InferReturn<Return>>;
|
1373
1412
|
};
|
1374
1413
|
};
|
1375
|
-
declare function fn<Args extends AnyWgslData[] | []>(argTypes: Args, returnType?: undefined): TgpuFnShell<Args, undefined>;
|
1376
|
-
declare function fn<Args extends AnyWgslData[] | [], Return extends AnyWgslData>(argTypes: Args, returnType: Return): TgpuFnShell<Args, Return>;
|
1414
|
+
declare function fn<Args extends AnyWgslData[] | Record<string, AnyWgslData> | []>(argTypes: Args, returnType?: undefined): TgpuFnShell<Args, undefined>;
|
1415
|
+
declare function fn<Args extends AnyWgslData[] | Record<string, AnyWgslData> | [], Return extends AnyWgslData>(argTypes: Args, returnType: Return): TgpuFnShell<Args, Return>;
|
1377
1416
|
declare function isTgpuFn<Args extends AnyWgslData[], Return extends AnyWgslData | undefined = undefined>(value: unknown | TgpuFn<Args, Return>): value is TgpuFn<Args, Return>;
|
1378
1417
|
|
1379
1418
|
interface TgpuResolveOptions {
|
package/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import { A as AnyWgslData, T as TgpuNamable, I as Infer, F as F32, a as F16, b as I32, U as U32, V as Vec2f, c as Vec3f, d as Vec4f, e as Vec2h, f as Vec3h, g as Vec4h, h as Vec2i, i as Vec3i, j as Vec4i, k as Vec2u, l as Vec3u, m as Vec4u, D as Decorated, n as AnyWgslStruct, B as BaseData, L as Location, W as WgslStruct, o as Default, p as UnionToIntersection, q as WgslArray,
|
2
|
-
import { A as AnyAttribute, a as AnyComputeBuiltin, D as Decorate, I as IsBuiltin, H as HasCustomLocation, b as AnyFragmentInputBuiltin, c as AnyFragmentOutputBuiltin, O as OmitBuiltins } from './attributes-
|
1
|
+
import { A as AnyWgslData, T as TgpuNamable, I as Infer, F as F32, a as F16, b as I32, U as U32, V as Vec2f, c as Vec3f, d as Vec4f, e as Vec2h, f as Vec3h, g as Vec4h, h as Vec2i, i as Vec3i, j as Vec4i, k as Vec2u, l as Vec3u, m as Vec4u, D as Decorated, n as AnyWgslStruct, $ as $repr, B as BaseData, L as Location, W as WgslStruct, o as Default, p as UnionToIntersection, q as WgslArray, O as OmitProps, P as Prettify, M as Mutable, r as WgslTypeLiteral, s as InferPartial, t as MemIdentity, u as InferGPU, v as AbstractInt, w as AbstractFloat, x as AnyVecInstance, y as AnyMatInstance } from './wgslTypes-Bh2dG5qv.js';
|
2
|
+
import { A as AnyAttribute, a as AnyComputeBuiltin, D as Decorate, I as IsBuiltin, H as HasCustomLocation, b as AnyFragmentInputBuiltin, c as AnyFragmentOutputBuiltin, O as OmitBuiltins, d as Disarray, U as Unstruct, V as VertexFormat, T as TgpuVertexAttrib, K as KindToDefaultFormatMap, e as KindToAcceptedAttribMap, f as AnyData } from './attributes-CAsvE5Z9.js';
|
3
3
|
import * as smol from 'tinyest';
|
4
|
-
import { Block } from 'tinyest';
|
4
|
+
import { ArgNames, Block } from 'tinyest';
|
5
5
|
|
6
6
|
declare const $internal: unique symbol;
|
7
7
|
|
@@ -36,7 +36,7 @@ declare function declare(declaration: string): TgpuDeclare;
|
|
36
36
|
* Information extracted from transpiling a JS function.
|
37
37
|
*/
|
38
38
|
type TranspilationResult = {
|
39
|
-
argNames:
|
39
|
+
argNames: smol.ArgNames;
|
40
40
|
body: smol.Block;
|
41
41
|
/**
|
42
42
|
* All identifiers found in the function code that are not declared in the
|
@@ -63,24 +63,40 @@ type InferIO<T> = T extends {
|
|
63
63
|
} : T;
|
64
64
|
|
65
65
|
/**
|
66
|
-
* Describes a compute entry function signature (its arguments and
|
66
|
+
* Describes a compute entry function signature (its arguments, return type and workgroup size)
|
67
67
|
*/
|
68
|
-
|
68
|
+
type TgpuComputeFnShellHeader<ComputeIn extends Record<string, AnyComputeBuiltin>> = {
|
69
69
|
readonly argTypes: [AnyWgslStruct];
|
70
70
|
readonly returnType: undefined;
|
71
71
|
readonly workgroupSize: [number, number, number];
|
72
|
+
};
|
73
|
+
/**
|
74
|
+
* Describes a compute entry function signature (its arguments, return type and workgroup size).
|
75
|
+
* Allows creating tgpu compute functions by calling this shell
|
76
|
+
* and passing the implementation (as WGSL string or JS function) as the argument.
|
77
|
+
*/
|
78
|
+
type TgpuComputeFnShell<ComputeIn extends Record<string, AnyComputeBuiltin>> = TgpuComputeFnShellHeader<ComputeIn> /**
|
79
|
+
* Creates a type-safe implementation of this signature
|
80
|
+
*/ & ((implementation: (input: InferIO<ComputeIn>) => undefined) => TgpuComputeFn<ComputeIn>) &
|
81
|
+
/**
|
82
|
+
* @param implementation
|
83
|
+
* Raw WGSL function implementation with header and body
|
84
|
+
* without `fn` keyword and function name
|
85
|
+
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
86
|
+
*/
|
87
|
+
((implementation: string) => TgpuComputeFn<ComputeIn>) & {
|
72
88
|
/**
|
73
|
-
*
|
89
|
+
* @deprecated Invoke the shell as a function instead.
|
74
90
|
*/
|
75
|
-
does(implementation: (input: InferIO<ComputeIn>) => undefined)
|
91
|
+
does: ((implementation: (input: InferIO<ComputeIn>) => undefined) => TgpuComputeFn<ComputeIn>) &
|
76
92
|
/**
|
77
93
|
* @param implementation
|
78
94
|
* Raw WGSL function implementation with header and body
|
79
95
|
* without `fn` keyword and function name
|
80
96
|
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
81
97
|
*/
|
82
|
-
|
83
|
-
}
|
98
|
+
((implementation: string) => TgpuComputeFn<ComputeIn>);
|
99
|
+
};
|
84
100
|
interface TgpuComputeFn<ComputeIn extends Record<string, AnyComputeBuiltin> = Record<string, AnyComputeBuiltin>> extends TgpuNamable {
|
85
101
|
readonly shell: TgpuComputeFnShell<ComputeIn>;
|
86
102
|
$uses(dependencyMap: Record<string, unknown>): this;
|
@@ -132,7 +148,7 @@ declare class StrictNameRegistry implements NameRegistry {
|
|
132
148
|
|
133
149
|
interface TgpuSlot<T> extends TgpuNamable, Labelled {
|
134
150
|
readonly resourceType: 'slot';
|
135
|
-
|
151
|
+
[$repr]: Infer<T>;
|
136
152
|
readonly defaultValue: T | undefined;
|
137
153
|
/**
|
138
154
|
* Used to determine if code generated using either value `a` or `b` in place
|
@@ -144,7 +160,7 @@ interface TgpuSlot<T> extends TgpuNamable, Labelled {
|
|
144
160
|
interface TgpuDerived<T> {
|
145
161
|
readonly resourceType: 'derived';
|
146
162
|
readonly value: Infer<T>;
|
147
|
-
|
163
|
+
[$repr]: Infer<T>;
|
148
164
|
readonly '~providing'?: Providing | undefined;
|
149
165
|
with<TValue>(slot: TgpuSlot<TValue>, value: Eventual<TValue>): TgpuDerived<T>;
|
150
166
|
/**
|
@@ -154,7 +170,7 @@ interface TgpuDerived<T> {
|
|
154
170
|
}
|
155
171
|
interface TgpuAccessor<T extends AnyWgslData = AnyWgslData> extends TgpuNamable, Labelled {
|
156
172
|
readonly resourceType: 'accessor';
|
157
|
-
|
173
|
+
[$repr]: Infer<T>;
|
158
174
|
readonly schema: T;
|
159
175
|
readonly defaultValue: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T> | undefined;
|
160
176
|
readonly slot: TgpuSlot<TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>>;
|
@@ -187,26 +203,42 @@ type IOLayoutToSchema<T extends IOLayout> = T extends BaseData ? Decorate<T, Loc
|
|
187
203
|
type FragmentOutConstrained = Vec4f | Decorated<Vec4f, [Location<number>]> | AnyFragmentOutputBuiltin | IORecord<Vec4f | Decorated<Vec4f, [Location<number>]> | AnyFragmentOutputBuiltin>;
|
188
204
|
type FragmentInConstrained = IORecord<BaseIOData | Decorated<BaseIOData, AnyAttribute<never>[]> | AnyFragmentInputBuiltin>;
|
189
205
|
/**
|
190
|
-
* Describes a fragment entry function signature (its arguments
|
206
|
+
* Describes a fragment entry function signature (its arguments, return type and targets)
|
191
207
|
*/
|
192
|
-
|
208
|
+
type TgpuFragmentFnShellHeader<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = {
|
193
209
|
readonly argTypes: [AnyWgslStruct];
|
194
210
|
readonly targets: FragmentOut;
|
195
211
|
readonly returnType: FragmentOut;
|
212
|
+
};
|
213
|
+
/**
|
214
|
+
* Describes a fragment entry function signature (its arguments, return type and targets).
|
215
|
+
* Allows creating tgpu fragment functions by calling this shell
|
216
|
+
* and passing the implementation (as WGSL string or JS function) as the argument.
|
217
|
+
*/
|
218
|
+
type TgpuFragmentFnShell<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = TgpuFragmentFnShellHeader<FragmentIn, FragmentOut> /**
|
219
|
+
* Creates a type-safe implementation of this signature
|
220
|
+
*/ & ((implementation: (input: InferIO<FragmentIn>) => InferIO<FragmentOut>) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) &
|
221
|
+
/**
|
222
|
+
* @param implementation
|
223
|
+
* Raw WGSL function implementation with header and body
|
224
|
+
* without `fn` keyword and function name
|
225
|
+
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
226
|
+
*/
|
227
|
+
((implementation: string) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) & {
|
196
228
|
/**
|
197
|
-
*
|
229
|
+
* @deprecated Invoke the shell as a function instead.
|
198
230
|
*/
|
199
|
-
does(implementation: (input: InferIO<FragmentIn>) => InferIO<FragmentOut>)
|
231
|
+
does: ((implementation: (input: InferIO<FragmentIn>) => InferIO<FragmentOut>) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) &
|
200
232
|
/**
|
201
233
|
* @param implementation
|
202
234
|
* Raw WGSL function implementation with header and body
|
203
235
|
* without `fn` keyword and function name
|
204
236
|
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
205
237
|
*/
|
206
|
-
|
207
|
-
}
|
238
|
+
((implementation: string) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>);
|
239
|
+
};
|
208
240
|
interface TgpuFragmentFn<Varying extends FragmentInConstrained = FragmentInConstrained, Output extends FragmentOutConstrained = FragmentOutConstrained> extends TgpuNamable {
|
209
|
-
readonly shell:
|
241
|
+
readonly shell: TgpuFragmentFnShellHeader<Varying, Output>;
|
210
242
|
readonly outputType: IOLayoutToSchema<Output>;
|
211
243
|
$uses(dependencyMap: Record<string, unknown>): this;
|
212
244
|
}
|
@@ -219,26 +251,26 @@ declare function fragmentFn<FragmentIn extends FragmentInConstrained, FragmentOu
|
|
219
251
|
}): TgpuFragmentFnShell<FragmentIn, FragmentOut>;
|
220
252
|
|
221
253
|
/**
|
222
|
-
* Describes a vertex entry function signature (its arguments
|
254
|
+
* Describes a vertex entry function signature (its arguments, return type and attributes)
|
223
255
|
*/
|
224
|
-
|
256
|
+
type TgpuVertexFnShellHeader<VertexIn extends IOLayout, VertexOut extends IOLayout> = {
|
225
257
|
readonly argTypes: [AnyWgslStruct];
|
226
258
|
readonly returnType: VertexOut;
|
227
259
|
readonly attributes: [VertexIn];
|
260
|
+
};
|
261
|
+
/**
|
262
|
+
* Describes a vertex entry function signature (its arguments, return type and attributes).
|
263
|
+
* Allows creating tgpu vertex functions by calling this shell
|
264
|
+
* and passing the implementation (as WGSL string or JS function) as the argument.
|
265
|
+
*/
|
266
|
+
type TgpuVertexFnShell<VertexIn extends IOLayout, VertexOut extends IOLayout> = TgpuVertexFnShellHeader<VertexIn, VertexOut> & ((implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & ((implementation: string) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & {
|
228
267
|
/**
|
229
|
-
*
|
230
|
-
*/
|
231
|
-
does(implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>): TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>;
|
232
|
-
/**
|
233
|
-
* @param implementation
|
234
|
-
* Raw WGSL function implementation with header and body
|
235
|
-
* without `fn` keyword and function name
|
236
|
-
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
268
|
+
* @deprecated Invoke the shell as a function instead.
|
237
269
|
*/
|
238
|
-
does(implementation:
|
239
|
-
}
|
270
|
+
does: ((implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & ((implementation: string) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>);
|
271
|
+
};
|
240
272
|
interface TgpuVertexFn<VertexIn extends IOLayout = IOLayout, VertexOut extends IOLayout = IOLayout> extends TgpuNamable {
|
241
|
-
readonly shell:
|
273
|
+
readonly shell: TgpuVertexFnShellHeader<VertexIn, VertexOut>;
|
242
274
|
readonly outputType: IOLayoutToSchema<VertexOut>;
|
243
275
|
readonly inputType: IOLayoutToSchema<VertexIn>;
|
244
276
|
$uses(dependencyMap: Record<string, unknown>): this;
|
@@ -1126,6 +1158,12 @@ interface TgpuBindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | n
|
|
1126
1158
|
readonly bound: {
|
1127
1159
|
[K in keyof Entries]: BindLayoutEntry<Entries[K]>;
|
1128
1160
|
};
|
1161
|
+
readonly value: {
|
1162
|
+
[K in keyof Entries]: InferLayoutEntry<Entries[K]>;
|
1163
|
+
};
|
1164
|
+
readonly $: {
|
1165
|
+
[K in keyof Entries]: InferLayoutEntry<Entries[K]>;
|
1166
|
+
};
|
1129
1167
|
/**
|
1130
1168
|
* An explicit numeric index assigned to this bind group layout. If undefined, a unique
|
1131
1169
|
* index is assigned automatically during resolution. This can be changed with the
|
@@ -1177,7 +1215,8 @@ type GetStorageTextureRestriction<T extends TgpuLayoutStorageTexture> = Default<
|
|
1177
1215
|
dimension: Dimension;
|
1178
1216
|
} : never;
|
1179
1217
|
type LayoutEntryToInput<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? (TgpuBuffer<UnwrapRuntimeConstructor<T['uniform']>> & UniformFlag) | GPUBuffer : T extends TgpuLayoutStorage ? (TgpuBuffer<UnwrapRuntimeConstructor<T['storage']>> & StorageFlag) | GPUBuffer : T extends TgpuLayoutSampler ? TgpuSampler | GPUSampler : T extends TgpuLayoutComparisonSampler ? TgpuComparisonSampler | GPUSampler : T extends TgpuLayoutTexture ? GPUTextureView | (Sampled & TgpuTexture<Prettify<TextureProps & GetTextureRestriction<T>>>) | TgpuSampledTexture<Default<T['viewDimension'], '2d'>, ChannelFormatToSchema[T['texture']]> : T extends TgpuLayoutStorageTexture ? GPUTextureView | (StorageFlag & TgpuTexture<Prettify<TextureProps & GetStorageTextureRestriction<T>>>) | StorageTextureUsageForEntry<T> : T extends TgpuLayoutExternalTexture ? GPUExternalTexture : never;
|
1180
|
-
type BindLayoutEntry<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? TgpuBufferUniform<
|
1218
|
+
type BindLayoutEntry<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? TgpuBufferUniform<T['uniform']> : T extends TgpuLayoutStorage ? StorageUsageForEntry<T> : T extends TgpuLayoutSampler ? TgpuSampler : T extends TgpuLayoutComparisonSampler ? TgpuComparisonSampler : T extends TgpuLayoutTexture ? TgpuSampledTexture<Default<GetDimension<T['viewDimension']>, '2d'>, ChannelFormatToSchema[T['texture']]> : T extends TgpuLayoutStorageTexture ? StorageTextureUsageForEntry<T> : never;
|
1219
|
+
type InferLayoutEntry<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? Infer<T['uniform']> : T extends TgpuLayoutStorage ? Infer<UnwrapRuntimeConstructor<T['storage']>> : T extends TgpuLayoutSampler ? TgpuSampler : T extends TgpuLayoutComparisonSampler ? TgpuComparisonSampler : T extends TgpuLayoutTexture ? TgpuSampledTexture<Default<GetDimension<T['viewDimension']>, '2d'>, ChannelFormatToSchema[T['texture']]> : T extends TgpuLayoutStorageTexture ? StorageTextureUsageForEntry<T> : never;
|
1181
1220
|
type TgpuBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>> = {
|
1182
1221
|
readonly resourceType: 'bind-group';
|
1183
1222
|
readonly layout: TgpuBindGroupLayout<Entries>;
|
@@ -1188,7 +1227,7 @@ declare function bindGroupLayout<Entries extends Record<string, TgpuLayoutEntry
|
|
1188
1227
|
interface TgpuBufferUsage<TData extends BaseData = BaseData, TUsage extends BindableBufferUsage = BindableBufferUsage> {
|
1189
1228
|
readonly resourceType: 'buffer-usage';
|
1190
1229
|
readonly usage: TUsage;
|
1191
|
-
readonly
|
1230
|
+
readonly [$repr]: Infer<TData>;
|
1192
1231
|
value: InferGPU<TData>;
|
1193
1232
|
readonly [$internal]: {
|
1194
1233
|
readonly dataType: TData;
|
@@ -1315,7 +1354,7 @@ interface ResolutionCtx {
|
|
1315
1354
|
resolve(item: unknown): string;
|
1316
1355
|
resolveValue<T extends BaseData>(value: Infer<T>, schema: T): string;
|
1317
1356
|
transpileFn(fn: string): {
|
1318
|
-
argNames:
|
1357
|
+
argNames: ArgNames;
|
1319
1358
|
body: Block;
|
1320
1359
|
externalNames: string[];
|
1321
1360
|
};
|
@@ -1344,36 +1383,36 @@ type BindableBufferUsage = 'uniform' | 'readonly' | 'mutable';
|
|
1344
1383
|
/**
|
1345
1384
|
* Describes a function signature (its arguments and return type)
|
1346
1385
|
*/
|
1347
|
-
|
1386
|
+
type TgpuFnShellHeader<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = AnyWgslData | undefined> = {
|
1348
1387
|
readonly argTypes: Args;
|
1349
1388
|
readonly returnType: Return | undefined;
|
1389
|
+
};
|
1390
|
+
/**
|
1391
|
+
* Describes a function signature (its arguments and return type).
|
1392
|
+
* Allows creating tgpu functions by calling this shell
|
1393
|
+
* and passing the implementation (as WGSL string or JS function) as the argument.
|
1394
|
+
*/
|
1395
|
+
type TgpuFnShell<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = AnyWgslData | undefined> = TgpuFnShellHeader<Args, Return> & ((implementation: (...args: Args extends AnyWgslData[] ? InferArgs<Args> : [InferIO<Args>]) => InferReturn<Return>) => TgpuFn<Args, Return>) & ((implementation: string) => TgpuFn<Args, Return>) & {
|
1350
1396
|
/**
|
1351
|
-
*
|
1352
|
-
*/
|
1353
|
-
does(implementation: (...args: InferArgs<Args>) => InferReturn<Return>): TgpuFn<Args, Return>;
|
1354
|
-
/**
|
1355
|
-
* @param implementation
|
1356
|
-
* Raw WGSL function implementation with header and body
|
1357
|
-
* without `fn` keyword and function name
|
1358
|
-
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
1397
|
+
* @deprecated Invoke the shell as a function instead.
|
1359
1398
|
*/
|
1360
|
-
does(implementation:
|
1361
|
-
}
|
1362
|
-
interface TgpuFnBase<Args extends AnyWgslData[], Return extends AnyWgslData | undefined = undefined> extends TgpuNamable, Labelled {
|
1399
|
+
does: ((implementation: (...args: Args extends AnyWgslData[] ? InferArgs<Args> : [InferIO<Args>]) => InferReturn<Return>) => TgpuFn<Args, Return>) & ((implementation: string) => TgpuFn<Args, Return>);
|
1400
|
+
};
|
1401
|
+
interface TgpuFnBase<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = undefined> extends TgpuNamable, Labelled {
|
1363
1402
|
readonly resourceType: 'function';
|
1364
|
-
readonly shell:
|
1403
|
+
readonly shell: TgpuFnShellHeader<Args, Return>;
|
1365
1404
|
readonly '~providing'?: Providing | undefined;
|
1366
1405
|
$uses(dependencyMap: Record<string, unknown>): this;
|
1367
1406
|
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TgpuFn<Args, Return>;
|
1368
1407
|
with<T extends AnyWgslData>(accessor: TgpuAccessor<T>, value: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>): TgpuFn<Args, Return>;
|
1369
1408
|
}
|
1370
|
-
type TgpuFn<Args extends AnyWgslData[] = AnyWgslData[], Return extends AnyWgslData | undefined = AnyWgslData | undefined> = TgpuFnBase<Args, Return> & ((...args: InferArgs<Args>) => InferReturn<Return>) & {
|
1409
|
+
type TgpuFn<Args extends AnyWgslData[] | Record<string, AnyWgslData> = AnyWgslData[], Return extends AnyWgslData | undefined = AnyWgslData | undefined> = TgpuFnBase<Args, Return> & ((...args: Args extends AnyWgslData[] ? InferArgs<Args> : Args extends Record<string, never> ? [] : [InferIO<Args>]) => InferReturn<Return>) & {
|
1371
1410
|
readonly [$internal]: {
|
1372
|
-
implementation: Implementation<InferArgs<Args
|
1411
|
+
implementation: Implementation<Args extends AnyWgslData[] ? InferArgs<Args> : Args extends Record<string, never> ? [] : [InferIO<Args>], InferReturn<Return>>;
|
1373
1412
|
};
|
1374
1413
|
};
|
1375
|
-
declare function fn<Args extends AnyWgslData[] | []>(argTypes: Args, returnType?: undefined): TgpuFnShell<Args, undefined>;
|
1376
|
-
declare function fn<Args extends AnyWgslData[] | [], Return extends AnyWgslData>(argTypes: Args, returnType: Return): TgpuFnShell<Args, Return>;
|
1414
|
+
declare function fn<Args extends AnyWgslData[] | Record<string, AnyWgslData> | []>(argTypes: Args, returnType?: undefined): TgpuFnShell<Args, undefined>;
|
1415
|
+
declare function fn<Args extends AnyWgslData[] | Record<string, AnyWgslData> | [], Return extends AnyWgslData>(argTypes: Args, returnType: Return): TgpuFnShell<Args, Return>;
|
1377
1416
|
declare function isTgpuFn<Args extends AnyWgslData[], Return extends AnyWgslData | undefined = undefined>(value: unknown | TgpuFn<Args, Return>): value is TgpuFn<Args, Return>;
|
1378
1417
|
|
1379
1418
|
interface TgpuResolveOptions {
|