typegpu 0.5.9 → 0.6.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/chunk-APTRHY5Y.js +41 -0
- package/chunk-APTRHY5Y.js.map +1 -0
- package/chunk-RC26P3MP.cjs +2 -0
- package/chunk-RC26P3MP.cjs.map +1 -0
- package/{chunk-CGVYLGBG.js → chunk-RK6TMFVW.js} +2 -2
- package/chunk-S62QJDM6.js +2 -0
- package/chunk-S62QJDM6.js.map +1 -0
- package/chunk-TG4A6AM3.cjs +2 -0
- package/chunk-TG4A6AM3.cjs.map +1 -0
- package/chunk-UMHCZDPA.cjs +41 -0
- package/chunk-UMHCZDPA.cjs.map +1 -0
- package/data/index.cjs +1 -1
- package/data/index.cjs.map +1 -1
- package/data/index.d.cts +30 -4
- package/data/index.d.ts +30 -4
- package/data/index.js +1 -1
- package/index.cjs +20 -20
- package/index.cjs.map +1 -1
- package/index.d.cts +62 -11
- package/index.d.ts +62 -11
- package/index.js +20 -20
- package/index.js.map +1 -1
- package/{matrix-BnXitNJ7.d.cts → matrix-BN6ObiMv.d.cts} +1 -1
- package/{matrix-BULDDGYa.d.ts → matrix-S8W4dk8I.d.ts} +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 +2 -2
- package/std/index.d.ts +2 -2
- package/std/index.js +1 -1
- package/{tgpuComputeFn-BxPDI5hQ.d.ts → tgpuComputeFn-DOUjhQua.d.cts} +370 -157
- package/{tgpuComputeFn-BxPDI5hQ.d.cts → tgpuComputeFn-DOUjhQua.d.ts} +370 -157
- package/chunk-734H4JWF.js +0 -2
- package/chunk-734H4JWF.js.map +0 -1
- package/chunk-BJSN5UVV.cjs +0 -41
- package/chunk-BJSN5UVV.cjs.map +0 -1
- package/chunk-BZVU4Q6A.cjs +0 -2
- package/chunk-BZVU4Q6A.cjs.map +0 -1
- package/chunk-CDUKTYES.cjs +0 -2
- package/chunk-CDUKTYES.cjs.map +0 -1
- package/chunk-SWJVYRFM.js +0 -41
- package/chunk-SWJVYRFM.js.map +0 -1
- /package/{LICENSE.md → LICENSE} +0 -0
- /package/{chunk-CGVYLGBG.js.map → chunk-RK6TMFVW.js.map} +0 -0
package/index.d.cts
CHANGED
@@ -1,7 +1,20 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
1
|
+
import { T as TgpuBindGroupLayout, a as TgpuBindGroup, W as Wgsl, b as TgpuRoot, A as AnyWgslData, c as TgpuFn, d as TgpuBufferUsage, I as Infer, e as TgpuAccessor, f as TgpuDerived, g as TgpuSlot, h as TgpuVertexLayout, i as WgslArray, D as Disarray, j as TgpuBuffer, k as AnyData, l as fn, m as bindGroupLayout, v as vertexLayout, n as fragmentFn, o as vertexFn, p as computeFn, q as privateVar, w as workgroupVar, r as constant, s as declare, t as sampler, u as comparisonSampler } from './tgpuComputeFn-DOUjhQua.cjs';
|
2
|
+
export { as as BindLayoutEntry, V as Configurable, ae as Eventual, at as ExtractBindGroupInputFromLayout, aL as INTERNAL_GlobalExt, a3 as IndexFlag, au as LayoutEntryToInput, R as RandomNameRegistry, am as Render, an as Sampled, $ as Storage, a0 as StorageFlag, S as StrictNameRegistry, al as TextureProps, af as TgpuAnyTextureView, a8 as TgpuBufferMutable, a9 as TgpuBufferReadonly, aa as TgpuBufferUniform, aI as TgpuComputeFn, aJ as TgpuComputeFnShell, a2 as TgpuComputePipeline, ao as TgpuConst, aK as TgpuDeclare, aD as TgpuFnShell, aG as TgpuFragmentFn, aH as TgpuFragmentFnShell, av as TgpuLayoutComparisonSampler, aw as TgpuLayoutEntry, ax as TgpuLayoutExternalTexture, ay as TgpuLayoutSampler, az as TgpuLayoutStorage, aA as TgpuLayoutStorageTexture, aB as TgpuLayoutTexture, aC as TgpuLayoutUniform, ab as TgpuMutable, ag as TgpuMutableTexture, ac as TgpuReadonly, ah as TgpuReadonlyTexture, a1 as TgpuRenderPipeline, ai as TgpuSampledTexture, ar as TgpuSampler, aj as TgpuTexture, ad as TgpuUniform, ap as TgpuVar, aE as TgpuVertexFn, aF as TgpuVertexFnShell, ak as TgpuWriteonlyTexture, a4 as Uniform, a5 as UniformFlag, aq as VariableScope, a6 as Vertex, a7 as VertexFlag, X as WithBinding, Y as WithCompute, Z as WithFragment, _ as WithVertex, x as isBuffer, Q as isBufferShorthand, C as isComparisonSampler, z as isDerived, F as isSampledTextureView, E as isSampler, B as isSlot, G as isStorageTextureView, H as isTexture, U as isTgpuFn, J as isUsableAsRender, K as isUsableAsSampled, L as isUsableAsStorage, P as isUsableAsUniform, y as isUsableAsVertex, M as unstable_asMutable, N as unstable_asReadonly, O as unstable_asUniform } from './tgpuComputeFn-DOUjhQua.cjs';
|
3
3
|
import 'tinyest';
|
4
4
|
|
5
|
+
/**
|
6
|
+
* The results of a WGSL resolution.
|
7
|
+
*
|
8
|
+
* @param code - The resolved code.
|
9
|
+
* @param usedBindGroupLayouts - List of used `tgpu.bindGroupLayout`s.
|
10
|
+
* @param catchall - Automatically constructed bind group for buffer usages and buffer shorthands, preceded by its index.
|
11
|
+
*/
|
12
|
+
interface ResolutionResult {
|
13
|
+
code: string;
|
14
|
+
usedBindGroupLayouts: TgpuBindGroupLayout[];
|
15
|
+
catchall: [number, TgpuBindGroup] | undefined;
|
16
|
+
}
|
17
|
+
|
5
18
|
interface TgpuResolveOptions {
|
6
19
|
/**
|
7
20
|
* Map of external names to their resolvable values.
|
@@ -17,12 +30,43 @@ interface TgpuResolveOptions {
|
|
17
30
|
* @default 'random'
|
18
31
|
*/
|
19
32
|
names?: 'strict' | 'random' | undefined;
|
20
|
-
/**
|
21
|
-
* Optional JIT transpiler for resolving TGSL functions.
|
22
|
-
* @experimental
|
23
|
-
*/
|
24
|
-
unstable_jitTranspiler?: JitTranspiler | undefined;
|
25
33
|
}
|
34
|
+
/**
|
35
|
+
* Resolves a template with external values. Each external will get resolved to a code string and replaced in the template.
|
36
|
+
* Any dependencies of the externals will also be resolved and included in the output.
|
37
|
+
* @param options - The options for the resolution.
|
38
|
+
*
|
39
|
+
* @returns {ResolutionResult}
|
40
|
+
*
|
41
|
+
* @example
|
42
|
+
* ```ts
|
43
|
+
* const Gradient = d.struct({
|
44
|
+
* from: d.vec3f,
|
45
|
+
* to: d.vec3f,
|
46
|
+
* });
|
47
|
+
*
|
48
|
+
* const { code, usedBindGroupLayouts, catchall } = tgpu.resolveWithContext({
|
49
|
+
* template: `
|
50
|
+
* fn getGradientAngle(gradient: Gradient) -> f32 {
|
51
|
+
* return atan(gradient.to.y - gradient.from.y, gradient.to.x - gradient.from.x);
|
52
|
+
* }
|
53
|
+
* `,
|
54
|
+
* externals: {
|
55
|
+
* Gradient,
|
56
|
+
* },
|
57
|
+
* });
|
58
|
+
*
|
59
|
+
* console.log(code);
|
60
|
+
* // struct Gradient_0 {
|
61
|
+
* // from: vec3f,
|
62
|
+
* // to: vec3f,
|
63
|
+
* // }
|
64
|
+
* // fn getGradientAngle(gradient: Gradient_0) -> f32 {
|
65
|
+
* // return atan(gradient.to.y - gradient.from.y, gradient.to.x - gradient.from.x);
|
66
|
+
* // }
|
67
|
+
* ```
|
68
|
+
*/
|
69
|
+
declare function resolveWithContext(options: TgpuResolveOptions): ResolutionResult;
|
26
70
|
/**
|
27
71
|
* Resolves a template with external values. Each external will get resolved to a code string and replaced in the template.
|
28
72
|
* Any dependencies of the externals will also be resolved and included in the output.
|
@@ -70,7 +114,6 @@ type InitOptions = {
|
|
70
114
|
} | undefined;
|
71
115
|
/** @default 'random' */
|
72
116
|
unstable_names?: 'random' | 'strict' | undefined;
|
73
|
-
unstable_jitTranspiler?: JitTranspiler | undefined;
|
74
117
|
};
|
75
118
|
/**
|
76
119
|
* Options passed into {@link initFromDevice}.
|
@@ -79,7 +122,6 @@ type InitFromDeviceOptions = {
|
|
79
122
|
device: GPUDevice;
|
80
123
|
/** @default 'random' */
|
81
124
|
unstable_names?: 'random' | 'strict' | undefined;
|
82
|
-
unstable_jitTranspiler?: JitTranspiler | undefined;
|
83
125
|
};
|
84
126
|
/**
|
85
127
|
* Requests a new GPU device and creates a root around it.
|
@@ -111,7 +153,7 @@ declare function init(options?: InitOptions): Promise<TgpuRoot>;
|
|
111
153
|
*/
|
112
154
|
declare function initFromDevice(options: InitFromDeviceOptions): TgpuRoot;
|
113
155
|
|
114
|
-
declare function accessor<T extends AnyWgslData>(schema: T, defaultValue?: TgpuFn<
|
156
|
+
declare function accessor<T extends AnyWgslData>(schema: T, defaultValue?: TgpuFn<() => T> | TgpuBufferUsage<T> | Infer<T>): TgpuAccessor<T>;
|
115
157
|
|
116
158
|
declare function derived<T>(compute: () => T): TgpuDerived<T>;
|
117
159
|
|
@@ -158,12 +200,18 @@ declare class MissingVertexBuffersError extends Error {
|
|
158
200
|
*/
|
159
201
|
|
160
202
|
declare const tgpu: {
|
203
|
+
fn: typeof fn;
|
161
204
|
bindGroupLayout: typeof bindGroupLayout;
|
162
205
|
vertexLayout: typeof vertexLayout;
|
206
|
+
slot: typeof slot;
|
163
207
|
init: typeof init;
|
164
208
|
initFromDevice: typeof initFromDevice;
|
165
209
|
resolve: typeof resolve;
|
210
|
+
resolveWithContext: typeof resolveWithContext;
|
166
211
|
'~unstable': {
|
212
|
+
/**
|
213
|
+
* @deprecated This feature is now stable, use tgpu.fn.
|
214
|
+
*/
|
167
215
|
fn: typeof fn;
|
168
216
|
fragmentFn: typeof fragmentFn;
|
169
217
|
vertexFn: typeof vertexFn;
|
@@ -173,6 +221,9 @@ declare const tgpu: {
|
|
173
221
|
*/
|
174
222
|
vertexLayout: typeof vertexLayout;
|
175
223
|
derived: typeof derived;
|
224
|
+
/**
|
225
|
+
* @deprecated This feature is now stable, use tgpu.slot.
|
226
|
+
*/
|
176
227
|
slot: typeof slot;
|
177
228
|
accessor: typeof accessor;
|
178
229
|
privateVar: typeof privateVar;
|
@@ -184,4 +235,4 @@ declare const tgpu: {
|
|
184
235
|
};
|
185
236
|
};
|
186
237
|
|
187
|
-
export { type InitFromDeviceOptions, type InitOptions, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError, TgpuAccessor, TgpuBindGroupLayout, TgpuBuffer, TgpuDerived, TgpuFn, TgpuRoot, TgpuSlot, TgpuVertexLayout, tgpu as default, tgpu };
|
238
|
+
export { type InitFromDeviceOptions, type InitOptions, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError, TgpuAccessor, TgpuBindGroup, TgpuBindGroupLayout, TgpuBuffer, TgpuDerived, TgpuFn, TgpuRoot, TgpuSlot, TgpuVertexLayout, tgpu as default, tgpu };
|
package/index.d.ts
CHANGED
@@ -1,7 +1,20 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
1
|
+
import { T as TgpuBindGroupLayout, a as TgpuBindGroup, W as Wgsl, b as TgpuRoot, A as AnyWgslData, c as TgpuFn, d as TgpuBufferUsage, I as Infer, e as TgpuAccessor, f as TgpuDerived, g as TgpuSlot, h as TgpuVertexLayout, i as WgslArray, D as Disarray, j as TgpuBuffer, k as AnyData, l as fn, m as bindGroupLayout, v as vertexLayout, n as fragmentFn, o as vertexFn, p as computeFn, q as privateVar, w as workgroupVar, r as constant, s as declare, t as sampler, u as comparisonSampler } from './tgpuComputeFn-DOUjhQua.js';
|
2
|
+
export { as as BindLayoutEntry, V as Configurable, ae as Eventual, at as ExtractBindGroupInputFromLayout, aL as INTERNAL_GlobalExt, a3 as IndexFlag, au as LayoutEntryToInput, R as RandomNameRegistry, am as Render, an as Sampled, $ as Storage, a0 as StorageFlag, S as StrictNameRegistry, al as TextureProps, af as TgpuAnyTextureView, a8 as TgpuBufferMutable, a9 as TgpuBufferReadonly, aa as TgpuBufferUniform, aI as TgpuComputeFn, aJ as TgpuComputeFnShell, a2 as TgpuComputePipeline, ao as TgpuConst, aK as TgpuDeclare, aD as TgpuFnShell, aG as TgpuFragmentFn, aH as TgpuFragmentFnShell, av as TgpuLayoutComparisonSampler, aw as TgpuLayoutEntry, ax as TgpuLayoutExternalTexture, ay as TgpuLayoutSampler, az as TgpuLayoutStorage, aA as TgpuLayoutStorageTexture, aB as TgpuLayoutTexture, aC as TgpuLayoutUniform, ab as TgpuMutable, ag as TgpuMutableTexture, ac as TgpuReadonly, ah as TgpuReadonlyTexture, a1 as TgpuRenderPipeline, ai as TgpuSampledTexture, ar as TgpuSampler, aj as TgpuTexture, ad as TgpuUniform, ap as TgpuVar, aE as TgpuVertexFn, aF as TgpuVertexFnShell, ak as TgpuWriteonlyTexture, a4 as Uniform, a5 as UniformFlag, aq as VariableScope, a6 as Vertex, a7 as VertexFlag, X as WithBinding, Y as WithCompute, Z as WithFragment, _ as WithVertex, x as isBuffer, Q as isBufferShorthand, C as isComparisonSampler, z as isDerived, F as isSampledTextureView, E as isSampler, B as isSlot, G as isStorageTextureView, H as isTexture, U as isTgpuFn, J as isUsableAsRender, K as isUsableAsSampled, L as isUsableAsStorage, P as isUsableAsUniform, y as isUsableAsVertex, M as unstable_asMutable, N as unstable_asReadonly, O as unstable_asUniform } from './tgpuComputeFn-DOUjhQua.js';
|
3
3
|
import 'tinyest';
|
4
4
|
|
5
|
+
/**
|
6
|
+
* The results of a WGSL resolution.
|
7
|
+
*
|
8
|
+
* @param code - The resolved code.
|
9
|
+
* @param usedBindGroupLayouts - List of used `tgpu.bindGroupLayout`s.
|
10
|
+
* @param catchall - Automatically constructed bind group for buffer usages and buffer shorthands, preceded by its index.
|
11
|
+
*/
|
12
|
+
interface ResolutionResult {
|
13
|
+
code: string;
|
14
|
+
usedBindGroupLayouts: TgpuBindGroupLayout[];
|
15
|
+
catchall: [number, TgpuBindGroup] | undefined;
|
16
|
+
}
|
17
|
+
|
5
18
|
interface TgpuResolveOptions {
|
6
19
|
/**
|
7
20
|
* Map of external names to their resolvable values.
|
@@ -17,12 +30,43 @@ interface TgpuResolveOptions {
|
|
17
30
|
* @default 'random'
|
18
31
|
*/
|
19
32
|
names?: 'strict' | 'random' | undefined;
|
20
|
-
/**
|
21
|
-
* Optional JIT transpiler for resolving TGSL functions.
|
22
|
-
* @experimental
|
23
|
-
*/
|
24
|
-
unstable_jitTranspiler?: JitTranspiler | undefined;
|
25
33
|
}
|
34
|
+
/**
|
35
|
+
* Resolves a template with external values. Each external will get resolved to a code string and replaced in the template.
|
36
|
+
* Any dependencies of the externals will also be resolved and included in the output.
|
37
|
+
* @param options - The options for the resolution.
|
38
|
+
*
|
39
|
+
* @returns {ResolutionResult}
|
40
|
+
*
|
41
|
+
* @example
|
42
|
+
* ```ts
|
43
|
+
* const Gradient = d.struct({
|
44
|
+
* from: d.vec3f,
|
45
|
+
* to: d.vec3f,
|
46
|
+
* });
|
47
|
+
*
|
48
|
+
* const { code, usedBindGroupLayouts, catchall } = tgpu.resolveWithContext({
|
49
|
+
* template: `
|
50
|
+
* fn getGradientAngle(gradient: Gradient) -> f32 {
|
51
|
+
* return atan(gradient.to.y - gradient.from.y, gradient.to.x - gradient.from.x);
|
52
|
+
* }
|
53
|
+
* `,
|
54
|
+
* externals: {
|
55
|
+
* Gradient,
|
56
|
+
* },
|
57
|
+
* });
|
58
|
+
*
|
59
|
+
* console.log(code);
|
60
|
+
* // struct Gradient_0 {
|
61
|
+
* // from: vec3f,
|
62
|
+
* // to: vec3f,
|
63
|
+
* // }
|
64
|
+
* // fn getGradientAngle(gradient: Gradient_0) -> f32 {
|
65
|
+
* // return atan(gradient.to.y - gradient.from.y, gradient.to.x - gradient.from.x);
|
66
|
+
* // }
|
67
|
+
* ```
|
68
|
+
*/
|
69
|
+
declare function resolveWithContext(options: TgpuResolveOptions): ResolutionResult;
|
26
70
|
/**
|
27
71
|
* Resolves a template with external values. Each external will get resolved to a code string and replaced in the template.
|
28
72
|
* Any dependencies of the externals will also be resolved and included in the output.
|
@@ -70,7 +114,6 @@ type InitOptions = {
|
|
70
114
|
} | undefined;
|
71
115
|
/** @default 'random' */
|
72
116
|
unstable_names?: 'random' | 'strict' | undefined;
|
73
|
-
unstable_jitTranspiler?: JitTranspiler | undefined;
|
74
117
|
};
|
75
118
|
/**
|
76
119
|
* Options passed into {@link initFromDevice}.
|
@@ -79,7 +122,6 @@ type InitFromDeviceOptions = {
|
|
79
122
|
device: GPUDevice;
|
80
123
|
/** @default 'random' */
|
81
124
|
unstable_names?: 'random' | 'strict' | undefined;
|
82
|
-
unstable_jitTranspiler?: JitTranspiler | undefined;
|
83
125
|
};
|
84
126
|
/**
|
85
127
|
* Requests a new GPU device and creates a root around it.
|
@@ -111,7 +153,7 @@ declare function init(options?: InitOptions): Promise<TgpuRoot>;
|
|
111
153
|
*/
|
112
154
|
declare function initFromDevice(options: InitFromDeviceOptions): TgpuRoot;
|
113
155
|
|
114
|
-
declare function accessor<T extends AnyWgslData>(schema: T, defaultValue?: TgpuFn<
|
156
|
+
declare function accessor<T extends AnyWgslData>(schema: T, defaultValue?: TgpuFn<() => T> | TgpuBufferUsage<T> | Infer<T>): TgpuAccessor<T>;
|
115
157
|
|
116
158
|
declare function derived<T>(compute: () => T): TgpuDerived<T>;
|
117
159
|
|
@@ -158,12 +200,18 @@ declare class MissingVertexBuffersError extends Error {
|
|
158
200
|
*/
|
159
201
|
|
160
202
|
declare const tgpu: {
|
203
|
+
fn: typeof fn;
|
161
204
|
bindGroupLayout: typeof bindGroupLayout;
|
162
205
|
vertexLayout: typeof vertexLayout;
|
206
|
+
slot: typeof slot;
|
163
207
|
init: typeof init;
|
164
208
|
initFromDevice: typeof initFromDevice;
|
165
209
|
resolve: typeof resolve;
|
210
|
+
resolveWithContext: typeof resolveWithContext;
|
166
211
|
'~unstable': {
|
212
|
+
/**
|
213
|
+
* @deprecated This feature is now stable, use tgpu.fn.
|
214
|
+
*/
|
167
215
|
fn: typeof fn;
|
168
216
|
fragmentFn: typeof fragmentFn;
|
169
217
|
vertexFn: typeof vertexFn;
|
@@ -173,6 +221,9 @@ declare const tgpu: {
|
|
173
221
|
*/
|
174
222
|
vertexLayout: typeof vertexLayout;
|
175
223
|
derived: typeof derived;
|
224
|
+
/**
|
225
|
+
* @deprecated This feature is now stable, use tgpu.slot.
|
226
|
+
*/
|
176
227
|
slot: typeof slot;
|
177
228
|
accessor: typeof accessor;
|
178
229
|
privateVar: typeof privateVar;
|
@@ -184,4 +235,4 @@ declare const tgpu: {
|
|
184
235
|
};
|
185
236
|
};
|
186
237
|
|
187
|
-
export { type InitFromDeviceOptions, type InitOptions, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError, TgpuAccessor, TgpuBindGroupLayout, TgpuBuffer, TgpuDerived, TgpuFn, TgpuRoot, TgpuSlot, TgpuVertexLayout, tgpu as default, tgpu };
|
238
|
+
export { type InitFromDeviceOptions, type InitOptions, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError, TgpuAccessor, TgpuBindGroup, TgpuBindGroupLayout, TgpuBuffer, TgpuDerived, TgpuFn, TgpuRoot, TgpuSlot, TgpuVertexLayout, tgpu as default, tgpu };
|