typegpu 0.5.7 → 0.5.9
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-734H4JWF.js +2 -0
- package/chunk-734H4JWF.js.map +1 -0
- package/chunk-BJSN5UVV.cjs +41 -0
- package/chunk-BJSN5UVV.cjs.map +1 -0
- package/chunk-BZVU4Q6A.cjs +2 -0
- package/chunk-BZVU4Q6A.cjs.map +1 -0
- package/chunk-CDUKTYES.cjs +2 -0
- package/chunk-CDUKTYES.cjs.map +1 -0
- package/chunk-CGVYLGBG.js +2 -0
- package/chunk-CGVYLGBG.js.map +1 -0
- package/chunk-SWJVYRFM.js +41 -0
- package/chunk-SWJVYRFM.js.map +1 -0
- package/data/index.cjs +1 -1
- package/data/index.cjs.map +1 -1
- package/data/index.d.cts +4 -77
- package/data/index.d.ts +4 -77
- package/data/index.js +1 -1
- package/index.cjs +21 -20
- package/index.cjs.map +1 -1
- package/index.d.cts +5 -3
- package/index.d.ts +5 -3
- package/index.js +21 -20
- package/index.js.map +1 -1
- package/matrix-BULDDGYa.d.ts +122 -0
- package/matrix-BnXitNJ7.d.cts +122 -0
- package/package.json +2 -2
- package/std/index.cjs +1 -1
- package/std/index.cjs.map +1 -1
- package/std/index.d.cts +104 -17
- package/std/index.d.ts +104 -17
- package/std/index.js +1 -1
- package/std/index.js.map +1 -1
- package/{tgpuComputeFn-DH8_PcIR.d.cts → tgpuComputeFn-BxPDI5hQ.d.cts} +178 -95
- package/{tgpuComputeFn-DH8_PcIR.d.ts → tgpuComputeFn-BxPDI5hQ.d.ts} +178 -95
- package/chunk-5RYM4COI.js +0 -4
- package/chunk-5RYM4COI.js.map +0 -1
- package/chunk-FHOQ6WZE.cjs +0 -2
- package/chunk-FHOQ6WZE.cjs.map +0 -1
- package/chunk-ODKBWWHU.cjs +0 -4
- package/chunk-ODKBWWHU.cjs.map +0 -1
- package/chunk-SMTSXYNG.js +0 -2
- package/chunk-SMTSXYNG.js.map +0 -1
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as tinyest from 'tinyest';
|
2
|
-
import {
|
2
|
+
import { FuncParameter, Block } from 'tinyest';
|
3
3
|
|
4
4
|
/**
|
5
5
|
* Can be assigned a name. Not to be confused with
|
@@ -44,7 +44,7 @@ type InferPartial<T> = T extends {
|
|
44
44
|
* @example
|
45
45
|
* type A = InferGPU<F32> // => number
|
46
46
|
* type B = InferGPU<WgslArray<F32>> // => number[]
|
47
|
-
* type C =
|
47
|
+
* type C = InferGPU<Atomic<U32>> // => atomicU32
|
48
48
|
*/
|
49
49
|
type InferGPU<T> = T extends {
|
50
50
|
readonly '~gpuRepr': infer TRepr;
|
@@ -85,7 +85,7 @@ type Mutable<T> = {
|
|
85
85
|
-readonly [P in keyof T]: T[P];
|
86
86
|
};
|
87
87
|
|
88
|
-
type DecoratedLocation<T extends BaseData> = Decorated<T, Location
|
88
|
+
type DecoratedLocation<T extends BaseData> = Decorated<T, Location[]>;
|
89
89
|
interface NumberArrayView {
|
90
90
|
readonly length: number;
|
91
91
|
[n: number]: number;
|
@@ -627,6 +627,7 @@ interface matBase<TColumn> extends NumberArrayView {
|
|
627
627
|
interface mat2x2<TColumn> extends matBase<TColumn> {
|
628
628
|
readonly length: 4;
|
629
629
|
readonly kind: string;
|
630
|
+
readonly columns: readonly [TColumn, TColumn];
|
630
631
|
[n: number]: number;
|
631
632
|
}
|
632
633
|
/**
|
@@ -643,6 +644,7 @@ interface m2x2f extends mat2x2<v2f> {
|
|
643
644
|
interface mat3x3<TColumn> extends matBase<TColumn> {
|
644
645
|
readonly length: 12;
|
645
646
|
readonly kind: string;
|
647
|
+
readonly columns: readonly [TColumn, TColumn, TColumn];
|
646
648
|
[n: number]: number;
|
647
649
|
}
|
648
650
|
/**
|
@@ -659,6 +661,12 @@ interface m3x3f extends mat3x3<v3f> {
|
|
659
661
|
interface mat4x4<TColumn> extends matBase<TColumn> {
|
660
662
|
readonly length: 16;
|
661
663
|
readonly kind: string;
|
664
|
+
readonly columns: readonly [
|
665
|
+
TColumn,
|
666
|
+
TColumn,
|
667
|
+
TColumn,
|
668
|
+
TColumn
|
669
|
+
];
|
662
670
|
[n: number]: number;
|
663
671
|
}
|
664
672
|
/**
|
@@ -670,6 +678,7 @@ interface m4x4f extends mat4x4<v4f> {
|
|
670
678
|
}
|
671
679
|
type AnyMatInstance = m2x2f | m3x3f | m4x4f;
|
672
680
|
type vBaseForMat<T extends AnyMatInstance> = T extends m2x2f ? v2f : T extends m3x3f ? v3f : v4f;
|
681
|
+
type mBaseForVec<T extends AnyVecInstance> = T extends v2f ? m2x2f : T extends v3f ? m3x3f : T extends v4f ? m4x4f : never;
|
673
682
|
/**
|
674
683
|
* Boolean schema representing a single WGSL bool value.
|
675
684
|
* Cannot be used inside buffers as it is not host-shareable.
|
@@ -947,9 +956,10 @@ interface Mat2x2f {
|
|
947
956
|
readonly [$internal]: true;
|
948
957
|
readonly type: 'mat2x2f';
|
949
958
|
readonly [$repr]: m2x2f;
|
950
|
-
(...elements: number
|
951
|
-
(...columns: v2f
|
959
|
+
(...elements: [number, number, number, number]): m2x2f;
|
960
|
+
(...columns: [v2f, v2f]): m2x2f;
|
952
961
|
(): m2x2f;
|
962
|
+
identity(): m2x2f;
|
953
963
|
}
|
954
964
|
/**
|
955
965
|
* Type of the `d.mat3x3f` object/function: matrix data type schema/constructor
|
@@ -958,9 +968,10 @@ interface Mat3x3f {
|
|
958
968
|
readonly [$internal]: true;
|
959
969
|
readonly type: 'mat3x3f';
|
960
970
|
readonly [$repr]: m3x3f;
|
961
|
-
(...elements: number
|
962
|
-
(...columns: v3f
|
971
|
+
(...elements: [number, number, number, number, number, number, number, number, number]): m3x3f;
|
972
|
+
(...columns: [v3f, v3f, v3f]): m3x3f;
|
963
973
|
(): m3x3f;
|
974
|
+
identity(): m3x3f;
|
964
975
|
}
|
965
976
|
/**
|
966
977
|
* Type of the `d.mat4x4f` object/function: matrix data type schema/constructor
|
@@ -969,9 +980,15 @@ interface Mat4x4f {
|
|
969
980
|
readonly [$internal]: true;
|
970
981
|
readonly type: 'mat4x4f';
|
971
982
|
readonly [$repr]: m4x4f;
|
972
|
-
(...elements: number
|
973
|
-
(...columns: v4f
|
983
|
+
(...elements: [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]): m4x4f;
|
984
|
+
(...columns: [v4f, v4f, v4f, v4f]): m4x4f;
|
974
985
|
(): m4x4f;
|
986
|
+
identity(): m4x4f;
|
987
|
+
translation(vec: v3f): m4x4f;
|
988
|
+
scaling(vec: v3f): m4x4f;
|
989
|
+
rotationX(angle: number): m4x4f;
|
990
|
+
rotationY(angle: number): m4x4f;
|
991
|
+
rotationZ(angle: number): m4x4f;
|
975
992
|
}
|
976
993
|
/**
|
977
994
|
* Array schema constructed via `d.arrayOf` function.
|
@@ -1054,7 +1071,7 @@ interface Size<T extends number> {
|
|
1054
1071
|
readonly type: '@size';
|
1055
1072
|
readonly value: T;
|
1056
1073
|
}
|
1057
|
-
interface Location<T extends number> {
|
1074
|
+
interface Location<T extends number = number> {
|
1058
1075
|
readonly [$internal]: true;
|
1059
1076
|
readonly type: '@location';
|
1060
1077
|
readonly value: T;
|
@@ -1062,7 +1079,7 @@ interface Location<T extends number> {
|
|
1062
1079
|
type PerspectiveOrLinearInterpolationType = `${'perspective' | 'linear'}${'' | ', center' | ', centroid' | ', sample'}`;
|
1063
1080
|
type FlatInterpolationType = `flat${'' | ', first' | ', either'}`;
|
1064
1081
|
type InterpolationType = PerspectiveOrLinearInterpolationType | FlatInterpolationType;
|
1065
|
-
interface Interpolate<T extends InterpolationType> {
|
1082
|
+
interface Interpolate<T extends InterpolationType = InterpolationType> {
|
1066
1083
|
readonly [$internal]: true;
|
1067
1084
|
readonly type: '@interpolate';
|
1068
1085
|
readonly value: T;
|
@@ -1080,7 +1097,7 @@ interface Decorated<TInner extends BaseData = BaseData, TAttribs extends unknown
|
|
1080
1097
|
readonly [$repr]: Infer<TInner>;
|
1081
1098
|
readonly '~gpuRepr': InferGPU<TInner>;
|
1082
1099
|
readonly '~reprPartial': InferPartial<TInner>;
|
1083
|
-
readonly '~memIdent': TAttribs extends Location
|
1100
|
+
readonly '~memIdent': TAttribs extends Location[] ? MemIdentity<TInner> | Decorated<MemIdentity<TInner>, TAttribs> : Decorated<MemIdentity<TInner>, TAttribs>;
|
1084
1101
|
}
|
1085
1102
|
declare const wgslTypeLiterals: readonly ["bool", "f32", "f16", "i32", "u32", "vec2f", "vec2h", "vec2i", "vec2u", "vec2<bool>", "vec3f", "vec3h", "vec3i", "vec3u", "vec3<bool>", "vec4f", "vec4h", "vec4i", "vec4u", "vec4<bool>", "mat2x2f", "mat3x3f", "mat4x4f", "struct", "array", "ptr", "atomic", "decorated", "abstractInt", "abstractFloat", "void"];
|
1086
1103
|
type WgslTypeLiteral = (typeof wgslTypeLiterals)[number];
|
@@ -1140,7 +1157,7 @@ declare function isBuiltinAttrib<T extends Builtin<string>>(value: unknown | T):
|
|
1140
1157
|
declare function isDecorated<T extends Decorated>(value: unknown | T): value is T;
|
1141
1158
|
|
1142
1159
|
interface TgpuConst<TDataType extends AnyWgslData = AnyWgslData> extends TgpuNamable {
|
1143
|
-
readonly value:
|
1160
|
+
readonly value: InferGPU<TDataType>;
|
1144
1161
|
readonly [$internal]: {
|
1145
1162
|
readonly dataType: TDataType;
|
1146
1163
|
};
|
@@ -1148,7 +1165,7 @@ interface TgpuConst<TDataType extends AnyWgslData = AnyWgslData> extends TgpuNam
|
|
1148
1165
|
/**
|
1149
1166
|
* Creates a module constant with specified value.
|
1150
1167
|
*/
|
1151
|
-
declare function constant<TDataType extends AnyWgslData>(dataType: TDataType, value:
|
1168
|
+
declare function constant<TDataType extends AnyWgslData>(dataType: TDataType, value: InferGPU<TDataType>): TgpuConst<TDataType>;
|
1152
1169
|
|
1153
1170
|
/**
|
1154
1171
|
* Extra declaration that shall be included in final WGSL code,
|
@@ -1212,6 +1229,8 @@ declare const builtin: {
|
|
1212
1229
|
};
|
1213
1230
|
type AnyBuiltin = (typeof builtin)[keyof typeof builtin];
|
1214
1231
|
type AnyComputeBuiltin = BuiltinLocalInvocationId | BuiltinLocalInvocationIndex | BuiltinGlobalInvocationId | BuiltinWorkgroupId | BuiltinNumWorkgroups | BuiltinSubgroupInvocationId | BuiltinSubgroupSize;
|
1232
|
+
type AnyVertexInputBuiltin = BuiltinVertexIndex | BuiltinInstanceIndex;
|
1233
|
+
type AnyVertexOutputBuiltin = BuiltinClipDistances | BuiltinPosition;
|
1215
1234
|
type AnyFragmentInputBuiltin = BuiltinPosition | BuiltinFrontFacing | BuiltinSampleIndex | BuiltinSampleMask | BuiltinSubgroupInvocationId | BuiltinSubgroupSize;
|
1216
1235
|
type AnyFragmentOutputBuiltin = BuiltinFragDepth | BuiltinSampleMask;
|
1217
1236
|
type OmitBuiltins<S> = S extends AnyBuiltin ? never : S extends BaseData ? S : {
|
@@ -1227,6 +1246,22 @@ interface StorageFlag {
|
|
1227
1246
|
type Storage = StorageFlag;
|
1228
1247
|
declare function isUsableAsStorage<T>(value: T): value is T & StorageFlag;
|
1229
1248
|
|
1249
|
+
interface TgpuQuerySet<T extends GPUQueryType> extends TgpuNamable {
|
1250
|
+
readonly resourceType: 'query-set';
|
1251
|
+
readonly type: T;
|
1252
|
+
readonly count: number;
|
1253
|
+
readonly querySet: GPUQuerySet;
|
1254
|
+
readonly destroyed: boolean;
|
1255
|
+
readonly available: boolean;
|
1256
|
+
readonly [$internal]: {
|
1257
|
+
readonly readBuffer: GPUBuffer;
|
1258
|
+
readonly resolveBuffer: GPUBuffer;
|
1259
|
+
};
|
1260
|
+
resolve(): void;
|
1261
|
+
read(): Promise<bigint[]>;
|
1262
|
+
destroy(): void;
|
1263
|
+
}
|
1264
|
+
|
1230
1265
|
/**
|
1231
1266
|
* Used to transpile JS resources into tinyest on demand.
|
1232
1267
|
*/
|
@@ -1258,7 +1293,7 @@ declare class StrictNameRegistry implements NameRegistry {
|
|
1258
1293
|
/**
|
1259
1294
|
* Describes a function signature (its arguments and return type)
|
1260
1295
|
*/
|
1261
|
-
type TgpuFnShellHeader<Args extends
|
1296
|
+
type TgpuFnShellHeader<Args extends AnyData[], Return extends AnyData> = {
|
1262
1297
|
readonly [$internal]: true;
|
1263
1298
|
readonly argTypes: Args;
|
1264
1299
|
readonly returnType: Return | undefined;
|
@@ -1269,13 +1304,13 @@ type TgpuFnShellHeader<Args extends AnyWgslData[] | Record<string, AnyWgslData>,
|
|
1269
1304
|
* Allows creating tgpu functions by calling this shell
|
1270
1305
|
* and passing the implementation (as WGSL string or JS function) as the argument.
|
1271
1306
|
*/
|
1272
|
-
type TgpuFnShell<Args extends
|
1307
|
+
type TgpuFnShell<Args extends AnyData[], Return extends AnyData> = TgpuFnShellHeader<Args, Return> & ((implementation: (...args: InferArgs<Args>) => Infer<Return>) => TgpuFn<Args, Return>) & ((implementation: string) => TgpuFn<Args, Return>) & ((strings: TemplateStringsArray, ...values: unknown[]) => TgpuFn<Args, Return>) & {
|
1273
1308
|
/**
|
1274
1309
|
* @deprecated Invoke the shell as a function instead.
|
1275
1310
|
*/
|
1276
|
-
does: ((implementation: (...args:
|
1311
|
+
does: ((implementation: (...args: InferArgs<Args>) => Infer<Return>) => TgpuFn<Args, Return>) & ((implementation: string) => TgpuFn<Args, Return>);
|
1277
1312
|
};
|
1278
|
-
interface TgpuFnBase<Args extends
|
1313
|
+
interface TgpuFnBase<Args extends AnyData[], Return extends AnyData> extends TgpuNamable {
|
1279
1314
|
readonly [$internal]: {
|
1280
1315
|
implementation: Implementation<Args, Return>;
|
1281
1316
|
argTypes: FnArgsConversionHint;
|
@@ -1285,28 +1320,30 @@ interface TgpuFnBase<Args extends AnyWgslData[] | Record<string, AnyWgslData>, R
|
|
1285
1320
|
readonly '~providing'?: Providing | undefined;
|
1286
1321
|
$uses(dependencyMap: Record<string, unknown>): this;
|
1287
1322
|
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TgpuFn<Args, Return>;
|
1288
|
-
with<T extends
|
1323
|
+
with<T extends AnyData>(accessor: TgpuAccessor<T>, value: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>): TgpuFn<Args, Return>;
|
1289
1324
|
}
|
1290
|
-
type TgpuFn<Args extends
|
1291
|
-
declare function fn<Args extends
|
1292
|
-
declare function fn<Args extends
|
1293
|
-
declare function isTgpuFn<Args extends
|
1325
|
+
type TgpuFn<Args extends AnyData[] = AnyData[], Return extends AnyData = AnyData> = TgpuFnBase<Args, Return> & ((...args: InferArgs<Args>) => Infer<Return>);
|
1326
|
+
declare function fn<Args extends AnyData[] | []>(argTypes: Args, returnType?: undefined): TgpuFnShell<Args, Void>;
|
1327
|
+
declare function fn<Args extends AnyData[] | [], Return extends AnyData>(argTypes: Args, returnType: Return): TgpuFnShell<Args, Return>;
|
1328
|
+
declare function isTgpuFn<Args extends AnyData[] | [], Return extends AnyData>(value: unknown | TgpuFn<Args, Return>): value is TgpuFn<Args, Return>;
|
1294
1329
|
|
1295
1330
|
interface TgpuSlot<T> extends TgpuNamable {
|
1296
1331
|
readonly resourceType: 'slot';
|
1297
|
-
[$repr]: Infer<T>;
|
1332
|
+
readonly [$repr]: Infer<T>;
|
1333
|
+
readonly '~gpuRepr': InferGPU<T>;
|
1298
1334
|
readonly defaultValue: T | undefined;
|
1299
1335
|
/**
|
1300
1336
|
* Used to determine if code generated using either value `a` or `b` in place
|
1301
1337
|
* of the slot will be equivalent. Defaults to `Object.is`.
|
1302
1338
|
*/
|
1303
1339
|
areEqual(a: T, b: T): boolean;
|
1304
|
-
readonly value:
|
1340
|
+
readonly value: InferGPU<T>;
|
1305
1341
|
}
|
1306
1342
|
interface TgpuDerived<T> {
|
1307
1343
|
readonly resourceType: 'derived';
|
1308
|
-
readonly value:
|
1344
|
+
readonly value: InferGPU<T>;
|
1309
1345
|
[$repr]: Infer<T>;
|
1346
|
+
'~gpuRepr': InferGPU<T>;
|
1310
1347
|
readonly '~providing'?: Providing | undefined;
|
1311
1348
|
with<TValue>(slot: TgpuSlot<TValue>, value: Eventual<TValue>): TgpuDerived<T>;
|
1312
1349
|
/**
|
@@ -1314,13 +1351,14 @@ interface TgpuDerived<T> {
|
|
1314
1351
|
*/
|
1315
1352
|
'~compute'(): T;
|
1316
1353
|
}
|
1317
|
-
interface TgpuAccessor<T extends
|
1354
|
+
interface TgpuAccessor<T extends AnyData = AnyData> extends TgpuNamable {
|
1318
1355
|
readonly resourceType: 'accessor';
|
1319
|
-
[$repr]: Infer<T>;
|
1356
|
+
readonly [$repr]: Infer<T>;
|
1357
|
+
readonly '~gpuRepr': InferGPU<T>;
|
1320
1358
|
readonly schema: T;
|
1321
1359
|
readonly defaultValue: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T> | undefined;
|
1322
1360
|
readonly slot: TgpuSlot<TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>>;
|
1323
|
-
readonly value:
|
1361
|
+
readonly value: InferGPU<T>;
|
1324
1362
|
}
|
1325
1363
|
/**
|
1326
1364
|
* Represents a value that is available at resolution time.
|
@@ -1334,16 +1372,6 @@ type Providing = {
|
|
1334
1372
|
declare function isSlot<T>(value: unknown | TgpuSlot<T>): value is TgpuSlot<T>;
|
1335
1373
|
declare function isDerived<T extends TgpuDerived<unknown>>(value: T | unknown): value is T;
|
1336
1374
|
|
1337
|
-
interface ComputePipelineInternals {
|
1338
|
-
readonly rawPipeline: GPUComputePipeline;
|
1339
|
-
}
|
1340
|
-
interface TgpuComputePipeline extends TgpuNamable {
|
1341
|
-
readonly [$internal]: ComputePipelineInternals;
|
1342
|
-
readonly resourceType: 'compute-pipeline';
|
1343
|
-
with(bindGroupLayout: TgpuBindGroupLayout, bindGroup: TgpuBindGroup): TgpuComputePipeline;
|
1344
|
-
dispatchWorkgroups(x: number, y?: number | undefined, z?: number | undefined): void;
|
1345
|
-
}
|
1346
|
-
|
1347
1375
|
declare const vertexFormats: readonly ["uint8", "uint8x2", "uint8x4", "sint8", "sint8x2", "sint8x4", "unorm8", "unorm8x2", "unorm8x4", "snorm8", "snorm8x2", "snorm8x4", "uint16", "uint16x2", "uint16x4", "sint16", "sint16x2", "sint16x4", "unorm16", "unorm16x2", "unorm16x4", "snorm16", "snorm16x2", "snorm16x4", "float16", "float16x2", "float16x4", "float32", "float32x2", "float32x3", "float32x4", "uint32", "uint32x2", "uint32x3", "uint32x4", "sint32", "sint32x2", "sint32x3", "sint32x4", "unorm10-10-10-2", "unorm8x4-bgra"];
|
1348
1376
|
type VertexFormat = (typeof vertexFormats)[number];
|
1349
1377
|
declare const kindToDefaultFormatMap: {
|
@@ -1413,21 +1441,21 @@ type KindToAcceptedAttribMap = {
|
|
1413
1441
|
};
|
1414
1442
|
|
1415
1443
|
type WithLocations<T extends IORecord> = {
|
1416
|
-
[Key in keyof T]: IsBuiltin<T[Key]> extends true ? T[Key] : HasCustomLocation<T[Key]> extends true ? T[Key] : Decorate<T[Key], Location
|
1444
|
+
[Key in keyof T]: IsBuiltin<T[Key]> extends true ? T[Key] : HasCustomLocation<T[Key]> extends true ? T[Key] : Decorate<T[Key], Location>;
|
1417
1445
|
};
|
1418
1446
|
type IOLayoutToSchema<T extends IOLayout> = T extends BaseData ? Decorate<T, Location<0>> : T extends IORecord ? WgslStruct<WithLocations<T>> : T extends {
|
1419
1447
|
type: 'void';
|
1420
1448
|
} ? void : never;
|
1421
1449
|
|
1422
|
-
type
|
1423
|
-
type
|
1450
|
+
type FragmentInConstrained = IORecord<BaseIOData | Decorated<BaseIOData, (Location | Interpolate)[]> | AnyFragmentInputBuiltin>;
|
1451
|
+
type FragmentOutConstrained = IOLayout<Vec4f | Decorated<Vec4f, (Location | Interpolate)[]> | AnyFragmentOutputBuiltin>;
|
1424
1452
|
/**
|
1425
1453
|
* Describes a fragment entry function signature (its arguments, return type and targets)
|
1426
1454
|
*/
|
1427
1455
|
type TgpuFragmentFnShellHeader<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = {
|
1428
|
-
readonly argTypes: [
|
1456
|
+
readonly argTypes: [IOLayoutToSchema<FragmentIn>] | [];
|
1429
1457
|
readonly targets: FragmentOut;
|
1430
|
-
readonly returnType: FragmentOut
|
1458
|
+
readonly returnType: IOLayoutToSchema<FragmentOut>;
|
1431
1459
|
readonly isEntry: true;
|
1432
1460
|
};
|
1433
1461
|
/**
|
@@ -1466,12 +1494,14 @@ declare function fragmentFn<FragmentIn extends FragmentInConstrained, FragmentOu
|
|
1466
1494
|
out: FragmentOut;
|
1467
1495
|
}): TgpuFragmentFnShell<FragmentIn, FragmentOut>;
|
1468
1496
|
|
1497
|
+
type VertexInConstrained = IORecord<BaseIOData | AnyVertexInputBuiltin>;
|
1498
|
+
type VertexOutConstrained = IORecord<BaseIOData | Decorated<BaseIOData, (Location | Interpolate)[]> | AnyVertexOutputBuiltin>;
|
1469
1499
|
/**
|
1470
1500
|
* Describes a vertex entry function signature (its arguments, return type and attributes)
|
1471
1501
|
*/
|
1472
|
-
type TgpuVertexFnShellHeader<VertexIn extends
|
1473
|
-
readonly argTypes: [
|
1474
|
-
readonly returnType: VertexOut
|
1502
|
+
type TgpuVertexFnShellHeader<VertexIn extends VertexInConstrained, VertexOut extends VertexOutConstrained> = {
|
1503
|
+
readonly argTypes: [IOLayoutToSchema<VertexIn>] | [];
|
1504
|
+
readonly returnType: IOLayoutToSchema<VertexOut>;
|
1475
1505
|
readonly attributes: [VertexIn];
|
1476
1506
|
readonly isEntry: true;
|
1477
1507
|
};
|
@@ -1480,22 +1510,22 @@ type TgpuVertexFnShellHeader<VertexIn extends IOLayout, VertexOut extends IOLayo
|
|
1480
1510
|
* Allows creating tgpu vertex functions by calling this shell
|
1481
1511
|
* and passing the implementation (as WGSL string or JS function) as the argument.
|
1482
1512
|
*/
|
1483
|
-
type TgpuVertexFnShell<VertexIn extends
|
1513
|
+
type TgpuVertexFnShell<VertexIn extends VertexInConstrained, VertexOut extends VertexOutConstrained> = 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>>) & {
|
1484
1514
|
/**
|
1485
1515
|
* @deprecated Invoke the shell as a function instead.
|
1486
1516
|
*/
|
1487
1517
|
does: ((implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & ((implementation: string) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>);
|
1488
1518
|
};
|
1489
|
-
interface TgpuVertexFn<VertexIn extends
|
1519
|
+
interface TgpuVertexFn<VertexIn extends VertexInConstrained = any, VertexOut extends VertexOutConstrained = any> extends TgpuNamable {
|
1490
1520
|
readonly shell: TgpuVertexFnShellHeader<VertexIn, VertexOut>;
|
1491
1521
|
readonly outputType: IOLayoutToSchema<VertexOut>;
|
1492
|
-
readonly inputType: IOLayoutToSchema<VertexIn
|
1522
|
+
readonly inputType: IOLayoutToSchema<VertexIn> | undefined;
|
1493
1523
|
$uses(dependencyMap: Record<string, unknown>): this;
|
1494
1524
|
}
|
1495
|
-
declare function vertexFn<VertexOut extends
|
1525
|
+
declare function vertexFn<VertexOut extends VertexOutConstrained>(options: {
|
1496
1526
|
out: VertexOut;
|
1497
1527
|
}): TgpuVertexFnShell<{}, VertexOut>;
|
1498
|
-
declare function vertexFn<VertexIn extends
|
1528
|
+
declare function vertexFn<VertexIn extends VertexInConstrained, VertexOut extends VertexOutConstrained>(options: {
|
1499
1529
|
in: VertexIn;
|
1500
1530
|
out: VertexOut;
|
1501
1531
|
}): TgpuVertexFnShell<VertexIn, VertexOut>;
|
@@ -1808,15 +1838,15 @@ declare function vertexLayout<TData extends WgslArray | Disarray>(schemaForCount
|
|
1808
1838
|
|
1809
1839
|
interface RenderPipelineInternals {
|
1810
1840
|
readonly core: RenderPipelineCore;
|
1811
|
-
readonly priors: TgpuRenderPipelinePriors;
|
1841
|
+
readonly priors: TgpuRenderPipelinePriors & TimestampWritesPriors;
|
1812
1842
|
}
|
1813
|
-
interface TgpuRenderPipeline<Output extends IOLayout = IOLayout> extends TgpuNamable {
|
1843
|
+
interface TgpuRenderPipeline<Output extends IOLayout = IOLayout> extends TgpuNamable, Timeable<TgpuRenderPipeline> {
|
1814
1844
|
readonly [$internal]: RenderPipelineInternals;
|
1815
1845
|
readonly resourceType: 'render-pipeline';
|
1816
|
-
with<TData extends WgslArray | Disarray>(vertexLayout: TgpuVertexLayout<TData>, buffer: TgpuBuffer<TData> & VertexFlag): TgpuRenderPipeline
|
1817
|
-
with<Entries extends Record<string, TgpuLayoutEntry | null>>(bindGroupLayout: TgpuBindGroupLayout<Entries>, bindGroup: TgpuBindGroup<Entries>): TgpuRenderPipeline
|
1818
|
-
withColorAttachment(attachment: FragmentOutToColorAttachment<Output>): TgpuRenderPipeline
|
1819
|
-
withDepthStencilAttachment(attachment: DepthStencilAttachment): TgpuRenderPipeline
|
1846
|
+
with<TData extends WgslArray | Disarray>(vertexLayout: TgpuVertexLayout<TData>, buffer: TgpuBuffer<TData> & VertexFlag): TgpuRenderPipeline;
|
1847
|
+
with<Entries extends Record<string, TgpuLayoutEntry | null>>(bindGroupLayout: TgpuBindGroupLayout<Entries>, bindGroup: TgpuBindGroup<Entries>): TgpuRenderPipeline;
|
1848
|
+
withColorAttachment(attachment: FragmentOutToColorAttachment<Output>): TgpuRenderPipeline;
|
1849
|
+
withDepthStencilAttachment(attachment: DepthStencilAttachment): TgpuRenderPipeline;
|
1820
1850
|
draw(vertexCount: number, instanceCount?: number, firstVertex?: number, firstInstance?: number): void;
|
1821
1851
|
}
|
1822
1852
|
type FragmentOutToTargets<T extends IOLayout> = T extends IOData ? GPUColorTargetState : T extends Record<string, unknown> ? {
|
@@ -1936,7 +1966,7 @@ type TgpuRenderPipelinePriors = {
|
|
1936
1966
|
readonly bindGroupLayoutMap?: Map<TgpuBindGroupLayout, TgpuBindGroup> | undefined;
|
1937
1967
|
readonly colorAttachment?: AnyFragmentColorAttachment | undefined;
|
1938
1968
|
readonly depthStencilAttachment?: DepthStencilAttachment | undefined;
|
1939
|
-
};
|
1969
|
+
} & TimestampWritesPriors;
|
1940
1970
|
type Memo = {
|
1941
1971
|
pipeline: GPURenderPipeline;
|
1942
1972
|
bindGroupLayouts: TgpuBindGroupLayout[];
|
@@ -1952,6 +1982,38 @@ declare class RenderPipelineCore {
|
|
1952
1982
|
unwrap(): Memo;
|
1953
1983
|
}
|
1954
1984
|
|
1985
|
+
interface Timeable<T extends TgpuComputePipeline | TgpuRenderPipeline> {
|
1986
|
+
withPerformanceCallback(callback: (start: bigint, end: bigint) => void | Promise<void>): T;
|
1987
|
+
withTimestampWrites(options: {
|
1988
|
+
querySet: TgpuQuerySet<'timestamp'> | GPUQuerySet;
|
1989
|
+
beginningOfPassWriteIndex?: number;
|
1990
|
+
endOfPassWriteIndex?: number;
|
1991
|
+
}): T;
|
1992
|
+
}
|
1993
|
+
type TimestampWritesPriors = {
|
1994
|
+
readonly timestampWrites?: {
|
1995
|
+
querySet: TgpuQuerySet<'timestamp'> | GPUQuerySet;
|
1996
|
+
beginningOfPassWriteIndex?: number;
|
1997
|
+
endOfPassWriteIndex?: number;
|
1998
|
+
};
|
1999
|
+
readonly performanceCallback?: (start: bigint, end: bigint) => void | Promise<void>;
|
2000
|
+
readonly hasAutoQuerySet?: boolean;
|
2001
|
+
};
|
2002
|
+
|
2003
|
+
interface ComputePipelineInternals {
|
2004
|
+
readonly rawPipeline: GPUComputePipeline;
|
2005
|
+
readonly priors: TgpuComputePipelinePriors & TimestampWritesPriors;
|
2006
|
+
}
|
2007
|
+
interface TgpuComputePipeline extends TgpuNamable, Timeable<TgpuComputePipeline> {
|
2008
|
+
readonly [$internal]: ComputePipelineInternals;
|
2009
|
+
readonly resourceType: 'compute-pipeline';
|
2010
|
+
with(bindGroupLayout: TgpuBindGroupLayout, bindGroup: TgpuBindGroup): TgpuComputePipeline;
|
2011
|
+
dispatchWorkgroups(x: number, y?: number | undefined, z?: number | undefined): void;
|
2012
|
+
}
|
2013
|
+
type TgpuComputePipelinePriors = {
|
2014
|
+
readonly bindGroupLayoutMap?: Map<TgpuBindGroupLayout, TgpuBindGroup>;
|
2015
|
+
} & TimestampWritesPriors;
|
2016
|
+
|
1955
2017
|
interface SamplerInternals {
|
1956
2018
|
readonly unwrap?: ((branch: Unwrapper) => GPUSampler) | undefined;
|
1957
2019
|
}
|
@@ -2063,6 +2125,7 @@ interface Unwrapper {
|
|
2063
2125
|
unwrap(resource: TgpuVertexLayout): GPUVertexBufferLayout;
|
2064
2126
|
unwrap(resource: TgpuSampler): GPUSampler;
|
2065
2127
|
unwrap(resource: TgpuComparisonSampler): GPUSampler;
|
2128
|
+
unwrap(resource: TgpuQuerySet<GPUQueryType>): GPUQuerySet;
|
2066
2129
|
}
|
2067
2130
|
|
2068
2131
|
interface WithCompute {
|
@@ -2096,8 +2159,8 @@ interface WithFragment<Output extends FragmentOutConstrained = FragmentOutConstr
|
|
2096
2159
|
interface WithBinding {
|
2097
2160
|
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): WithBinding;
|
2098
2161
|
with<T extends AnyWgslData>(accessor: TgpuAccessor<T>, value: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>): WithBinding;
|
2099
|
-
withCompute(entryFn: TgpuComputeFn): WithCompute;
|
2100
|
-
withVertex<VertexIn extends
|
2162
|
+
withCompute<ComputeIn extends IORecord<AnyComputeBuiltin>>(entryFn: TgpuComputeFn<ComputeIn>): WithCompute;
|
2163
|
+
withVertex<VertexIn extends VertexInConstrained, VertexOut extends VertexOutConstrained>(entryFn: TgpuVertexFn<VertexIn, VertexOut>, attribs: LayoutToAllowedAttribs<OmitBuiltins<VertexIn>>): WithVertex<VertexOut>;
|
2101
2164
|
}
|
2102
2165
|
type CreateTextureOptions<TSize, TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormat extends GPUTextureFormat, TDimension extends GPUTextureDimension> = {
|
2103
2166
|
/**
|
@@ -2261,6 +2324,17 @@ interface TgpuRoot extends Unwrapper {
|
|
2261
2324
|
* @param gpuBuffer A vanilla WebGPU buffer.
|
2262
2325
|
*/
|
2263
2326
|
createBuffer<TData extends AnyData>(typeSchema: TData, gpuBuffer: GPUBuffer): TgpuBuffer<TData>;
|
2327
|
+
/**
|
2328
|
+
* Creates a query set for collecting timestamps or occlusion queries.
|
2329
|
+
*
|
2330
|
+
* @remarks
|
2331
|
+
* Typed wrapper around a GPUQuerySet.
|
2332
|
+
*
|
2333
|
+
* @param type The type of queries to collect ('occlusion' or 'timestamp').
|
2334
|
+
* @param count The number of queries in the set.
|
2335
|
+
* @param rawQuerySet An optional pre-existing GPUQuerySet to use instead of creating a new one.
|
2336
|
+
*/
|
2337
|
+
createQuerySet<T extends GPUQueryType>(type: T, count: number, rawQuerySet?: GPUQuerySet | undefined): TgpuQuerySet<T>;
|
2264
2338
|
/**
|
2265
2339
|
* Creates a group of resources that can be bound to a shader based on a specified layout.
|
2266
2340
|
*
|
@@ -2288,6 +2362,11 @@ interface TgpuRoot extends Unwrapper {
|
|
2288
2362
|
createBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>>(layout: TgpuBindGroupLayout<Entries>, entries: {
|
2289
2363
|
[K in keyof OmitProps<Entries, null>]: LayoutEntryToInput<Entries[K]>;
|
2290
2364
|
}): TgpuBindGroup<Entries>;
|
2365
|
+
/**
|
2366
|
+
* Retrieves a read-only list of all enabled features of the GPU device.
|
2367
|
+
* @returns A set of strings representing the enabled features.
|
2368
|
+
*/
|
2369
|
+
get enabledFeatures(): ReadonlySet<GPUFeatureName>;
|
2291
2370
|
/**
|
2292
2371
|
* Destroys all underlying resources (i.e. buffers...) created through this root object.
|
2293
2372
|
* If the object is created via `tgpu.init` instead of `tgpu.initFromDevice`,
|
@@ -2475,7 +2554,7 @@ type GetStorageTextureRestriction<T extends TgpuLayoutStorageTexture> = Default<
|
|
2475
2554
|
format: T['storageTexture'];
|
2476
2555
|
dimension: Dimension;
|
2477
2556
|
} : never;
|
2478
|
-
type LayoutEntryToInput<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? (TgpuBuffer<UnwrapRuntimeConstructor<T['uniform']
|
2557
|
+
type LayoutEntryToInput<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? (TgpuBuffer<MemIdentity<UnwrapRuntimeConstructor<T['uniform']>>> & UniformFlag) | GPUBuffer : T extends TgpuLayoutStorage ? (TgpuBuffer<MemIdentity<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;
|
2479
2558
|
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;
|
2480
2559
|
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<T['viewDimension'], '2d'>, ChannelFormatToSchema[T['texture']]> : T extends TgpuLayoutStorageTexture ? StorageTextureUsageForEntry<T> : never;
|
2481
2560
|
type ExtractBindGroupInputFromLayout<T extends Record<string, TgpuLayoutEntry | null>> = {
|
@@ -2528,9 +2607,11 @@ interface TgpuExternalTexture {
|
|
2528
2607
|
}
|
2529
2608
|
|
2530
2609
|
type VariableScope = 'private' | 'workgroup';
|
2531
|
-
interface TgpuVar<TScope extends VariableScope = VariableScope, TDataType extends
|
2610
|
+
interface TgpuVar<TScope extends VariableScope = VariableScope, TDataType extends AnyData = AnyData> extends TgpuNamable {
|
2532
2611
|
value: Infer<TDataType>;
|
2533
|
-
readonly
|
2612
|
+
readonly [$internal]: {
|
2613
|
+
readonly scope: TScope;
|
2614
|
+
};
|
2534
2615
|
}
|
2535
2616
|
/**
|
2536
2617
|
* Defines a variable scoped to each entry function (private).
|
@@ -2538,29 +2619,22 @@ interface TgpuVar<TScope extends VariableScope = VariableScope, TDataType extend
|
|
2538
2619
|
* @param dataType The schema of the held data's type
|
2539
2620
|
* @param initialValue If not provided, the variable will be initialized to the dataType's "zero-value".
|
2540
2621
|
*/
|
2541
|
-
declare function privateVar<TDataType extends
|
2622
|
+
declare function privateVar<TDataType extends AnyData>(dataType: TDataType, initialValue?: Infer<TDataType>): TgpuVar<'private', TDataType>;
|
2542
2623
|
/**
|
2543
2624
|
* Defines a variable scoped to the whole workgroup, shared between entry functions
|
2544
2625
|
* of the same invocation.
|
2545
2626
|
*
|
2546
2627
|
* @param dataType The schema of the held data's type
|
2547
2628
|
*/
|
2548
|
-
declare function workgroupVar<TDataType extends
|
2629
|
+
declare function workgroupVar<TDataType extends AnyData>(dataType: TDataType): TgpuVar<'workgroup', TDataType>;
|
2549
2630
|
|
2550
2631
|
type ResolvableObject = SelfResolvable | TgpuBufferUsage | TgpuConst | TgpuDeclare | TgpuFn | TgpuComputeFn | TgpuFragmentFn | TgpuComputePipeline | TgpuRenderPipeline | TgpuVertexFn | TgpuSampler | TgpuAccessor | TgpuExternalTexture | TgpuTexture | TgpuAnyTextureView | TgpuVar | AnyVecInstance | AnyMatInstance | AnyData | TgpuFn<any, any>;
|
2551
2632
|
type Wgsl = Eventual<string | number | boolean | ResolvableObject>;
|
2552
|
-
declare const UnknownData: {
|
2553
|
-
type: "unknown";
|
2554
|
-
};
|
2555
|
-
type UnknownData = typeof UnknownData;
|
2556
|
-
type Snippet = {
|
2557
|
-
value: unknown;
|
2558
|
-
dataType: AnyData | UnknownData;
|
2559
|
-
};
|
2560
2633
|
type TgpuShaderStage = 'compute' | 'vertex' | 'fragment';
|
2561
2634
|
interface FnToWgslOptions {
|
2562
2635
|
args: Snippet[];
|
2563
|
-
|
2636
|
+
argAliases: Record<string, Snippet>;
|
2637
|
+
returnType: AnyData;
|
2564
2638
|
body: Block;
|
2565
2639
|
externalMap: Record<string, unknown>;
|
2566
2640
|
}
|
@@ -2575,7 +2649,7 @@ interface ItemStateStack {
|
|
2575
2649
|
popItem(): void;
|
2576
2650
|
pushSlotBindings(pairs: SlotValuePair<unknown>[]): void;
|
2577
2651
|
popSlotBindings(): void;
|
2578
|
-
pushFunctionScope(args: Snippet[],
|
2652
|
+
pushFunctionScope(args: Snippet[], argAliases: Record<string, Snippet>, returnType: AnyData, externalMap: Record<string, unknown>): void;
|
2579
2653
|
popFunctionScope(): void;
|
2580
2654
|
pushBlockScope(): void;
|
2581
2655
|
popBlockScope(): void;
|
@@ -2612,9 +2686,9 @@ interface ResolutionCtx {
|
|
2612
2686
|
*/
|
2613
2687
|
unwrap<T>(eventual: Eventual<T>): T;
|
2614
2688
|
resolve(item: unknown): string;
|
2615
|
-
resolveValue<T extends BaseData>(value: Infer<T>, schema: T): string;
|
2689
|
+
resolveValue<T extends BaseData>(value: Infer<T> | InferGPU<T>, schema: T): string;
|
2616
2690
|
transpileFn(fn: string): {
|
2617
|
-
|
2691
|
+
params: FuncParameter[];
|
2618
2692
|
body: Block;
|
2619
2693
|
externalNames: string[];
|
2620
2694
|
};
|
@@ -2637,7 +2711,7 @@ interface SelfResolvable {
|
|
2637
2711
|
}
|
2638
2712
|
type BindableBufferUsage = 'uniform' | 'readonly' | 'mutable';
|
2639
2713
|
type DefaultConversionStrategy = 'keep' | 'coerce';
|
2640
|
-
type FnArgsConversionHint =
|
2714
|
+
type FnArgsConversionHint = AnyData[] | ((...args: Snippet[]) => AnyWgslData[]) | DefaultConversionStrategy | undefined;
|
2641
2715
|
|
2642
2716
|
type FormatToWGSLType<T extends VertexFormat> = (typeof formatToWGSLType)[T];
|
2643
2717
|
interface TgpuVertexFormatData<T extends VertexFormat> {
|
@@ -2773,7 +2847,7 @@ type unorm8x4_bgra = TgpuVertexFormatData<'unorm8x4-bgra'>;
|
|
2773
2847
|
declare const unorm8x4_bgra: unorm8x4_bgra;
|
2774
2848
|
type PackedData = uint8 | uint8x2 | uint8x4 | sint8 | sint8x2 | sint8x4 | unorm8 | unorm8x2 | unorm8x4 | snorm8 | snorm8x2 | snorm8x4 | uint16 | uint16x2 | uint16x4 | sint16 | sint16x2 | sint16x4 | unorm16 | unorm16x2 | unorm16x4 | snorm16 | snorm16x2 | snorm16x4 | float16 | float16x2 | float16x4 | float32 | float32x2 | float32x3 | float32x4 | uint32 | uint32x2 | uint32x3 | uint32x4 | sint32 | sint32x2 | sint32x3 | sint32x4 | unorm10_10_10_2 | unorm8x4_bgra;
|
2775
2849
|
|
2776
|
-
type TgpuDualFn<TImpl extends (...args:
|
2850
|
+
type TgpuDualFn<TImpl extends (...args: never[]) => unknown> = TImpl & {
|
2777
2851
|
[$internal]: {
|
2778
2852
|
implementation: TImpl | string;
|
2779
2853
|
argTypes: FnArgsConversionHint;
|
@@ -2859,6 +2933,14 @@ declare function isUnstruct<T extends Unstruct>(schema: T | unknown): schema is
|
|
2859
2933
|
declare function isLooseDecorated<T extends LooseDecorated>(value: T | unknown): value is T;
|
2860
2934
|
declare function isData(value: unknown): value is AnyData;
|
2861
2935
|
type AnyData = AnyWgslData | AnyLooseData;
|
2936
|
+
interface UnknownData {
|
2937
|
+
readonly type: 'unknown';
|
2938
|
+
}
|
2939
|
+
declare const UnknownData: UnknownData;
|
2940
|
+
interface Snippet {
|
2941
|
+
readonly value: unknown;
|
2942
|
+
readonly dataType: AnyData | UnknownData;
|
2943
|
+
}
|
2862
2944
|
|
2863
2945
|
declare const builtinNames: readonly ["vertex_index", "instance_index", "position", "clip_distances", "front_facing", "frag_depth", "sample_index", "sample_mask", "fragment", "local_invocation_id", "local_invocation_index", "global_invocation_id", "workgroup_id", "num_workgroups", "subgroup_invocation_id", "subgroup_size"];
|
2864
2946
|
type BuiltinName = (typeof builtinNames)[number];
|
@@ -2885,7 +2967,7 @@ type Undecorate<T> = T extends {
|
|
2885
2967
|
*/
|
2886
2968
|
type Decorate<TData extends BaseData, TAttrib extends AnyAttribute> = TData['type'] extends WgslTypeLiteral ? Decorated<Undecorate<TData>, [TAttrib, ...ExtractAttributes<TData>]> : TData['type'] extends LooseTypeLiteral ? LooseDecorated<Undecorate<TData>, [TAttrib, ...ExtractAttributes<TData>]> : never;
|
2887
2969
|
type IsBuiltin<T> = ExtractAttributes<T>[number] extends [] ? false : ExtractAttributes<T>[number] extends Builtin<BuiltinName> ? true : false;
|
2888
|
-
type HasCustomLocation<T> = ExtractAttributes<T>[number] extends [] ? false : ExtractAttributes<T>[number] extends Location
|
2970
|
+
type HasCustomLocation<T> = ExtractAttributes<T>[number] extends [] ? false : ExtractAttributes<T>[number] extends Location ? true : false;
|
2889
2971
|
/**
|
2890
2972
|
* Gives the wrapped data-type a custom byte alignment. Useful in order to
|
2891
2973
|
* fulfill uniform alignment requirements.
|
@@ -2968,7 +3050,7 @@ declare function isBuiltin<T extends Decorated<AnyWgslData, AnyAttribute[]> | Lo
|
|
2968
3050
|
* Information extracted from transpiling a JS function.
|
2969
3051
|
*/
|
2970
3052
|
type TranspilationResult = {
|
2971
|
-
|
3053
|
+
params: tinyest.FuncParameter[];
|
2972
3054
|
body: tinyest.Block;
|
2973
3055
|
/**
|
2974
3056
|
* All identifiers found in the function code that are not declared in the
|
@@ -2979,11 +3061,10 @@ type TranspilationResult = {
|
|
2979
3061
|
type InferArgs<T extends unknown[]> = {
|
2980
3062
|
[Idx in keyof T]: Infer<T[Idx]>;
|
2981
3063
|
};
|
2982
|
-
type
|
2983
|
-
type
|
2984
|
-
type Implementation<Args extends unknown[] | Record<string, unknown> = unknown[] | Record<string, unknown>, Return = unknown> = string | JsImplementation<Args, Return>;
|
3064
|
+
type JsImplementation<Args extends unknown[] | [] = unknown[] | [], Return = unknown> = (...args: InferArgs<Args>) => Infer<Return>;
|
3065
|
+
type Implementation<Args extends unknown[] | [] = unknown[] | [], Return = unknown> = string | JsImplementation<Args, Return>;
|
2985
3066
|
type BaseIOData = F32 | F16 | I32 | U32 | Vec2f | Vec3f | Vec4f | Vec2h | Vec3h | Vec4h | Vec2i | Vec3i | Vec4i | Vec2u | Vec3u | Vec4u;
|
2986
|
-
type IOData = BaseIOData | Decorated<BaseIOData, AnyAttribute[]
|
3067
|
+
type IOData = BaseIOData | Decorated<BaseIOData, AnyAttribute[]> | BuiltinClipDistances;
|
2987
3068
|
type IORecord<TElementType extends IOData = IOData> = Record<string, TElementType>;
|
2988
3069
|
/**
|
2989
3070
|
* Used for I/O definitions of entry functions.
|
@@ -2998,9 +3079,9 @@ type InferIO<T> = T extends {
|
|
2998
3079
|
/**
|
2999
3080
|
* Describes a compute entry function signature (its arguments, return type and workgroup size)
|
3000
3081
|
*/
|
3001
|
-
type TgpuComputeFnShellHeader<ComputeIn extends
|
3002
|
-
readonly argTypes: [
|
3003
|
-
readonly returnType:
|
3082
|
+
type TgpuComputeFnShellHeader<ComputeIn extends IORecord<AnyComputeBuiltin>> = {
|
3083
|
+
readonly argTypes: [IOLayoutToSchema<ComputeIn>] | [];
|
3084
|
+
readonly returnType: Void;
|
3004
3085
|
readonly workgroupSize: [number, number, number];
|
3005
3086
|
readonly isEntry: true;
|
3006
3087
|
};
|
@@ -3009,9 +3090,11 @@ type TgpuComputeFnShellHeader<ComputeIn extends Record<string, AnyComputeBuiltin
|
|
3009
3090
|
* Allows creating tgpu compute functions by calling this shell
|
3010
3091
|
* and passing the implementation (as WGSL string or JS function) as the argument.
|
3011
3092
|
*/
|
3012
|
-
type TgpuComputeFnShell<ComputeIn extends
|
3093
|
+
type TgpuComputeFnShell<ComputeIn extends IORecord<AnyComputeBuiltin>> = TgpuComputeFnShellHeader<ComputeIn>
|
3094
|
+
/**
|
3013
3095
|
* Creates a type-safe implementation of this signature
|
3014
|
-
*/
|
3096
|
+
*/
|
3097
|
+
& ((implementation: (input: InferIO<ComputeIn>) => undefined) => TgpuComputeFn<ComputeIn>) & /**
|
3015
3098
|
* @param implementation
|
3016
3099
|
* Raw WGSL function implementation with header and body
|
3017
3100
|
* without `fn` keyword and function name
|
@@ -3027,16 +3110,16 @@ type TgpuComputeFnShell<ComputeIn extends Record<string, AnyComputeBuiltin>> = T
|
|
3027
3110
|
* e.g. `"(x: f32) -> f32 { return x; }"`;
|
3028
3111
|
*/ ((implementation: string) => TgpuComputeFn<ComputeIn>);
|
3029
3112
|
};
|
3030
|
-
interface TgpuComputeFn<ComputeIn extends
|
3031
|
-
readonly shell:
|
3113
|
+
interface TgpuComputeFn<ComputeIn extends IORecord<AnyComputeBuiltin> = any> extends TgpuNamable {
|
3114
|
+
readonly shell: TgpuComputeFnShellHeader<ComputeIn>;
|
3032
3115
|
$uses(dependencyMap: Record<string, unknown>): this;
|
3033
3116
|
}
|
3034
3117
|
declare function computeFn(options: {
|
3035
3118
|
workgroupSize: number[];
|
3036
3119
|
}): TgpuComputeFnShell<{}>;
|
3037
|
-
declare function computeFn<ComputeIn extends
|
3120
|
+
declare function computeFn<ComputeIn extends IORecord<AnyComputeBuiltin>>(options: {
|
3038
3121
|
in: ComputeIn;
|
3039
3122
|
workgroupSize: number[];
|
3040
3123
|
}): TgpuComputeFnShell<ComputeIn>;
|
3041
3124
|
|
3042
|
-
export { type TgpuRenderPipeline as $, type AnyWgslData as A, isComparisonSampler as B, isSampler as C, type Disarray as D, isSampledTextureView as E, isStorageTextureView as F, isTexture as G, isUsableAsRender as H, type Infer as I, type JitTranspiler as J, isUsableAsSampled as K, isUsableAsStorage as L, asMutable as M, asReadonly as N, asUniform as O, isUsableAsUniform as P, isTgpuFn as Q, RandomNameRegistry as R, StrictNameRegistry as S, type TgpuRoot as T, type WithBinding as U, type WithCompute as V, type Wgsl as W, type WithFragment as X, type WithVertex as Y, type Storage as Z, type StorageFlag as _, type TgpuFn as a, type Vec4u as a$, type TgpuComputePipeline as a0, type Uniform as a1, type UniformFlag as a2, type Vertex as a3, type VertexFlag as a4, type TgpuBufferMutable as a5, type TgpuBufferReadonly as a6, type TgpuBufferUniform as a7, type Eventual as a8, type TgpuAnyTextureView as a9, type TgpuVertexFnShell as aA, type TgpuFragmentFn as aB, type TgpuFragmentFnShell as aC, type TgpuComputeFn as aD, type TgpuComputeFnShell as aE, type TgpuDeclare as aF, type Bool as aG, type F16 as aH, type F32 as aI, type I32 as aJ, type U32 as aK, type WgslStruct as aL, type Ptr as aM, type Vec2b as aN, type Vec2f as aO, type Vec2h as aP, type Vec2i as aQ, type Vec2u as aR, type Vec3b as aS, type Vec3f as aT, type Vec3h as aU, type Vec3i as aV, type Vec3u as aW, type Vec4b as aX, type Vec4f as aY, type Vec4h as aZ, type Vec4i as a_, type TgpuMutableTexture as aa, type TgpuReadonlyTexture as ab, type TgpuSampledTexture as ac, type TgpuTexture as ad, type TgpuWriteonlyTexture as ae, type TextureProps as af, type Render as ag, type Sampled as ah, type TgpuConst as ai, type TgpuVar as aj, type VariableScope as ak, type TgpuSampler as al, type BindLayoutEntry as am, type ExtractBindGroupInputFromLayout as an, type LayoutEntryToInput as ao, type TgpuBindGroup as ap, type TgpuLayoutComparisonSampler as aq, type TgpuLayoutEntry as ar, type TgpuLayoutExternalTexture as as, type TgpuLayoutSampler as at, type TgpuLayoutStorage as au, type TgpuLayoutStorageTexture as av, type TgpuLayoutTexture as aw, type TgpuLayoutUniform as ax, type TgpuFnShell as ay, type TgpuVertexFn as az, type TgpuBufferUsage as b, type
|
3125
|
+
export { type TgpuRenderPipeline as $, type AnyWgslData as A, isComparisonSampler as B, isSampler as C, type Disarray as D, isSampledTextureView as E, isStorageTextureView as F, isTexture as G, isUsableAsRender as H, type Infer as I, type JitTranspiler as J, isUsableAsSampled as K, isUsableAsStorage as L, asMutable as M, asReadonly as N, asUniform as O, isUsableAsUniform as P, isTgpuFn as Q, RandomNameRegistry as R, StrictNameRegistry as S, type TgpuRoot as T, type WithBinding as U, type WithCompute as V, type Wgsl as W, type WithFragment as X, type WithVertex as Y, type Storage as Z, type StorageFlag as _, type TgpuFn as a, type Vec4u as a$, type TgpuComputePipeline as a0, type Uniform as a1, type UniformFlag as a2, type Vertex as a3, type VertexFlag as a4, type TgpuBufferMutable as a5, type TgpuBufferReadonly as a6, type TgpuBufferUniform as a7, type Eventual as a8, type TgpuAnyTextureView as a9, type TgpuVertexFnShell as aA, type TgpuFragmentFn as aB, type TgpuFragmentFnShell as aC, type TgpuComputeFn as aD, type TgpuComputeFnShell as aE, type TgpuDeclare as aF, type Bool as aG, type F16 as aH, type F32 as aI, type I32 as aJ, type U32 as aK, type WgslStruct as aL, type Ptr as aM, type Vec2b as aN, type Vec2f as aO, type Vec2h as aP, type Vec2i as aQ, type Vec2u as aR, type Vec3b as aS, type Vec3f as aT, type Vec3h as aU, type Vec3i as aV, type Vec3u as aW, type Vec4b as aX, type Vec4f as aY, type Vec4h as aZ, type Vec4i as a_, type TgpuMutableTexture as aa, type TgpuReadonlyTexture as ab, type TgpuSampledTexture as ac, type TgpuTexture as ad, type TgpuWriteonlyTexture as ae, type TextureProps as af, type Render as ag, type Sampled as ah, type TgpuConst as ai, type TgpuVar as aj, type VariableScope as ak, type TgpuSampler as al, type BindLayoutEntry as am, type ExtractBindGroupInputFromLayout as an, type LayoutEntryToInput as ao, type TgpuBindGroup as ap, type TgpuLayoutComparisonSampler as aq, type TgpuLayoutEntry as ar, type TgpuLayoutExternalTexture as as, type TgpuLayoutSampler as at, type TgpuLayoutStorage as au, type TgpuLayoutStorageTexture as av, type TgpuLayoutTexture as aw, type TgpuLayoutUniform as ax, type TgpuFnShell as ay, type TgpuVertexFn as az, type TgpuBufferUsage as b, type BuiltinLocalInvocationId as b$, type BaseData as b0, type Unstruct as b1, type Atomic as b2, isAlignAttrib as b3, isAtomic as b4, isBuiltinAttrib as b5, isDecorated as b6, isInterpolateAttrib as b7, isLocationAttrib as b8, isPtr as b9, type v3u as bA, type v4b as bB, type v4f as bC, type v4i as bD, type v4u as bE, type AnyLooseData as bF, type LooseDecorated as bG, align as bH, type AnyAttribute as bI, type HasCustomLocation as bJ, interpolate as bK, type IsBuiltin as bL, isBuiltin as bM, location as bN, size as bO, isData as bP, isDisarray as bQ, isLooseData as bR, isLooseDecorated as bS, isUnstruct as bT, builtin as bU, type AnyBuiltin as bV, type BuiltinClipDistances as bW, type BuiltinFragDepth as bX, type BuiltinFrontFacing as bY, type BuiltinGlobalInvocationId as bZ, type BuiltinInstanceIndex as b_, isSizeAttrib as ba, isWgslArray as bb, isWgslData as bc, isWgslStruct as bd, Void as be, type Align as bf, type AnyVecInstance as bg, type AnyWgslStruct as bh, type Builtin as bi, type Decorated as bj, type Interpolate as bk, type Location as bl, type m2x2f as bm, type m3x3f as bn, type m4x4f as bo, type Mat2x2f as bp, type Mat3x3f as bq, type Mat4x4f as br, type Size as bs, type v2b as bt, type v2f as bu, type v2i as bv, type v2u as bw, type v3b as bx, type v3f as by, type v3i as bz, type TgpuAccessor as c, type v4h as c$, type BuiltinLocalInvocationIndex as c0, type BuiltinNumWorkgroups as c1, type BuiltinPosition as c2, type BuiltinSampleIndex as c3, type BuiltinSampleMask as c4, type BuiltinVertexIndex as c5, type BuiltinWorkgroupId as c6, type InferGPU as c7, type InferPartial as c8, type FormatToWGSLType as c9, snorm16x4 as cA, float16 as cB, float16x2 as cC, float16x4 as cD, float32 as cE, float32x2 as cF, float32x3 as cG, float32x4 as cH, uint32 as cI, uint32x2 as cJ, uint32x3 as cK, uint32x4 as cL, sint32 as cM, sint32x2 as cN, sint32x3 as cO, sint32x4 as cP, unorm10_10_10_2 as cQ, unorm8x4_bgra as cR, type PackedData as cS, type TgpuDualFn as cT, type AnyNumericVecInstance as cU, type AnyMatInstance as cV, type vBaseForMat as cW, type mBaseForVec as cX, type AnyFloatVecInstance as cY, type v3h as cZ, type v2h as c_, type TgpuVertexFormatData as ca, formatToWGSLType as cb, packedFormats as cc, uint8 as cd, uint8x2 as ce, uint8x4 as cf, sint8 as cg, sint8x2 as ch, sint8x4 as ci, unorm8 as cj, unorm8x2 as ck, unorm8x4 as cl, snorm8 as cm, snorm8x2 as cn, snorm8x4 as co, uint16 as cp, uint16x2 as cq, uint16x4 as cr, sint16 as cs, sint16x2 as ct, sint16x4 as cu, unorm16 as cv, unorm16x2 as cw, unorm16x4 as cx, snorm16 as cy, snorm16x2 as cz, type TgpuDerived as d, type AnyVec2Instance as d0, type AnyVec3Instance as d1, type AnyBooleanVecInstance as d2, type atomicI32 as d3, type atomicU32 as d4, type TgpuStorageTexture as d5, type TexelData as d6, type ChannelData as d7, type TgpuSlot as e, type TgpuBindGroupLayout as f, type TgpuVertexLayout as g, type WgslArray as h, type TgpuBuffer as i, type AnyData as j, bindGroupLayout as k, fn as l, fragmentFn as m, vertexFn as n, computeFn as o, privateVar as p, constant as q, declare as r, sampler as s, comparisonSampler as t, isBuffer as u, vertexLayout as v, workgroupVar as w, isUsableAsVertex as x, isDerived as y, isSlot as z };
|