typegpu 0.8.1 → 0.9.0
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/chunk-5ABKYSJD.js +2 -0
- package/chunk-5ABKYSJD.js.map +1 -0
- package/chunk-D5UYO3OX.js +3 -0
- package/chunk-D5UYO3OX.js.map +1 -0
- package/chunk-EHLRP4V2.js +2 -0
- package/chunk-EHLRP4V2.js.map +1 -0
- package/chunk-LMPPDGRD.js +2 -0
- package/chunk-LMPPDGRD.js.map +1 -0
- package/chunk-MBB2XFH6.js +2 -0
- package/chunk-MBB2XFH6.js.map +1 -0
- package/chunk-SHSILTWI.js +10 -0
- package/chunk-SHSILTWI.js.map +1 -0
- package/common/index.d.ts +1 -1
- package/common/index.js +1 -1
- package/common/index.js.map +1 -1
- package/comptime-DKpw1IVu.d.ts +28 -0
- package/data/index.d.ts +124 -123
- package/data/index.js +1 -1
- package/data/index.js.map +1 -1
- package/index.d.ts +114 -25
- package/index.js +169 -164
- package/index.js.map +1 -1
- package/{matrix-DHFT4O8f.d.cts → matrix-C4IFKU1R.d.ts} +5 -4
- package/package.json +6 -14
- package/std/index.d.ts +25 -41
- package/std/index.js +1 -1
- package/std/index.js.map +1 -1
- package/{tgpuConstant-BU72w5qs.d.cts → tgpuConstant-BOn7U_lv.d.ts} +135 -1296
- package/chunk-2UXPGML5.js +0 -7
- package/chunk-2UXPGML5.js.map +0 -1
- package/chunk-3246CM7C.cjs +0 -2
- package/chunk-3246CM7C.cjs.map +0 -1
- package/chunk-4W5Z7BO4.js +0 -10
- package/chunk-4W5Z7BO4.js.map +0 -1
- package/chunk-5Y6GTBWR.cjs +0 -3
- package/chunk-5Y6GTBWR.cjs.map +0 -1
- package/chunk-7S3IK3D4.js +0 -2
- package/chunk-7S3IK3D4.js.map +0 -1
- package/chunk-7XFSK632.js +0 -3
- package/chunk-7XFSK632.js.map +0 -1
- package/chunk-PRMFGUQT.cjs +0 -2
- package/chunk-PRMFGUQT.cjs.map +0 -1
- package/chunk-TRE7NUKE.cjs +0 -10
- package/chunk-TRE7NUKE.cjs.map +0 -1
- package/chunk-VOVQAOVG.js +0 -2
- package/chunk-VOVQAOVG.js.map +0 -1
- package/chunk-ZYGTVBDH.cjs +0 -7
- package/chunk-ZYGTVBDH.cjs.map +0 -1
- package/common/index.cjs +0 -7
- package/common/index.cjs.map +0 -1
- package/common/index.d.cts +0 -24
- package/data/index.cjs +0 -2
- package/data/index.cjs.map +0 -1
- package/data/index.d.cts +0 -402
- package/index.cjs +0 -192
- package/index.cjs.map +0 -1
- package/index.d.cts +0 -369
- package/matrix-DLipCOZF.d.ts +0 -122
- package/std/index.cjs +0 -2
- package/std/index.cjs.map +0 -1
- package/std/index.d.cts +0 -639
- package/tgpuConstant-BU72w5qs.d.ts +0 -5192
package/index.d.ts
CHANGED
|
@@ -1,15 +1,68 @@
|
|
|
1
|
-
import { $ as $internal, S as ShelllessRepository, T as TgpuSlot, R as ResolvedSnippet, a as TgpuDerived, b as TgpuBindGroupLayout, c as TgpuBindGroup, L as LogResources,
|
|
2
|
-
export {
|
|
1
|
+
import { A as AnyData, O as Origin, I as InferGPU, $ as $internal, S as ShelllessRepository, T as TgpuSlot, R as ResolvedSnippet, a as TgpuDerived, b as TgpuBindGroupLayout, c as TgpuBindGroup, L as LogResources, C as Configurable, W as WgslExtension, d as ShaderGenerator, e as Wgsl, f as ResolvableObject, g as TgpuBuffer, h as TgpuVar, i as LogGeneratorOptions, j as TgpuRoot, k as AnyWgslData, l as TgpuFn, m as TgpuBufferUsage, n as TgpuBufferShorthand, o as Infer, p as TgpuAccessor, q as TgpuVertexLayout, r as WgslArray, D as Disarray, s as fn, t as bindGroupLayout, v as vertexLayout, u as privateVar, w as workgroupVar, x as constant, y as fragmentFn, z as vertexFn, B as computeFn, E as declare } from './tgpuConstant-BOn7U_lv.js';
|
|
2
|
+
export { aA as BindLayoutEntry, an as Eventual, aB as ExtractBindGroupInputFromLayout, aS as INTERNAL_GlobalExt, ab as IndexFlag, aC as LayoutEntryToInput, ar as RenderFlag, as as SampledFlag, a7 as Storage, a8 as StorageFlag, aq as TextureProps, ah as TgpuBufferMutable, ai as TgpuBufferReadonly, aj as TgpuBufferUniform, av as TgpuComparisonSampler, aP as TgpuComputeFn, aQ as TgpuComputeFnShell, aa as TgpuComputePipeline, at as TgpuConst, aR as TgpuDeclare, aw as TgpuFixedComparisonSampler, ax as TgpuFixedSampler, aK as TgpuFnShell, aN as TgpuFragmentFn, aO as TgpuFragmentFnShell, _ as TgpuGuardedComputePipeline, aD as TgpuLayoutComparisonSampler, aE as TgpuLayoutEntry, aF as TgpuLayoutExternalTexture, aG as TgpuLayoutSampler, aH as TgpuLayoutStorage, aI as TgpuLayoutTexture, aJ as TgpuLayoutUniform, ak as TgpuMutable, az as TgpuQuerySet, al as TgpuReadonly, a9 as TgpuRenderPipeline, ay as TgpuSampler, ao as TgpuTexture, ap as TgpuTextureView, am as TgpuUniform, aL as TgpuVertexFn, aM as TgpuVertexFnShell, ac as Uniform, ad as UniformFlag, ae as ValidUsagesFor, a0 as ValidateBufferSchema, a1 as ValidateStorageSchema, a2 as ValidateUniformSchema, au as VariableScope, af as Vertex, ag as VertexFlag, a3 as WithBinding, a4 as WithCompute, a5 as WithFragment, a6 as WithVertex, F as isBuffer, X as isBufferShorthand, K as isComparisonSampler, H as isDerived, M as isSampler, J as isSlot, N as isTexture, Y as isTgpuFn, P as isUsableAsRender, Q as isUsableAsSampled, U as isUsableAsStorage, V as isUsableAsUniform, G as isUsableAsVertex, Z as isVariable } from './tgpuConstant-BOn7U_lv.js';
|
|
3
|
+
import { c as comptime } from './comptime-DKpw1IVu.js';
|
|
4
|
+
export { T as TgpuComptime } from './comptime-DKpw1IVu.js';
|
|
3
5
|
import 'tinyest';
|
|
4
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Extra declaration that will be included in final WGSL code
|
|
9
|
+
* when resolving objects that use it.
|
|
10
|
+
*/
|
|
11
|
+
interface TgpuRawCodeSnippet<TDataType extends AnyData> {
|
|
12
|
+
$: InferGPU<TDataType>;
|
|
13
|
+
value: InferGPU<TDataType>;
|
|
14
|
+
$uses(dependencyMap: Record<string, unknown>): this;
|
|
15
|
+
}
|
|
16
|
+
type RawCodeSnippetOrigin = Exclude<Origin, 'function' | 'this-function' | 'argument' | 'constant-ref'>;
|
|
17
|
+
/**
|
|
18
|
+
* An advanced API that creates a typed shader expression which
|
|
19
|
+
* can be injected into the final shader bundle upon use.
|
|
20
|
+
*
|
|
21
|
+
* @param expression The code snippet that will be injected in place of `foo.$`
|
|
22
|
+
* @param type The type of the expression
|
|
23
|
+
* @param [origin='runtime'] Where the value originates from.
|
|
24
|
+
*
|
|
25
|
+
* **-- Which origin to choose?**
|
|
26
|
+
*
|
|
27
|
+
* Usually 'runtime' (the default) is a safe bet, but if you're sure that the expression or
|
|
28
|
+
* computation is constant (either a reference to a constant, a numeric literal,
|
|
29
|
+
* or an operation on constants), then pass 'constant' as it might lead to better
|
|
30
|
+
* optimizations.
|
|
31
|
+
*
|
|
32
|
+
* If what the expression is a direct reference to an existing value (e.g. a uniform, a
|
|
33
|
+
* storage binding, ...), then choose from 'uniform', 'mutable', 'readonly', 'workgroup',
|
|
34
|
+
* 'private' or 'handle' depending on the address space of the referred value.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* // An identifier that we know will be in the
|
|
39
|
+
* // final shader bundle, but we cannot
|
|
40
|
+
* // refer to it in any other way.
|
|
41
|
+
* const existingGlobal = tgpu['~unstable']
|
|
42
|
+
* .rawCodeSnippet('EXISTING_GLOBAL', d.f32, 'constant');
|
|
43
|
+
*
|
|
44
|
+
* const foo = () => {
|
|
45
|
+
* 'use gpu';
|
|
46
|
+
* return existingGlobal.$ * 2;
|
|
47
|
+
* };
|
|
48
|
+
*
|
|
49
|
+
* const wgsl = tgpu.resolve([foo]);
|
|
50
|
+
* // fn foo() -> f32 {
|
|
51
|
+
* // return EXISTING_GLOBAL * 2;
|
|
52
|
+
* // }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
declare function rawCodeSnippet<TDataType extends AnyData>(expression: string, type: TDataType, origin?: RawCodeSnippetOrigin | undefined): TgpuRawCodeSnippet<TDataType>;
|
|
56
|
+
|
|
5
57
|
interface NameRegistry {
|
|
6
58
|
/**
|
|
7
59
|
* Creates a valid WGSL identifier, each guaranteed to be unique
|
|
8
60
|
* in the lifetime of a single resolution process.
|
|
9
61
|
* Should append "_" to primer, followed by some id.
|
|
10
62
|
* @param primer Used in the generation process, makes the identifier more recognizable.
|
|
63
|
+
* @param global Whether the name should be registered in the global scope (true), or in the current function scope (false)
|
|
11
64
|
*/
|
|
12
|
-
makeUnique(primer
|
|
65
|
+
makeUnique(primer: string | undefined, global: boolean): string;
|
|
13
66
|
/**
|
|
14
67
|
* Creates a valid WGSL identifier.
|
|
15
68
|
* Renames identifiers that are WGSL reserved words.
|
|
@@ -22,6 +75,8 @@ interface NameRegistry {
|
|
|
22
75
|
* makeValid("_"); // ERROR (too difficult to make valid to care)
|
|
23
76
|
*/
|
|
24
77
|
makeValid(primer: string): string;
|
|
78
|
+
pushFunctionScope(): void;
|
|
79
|
+
popFunctionScope(): void;
|
|
25
80
|
}
|
|
26
81
|
|
|
27
82
|
type SlotToValueMap = Map<TgpuSlot<unknown>, unknown>;
|
|
@@ -72,15 +127,6 @@ interface ResolutionResult {
|
|
|
72
127
|
}
|
|
73
128
|
|
|
74
129
|
interface TgpuResolveOptions {
|
|
75
|
-
/**
|
|
76
|
-
* Map of external names to their resolvable values.
|
|
77
|
-
*/
|
|
78
|
-
externals: Record<string, Wgsl | object>;
|
|
79
|
-
/**
|
|
80
|
-
* The code template to use for the resolution. All external names will be replaced with their resolved values.
|
|
81
|
-
* @default ''
|
|
82
|
-
*/
|
|
83
|
-
template?: string | undefined;
|
|
84
130
|
/**
|
|
85
131
|
* The naming strategy used for generating identifiers for resolved externals and their dependencies.
|
|
86
132
|
*
|
|
@@ -108,8 +154,19 @@ interface TgpuResolveOptions {
|
|
|
108
154
|
*/
|
|
109
155
|
shaderGenerator?: ShaderGenerator | undefined;
|
|
110
156
|
}
|
|
157
|
+
interface TgpuExtendedResolveOptions extends TgpuResolveOptions {
|
|
158
|
+
/**
|
|
159
|
+
* Map of external names to their resolvable values.
|
|
160
|
+
*/
|
|
161
|
+
externals: Record<string, Wgsl | object>;
|
|
162
|
+
/**
|
|
163
|
+
* The code template to use for the resolution. All external names will be replaced with their resolved values.
|
|
164
|
+
* @default ''
|
|
165
|
+
*/
|
|
166
|
+
template?: string | undefined;
|
|
167
|
+
}
|
|
111
168
|
/**
|
|
112
|
-
* Resolves a template with external values. Each external will get resolved to a code string and replaced in the template.
|
|
169
|
+
* Resolves a template with external values. Each external that is used will get resolved to a code string and replaced in the template.
|
|
113
170
|
* Any dependencies of the externals will also be resolved and included in the output.
|
|
114
171
|
* @param options - The options for the resolution.
|
|
115
172
|
*
|
|
@@ -117,10 +174,7 @@ interface TgpuResolveOptions {
|
|
|
117
174
|
*
|
|
118
175
|
* @example
|
|
119
176
|
* ```ts
|
|
120
|
-
* const Gradient = d.struct({
|
|
121
|
-
* from: d.vec3f,
|
|
122
|
-
* to: d.vec3f,
|
|
123
|
-
* });
|
|
177
|
+
* const Gradient = d.struct({ from: d.vec3f, to: d.vec3f });
|
|
124
178
|
*
|
|
125
179
|
* const { code, usedBindGroupLayouts, catchall } = tgpu.resolveWithContext({
|
|
126
180
|
* template: `
|
|
@@ -143,13 +197,14 @@ interface TgpuResolveOptions {
|
|
|
143
197
|
* // }
|
|
144
198
|
* ```
|
|
145
199
|
*/
|
|
146
|
-
declare function resolveWithContext(options:
|
|
200
|
+
declare function resolveWithContext(options: TgpuExtendedResolveOptions): ResolutionResult;
|
|
147
201
|
/**
|
|
148
|
-
* Resolves
|
|
202
|
+
* Resolves given TypeGPU resources.
|
|
149
203
|
* Any dependencies of the externals will also be resolved and included in the output.
|
|
204
|
+
* @param items - An array of items to resolve.
|
|
150
205
|
* @param options - The options for the resolution.
|
|
151
206
|
*
|
|
152
|
-
* @returns
|
|
207
|
+
* @returns {ResolutionResult}
|
|
153
208
|
*
|
|
154
209
|
* @example
|
|
155
210
|
* ```ts
|
|
@@ -158,7 +213,38 @@ declare function resolveWithContext(options: TgpuResolveOptions): ResolutionResu
|
|
|
158
213
|
* to: d.vec3f,
|
|
159
214
|
* });
|
|
160
215
|
*
|
|
161
|
-
* const
|
|
216
|
+
* const { code, usedBindGroupLayouts, catchall } =
|
|
217
|
+
* tgpu.resolveWithContext([Gradient]);
|
|
218
|
+
*
|
|
219
|
+
* console.log(code);
|
|
220
|
+
* // struct Gradient_0 {
|
|
221
|
+
* // from: vec3f,
|
|
222
|
+
* // to: vec3f,
|
|
223
|
+
* // }
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
declare function resolveWithContext(items: ResolvableObject[], options?: TgpuResolveOptions): ResolutionResult;
|
|
227
|
+
/**
|
|
228
|
+
* A shorthand for calling `tgpu.resolveWithContext(...).code`.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```ts
|
|
232
|
+
* const Gradient = d.struct({ from: d.vec3f, to: d.vec3f });
|
|
233
|
+
*
|
|
234
|
+
* const resolved = tgpu.resolve([Gradient]);
|
|
235
|
+
*
|
|
236
|
+
* console.log(resolved);
|
|
237
|
+
* // struct Gradient_0 {
|
|
238
|
+
* // from: vec3f,
|
|
239
|
+
* // to: vec3f,
|
|
240
|
+
* // }
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```ts
|
|
245
|
+
* const Gradient = d.struct({ from: d.vec3f, to: d.vec3f });
|
|
246
|
+
*
|
|
247
|
+
* const code = tgpu.resolve({
|
|
162
248
|
* template: `
|
|
163
249
|
* fn getGradientAngle(gradient: Gradient) -> f32 {
|
|
164
250
|
* return atan(gradient.to.y - gradient.from.y, gradient.to.x - gradient.from.x);
|
|
@@ -169,7 +255,7 @@ declare function resolveWithContext(options: TgpuResolveOptions): ResolutionResu
|
|
|
169
255
|
* },
|
|
170
256
|
* });
|
|
171
257
|
*
|
|
172
|
-
* console.log(
|
|
258
|
+
* console.log(code);
|
|
173
259
|
* // struct Gradient_0 {
|
|
174
260
|
* // from: vec3f,
|
|
175
261
|
* // to: vec3f,
|
|
@@ -179,7 +265,8 @@ declare function resolveWithContext(options: TgpuResolveOptions): ResolutionResu
|
|
|
179
265
|
* // }
|
|
180
266
|
* ```
|
|
181
267
|
*/
|
|
182
|
-
declare function resolve(options:
|
|
268
|
+
declare function resolve(options: TgpuExtendedResolveOptions): string;
|
|
269
|
+
declare function resolve(items: ResolvableObject[], options?: TgpuResolveOptions): string;
|
|
183
270
|
|
|
184
271
|
interface SimulationResult<T> {
|
|
185
272
|
value: T;
|
|
@@ -272,7 +359,7 @@ declare function init(options?: InitOptions): Promise<TgpuRoot>;
|
|
|
272
359
|
*/
|
|
273
360
|
declare function initFromDevice(options: InitFromDeviceOptions): TgpuRoot;
|
|
274
361
|
|
|
275
|
-
declare function accessor<T extends AnyWgslData>(schema: T, defaultValue?: TgpuFn<() => T> | TgpuBufferUsage<T> | Infer<T>): TgpuAccessor<T>;
|
|
362
|
+
declare function accessor<T extends AnyWgslData>(schema: T, defaultValue?: TgpuFn<() => T> | TgpuBufferUsage<T> | TgpuBufferShorthand<T> | Infer<T>): TgpuAccessor<T>;
|
|
276
363
|
|
|
277
364
|
declare function derived<T>(compute: () => T): TgpuDerived<T>;
|
|
278
365
|
|
|
@@ -338,6 +425,7 @@ declare const tgpu: {
|
|
|
338
425
|
fragmentFn: typeof fragmentFn;
|
|
339
426
|
vertexFn: typeof vertexFn;
|
|
340
427
|
computeFn: typeof computeFn;
|
|
428
|
+
comptime: typeof comptime;
|
|
341
429
|
/**
|
|
342
430
|
* @deprecated This feature is now stable, use tgpu.vertexLayout.
|
|
343
431
|
*/
|
|
@@ -362,8 +450,9 @@ declare const tgpu: {
|
|
|
362
450
|
*/
|
|
363
451
|
const: typeof constant;
|
|
364
452
|
declare: typeof declare;
|
|
453
|
+
rawCodeSnippet: typeof rawCodeSnippet;
|
|
365
454
|
simulate: typeof simulate;
|
|
366
455
|
};
|
|
367
456
|
};
|
|
368
457
|
|
|
369
|
-
export { Configurable, type InitFromDeviceOptions, type InitOptions, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, type Namespace, NotUniformError, ResolutionError, TgpuAccessor, TgpuBindGroup, TgpuBindGroupLayout, TgpuBuffer, TgpuDerived, TgpuFn, TgpuRoot, TgpuSlot, TgpuVar, TgpuVertexLayout, tgpu as default, tgpu };
|
|
458
|
+
export { Configurable, type InitFromDeviceOptions, type InitOptions, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, type Namespace, NotUniformError, type RawCodeSnippetOrigin, ResolutionError, TgpuAccessor, TgpuBindGroup, TgpuBindGroupLayout, TgpuBuffer, TgpuDerived, TgpuFn, type TgpuRawCodeSnippet, TgpuRoot, TgpuSlot, TgpuVar, TgpuVertexLayout, tgpu as default, tgpu };
|