typegpu 0.5.6 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +11 -12
- package/README.md +13 -5
- package/chunk-5RYM4COI.js +4 -0
- package/chunk-5RYM4COI.js.map +1 -0
- package/chunk-FHOQ6WZE.cjs +2 -0
- package/chunk-FHOQ6WZE.cjs.map +1 -0
- package/chunk-ODKBWWHU.cjs +4 -0
- package/chunk-ODKBWWHU.cjs.map +1 -0
- package/chunk-SMTSXYNG.js +2 -0
- package/chunk-SMTSXYNG.js.map +1 -0
- package/data/index.cjs +1 -1
- package/data/index.cjs.map +1 -1
- package/data/index.d.cts +5 -23
- package/data/index.d.ts +5 -23
- package/data/index.js +1 -1
- package/index.cjs +23 -19
- package/index.cjs.map +1 -1
- package/index.d.cts +4 -1045
- package/index.d.ts +4 -1045
- package/index.js +23 -19
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/std/index.cjs +1 -1
- package/std/index.cjs.map +1 -1
- package/std/index.d.cts +53 -4
- package/std/index.d.ts +53 -4
- package/std/index.js +1 -1
- package/std/index.js.map +1 -1
- package/tgpuComputeFn-DH8_PcIR.d.cts +3042 -0
- package/tgpuComputeFn-DH8_PcIR.d.ts +3042 -0
- package/attributes-B90UjSYb.d.ts +0 -159
- package/attributes-zljQ-iA7.d.cts +0 -159
- package/chunk-KJHEEZQT.js +0 -4
- package/chunk-KJHEEZQT.js.map +0 -1
- package/chunk-LB4TSIPN.cjs +0 -2
- package/chunk-LB4TSIPN.cjs.map +0 -1
- package/chunk-VTUUXD6H.cjs +0 -4
- package/chunk-VTUUXD6H.cjs.map +0 -1
- package/chunk-YVK55BVR.js +0 -2
- package/chunk-YVK55BVR.js.map +0 -1
- package/dataTypes-6k4EJeol.d.cts +0 -1405
- package/dataTypes-6k4EJeol.d.ts +0 -1405
- package/sampler-ByLNpSxj.d.ts +0 -369
- package/sampler-NRTAYTIW.d.cts +0 -369
package/index.d.cts
CHANGED
@@ -1,1047 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
import
|
4
|
-
import { ArgNames, Block } from 'tinyest';
|
5
|
-
import { T as TgpuTexture, R as Render, a as TgpuReadonlyTexture, b as TgpuWriteonlyTexture, c as TgpuMutableTexture, d as TgpuSampledTexture, e as TgpuSampler, f as TgpuComparisonSampler, S as StorageFlag, g as StorageTextureTexelFormat, h as StorageTextureDimension, C as ChannelFormatToSchema, V as ViewDimensionToDimension, i as TexelFormatToDataType, j as Sampled, k as TextureProps, l as ChannelTypeToLegalFormats, m as SampleTypeToStringChannelType, n as TgpuAnyTextureView, s as sampler, o as comparisonSampler } from './sampler-NRTAYTIW.cjs';
|
6
|
-
export { y as Storage, q as isComparisonSampler, r as isSampledTextureView, p as isSampler, t as isStorageTextureView, u as isTexture, v as isUsableAsRender, w as isUsableAsSampled, x as isUsableAsStorage } from './sampler-NRTAYTIW.cjs';
|
7
|
-
|
8
|
-
interface TgpuConst<TDataType extends AnyWgslData = AnyWgslData> extends TgpuNamable {
|
9
|
-
readonly value: Infer<TDataType>;
|
10
|
-
readonly [$internal]: {
|
11
|
-
readonly dataType: TDataType;
|
12
|
-
};
|
13
|
-
}
|
14
|
-
/**
|
15
|
-
* Creates a module constant with specified value.
|
16
|
-
*/
|
17
|
-
declare function constant<TDataType extends AnyWgslData>(dataType: TDataType, value: Infer<TDataType>): TgpuConst<TDataType>;
|
18
|
-
|
19
|
-
/**
|
20
|
-
* Extra declaration that shall be included in final WGSL code,
|
21
|
-
* when resolving objects that use it.
|
22
|
-
*/
|
23
|
-
interface TgpuDeclare {
|
24
|
-
$uses(dependencyMap: Record<string, unknown>): this;
|
25
|
-
}
|
26
|
-
/**
|
27
|
-
* Allows defining extra declarations that shall be included in the final WGSL code,
|
28
|
-
* when resolving objects that use them.
|
29
|
-
*
|
30
|
-
* Using this API is generally discouraged, as it shouldn't be necessary in any common scenario.
|
31
|
-
* It was developed to ensure full compatibility of TypeGPU programs with current and future versions of WGSL.
|
32
|
-
*/
|
33
|
-
declare function declare(declaration: string): TgpuDeclare;
|
34
|
-
|
35
|
-
/**
|
36
|
-
* Information extracted from transpiling a JS function.
|
37
|
-
*/
|
38
|
-
type TranspilationResult = {
|
39
|
-
argNames: tinyest.ArgNames;
|
40
|
-
body: tinyest.Block;
|
41
|
-
/**
|
42
|
-
* All identifiers found in the function code that are not declared in the
|
43
|
-
* function itself, or in the block that is accessing that identifier.
|
44
|
-
*/
|
45
|
-
externalNames: string[];
|
46
|
-
};
|
47
|
-
type InferArgs<T extends unknown[]> = {
|
48
|
-
[Idx in keyof T]: Infer<T[Idx]>;
|
49
|
-
};
|
50
|
-
type InferReturn<T> = T extends undefined ? void : Infer<T>;
|
51
|
-
type JsImplementation<Args extends unknown[] | Record<string, unknown> = unknown[] | Record<string, unknown>, Return = unknown> = (...args: Args extends unknown[] ? InferArgs<Args> : Args extends Record<string, never> ? [] : [InferIO<Args>]) => InferReturn<Return>;
|
52
|
-
type Implementation<Args extends unknown[] | Record<string, unknown> = unknown[] | Record<string, unknown>, Return = unknown> = string | JsImplementation<Args, Return>;
|
53
|
-
type BaseIOData = F32 | F16 | I32 | U32 | Vec2f | Vec3f | Vec4f | Vec2h | Vec3h | Vec4h | Vec2i | Vec3i | Vec4i | Vec2u | Vec3u | Vec4u;
|
54
|
-
type IOData = BaseIOData | Decorated<BaseIOData, AnyAttribute[]>;
|
55
|
-
type IORecord<TElementType extends IOData = IOData> = Record<string, TElementType>;
|
56
|
-
/**
|
57
|
-
* Used for I/O definitions of entry functions.
|
58
|
-
*/
|
59
|
-
type IOLayout<TElementType extends IOData = IOData> = TElementType | IORecord<TElementType>;
|
60
|
-
type InferIO<T> = T extends {
|
61
|
-
type: string;
|
62
|
-
} ? Infer<T> : T extends Record<string, unknown> ? {
|
63
|
-
[K in keyof T]: Infer<T[K]>;
|
64
|
-
} : T;
|
65
|
-
|
66
|
-
/**
|
67
|
-
* Describes a compute entry function signature (its arguments, return type and workgroup size)
|
68
|
-
*/
|
69
|
-
type TgpuComputeFnShellHeader<ComputeIn extends Record<string, AnyComputeBuiltin>> = {
|
70
|
-
readonly argTypes: [AnyWgslStruct] | [];
|
71
|
-
readonly returnType: undefined;
|
72
|
-
readonly workgroupSize: [number, number, number];
|
73
|
-
readonly isEntry: true;
|
74
|
-
};
|
75
|
-
/**
|
76
|
-
* Describes a compute entry function signature (its arguments, return type and workgroup size).
|
77
|
-
* Allows creating tgpu compute functions by calling this shell
|
78
|
-
* and passing the implementation (as WGSL string or JS function) as the argument.
|
79
|
-
*/
|
80
|
-
type TgpuComputeFnShell<ComputeIn extends Record<string, AnyComputeBuiltin>> = TgpuComputeFnShellHeader<ComputeIn> /**
|
81
|
-
* Creates a type-safe implementation of this signature
|
82
|
-
*/ & ((implementation: (input: InferIO<ComputeIn>) => undefined) => TgpuComputeFn<ComputeIn>) &
|
83
|
-
/**
|
84
|
-
* @param implementation
|
85
|
-
* Raw WGSL function implementation with header and body
|
86
|
-
* without `fn` keyword and function name
|
87
|
-
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
88
|
-
*/
|
89
|
-
((implementation: string) => TgpuComputeFn<ComputeIn>) & ((strings: TemplateStringsArray, ...values: unknown[]) => TgpuComputeFn<ComputeIn>) & {
|
90
|
-
/**
|
91
|
-
* @deprecated Invoke the shell as a function instead.
|
92
|
-
*/
|
93
|
-
does: ((implementation: (input: InferIO<ComputeIn>) => undefined) => TgpuComputeFn<ComputeIn>) &
|
94
|
-
/**
|
95
|
-
* @param implementation
|
96
|
-
* Raw WGSL function implementation with header and body
|
97
|
-
* without `fn` keyword and function name
|
98
|
-
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
99
|
-
*/
|
100
|
-
((implementation: string) => TgpuComputeFn<ComputeIn>);
|
101
|
-
};
|
102
|
-
interface TgpuComputeFn<ComputeIn extends Record<string, AnyComputeBuiltin> = Record<string, AnyComputeBuiltin>> extends TgpuNamable {
|
103
|
-
readonly shell: TgpuComputeFnShell<ComputeIn>;
|
104
|
-
$uses(dependencyMap: Record<string, unknown>): this;
|
105
|
-
}
|
106
|
-
declare function computeFn(options: {
|
107
|
-
workgroupSize: number[];
|
108
|
-
}): TgpuComputeFnShell<{}>;
|
109
|
-
declare function computeFn<ComputeIn extends Record<string, AnyComputeBuiltin>>(options: {
|
110
|
-
in: ComputeIn;
|
111
|
-
workgroupSize: number[];
|
112
|
-
}): TgpuComputeFnShell<ComputeIn>;
|
113
|
-
|
114
|
-
/**
|
115
|
-
* Used to transpile JS resources into tinyest on demand.
|
116
|
-
*/
|
117
|
-
interface JitTranspiler {
|
118
|
-
transpileFn(rawJs: string): TranspilationResult;
|
119
|
-
}
|
120
|
-
|
121
|
-
interface NameRegistry {
|
122
|
-
/**
|
123
|
-
* Creates a valid WGSL identifier, each guaranteed to be unique
|
124
|
-
* in the lifetime of a single resolution process.
|
125
|
-
* @param primer Used in the generation process, makes the identifier more recognizable.
|
126
|
-
*/
|
127
|
-
makeUnique(primer?: string): string;
|
128
|
-
}
|
129
|
-
declare class RandomNameRegistry implements NameRegistry {
|
130
|
-
private lastUniqueId;
|
131
|
-
makeUnique(primer?: string | undefined): string;
|
132
|
-
}
|
133
|
-
declare class StrictNameRegistry implements NameRegistry {
|
134
|
-
/**
|
135
|
-
* Allows to provide a good fallback for instances of the
|
136
|
-
* same function that are bound to different slot values.
|
137
|
-
*/
|
138
|
-
private readonly _usedNames;
|
139
|
-
makeUnique(primer?: string | undefined): string;
|
140
|
-
}
|
141
|
-
|
142
|
-
interface TgpuSlot<T> extends TgpuNamable, Labelled {
|
143
|
-
readonly resourceType: 'slot';
|
144
|
-
[$repr]: Infer<T>;
|
145
|
-
readonly defaultValue: T | undefined;
|
146
|
-
/**
|
147
|
-
* Used to determine if code generated using either value `a` or `b` in place
|
148
|
-
* of the slot will be equivalent. Defaults to `Object.is`.
|
149
|
-
*/
|
150
|
-
areEqual(a: T, b: T): boolean;
|
151
|
-
readonly value: Infer<T>;
|
152
|
-
}
|
153
|
-
interface TgpuDerived<T> {
|
154
|
-
readonly resourceType: 'derived';
|
155
|
-
readonly value: Infer<T>;
|
156
|
-
[$repr]: Infer<T>;
|
157
|
-
readonly '~providing'?: Providing | undefined;
|
158
|
-
with<TValue>(slot: TgpuSlot<TValue>, value: Eventual<TValue>): TgpuDerived<T>;
|
159
|
-
/**
|
160
|
-
* @internal
|
161
|
-
*/
|
162
|
-
'~compute'(): T;
|
163
|
-
}
|
164
|
-
interface TgpuAccessor<T extends AnyWgslData = AnyWgslData> extends TgpuNamable, Labelled {
|
165
|
-
readonly resourceType: 'accessor';
|
166
|
-
[$repr]: Infer<T>;
|
167
|
-
readonly schema: T;
|
168
|
-
readonly defaultValue: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T> | undefined;
|
169
|
-
readonly slot: TgpuSlot<TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>>;
|
170
|
-
readonly value: Infer<T>;
|
171
|
-
}
|
172
|
-
/**
|
173
|
-
* Represents a value that is available at resolution time.
|
174
|
-
*/
|
175
|
-
type Eventual<T> = T | TgpuSlot<T> | TgpuDerived<T>;
|
176
|
-
type SlotValuePair<T = unknown> = [TgpuSlot<T>, T];
|
177
|
-
type Providing = {
|
178
|
-
inner: unknown;
|
179
|
-
pairs: SlotValuePair[];
|
180
|
-
};
|
181
|
-
declare function isSlot<T>(value: unknown | TgpuSlot<T>): value is TgpuSlot<T>;
|
182
|
-
declare function isDerived<T extends TgpuDerived<unknown>>(value: T | unknown): value is T;
|
183
|
-
|
184
|
-
interface TgpuComputePipeline extends TgpuNamable {
|
185
|
-
readonly resourceType: 'compute-pipeline';
|
186
|
-
readonly label: string | undefined;
|
187
|
-
with(bindGroupLayout: TgpuBindGroupLayout, bindGroup: TgpuBindGroup): TgpuComputePipeline;
|
188
|
-
dispatchWorkgroups(x: number, y?: number | undefined, z?: number | undefined): void;
|
189
|
-
}
|
190
|
-
|
191
|
-
type WithLocations<T extends IORecord> = {
|
192
|
-
[Key in keyof T]: IsBuiltin<T[Key]> extends true ? T[Key] : HasCustomLocation<T[Key]> extends true ? T[Key] : Decorate<T[Key], Location<number>>;
|
193
|
-
};
|
194
|
-
type IOLayoutToSchema<T extends IOLayout> = T extends BaseData ? Decorate<T, Location<0>> : T extends IORecord ? WgslStruct<WithLocations<T>> : never;
|
195
|
-
|
196
|
-
type FragmentOutConstrained = Vec4f | Decorated<Vec4f, [Location<number>]> | AnyFragmentOutputBuiltin | IORecord<Vec4f | Decorated<Vec4f, [Location<number>]> | AnyFragmentOutputBuiltin>;
|
197
|
-
type FragmentInConstrained = IORecord<BaseIOData | Decorated<BaseIOData, AnyAttribute<never>[]> | AnyFragmentInputBuiltin>;
|
198
|
-
/**
|
199
|
-
* Describes a fragment entry function signature (its arguments, return type and targets)
|
200
|
-
*/
|
201
|
-
type TgpuFragmentFnShellHeader<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = {
|
202
|
-
readonly argTypes: [AnyWgslStruct] | [];
|
203
|
-
readonly targets: FragmentOut;
|
204
|
-
readonly returnType: FragmentOut;
|
205
|
-
readonly isEntry: true;
|
206
|
-
};
|
207
|
-
/**
|
208
|
-
* Describes a fragment entry function signature (its arguments, return type and targets).
|
209
|
-
* Allows creating tgpu fragment functions by calling this shell
|
210
|
-
* and passing the implementation (as WGSL string or JS function) as the argument.
|
211
|
-
*/
|
212
|
-
type TgpuFragmentFnShell<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = TgpuFragmentFnShellHeader<FragmentIn, FragmentOut> /**
|
213
|
-
* Creates a type-safe implementation of this signature
|
214
|
-
*/ & ((implementation: (input: InferIO<FragmentIn>) => InferIO<FragmentOut>) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) &
|
215
|
-
/**
|
216
|
-
* @param implementation
|
217
|
-
* Raw WGSL function implementation with header and body
|
218
|
-
* without `fn` keyword and function name
|
219
|
-
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
220
|
-
*/
|
221
|
-
((implementation: string) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) & ((strings: TemplateStringsArray, ...values: unknown[]) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) & {
|
222
|
-
/**
|
223
|
-
* @deprecated Invoke the shell as a function instead.
|
224
|
-
*/
|
225
|
-
does: ((implementation: (input: InferIO<FragmentIn>) => InferIO<FragmentOut>) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) &
|
226
|
-
/**
|
227
|
-
* @param implementation
|
228
|
-
* Raw WGSL function implementation with header and body
|
229
|
-
* without `fn` keyword and function name
|
230
|
-
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
231
|
-
*/
|
232
|
-
((implementation: string) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>);
|
233
|
-
};
|
234
|
-
interface TgpuFragmentFn<Varying extends FragmentInConstrained = FragmentInConstrained, Output extends FragmentOutConstrained = FragmentOutConstrained> extends TgpuNamable {
|
235
|
-
readonly shell: TgpuFragmentFnShellHeader<Varying, Output>;
|
236
|
-
readonly outputType: IOLayoutToSchema<Output>;
|
237
|
-
$uses(dependencyMap: Record<string, unknown>): this;
|
238
|
-
}
|
239
|
-
declare function fragmentFn<FragmentOut extends FragmentOutConstrained>(options: {
|
240
|
-
out: FragmentOut;
|
241
|
-
}): TgpuFragmentFnShell<{}, FragmentOut>;
|
242
|
-
declare function fragmentFn<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained>(options: {
|
243
|
-
in: FragmentIn;
|
244
|
-
out: FragmentOut;
|
245
|
-
}): TgpuFragmentFnShell<FragmentIn, FragmentOut>;
|
246
|
-
|
247
|
-
/**
|
248
|
-
* Describes a vertex entry function signature (its arguments, return type and attributes)
|
249
|
-
*/
|
250
|
-
type TgpuVertexFnShellHeader<VertexIn extends IOLayout, VertexOut extends IOLayout> = {
|
251
|
-
readonly argTypes: [AnyWgslStruct] | [];
|
252
|
-
readonly returnType: VertexOut;
|
253
|
-
readonly attributes: [VertexIn];
|
254
|
-
readonly isEntry: true;
|
255
|
-
};
|
256
|
-
/**
|
257
|
-
* Describes a vertex entry function signature (its arguments, return type and attributes).
|
258
|
-
* Allows creating tgpu vertex functions by calling this shell
|
259
|
-
* and passing the implementation (as WGSL string or JS function) as the argument.
|
260
|
-
*/
|
261
|
-
type TgpuVertexFnShell<VertexIn extends IOLayout, VertexOut extends IOLayout> = TgpuVertexFnShellHeader<VertexIn, VertexOut> & ((implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & ((implementation: string) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & ((strings: TemplateStringsArray, ...values: unknown[]) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & {
|
262
|
-
/**
|
263
|
-
* @deprecated Invoke the shell as a function instead.
|
264
|
-
*/
|
265
|
-
does: ((implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & ((implementation: string) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>);
|
266
|
-
};
|
267
|
-
interface TgpuVertexFn<VertexIn extends IOLayout = IOLayout, VertexOut extends IOLayout = IOLayout> extends TgpuNamable {
|
268
|
-
readonly shell: TgpuVertexFnShellHeader<VertexIn, VertexOut>;
|
269
|
-
readonly outputType: IOLayoutToSchema<VertexOut>;
|
270
|
-
readonly inputType: IOLayoutToSchema<VertexIn>;
|
271
|
-
$uses(dependencyMap: Record<string, unknown>): this;
|
272
|
-
}
|
273
|
-
declare function vertexFn<VertexOut extends IORecord>(options: {
|
274
|
-
out: VertexOut;
|
275
|
-
}): TgpuVertexFnShell<{}, VertexOut>;
|
276
|
-
declare function vertexFn<VertexIn extends IORecord, VertexOut extends IORecord>(options: {
|
277
|
-
in: VertexIn;
|
278
|
-
out: VertexOut;
|
279
|
-
}): TgpuVertexFnShell<VertexIn, VertexOut>;
|
280
|
-
|
281
|
-
/**
|
282
|
-
* The array can hold T, where T is a single/multi-component numeric, or a struct with members of type T.
|
283
|
-
* Examples of valid array members:
|
284
|
-
* - Vec3f,
|
285
|
-
* - unorm8x2
|
286
|
-
* - WgslStruct<{ a: Vec3f, b: unorm8x2 }>
|
287
|
-
* - WgslStruct<{ nested: WgslStruct<{ a: Vec3f }> }>
|
288
|
-
*/
|
289
|
-
type DataToContainedAttribs<T> = T extends AnyWgslStruct | AnyUnstruct ? {
|
290
|
-
[Key in keyof T['propTypes']]: DataToContainedAttribs<T['propTypes'][Key]>;
|
291
|
-
} : T extends {
|
292
|
-
type: VertexFormat;
|
293
|
-
} ? TgpuVertexAttrib<T['type']> : T extends {
|
294
|
-
type: keyof KindToDefaultFormatMap;
|
295
|
-
} ? TgpuVertexAttrib<KindToDefaultFormatMap[T['type']]> : T extends Decorated<infer TInner> ? DataToContainedAttribs<TInner> : never;
|
296
|
-
/**
|
297
|
-
* Interprets an array as a set of vertex attributes.
|
298
|
-
*/
|
299
|
-
type ArrayToContainedAttribs<T extends WgslArray | Disarray> = DataToContainedAttribs<T['elementType']>;
|
300
|
-
type LayoutToAllowedAttribs<T> = T extends {
|
301
|
-
type: keyof KindToAcceptedAttribMap;
|
302
|
-
} ? KindToAcceptedAttribMap[T['type']] : T extends Record<string, unknown> ? {
|
303
|
-
[Key in keyof T]: LayoutToAllowedAttribs<T[Key]>;
|
304
|
-
} : never;
|
305
|
-
|
306
|
-
interface TgpuVertexLayout<TData extends WgslArray | Disarray = WgslArray | Disarray> extends TgpuNamable, Labelled {
|
307
|
-
readonly resourceType: 'vertex-layout';
|
308
|
-
readonly stride: number;
|
309
|
-
readonly stepMode: 'vertex' | 'instance';
|
310
|
-
readonly attrib: ArrayToContainedAttribs<TData>;
|
311
|
-
readonly vertexLayout: GPUVertexBufferLayout;
|
312
|
-
schemaForCount(n: number): TData;
|
313
|
-
}
|
314
|
-
declare function vertexLayout<TData extends WgslArray | Disarray>(schemaForCount: (count: number) => TData, stepMode?: 'vertex' | 'instance'): TgpuVertexLayout<TData>;
|
315
|
-
|
316
|
-
interface TgpuRenderPipeline<Output extends IOLayout = IOLayout> extends TgpuNamable {
|
317
|
-
readonly resourceType: 'render-pipeline';
|
318
|
-
readonly label: string | undefined;
|
319
|
-
with<TData extends WgslArray | Disarray>(vertexLayout: TgpuVertexLayout<TData>, buffer: TgpuBuffer<TData> & VertexFlag): TgpuRenderPipeline<IOLayout>;
|
320
|
-
with<Entries extends Record<string, TgpuLayoutEntry | null>>(bindGroupLayout: TgpuBindGroupLayout<Entries>, bindGroup: TgpuBindGroup<Entries>): TgpuRenderPipeline<IOLayout>;
|
321
|
-
withColorAttachment(attachment: FragmentOutToColorAttachment<Output>): TgpuRenderPipeline<IOLayout>;
|
322
|
-
withDepthStencilAttachment(attachment: DepthStencilAttachment): TgpuRenderPipeline<IOLayout>;
|
323
|
-
draw(vertexCount: number, instanceCount?: number, firstVertex?: number, firstInstance?: number): void;
|
324
|
-
}
|
325
|
-
type FragmentOutToTargets<T extends IOLayout> = T extends IOData ? GPUColorTargetState : T extends Record<string, unknown> ? {
|
326
|
-
[Key in keyof T]: GPUColorTargetState;
|
327
|
-
} : never;
|
328
|
-
type FragmentOutToColorAttachment<T extends IOLayout> = T extends IOData ? ColorAttachment : T extends Record<string, unknown> ? {
|
329
|
-
[Key in keyof T]: ColorAttachment;
|
330
|
-
} : never;
|
331
|
-
interface ColorAttachment {
|
332
|
-
/**
|
333
|
-
* A {@link GPUTextureView} describing the texture subresource that will be output to for this
|
334
|
-
* color attachment.
|
335
|
-
*/
|
336
|
-
view: (TgpuTexture & Render) | GPUTextureView;
|
337
|
-
/**
|
338
|
-
* Indicates the depth slice index of {@link GPUTextureViewDimension#"3d"} {@link GPURenderPassColorAttachment#view}
|
339
|
-
* that will be output to for this color attachment.
|
340
|
-
*/
|
341
|
-
depthSlice?: GPUIntegerCoordinate;
|
342
|
-
/**
|
343
|
-
* A {@link GPUTextureView} describing the texture subresource that will receive the resolved
|
344
|
-
* output for this color attachment if {@link GPURenderPassColorAttachment#view} is
|
345
|
-
* multisampled.
|
346
|
-
*/
|
347
|
-
resolveTarget?: GPUTextureView;
|
348
|
-
/**
|
349
|
-
* Indicates the value to clear {@link GPURenderPassColorAttachment#view} to prior to executing the
|
350
|
-
* render pass. If not map/exist|provided, defaults to `{r: 0, g: 0, b: 0, a: 0}`. Ignored
|
351
|
-
* if {@link GPURenderPassColorAttachment#loadOp} is not {@link GPULoadOp#"clear"}.
|
352
|
-
* The components of {@link GPURenderPassColorAttachment#clearValue} are all double values.
|
353
|
-
* They are converted to a texel value of texture format matching the render attachment.
|
354
|
-
* If conversion fails, a validation error is generated.
|
355
|
-
*/
|
356
|
-
clearValue?: GPUColor;
|
357
|
-
/**
|
358
|
-
* Indicates the load operation to perform on {@link GPURenderPassColorAttachment#view} prior to
|
359
|
-
* executing the render pass.
|
360
|
-
* Note: It is recommended to prefer clearing; see {@link GPULoadOp#"clear"} for details.
|
361
|
-
*/
|
362
|
-
loadOp: GPULoadOp;
|
363
|
-
/**
|
364
|
-
* The store operation to perform on {@link GPURenderPassColorAttachment#view}
|
365
|
-
* after executing the render pass.
|
366
|
-
*/
|
367
|
-
storeOp: GPUStoreOp;
|
368
|
-
}
|
369
|
-
interface DepthStencilAttachment {
|
370
|
-
/**
|
371
|
-
* A {@link GPUTextureView} | ({@link TgpuTexture} & {@link Render}) describing the texture subresource that will be output to
|
372
|
-
* and read from for this depth/stencil attachment.
|
373
|
-
*/
|
374
|
-
view: (TgpuTexture & Render) | GPUTextureView;
|
375
|
-
/**
|
376
|
-
* Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s depth component
|
377
|
-
* to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#depthLoadOp}
|
378
|
-
* is not {@link GPULoadOp#"clear"}. Must be between 0.0 and 1.0, inclusive (unless unrestricted depth is enabled).
|
379
|
-
*/
|
380
|
-
depthClearValue?: number;
|
381
|
-
/**
|
382
|
-
* Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
|
383
|
-
* depth component prior to executing the render pass.
|
384
|
-
* Note: It is recommended to prefer clearing; see {@link GPULoadOp#"clear"} for details.
|
385
|
-
*/
|
386
|
-
depthLoadOp?: GPULoadOp;
|
387
|
-
/**
|
388
|
-
* The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
|
389
|
-
* depth component after executing the render pass.
|
390
|
-
*/
|
391
|
-
depthStoreOp?: GPUStoreOp;
|
392
|
-
/**
|
393
|
-
* Indicates that the depth component of {@link GPURenderPassDepthStencilAttachment#view}
|
394
|
-
* is read only.
|
395
|
-
*/
|
396
|
-
depthReadOnly?: boolean;
|
397
|
-
/**
|
398
|
-
* Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s stencil component
|
399
|
-
* to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#stencilLoadOp}
|
400
|
-
* is not {@link GPULoadOp#"clear"}.
|
401
|
-
* The value will be converted to the type of the stencil aspect of `view` by taking the same
|
402
|
-
* number of LSBs as the number of bits in the stencil aspect of one texel block|texel of `view`.
|
403
|
-
*/
|
404
|
-
stencilClearValue?: GPUStencilValue;
|
405
|
-
/**
|
406
|
-
* Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
|
407
|
-
* stencil component prior to executing the render pass.
|
408
|
-
* Note: It is recommended to prefer clearing; see {@link GPULoadOp#"clear"} for details.
|
409
|
-
*/
|
410
|
-
stencilLoadOp?: GPULoadOp;
|
411
|
-
/**
|
412
|
-
* The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
|
413
|
-
* stencil component after executing the render pass.
|
414
|
-
*/
|
415
|
-
stencilStoreOp?: GPUStoreOp;
|
416
|
-
/**
|
417
|
-
* Indicates that the stencil component of {@link GPURenderPassDepthStencilAttachment#view}
|
418
|
-
* is read only.
|
419
|
-
*/
|
420
|
-
stencilReadOnly?: boolean;
|
421
|
-
}
|
422
|
-
|
423
|
-
interface Unwrapper {
|
424
|
-
readonly device: GPUDevice;
|
425
|
-
unwrap(resource: TgpuComputePipeline): GPUComputePipeline;
|
426
|
-
unwrap(resource: TgpuRenderPipeline): GPURenderPipeline;
|
427
|
-
unwrap(resource: TgpuBindGroupLayout): GPUBindGroupLayout;
|
428
|
-
unwrap(resource: TgpuBindGroup): GPUBindGroup;
|
429
|
-
unwrap(resource: TgpuBuffer<AnyData>): GPUBuffer;
|
430
|
-
unwrap(resource: TgpuTexture): GPUTexture;
|
431
|
-
unwrap(resource: TgpuReadonlyTexture | TgpuWriteonlyTexture | TgpuMutableTexture | TgpuSampledTexture): GPUTextureView;
|
432
|
-
unwrap(resource: TgpuVertexLayout): GPUVertexBufferLayout;
|
433
|
-
unwrap(resource: TgpuSampler): GPUSampler;
|
434
|
-
unwrap(resource: TgpuComparisonSampler): GPUSampler;
|
435
|
-
}
|
436
|
-
|
437
|
-
interface WithCompute {
|
438
|
-
createPipeline(): TgpuComputePipeline;
|
439
|
-
}
|
440
|
-
type ValidateFragmentIn<VertexOut extends IORecord, FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = FragmentIn extends Partial<VertexOut> ? VertexOut extends FragmentIn ? [
|
441
|
-
entryFn: TgpuFragmentFn<FragmentIn, FragmentOut>,
|
442
|
-
targets: FragmentOutToTargets<FragmentOut>
|
443
|
-
] : [
|
444
|
-
entryFn: 'n/a',
|
445
|
-
targets: 'n/a',
|
446
|
-
MissingFromVertexOutput: {
|
447
|
-
[Key in Exclude<keyof FragmentIn, keyof VertexOut>]: FragmentIn[Key];
|
448
|
-
}
|
449
|
-
] : [
|
450
|
-
entryFn: 'n/a',
|
451
|
-
targets: 'n/a',
|
452
|
-
MismatchedVertexOutput: {
|
453
|
-
[Key in keyof FragmentIn & keyof VertexOut as FragmentIn[Key] extends VertexOut[Key] ? never : Key]: [got: VertexOut[Key], expecting: FragmentIn[Key]];
|
454
|
-
}
|
455
|
-
];
|
456
|
-
interface WithVertex<VertexOut extends IORecord = IORecord> {
|
457
|
-
withFragment<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained>(...args: ValidateFragmentIn<VertexOut, FragmentIn, FragmentOut>): WithFragment<FragmentOut>;
|
458
|
-
}
|
459
|
-
interface WithFragment<Output extends FragmentOutConstrained = FragmentOutConstrained> {
|
460
|
-
withPrimitive(primitiveState: GPUPrimitiveState | undefined): WithFragment<Output>;
|
461
|
-
withDepthStencil(depthStencilState: GPUDepthStencilState | undefined): WithFragment<Output>;
|
462
|
-
withMultisample(multisampleState: GPUMultisampleState | undefined): WithFragment<Output>;
|
463
|
-
createPipeline(): TgpuRenderPipeline<Output>;
|
464
|
-
}
|
465
|
-
interface WithBinding {
|
466
|
-
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): WithBinding;
|
467
|
-
with<T extends AnyWgslData>(accessor: TgpuAccessor<T>, value: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>): WithBinding;
|
468
|
-
withCompute(entryFn: TgpuComputeFn): WithCompute;
|
469
|
-
withVertex<VertexIn extends IOLayout, VertexOut extends IORecord>(entryFn: TgpuVertexFn<VertexIn, VertexOut>, attribs: LayoutToAllowedAttribs<OmitBuiltins<VertexIn>>): WithVertex<VertexOut>;
|
470
|
-
}
|
471
|
-
type CreateTextureOptions<TSize, TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormat extends GPUTextureFormat, TDimension extends GPUTextureDimension> = {
|
472
|
-
/**
|
473
|
-
* The width, height, and depth or layer count of the texture.
|
474
|
-
*/
|
475
|
-
size: TSize;
|
476
|
-
/**
|
477
|
-
* The format of the texture.
|
478
|
-
*/
|
479
|
-
format: TFormat;
|
480
|
-
/**
|
481
|
-
* The number of mip levels the texture will contain.
|
482
|
-
* @default 1
|
483
|
-
*/
|
484
|
-
mipLevelCount?: TMipLevelCount | undefined;
|
485
|
-
/**
|
486
|
-
* The sample count of the texture. A sampleCount > 1 indicates a multisampled texture.
|
487
|
-
* @default 1
|
488
|
-
*/
|
489
|
-
sampleCount?: TSampleCount | undefined;
|
490
|
-
/**
|
491
|
-
* Specifies extra formats (in addition to the texture's actual format) that can be used
|
492
|
-
* when creating views of this texture.
|
493
|
-
* @default []
|
494
|
-
*/
|
495
|
-
viewFormats?: TViewFormat[] | undefined;
|
496
|
-
/**
|
497
|
-
* Whether the texture is one-dimensional, an array of two-dimensional layers, or three-dimensional.
|
498
|
-
* @default '2d'
|
499
|
-
*/
|
500
|
-
dimension?: TDimension | undefined;
|
501
|
-
};
|
502
|
-
type CreateTextureResult<TSize extends readonly number[], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormat extends GPUTextureFormat, TDimension extends GPUTextureDimension> = Prettify<{
|
503
|
-
size: Mutable<TSize>;
|
504
|
-
format: TFormat;
|
505
|
-
} & OmitProps<{
|
506
|
-
dimension: GPUTextureDimension extends TDimension ? undefined : TDimension extends '2d' ? undefined : TDimension;
|
507
|
-
mipLevelCount: number extends TMipLevelCount ? undefined : TMipLevelCount extends 1 ? undefined : TMipLevelCount;
|
508
|
-
sampleCount: number extends TSampleCount ? undefined : TSampleCount extends 1 ? undefined : TSampleCount;
|
509
|
-
viewFormats: GPUTextureFormat extends TViewFormat ? undefined : TViewFormat[] extends never[] ? undefined : TViewFormat[];
|
510
|
-
}, undefined>>;
|
511
|
-
interface RenderPass {
|
512
|
-
/**
|
513
|
-
* Sets the viewport used during the rasterization stage to linearly map from
|
514
|
-
* NDC (i.e., normalized device coordinates) to viewport coordinates.
|
515
|
-
* @param x - Minimum X value of the viewport in pixels.
|
516
|
-
* @param y - Minimum Y value of the viewport in pixels.
|
517
|
-
* @param width - Width of the viewport in pixels.
|
518
|
-
* @param height - Height of the viewport in pixels.
|
519
|
-
* @param minDepth - Minimum depth value of the viewport.
|
520
|
-
* @param maxDepth - Maximum depth value of the viewport.
|
521
|
-
*/
|
522
|
-
setViewport(x: number, y: number, width: number, height: number, minDepth: number, maxDepth: number): void;
|
523
|
-
/**
|
524
|
-
* Sets the scissor rectangle used during the rasterization stage.
|
525
|
-
* After transformation into viewport coordinates any fragments which fall outside the scissor
|
526
|
-
* rectangle will be discarded.
|
527
|
-
* @param x - Minimum X value of the scissor rectangle in pixels.
|
528
|
-
* @param y - Minimum Y value of the scissor rectangle in pixels.
|
529
|
-
* @param width - Width of the scissor rectangle in pixels.
|
530
|
-
* @param height - Height of the scissor rectangle in pixels.
|
531
|
-
*/
|
532
|
-
setScissorRect(x: number, y: number, width: number, height: number): void;
|
533
|
-
/**
|
534
|
-
* Sets the constant blend color and alpha values used with {@link GPUBlendFactor#constant}
|
535
|
-
* and {@link GPUBlendFactor#"one-minus-constant"} {@link GPUBlendFactor}s.
|
536
|
-
* @param color - The color to use when blending.
|
537
|
-
*/
|
538
|
-
setBlendConstant(color: GPUColor): void;
|
539
|
-
/**
|
540
|
-
* Sets the {@link RenderState#[[stencilReference]]} value used during stencil tests with
|
541
|
-
* the {@link GPUStencilOperation#"replace"} {@link GPUStencilOperation}.
|
542
|
-
* @param reference - The new stencil reference value.
|
543
|
-
*/
|
544
|
-
setStencilReference(reference: GPUStencilValue): undefined;
|
545
|
-
/**
|
546
|
-
* @param queryIndex - The index of the query in the query set.
|
547
|
-
*/
|
548
|
-
beginOcclusionQuery(queryIndex: GPUSize32): undefined;
|
549
|
-
endOcclusionQuery(): undefined;
|
550
|
-
/**
|
551
|
-
* Executes the commands previously recorded into the given {@link GPURenderBundle}s as part of
|
552
|
-
* this render pass.
|
553
|
-
* When a {@link GPURenderBundle} is executed, it does not inherit the render pass's pipeline, bind
|
554
|
-
* groups, or vertex and index buffers. After a {@link GPURenderBundle} has executed, the render
|
555
|
-
* pass's pipeline, bind group, and vertex/index buffer state is cleared
|
556
|
-
* (to the initial, empty values).
|
557
|
-
* Note: The state is cleared, not restored to the previous state.
|
558
|
-
* This occurs even if zero {@link GPURenderBundle|GPURenderBundles} are executed.
|
559
|
-
* @param bundles - List of render bundles to execute.
|
560
|
-
*/
|
561
|
-
executeBundles(bundles: Iterable<GPURenderBundle>): undefined;
|
562
|
-
setPipeline(pipeline: TgpuRenderPipeline): void;
|
563
|
-
/**
|
564
|
-
* Sets the current index buffer.
|
565
|
-
* @param buffer - Buffer containing index data to use for subsequent drawing commands.
|
566
|
-
* @param indexFormat - Format of the index data contained in `buffer`.
|
567
|
-
* @param offset - Offset in bytes into `buffer` where the index data begins. Defaults to `0`.
|
568
|
-
* @param size - Size in bytes of the index data in `buffer`.
|
569
|
-
* Defaults to the size of the buffer minus the offset.
|
570
|
-
*/
|
571
|
-
setIndexBuffer<TData extends WgslArray | Disarray>(buffer: TgpuBuffer<TData> | GPUBuffer, indexFormat: GPUIndexFormat, offset?: GPUSize64, size?: GPUSize64): void;
|
572
|
-
setVertexBuffer<TData extends WgslArray | Disarray>(vertexLayout: TgpuVertexLayout<TData>, buffer: (TgpuBuffer<TData> & VertexFlag) | GPUBuffer, offset?: GPUSize64, size?: GPUSize64): void;
|
573
|
-
setBindGroup<Entries extends Record<string, TgpuLayoutEntry | null>>(bindGroupLayout: TgpuBindGroupLayout<Entries>, bindGroup: TgpuBindGroup<Entries> | GPUBindGroup): void;
|
574
|
-
/**
|
575
|
-
* Draws primitives.
|
576
|
-
* @param vertexCount - The number of vertices to draw.
|
577
|
-
* @param instanceCount - The number of instances to draw.
|
578
|
-
* @param firstVertex - Offset into the vertex buffers, in vertices, to begin drawing from.
|
579
|
-
* @param firstInstance - First instance to draw.
|
580
|
-
*/
|
581
|
-
draw(vertexCount: number, instanceCount?: number | undefined, firstVertex?: number | undefined, firstInstance?: number | undefined): void;
|
582
|
-
/**
|
583
|
-
* Draws indexed primitives.
|
584
|
-
* @param indexCount - The number of indices to draw.
|
585
|
-
* @param instanceCount - The number of instances to draw.
|
586
|
-
* @param firstIndex - Offset into the index buffer, in indices, begin drawing from.
|
587
|
-
* @param baseVertex - Added to each index value before indexing into the vertex buffers.
|
588
|
-
* @param firstInstance - First instance to draw.
|
589
|
-
*/
|
590
|
-
drawIndexed(indexCount: number, instanceCount?: number | undefined, firstIndex?: number | undefined, baseVertex?: number | undefined, firstInstance?: number | undefined): void;
|
591
|
-
/**
|
592
|
-
* Draws primitives using parameters read from a {@link GPUBuffer}.
|
593
|
-
* Packed block of **four 32-bit unsigned integer values (16 bytes total)**, given in the same
|
594
|
-
* order as the arguments for {@link GPURenderEncoderBase#draw}. For example:
|
595
|
-
* @param indirectBuffer - Buffer containing the indirect draw parameters.
|
596
|
-
* @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.
|
597
|
-
*/
|
598
|
-
drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): undefined;
|
599
|
-
/**
|
600
|
-
* Draws indexed primitives using parameters read from a {@link GPUBuffer}.
|
601
|
-
* Tightly packed block of **five 32-bit unsigned integer values (20 bytes total)**, given in
|
602
|
-
* the same order as the arguments for {@link GPURenderEncoderBase#drawIndexed}. For example:
|
603
|
-
* @param indirectBuffer - Buffer containing the indirect drawIndexed parameters.
|
604
|
-
* @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.
|
605
|
-
*/
|
606
|
-
drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): undefined;
|
607
|
-
}
|
608
|
-
interface TgpuRoot extends Unwrapper {
|
609
|
-
/**
|
610
|
-
* The GPU device associated with this root.
|
611
|
-
*/
|
612
|
-
readonly device: GPUDevice;
|
613
|
-
/**
|
614
|
-
* Allocates memory on the GPU, allows passing data between host and shader.
|
615
|
-
*
|
616
|
-
* @remarks
|
617
|
-
* Typed wrapper around a GPUBuffer.
|
618
|
-
*
|
619
|
-
* @param typeSchema The type of data that this buffer will hold.
|
620
|
-
* @param initial The initial value of the buffer. (optional)
|
621
|
-
*/
|
622
|
-
createBuffer<TData extends AnyData>(typeSchema: TData, initial?: Infer<TData> | undefined): TgpuBuffer<TData>;
|
623
|
-
/**
|
624
|
-
* Allocates memory on the GPU, allows passing data between host and shader.
|
625
|
-
*
|
626
|
-
* @remarks
|
627
|
-
* Typed wrapper around a GPUBuffer.
|
628
|
-
*
|
629
|
-
* @param typeSchema The type of data that this buffer will hold.
|
630
|
-
* @param gpuBuffer A vanilla WebGPU buffer.
|
631
|
-
*/
|
632
|
-
createBuffer<TData extends AnyData>(typeSchema: TData, gpuBuffer: GPUBuffer): TgpuBuffer<TData>;
|
633
|
-
/**
|
634
|
-
* Creates a group of resources that can be bound to a shader based on a specified layout.
|
635
|
-
*
|
636
|
-
* @remarks
|
637
|
-
* Typed wrapper around a GPUBindGroup.
|
638
|
-
*
|
639
|
-
* @example
|
640
|
-
* const fooLayout = tgpu.bindGroupLayout({
|
641
|
-
* foo: { uniform: d.vec3f },
|
642
|
-
* bar: { texture: 'float' },
|
643
|
-
* });
|
644
|
-
*
|
645
|
-
* const fooBuffer = ...;
|
646
|
-
* const barTexture = ...;
|
647
|
-
*
|
648
|
-
* const fooBindGroup = root.createBindGroup(fooLayout, {
|
649
|
-
* foo: fooBuffer,
|
650
|
-
* bar: barTexture,
|
651
|
-
* });
|
652
|
-
*
|
653
|
-
* @param layout Layout describing the bind group to be created.
|
654
|
-
* @param entries A record with values being the resources populating the bind group
|
655
|
-
* and keys being their associated names, matching the layout keys.
|
656
|
-
*/
|
657
|
-
createBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>>(layout: TgpuBindGroupLayout<Entries>, entries: {
|
658
|
-
[K in keyof OmitProps<Entries, null>]: LayoutEntryToInput<Entries[K]>;
|
659
|
-
}): TgpuBindGroup<Entries>;
|
660
|
-
/**
|
661
|
-
* Destroys all underlying resources (i.e. buffers...) created through this root object.
|
662
|
-
* If the object is created via `tgpu.init` instead of `tgpu.initFromDevice`,
|
663
|
-
* then the inner GPU device is destroyed as well.
|
664
|
-
*/
|
665
|
-
destroy(): void;
|
666
|
-
'~unstable': Omit<ExperimentalTgpuRoot, keyof TgpuRoot>;
|
667
|
-
}
|
668
|
-
interface ExperimentalTgpuRoot extends TgpuRoot, WithBinding {
|
669
|
-
readonly jitTranspiler?: JitTranspiler | undefined;
|
670
|
-
readonly nameRegistry: NameRegistry;
|
671
|
-
/**
|
672
|
-
* The current command encoder. This property will
|
673
|
-
* hold the same value until `flush()` is called.
|
674
|
-
*/
|
675
|
-
readonly commandEncoder: GPUCommandEncoder;
|
676
|
-
createUniform<TData extends AnyWgslData>(typeSchema: TData, initialOrBuffer?: Infer<TData> | GPUBuffer): TgpuBufferUniform<TData> & TgpuFixedBufferUsage<TData>;
|
677
|
-
createMutable<TData extends AnyWgslData>(typeSchema: TData, initialOrBuffer?: Infer<TData> | GPUBuffer): TgpuBufferMutable<TData> & TgpuFixedBufferUsage<TData>;
|
678
|
-
createReadonly<TData extends AnyWgslData>(typeSchema: TData, initialOrBuffer?: Infer<TData> | GPUBuffer): TgpuBufferReadonly<TData> & TgpuFixedBufferUsage<TData>;
|
679
|
-
createTexture<TWidth extends number, THeight extends number, TDepth extends number, TSize extends readonly [TWidth] | readonly [TWidth, THeight] | readonly [TWidth, THeight, TDepth], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormat extends GPUTextureFormat, TDimension extends GPUTextureDimension>(props: CreateTextureOptions<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormat, TDimension>): TgpuTexture<CreateTextureResult<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormat, TDimension>>;
|
680
|
-
beginRenderPass(descriptor: GPURenderPassDescriptor, callback: (pass: RenderPass) => void): void;
|
681
|
-
/**
|
682
|
-
* Causes all commands enqueued by pipelines to be
|
683
|
-
* submitted to the GPU.
|
684
|
-
*/
|
685
|
-
flush(): void;
|
686
|
-
}
|
687
|
-
|
688
|
-
interface UniformFlag {
|
689
|
-
usableAsUniform: true;
|
690
|
-
}
|
691
|
-
/**
|
692
|
-
* @deprecated Use UniformFlag instead.
|
693
|
-
*/
|
694
|
-
type Uniform = UniformFlag;
|
695
|
-
interface VertexFlag {
|
696
|
-
usableAsVertex: true;
|
697
|
-
}
|
698
|
-
/**
|
699
|
-
* @deprecated Use VertexFlag instead.
|
700
|
-
*/
|
701
|
-
type Vertex = VertexFlag;
|
702
|
-
type LiteralToUsageType<T extends 'uniform' | 'storage' | 'vertex'> = T extends 'uniform' ? UniformFlag : T extends 'storage' ? StorageFlag : T extends 'vertex' ? VertexFlag : never;
|
703
|
-
type ViewUsages<TBuffer extends TgpuBuffer<BaseData>> = (boolean extends TBuffer['usableAsUniform'] ? never : 'uniform') | (boolean extends TBuffer['usableAsStorage'] ? never : 'readonly' | 'mutable');
|
704
|
-
type UsageTypeToBufferUsage<TData extends BaseData> = {
|
705
|
-
uniform: TgpuBufferUniform<TData> & TgpuFixedBufferUsage<TData>;
|
706
|
-
mutable: TgpuBufferMutable<TData> & TgpuFixedBufferUsage<TData>;
|
707
|
-
readonly: TgpuBufferReadonly<TData> & TgpuFixedBufferUsage<TData>;
|
708
|
-
};
|
709
|
-
interface TgpuBuffer<TData extends BaseData> extends TgpuNamable {
|
710
|
-
readonly resourceType: 'buffer';
|
711
|
-
readonly dataType: TData;
|
712
|
-
readonly initial?: Infer<TData> | undefined;
|
713
|
-
readonly label: string | undefined;
|
714
|
-
readonly buffer: GPUBuffer;
|
715
|
-
readonly destroyed: boolean;
|
716
|
-
usableAsUniform: boolean;
|
717
|
-
usableAsStorage: boolean;
|
718
|
-
usableAsVertex: boolean;
|
719
|
-
$usage<T extends RestrictVertexUsages<TData>>(...usages: T): this & UnionToIntersection<LiteralToUsageType<T[number]>>;
|
720
|
-
$addFlags(flags: GPUBufferUsageFlags): this;
|
721
|
-
as<T extends ViewUsages<this>>(usage: T): UsageTypeToBufferUsage<TData>[T];
|
722
|
-
compileWriter(): void;
|
723
|
-
write(data: Infer<TData>): void;
|
724
|
-
writePartial(data: InferPartial<TData>): void;
|
725
|
-
copyFrom(srcBuffer: TgpuBuffer<MemIdentity<TData>>): void;
|
726
|
-
read(): Promise<Infer<TData>>;
|
727
|
-
destroy(): void;
|
728
|
-
}
|
729
|
-
declare function isBuffer<T extends TgpuBuffer<AnyData>>(value: T | unknown): value is T;
|
730
|
-
declare function isUsableAsVertex<T extends TgpuBuffer<AnyData>>(buffer: T): buffer is T & VertexFlag;
|
731
|
-
type RestrictVertexUsages<TData extends BaseData> = TData extends {
|
732
|
-
readonly type: WgslTypeLiteral;
|
733
|
-
} ? ('uniform' | 'storage' | 'vertex')[] : 'vertex'[];
|
734
|
-
|
735
|
-
type TgpuLayoutEntryBase = {
|
736
|
-
/**
|
737
|
-
* Limits this resource's visibility to specific shader stages.
|
738
|
-
*
|
739
|
-
* By default, each resource is visible to all shader stage types, but
|
740
|
-
* depending on the underlying implementation, this may have performance implications.
|
741
|
-
*
|
742
|
-
* @default ['compute'] for mutable resources
|
743
|
-
* @default ['compute','vertex','fragment'] for everything else
|
744
|
-
*/
|
745
|
-
visibility?: TgpuShaderStage[];
|
746
|
-
};
|
747
|
-
type TgpuLayoutUniform = TgpuLayoutEntryBase & {
|
748
|
-
uniform: AnyWgslData;
|
749
|
-
};
|
750
|
-
type TgpuLayoutStorage = TgpuLayoutEntryBase & {
|
751
|
-
storage: AnyWgslData | ((arrayLength: number) => AnyWgslData);
|
752
|
-
/** @default 'readonly' */
|
753
|
-
access?: 'mutable' | 'readonly';
|
754
|
-
};
|
755
|
-
type TgpuLayoutSampler = TgpuLayoutEntryBase & {
|
756
|
-
sampler: 'filtering' | 'non-filtering';
|
757
|
-
};
|
758
|
-
type TgpuLayoutComparisonSampler = TgpuLayoutEntryBase & {
|
759
|
-
sampler: 'comparison';
|
760
|
-
};
|
761
|
-
type TgpuLayoutTexture<TSampleType extends GPUTextureSampleType = GPUTextureSampleType> = TgpuLayoutEntryBase & {
|
762
|
-
/**
|
763
|
-
* - 'float' - f32
|
764
|
-
* - 'unfilterable-float' - f32, cannot be used with filtering samplers
|
765
|
-
* - 'depth' - f32
|
766
|
-
* - 'sint' - i32
|
767
|
-
* - 'uint' - u32
|
768
|
-
*/
|
769
|
-
texture: TSampleType;
|
770
|
-
/**
|
771
|
-
* @default '2d'
|
772
|
-
*/
|
773
|
-
viewDimension?: GPUTextureViewDimension;
|
774
|
-
/**
|
775
|
-
* @default false
|
776
|
-
*/
|
777
|
-
multisampled?: boolean;
|
778
|
-
};
|
779
|
-
type TgpuLayoutStorageTexture<TFormat extends StorageTextureTexelFormat = StorageTextureTexelFormat> = TgpuLayoutEntryBase & {
|
780
|
-
storageTexture: TFormat;
|
781
|
-
/** @default 'writeonly' */
|
782
|
-
access?: 'readonly' | 'writeonly' | 'mutable';
|
783
|
-
/** @default '2d' */
|
784
|
-
viewDimension?: StorageTextureDimension;
|
785
|
-
};
|
786
|
-
type TgpuLayoutExternalTexture = TgpuLayoutEntryBase & {
|
787
|
-
externalTexture: Record<string, never>;
|
788
|
-
};
|
789
|
-
type TgpuLayoutEntry = TgpuLayoutUniform | TgpuLayoutStorage | TgpuLayoutSampler | TgpuLayoutComparisonSampler | TgpuLayoutTexture | TgpuLayoutStorageTexture | TgpuLayoutExternalTexture;
|
790
|
-
type UnwrapRuntimeConstructorInner<T extends BaseData | ((_: number) => BaseData)> = T extends (_: number) => BaseData ? ReturnType<T> : T;
|
791
|
-
type UnwrapRuntimeConstructor<T extends AnyData | ((_: number) => AnyData)> = T extends unknown ? UnwrapRuntimeConstructorInner<T> : never;
|
792
|
-
interface TgpuBindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>> extends TgpuNamable {
|
793
|
-
readonly resourceType: 'bind-group-layout';
|
794
|
-
readonly label: string | undefined;
|
795
|
-
readonly entries: Entries;
|
796
|
-
readonly bound: {
|
797
|
-
[K in keyof Entries]: BindLayoutEntry<Entries[K]>;
|
798
|
-
};
|
799
|
-
readonly value: {
|
800
|
-
[K in keyof Entries]: InferLayoutEntry<Entries[K]>;
|
801
|
-
};
|
802
|
-
readonly $: {
|
803
|
-
[K in keyof Entries]: InferLayoutEntry<Entries[K]>;
|
804
|
-
};
|
805
|
-
/**
|
806
|
-
* An explicit numeric index assigned to this bind group layout. If undefined, a unique
|
807
|
-
* index is assigned automatically during resolution. This can be changed with the
|
808
|
-
* `.$idx()` method.
|
809
|
-
*/
|
810
|
-
readonly index: number | undefined;
|
811
|
-
/**
|
812
|
-
* Associates this bind group layout with an explicit numeric index. When a call to this
|
813
|
-
* method is omitted, a unique numeric index is assigned to it automatically.
|
814
|
-
*
|
815
|
-
* Used when generating WGSL code: `@group(${index}) @binding(...) ...;`
|
816
|
-
*/
|
817
|
-
$idx(index?: number): this;
|
818
|
-
/**
|
819
|
-
* Creates a raw WebGPU resource based on the typed descriptor.
|
820
|
-
* NOTE: This creates a new resource every time, better to use `root.unwrap(...)` instead.
|
821
|
-
* @param unwrapper Used to unwrap any resources that this resource depends on.
|
822
|
-
*/
|
823
|
-
unwrap(unwrapper: Unwrapper): GPUBindGroupLayout;
|
824
|
-
}
|
825
|
-
type StorageUsageForEntry<T extends TgpuLayoutStorage> = T extends {
|
826
|
-
access?: infer Access;
|
827
|
-
} ? 'mutable' | 'readonly' extends Access ? TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>> | TgpuBufferMutable<UnwrapRuntimeConstructor<T['storage']>> : 'readonly' extends Access ? TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>> : 'mutable' extends Access ? TgpuBufferMutable<UnwrapRuntimeConstructor<T['storage']>> : TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>> | TgpuBufferMutable<UnwrapRuntimeConstructor<T['storage']>> : TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>>;
|
828
|
-
type GetUsageForStorageTexture<T extends TgpuLayoutStorageTexture, TAccess extends 'readonly' | 'writeonly' | 'mutable'> = {
|
829
|
-
mutable: TgpuMutableTexture<Default<GetDimension<T['viewDimension']>, '2d'>, TexelFormatToDataType[T['storageTexture']]>;
|
830
|
-
readonly: TgpuReadonlyTexture<Default<GetDimension<T['viewDimension']>, '2d'>, TexelFormatToDataType[T['storageTexture']]>;
|
831
|
-
writeonly: TgpuWriteonlyTexture<Default<GetDimension<T['viewDimension']>, '2d'>, TexelFormatToDataType[T['storageTexture']]>;
|
832
|
-
}[TAccess];
|
833
|
-
type StorageTextureUsageForEntry<T extends TgpuLayoutStorageTexture> = T extends unknown ? GetUsageForStorageTexture<T, Default<T['access'], 'writeonly'>> : never;
|
834
|
-
type GetDimension<T extends GPUTextureViewDimension | undefined> = T extends keyof ViewDimensionToDimension ? ViewDimensionToDimension[T] : undefined;
|
835
|
-
type GetTextureRestriction<T extends TgpuLayoutTexture> = Default<GetDimension<T['viewDimension']>, '2d'> extends infer Dimension ? Dimension extends '2d' ? {
|
836
|
-
format: ChannelTypeToLegalFormats[SampleTypeToStringChannelType[T['texture']]];
|
837
|
-
dimension?: Dimension;
|
838
|
-
} : {
|
839
|
-
format: ChannelTypeToLegalFormats[SampleTypeToStringChannelType[T['texture']]];
|
840
|
-
dimension: Dimension;
|
841
|
-
} : never;
|
842
|
-
type GetStorageTextureRestriction<T extends TgpuLayoutStorageTexture> = Default<GetDimension<T['viewDimension']>, '2d'> extends infer Dimension ? Dimension extends '2d' ? {
|
843
|
-
format: T['storageTexture'];
|
844
|
-
dimension?: Dimension;
|
845
|
-
} : {
|
846
|
-
format: T['storageTexture'];
|
847
|
-
dimension: Dimension;
|
848
|
-
} : never;
|
849
|
-
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;
|
850
|
-
type BindLayoutEntry<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? TgpuBufferUniform<T['uniform']> : T extends TgpuLayoutStorage ? StorageUsageForEntry<T> : T extends TgpuLayoutSampler ? TgpuSampler : T extends TgpuLayoutComparisonSampler ? TgpuComparisonSampler : T extends TgpuLayoutTexture ? TgpuSampledTexture<Default<T['viewDimension'], '2d'>, ChannelFormatToSchema[T['texture']]> : T extends TgpuLayoutStorageTexture ? StorageTextureUsageForEntry<T> : never;
|
851
|
-
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;
|
852
|
-
type TgpuBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>> = {
|
853
|
-
readonly resourceType: 'bind-group';
|
854
|
-
readonly layout: TgpuBindGroupLayout<Entries>;
|
855
|
-
unwrap(unwrapper: Unwrapper): GPUBindGroup;
|
856
|
-
};
|
857
|
-
declare function bindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | null>>(entries: Entries): TgpuBindGroupLayout<Prettify<Entries>>;
|
858
|
-
|
859
|
-
interface TgpuBufferUsage<TData extends BaseData = BaseData, TUsage extends BindableBufferUsage = BindableBufferUsage> {
|
860
|
-
readonly resourceType: 'buffer-usage';
|
861
|
-
readonly usage: TUsage;
|
862
|
-
readonly [$repr]: Infer<TData>;
|
863
|
-
value: InferGPU<TData>;
|
864
|
-
readonly [$internal]: {
|
865
|
-
readonly dataType: TData;
|
866
|
-
};
|
867
|
-
}
|
868
|
-
interface TgpuBufferUniform<TData extends BaseData> extends TgpuBufferUsage<TData, 'uniform'> {
|
869
|
-
readonly value: InferGPU<TData>;
|
870
|
-
}
|
871
|
-
interface TgpuBufferReadonly<TData extends BaseData> extends TgpuBufferUsage<TData, 'readonly'> {
|
872
|
-
readonly value: InferGPU<TData>;
|
873
|
-
}
|
874
|
-
interface TgpuFixedBufferUsage<TData extends BaseData> extends TgpuNamable {
|
875
|
-
readonly buffer: TgpuBuffer<TData>;
|
876
|
-
write(data: Infer<TData>): void;
|
877
|
-
}
|
878
|
-
interface TgpuBufferMutable<TData extends BaseData> extends TgpuBufferUsage<TData, 'mutable'> {
|
879
|
-
}
|
880
|
-
declare function isUsableAsUniform<T extends TgpuBuffer<AnyData>>(buffer: T): buffer is T & UniformFlag;
|
881
|
-
/**
|
882
|
-
* @deprecated Use buffer.as('mutable') instead.
|
883
|
-
*/
|
884
|
-
declare function asMutable<TData extends AnyWgslData>(buffer: TgpuBuffer<TData> & StorageFlag): TgpuBufferMutable<TData> & TgpuFixedBufferUsage<TData>;
|
885
|
-
/**
|
886
|
-
* @deprecated Use buffer.as('readonly') instead.
|
887
|
-
*/
|
888
|
-
declare function asReadonly<TData extends AnyWgslData>(buffer: TgpuBuffer<TData> & StorageFlag): TgpuBufferReadonly<TData> & TgpuFixedBufferUsage<TData>;
|
889
|
-
/**
|
890
|
-
* @deprecated Use buffer.as('uniform') instead.
|
891
|
-
*/
|
892
|
-
declare function asUniform<TData extends AnyWgslData>(buffer: TgpuBuffer<TData> & UniformFlag): TgpuBufferUniform<TData> & TgpuFixedBufferUsage<TData>;
|
893
|
-
|
894
|
-
interface TgpuExternalTexture {
|
895
|
-
readonly resourceType: 'external-texture';
|
896
|
-
}
|
897
|
-
|
898
|
-
type VariableScope = 'private' | 'workgroup';
|
899
|
-
interface TgpuVar<TScope extends VariableScope = VariableScope, TDataType extends AnyWgslData = AnyWgslData> extends TgpuNamable {
|
900
|
-
value: Infer<TDataType>;
|
901
|
-
readonly scope: TScope;
|
902
|
-
}
|
903
|
-
/**
|
904
|
-
* Defines a variable scoped to each entry function (private).
|
905
|
-
*
|
906
|
-
* @param dataType The schema of the held data's type
|
907
|
-
* @param initialValue If not provided, the variable will be initialized to the dataType's "zero-value".
|
908
|
-
*/
|
909
|
-
declare function privateVar<TDataType extends AnyWgslData>(dataType: TDataType, initialValue?: Infer<TDataType>): TgpuVar<'private', TDataType>;
|
910
|
-
/**
|
911
|
-
* Defines a variable scoped to the whole workgroup, shared between entry functions
|
912
|
-
* of the same invocation.
|
913
|
-
*
|
914
|
-
* @param dataType The schema of the held data's type
|
915
|
-
*/
|
916
|
-
declare function workgroupVar<TDataType extends AnyWgslData>(dataType: TDataType): TgpuVar<'workgroup', TDataType>;
|
917
|
-
|
918
|
-
type ResolvableObject = SelfResolvable | TgpuBufferUsage | TgpuConst | TgpuDeclare | TgpuFn | TgpuComputeFn | TgpuFragmentFn | TgpuComputePipeline | TgpuRenderPipeline | TgpuVertexFn | TgpuSampler | TgpuAccessor | TgpuExternalTexture | TgpuTexture | TgpuAnyTextureView | TgpuVar | AnyVecInstance | AnyMatInstance | AnyData | TgpuFn<any, any>;
|
919
|
-
type Wgsl = Eventual<string | number | boolean | ResolvableObject>;
|
920
|
-
declare const UnknownData: {
|
921
|
-
type: "unknown";
|
922
|
-
};
|
923
|
-
type UnknownData = typeof UnknownData;
|
924
|
-
type Snippet = {
|
925
|
-
value: unknown;
|
926
|
-
dataType: AnyData | UnknownData;
|
927
|
-
};
|
928
|
-
type TgpuShaderStage = 'compute' | 'vertex' | 'fragment';
|
929
|
-
interface FnToWgslOptions {
|
930
|
-
args: Snippet[];
|
931
|
-
returnType: AnyWgslData;
|
932
|
-
body: Block;
|
933
|
-
externalMap: Record<string, unknown>;
|
934
|
-
}
|
935
|
-
type ItemLayer = {
|
936
|
-
type: 'item';
|
937
|
-
usedSlots: Set<TgpuSlot<unknown>>;
|
938
|
-
};
|
939
|
-
interface ItemStateStack {
|
940
|
-
readonly itemDepth: number;
|
941
|
-
readonly topItem: ItemLayer;
|
942
|
-
pushItem(): void;
|
943
|
-
popItem(): void;
|
944
|
-
pushSlotBindings(pairs: SlotValuePair<unknown>[]): void;
|
945
|
-
popSlotBindings(): void;
|
946
|
-
pushFunctionScope(args: Snippet[], returnType: AnyWgslData | undefined, externalMap: Record<string, unknown>): void;
|
947
|
-
popFunctionScope(): void;
|
948
|
-
pushBlockScope(): void;
|
949
|
-
popBlockScope(): void;
|
950
|
-
pop(type?: 'functionScope' | 'blockScope' | 'slotBinding' | 'item'): void;
|
951
|
-
readSlot<T>(slot: TgpuSlot<T>): T | undefined;
|
952
|
-
getSnippetById(id: string): Snippet | undefined;
|
953
|
-
defineBlockVariable(id: string, type: AnyWgslData | UnknownData): Snippet;
|
954
|
-
}
|
955
|
-
/**
|
956
|
-
* Passed into each resolvable item. All items in a tree share a resolution ctx,
|
957
|
-
* but there can be layers added and removed from the item stack when going down
|
958
|
-
* and up the tree.
|
959
|
-
*/
|
960
|
-
interface ResolutionCtx {
|
961
|
-
readonly names: NameRegistry;
|
962
|
-
addDeclaration(declaration: string): void;
|
963
|
-
/**
|
964
|
-
* Reserves a bind group number, and returns a placeholder that will be replaced
|
965
|
-
* with a concrete number at the end of the resolution process.
|
966
|
-
*/
|
967
|
-
allocateLayoutEntry(layout: TgpuBindGroupLayout): string;
|
968
|
-
/**
|
969
|
-
* Reserves a spot in the catch-all bind group, without the indirection of a bind-group.
|
970
|
-
* This means the resource is 'fixed', and cannot be swapped between code execution.
|
971
|
-
*/
|
972
|
-
allocateFixedEntry(layoutEntry: TgpuLayoutEntry, resource: object): {
|
973
|
-
group: string;
|
974
|
-
binding: number;
|
975
|
-
};
|
976
|
-
withSlots<T>(pairs: SlotValuePair<unknown>[], callback: () => T): T;
|
977
|
-
/**
|
978
|
-
* Unwraps all layers of slot/derived indirection and returns the concrete value if available.
|
979
|
-
* @throws {MissingSlotValueError}
|
980
|
-
*/
|
981
|
-
unwrap<T>(eventual: Eventual<T>): T;
|
982
|
-
resolve(item: unknown): string;
|
983
|
-
resolveValue<T extends BaseData>(value: Infer<T>, schema: T): string;
|
984
|
-
transpileFn(fn: string): {
|
985
|
-
argNames: ArgNames;
|
986
|
-
body: Block;
|
987
|
-
externalNames: string[];
|
988
|
-
};
|
989
|
-
fnToWgsl(options: FnToWgslOptions): {
|
990
|
-
head: Wgsl;
|
991
|
-
body: Wgsl;
|
992
|
-
};
|
993
|
-
[$internal]: {
|
994
|
-
itemStateStack: ItemStateStack;
|
995
|
-
};
|
996
|
-
}
|
997
|
-
/**
|
998
|
-
* Houses a method '~resolve` that returns a code string
|
999
|
-
* representing it, as opposed to offloading the resolution
|
1000
|
-
* to another mechanism.
|
1001
|
-
*/
|
1002
|
-
interface SelfResolvable {
|
1003
|
-
'~resolve'(ctx: ResolutionCtx): string;
|
1004
|
-
toString(): string;
|
1005
|
-
}
|
1006
|
-
interface Labelled {
|
1007
|
-
readonly label?: string | undefined;
|
1008
|
-
}
|
1009
|
-
type BindableBufferUsage = 'uniform' | 'readonly' | 'mutable';
|
1010
|
-
|
1011
|
-
/**
|
1012
|
-
* Describes a function signature (its arguments and return type)
|
1013
|
-
*/
|
1014
|
-
type TgpuFnShellHeader<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = AnyWgslData | undefined> = {
|
1015
|
-
readonly argTypes: Args;
|
1016
|
-
readonly returnType: Return | undefined;
|
1017
|
-
readonly isEntry: false;
|
1018
|
-
};
|
1019
|
-
/**
|
1020
|
-
* Describes a function signature (its arguments and return type).
|
1021
|
-
* Allows creating tgpu functions by calling this shell
|
1022
|
-
* and passing the implementation (as WGSL string or JS function) as the argument.
|
1023
|
-
*/
|
1024
|
-
type TgpuFnShell<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = AnyWgslData | undefined> = TgpuFnShellHeader<Args, Return> & ((implementation: (...args: Args extends AnyWgslData[] ? InferArgs<Args> : [InferIO<Args>]) => InferReturn<Return>) => TgpuFn<Args, Return>) & ((implementation: string) => TgpuFn<Args, Return>) & ((strings: TemplateStringsArray, ...values: unknown[]) => TgpuFn<Args, Return>) & {
|
1025
|
-
/**
|
1026
|
-
* @deprecated Invoke the shell as a function instead.
|
1027
|
-
*/
|
1028
|
-
does: ((implementation: (...args: Args extends AnyWgslData[] ? InferArgs<Args> : [InferIO<Args>]) => InferReturn<Return>) => TgpuFn<Args, Return>) & ((implementation: string) => TgpuFn<Args, Return>);
|
1029
|
-
};
|
1030
|
-
interface TgpuFnBase<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = undefined> extends TgpuNamable, Labelled {
|
1031
|
-
readonly [$internal]: {
|
1032
|
-
implementation: Implementation<Args, Return>;
|
1033
|
-
};
|
1034
|
-
readonly resourceType: 'function';
|
1035
|
-
readonly shell: TgpuFnShellHeader<Args, Return>;
|
1036
|
-
readonly '~providing'?: Providing | undefined;
|
1037
|
-
$uses(dependencyMap: Record<string, unknown>): this;
|
1038
|
-
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TgpuFn<Args, Return>;
|
1039
|
-
with<T extends AnyWgslData>(accessor: TgpuAccessor<T>, value: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>): TgpuFn<Args, Return>;
|
1040
|
-
}
|
1041
|
-
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>);
|
1042
|
-
declare function fn<Args extends AnyWgslData[] | Record<string, AnyWgslData> | []>(argTypes: Args, returnType?: undefined): TgpuFnShell<Args, undefined>;
|
1043
|
-
declare function fn<Args extends AnyWgslData[] | Record<string, AnyWgslData> | [], Return extends AnyWgslData>(argTypes: Args, returnType: Return): TgpuFnShell<Args, Return>;
|
1044
|
-
declare function isTgpuFn<Args extends AnyWgslData[], Return extends AnyWgslData | undefined = undefined>(value: unknown | TgpuFn<Args, Return>): value is TgpuFn<Args, Return>;
|
1
|
+
import { W as Wgsl, J as JitTranspiler, T as TgpuRoot, A as AnyWgslData, a as TgpuFn, b as TgpuBufferUsage, I as Infer, c as TgpuAccessor, d as TgpuDerived, e as TgpuSlot, f as TgpuBindGroupLayout, g as TgpuVertexLayout, h as WgslArray, D as Disarray, i as TgpuBuffer, j as AnyData, k as bindGroupLayout, v as vertexLayout, l as fn, m as fragmentFn, n as vertexFn, o as computeFn, p as privateVar, w as workgroupVar, q as constant, r as declare, s as sampler, t as comparisonSampler } from './tgpuComputeFn-DH8_PcIR.cjs';
|
2
|
+
export { am as BindLayoutEntry, a8 as Eventual, an as ExtractBindGroupInputFromLayout, ao as LayoutEntryToInput, R as RandomNameRegistry, ag as Render, ah as Sampled, Z as Storage, _ as StorageFlag, S as StrictNameRegistry, af as TextureProps, a9 as TgpuAnyTextureView, ap as TgpuBindGroup, a5 as TgpuBufferMutable, a6 as TgpuBufferReadonly, a7 as TgpuBufferUniform, aD as TgpuComputeFn, aE as TgpuComputeFnShell, a0 as TgpuComputePipeline, ai as TgpuConst, aF as TgpuDeclare, ay as TgpuFnShell, aB as TgpuFragmentFn, aC as TgpuFragmentFnShell, aq as TgpuLayoutComparisonSampler, ar as TgpuLayoutEntry, as as TgpuLayoutExternalTexture, at as TgpuLayoutSampler, au as TgpuLayoutStorage, av as TgpuLayoutStorageTexture, aw as TgpuLayoutTexture, ax as TgpuLayoutUniform, aa as TgpuMutableTexture, ab as TgpuReadonlyTexture, $ as TgpuRenderPipeline, ac as TgpuSampledTexture, al as TgpuSampler, ad as TgpuTexture, aj as TgpuVar, az as TgpuVertexFn, aA as TgpuVertexFnShell, ae as TgpuWriteonlyTexture, a1 as Uniform, a2 as UniformFlag, ak as VariableScope, a3 as Vertex, a4 as VertexFlag, U as WithBinding, V as WithCompute, X as WithFragment, Y as WithVertex, u as isBuffer, B as isComparisonSampler, y as isDerived, E as isSampledTextureView, C as isSampler, z as isSlot, F as isStorageTextureView, G as isTexture, Q as isTgpuFn, H as isUsableAsRender, K as isUsableAsSampled, L as isUsableAsStorage, P as isUsableAsUniform, x as isUsableAsVertex, M as unstable_asMutable, N as unstable_asReadonly, O as unstable_asUniform } from './tgpuComputeFn-DH8_PcIR.cjs';
|
3
|
+
import 'tinyest';
|
1045
4
|
|
1046
5
|
interface TgpuResolveOptions {
|
1047
6
|
/**
|
@@ -1223,4 +182,4 @@ declare const tgpu: {
|
|
1223
182
|
};
|
1224
183
|
};
|
1225
184
|
|
1226
|
-
export { type
|
185
|
+
export { type InitFromDeviceOptions, type InitOptions, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError, TgpuAccessor, TgpuBindGroupLayout, TgpuBuffer, TgpuDerived, TgpuFn, TgpuRoot, TgpuSlot, TgpuVertexLayout, tgpu as default, tgpu };
|