typegpu 0.5.4 → 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/attributes-BcDZsQCE.d.cts +159 -0
- package/attributes-DsIdcdq4.d.ts +159 -0
- 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 +3 -4
- package/data/index.d.ts +3 -4
- package/data/index.js +1 -1
- package/{wgslTypes-Bh2dG5qv.d.cts → dataTypes-ts2Ccted.d.cts} +300 -6
- package/{wgslTypes-Bh2dG5qv.d.ts → dataTypes-ts2Ccted.d.ts} +300 -6
- package/index.cjs +19 -19
- package/index.cjs.map +1 -1
- package/index.d.cts +25 -397
- package/index.d.ts +25 -397
- package/index.js +19 -19
- package/index.js.map +1 -1
- package/package.json +1 -1
- 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 +85 -50
- package/std/index.d.ts +85 -50
- package/std/index.js +1 -1
- package/std/index.js.map +1 -1
- package/attributes-BdU8hyQq.d.cts +0 -435
- package/attributes-CAsvE5Z9.d.ts +0 -435
- package/chunk-5PJ3H5OR.js +0 -2
- package/chunk-5PJ3H5OR.js.map +0 -1
- package/chunk-7UUBX6MC.cjs +0 -4
- package/chunk-7UUBX6MC.cjs.map +0 -1
- package/chunk-AKBL6GDL.js +0 -4
- package/chunk-AKBL6GDL.js.map +0 -1
- package/chunk-URJCMUTT.cjs +0 -2
- package/chunk-URJCMUTT.cjs.map +0 -1
package/index.d.cts
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,
|
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
|
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.cjs';
|
2
|
+
import { A as AnyAttribute, a as AnyComputeBuiltin, D as Decorate, I as IsBuiltin, H as HasCustomLocation, b as AnyFragmentInputBuiltin, c as AnyFragmentOutputBuiltin, O as OmitBuiltins } from './attributes-BcDZsQCE.cjs';
|
3
3
|
import * as smol from 'tinyest';
|
4
4
|
import { ArgNames, Block } from 'tinyest';
|
5
|
-
|
6
|
-
|
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-DeX4AnIZ.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-DeX4AnIZ.cjs';
|
7
7
|
|
8
8
|
interface TgpuConst<TDataType extends AnyWgslData = AnyWgslData> extends TgpuNamable {
|
9
9
|
readonly value: Infer<TDataType>;
|
@@ -66,9 +66,10 @@ type InferIO<T> = T extends {
|
|
66
66
|
* Describes a compute entry function signature (its arguments, return type and workgroup size)
|
67
67
|
*/
|
68
68
|
type TgpuComputeFnShellHeader<ComputeIn extends Record<string, AnyComputeBuiltin>> = {
|
69
|
-
readonly argTypes: [AnyWgslStruct];
|
69
|
+
readonly argTypes: [AnyWgslStruct] | [];
|
70
70
|
readonly returnType: undefined;
|
71
71
|
readonly workgroupSize: [number, number, number];
|
72
|
+
readonly isEntry: true;
|
72
73
|
};
|
73
74
|
/**
|
74
75
|
* Describes a compute entry function signature (its arguments, return type and workgroup size).
|
@@ -84,7 +85,7 @@ type TgpuComputeFnShell<ComputeIn extends Record<string, AnyComputeBuiltin>> = T
|
|
84
85
|
* without `fn` keyword and function name
|
85
86
|
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
86
87
|
*/
|
87
|
-
((implementation: string) => TgpuComputeFn<ComputeIn>) & {
|
88
|
+
((implementation: string) => TgpuComputeFn<ComputeIn>) & ((strings: TemplateStringsArray, ...values: unknown[]) => TgpuComputeFn<ComputeIn>) & {
|
88
89
|
/**
|
89
90
|
* @deprecated Invoke the shell as a function instead.
|
90
91
|
*/
|
@@ -109,15 +110,6 @@ declare function computeFn<ComputeIn extends Record<string, AnyComputeBuiltin>>(
|
|
109
110
|
workgroupSize: number[];
|
110
111
|
}): TgpuComputeFnShell<ComputeIn>;
|
111
112
|
|
112
|
-
interface StorageFlag {
|
113
|
-
usableAsStorage: true;
|
114
|
-
}
|
115
|
-
/**
|
116
|
-
* @deprecated Use StorageFlag instead.
|
117
|
-
*/
|
118
|
-
type Storage = StorageFlag;
|
119
|
-
declare function isUsableAsStorage<T>(value: T): value is T & StorageFlag;
|
120
|
-
|
121
113
|
/**
|
122
114
|
* Used to transpile JS resources into SMoL on demand.
|
123
115
|
*/
|
@@ -206,9 +198,10 @@ type FragmentInConstrained = IORecord<BaseIOData | Decorated<BaseIOData, AnyAttr
|
|
206
198
|
* Describes a fragment entry function signature (its arguments, return type and targets)
|
207
199
|
*/
|
208
200
|
type TgpuFragmentFnShellHeader<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = {
|
209
|
-
readonly argTypes: [AnyWgslStruct];
|
201
|
+
readonly argTypes: [AnyWgslStruct] | [];
|
210
202
|
readonly targets: FragmentOut;
|
211
203
|
readonly returnType: FragmentOut;
|
204
|
+
readonly isEntry: true;
|
212
205
|
};
|
213
206
|
/**
|
214
207
|
* Describes a fragment entry function signature (its arguments, return type and targets).
|
@@ -224,7 +217,7 @@ type TgpuFragmentFnShell<FragmentIn extends FragmentInConstrained, FragmentOut e
|
|
224
217
|
* without `fn` keyword and function name
|
225
218
|
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
226
219
|
*/
|
227
|
-
((implementation: string) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) & {
|
220
|
+
((implementation: string) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) & ((strings: TemplateStringsArray, ...values: unknown[]) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>) & {
|
228
221
|
/**
|
229
222
|
* @deprecated Invoke the shell as a function instead.
|
230
223
|
*/
|
@@ -254,16 +247,17 @@ declare function fragmentFn<FragmentIn extends FragmentInConstrained, FragmentOu
|
|
254
247
|
* Describes a vertex entry function signature (its arguments, return type and attributes)
|
255
248
|
*/
|
256
249
|
type TgpuVertexFnShellHeader<VertexIn extends IOLayout, VertexOut extends IOLayout> = {
|
257
|
-
readonly argTypes: [AnyWgslStruct];
|
250
|
+
readonly argTypes: [AnyWgslStruct] | [];
|
258
251
|
readonly returnType: VertexOut;
|
259
252
|
readonly attributes: [VertexIn];
|
253
|
+
readonly isEntry: true;
|
260
254
|
};
|
261
255
|
/**
|
262
256
|
* Describes a vertex entry function signature (its arguments, return type and attributes).
|
263
257
|
* Allows creating tgpu vertex functions by calling this shell
|
264
258
|
* and passing the implementation (as WGSL string or JS function) as the argument.
|
265
259
|
*/
|
266
|
-
type TgpuVertexFnShell<VertexIn extends IOLayout, VertexOut extends IOLayout> = TgpuVertexFnShellHeader<VertexIn, VertexOut> & ((implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & ((implementation: string) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & {
|
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>>) & {
|
267
261
|
/**
|
268
262
|
* @deprecated Invoke the shell as a function instead.
|
269
263
|
*/
|
@@ -283,269 +277,6 @@ declare function vertexFn<VertexIn extends IORecord, VertexOut extends IORecord>
|
|
283
277
|
out: VertexOut;
|
284
278
|
}): TgpuVertexFnShell<VertexIn, VertexOut>;
|
285
279
|
|
286
|
-
type TextureProps = {
|
287
|
-
size: readonly number[];
|
288
|
-
format: GPUTextureFormat;
|
289
|
-
viewFormats?: GPUTextureFormat[] | undefined;
|
290
|
-
dimension?: GPUTextureDimension | undefined;
|
291
|
-
mipLevelCount?: number | undefined;
|
292
|
-
sampleCount?: number | undefined;
|
293
|
-
};
|
294
|
-
|
295
|
-
declare const texelFormatToChannelType: {
|
296
|
-
r8unorm: F32;
|
297
|
-
r8snorm: F32;
|
298
|
-
r8uint: U32;
|
299
|
-
r8sint: I32;
|
300
|
-
r16uint: U32;
|
301
|
-
r16sint: I32;
|
302
|
-
r16float: F32;
|
303
|
-
rg8unorm: F32;
|
304
|
-
rg8snorm: F32;
|
305
|
-
rg8uint: U32;
|
306
|
-
rg8sint: I32;
|
307
|
-
r32uint: U32;
|
308
|
-
r32sint: I32;
|
309
|
-
r32float: F32;
|
310
|
-
rg16uint: U32;
|
311
|
-
rg16sint: I32;
|
312
|
-
rg16float: F32;
|
313
|
-
rgba8unorm: F32;
|
314
|
-
'rgba8unorm-srgb': F32;
|
315
|
-
rgba8snorm: F32;
|
316
|
-
rgba8uint: U32;
|
317
|
-
rgba8sint: I32;
|
318
|
-
bgra8unorm: F32;
|
319
|
-
'bgra8unorm-srgb': F32;
|
320
|
-
rgb9e5ufloat: F32;
|
321
|
-
rgb10a2uint: U32;
|
322
|
-
rgb10a2unorm: F32;
|
323
|
-
rg11b10ufloat: F32;
|
324
|
-
rg32uint: U32;
|
325
|
-
rg32sint: I32;
|
326
|
-
rg32float: F32;
|
327
|
-
rgba16uint: U32;
|
328
|
-
rgba16sint: I32;
|
329
|
-
rgba16float: F32;
|
330
|
-
rgba32uint: U32;
|
331
|
-
rgba32sint: I32;
|
332
|
-
rgba32float: F32;
|
333
|
-
stencil8: F32;
|
334
|
-
depth16unorm: F32;
|
335
|
-
depth24plus: F32;
|
336
|
-
'depth24plus-stencil8': F32;
|
337
|
-
depth32float: F32;
|
338
|
-
'depth32float-stencil8': F32;
|
339
|
-
'bc1-rgba-unorm': F32;
|
340
|
-
'bc1-rgba-unorm-srgb': F32;
|
341
|
-
'bc2-rgba-unorm': F32;
|
342
|
-
'bc2-rgba-unorm-srgb': F32;
|
343
|
-
'bc3-rgba-unorm': F32;
|
344
|
-
'bc3-rgba-unorm-srgb': F32;
|
345
|
-
'bc4-r-unorm': F32;
|
346
|
-
'bc4-r-snorm': F32;
|
347
|
-
'bc5-rg-unorm': F32;
|
348
|
-
'bc5-rg-snorm': F32;
|
349
|
-
'bc6h-rgb-ufloat': F32;
|
350
|
-
'bc6h-rgb-float': F32;
|
351
|
-
'bc7-rgba-unorm': F32;
|
352
|
-
'bc7-rgba-unorm-srgb': F32;
|
353
|
-
'etc2-rgb8unorm': F32;
|
354
|
-
'etc2-rgb8unorm-srgb': F32;
|
355
|
-
'etc2-rgb8a1unorm': F32;
|
356
|
-
'etc2-rgb8a1unorm-srgb': F32;
|
357
|
-
'etc2-rgba8unorm': F32;
|
358
|
-
'etc2-rgba8unorm-srgb': F32;
|
359
|
-
'eac-r11unorm': F32;
|
360
|
-
'eac-r11snorm': F32;
|
361
|
-
'eac-rg11unorm': F32;
|
362
|
-
'eac-rg11snorm': F32;
|
363
|
-
'astc-4x4-unorm': F32;
|
364
|
-
'astc-4x4-unorm-srgb': F32;
|
365
|
-
'astc-5x4-unorm': F32;
|
366
|
-
'astc-5x4-unorm-srgb': F32;
|
367
|
-
'astc-5x5-unorm': F32;
|
368
|
-
'astc-5x5-unorm-srgb': F32;
|
369
|
-
'astc-6x5-unorm': F32;
|
370
|
-
'astc-6x5-unorm-srgb': F32;
|
371
|
-
'astc-6x6-unorm': F32;
|
372
|
-
'astc-6x6-unorm-srgb': F32;
|
373
|
-
'astc-8x5-unorm': F32;
|
374
|
-
'astc-8x5-unorm-srgb': F32;
|
375
|
-
'astc-8x6-unorm': F32;
|
376
|
-
'astc-8x6-unorm-srgb': F32;
|
377
|
-
'astc-8x8-unorm': F32;
|
378
|
-
'astc-8x8-unorm-srgb': F32;
|
379
|
-
'astc-10x5-unorm': F32;
|
380
|
-
'astc-10x5-unorm-srgb': F32;
|
381
|
-
'astc-10x6-unorm': F32;
|
382
|
-
'astc-10x6-unorm-srgb': F32;
|
383
|
-
'astc-10x8-unorm': F32;
|
384
|
-
'astc-10x8-unorm-srgb': F32;
|
385
|
-
'astc-10x10-unorm': F32;
|
386
|
-
'astc-10x10-unorm-srgb': F32;
|
387
|
-
'astc-12x10-unorm': F32;
|
388
|
-
'astc-12x10-unorm-srgb': F32;
|
389
|
-
'astc-12x12-unorm': F32;
|
390
|
-
'astc-12x12-unorm-srgb': F32;
|
391
|
-
};
|
392
|
-
type TexelFormatToChannelType = typeof texelFormatToChannelType;
|
393
|
-
type TexelFormatToStringChannels = {
|
394
|
-
[Key in keyof TexelFormatToChannelType]: TexelFormatToChannelType[Key]['type'];
|
395
|
-
};
|
396
|
-
type KeysWithValue<T extends Record<string, unknown>, TValue> = keyof {
|
397
|
-
[Key in keyof T as T[Key] extends TValue ? Key : never]: Key;
|
398
|
-
};
|
399
|
-
type ChannelTypeToLegalFormats = {
|
400
|
-
[Key in TexelFormatToChannelType[keyof TexelFormatToChannelType]['type']]: KeysWithValue<TexelFormatToStringChannels, Key>;
|
401
|
-
};
|
402
|
-
type SampleTypeToStringChannelType = {
|
403
|
-
float: 'f32';
|
404
|
-
'unfilterable-float': 'f32';
|
405
|
-
depth: 'f32';
|
406
|
-
sint: 'i32';
|
407
|
-
uint: 'u32';
|
408
|
-
};
|
409
|
-
type ViewDimensionToDimension = {
|
410
|
-
'1d': '1d';
|
411
|
-
'2d': '2d';
|
412
|
-
'2d-array': '2d';
|
413
|
-
'3d': '3d';
|
414
|
-
cube: '2d';
|
415
|
-
'cube-array': '2d';
|
416
|
-
};
|
417
|
-
/**
|
418
|
-
* https://www.w3.org/TR/WGSL/#storage-texel-formats
|
419
|
-
*/
|
420
|
-
type StorageTextureTexelFormat = 'rgba8unorm' | 'rgba8snorm' | 'rgba8uint' | 'rgba8sint' | 'rgba16uint' | 'rgba16sint' | 'rgba16float' | 'r32uint' | 'r32sint' | 'r32float' | 'rg32uint' | 'rg32sint' | 'rg32float' | 'rgba32uint' | 'rgba32sint' | 'rgba32float' | 'bgra8unorm';
|
421
|
-
declare const texelFormatToDataType: {
|
422
|
-
readonly rgba8unorm: Vec4f;
|
423
|
-
readonly rgba8snorm: Vec4f;
|
424
|
-
readonly rgba8uint: Vec4u;
|
425
|
-
readonly rgba8sint: Vec4i;
|
426
|
-
readonly rgba16uint: Vec4u;
|
427
|
-
readonly rgba16sint: Vec4i;
|
428
|
-
readonly rgba16float: Vec4f;
|
429
|
-
readonly r32uint: Vec4u;
|
430
|
-
readonly r32sint: Vec4i;
|
431
|
-
readonly r32float: Vec4f;
|
432
|
-
readonly rg32uint: Vec4u;
|
433
|
-
readonly rg32sint: Vec4i;
|
434
|
-
readonly rg32float: Vec4f;
|
435
|
-
readonly rgba32uint: Vec4u;
|
436
|
-
readonly rgba32sint: Vec4i;
|
437
|
-
readonly rgba32float: Vec4f;
|
438
|
-
readonly bgra8unorm: Vec4f;
|
439
|
-
};
|
440
|
-
declare const channelFormatToSchema: {
|
441
|
-
float: F32;
|
442
|
-
'unfilterable-float': F32;
|
443
|
-
uint: U32;
|
444
|
-
sint: I32;
|
445
|
-
depth: F32;
|
446
|
-
};
|
447
|
-
type ChannelFormatToSchema = typeof channelFormatToSchema;
|
448
|
-
type TexelFormatToDataType = typeof texelFormatToDataType;
|
449
|
-
type TexelFormatToDataTypeOrNever<T> = T extends keyof TexelFormatToDataType ? TexelFormatToDataType[T] : never;
|
450
|
-
/**
|
451
|
-
* Represents what formats a storage view can choose from based on its owner texture's props.
|
452
|
-
*/
|
453
|
-
type StorageFormatOptions<TProps extends TextureProps> = Extract<TProps['format'] | Default<TProps['viewFormats'], []>[number], StorageTextureTexelFormat>;
|
454
|
-
/**
|
455
|
-
* Represents what formats a sampled view can choose from based on its owner texture's props.
|
456
|
-
*/
|
457
|
-
type SampledFormatOptions<TProps extends TextureProps> = TProps['format'] | Default<TProps['viewFormats'], []>[number];
|
458
|
-
|
459
|
-
interface Sampled {
|
460
|
-
usableAsSampled: true;
|
461
|
-
}
|
462
|
-
interface Render {
|
463
|
-
usableAsRender: true;
|
464
|
-
}
|
465
|
-
type LiteralToExtensionMap = {
|
466
|
-
storage: StorageFlag;
|
467
|
-
sampled: Sampled;
|
468
|
-
render: Render;
|
469
|
-
};
|
470
|
-
type AllowedUsages<TProps extends TextureProps> = 'sampled' | 'render' | (TProps['format'] extends StorageTextureTexelFormat ? 'storage' : never);
|
471
|
-
declare function isUsableAsSampled<T>(value: T): value is T & Sampled;
|
472
|
-
declare function isUsableAsRender<T>(value: T): value is T & Render;
|
473
|
-
|
474
|
-
type ResolveStorageDimension<TDimension extends GPUTextureViewDimension, TProps extends TextureProps> = StorageTextureDimension extends TDimension ? Default<TProps['dimension'], '2d'> : TDimension extends StorageTextureDimension ? TDimension : '2d';
|
475
|
-
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';
|
476
|
-
type ChannelData = U32 | I32 | F32;
|
477
|
-
type TexelData = Vec4u | Vec4i | Vec4f;
|
478
|
-
/**
|
479
|
-
* @param TProps all properties that distinguish this texture apart from other textures on the type level.
|
480
|
-
*/
|
481
|
-
interface TgpuTexture<TProps extends TextureProps = TextureProps> extends TgpuNamable {
|
482
|
-
readonly resourceType: 'texture';
|
483
|
-
readonly props: TProps;
|
484
|
-
readonly label: string | undefined;
|
485
|
-
readonly usableAsStorage: boolean;
|
486
|
-
readonly usableAsSampled: boolean;
|
487
|
-
readonly usableAsRender: boolean;
|
488
|
-
$usage<T extends AllowedUsages<TProps>[]>(...usages: T): this & UnionToIntersection<LiteralToExtensionMap[T[number]]>;
|
489
|
-
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>): {
|
490
|
-
mutable: TgpuMutableTexture<ResolveStorageDimension<TDimension, TProps>, TexelFormatToDataTypeOrNever<StorageFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat>>;
|
491
|
-
readonly: TgpuReadonlyTexture<ResolveStorageDimension<TDimension, TProps>, TexelFormatToDataTypeOrNever<StorageFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat>>;
|
492
|
-
writeonly: TgpuWriteonlyTexture<ResolveStorageDimension<TDimension, TProps>, TexelFormatToDataTypeOrNever<StorageFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat>>;
|
493
|
-
sampled: TgpuSampledTexture<GPUTextureViewDimension extends TDimension ? Default<TProps['dimension'], '2d'> : TDimension, TexelFormatToChannelType[SampledFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat]>;
|
494
|
-
}[TUsage];
|
495
|
-
destroy(): void;
|
496
|
-
}
|
497
|
-
type StorageTextureAccess = 'readonly' | 'writeonly' | 'mutable';
|
498
|
-
/**
|
499
|
-
* Based on @see GPUTextureViewDimension
|
500
|
-
* https://www.w3.org/TR/WGSL/#texture-depth
|
501
|
-
*/
|
502
|
-
type StorageTextureDimension = '1d' | '2d' | '2d-array' | '3d';
|
503
|
-
type TextureViewParams<TDimension extends GPUTextureViewDimension | undefined, TFormat extends GPUTextureFormat | undefined> = {
|
504
|
-
format?: TFormat;
|
505
|
-
dimension?: TDimension;
|
506
|
-
aspect?: GPUTextureAspect;
|
507
|
-
baseMipLevel?: number;
|
508
|
-
mipLevelCount?: number;
|
509
|
-
baseArrayLayout?: number;
|
510
|
-
arrayLayerCount?: number;
|
511
|
-
};
|
512
|
-
interface TgpuStorageTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> {
|
513
|
-
readonly resourceType: 'texture-storage-view';
|
514
|
-
readonly dimension: TDimension;
|
515
|
-
readonly texelDataType: TData;
|
516
|
-
readonly access: StorageTextureAccess;
|
517
|
-
}
|
518
|
-
/**
|
519
|
-
* A texture accessed as "readonly" storage on the GPU.
|
520
|
-
*/
|
521
|
-
interface TgpuReadonlyTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> extends TgpuStorageTexture<TDimension, TData> {
|
522
|
-
readonly access: 'readonly';
|
523
|
-
}
|
524
|
-
/**
|
525
|
-
* A texture accessed as "writeonly" storage on the GPU.
|
526
|
-
*/
|
527
|
-
interface TgpuWriteonlyTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> extends TgpuStorageTexture<TDimension, TData> {
|
528
|
-
readonly access: 'writeonly';
|
529
|
-
}
|
530
|
-
/**
|
531
|
-
* A texture accessed as "mutable" (or read_write) storage on the GPU.
|
532
|
-
*/
|
533
|
-
interface TgpuMutableTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> extends TgpuStorageTexture<TDimension, TData> {
|
534
|
-
readonly access: 'mutable';
|
535
|
-
}
|
536
|
-
/**
|
537
|
-
* A texture accessed as sampled on the GPU.
|
538
|
-
*/
|
539
|
-
interface TgpuSampledTexture<TDimension extends GPUTextureViewDimension = GPUTextureViewDimension, TData extends ChannelData = ChannelData> {
|
540
|
-
readonly resourceType: 'texture-sampled-view';
|
541
|
-
readonly dimension: TDimension;
|
542
|
-
readonly channelDataType: TData;
|
543
|
-
}
|
544
|
-
declare function isTexture<T extends TgpuTexture>(value: unknown | T): value is T;
|
545
|
-
declare function isStorageTextureView<T extends TgpuReadonlyTexture | TgpuWriteonlyTexture | TgpuMutableTexture>(value: unknown | T): value is T;
|
546
|
-
declare function isSampledTextureView<T extends TgpuSampledTexture>(value: unknown | T): value is T;
|
547
|
-
type TgpuAnyTextureView = TgpuReadonlyTexture | TgpuWriteonlyTexture | TgpuMutableTexture | TgpuSampledTexture;
|
548
|
-
|
549
280
|
/**
|
550
281
|
* The array can hold T, where T is a single/multi-component numeric, or a struct with members of type T.
|
551
282
|
* Examples of valid array members:
|
@@ -554,7 +285,7 @@ type TgpuAnyTextureView = TgpuReadonlyTexture | TgpuWriteonlyTexture | TgpuMutab
|
|
554
285
|
* - WgslStruct<{ a: Vec3f, b: unorm8x2 }>
|
555
286
|
* - WgslStruct<{ nested: WgslStruct<{ a: Vec3f }> }>
|
556
287
|
*/
|
557
|
-
type DataToContainedAttribs<T> = T extends AnyWgslStruct |
|
288
|
+
type DataToContainedAttribs<T> = T extends AnyWgslStruct | AnyUnstruct ? {
|
558
289
|
[Key in keyof T['propTypes']]: DataToContainedAttribs<T['propTypes'][Key]>;
|
559
290
|
} : T extends {
|
560
291
|
type: VertexFormat;
|
@@ -688,100 +419,6 @@ interface DepthStencilAttachment {
|
|
688
419
|
stencilReadOnly?: boolean;
|
689
420
|
}
|
690
421
|
|
691
|
-
interface SamplerProps {
|
692
|
-
addressModeU?: GPUAddressMode;
|
693
|
-
addressModeV?: GPUAddressMode;
|
694
|
-
/**
|
695
|
-
* Specifies the address modes for the texture width, height, and depth
|
696
|
-
* coordinates, respectively.
|
697
|
-
*/
|
698
|
-
addressModeW?: GPUAddressMode;
|
699
|
-
/**
|
700
|
-
* Specifies the sampling behavior when the sample footprint is smaller than or equal to one
|
701
|
-
* texel.
|
702
|
-
*/
|
703
|
-
magFilter?: GPUFilterMode;
|
704
|
-
/**
|
705
|
-
* Specifies the sampling behavior when the sample footprint is larger than one texel.
|
706
|
-
*/
|
707
|
-
minFilter?: GPUFilterMode;
|
708
|
-
/**
|
709
|
-
* Specifies behavior for sampling between mipmap levels.
|
710
|
-
*/
|
711
|
-
mipmapFilter?: GPUMipmapFilterMode;
|
712
|
-
lodMinClamp?: number;
|
713
|
-
/**
|
714
|
-
* Specifies the minimum and maximum levels of detail, respectively, used internally when
|
715
|
-
* sampling a texture.
|
716
|
-
*/
|
717
|
-
lodMaxClamp?: number;
|
718
|
-
/**
|
719
|
-
* Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is
|
720
|
-
* enabled when {@link GPUSamplerDescriptor.maxAnisotropy} is > 1 and the implementation supports it.
|
721
|
-
* Anisotropic filtering improves the image quality of textures sampled at oblique viewing
|
722
|
-
* angles. Higher {@link GPUSamplerDescriptor.maxAnisotropy} values indicate the maximum ratio of
|
723
|
-
* anisotropy supported when filtering.
|
724
|
-
*
|
725
|
-
* Most implementations support {@link GPUSamplerDescriptor.maxAnisotropy} values in range
|
726
|
-
* between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor.maxAnisotropy}
|
727
|
-
* will be clamped to the maximum value that the platform supports.
|
728
|
-
* The precise filtering behavior is implementation-dependent.
|
729
|
-
*/
|
730
|
-
maxAnisotropy?: number;
|
731
|
-
}
|
732
|
-
interface ComparisonSamplerProps {
|
733
|
-
compare: GPUCompareFunction;
|
734
|
-
addressModeU?: GPUAddressMode;
|
735
|
-
addressModeV?: GPUAddressMode;
|
736
|
-
/**
|
737
|
-
* Specifies the address modes for the texture width, height, and depth
|
738
|
-
* coordinates, respectively.
|
739
|
-
*/
|
740
|
-
addressModeW?: GPUAddressMode;
|
741
|
-
/**
|
742
|
-
* Specifies the sampling behavior when the sample footprint is smaller than or equal to one
|
743
|
-
* texel.
|
744
|
-
*/
|
745
|
-
magFilter?: GPUFilterMode;
|
746
|
-
/**
|
747
|
-
* Specifies the sampling behavior when the sample footprint is larger than one texel.
|
748
|
-
*/
|
749
|
-
minFilter?: GPUFilterMode;
|
750
|
-
/**
|
751
|
-
* Specifies behavior for sampling between mipmap levels.
|
752
|
-
*/
|
753
|
-
mipmapFilter?: GPUMipmapFilterMode;
|
754
|
-
lodMinClamp?: number;
|
755
|
-
/**
|
756
|
-
* Specifies the minimum and maximum levels of detail, respectively, used internally when
|
757
|
-
* sampling a texture.
|
758
|
-
*/
|
759
|
-
lodMaxClamp?: number;
|
760
|
-
/**
|
761
|
-
* Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is
|
762
|
-
* enabled when {@link GPUSamplerDescriptor.maxAnisotropy} is > 1 and the implementation supports it.
|
763
|
-
* Anisotropic filtering improves the image quality of textures sampled at oblique viewing
|
764
|
-
* angles. Higher {@link GPUSamplerDescriptor.maxAnisotropy} values indicate the maximum ratio of
|
765
|
-
* anisotropy supported when filtering.
|
766
|
-
*
|
767
|
-
* Most implementations support {@link GPUSamplerDescriptor.maxAnisotropy} values in range
|
768
|
-
* between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor.maxAnisotropy}
|
769
|
-
* will be clamped to the maximum value that the platform supports.
|
770
|
-
* The precise filtering behavior is implementation-dependent.
|
771
|
-
*/
|
772
|
-
maxAnisotropy?: number;
|
773
|
-
}
|
774
|
-
interface TgpuSampler {
|
775
|
-
readonly resourceType: 'sampler';
|
776
|
-
}
|
777
|
-
interface TgpuComparisonSampler {
|
778
|
-
readonly resourceType: 'sampler-comparison';
|
779
|
-
}
|
780
|
-
declare function sampler(props: SamplerProps): TgpuSampler;
|
781
|
-
declare function comparisonSampler(props: ComparisonSamplerProps): TgpuComparisonSampler;
|
782
|
-
declare function isSampler(resource: unknown): resource is TgpuSampler;
|
783
|
-
declare function isComparisonSampler(resource: unknown): resource is TgpuComparisonSampler;
|
784
|
-
|
785
422
|
interface Unwrapper {
|
786
423
|
readonly device: GPUDevice;
|
787
424
|
unwrap(resource: TgpuComputePipeline): GPUComputePipeline;
|
@@ -1177,12 +814,6 @@ interface TgpuBindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | n
|
|
1177
814
|
* Used when generating WGSL code: `@group(${index}) @binding(...) ...;`
|
1178
815
|
*/
|
1179
816
|
$idx(index?: number): this;
|
1180
|
-
/**
|
1181
|
-
* @deprecated Use the `root.createBindGroup` API instead, accessible through `await tgpu.init()`
|
1182
|
-
*/
|
1183
|
-
populate(entries: {
|
1184
|
-
[K in keyof OmitProps<Entries, null>]: LayoutEntryToInput<Entries[K]>;
|
1185
|
-
}): TgpuBindGroup<Entries>;
|
1186
817
|
/**
|
1187
818
|
* Creates a raw WebGPU resource based on the typed descriptor.
|
1188
819
|
* NOTE: This creates a new resource every time, better to use `root.unwrap(...)` instead.
|
@@ -1215,7 +846,7 @@ type GetStorageTextureRestriction<T extends TgpuLayoutStorageTexture> = Default<
|
|
1215
846
|
dimension: Dimension;
|
1216
847
|
} : never;
|
1217
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;
|
1218
|
-
type BindLayoutEntry<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? TgpuBufferUniform<T['uniform']> : T extends TgpuLayoutStorage ? StorageUsageForEntry<T> : T extends TgpuLayoutSampler ? TgpuSampler : T extends TgpuLayoutComparisonSampler ? TgpuComparisonSampler : T extends TgpuLayoutTexture ? TgpuSampledTexture<Default<
|
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;
|
1219
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;
|
1220
851
|
type TgpuBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>> = {
|
1221
852
|
readonly resourceType: 'bind-group';
|
@@ -1286,20 +917,16 @@ declare function workgroupVar<TDataType extends AnyWgslData>(dataType: TDataType
|
|
1286
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>;
|
1287
918
|
type Wgsl = Eventual<string | number | boolean | ResolvableObject>;
|
1288
919
|
declare const UnknownData: {
|
1289
|
-
type:
|
920
|
+
type: "unknown";
|
1290
921
|
};
|
1291
922
|
type UnknownData = typeof UnknownData;
|
1292
|
-
|
1293
|
-
type: "void";
|
1294
|
-
};
|
1295
|
-
type Void = typeof Void;
|
1296
|
-
type Resource = {
|
923
|
+
type Snippet = {
|
1297
924
|
value: unknown;
|
1298
|
-
dataType:
|
925
|
+
dataType: AnyData | UnknownData;
|
1299
926
|
};
|
1300
927
|
type TgpuShaderStage = 'compute' | 'vertex' | 'fragment';
|
1301
928
|
interface FnToWgslOptions {
|
1302
|
-
args:
|
929
|
+
args: Snippet[];
|
1303
930
|
returnType: AnyWgslData;
|
1304
931
|
body: Block;
|
1305
932
|
externalMap: Record<string, unknown>;
|
@@ -1315,14 +942,14 @@ interface ItemStateStack {
|
|
1315
942
|
popItem(): void;
|
1316
943
|
pushSlotBindings(pairs: SlotValuePair<unknown>[]): void;
|
1317
944
|
popSlotBindings(): void;
|
1318
|
-
pushFunctionScope(args:
|
945
|
+
pushFunctionScope(args: Snippet[], returnType: AnyWgslData | undefined, externalMap: Record<string, unknown>): void;
|
1319
946
|
popFunctionScope(): void;
|
1320
947
|
pushBlockScope(): void;
|
1321
948
|
popBlockScope(): void;
|
1322
949
|
pop(type?: 'functionScope' | 'blockScope' | 'slotBinding' | 'item'): void;
|
1323
950
|
readSlot<T>(slot: TgpuSlot<T>): T | undefined;
|
1324
|
-
|
1325
|
-
defineBlockVariable(id: string, type: AnyWgslData | UnknownData):
|
951
|
+
getSnippetById(id: string): Snippet | undefined;
|
952
|
+
defineBlockVariable(id: string, type: AnyWgslData | UnknownData): Snippet;
|
1326
953
|
}
|
1327
954
|
/**
|
1328
955
|
* Passed into each resolvable item. All items in a tree share a resolution ctx,
|
@@ -1386,13 +1013,14 @@ type BindableBufferUsage = 'uniform' | 'readonly' | 'mutable';
|
|
1386
1013
|
type TgpuFnShellHeader<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = AnyWgslData | undefined> = {
|
1387
1014
|
readonly argTypes: Args;
|
1388
1015
|
readonly returnType: Return | undefined;
|
1016
|
+
readonly isEntry: false;
|
1389
1017
|
};
|
1390
1018
|
/**
|
1391
1019
|
* Describes a function signature (its arguments and return type).
|
1392
1020
|
* Allows creating tgpu functions by calling this shell
|
1393
1021
|
* and passing the implementation (as WGSL string or JS function) as the argument.
|
1394
1022
|
*/
|
1395
|
-
type TgpuFnShell<Args extends AnyWgslData[] | Record<string, AnyWgslData>, Return extends AnyWgslData | undefined = AnyWgslData | undefined> = TgpuFnShellHeader<Args, Return> & ((implementation: (...args: Args extends AnyWgslData[] ? InferArgs<Args> : [InferIO<Args>]) => InferReturn<Return>) => TgpuFn<Args, Return>) & ((implementation: string) => TgpuFn<Args, Return>) & {
|
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>) & {
|
1396
1024
|
/**
|
1397
1025
|
* @deprecated Invoke the shell as a function instead.
|
1398
1026
|
*/
|
@@ -1595,4 +1223,4 @@ declare const tgpu: {
|
|
1595
1223
|
};
|
1596
1224
|
};
|
1597
1225
|
|
1598
|
-
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 };
|