typegpu 0.5.3 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/{attributes-DSOqT8yA.d.cts → attributes-BcDZsQCE.d.cts} +1 -1
- package/{attributes-B4JpvOTz.d.ts → attributes-DsIdcdq4.d.ts} +1 -1
- package/chunk-A6AAWPBU.cjs +2 -0
- package/chunk-A6AAWPBU.cjs.map +1 -0
- package/chunk-HZAXWB4J.js +2 -0
- package/chunk-HZAXWB4J.js.map +1 -0
- package/chunk-T5Y2EQPZ.js +4 -0
- package/chunk-T5Y2EQPZ.js.map +1 -0
- package/chunk-VUYQ2ZIK.cjs +4 -0
- package/chunk-VUYQ2ZIK.cjs.map +1 -0
- package/data/index.cjs +1 -1
- package/data/index.cjs.map +1 -1
- package/data/index.d.cts +50 -4
- package/data/index.d.ts +50 -4
- package/data/index.js +1 -1
- package/{wgslTypes-VtSRoe90.d.ts → dataTypes-ts2Ccted.d.cts} +608 -506
- package/{wgslTypes-VtSRoe90.d.cts → dataTypes-ts2Ccted.d.ts} +608 -506
- package/index.cjs +19 -19
- package/index.cjs.map +1 -1
- package/index.d.cts +110 -443
- package/index.d.ts +110 -443
- package/index.js +19 -19
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/sampler-CPNwYXSH.d.ts +369 -0
- package/sampler-DeX4AnIZ.d.cts +369 -0
- package/std/index.cjs +1 -1
- package/std/index.cjs.map +1 -1
- package/std/index.d.cts +190 -47
- package/std/index.d.ts +190 -47
- package/std/index.js +1 -1
- package/std/index.js.map +1 -1
- package/chunk-DVZNNZFQ.js +0 -2
- package/chunk-DVZNNZFQ.js.map +0 -1
- package/chunk-FM3TKZFZ.cjs +0 -2
- package/chunk-FM3TKZFZ.cjs.map +0 -1
- package/chunk-M4VUFFPZ.cjs +0 -4
- package/chunk-M4VUFFPZ.cjs.map +0 -1
- package/chunk-RMXVIINO.js +0 -2
- package/chunk-RMXVIINO.js.map +0 -1
- package/chunk-UHU5Z2IS.js +0 -4
- package/chunk-UHU5Z2IS.js.map +0 -1
- package/chunk-UPPJES6W.cjs +0 -2
- package/chunk-UPPJES6W.cjs.map +0 -1
package/index.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import { A as AnyWgslData, T as TgpuNamable, I as Infer, F as F32, a as F16, b as I32, U as U32, V as Vec2f, c as Vec3f, d as Vec4f, e as Vec2h, f as Vec3h, g as Vec4h, h as Vec2i, i as Vec3i, j as Vec4i, k as Vec2u, l as Vec3u, m as Vec4u, D as Decorated, n as AnyWgslStruct, B as BaseData, L as Location, W as WgslStruct,
|
2
|
-
import { A as AnyAttribute, a as AnyComputeBuiltin, D as Decorate, I as IsBuiltin, H as HasCustomLocation, b as AnyFragmentInputBuiltin, c as AnyFragmentOutputBuiltin, O as OmitBuiltins } from './attributes-
|
1
|
+
import { A as AnyWgslData, T as TgpuNamable, I as Infer, $ as $internal, F as F32, a as F16, b as I32, U as U32, V as Vec2f, c as Vec3f, d as Vec4f, e as Vec2h, f as Vec3h, g as Vec4h, h as Vec2i, i as Vec3i, j as Vec4i, k as Vec2u, l as Vec3u, m as Vec4u, D as Decorated, n as AnyWgslStruct, o as $repr, B as BaseData, L as Location, W as WgslStruct, p as WgslArray, q as Disarray, r as AnyUnstruct, s as VertexFormat, t as TgpuVertexAttrib, K as KindToDefaultFormatMap, u as KindToAcceptedAttribMap, v as AnyData, O as OmitProps, P as Prettify, M as Mutable, w as WgslTypeLiteral, x as UnionToIntersection, y as InferPartial, z as MemIdentity, C as Default, E as InferGPU, G as AnyVecInstance, H as AnyMatInstance } from './dataTypes-ts2Ccted.js';
|
2
|
+
import { A as AnyAttribute, a as AnyComputeBuiltin, D as Decorate, I as IsBuiltin, H as HasCustomLocation, b as AnyFragmentInputBuiltin, c as AnyFragmentOutputBuiltin, O as OmitBuiltins } from './attributes-DsIdcdq4.js';
|
3
3
|
import * as smol from 'tinyest';
|
4
|
-
import { Block } from 'tinyest';
|
5
|
-
|
6
|
-
|
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-CPNwYXSH.js';
|
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-CPNwYXSH.js';
|
7
7
|
|
8
8
|
interface TgpuConst<TDataType extends AnyWgslData = AnyWgslData> extends TgpuNamable {
|
9
9
|
readonly value: Infer<TDataType>;
|
@@ -36,7 +36,7 @@ declare function declare(declaration: string): TgpuDeclare;
|
|
36
36
|
* Information extracted from transpiling a JS function.
|
37
37
|
*/
|
38
38
|
type TranspilationResult = {
|
39
|
-
argNames:
|
39
|
+
argNames: smol.ArgNames;
|
40
40
|
body: smol.Block;
|
41
41
|
/**
|
42
42
|
* All identifiers found in the function code that are not declared in the
|
@@ -63,24 +63,41 @@ type InferIO<T> = T extends {
|
|
63
63
|
} : T;
|
64
64
|
|
65
65
|
/**
|
66
|
-
* Describes a compute entry function signature (its arguments and
|
66
|
+
* Describes a compute entry function signature (its arguments, return type and workgroup size)
|
67
67
|
*/
|
68
|
-
|
69
|
-
readonly argTypes: [AnyWgslStruct];
|
68
|
+
type TgpuComputeFnShellHeader<ComputeIn extends Record<string, AnyComputeBuiltin>> = {
|
69
|
+
readonly argTypes: [AnyWgslStruct] | [];
|
70
70
|
readonly returnType: undefined;
|
71
71
|
readonly workgroupSize: [number, number, number];
|
72
|
+
readonly isEntry: true;
|
73
|
+
};
|
74
|
+
/**
|
75
|
+
* Describes a compute entry function signature (its arguments, return type and workgroup size).
|
76
|
+
* Allows creating tgpu compute functions by calling this shell
|
77
|
+
* and passing the implementation (as WGSL string or JS function) as the argument.
|
78
|
+
*/
|
79
|
+
type TgpuComputeFnShell<ComputeIn extends Record<string, AnyComputeBuiltin>> = TgpuComputeFnShellHeader<ComputeIn> /**
|
80
|
+
* Creates a type-safe implementation of this signature
|
81
|
+
*/ & ((implementation: (input: InferIO<ComputeIn>) => undefined) => TgpuComputeFn<ComputeIn>) &
|
82
|
+
/**
|
83
|
+
* @param implementation
|
84
|
+
* Raw WGSL function implementation with header and body
|
85
|
+
* without `fn` keyword and function name
|
86
|
+
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
87
|
+
*/
|
88
|
+
((implementation: string) => TgpuComputeFn<ComputeIn>) & ((strings: TemplateStringsArray, ...values: unknown[]) => TgpuComputeFn<ComputeIn>) & {
|
72
89
|
/**
|
73
|
-
*
|
90
|
+
* @deprecated Invoke the shell as a function instead.
|
74
91
|
*/
|
75
|
-
does(implementation: (input: InferIO<ComputeIn>) => undefined)
|
92
|
+
does: ((implementation: (input: InferIO<ComputeIn>) => undefined) => TgpuComputeFn<ComputeIn>) &
|
76
93
|
/**
|
77
94
|
* @param implementation
|
78
95
|
* Raw WGSL function implementation with header and body
|
79
96
|
* without `fn` keyword and function name
|
80
97
|
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
81
98
|
*/
|
82
|
-
|
83
|
-
}
|
99
|
+
((implementation: string) => TgpuComputeFn<ComputeIn>);
|
100
|
+
};
|
84
101
|
interface TgpuComputeFn<ComputeIn extends Record<string, AnyComputeBuiltin> = Record<string, AnyComputeBuiltin>> extends TgpuNamable {
|
85
102
|
readonly shell: TgpuComputeFnShell<ComputeIn>;
|
86
103
|
$uses(dependencyMap: Record<string, unknown>): this;
|
@@ -93,15 +110,6 @@ declare function computeFn<ComputeIn extends Record<string, AnyComputeBuiltin>>(
|
|
93
110
|
workgroupSize: number[];
|
94
111
|
}): TgpuComputeFnShell<ComputeIn>;
|
95
112
|
|
96
|
-
interface StorageFlag {
|
97
|
-
usableAsStorage: true;
|
98
|
-
}
|
99
|
-
/**
|
100
|
-
* @deprecated Use StorageFlag instead.
|
101
|
-
*/
|
102
|
-
type Storage = StorageFlag;
|
103
|
-
declare function isUsableAsStorage<T>(value: T): value is T & StorageFlag;
|
104
|
-
|
105
113
|
/**
|
106
114
|
* Used to transpile JS resources into SMoL on demand.
|
107
115
|
*/
|
@@ -132,7 +140,7 @@ declare class StrictNameRegistry implements NameRegistry {
|
|
132
140
|
|
133
141
|
interface TgpuSlot<T> extends TgpuNamable, Labelled {
|
134
142
|
readonly resourceType: 'slot';
|
135
|
-
|
143
|
+
[$repr]: Infer<T>;
|
136
144
|
readonly defaultValue: T | undefined;
|
137
145
|
/**
|
138
146
|
* Used to determine if code generated using either value `a` or `b` in place
|
@@ -144,7 +152,7 @@ interface TgpuSlot<T> extends TgpuNamable, Labelled {
|
|
144
152
|
interface TgpuDerived<T> {
|
145
153
|
readonly resourceType: 'derived';
|
146
154
|
readonly value: Infer<T>;
|
147
|
-
|
155
|
+
[$repr]: Infer<T>;
|
148
156
|
readonly '~providing'?: Providing | undefined;
|
149
157
|
with<TValue>(slot: TgpuSlot<TValue>, value: Eventual<TValue>): TgpuDerived<T>;
|
150
158
|
/**
|
@@ -154,7 +162,7 @@ interface TgpuDerived<T> {
|
|
154
162
|
}
|
155
163
|
interface TgpuAccessor<T extends AnyWgslData = AnyWgslData> extends TgpuNamable, Labelled {
|
156
164
|
readonly resourceType: 'accessor';
|
157
|
-
|
165
|
+
[$repr]: Infer<T>;
|
158
166
|
readonly schema: T;
|
159
167
|
readonly defaultValue: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T> | undefined;
|
160
168
|
readonly slot: TgpuSlot<TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>>;
|
@@ -187,26 +195,43 @@ type IOLayoutToSchema<T extends IOLayout> = T extends BaseData ? Decorate<T, Loc
|
|
187
195
|
type FragmentOutConstrained = Vec4f | Decorated<Vec4f, [Location<number>]> | AnyFragmentOutputBuiltin | IORecord<Vec4f | Decorated<Vec4f, [Location<number>]> | AnyFragmentOutputBuiltin>;
|
188
196
|
type FragmentInConstrained = IORecord<BaseIOData | Decorated<BaseIOData, AnyAttribute<never>[]> | AnyFragmentInputBuiltin>;
|
189
197
|
/**
|
190
|
-
* Describes a fragment entry function signature (its arguments
|
198
|
+
* Describes a fragment entry function signature (its arguments, return type and targets)
|
191
199
|
*/
|
192
|
-
|
193
|
-
readonly argTypes: [AnyWgslStruct];
|
200
|
+
type TgpuFragmentFnShellHeader<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = {
|
201
|
+
readonly argTypes: [AnyWgslStruct] | [];
|
194
202
|
readonly targets: FragmentOut;
|
195
203
|
readonly returnType: FragmentOut;
|
204
|
+
readonly isEntry: true;
|
205
|
+
};
|
206
|
+
/**
|
207
|
+
* Describes a fragment entry function signature (its arguments, return type and targets).
|
208
|
+
* Allows creating tgpu fragment functions by calling this shell
|
209
|
+
* and passing the implementation (as WGSL string or JS function) as the argument.
|
210
|
+
*/
|
211
|
+
type TgpuFragmentFnShell<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = TgpuFragmentFnShellHeader<FragmentIn, FragmentOut> /**
|
212
|
+
* Creates a type-safe implementation of this signature
|
213
|
+
*/ & ((implementation: (input: InferIO<FragmentIn>) => InferIO<FragmentOut>) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) &
|
214
|
+
/**
|
215
|
+
* @param implementation
|
216
|
+
* Raw WGSL function implementation with header and body
|
217
|
+
* without `fn` keyword and function name
|
218
|
+
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
219
|
+
*/
|
220
|
+
((implementation: string) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) & ((strings: TemplateStringsArray, ...values: unknown[]) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) & {
|
196
221
|
/**
|
197
|
-
*
|
222
|
+
* @deprecated Invoke the shell as a function instead.
|
198
223
|
*/
|
199
|
-
does(implementation: (input: InferIO<FragmentIn>) => InferIO<FragmentOut>)
|
224
|
+
does: ((implementation: (input: InferIO<FragmentIn>) => InferIO<FragmentOut>) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) &
|
200
225
|
/**
|
201
226
|
* @param implementation
|
202
227
|
* Raw WGSL function implementation with header and body
|
203
228
|
* without `fn` keyword and function name
|
204
229
|
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
205
230
|
*/
|
206
|
-
|
207
|
-
}
|
231
|
+
((implementation: string) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>);
|
232
|
+
};
|
208
233
|
interface TgpuFragmentFn<Varying extends FragmentInConstrained = FragmentInConstrained, Output extends FragmentOutConstrained = FragmentOutConstrained> extends TgpuNamable {
|
209
|
-
readonly shell:
|
234
|
+
readonly shell: TgpuFragmentFnShellHeader<Varying, Output>;
|
210
235
|
readonly outputType: IOLayoutToSchema<Output>;
|
211
236
|
$uses(dependencyMap: Record<string, unknown>): this;
|
212
237
|
}
|
@@ -219,26 +244,27 @@ declare function fragmentFn<FragmentIn extends FragmentInConstrained, FragmentOu
|
|
219
244
|
}): TgpuFragmentFnShell<FragmentIn, FragmentOut>;
|
220
245
|
|
221
246
|
/**
|
222
|
-
* Describes a vertex entry function signature (its arguments
|
247
|
+
* Describes a vertex entry function signature (its arguments, return type and attributes)
|
223
248
|
*/
|
224
|
-
|
225
|
-
readonly argTypes: [AnyWgslStruct];
|
249
|
+
type TgpuVertexFnShellHeader<VertexIn extends IOLayout, VertexOut extends IOLayout> = {
|
250
|
+
readonly argTypes: [AnyWgslStruct] | [];
|
226
251
|
readonly returnType: VertexOut;
|
227
252
|
readonly attributes: [VertexIn];
|
253
|
+
readonly isEntry: true;
|
254
|
+
};
|
255
|
+
/**
|
256
|
+
* Describes a vertex entry function signature (its arguments, return type and attributes).
|
257
|
+
* Allows creating tgpu vertex functions by calling this shell
|
258
|
+
* and passing the implementation (as WGSL string or JS function) as the argument.
|
259
|
+
*/
|
260
|
+
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>>) & {
|
228
261
|
/**
|
229
|
-
*
|
262
|
+
* @deprecated Invoke the shell as a function instead.
|
230
263
|
*/
|
231
|
-
does(implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>): TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut
|
232
|
-
|
233
|
-
* @param implementation
|
234
|
-
* Raw WGSL function implementation with header and body
|
235
|
-
* without `fn` keyword and function name
|
236
|
-
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
237
|
-
*/
|
238
|
-
does(implementation: string): TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>;
|
239
|
-
}
|
264
|
+
does: ((implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & ((implementation: string) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>);
|
265
|
+
};
|
240
266
|
interface TgpuVertexFn<VertexIn extends IOLayout = IOLayout, VertexOut extends IOLayout = IOLayout> extends TgpuNamable {
|
241
|
-
readonly shell:
|
267
|
+
readonly shell: TgpuVertexFnShellHeader<VertexIn, VertexOut>;
|
242
268
|
readonly outputType: IOLayoutToSchema<VertexOut>;
|
243
269
|
readonly inputType: IOLayoutToSchema<VertexIn>;
|
244
270
|
$uses(dependencyMap: Record<string, unknown>): this;
|
@@ -251,269 +277,6 @@ declare function vertexFn<VertexIn extends IORecord, VertexOut extends IORecord>
|
|
251
277
|
out: VertexOut;
|
252
278
|
}): TgpuVertexFnShell<VertexIn, VertexOut>;
|
253
279
|
|
254
|
-
type TextureProps = {
|
255
|
-
size: readonly number[];
|
256
|
-
format: GPUTextureFormat;
|
257
|
-
viewFormats?: GPUTextureFormat[] | undefined;
|
258
|
-
dimension?: GPUTextureDimension | undefined;
|
259
|
-
mipLevelCount?: number | undefined;
|
260
|
-
sampleCount?: number | undefined;
|
261
|
-
};
|
262
|
-
|
263
|
-
declare const texelFormatToChannelType: {
|
264
|
-
r8unorm: F32;
|
265
|
-
r8snorm: F32;
|
266
|
-
r8uint: U32;
|
267
|
-
r8sint: I32;
|
268
|
-
r16uint: U32;
|
269
|
-
r16sint: I32;
|
270
|
-
r16float: F32;
|
271
|
-
rg8unorm: F32;
|
272
|
-
rg8snorm: F32;
|
273
|
-
rg8uint: U32;
|
274
|
-
rg8sint: I32;
|
275
|
-
r32uint: U32;
|
276
|
-
r32sint: I32;
|
277
|
-
r32float: F32;
|
278
|
-
rg16uint: U32;
|
279
|
-
rg16sint: I32;
|
280
|
-
rg16float: F32;
|
281
|
-
rgba8unorm: F32;
|
282
|
-
'rgba8unorm-srgb': F32;
|
283
|
-
rgba8snorm: F32;
|
284
|
-
rgba8uint: U32;
|
285
|
-
rgba8sint: I32;
|
286
|
-
bgra8unorm: F32;
|
287
|
-
'bgra8unorm-srgb': F32;
|
288
|
-
rgb9e5ufloat: F32;
|
289
|
-
rgb10a2uint: U32;
|
290
|
-
rgb10a2unorm: F32;
|
291
|
-
rg11b10ufloat: F32;
|
292
|
-
rg32uint: U32;
|
293
|
-
rg32sint: I32;
|
294
|
-
rg32float: F32;
|
295
|
-
rgba16uint: U32;
|
296
|
-
rgba16sint: I32;
|
297
|
-
rgba16float: F32;
|
298
|
-
rgba32uint: U32;
|
299
|
-
rgba32sint: I32;
|
300
|
-
rgba32float: F32;
|
301
|
-
stencil8: F32;
|
302
|
-
depth16unorm: F32;
|
303
|
-
depth24plus: F32;
|
304
|
-
'depth24plus-stencil8': F32;
|
305
|
-
depth32float: F32;
|
306
|
-
'depth32float-stencil8': F32;
|
307
|
-
'bc1-rgba-unorm': F32;
|
308
|
-
'bc1-rgba-unorm-srgb': F32;
|
309
|
-
'bc2-rgba-unorm': F32;
|
310
|
-
'bc2-rgba-unorm-srgb': F32;
|
311
|
-
'bc3-rgba-unorm': F32;
|
312
|
-
'bc3-rgba-unorm-srgb': F32;
|
313
|
-
'bc4-r-unorm': F32;
|
314
|
-
'bc4-r-snorm': F32;
|
315
|
-
'bc5-rg-unorm': F32;
|
316
|
-
'bc5-rg-snorm': F32;
|
317
|
-
'bc6h-rgb-ufloat': F32;
|
318
|
-
'bc6h-rgb-float': F32;
|
319
|
-
'bc7-rgba-unorm': F32;
|
320
|
-
'bc7-rgba-unorm-srgb': F32;
|
321
|
-
'etc2-rgb8unorm': F32;
|
322
|
-
'etc2-rgb8unorm-srgb': F32;
|
323
|
-
'etc2-rgb8a1unorm': F32;
|
324
|
-
'etc2-rgb8a1unorm-srgb': F32;
|
325
|
-
'etc2-rgba8unorm': F32;
|
326
|
-
'etc2-rgba8unorm-srgb': F32;
|
327
|
-
'eac-r11unorm': F32;
|
328
|
-
'eac-r11snorm': F32;
|
329
|
-
'eac-rg11unorm': F32;
|
330
|
-
'eac-rg11snorm': F32;
|
331
|
-
'astc-4x4-unorm': F32;
|
332
|
-
'astc-4x4-unorm-srgb': F32;
|
333
|
-
'astc-5x4-unorm': F32;
|
334
|
-
'astc-5x4-unorm-srgb': F32;
|
335
|
-
'astc-5x5-unorm': F32;
|
336
|
-
'astc-5x5-unorm-srgb': F32;
|
337
|
-
'astc-6x5-unorm': F32;
|
338
|
-
'astc-6x5-unorm-srgb': F32;
|
339
|
-
'astc-6x6-unorm': F32;
|
340
|
-
'astc-6x6-unorm-srgb': F32;
|
341
|
-
'astc-8x5-unorm': F32;
|
342
|
-
'astc-8x5-unorm-srgb': F32;
|
343
|
-
'astc-8x6-unorm': F32;
|
344
|
-
'astc-8x6-unorm-srgb': F32;
|
345
|
-
'astc-8x8-unorm': F32;
|
346
|
-
'astc-8x8-unorm-srgb': F32;
|
347
|
-
'astc-10x5-unorm': F32;
|
348
|
-
'astc-10x5-unorm-srgb': F32;
|
349
|
-
'astc-10x6-unorm': F32;
|
350
|
-
'astc-10x6-unorm-srgb': F32;
|
351
|
-
'astc-10x8-unorm': F32;
|
352
|
-
'astc-10x8-unorm-srgb': F32;
|
353
|
-
'astc-10x10-unorm': F32;
|
354
|
-
'astc-10x10-unorm-srgb': F32;
|
355
|
-
'astc-12x10-unorm': F32;
|
356
|
-
'astc-12x10-unorm-srgb': F32;
|
357
|
-
'astc-12x12-unorm': F32;
|
358
|
-
'astc-12x12-unorm-srgb': F32;
|
359
|
-
};
|
360
|
-
type TexelFormatToChannelType = typeof texelFormatToChannelType;
|
361
|
-
type TexelFormatToStringChannels = {
|
362
|
-
[Key in keyof TexelFormatToChannelType]: TexelFormatToChannelType[Key]['type'];
|
363
|
-
};
|
364
|
-
type KeysWithValue<T extends Record<string, unknown>, TValue> = keyof {
|
365
|
-
[Key in keyof T as T[Key] extends TValue ? Key : never]: Key;
|
366
|
-
};
|
367
|
-
type ChannelTypeToLegalFormats = {
|
368
|
-
[Key in TexelFormatToChannelType[keyof TexelFormatToChannelType]['type']]: KeysWithValue<TexelFormatToStringChannels, Key>;
|
369
|
-
};
|
370
|
-
type SampleTypeToStringChannelType = {
|
371
|
-
float: 'f32';
|
372
|
-
'unfilterable-float': 'f32';
|
373
|
-
depth: 'f32';
|
374
|
-
sint: 'i32';
|
375
|
-
uint: 'u32';
|
376
|
-
};
|
377
|
-
type ViewDimensionToDimension = {
|
378
|
-
'1d': '1d';
|
379
|
-
'2d': '2d';
|
380
|
-
'2d-array': '2d';
|
381
|
-
'3d': '3d';
|
382
|
-
cube: '2d';
|
383
|
-
'cube-array': '2d';
|
384
|
-
};
|
385
|
-
/**
|
386
|
-
* https://www.w3.org/TR/WGSL/#storage-texel-formats
|
387
|
-
*/
|
388
|
-
type StorageTextureTexelFormat = 'rgba8unorm' | 'rgba8snorm' | 'rgba8uint' | 'rgba8sint' | 'rgba16uint' | 'rgba16sint' | 'rgba16float' | 'r32uint' | 'r32sint' | 'r32float' | 'rg32uint' | 'rg32sint' | 'rg32float' | 'rgba32uint' | 'rgba32sint' | 'rgba32float' | 'bgra8unorm';
|
389
|
-
declare const texelFormatToDataType: {
|
390
|
-
readonly rgba8unorm: Vec4f;
|
391
|
-
readonly rgba8snorm: Vec4f;
|
392
|
-
readonly rgba8uint: Vec4u;
|
393
|
-
readonly rgba8sint: Vec4i;
|
394
|
-
readonly rgba16uint: Vec4u;
|
395
|
-
readonly rgba16sint: Vec4i;
|
396
|
-
readonly rgba16float: Vec4f;
|
397
|
-
readonly r32uint: Vec4u;
|
398
|
-
readonly r32sint: Vec4i;
|
399
|
-
readonly r32float: Vec4f;
|
400
|
-
readonly rg32uint: Vec4u;
|
401
|
-
readonly rg32sint: Vec4i;
|
402
|
-
readonly rg32float: Vec4f;
|
403
|
-
readonly rgba32uint: Vec4u;
|
404
|
-
readonly rgba32sint: Vec4i;
|
405
|
-
readonly rgba32float: Vec4f;
|
406
|
-
readonly bgra8unorm: Vec4f;
|
407
|
-
};
|
408
|
-
declare const channelFormatToSchema: {
|
409
|
-
float: F32;
|
410
|
-
'unfilterable-float': F32;
|
411
|
-
uint: U32;
|
412
|
-
sint: I32;
|
413
|
-
depth: F32;
|
414
|
-
};
|
415
|
-
type ChannelFormatToSchema = typeof channelFormatToSchema;
|
416
|
-
type TexelFormatToDataType = typeof texelFormatToDataType;
|
417
|
-
type TexelFormatToDataTypeOrNever<T> = T extends keyof TexelFormatToDataType ? TexelFormatToDataType[T] : never;
|
418
|
-
/**
|
419
|
-
* Represents what formats a storage view can choose from based on its owner texture's props.
|
420
|
-
*/
|
421
|
-
type StorageFormatOptions<TProps extends TextureProps> = Extract<TProps['format'] | Default<TProps['viewFormats'], []>[number], StorageTextureTexelFormat>;
|
422
|
-
/**
|
423
|
-
* Represents what formats a sampled view can choose from based on its owner texture's props.
|
424
|
-
*/
|
425
|
-
type SampledFormatOptions<TProps extends TextureProps> = TProps['format'] | Default<TProps['viewFormats'], []>[number];
|
426
|
-
|
427
|
-
interface Sampled {
|
428
|
-
usableAsSampled: true;
|
429
|
-
}
|
430
|
-
interface Render {
|
431
|
-
usableAsRender: true;
|
432
|
-
}
|
433
|
-
type LiteralToExtensionMap = {
|
434
|
-
storage: StorageFlag;
|
435
|
-
sampled: Sampled;
|
436
|
-
render: Render;
|
437
|
-
};
|
438
|
-
type AllowedUsages<TProps extends TextureProps> = 'sampled' | 'render' | (TProps['format'] extends StorageTextureTexelFormat ? 'storage' : never);
|
439
|
-
declare function isUsableAsSampled<T>(value: T): value is T & Sampled;
|
440
|
-
declare function isUsableAsRender<T>(value: T): value is T & Render;
|
441
|
-
|
442
|
-
type ResolveStorageDimension<TDimension extends GPUTextureViewDimension, TProps extends TextureProps> = StorageTextureDimension extends TDimension ? Default<TProps['dimension'], '2d'> : TDimension extends StorageTextureDimension ? TDimension : '2d';
|
443
|
-
type ViewUsages$1<TProps extends TextureProps, TTexture extends TgpuTexture<TProps>> = boolean extends TTexture['usableAsSampled'] ? boolean extends TTexture['usableAsStorage'] ? never : 'readonly' | 'writeonly' | 'mutable' : boolean extends TTexture['usableAsStorage'] ? 'sampled' : 'readonly' | 'writeonly' | 'mutable' | 'sampled';
|
444
|
-
type ChannelData = U32 | I32 | F32;
|
445
|
-
type TexelData = Vec4u | Vec4i | Vec4f;
|
446
|
-
/**
|
447
|
-
* @param TProps all properties that distinguish this texture apart from other textures on the type level.
|
448
|
-
*/
|
449
|
-
interface TgpuTexture<TProps extends TextureProps = TextureProps> extends TgpuNamable {
|
450
|
-
readonly resourceType: 'texture';
|
451
|
-
readonly props: TProps;
|
452
|
-
readonly label: string | undefined;
|
453
|
-
readonly usableAsStorage: boolean;
|
454
|
-
readonly usableAsSampled: boolean;
|
455
|
-
readonly usableAsRender: boolean;
|
456
|
-
$usage<T extends AllowedUsages<TProps>[]>(...usages: T): this & UnionToIntersection<LiteralToExtensionMap[T[number]]>;
|
457
|
-
createView<TUsage extends ViewUsages$1<TProps, this>, TDimension extends 'sampled' extends TUsage ? GPUTextureViewDimension : StorageTextureDimension, TFormat extends 'sampled' extends TUsage ? SampledFormatOptions<TProps> : StorageFormatOptions<TProps>>(access: TUsage, params?: TextureViewParams<TDimension, TFormat>): {
|
458
|
-
mutable: TgpuMutableTexture<ResolveStorageDimension<TDimension, TProps>, TexelFormatToDataTypeOrNever<StorageFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat>>;
|
459
|
-
readonly: TgpuReadonlyTexture<ResolveStorageDimension<TDimension, TProps>, TexelFormatToDataTypeOrNever<StorageFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat>>;
|
460
|
-
writeonly: TgpuWriteonlyTexture<ResolveStorageDimension<TDimension, TProps>, TexelFormatToDataTypeOrNever<StorageFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat>>;
|
461
|
-
sampled: TgpuSampledTexture<GPUTextureViewDimension extends TDimension ? Default<TProps['dimension'], '2d'> : TDimension, TexelFormatToChannelType[SampledFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat]>;
|
462
|
-
}[TUsage];
|
463
|
-
destroy(): void;
|
464
|
-
}
|
465
|
-
type StorageTextureAccess = 'readonly' | 'writeonly' | 'mutable';
|
466
|
-
/**
|
467
|
-
* Based on @see GPUTextureViewDimension
|
468
|
-
* https://www.w3.org/TR/WGSL/#texture-depth
|
469
|
-
*/
|
470
|
-
type StorageTextureDimension = '1d' | '2d' | '2d-array' | '3d';
|
471
|
-
type TextureViewParams<TDimension extends GPUTextureViewDimension | undefined, TFormat extends GPUTextureFormat | undefined> = {
|
472
|
-
format?: TFormat;
|
473
|
-
dimension?: TDimension;
|
474
|
-
aspect?: GPUTextureAspect;
|
475
|
-
baseMipLevel?: number;
|
476
|
-
mipLevelCount?: number;
|
477
|
-
baseArrayLayout?: number;
|
478
|
-
arrayLayerCount?: number;
|
479
|
-
};
|
480
|
-
interface TgpuStorageTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> {
|
481
|
-
readonly resourceType: 'texture-storage-view';
|
482
|
-
readonly dimension: TDimension;
|
483
|
-
readonly texelDataType: TData;
|
484
|
-
readonly access: StorageTextureAccess;
|
485
|
-
}
|
486
|
-
/**
|
487
|
-
* A texture accessed as "readonly" storage on the GPU.
|
488
|
-
*/
|
489
|
-
interface TgpuReadonlyTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> extends TgpuStorageTexture<TDimension, TData> {
|
490
|
-
readonly access: 'readonly';
|
491
|
-
}
|
492
|
-
/**
|
493
|
-
* A texture accessed as "writeonly" storage on the GPU.
|
494
|
-
*/
|
495
|
-
interface TgpuWriteonlyTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> extends TgpuStorageTexture<TDimension, TData> {
|
496
|
-
readonly access: 'writeonly';
|
497
|
-
}
|
498
|
-
/**
|
499
|
-
* A texture accessed as "mutable" (or read_write) storage on the GPU.
|
500
|
-
*/
|
501
|
-
interface TgpuMutableTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> extends TgpuStorageTexture<TDimension, TData> {
|
502
|
-
readonly access: 'mutable';
|
503
|
-
}
|
504
|
-
/**
|
505
|
-
* A texture accessed as sampled on the GPU.
|
506
|
-
*/
|
507
|
-
interface TgpuSampledTexture<TDimension extends GPUTextureViewDimension = GPUTextureViewDimension, TData extends ChannelData = ChannelData> {
|
508
|
-
readonly resourceType: 'texture-sampled-view';
|
509
|
-
readonly dimension: TDimension;
|
510
|
-
readonly channelDataType: TData;
|
511
|
-
}
|
512
|
-
declare function isTexture<T extends TgpuTexture>(value: unknown | T): value is T;
|
513
|
-
declare function isStorageTextureView<T extends TgpuReadonlyTexture | TgpuWriteonlyTexture | TgpuMutableTexture>(value: unknown | T): value is T;
|
514
|
-
declare function isSampledTextureView<T extends TgpuSampledTexture>(value: unknown | T): value is T;
|
515
|
-
type TgpuAnyTextureView = TgpuReadonlyTexture | TgpuWriteonlyTexture | TgpuMutableTexture | TgpuSampledTexture;
|
516
|
-
|
517
280
|
/**
|
518
281
|
* The array can hold T, where T is a single/multi-component numeric, or a struct with members of type T.
|
519
282
|
* Examples of valid array members:
|
@@ -522,7 +285,7 @@ type TgpuAnyTextureView = TgpuReadonlyTexture | TgpuWriteonlyTexture | TgpuMutab
|
|
522
285
|
* - WgslStruct<{ a: Vec3f, b: unorm8x2 }>
|
523
286
|
* - WgslStruct<{ nested: WgslStruct<{ a: Vec3f }> }>
|
524
287
|
*/
|
525
|
-
type DataToContainedAttribs<T> = T extends AnyWgslStruct |
|
288
|
+
type DataToContainedAttribs<T> = T extends AnyWgslStruct | AnyUnstruct ? {
|
526
289
|
[Key in keyof T['propTypes']]: DataToContainedAttribs<T['propTypes'][Key]>;
|
527
290
|
} : T extends {
|
528
291
|
type: VertexFormat;
|
@@ -656,100 +419,6 @@ interface DepthStencilAttachment {
|
|
656
419
|
stencilReadOnly?: boolean;
|
657
420
|
}
|
658
421
|
|
659
|
-
interface SamplerProps {
|
660
|
-
addressModeU?: GPUAddressMode;
|
661
|
-
addressModeV?: GPUAddressMode;
|
662
|
-
/**
|
663
|
-
* Specifies the address modes for the texture width, height, and depth
|
664
|
-
* coordinates, respectively.
|
665
|
-
*/
|
666
|
-
addressModeW?: GPUAddressMode;
|
667
|
-
/**
|
668
|
-
* Specifies the sampling behavior when the sample footprint is smaller than or equal to one
|
669
|
-
* texel.
|
670
|
-
*/
|
671
|
-
magFilter?: GPUFilterMode;
|
672
|
-
/**
|
673
|
-
* Specifies the sampling behavior when the sample footprint is larger than one texel.
|
674
|
-
*/
|
675
|
-
minFilter?: GPUFilterMode;
|
676
|
-
/**
|
677
|
-
* Specifies behavior for sampling between mipmap levels.
|
678
|
-
*/
|
679
|
-
mipmapFilter?: GPUMipmapFilterMode;
|
680
|
-
lodMinClamp?: number;
|
681
|
-
/**
|
682
|
-
* Specifies the minimum and maximum levels of detail, respectively, used internally when
|
683
|
-
* sampling a texture.
|
684
|
-
*/
|
685
|
-
lodMaxClamp?: number;
|
686
|
-
/**
|
687
|
-
* Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is
|
688
|
-
* enabled when {@link GPUSamplerDescriptor.maxAnisotropy} is > 1 and the implementation supports it.
|
689
|
-
* Anisotropic filtering improves the image quality of textures sampled at oblique viewing
|
690
|
-
* angles. Higher {@link GPUSamplerDescriptor.maxAnisotropy} values indicate the maximum ratio of
|
691
|
-
* anisotropy supported when filtering.
|
692
|
-
*
|
693
|
-
* Most implementations support {@link GPUSamplerDescriptor.maxAnisotropy} values in range
|
694
|
-
* between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor.maxAnisotropy}
|
695
|
-
* will be clamped to the maximum value that the platform supports.
|
696
|
-
* The precise filtering behavior is implementation-dependent.
|
697
|
-
*/
|
698
|
-
maxAnisotropy?: number;
|
699
|
-
}
|
700
|
-
interface ComparisonSamplerProps {
|
701
|
-
compare: GPUCompareFunction;
|
702
|
-
addressModeU?: GPUAddressMode;
|
703
|
-
addressModeV?: GPUAddressMode;
|
704
|
-
/**
|
705
|
-
* Specifies the address modes for the texture width, height, and depth
|
706
|
-
* coordinates, respectively.
|
707
|
-
*/
|
708
|
-
addressModeW?: GPUAddressMode;
|
709
|
-
/**
|
710
|
-
* Specifies the sampling behavior when the sample footprint is smaller than or equal to one
|
711
|
-
* texel.
|
712
|
-
*/
|
713
|
-
magFilter?: GPUFilterMode;
|
714
|
-
/**
|
715
|
-
* Specifies the sampling behavior when the sample footprint is larger than one texel.
|
716
|
-
*/
|
717
|
-
minFilter?: GPUFilterMode;
|
718
|
-
/**
|
719
|
-
* Specifies behavior for sampling between mipmap levels.
|
720
|
-
*/
|
721
|
-
mipmapFilter?: GPUMipmapFilterMode;
|
722
|
-
lodMinClamp?: number;
|
723
|
-
/**
|
724
|
-
* Specifies the minimum and maximum levels of detail, respectively, used internally when
|
725
|
-
* sampling a texture.
|
726
|
-
*/
|
727
|
-
lodMaxClamp?: number;
|
728
|
-
/**
|
729
|
-
* Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is
|
730
|
-
* enabled when {@link GPUSamplerDescriptor.maxAnisotropy} is > 1 and the implementation supports it.
|
731
|
-
* Anisotropic filtering improves the image quality of textures sampled at oblique viewing
|
732
|
-
* angles. Higher {@link GPUSamplerDescriptor.maxAnisotropy} values indicate the maximum ratio of
|
733
|
-
* anisotropy supported when filtering.
|
734
|
-
*
|
735
|
-
* Most implementations support {@link GPUSamplerDescriptor.maxAnisotropy} values in range
|
736
|
-
* between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor.maxAnisotropy}
|
737
|
-
* will be clamped to the maximum value that the platform supports.
|
738
|
-
* The precise filtering behavior is implementation-dependent.
|
739
|
-
*/
|
740
|
-
maxAnisotropy?: number;
|
741
|
-
}
|
742
|
-
interface TgpuSampler {
|
743
|
-
readonly resourceType: 'sampler';
|
744
|
-
}
|
745
|
-
interface TgpuComparisonSampler {
|
746
|
-
readonly resourceType: 'sampler-comparison';
|
747
|
-
}
|
748
|
-
declare function sampler(props: SamplerProps): TgpuSampler;
|
749
|
-
declare function comparisonSampler(props: ComparisonSamplerProps): TgpuComparisonSampler;
|
750
|
-
declare function isSampler(resource: unknown): resource is TgpuSampler;
|
751
|
-
declare function isComparisonSampler(resource: unknown): resource is TgpuComparisonSampler;
|
752
|
-
|
753
422
|
interface Unwrapper {
|
754
423
|
readonly device: GPUDevice;
|
755
424
|
unwrap(resource: TgpuComputePipeline): GPUComputePipeline;
|
@@ -1126,6 +795,12 @@ interface TgpuBindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | n
|
|
1126
795
|
readonly bound: {
|
1127
796
|
[K in keyof Entries]: BindLayoutEntry<Entries[K]>;
|
1128
797
|
};
|
798
|
+
readonly value: {
|
799
|
+
[K in keyof Entries]: InferLayoutEntry<Entries[K]>;
|
800
|
+
};
|
801
|
+
readonly $: {
|
802
|
+
[K in keyof Entries]: InferLayoutEntry<Entries[K]>;
|
803
|
+
};
|
1129
804
|
/**
|
1130
805
|
* An explicit numeric index assigned to this bind group layout. If undefined, a unique
|
1131
806
|
* index is assigned automatically during resolution. This can be changed with the
|
@@ -1139,12 +814,6 @@ interface TgpuBindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | n
|
|
1139
814
|
* Used when generating WGSL code: `@group(${index}) @binding(...) ...;`
|
1140
815
|
*/
|
1141
816
|
$idx(index?: number): this;
|
1142
|
-
/**
|
1143
|
-
* @deprecated Use the `root.createBindGroup` API instead, accessible through `await tgpu.init()`
|
1144
|
-
*/
|
1145
|
-
populate(entries: {
|
1146
|
-
[K in keyof OmitProps<Entries, null>]: LayoutEntryToInput<Entries[K]>;
|
1147
|
-
}): TgpuBindGroup<Entries>;
|
1148
817
|
/**
|
1149
818
|
* Creates a raw WebGPU resource based on the typed descriptor.
|
1150
819
|
* NOTE: This creates a new resource every time, better to use `root.unwrap(...)` instead.
|
@@ -1177,7 +846,8 @@ type GetStorageTextureRestriction<T extends TgpuLayoutStorageTexture> = Default<
|
|
1177
846
|
dimension: Dimension;
|
1178
847
|
} : never;
|
1179
848
|
type LayoutEntryToInput<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? (TgpuBuffer<UnwrapRuntimeConstructor<T['uniform']>> & UniformFlag) | GPUBuffer : T extends TgpuLayoutStorage ? (TgpuBuffer<UnwrapRuntimeConstructor<T['storage']>> & StorageFlag) | GPUBuffer : T extends TgpuLayoutSampler ? TgpuSampler | GPUSampler : T extends TgpuLayoutComparisonSampler ? TgpuComparisonSampler | GPUSampler : T extends TgpuLayoutTexture ? GPUTextureView | (Sampled & TgpuTexture<Prettify<TextureProps & GetTextureRestriction<T>>>) | TgpuSampledTexture<Default<T['viewDimension'], '2d'>, ChannelFormatToSchema[T['texture']]> : T extends TgpuLayoutStorageTexture ? GPUTextureView | (StorageFlag & TgpuTexture<Prettify<TextureProps & GetStorageTextureRestriction<T>>>) | StorageTextureUsageForEntry<T> : T extends TgpuLayoutExternalTexture ? GPUExternalTexture : never;
|
1180
|
-
type BindLayoutEntry<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? TgpuBufferUniform<
|
849
|
+
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;
|
850
|
+
type InferLayoutEntry<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? Infer<T['uniform']> : T extends TgpuLayoutStorage ? Infer<UnwrapRuntimeConstructor<T['storage']>> : T extends TgpuLayoutSampler ? TgpuSampler : T extends TgpuLayoutComparisonSampler ? TgpuComparisonSampler : T extends TgpuLayoutTexture ? TgpuSampledTexture<Default<GetDimension<T['viewDimension']>, '2d'>, ChannelFormatToSchema[T['texture']]> : T extends TgpuLayoutStorageTexture ? StorageTextureUsageForEntry<T> : never;
|
1181
851
|
type TgpuBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>> = {
|
1182
852
|
readonly resourceType: 'bind-group';
|
1183
853
|
readonly layout: TgpuBindGroupLayout<Entries>;
|
@@ -1188,7 +858,7 @@ declare function bindGroupLayout<Entries extends Record<string, TgpuLayoutEntry
|
|
1188
858
|
interface TgpuBufferUsage<TData extends BaseData = BaseData, TUsage extends BindableBufferUsage = BindableBufferUsage> {
|
1189
859
|
readonly resourceType: 'buffer-usage';
|
1190
860
|
readonly usage: TUsage;
|
1191
|
-
readonly
|
861
|
+
readonly [$repr]: Infer<TData>;
|
1192
862
|
value: InferGPU<TData>;
|
1193
863
|
readonly [$internal]: {
|
1194
864
|
readonly dataType: TData;
|
@@ -1247,20 +917,16 @@ declare function workgroupVar<TDataType extends AnyWgslData>(dataType: TDataType
|
|
1247
917
|
type ResolvableObject = SelfResolvable | TgpuBufferUsage | TgpuConst | TgpuDeclare | TgpuFn | TgpuComputeFn | TgpuFragmentFn | TgpuComputePipeline | TgpuRenderPipeline | TgpuVertexFn | TgpuSampler | TgpuAccessor | TgpuExternalTexture | TgpuTexture | TgpuAnyTextureView | TgpuVar | AnyVecInstance | AnyMatInstance | AnyData | TgpuFn<any, any>;
|
1248
918
|
type Wgsl = Eventual<string | number | boolean | ResolvableObject>;
|
1249
919
|
declare const UnknownData: {
|
1250
|
-
type:
|
920
|
+
type: "unknown";
|
1251
921
|
};
|
1252
922
|
type UnknownData = typeof UnknownData;
|
1253
|
-
|
1254
|
-
type: "void";
|
1255
|
-
};
|
1256
|
-
type Void = typeof Void;
|
1257
|
-
type Resource = {
|
923
|
+
type Snippet = {
|
1258
924
|
value: unknown;
|
1259
|
-
dataType:
|
925
|
+
dataType: AnyData | UnknownData;
|
1260
926
|
};
|
1261
927
|
type TgpuShaderStage = 'compute' | 'vertex' | 'fragment';
|
1262
928
|
interface FnToWgslOptions {
|
1263
|
-
args:
|
929
|
+
args: Snippet[];
|
1264
930
|
returnType: AnyWgslData;
|
1265
931
|
body: Block;
|
1266
932
|
externalMap: Record<string, unknown>;
|
@@ -1276,14 +942,14 @@ interface ItemStateStack {
|
|
1276
942
|
popItem(): void;
|
1277
943
|
pushSlotBindings(pairs: SlotValuePair<unknown>[]): void;
|
1278
944
|
popSlotBindings(): void;
|
1279
|
-
pushFunctionScope(args:
|
945
|
+
pushFunctionScope(args: Snippet[], returnType: AnyWgslData | undefined, externalMap: Record<string, unknown>): void;
|
1280
946
|
popFunctionScope(): void;
|
1281
947
|
pushBlockScope(): void;
|
1282
948
|
popBlockScope(): void;
|
1283
949
|
pop(type?: 'functionScope' | 'blockScope' | 'slotBinding' | 'item'): void;
|
1284
950
|
readSlot<T>(slot: TgpuSlot<T>): T | undefined;
|
1285
|
-
|
1286
|
-
defineBlockVariable(id: string, type: AnyWgslData | UnknownData):
|
951
|
+
getSnippetById(id: string): Snippet | undefined;
|
952
|
+
defineBlockVariable(id: string, type: AnyWgslData | UnknownData): Snippet;
|
1287
953
|
}
|
1288
954
|
/**
|
1289
955
|
* Passed into each resolvable item. All items in a tree share a resolution ctx,
|
@@ -1315,7 +981,7 @@ interface ResolutionCtx {
|
|
1315
981
|
resolve(item: unknown): string;
|
1316
982
|
resolveValue<T extends BaseData>(value: Infer<T>, schema: T): string;
|
1317
983
|
transpileFn(fn: string): {
|
1318
|
-
argNames:
|
984
|
+
argNames: ArgNames;
|
1319
985
|
body: Block;
|
1320
986
|
externalNames: string[];
|
1321
987
|
};
|
@@ -1344,36 +1010,37 @@ type BindableBufferUsage = 'uniform' | 'readonly' | 'mutable';
|
|
1344
1010
|
/**
|
1345
1011
|
* Describes a function signature (its arguments and return type)
|
1346
1012
|
*/
|
1347
|
-
|
1013
|
+
type TgpuFnShellHeader<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = AnyWgslData | undefined> = {
|
1348
1014
|
readonly argTypes: Args;
|
1349
1015
|
readonly returnType: Return | undefined;
|
1016
|
+
readonly isEntry: false;
|
1017
|
+
};
|
1018
|
+
/**
|
1019
|
+
* Describes a function signature (its arguments and return type).
|
1020
|
+
* Allows creating tgpu functions by calling this shell
|
1021
|
+
* and passing the implementation (as WGSL string or JS function) as the argument.
|
1022
|
+
*/
|
1023
|
+
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>) & {
|
1350
1024
|
/**
|
1351
|
-
*
|
1352
|
-
*/
|
1353
|
-
does(implementation: (...args: InferArgs<Args>) => InferReturn<Return>): TgpuFn<Args, Return>;
|
1354
|
-
/**
|
1355
|
-
* @param implementation
|
1356
|
-
* Raw WGSL function implementation with header and body
|
1357
|
-
* without `fn` keyword and function name
|
1358
|
-
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
1025
|
+
* @deprecated Invoke the shell as a function instead.
|
1359
1026
|
*/
|
1360
|
-
does(implementation:
|
1361
|
-
}
|
1362
|
-
interface TgpuFnBase<Args extends AnyWgslData[], Return extends AnyWgslData | undefined = undefined> extends TgpuNamable, Labelled {
|
1027
|
+
does: ((implementation: (...args: Args extends AnyWgslData[] ? InferArgs<Args> : [InferIO<Args>]) => InferReturn<Return>) => TgpuFn<Args, Return>) & ((implementation: string) => TgpuFn<Args, Return>);
|
1028
|
+
};
|
1029
|
+
interface TgpuFnBase<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = undefined> extends TgpuNamable, Labelled {
|
1363
1030
|
readonly resourceType: 'function';
|
1364
|
-
readonly shell:
|
1031
|
+
readonly shell: TgpuFnShellHeader<Args, Return>;
|
1365
1032
|
readonly '~providing'?: Providing | undefined;
|
1366
1033
|
$uses(dependencyMap: Record<string, unknown>): this;
|
1367
1034
|
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TgpuFn<Args, Return>;
|
1368
1035
|
with<T extends AnyWgslData>(accessor: TgpuAccessor<T>, value: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>): TgpuFn<Args, Return>;
|
1369
1036
|
}
|
1370
|
-
type TgpuFn<Args extends AnyWgslData[] = AnyWgslData[], Return extends AnyWgslData | undefined = AnyWgslData | undefined> = TgpuFnBase<Args, Return> & ((...args: InferArgs<Args>) => InferReturn<Return>) & {
|
1037
|
+
type TgpuFn<Args extends AnyWgslData[] | Record<string, AnyWgslData> = AnyWgslData[], Return extends AnyWgslData | undefined = AnyWgslData | undefined> = TgpuFnBase<Args, Return> & ((...args: Args extends AnyWgslData[] ? InferArgs<Args> : Args extends Record<string, never> ? [] : [InferIO<Args>]) => InferReturn<Return>) & {
|
1371
1038
|
readonly [$internal]: {
|
1372
|
-
implementation: Implementation<InferArgs<Args
|
1039
|
+
implementation: Implementation<Args extends AnyWgslData[] ? InferArgs<Args> : Args extends Record<string, never> ? [] : [InferIO<Args>], InferReturn<Return>>;
|
1373
1040
|
};
|
1374
1041
|
};
|
1375
|
-
declare function fn<Args extends AnyWgslData[] | []>(argTypes: Args, returnType?: undefined): TgpuFnShell<Args, undefined>;
|
1376
|
-
declare function fn<Args extends AnyWgslData[] | [], Return extends AnyWgslData>(argTypes: Args, returnType: Return): TgpuFnShell<Args, Return>;
|
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>;
|
1377
1044
|
declare function isTgpuFn<Args extends AnyWgslData[], Return extends AnyWgslData | undefined = undefined>(value: unknown | TgpuFn<Args, Return>): value is TgpuFn<Args, Return>;
|
1378
1045
|
|
1379
1046
|
interface TgpuResolveOptions {
|
@@ -1556,4 +1223,4 @@ declare const tgpu: {
|
|
1556
1223
|
};
|
1557
1224
|
};
|
1558
1225
|
|
1559
|
-
export { type BindLayoutEntry, type Eventual, type InitFromDeviceOptions, type InitOptions, type LayoutEntryToInput, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, RandomNameRegistry,
|
1226
|
+
export { type BindLayoutEntry, type Eventual, type InitFromDeviceOptions, type InitOptions, type LayoutEntryToInput, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, RandomNameRegistry, Render, ResolutionError, Sampled, StorageFlag, StrictNameRegistry, TextureProps, type TgpuAccessor, TgpuAnyTextureView, type TgpuBindGroup, type TgpuBindGroupLayout, type TgpuBuffer, type TgpuBufferMutable, type TgpuBufferReadonly, type TgpuBufferUniform, type TgpuComputeFn, type TgpuComputeFnShell, type TgpuComputePipeline, type TgpuConst, type TgpuDeclare, type TgpuDerived, type TgpuFn, type TgpuFnShell, type TgpuFragmentFn, type TgpuFragmentFnShell, type TgpuLayoutComparisonSampler, type TgpuLayoutEntry, type TgpuLayoutExternalTexture, type TgpuLayoutSampler, type TgpuLayoutStorage, type TgpuLayoutStorageTexture, type TgpuLayoutTexture, type TgpuLayoutUniform, TgpuMutableTexture, TgpuReadonlyTexture, type TgpuRenderPipeline, type TgpuRoot, TgpuSampledTexture, TgpuSampler, type TgpuSlot, TgpuTexture, type TgpuVar, type TgpuVertexFn, type TgpuVertexFnShell, type TgpuVertexLayout, TgpuWriteonlyTexture, type Uniform, type UniformFlag, type VariableScope, type Vertex, type VertexFlag, type WithBinding, type WithCompute, type WithFragment, type WithVertex, tgpu as default, isBuffer, isDerived, isSlot, isTgpuFn, isUsableAsUniform, isUsableAsVertex, tgpu, asMutable as unstable_asMutable, asReadonly as unstable_asReadonly, asUniform as unstable_asUniform };
|