typegpu 0.5.9 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chunk-APTRHY5Y.js +41 -0
- package/chunk-APTRHY5Y.js.map +1 -0
- package/chunk-RC26P3MP.cjs +2 -0
- package/chunk-RC26P3MP.cjs.map +1 -0
- package/{chunk-CGVYLGBG.js → chunk-RK6TMFVW.js} +2 -2
- package/chunk-S62QJDM6.js +2 -0
- package/chunk-S62QJDM6.js.map +1 -0
- package/chunk-TG4A6AM3.cjs +2 -0
- package/chunk-TG4A6AM3.cjs.map +1 -0
- package/chunk-UMHCZDPA.cjs +41 -0
- package/chunk-UMHCZDPA.cjs.map +1 -0
- package/data/index.cjs +1 -1
- package/data/index.cjs.map +1 -1
- package/data/index.d.cts +30 -4
- package/data/index.d.ts +30 -4
- package/data/index.js +1 -1
- package/index.cjs +20 -20
- package/index.cjs.map +1 -1
- package/index.d.cts +62 -11
- package/index.d.ts +62 -11
- package/index.js +20 -20
- package/index.js.map +1 -1
- package/{matrix-BnXitNJ7.d.cts → matrix-BN6ObiMv.d.cts} +1 -1
- package/{matrix-BULDDGYa.d.ts → matrix-S8W4dk8I.d.ts} +1 -1
- package/package.json +1 -1
- package/std/index.cjs +1 -1
- package/std/index.cjs.map +1 -1
- package/std/index.d.cts +2 -2
- package/std/index.d.ts +2 -2
- package/std/index.js +1 -1
- package/{tgpuComputeFn-BxPDI5hQ.d.ts → tgpuComputeFn-DOUjhQua.d.cts} +370 -157
- package/{tgpuComputeFn-BxPDI5hQ.d.cts → tgpuComputeFn-DOUjhQua.d.ts} +370 -157
- package/chunk-734H4JWF.js +0 -2
- package/chunk-734H4JWF.js.map +0 -1
- package/chunk-BJSN5UVV.cjs +0 -41
- package/chunk-BJSN5UVV.cjs.map +0 -1
- package/chunk-BZVU4Q6A.cjs +0 -2
- package/chunk-BZVU4Q6A.cjs.map +0 -1
- package/chunk-CDUKTYES.cjs +0 -2
- package/chunk-CDUKTYES.cjs.map +0 -1
- package/chunk-SWJVYRFM.js +0 -41
- package/chunk-SWJVYRFM.js.map +0 -1
- /package/{LICENSE.md → LICENSE} +0 -0
- /package/{chunk-CGVYLGBG.js.map → chunk-RK6TMFVW.js.map} +0 -0
@@ -1,6 +1,30 @@
|
|
1
|
-
import * as tinyest from 'tinyest';
|
2
1
|
import { FuncParameter, Block } from 'tinyest';
|
3
2
|
|
3
|
+
interface MetaData {
|
4
|
+
name?: string | undefined;
|
5
|
+
ast?: {
|
6
|
+
v: number;
|
7
|
+
params: FuncParameter[];
|
8
|
+
body: Block;
|
9
|
+
externalNames: string[];
|
10
|
+
} | undefined;
|
11
|
+
externals?: Record<string, unknown> | undefined;
|
12
|
+
}
|
13
|
+
/**
|
14
|
+
* Don't use or you WILL get fired from your job.
|
15
|
+
*
|
16
|
+
* The information that this type describes is additional
|
17
|
+
* properties that we add onto `globalThis`, used by tools
|
18
|
+
* like `unplugin-typegpu` or our test suite.
|
19
|
+
*
|
20
|
+
* @internal
|
21
|
+
*/
|
22
|
+
type INTERNAL_GlobalExt = typeof globalThis & {
|
23
|
+
__TYPEGPU_META__: WeakMap<object, MetaData>;
|
24
|
+
__TYPEGPU_AUTONAME__: <T>(exp: T, label: string) => T;
|
25
|
+
__TYPEGPU_MEASURE_PERF__?: boolean | undefined;
|
26
|
+
__TYPEGPU_PERF_RECORDS__?: Map<string, unknown[]> | undefined;
|
27
|
+
};
|
4
28
|
/**
|
5
29
|
* Can be assigned a name. Not to be confused with
|
6
30
|
* being able to HAVE a name.
|
@@ -11,7 +35,30 @@ interface TgpuNamable {
|
|
11
35
|
$name(label: string): this;
|
12
36
|
}
|
13
37
|
|
38
|
+
declare const $internal: unique symbol;
|
39
|
+
/**
|
40
|
+
* Marks an object with slot-value bindings
|
41
|
+
*/
|
42
|
+
declare const $providing: unique symbol;
|
43
|
+
/**
|
44
|
+
* Type token for the inferred (CPU & GPU) representation of a resource
|
45
|
+
*/
|
14
46
|
declare const $repr: unique symbol;
|
47
|
+
/**
|
48
|
+
* Type token for the inferred (GPU-side) representation of a resource
|
49
|
+
* If present, it shadows the value of `$repr` for GPU-side inference.
|
50
|
+
*/
|
51
|
+
declare const $gpuRepr: unique symbol;
|
52
|
+
/**
|
53
|
+
* Type token for the inferred partial representation of a resource.
|
54
|
+
* If present, it shadows the value of `$repr` for use in partial IO.
|
55
|
+
*/
|
56
|
+
declare const $reprPartial: unique symbol;
|
57
|
+
/**
|
58
|
+
* Type token holding schemas that are identical in memory layout.
|
59
|
+
*/
|
60
|
+
declare const $memIdent: unique symbol;
|
61
|
+
|
15
62
|
/**
|
16
63
|
* Extracts the inferred representation of a resource.
|
17
64
|
* For inferring types as seen by the GPU, see {@link InferGPU}
|
@@ -34,7 +81,7 @@ type Infer<T> = T extends {
|
|
34
81
|
* type C = InferPartial<WgslArray<F32>> // => { idx: number; value: number | undefined }[] | undefined
|
35
82
|
*/
|
36
83
|
type InferPartial<T> = T extends {
|
37
|
-
readonly
|
84
|
+
readonly [$reprPartial]: infer TRepr;
|
38
85
|
} ? TRepr : T extends {
|
39
86
|
readonly [$repr]: infer TRepr;
|
40
87
|
} ? TRepr | undefined : T;
|
@@ -47,7 +94,7 @@ type InferPartial<T> = T extends {
|
|
47
94
|
* type C = InferGPU<Atomic<U32>> // => atomicU32
|
48
95
|
*/
|
49
96
|
type InferGPU<T> = T extends {
|
50
|
-
readonly
|
97
|
+
readonly [$gpuRepr]: infer TRepr;
|
51
98
|
} ? TRepr : Infer<T>;
|
52
99
|
type InferRecord<T extends Record<string | number | symbol, unknown>> = {
|
53
100
|
[Key in keyof T]: Infer<T[Key]>;
|
@@ -59,14 +106,12 @@ type InferGPURecord<T extends Record<string | number | symbol, unknown>> = {
|
|
59
106
|
[Key in keyof T]: InferGPU<T[Key]>;
|
60
107
|
};
|
61
108
|
type MemIdentity<T> = T extends {
|
62
|
-
readonly
|
109
|
+
readonly [$memIdent]: infer TMemIdent;
|
63
110
|
} ? TMemIdent : T;
|
64
111
|
type MemIdentityRecord<T extends Record<string | number | symbol, unknown>> = {
|
65
112
|
[Key in keyof T]: MemIdentity<T[Key]>;
|
66
113
|
};
|
67
114
|
|
68
|
-
declare const $internal: unique symbol;
|
69
|
-
|
70
115
|
type Default<T, TDefault> = unknown extends T ? TDefault : T extends undefined ? TDefault : T;
|
71
116
|
type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
|
72
117
|
type Prettify<T> = {
|
@@ -78,6 +123,11 @@ type Prettify<T> = {
|
|
78
123
|
type OmitProps<T extends Record<string, unknown>, Prop> = Pick<T, {
|
79
124
|
[Key in keyof T]: T[Key] extends Prop ? never : Key;
|
80
125
|
}[keyof T]>;
|
126
|
+
type NullableToOptional<T> = {
|
127
|
+
[K in keyof T as T[K] extends null ? K : never]?: T[K];
|
128
|
+
} & {
|
129
|
+
[K in keyof T as T[K] extends null ? never : K]: T[K];
|
130
|
+
};
|
81
131
|
/**
|
82
132
|
* The opposite of Readonly<T>
|
83
133
|
*/
|
@@ -687,6 +737,7 @@ interface Bool {
|
|
687
737
|
readonly [$internal]: true;
|
688
738
|
readonly type: 'bool';
|
689
739
|
readonly [$repr]: boolean;
|
740
|
+
(v?: number | boolean): boolean;
|
690
741
|
}
|
691
742
|
/**
|
692
743
|
* 32-bit float schema representing a single WGSL f32 value.
|
@@ -695,7 +746,7 @@ interface F32 {
|
|
695
746
|
readonly [$internal]: true;
|
696
747
|
readonly type: 'f32';
|
697
748
|
readonly [$repr]: number;
|
698
|
-
(v
|
749
|
+
(v?: number | boolean): number;
|
699
750
|
}
|
700
751
|
/**
|
701
752
|
* 16-bit float schema representing a single WGSL f16 value.
|
@@ -704,7 +755,7 @@ interface F16 {
|
|
704
755
|
readonly [$internal]: true;
|
705
756
|
readonly type: 'f16';
|
706
757
|
readonly [$repr]: number;
|
707
|
-
(v
|
758
|
+
(v?: number | boolean): number;
|
708
759
|
}
|
709
760
|
/**
|
710
761
|
* Signed 32-bit integer schema representing a single WGSL i32 value.
|
@@ -713,8 +764,8 @@ interface I32 {
|
|
713
764
|
readonly [$internal]: true;
|
714
765
|
readonly type: 'i32';
|
715
766
|
readonly [$repr]: number;
|
716
|
-
readonly
|
717
|
-
(v
|
767
|
+
readonly [$memIdent]: I32 | Atomic<I32> | DecoratedLocation<I32>;
|
768
|
+
(v?: number | boolean): number;
|
718
769
|
}
|
719
770
|
/**
|
720
771
|
* Unsigned 32-bit integer schema representing a single WGSL u32 value.
|
@@ -723,8 +774,16 @@ interface U32 {
|
|
723
774
|
readonly [$internal]: true;
|
724
775
|
readonly type: 'u32';
|
725
776
|
readonly [$repr]: number;
|
726
|
-
readonly
|
727
|
-
(v
|
777
|
+
readonly [$memIdent]: U32 | Atomic<U32> | DecoratedLocation<U32>;
|
778
|
+
(v?: number | boolean): number;
|
779
|
+
}
|
780
|
+
/**
|
781
|
+
* Unsigned 16-bit integer schema used exclusively for index buffer schemas.
|
782
|
+
*/
|
783
|
+
interface U16 {
|
784
|
+
readonly [$internal]: true;
|
785
|
+
readonly type: 'u16';
|
786
|
+
readonly [$repr]: number;
|
728
787
|
}
|
729
788
|
/**
|
730
789
|
* Type of the `d.vec2f` object/function: vector data type schema/constructor
|
@@ -1003,12 +1062,12 @@ interface WgslArray<TElement extends BaseData = BaseData> {
|
|
1003
1062
|
readonly elementCount: number;
|
1004
1063
|
readonly elementType: TElement;
|
1005
1064
|
readonly [$repr]: Infer<TElement>[];
|
1006
|
-
readonly
|
1007
|
-
readonly
|
1065
|
+
readonly [$gpuRepr]: InferGPU<TElement>[];
|
1066
|
+
readonly [$reprPartial]: {
|
1008
1067
|
idx: number;
|
1009
1068
|
value: InferPartial<TElement>;
|
1010
1069
|
}[] | undefined;
|
1011
|
-
readonly
|
1070
|
+
readonly [$memIdent]: WgslArray<MemIdentity<TElement>>;
|
1012
1071
|
}
|
1013
1072
|
/**
|
1014
1073
|
* Struct schema constructed via `d.struct` function.
|
@@ -1023,12 +1082,9 @@ interface WgslStruct<TProps extends Record<string, BaseData> = Record<string, Ba
|
|
1023
1082
|
readonly type: 'struct';
|
1024
1083
|
readonly propTypes: TProps;
|
1025
1084
|
readonly [$repr]: Prettify<InferRecord<TProps>>;
|
1026
|
-
|
1027
|
-
readonly
|
1028
|
-
|
1029
|
-
readonly '~memIdent': WgslStruct<Prettify<MemIdentityRecord<TProps>>>;
|
1030
|
-
/** Type-token, not available at runtime */
|
1031
|
-
readonly '~reprPartial': Prettify<Partial<InferPartialRecord<TProps>>> | undefined;
|
1085
|
+
readonly [$gpuRepr]: Prettify<InferGPURecord<TProps>>;
|
1086
|
+
readonly [$memIdent]: WgslStruct<Prettify<MemIdentityRecord<TProps>>>;
|
1087
|
+
readonly [$reprPartial]: Prettify<Partial<InferPartialRecord<TProps>>> | undefined;
|
1032
1088
|
}
|
1033
1089
|
type AnyWgslStruct = WgslStruct<any>;
|
1034
1090
|
type AddressSpace = 'uniform' | 'storage' | 'workgroup' | 'private' | 'function' | 'handle';
|
@@ -1050,8 +1106,8 @@ interface Atomic<TInner extends U32 | I32 = U32 | I32> {
|
|
1050
1106
|
readonly type: 'atomic';
|
1051
1107
|
readonly inner: TInner;
|
1052
1108
|
readonly [$repr]: Infer<TInner>;
|
1053
|
-
readonly
|
1054
|
-
readonly
|
1109
|
+
readonly [$gpuRepr]: TInner extends U32 ? atomicU32 : atomicI32;
|
1110
|
+
readonly [$memIdent]: MemIdentity<TInner>;
|
1055
1111
|
}
|
1056
1112
|
interface atomicU32 {
|
1057
1113
|
readonly [$internal]: true;
|
@@ -1095,17 +1151,17 @@ interface Decorated<TInner extends BaseData = BaseData, TAttribs extends unknown
|
|
1095
1151
|
readonly inner: TInner;
|
1096
1152
|
readonly attribs: TAttribs;
|
1097
1153
|
readonly [$repr]: Infer<TInner>;
|
1098
|
-
readonly
|
1099
|
-
readonly
|
1100
|
-
readonly
|
1154
|
+
readonly [$gpuRepr]: InferGPU<TInner>;
|
1155
|
+
readonly [$reprPartial]: InferPartial<TInner>;
|
1156
|
+
readonly [$memIdent]: TAttribs extends Location[] ? MemIdentity<TInner> | Decorated<MemIdentity<TInner>, TAttribs> : Decorated<MemIdentity<TInner>, TAttribs>;
|
1101
1157
|
}
|
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"];
|
1158
|
+
declare const wgslTypeLiterals: readonly ["bool", "f32", "f16", "i32", "u32", "u16", "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"];
|
1103
1159
|
type WgslTypeLiteral = (typeof wgslTypeLiterals)[number];
|
1104
1160
|
type PerspectiveOrLinearInterpolatableBaseType = F32 | F16 | Vec2f | Vec2h | Vec3f | Vec3h | Vec4f | Vec4h;
|
1105
1161
|
type PerspectiveOrLinearInterpolatableData = PerspectiveOrLinearInterpolatableBaseType | Decorated<PerspectiveOrLinearInterpolatableBaseType>;
|
1106
1162
|
type FlatInterpolatableAdditionalBaseType = I32 | U32 | Vec2i | Vec2u | Vec3i | Vec3u | Vec4i | Vec4u;
|
1107
1163
|
type FlatInterpolatableData = PerspectiveOrLinearInterpolatableData | FlatInterpolatableAdditionalBaseType | Decorated<FlatInterpolatableAdditionalBaseType>;
|
1108
|
-
type AnyWgslData = Bool | F32 | F16 | I32 | U32 | Vec2f | Vec2h | Vec2i | Vec2u | Vec2b | Vec3f | Vec3h | Vec3i | Vec3u | Vec3b | Vec4f | Vec4h | Vec4i | Vec4u | Vec4b | Mat2x2f | Mat3x3f | Mat4x4f | AnyWgslStruct | WgslArray | Ptr | Atomic | Decorated | AbstractInt | AbstractFloat | Void;
|
1164
|
+
type AnyWgslData = Bool | F32 | F16 | I32 | U32 | U16 | Vec2f | Vec2h | Vec2i | Vec2u | Vec2b | Vec3f | Vec3h | Vec3i | Vec3u | Vec3b | Vec4f | Vec4h | Vec4i | Vec4u | Vec4b | Mat2x2f | Mat3x3f | Mat4x4f | AnyWgslStruct | WgslArray | Ptr | Atomic<U32> | Atomic<I32> | Decorated | AbstractInt | AbstractFloat | Void;
|
1109
1165
|
declare function isWgslData(value: unknown): value is AnyWgslData;
|
1110
1166
|
/**
|
1111
1167
|
* Checks whether passed in value is an array schema,
|
@@ -1158,6 +1214,7 @@ declare function isDecorated<T extends Decorated>(value: unknown | T): value is
|
|
1158
1214
|
|
1159
1215
|
interface TgpuConst<TDataType extends AnyWgslData = AnyWgslData> extends TgpuNamable {
|
1160
1216
|
readonly value: InferGPU<TDataType>;
|
1217
|
+
readonly $: InferGPU<TDataType>;
|
1161
1218
|
readonly [$internal]: {
|
1162
1219
|
readonly dataType: TDataType;
|
1163
1220
|
};
|
@@ -1189,7 +1246,7 @@ type BuiltinPosition = Decorated<Vec4f, [Builtin<'position'>]>;
|
|
1189
1246
|
type BuiltinClipDistances = Decorated<WgslArray<U32>, [
|
1190
1247
|
Builtin<'clip_distances'>
|
1191
1248
|
]>;
|
1192
|
-
type BuiltinFrontFacing = Decorated<
|
1249
|
+
type BuiltinFrontFacing = Decorated<Bool, [Builtin<'front_facing'>]>;
|
1193
1250
|
type BuiltinFragDepth = Decorated<F32, [Builtin<'frag_depth'>]>;
|
1194
1251
|
type BuiltinSampleIndex = Decorated<U32, [Builtin<'sample_index'>]>;
|
1195
1252
|
type BuiltinSampleMask = Decorated<U32, [Builtin<'sample_mask'>]>;
|
@@ -1262,13 +1319,6 @@ interface TgpuQuerySet<T extends GPUQueryType> extends TgpuNamable {
|
|
1262
1319
|
destroy(): void;
|
1263
1320
|
}
|
1264
1321
|
|
1265
|
-
/**
|
1266
|
-
* Used to transpile JS resources into tinyest on demand.
|
1267
|
-
*/
|
1268
|
-
interface JitTranspiler {
|
1269
|
-
transpileFn(rawJs: string): TranspilationResult;
|
1270
|
-
}
|
1271
|
-
|
1272
1322
|
interface NameRegistry {
|
1273
1323
|
/**
|
1274
1324
|
* Creates a valid WGSL identifier, each guaranteed to be unique
|
@@ -1296,7 +1346,7 @@ declare class StrictNameRegistry implements NameRegistry {
|
|
1296
1346
|
type TgpuFnShellHeader<Args extends AnyData[], Return extends AnyData> = {
|
1297
1347
|
readonly [$internal]: true;
|
1298
1348
|
readonly argTypes: Args;
|
1299
|
-
readonly returnType: Return
|
1349
|
+
readonly returnType: Return;
|
1300
1350
|
readonly isEntry: false;
|
1301
1351
|
};
|
1302
1352
|
/**
|
@@ -1304,33 +1354,29 @@ type TgpuFnShellHeader<Args extends AnyData[], Return extends AnyData> = {
|
|
1304
1354
|
* Allows creating tgpu functions by calling this shell
|
1305
1355
|
* and passing the implementation (as WGSL string or JS function) as the argument.
|
1306
1356
|
*/
|
1307
|
-
type TgpuFnShell<Args extends AnyData[], Return extends AnyData> = TgpuFnShellHeader<Args, Return> & (
|
1308
|
-
|
1309
|
-
* @deprecated Invoke the shell as a function instead.
|
1310
|
-
*/
|
1311
|
-
does: ((implementation: (...args: InferArgs<Args>) => Infer<Return>) => TgpuFn<Args, Return>) & ((implementation: string) => TgpuFn<Args, Return>);
|
1312
|
-
};
|
1313
|
-
interface TgpuFnBase<Args extends AnyData[], Return extends AnyData> extends TgpuNamable {
|
1357
|
+
type TgpuFnShell<Args extends AnyData[], Return extends AnyData> = TgpuFnShellHeader<Args, Return> & (<T extends (...args: InferArgs<Args>) => Infer<Return>>(implementation: T) => TgpuFn<Prettify<InheritArgNames<(...args: Args) => Return, T>>['result']>) & ((implementation: string) => TgpuFn<(...args: Args) => Return>) & ((strings: TemplateStringsArray, ...values: unknown[]) => TgpuFn<(...args: Args) => Return>);
|
1358
|
+
interface TgpuFnBase<ImplSchema extends AnyFn> extends TgpuNamable {
|
1314
1359
|
readonly [$internal]: {
|
1315
|
-
implementation: Implementation<
|
1360
|
+
implementation: Implementation<ImplSchema>;
|
1316
1361
|
argTypes: FnArgsConversionHint;
|
1317
1362
|
};
|
1318
1363
|
readonly resourceType: 'function';
|
1319
|
-
readonly shell: TgpuFnShellHeader<
|
1320
|
-
readonly
|
1364
|
+
readonly shell: TgpuFnShellHeader<Parameters<ImplSchema>, Extract<ReturnType<ImplSchema>, AnyData>>;
|
1365
|
+
readonly [$providing]?: Providing | undefined;
|
1321
1366
|
$uses(dependencyMap: Record<string, unknown>): this;
|
1322
|
-
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TgpuFn<
|
1323
|
-
with<T extends AnyData>(accessor: TgpuAccessor<T>, value: TgpuFn<
|
1367
|
+
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TgpuFn<ImplSchema>;
|
1368
|
+
with<T extends AnyData>(accessor: TgpuAccessor<T>, value: TgpuFn<() => T> | TgpuBufferUsage<T> | Infer<T>): TgpuFn<ImplSchema>;
|
1324
1369
|
}
|
1325
|
-
type TgpuFn<
|
1370
|
+
type TgpuFn<ImplSchema extends AnyFn = (...args: any[]) => any> = TgpuFnBase<ImplSchema> & InferImplSchema<ImplSchema>;
|
1326
1371
|
declare function fn<Args extends AnyData[] | []>(argTypes: Args, returnType?: undefined): TgpuFnShell<Args, Void>;
|
1327
1372
|
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
|
1373
|
+
declare function isTgpuFn<Args extends AnyData[] | [], Return extends AnyData>(value: unknown | TgpuFn<(...args: Args) => Return>): value is TgpuFn<(...args: Args) => Return>;
|
1329
1374
|
|
1330
1375
|
interface TgpuSlot<T> extends TgpuNamable {
|
1376
|
+
readonly [$internal]: true;
|
1331
1377
|
readonly resourceType: 'slot';
|
1332
1378
|
readonly [$repr]: Infer<T>;
|
1333
|
-
readonly
|
1379
|
+
readonly [$gpuRepr]: InferGPU<T>;
|
1334
1380
|
readonly defaultValue: T | undefined;
|
1335
1381
|
/**
|
1336
1382
|
* Used to determine if code generated using either value `a` or `b` in place
|
@@ -1338,13 +1384,15 @@ interface TgpuSlot<T> extends TgpuNamable {
|
|
1338
1384
|
*/
|
1339
1385
|
areEqual(a: T, b: T): boolean;
|
1340
1386
|
readonly value: InferGPU<T>;
|
1387
|
+
readonly $: InferGPU<T>;
|
1341
1388
|
}
|
1342
1389
|
interface TgpuDerived<T> {
|
1343
1390
|
readonly resourceType: 'derived';
|
1344
1391
|
readonly value: InferGPU<T>;
|
1345
|
-
|
1346
|
-
|
1347
|
-
readonly
|
1392
|
+
readonly $: InferGPU<T>;
|
1393
|
+
readonly [$repr]: Infer<T>;
|
1394
|
+
readonly [$gpuRepr]: InferGPU<T>;
|
1395
|
+
readonly [$providing]?: Providing | undefined;
|
1348
1396
|
with<TValue>(slot: TgpuSlot<TValue>, value: Eventual<TValue>): TgpuDerived<T>;
|
1349
1397
|
/**
|
1350
1398
|
* @internal
|
@@ -1352,13 +1400,15 @@ interface TgpuDerived<T> {
|
|
1352
1400
|
'~compute'(): T;
|
1353
1401
|
}
|
1354
1402
|
interface TgpuAccessor<T extends AnyData = AnyData> extends TgpuNamable {
|
1403
|
+
readonly [$internal]: true;
|
1355
1404
|
readonly resourceType: 'accessor';
|
1356
1405
|
readonly [$repr]: Infer<T>;
|
1357
|
-
readonly
|
1406
|
+
readonly [$gpuRepr]: InferGPU<T>;
|
1358
1407
|
readonly schema: T;
|
1359
|
-
readonly defaultValue: TgpuFn<
|
1360
|
-
readonly slot: TgpuSlot<TgpuFn<
|
1408
|
+
readonly defaultValue: TgpuFn<() => T> | TgpuBufferUsage<T> | Infer<T> | undefined;
|
1409
|
+
readonly slot: TgpuSlot<TgpuFn<() => T> | TgpuBufferUsage<T> | Infer<T>>;
|
1361
1410
|
readonly value: InferGPU<T>;
|
1411
|
+
readonly $: InferGPU<T>;
|
1362
1412
|
}
|
1363
1413
|
/**
|
1364
1414
|
* Represents a value that is available at resolution time.
|
@@ -1372,6 +1422,38 @@ type Providing = {
|
|
1372
1422
|
declare function isSlot<T>(value: unknown | TgpuSlot<T>): value is TgpuSlot<T>;
|
1373
1423
|
declare function isDerived<T extends TgpuDerived<unknown>>(value: T | unknown): value is T;
|
1374
1424
|
|
1425
|
+
interface Timeable {
|
1426
|
+
withPerformanceCallback(callback: (start: bigint, end: bigint) => void | Promise<void>): this;
|
1427
|
+
withTimestampWrites(options: {
|
1428
|
+
querySet: TgpuQuerySet<'timestamp'> | GPUQuerySet;
|
1429
|
+
beginningOfPassWriteIndex?: number;
|
1430
|
+
endOfPassWriteIndex?: number;
|
1431
|
+
}): this;
|
1432
|
+
}
|
1433
|
+
type TimestampWritesPriors = {
|
1434
|
+
readonly timestampWrites?: {
|
1435
|
+
querySet: TgpuQuerySet<'timestamp'> | GPUQuerySet;
|
1436
|
+
beginningOfPassWriteIndex?: number;
|
1437
|
+
endOfPassWriteIndex?: number;
|
1438
|
+
};
|
1439
|
+
readonly performanceCallback?: (start: bigint, end: bigint) => void | Promise<void>;
|
1440
|
+
readonly hasAutoQuerySet?: boolean;
|
1441
|
+
};
|
1442
|
+
|
1443
|
+
interface ComputePipelineInternals {
|
1444
|
+
readonly rawPipeline: GPUComputePipeline;
|
1445
|
+
readonly priors: TgpuComputePipelinePriors & TimestampWritesPriors;
|
1446
|
+
}
|
1447
|
+
interface TgpuComputePipeline extends TgpuNamable, SelfResolvable, Timeable {
|
1448
|
+
readonly [$internal]: ComputePipelineInternals;
|
1449
|
+
readonly resourceType: 'compute-pipeline';
|
1450
|
+
with(bindGroupLayout: TgpuBindGroupLayout, bindGroup: TgpuBindGroup): TgpuComputePipeline;
|
1451
|
+
dispatchWorkgroups(x: number, y?: number | undefined, z?: number | undefined): void;
|
1452
|
+
}
|
1453
|
+
type TgpuComputePipelinePriors = {
|
1454
|
+
readonly bindGroupLayoutMap?: Map<TgpuBindGroupLayout, TgpuBindGroup>;
|
1455
|
+
} & TimestampWritesPriors;
|
1456
|
+
|
1375
1457
|
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"];
|
1376
1458
|
type VertexFormat = (typeof vertexFormats)[number];
|
1377
1459
|
declare const kindToDefaultFormatMap: {
|
@@ -1453,8 +1535,8 @@ type FragmentOutConstrained = IOLayout<Vec4f | Decorated<Vec4f, (Location | Inte
|
|
1453
1535
|
* Describes a fragment entry function signature (its arguments, return type and targets)
|
1454
1536
|
*/
|
1455
1537
|
type TgpuFragmentFnShellHeader<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = {
|
1456
|
-
readonly
|
1457
|
-
readonly
|
1538
|
+
readonly in: FragmentIn | undefined;
|
1539
|
+
readonly out: FragmentOut;
|
1458
1540
|
readonly returnType: IOLayoutToSchema<FragmentOut>;
|
1459
1541
|
readonly isEntry: true;
|
1460
1542
|
};
|
@@ -1482,6 +1564,7 @@ type TgpuFragmentFnShell<FragmentIn extends FragmentInConstrained, FragmentOut e
|
|
1482
1564
|
*/ ((implementation: string) => TgpuFragmentFn<OmitBuiltins<FragmentIn>, OmitBuiltins<FragmentOut>>);
|
1483
1565
|
};
|
1484
1566
|
interface TgpuFragmentFn<Varying extends FragmentInConstrained = FragmentInConstrained, Output extends FragmentOutConstrained = FragmentOutConstrained> extends TgpuNamable {
|
1567
|
+
readonly [$internal]: true;
|
1485
1568
|
readonly shell: TgpuFragmentFnShellHeader<Varying, Output>;
|
1486
1569
|
readonly outputType: IOLayoutToSchema<Output>;
|
1487
1570
|
$uses(dependencyMap: Record<string, unknown>): this;
|
@@ -1494,15 +1577,15 @@ declare function fragmentFn<FragmentIn extends FragmentInConstrained, FragmentOu
|
|
1494
1577
|
out: FragmentOut;
|
1495
1578
|
}): TgpuFragmentFnShell<FragmentIn, FragmentOut>;
|
1496
1579
|
|
1497
|
-
type VertexInConstrained = IORecord<BaseIOData | AnyVertexInputBuiltin>;
|
1580
|
+
type VertexInConstrained = IORecord<BaseIOData | Decorated<BaseIOData, Location[]> | AnyVertexInputBuiltin>;
|
1498
1581
|
type VertexOutConstrained = IORecord<BaseIOData | Decorated<BaseIOData, (Location | Interpolate)[]> | AnyVertexOutputBuiltin>;
|
1499
1582
|
/**
|
1500
1583
|
* Describes a vertex entry function signature (its arguments, return type and attributes)
|
1501
1584
|
*/
|
1502
1585
|
type TgpuVertexFnShellHeader<VertexIn extends VertexInConstrained, VertexOut extends VertexOutConstrained> = {
|
1586
|
+
readonly in: VertexIn | undefined;
|
1587
|
+
readonly out: VertexOut;
|
1503
1588
|
readonly argTypes: [IOLayoutToSchema<VertexIn>] | [];
|
1504
|
-
readonly returnType: IOLayoutToSchema<VertexOut>;
|
1505
|
-
readonly attributes: [VertexIn];
|
1506
1589
|
readonly isEntry: true;
|
1507
1590
|
};
|
1508
1591
|
/**
|
@@ -1516,10 +1599,9 @@ type TgpuVertexFnShell<VertexIn extends VertexInConstrained, VertexOut extends V
|
|
1516
1599
|
*/
|
1517
1600
|
does: ((implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>) & ((implementation: string) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>);
|
1518
1601
|
};
|
1519
|
-
interface TgpuVertexFn<VertexIn extends VertexInConstrained =
|
1602
|
+
interface TgpuVertexFn<VertexIn extends VertexInConstrained = VertexInConstrained, VertexOut extends VertexOutConstrained = VertexOutConstrained> extends TgpuNamable {
|
1603
|
+
readonly [$internal]: true;
|
1520
1604
|
readonly shell: TgpuVertexFnShellHeader<VertexIn, VertexOut>;
|
1521
|
-
readonly outputType: IOLayoutToSchema<VertexOut>;
|
1522
|
-
readonly inputType: IOLayoutToSchema<VertexIn> | undefined;
|
1523
1605
|
$uses(dependencyMap: Record<string, unknown>): this;
|
1524
1606
|
}
|
1525
1607
|
declare function vertexFn<VertexOut extends VertexOutConstrained>(options: {
|
@@ -1635,6 +1717,12 @@ declare const texelFormatToChannelType: {
|
|
1635
1717
|
'astc-12x10-unorm-srgb': F32;
|
1636
1718
|
'astc-12x12-unorm': F32;
|
1637
1719
|
'astc-12x12-unorm-srgb': F32;
|
1720
|
+
r16snorm: F32;
|
1721
|
+
r16unorm: F32;
|
1722
|
+
rg16unorm: F32;
|
1723
|
+
rg16snorm: F32;
|
1724
|
+
rgba16unorm: F32;
|
1725
|
+
rgba16snorm: F32;
|
1638
1726
|
};
|
1639
1727
|
type TexelFormatToChannelType = typeof texelFormatToChannelType;
|
1640
1728
|
type TexelFormatToStringChannels = {
|
@@ -1827,6 +1915,7 @@ type LayoutToAllowedAttribs<T> = T extends {
|
|
1827
1915
|
} : never;
|
1828
1916
|
|
1829
1917
|
interface TgpuVertexLayout<TData extends WgslArray | Disarray = WgslArray | Disarray> extends TgpuNamable {
|
1918
|
+
readonly [$internal]: true;
|
1830
1919
|
readonly resourceType: 'vertex-layout';
|
1831
1920
|
readonly stride: number;
|
1832
1921
|
readonly stepMode: 'vertex' | 'instance';
|
@@ -1840,13 +1929,20 @@ interface RenderPipelineInternals {
|
|
1840
1929
|
readonly core: RenderPipelineCore;
|
1841
1930
|
readonly priors: TgpuRenderPipelinePriors & TimestampWritesPriors;
|
1842
1931
|
}
|
1843
|
-
interface
|
1932
|
+
interface HasIndexBuffer {
|
1933
|
+
readonly hasIndexBuffer: true;
|
1934
|
+
drawIndexed(indexCount: number, instanceCount?: number, firstIndex?: number, baseVertex?: number, firstInstance?: number): void;
|
1935
|
+
}
|
1936
|
+
interface TgpuRenderPipeline<Output extends IOLayout = IOLayout> extends TgpuNamable, SelfResolvable, Timeable {
|
1844
1937
|
readonly [$internal]: RenderPipelineInternals;
|
1845
1938
|
readonly resourceType: 'render-pipeline';
|
1846
|
-
|
1847
|
-
with<
|
1848
|
-
|
1849
|
-
|
1939
|
+
readonly hasIndexBuffer: boolean;
|
1940
|
+
with<TData extends WgslArray | Disarray>(vertexLayout: TgpuVertexLayout<TData>, buffer: TgpuBuffer<TData> & VertexFlag): this;
|
1941
|
+
with<Entries extends Record<string, TgpuLayoutEntry | null>>(bindGroupLayout: TgpuBindGroupLayout<Entries>, bindGroup: TgpuBindGroup<Entries>): this;
|
1942
|
+
withColorAttachment(attachment: FragmentOutToColorAttachment<Output>): this;
|
1943
|
+
withDepthStencilAttachment(attachment: DepthStencilAttachment): this;
|
1944
|
+
withIndexBuffer(buffer: TgpuBuffer<AnyWgslData> & IndexFlag, offsetElements?: number, sizeElements?: number): this & HasIndexBuffer;
|
1945
|
+
withIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offsetBytes?: number, sizeBytes?: number): this & HasIndexBuffer;
|
1850
1946
|
draw(vertexCount: number, instanceCount?: number, firstVertex?: number, firstInstance?: number): void;
|
1851
1947
|
}
|
1852
1948
|
type FragmentOutToTargets<T extends IOLayout> = T extends IOData ? GPUColorTargetState : T extends Record<string, unknown> ? {
|
@@ -1956,7 +2052,9 @@ type RenderPipelineCoreOptions = {
|
|
1956
2052
|
vertexAttribs: AnyVertexAttribs;
|
1957
2053
|
vertexFn: TgpuVertexFn;
|
1958
2054
|
fragmentFn: TgpuFragmentFn;
|
1959
|
-
primitiveState: GPUPrimitiveState |
|
2055
|
+
primitiveState: GPUPrimitiveState | Omit<GPUPrimitiveState, 'stripIndexFormat'> & {
|
2056
|
+
stripIndexFormat?: U32 | U16;
|
2057
|
+
} | undefined;
|
1960
2058
|
depthStencilState: GPUDepthStencilState | undefined;
|
1961
2059
|
targets: AnyFragmentTargets;
|
1962
2060
|
multisampleState: GPUMultisampleState | undefined;
|
@@ -1966,54 +2064,30 @@ type TgpuRenderPipelinePriors = {
|
|
1966
2064
|
readonly bindGroupLayoutMap?: Map<TgpuBindGroupLayout, TgpuBindGroup> | undefined;
|
1967
2065
|
readonly colorAttachment?: AnyFragmentColorAttachment | undefined;
|
1968
2066
|
readonly depthStencilAttachment?: DepthStencilAttachment | undefined;
|
2067
|
+
readonly indexBuffer?: {
|
2068
|
+
buffer: TgpuBuffer<AnyWgslData> & IndexFlag | GPUBuffer;
|
2069
|
+
indexFormat: GPUIndexFormat;
|
2070
|
+
offsetBytes?: number | undefined;
|
2071
|
+
sizeBytes?: number | undefined;
|
2072
|
+
} | undefined;
|
1969
2073
|
} & TimestampWritesPriors;
|
1970
2074
|
type Memo = {
|
1971
2075
|
pipeline: GPURenderPipeline;
|
1972
|
-
|
1973
|
-
catchall: [number, TgpuBindGroup] |
|
2076
|
+
usedBindGroupLayouts: TgpuBindGroupLayout[];
|
2077
|
+
catchall: [number, TgpuBindGroup] | undefined;
|
1974
2078
|
};
|
1975
|
-
declare class RenderPipelineCore {
|
2079
|
+
declare class RenderPipelineCore implements SelfResolvable {
|
1976
2080
|
readonly options: RenderPipelineCoreOptions;
|
1977
2081
|
readonly usedVertexLayouts: TgpuVertexLayout[];
|
1978
2082
|
private _memo;
|
1979
2083
|
private readonly _vertexBufferLayouts;
|
1980
2084
|
private readonly _targets;
|
1981
2085
|
constructor(options: RenderPipelineCoreOptions);
|
2086
|
+
'~resolve'(ctx: ResolutionCtx): string;
|
2087
|
+
toString(): string;
|
1982
2088
|
unwrap(): Memo;
|
1983
2089
|
}
|
1984
2090
|
|
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
|
-
|
2017
2091
|
interface SamplerInternals {
|
2018
2092
|
readonly unwrap?: ((branch: Unwrapper) => GPUSampler) | undefined;
|
2019
2093
|
}
|
@@ -2108,8 +2182,12 @@ interface TgpuComparisonSampler {
|
|
2108
2182
|
readonly [$internal]: SamplerInternals;
|
2109
2183
|
readonly resourceType: 'sampler-comparison';
|
2110
2184
|
}
|
2111
|
-
|
2112
|
-
|
2185
|
+
interface TgpuFixedSampler extends TgpuSampler, TgpuNamable {
|
2186
|
+
}
|
2187
|
+
interface TgpuFixedComparisonSampler extends TgpuComparisonSampler, TgpuNamable {
|
2188
|
+
}
|
2189
|
+
declare function sampler(props: SamplerProps): TgpuFixedSampler;
|
2190
|
+
declare function comparisonSampler(props: ComparisonSamplerProps): TgpuFixedComparisonSampler;
|
2113
2191
|
declare function isSampler(resource: unknown): resource is TgpuSampler;
|
2114
2192
|
declare function isComparisonSampler(resource: unknown): resource is TgpuComparisonSampler;
|
2115
2193
|
|
@@ -2128,10 +2206,37 @@ interface Unwrapper {
|
|
2128
2206
|
unwrap(resource: TgpuQuerySet<GPUQueryType>): GPUQuerySet;
|
2129
2207
|
}
|
2130
2208
|
|
2209
|
+
interface TgpuBufferShorthandBase<TData extends BaseData> extends TgpuNamable {
|
2210
|
+
readonly [$internal]: true;
|
2211
|
+
write(data: Infer<TData>): void;
|
2212
|
+
writePartial(data: InferPartial<TData>): void;
|
2213
|
+
read(): Promise<Infer<TData>>;
|
2214
|
+
}
|
2215
|
+
interface TgpuMutable<TData extends BaseData> extends TgpuBufferShorthandBase<TData> {
|
2216
|
+
readonly resourceType: 'mutable';
|
2217
|
+
readonly buffer: TgpuBuffer<TData> & StorageFlag;
|
2218
|
+
value: InferGPU<TData>;
|
2219
|
+
$: InferGPU<TData>;
|
2220
|
+
}
|
2221
|
+
interface TgpuReadonly<TData extends BaseData> extends TgpuBufferShorthandBase<TData> {
|
2222
|
+
readonly resourceType: 'readonly';
|
2223
|
+
readonly buffer: TgpuBuffer<TData> & StorageFlag;
|
2224
|
+
readonly value: InferGPU<TData>;
|
2225
|
+
readonly $: InferGPU<TData>;
|
2226
|
+
}
|
2227
|
+
interface TgpuUniform<TData extends BaseData> extends TgpuBufferShorthandBase<TData> {
|
2228
|
+
readonly resourceType: 'uniform';
|
2229
|
+
readonly buffer: TgpuBuffer<TData> & UniformFlag;
|
2230
|
+
readonly value: InferGPU<TData>;
|
2231
|
+
readonly $: InferGPU<TData>;
|
2232
|
+
}
|
2233
|
+
type TgpuBufferShorthand<TData extends BaseData> = TgpuMutable<TData> | TgpuReadonly<TData> | TgpuUniform<TData>;
|
2234
|
+
declare function isBufferShorthand<TData extends BaseData>(value: unknown | TgpuBufferShorthand<TData>): value is TgpuBufferShorthand<TData>;
|
2235
|
+
|
2131
2236
|
interface WithCompute {
|
2132
2237
|
createPipeline(): TgpuComputePipeline;
|
2133
2238
|
}
|
2134
|
-
type ValidateFragmentIn<VertexOut extends
|
2239
|
+
type ValidateFragmentIn<VertexOut extends VertexOutConstrained, FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = UndecorateRecord<FragmentIn> extends Partial<UndecorateRecord<VertexOut>> ? UndecorateRecord<VertexOut> extends UndecorateRecord<FragmentIn> ? [
|
2135
2240
|
entryFn: TgpuFragmentFn<FragmentIn, FragmentOut>,
|
2136
2241
|
targets: FragmentOutToTargets<FragmentOut>
|
2137
2242
|
] : [
|
@@ -2147,20 +2252,29 @@ type ValidateFragmentIn<VertexOut extends IORecord, FragmentIn extends FragmentI
|
|
2147
2252
|
[Key in keyof FragmentIn & keyof VertexOut as FragmentIn[Key] extends VertexOut[Key] ? never : Key]: [got: VertexOut[Key], expecting: FragmentIn[Key]];
|
2148
2253
|
}
|
2149
2254
|
];
|
2150
|
-
interface WithVertex<VertexOut extends
|
2255
|
+
interface WithVertex<VertexOut extends VertexOutConstrained = VertexOutConstrained> {
|
2151
2256
|
withFragment<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained>(...args: ValidateFragmentIn<VertexOut, FragmentIn, FragmentOut>): WithFragment<FragmentOut>;
|
2152
2257
|
}
|
2153
2258
|
interface WithFragment<Output extends FragmentOutConstrained = FragmentOutConstrained> {
|
2154
|
-
withPrimitive(primitiveState: GPUPrimitiveState |
|
2259
|
+
withPrimitive(primitiveState: GPUPrimitiveState | Omit<GPUPrimitiveState, 'stripIndexFormat'> & {
|
2260
|
+
stripIndexFormat?: U32 | U16;
|
2261
|
+
} | undefined): WithFragment<Output>;
|
2155
2262
|
withDepthStencil(depthStencilState: GPUDepthStencilState | undefined): WithFragment<Output>;
|
2156
2263
|
withMultisample(multisampleState: GPUMultisampleState | undefined): WithFragment<Output>;
|
2157
2264
|
createPipeline(): TgpuRenderPipeline<Output>;
|
2158
2265
|
}
|
2266
|
+
interface Configurable {
|
2267
|
+
readonly bindings: [slot: TgpuSlot<unknown>, value: unknown][];
|
2268
|
+
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): Configurable;
|
2269
|
+
with<T extends AnyWgslData>(accessor: TgpuAccessor<T>, value: TgpuFn<() => T> | TgpuBufferUsage<T> | TgpuBufferShorthand<T> | Infer<T>): Configurable;
|
2270
|
+
pipe(transform: (cfg: Configurable) => Configurable): Configurable;
|
2271
|
+
}
|
2159
2272
|
interface WithBinding {
|
2160
|
-
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): WithBinding;
|
2161
|
-
with<T extends AnyWgslData>(accessor: TgpuAccessor<T>, value: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>): WithBinding;
|
2162
2273
|
withCompute<ComputeIn extends IORecord<AnyComputeBuiltin>>(entryFn: TgpuComputeFn<ComputeIn>): WithCompute;
|
2163
2274
|
withVertex<VertexIn extends VertexInConstrained, VertexOut extends VertexOutConstrained>(entryFn: TgpuVertexFn<VertexIn, VertexOut>, attribs: LayoutToAllowedAttribs<OmitBuiltins<VertexIn>>): WithVertex<VertexOut>;
|
2275
|
+
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): WithBinding;
|
2276
|
+
with<T extends AnyWgslData>(accessor: TgpuAccessor<T>, value: TgpuFn<() => T> | TgpuBufferUsage<T> | TgpuBufferShorthand<T> | Infer<T>): WithBinding;
|
2277
|
+
pipe(transform: (cfg: Configurable) => Configurable): WithBinding;
|
2164
2278
|
}
|
2165
2279
|
type CreateTextureOptions<TSize, TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormat extends GPUTextureFormat, TDimension extends GPUTextureDimension> = {
|
2166
2280
|
/**
|
@@ -2299,6 +2413,14 @@ interface RenderPass {
|
|
2299
2413
|
*/
|
2300
2414
|
drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): undefined;
|
2301
2415
|
}
|
2416
|
+
type ValidateSchema<TData extends AnyData> = HasNestedType<[
|
2417
|
+
TData
|
2418
|
+
], 'bool'> extends true ? 'Error: Bool is not host-shareable, use U32 or I32 instead' : HasNestedType<[TData], 'u16'> extends true ? TData extends {
|
2419
|
+
type: 'array';
|
2420
|
+
elementType: {
|
2421
|
+
type: 'u16';
|
2422
|
+
};
|
2423
|
+
} ? TData : 'Error: U16 is only usable inside arrays for index buffers' : TData;
|
2302
2424
|
interface TgpuRoot extends Unwrapper {
|
2303
2425
|
/**
|
2304
2426
|
* The GPU device associated with this root.
|
@@ -2313,7 +2435,7 @@ interface TgpuRoot extends Unwrapper {
|
|
2313
2435
|
* @param typeSchema The type of data that this buffer will hold.
|
2314
2436
|
* @param initial The initial value of the buffer. (optional)
|
2315
2437
|
*/
|
2316
|
-
createBuffer<TData extends AnyData>(typeSchema: TData
|
2438
|
+
createBuffer<TData extends AnyData>(typeSchema: ValidateSchema<TData>, initial?: Infer<TData> | undefined): TgpuBuffer<TData>;
|
2317
2439
|
/**
|
2318
2440
|
* Allocates memory on the GPU, allows passing data between host and shader.
|
2319
2441
|
*
|
@@ -2323,7 +2445,61 @@ interface TgpuRoot extends Unwrapper {
|
|
2323
2445
|
* @param typeSchema The type of data that this buffer will hold.
|
2324
2446
|
* @param gpuBuffer A vanilla WebGPU buffer.
|
2325
2447
|
*/
|
2326
|
-
createBuffer<TData extends AnyData>(typeSchema: TData
|
2448
|
+
createBuffer<TData extends AnyData>(typeSchema: ValidateSchema<TData>, gpuBuffer: GPUBuffer): TgpuBuffer<TData>;
|
2449
|
+
/**
|
2450
|
+
* Allocates memory on the GPU, allows passing data between host and shader.
|
2451
|
+
* Read-only on the GPU, optimized for small data. For a general-purpose buffer,
|
2452
|
+
* use {@link TgpuRoot.createBuffer}.
|
2453
|
+
*
|
2454
|
+
* @param typeSchema The type of data that this buffer will hold.
|
2455
|
+
* @param initial The initial value of the buffer. (optional)
|
2456
|
+
*/
|
2457
|
+
createUniform<TData extends AnyWgslData>(typeSchema: TData, initial?: Infer<TData>): TgpuUniform<TData>;
|
2458
|
+
/**
|
2459
|
+
* Allocates memory on the GPU, allows passing data between host and shader.
|
2460
|
+
* Read-only on the GPU, optimized for small data. For a general-purpose buffer,
|
2461
|
+
* use {@link TgpuRoot.createBuffer}.
|
2462
|
+
*
|
2463
|
+
* @param typeSchema The type of data that this buffer will hold.
|
2464
|
+
* @param gpuBuffer A vanilla WebGPU buffer.
|
2465
|
+
*/
|
2466
|
+
createUniform<TData extends AnyWgslData>(typeSchema: TData, gpuBuffer: GPUBuffer): TgpuUniform<TData>;
|
2467
|
+
/**
|
2468
|
+
* Allocates memory on the GPU, allows passing data between host and shader.
|
2469
|
+
* Can be mutated in-place on the GPU. For a general-purpose buffer,
|
2470
|
+
* use {@link TgpuRoot.createBuffer}.
|
2471
|
+
*
|
2472
|
+
* @param typeSchema The type of data that this buffer will hold.
|
2473
|
+
* @param initial The initial value of the buffer. (optional)
|
2474
|
+
*/
|
2475
|
+
createMutable<TData extends AnyWgslData>(typeSchema: TData, initial?: Infer<TData>): TgpuMutable<TData>;
|
2476
|
+
/**
|
2477
|
+
* Allocates memory on the GPU, allows passing data between host and shader.
|
2478
|
+
* Can be mutated in-place on the GPU. For a general-purpose buffer,
|
2479
|
+
* use {@link TgpuRoot.createBuffer}.
|
2480
|
+
*
|
2481
|
+
* @param typeSchema The type of data that this buffer will hold.
|
2482
|
+
* @param gpuBuffer A vanilla WebGPU buffer.
|
2483
|
+
*/
|
2484
|
+
createMutable<TData extends AnyWgslData>(typeSchema: TData, gpuBuffer: GPUBuffer): TgpuMutable<TData>;
|
2485
|
+
/**
|
2486
|
+
* Allocates memory on the GPU, allows passing data between host and shader.
|
2487
|
+
* Read-only on the GPU, optimized for large data. For a general-purpose buffer,
|
2488
|
+
* use {@link TgpuRoot.createBuffer}.
|
2489
|
+
*
|
2490
|
+
* @param typeSchema The type of data that this buffer will hold.
|
2491
|
+
* @param initial The initial value of the buffer. (optional)
|
2492
|
+
*/
|
2493
|
+
createReadonly<TData extends AnyWgslData>(typeSchema: TData, initial?: Infer<TData>): TgpuReadonly<TData>;
|
2494
|
+
/**
|
2495
|
+
* Allocates memory on the GPU, allows passing data between host and shader.
|
2496
|
+
* Read-only on the GPU, optimized for large data. For a general-purpose buffer,
|
2497
|
+
* use {@link TgpuRoot.createBuffer}.
|
2498
|
+
*
|
2499
|
+
* @param typeSchema The type of data that this buffer will hold.
|
2500
|
+
* @param gpuBuffer A vanilla WebGPU buffer.
|
2501
|
+
*/
|
2502
|
+
createReadonly<TData extends AnyWgslData>(typeSchema: TData, gpuBuffer: GPUBuffer): TgpuReadonly<TData>;
|
2327
2503
|
/**
|
2328
2504
|
* Creates a query set for collecting timestamps or occlusion queries.
|
2329
2505
|
*
|
@@ -2359,9 +2535,7 @@ interface TgpuRoot extends Unwrapper {
|
|
2359
2535
|
* @param entries A record with values being the resources populating the bind group
|
2360
2536
|
* and keys being their associated names, matching the layout keys.
|
2361
2537
|
*/
|
2362
|
-
createBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>>(layout: TgpuBindGroupLayout<Entries>, entries:
|
2363
|
-
[K in keyof OmitProps<Entries, null>]: LayoutEntryToInput<Entries[K]>;
|
2364
|
-
}): TgpuBindGroup<Entries>;
|
2538
|
+
createBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>>(layout: TgpuBindGroupLayout<Entries>, entries: ExtractBindGroupInputFromLayout<Entries>): TgpuBindGroup<Entries>;
|
2365
2539
|
/**
|
2366
2540
|
* Retrieves a read-only list of all enabled features of the GPU device.
|
2367
2541
|
* @returns A set of strings representing the enabled features.
|
@@ -2376,16 +2550,12 @@ interface TgpuRoot extends Unwrapper {
|
|
2376
2550
|
'~unstable': Omit<ExperimentalTgpuRoot, keyof TgpuRoot>;
|
2377
2551
|
}
|
2378
2552
|
interface ExperimentalTgpuRoot extends TgpuRoot, WithBinding {
|
2379
|
-
readonly jitTranspiler?: JitTranspiler | undefined;
|
2380
2553
|
readonly nameRegistry: NameRegistry;
|
2381
2554
|
/**
|
2382
2555
|
* The current command encoder. This property will
|
2383
2556
|
* hold the same value until `flush()` is called.
|
2384
2557
|
*/
|
2385
2558
|
readonly commandEncoder: GPUCommandEncoder;
|
2386
|
-
createUniform<TData extends AnyWgslData>(typeSchema: TData, initialOrBuffer?: Infer<TData> | GPUBuffer): TgpuBufferUniform<TData> & TgpuFixedBufferUsage<TData>;
|
2387
|
-
createMutable<TData extends AnyWgslData>(typeSchema: TData, initialOrBuffer?: Infer<TData> | GPUBuffer): TgpuBufferMutable<TData> & TgpuFixedBufferUsage<TData>;
|
2388
|
-
createReadonly<TData extends AnyWgslData>(typeSchema: TData, initialOrBuffer?: Infer<TData> | GPUBuffer): TgpuBufferReadonly<TData> & TgpuFixedBufferUsage<TData>;
|
2389
2559
|
createTexture<TWidth extends number, THeight extends number, TDepth extends number, TSize extends readonly [TWidth] | readonly [TWidth, THeight] | readonly [TWidth, THeight, TDepth], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormat extends GPUTextureFormat, TDimension extends GPUTextureDimension>(props: CreateTextureOptions<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormat, TDimension>): TgpuTexture<CreateTextureResult<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormat, TDimension>>;
|
2390
2560
|
beginRenderPass(descriptor: GPURenderPassDescriptor, callback: (pass: RenderPass) => void): void;
|
2391
2561
|
/**
|
@@ -2405,18 +2575,28 @@ type Uniform = UniformFlag;
|
|
2405
2575
|
interface VertexFlag {
|
2406
2576
|
usableAsVertex: true;
|
2407
2577
|
}
|
2578
|
+
interface IndexFlag {
|
2579
|
+
usableAsIndex: true;
|
2580
|
+
}
|
2408
2581
|
/**
|
2409
2582
|
* @deprecated Use VertexFlag instead.
|
2410
2583
|
*/
|
2411
2584
|
type Vertex = VertexFlag;
|
2412
|
-
type LiteralToUsageType<T extends 'uniform' | 'storage' | 'vertex'> = T extends 'uniform' ? UniformFlag : T extends 'storage' ? StorageFlag : T extends 'vertex' ? VertexFlag : never;
|
2585
|
+
type LiteralToUsageType<T extends 'uniform' | 'storage' | 'vertex' | 'index'> = T extends 'uniform' ? UniformFlag : T extends 'storage' ? StorageFlag : T extends 'vertex' ? VertexFlag : T extends 'index' ? IndexFlag : never;
|
2413
2586
|
type ViewUsages<TBuffer extends TgpuBuffer<BaseData>> = (boolean extends TBuffer['usableAsUniform'] ? never : 'uniform') | (boolean extends TBuffer['usableAsStorage'] ? never : 'readonly' | 'mutable');
|
2414
2587
|
type UsageTypeToBufferUsage<TData extends BaseData> = {
|
2415
2588
|
uniform: TgpuBufferUniform<TData> & TgpuFixedBufferUsage<TData>;
|
2416
2589
|
mutable: TgpuBufferMutable<TData> & TgpuFixedBufferUsage<TData>;
|
2417
2590
|
readonly: TgpuBufferReadonly<TData> & TgpuFixedBufferUsage<TData>;
|
2418
2591
|
};
|
2592
|
+
type IsIndexCompatible<TData extends BaseData> = UnwrapDecorated<TData> extends {
|
2593
|
+
readonly type: 'array';
|
2594
|
+
readonly elementType: infer TElement;
|
2595
|
+
} ? TElement extends BaseData ? UnwrapDecorated<TElement> extends {
|
2596
|
+
readonly type: 'u32' | 'u16';
|
2597
|
+
} ? true : false : false : false;
|
2419
2598
|
interface TgpuBuffer<TData extends BaseData> extends TgpuNamable {
|
2599
|
+
readonly [$internal]: true;
|
2420
2600
|
readonly resourceType: 'buffer';
|
2421
2601
|
readonly dataType: TData;
|
2422
2602
|
readonly initial?: Infer<TData> | undefined;
|
@@ -2425,7 +2605,8 @@ interface TgpuBuffer<TData extends BaseData> extends TgpuNamable {
|
|
2425
2605
|
usableAsUniform: boolean;
|
2426
2606
|
usableAsStorage: boolean;
|
2427
2607
|
usableAsVertex: boolean;
|
2428
|
-
|
2608
|
+
usableAsIndex: boolean;
|
2609
|
+
$usage<T extends RestrictUsages<TData>>(...usages: T): this & UnionToIntersection<LiteralToUsageType<T[number]>>;
|
2429
2610
|
$addFlags(flags: GPUBufferUsageFlags): this;
|
2430
2611
|
as<T extends ViewUsages<this>>(usage: T): UsageTypeToBufferUsage<TData>[T];
|
2431
2612
|
compileWriter(): void;
|
@@ -2437,9 +2618,16 @@ interface TgpuBuffer<TData extends BaseData> extends TgpuNamable {
|
|
2437
2618
|
}
|
2438
2619
|
declare function isBuffer<T extends TgpuBuffer<AnyData>>(value: T | unknown): value is T;
|
2439
2620
|
declare function isUsableAsVertex<T extends TgpuBuffer<AnyData>>(buffer: T): buffer is T & VertexFlag;
|
2440
|
-
type
|
2621
|
+
type IsArrayOfU32<TData extends BaseData> = UnwrapDecorated<TData> extends {
|
2622
|
+
readonly type: 'array';
|
2623
|
+
readonly elementType: infer TElement;
|
2624
|
+
} ? TElement extends BaseData ? UnwrapDecorated<TElement> extends {
|
2625
|
+
readonly type: 'u32';
|
2626
|
+
} ? true : false : false : false;
|
2627
|
+
type IsWgslLiteral<TData extends BaseData> = TData extends {
|
2441
2628
|
readonly type: WgslTypeLiteral;
|
2442
|
-
} ?
|
2629
|
+
} ? true : false;
|
2630
|
+
type RestrictUsages<TData extends BaseData> = string extends TData['type'] ? ('uniform' | 'storage' | 'vertex' | 'index')[] : IsIndexCompatible<TData> extends true ? IsArrayOfU32<TData> extends true ? ('uniform' | 'storage' | 'vertex' | 'index')[] : ['index'] : IsWgslLiteral<TData> extends true ? ('uniform' | 'storage' | 'vertex')[] : ['vertex'];
|
2443
2631
|
|
2444
2632
|
type TgpuLayoutEntryBase = {
|
2445
2633
|
/**
|
@@ -2499,6 +2687,7 @@ type TgpuLayoutEntry = TgpuLayoutUniform | TgpuLayoutStorage | TgpuLayoutSampler
|
|
2499
2687
|
type UnwrapRuntimeConstructorInner<T extends BaseData | ((_: number) => BaseData)> = T extends (_: number) => BaseData ? ReturnType<T> : T;
|
2500
2688
|
type UnwrapRuntimeConstructor<T extends AnyData | ((_: number) => AnyData)> = T extends unknown ? UnwrapRuntimeConstructorInner<T> : never;
|
2501
2689
|
interface TgpuBindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>> extends TgpuNamable {
|
2690
|
+
readonly [$internal]: true;
|
2502
2691
|
readonly resourceType: 'bind-group-layout';
|
2503
2692
|
readonly entries: Entries;
|
2504
2693
|
readonly bound: {
|
@@ -2554,12 +2743,12 @@ type GetStorageTextureRestriction<T extends TgpuLayoutStorageTexture> = Default<
|
|
2554
2743
|
format: T['storageTexture'];
|
2555
2744
|
dimension: Dimension;
|
2556
2745
|
} : never;
|
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;
|
2746
|
+
type LayoutEntryToInput<T extends TgpuLayoutEntry | null> = TgpuLayoutEntry | null extends T ? TgpuBuffer<AnyWgslData> | GPUBuffer | TgpuSampler | GPUSampler | TgpuComparisonSampler | GPUSampler | TgpuTexture | TgpuSampledTexture | TgpuMutableTexture | TgpuReadonlyTexture | TgpuWriteonlyTexture | GPUTextureView | GPUExternalTexture : 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;
|
2558
2747
|
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;
|
2559
2748
|
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;
|
2560
|
-
type ExtractBindGroupInputFromLayout<T extends Record<string, TgpuLayoutEntry | null>> = {
|
2749
|
+
type ExtractBindGroupInputFromLayout<T extends Record<string, TgpuLayoutEntry | null>> = NullableToOptional<{
|
2561
2750
|
[K in keyof T]: LayoutEntryToInput<T[K]>;
|
2562
|
-
}
|
2751
|
+
}>;
|
2563
2752
|
type TgpuBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>> = {
|
2564
2753
|
readonly resourceType: 'bind-group';
|
2565
2754
|
readonly layout: TgpuBindGroupLayout<Entries>;
|
@@ -2572,19 +2761,21 @@ interface TgpuBufferUsage<TData extends BaseData = BaseData, TUsage extends Bind
|
|
2572
2761
|
readonly usage: TUsage;
|
2573
2762
|
readonly [$repr]: Infer<TData>;
|
2574
2763
|
value: InferGPU<TData>;
|
2764
|
+
$: InferGPU<TData>;
|
2575
2765
|
readonly [$internal]: {
|
2576
2766
|
readonly dataType: TData;
|
2577
2767
|
};
|
2578
2768
|
}
|
2579
2769
|
interface TgpuBufferUniform<TData extends BaseData> extends TgpuBufferUsage<TData, 'uniform'> {
|
2580
2770
|
readonly value: InferGPU<TData>;
|
2771
|
+
readonly $: InferGPU<TData>;
|
2581
2772
|
}
|
2582
2773
|
interface TgpuBufferReadonly<TData extends BaseData> extends TgpuBufferUsage<TData, 'readonly'> {
|
2583
2774
|
readonly value: InferGPU<TData>;
|
2775
|
+
readonly $: InferGPU<TData>;
|
2584
2776
|
}
|
2585
2777
|
interface TgpuFixedBufferUsage<TData extends BaseData> extends TgpuNamable {
|
2586
2778
|
readonly buffer: TgpuBuffer<TData>;
|
2587
|
-
write(data: Infer<TData>): void;
|
2588
2779
|
}
|
2589
2780
|
interface TgpuBufferMutable<TData extends BaseData> extends TgpuBufferUsage<TData, 'mutable'> {
|
2590
2781
|
}
|
@@ -2628,7 +2819,7 @@ declare function privateVar<TDataType extends AnyData>(dataType: TDataType, init
|
|
2628
2819
|
*/
|
2629
2820
|
declare function workgroupVar<TDataType extends AnyData>(dataType: TDataType): TgpuVar<'workgroup', TDataType>;
|
2630
2821
|
|
2631
|
-
type ResolvableObject = SelfResolvable | TgpuBufferUsage | TgpuConst | TgpuDeclare | TgpuFn | TgpuComputeFn | TgpuFragmentFn | TgpuComputePipeline | TgpuRenderPipeline | TgpuVertexFn | TgpuSampler | TgpuAccessor | TgpuExternalTexture | TgpuTexture | TgpuAnyTextureView | TgpuVar | AnyVecInstance | AnyMatInstance | AnyData | TgpuFn
|
2822
|
+
type ResolvableObject = SelfResolvable | TgpuBufferUsage | TgpuConst | TgpuDeclare | TgpuFn | TgpuComputeFn | TgpuFragmentFn | TgpuComputePipeline | TgpuRenderPipeline | TgpuVertexFn | TgpuSampler | TgpuAccessor | TgpuExternalTexture | TgpuTexture | TgpuAnyTextureView | TgpuVar | AnyVecInstance | AnyMatInstance | AnyData | TgpuFn;
|
2632
2823
|
type Wgsl = Eventual<string | number | boolean | ResolvableObject>;
|
2633
2824
|
type TgpuShaderStage = 'compute' | 'vertex' | 'fragment';
|
2634
2825
|
interface FnToWgslOptions {
|
@@ -2687,15 +2878,12 @@ interface ResolutionCtx {
|
|
2687
2878
|
unwrap<T>(eventual: Eventual<T>): T;
|
2688
2879
|
resolve(item: unknown): string;
|
2689
2880
|
resolveValue<T extends BaseData>(value: Infer<T> | InferGPU<T>, schema: T): string;
|
2690
|
-
transpileFn(fn: string): {
|
2691
|
-
params: FuncParameter[];
|
2692
|
-
body: Block;
|
2693
|
-
externalNames: string[];
|
2694
|
-
};
|
2695
2881
|
fnToWgsl(options: FnToWgslOptions): {
|
2696
2882
|
head: Wgsl;
|
2697
2883
|
body: Wgsl;
|
2698
2884
|
};
|
2885
|
+
withVaryingLocations<T>(locations: Record<string, number>, callback: () => T): T;
|
2886
|
+
get varyingLocations(): Record<string, number> | undefined;
|
2699
2887
|
[$internal]: {
|
2700
2888
|
itemStateStack: ItemStateStack;
|
2701
2889
|
};
|
@@ -2867,7 +3055,7 @@ interface Disarray<TElement extends BaseData = BaseData> {
|
|
2867
3055
|
readonly elementCount: number;
|
2868
3056
|
readonly elementType: TElement;
|
2869
3057
|
readonly [$repr]: Infer<TElement>[];
|
2870
|
-
readonly
|
3058
|
+
readonly [$reprPartial]: {
|
2871
3059
|
idx: number;
|
2872
3060
|
value: InferPartial<TElement>;
|
2873
3061
|
}[] | undefined;
|
@@ -2886,9 +3074,9 @@ interface Unstruct<TProps extends Record<string, BaseData> = Record<string, Base
|
|
2886
3074
|
readonly type: 'unstruct';
|
2887
3075
|
readonly propTypes: TProps;
|
2888
3076
|
readonly [$repr]: Prettify<InferRecord<TProps>>;
|
2889
|
-
readonly
|
2890
|
-
readonly
|
2891
|
-
readonly
|
3077
|
+
readonly [$gpuRepr]: Prettify<InferGPURecord<TProps>>;
|
3078
|
+
readonly [$memIdent]: Unstruct<Prettify<MemIdentityRecord<TProps>>>;
|
3079
|
+
readonly [$reprPartial]: Prettify<Partial<InferPartialRecord<TProps>>> | undefined;
|
2892
3080
|
}
|
2893
3081
|
type AnyUnstruct = Unstruct<any>;
|
2894
3082
|
interface LooseDecorated<TInner extends BaseData = BaseData, TAttribs extends unknown[] = unknown[]> {
|
@@ -2941,6 +3129,25 @@ interface Snippet {
|
|
2941
3129
|
readonly value: unknown;
|
2942
3130
|
readonly dataType: AnyData | UnknownData;
|
2943
3131
|
}
|
3132
|
+
type UnwrapDecorated<TData extends BaseData> = TData extends {
|
3133
|
+
readonly type: 'decorated';
|
3134
|
+
readonly inner: infer TInner;
|
3135
|
+
} ? TInner extends BaseData ? UnwrapDecorated<TInner> : TData : TData;
|
3136
|
+
type HasNestedType<TData extends [BaseData], TType extends string> = UnwrapDecorated<TData[0]> extends {
|
3137
|
+
readonly type: TType;
|
3138
|
+
} ? true : UnwrapDecorated<TData[0]> extends {
|
3139
|
+
readonly type: 'array';
|
3140
|
+
readonly elementType: infer TElement;
|
3141
|
+
} ? TElement extends BaseData ? UnwrapDecorated<TElement> extends {
|
3142
|
+
readonly type: TType;
|
3143
|
+
} ? true : HasNestedType<[TElement], TType> : false : UnwrapDecorated<TData[0]> extends {
|
3144
|
+
readonly type: 'struct';
|
3145
|
+
readonly propTypes: infer TProps;
|
3146
|
+
} ? TProps extends Record<string, BaseData> ? true extends {
|
3147
|
+
[K in keyof TProps]: UnwrapDecorated<TProps[K]> extends {
|
3148
|
+
readonly type: TType;
|
3149
|
+
} ? true : HasNestedType<[TProps[K]], TType>;
|
3150
|
+
}[keyof TProps] ? true : false : false : false;
|
2944
3151
|
|
2945
3152
|
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"];
|
2946
3153
|
type BuiltinName = (typeof builtinNames)[number];
|
@@ -2951,6 +3158,9 @@ type ExtractAttributes<T> = T extends {
|
|
2951
3158
|
type Undecorate<T> = T extends {
|
2952
3159
|
readonly inner: infer TInner;
|
2953
3160
|
} ? TInner : T;
|
3161
|
+
type UndecorateRecord<T extends Record<string, unknown>> = {
|
3162
|
+
[Key in keyof T]: Undecorate<T[Key]>;
|
3163
|
+
};
|
2954
3164
|
/**
|
2955
3165
|
* Decorates a data-type `TData` with an attribute `TAttrib`.
|
2956
3166
|
*
|
@@ -3046,24 +3256,26 @@ declare function interpolate<TInterpolation extends PerspectiveOrLinearInterpola
|
|
3046
3256
|
declare function interpolate<TInterpolation extends FlatInterpolationType, TData extends FlatInterpolatableData>(interpolationType: TInterpolation, data: TData): Decorate<TData, Interpolate<TInterpolation>>;
|
3047
3257
|
declare function isBuiltin<T extends Decorated<AnyWgslData, AnyAttribute[]> | LooseDecorated<AnyLooseData, AnyAttribute[]>>(value: T | unknown): value is T;
|
3048
3258
|
|
3049
|
-
|
3050
|
-
* Information extracted from transpiling a JS function.
|
3051
|
-
*/
|
3052
|
-
type TranspilationResult = {
|
3053
|
-
params: tinyest.FuncParameter[];
|
3054
|
-
body: tinyest.Block;
|
3055
|
-
/**
|
3056
|
-
* All identifiers found in the function code that are not declared in the
|
3057
|
-
* function itself, or in the block that is accessing that identifier.
|
3058
|
-
*/
|
3059
|
-
externalNames: string[];
|
3060
|
-
};
|
3259
|
+
type AnyFn = (...args: never[]) => unknown;
|
3061
3260
|
type InferArgs<T extends unknown[]> = {
|
3062
3261
|
[Idx in keyof T]: Infer<T[Idx]>;
|
3063
3262
|
};
|
3064
|
-
type
|
3065
|
-
|
3066
|
-
|
3263
|
+
type InheritTupleValues<T, From> = {
|
3264
|
+
[K in keyof T]: K extends keyof From ? From[K] : never;
|
3265
|
+
};
|
3266
|
+
/**
|
3267
|
+
* Returns a type that has arg and return types of `T`, but argument
|
3268
|
+
* names of `From`
|
3269
|
+
*
|
3270
|
+
* Wrapped in an object type with `result` prop just so that it's easier
|
3271
|
+
* to remove InheritArgNames<...> from Intellisense with Prettify<T>['result']
|
3272
|
+
*/
|
3273
|
+
type InheritArgNames<T extends AnyFn, From extends AnyFn> = {
|
3274
|
+
result: (...args: Parameters<((...args: InheritTupleValues<Parameters<From>, Parameters<T>>) => ReturnType<T>) & T>) => ReturnType<T>;
|
3275
|
+
};
|
3276
|
+
type InferImplSchema<ImplSchema extends AnyFn> = (...args: InferArgs<Parameters<ImplSchema>>) => Infer<ReturnType<ImplSchema>>;
|
3277
|
+
type Implementation<ImplSchema extends AnyFn = AnyFn> = string | InferImplSchema<ImplSchema>;
|
3278
|
+
type BaseIOData = Bool | F32 | F16 | I32 | U32 | Vec2f | Vec3f | Vec4f | Vec2h | Vec3h | Vec4h | Vec2i | Vec3i | Vec4i | Vec2u | Vec3u | Vec4u;
|
3067
3279
|
type IOData = BaseIOData | Decorated<BaseIOData, AnyAttribute[]> | BuiltinClipDistances;
|
3068
3280
|
type IORecord<TElementType extends IOData = IOData> = Record<string, TElementType>;
|
3069
3281
|
/**
|
@@ -3111,6 +3323,7 @@ type TgpuComputeFnShell<ComputeIn extends IORecord<AnyComputeBuiltin>> = TgpuCom
|
|
3111
3323
|
*/ ((implementation: string) => TgpuComputeFn<ComputeIn>);
|
3112
3324
|
};
|
3113
3325
|
interface TgpuComputeFn<ComputeIn extends IORecord<AnyComputeBuiltin> = any> extends TgpuNamable {
|
3326
|
+
readonly [$internal]: true;
|
3114
3327
|
readonly shell: TgpuComputeFnShellHeader<ComputeIn>;
|
3115
3328
|
$uses(dependencyMap: Record<string, unknown>): this;
|
3116
3329
|
}
|
@@ -3122,4 +3335,4 @@ declare function computeFn<ComputeIn extends IORecord<AnyComputeBuiltin>>(option
|
|
3122
3335
|
workgroupSize: number[];
|
3123
3336
|
}): TgpuComputeFnShell<ComputeIn>;
|
3124
3337
|
|
3125
|
-
export { type
|
3338
|
+
export { type Storage as $, type AnyWgslData as A, isSlot as B, isComparisonSampler as C, type Disarray as D, isSampler as E, isSampledTextureView as F, isStorageTextureView as G, isTexture as H, type Infer as I, isUsableAsRender as J, isUsableAsSampled as K, isUsableAsStorage as L, asMutable as M, asReadonly as N, asUniform as O, isUsableAsUniform as P, isBufferShorthand as Q, RandomNameRegistry as R, StrictNameRegistry as S, type TgpuBindGroupLayout as T, isTgpuFn as U, type Configurable as V, type Wgsl as W, type WithBinding as X, type WithCompute as Y, type WithFragment as Z, type WithVertex as _, type TgpuBindGroup as a, type Vec3h as a$, type StorageFlag as a0, type TgpuRenderPipeline as a1, type TgpuComputePipeline as a2, type IndexFlag as a3, type Uniform as a4, type UniformFlag as a5, type Vertex as a6, type VertexFlag as a7, type TgpuBufferMutable as a8, type TgpuBufferReadonly as a9, type TgpuLayoutStorageTexture as aA, type TgpuLayoutTexture as aB, type TgpuLayoutUniform as aC, type TgpuFnShell as aD, type TgpuVertexFn as aE, type TgpuVertexFnShell as aF, type TgpuFragmentFn as aG, type TgpuFragmentFnShell as aH, type TgpuComputeFn as aI, type TgpuComputeFnShell as aJ, type TgpuDeclare as aK, type INTERNAL_GlobalExt as aL, type Bool as aM, type F16 as aN, type F32 as aO, type I32 as aP, type U16 as aQ, type U32 as aR, type WgslStruct as aS, type Ptr as aT, type Vec2b as aU, type Vec2f as aV, type Vec2h as aW, type Vec2i as aX, type Vec2u as aY, type Vec3b as aZ, type Vec3f as a_, type TgpuBufferUniform as aa, type TgpuMutable as ab, type TgpuReadonly as ac, type TgpuUniform as ad, type Eventual as ae, type TgpuAnyTextureView as af, type TgpuMutableTexture as ag, type TgpuReadonlyTexture as ah, type TgpuSampledTexture as ai, type TgpuTexture as aj, type TgpuWriteonlyTexture as ak, type TextureProps as al, type Render as am, type Sampled as an, type TgpuConst as ao, type TgpuVar as ap, type VariableScope as aq, type TgpuSampler as ar, type BindLayoutEntry as as, type ExtractBindGroupInputFromLayout as at, type LayoutEntryToInput as au, type TgpuLayoutComparisonSampler as av, type TgpuLayoutEntry as aw, type TgpuLayoutExternalTexture as ax, type TgpuLayoutSampler as ay, type TgpuLayoutStorage as az, type TgpuRoot as b, builtin as b$, type Vec3i as b0, type Vec3u as b1, type Vec4b as b2, type Vec4f as b3, type Vec4h as b4, type Vec4i as b5, type Vec4u as b6, type BaseData as b7, type Unstruct as b8, type Atomic as b9, type v2b as bA, type v2f as bB, type v2i as bC, type v2u as bD, type v3b as bE, type v3f as bF, type v3i as bG, type v3u as bH, type v4b as bI, type v4f as bJ, type v4i as bK, type v4u as bL, type AnyLooseData as bM, type LooseDecorated as bN, align as bO, type AnyAttribute as bP, type HasCustomLocation as bQ, interpolate as bR, type IsBuiltin as bS, isBuiltin as bT, location as bU, size as bV, isData as bW, isDisarray as bX, isLooseData as bY, isLooseDecorated as bZ, isUnstruct as b_, isAlignAttrib as ba, isAtomic as bb, isBuiltinAttrib as bc, isDecorated as bd, isInterpolateAttrib as be, isLocationAttrib as bf, isPtr as bg, isSizeAttrib as bh, isWgslArray as bi, isWgslData as bj, isWgslStruct as bk, Void as bl, type Align as bm, type AnyVecInstance as bn, type AnyWgslStruct as bo, type Builtin as bp, type Decorated as bq, type Interpolate as br, type Location as bs, type m2x2f as bt, type m3x3f as bu, type m4x4f as bv, type Mat2x2f as bw, type Mat3x3f as bx, type Mat4x4f as by, type Size as bz, type TgpuFn as c, type AnyNumericVecInstance as c$, type AnyBuiltin as c0, type BuiltinClipDistances as c1, type BuiltinFragDepth as c2, type BuiltinFrontFacing as c3, type BuiltinGlobalInvocationId as c4, type BuiltinInstanceIndex as c5, type BuiltinLocalInvocationId as c6, type BuiltinLocalInvocationIndex as c7, type BuiltinNumWorkgroups as c8, type BuiltinPosition as c9, sint16x2 as cA, sint16x4 as cB, unorm16 as cC, unorm16x2 as cD, unorm16x4 as cE, snorm16 as cF, snorm16x2 as cG, snorm16x4 as cH, float16 as cI, float16x2 as cJ, float16x4 as cK, float32 as cL, float32x2 as cM, float32x3 as cN, float32x4 as cO, uint32 as cP, uint32x2 as cQ, uint32x3 as cR, uint32x4 as cS, sint32 as cT, sint32x2 as cU, sint32x3 as cV, sint32x4 as cW, unorm10_10_10_2 as cX, unorm8x4_bgra as cY, type PackedData as cZ, type TgpuDualFn as c_, type BuiltinSampleIndex as ca, type BuiltinSampleMask as cb, type BuiltinVertexIndex as cc, type BuiltinWorkgroupId as cd, type InferGPU as ce, type InferPartial as cf, type FormatToWGSLType as cg, type TgpuVertexFormatData as ch, formatToWGSLType as ci, packedFormats as cj, uint8 as ck, uint8x2 as cl, uint8x4 as cm, sint8 as cn, sint8x2 as co, sint8x4 as cp, unorm8 as cq, unorm8x2 as cr, unorm8x4 as cs, snorm8 as ct, snorm8x2 as cu, snorm8x4 as cv, uint16 as cw, uint16x2 as cx, uint16x4 as cy, sint16 as cz, type TgpuBufferUsage as d, type AnyMatInstance as d0, type vBaseForMat as d1, type mBaseForVec as d2, type AnyFloatVecInstance as d3, type v3h as d4, type v2h as d5, type v4h as d6, type AnyVec2Instance as d7, type AnyVec3Instance as d8, type AnyBooleanVecInstance as d9, type atomicI32 as da, type atomicU32 as db, type TgpuStorageTexture as dc, type TexelData as dd, type ChannelData as de, type TgpuAccessor as e, type TgpuDerived as f, type TgpuSlot as g, type TgpuVertexLayout as h, type WgslArray as i, type TgpuBuffer as j, type AnyData as k, fn as l, bindGroupLayout as m, fragmentFn as n, vertexFn as o, computeFn as p, privateVar as q, constant as r, declare as s, sampler as t, comparisonSampler as u, vertexLayout as v, workgroupVar as w, isBuffer as x, isUsableAsVertex as y, isDerived as z };
|