typegpu 0.2.0-alpha.0 → 0.3.0-alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +2 -2
- package/chunk-CKSBATTP.cjs +2 -0
- package/chunk-CKSBATTP.cjs.map +1 -0
- package/chunk-IQYHODCR.js +2 -0
- package/chunk-IQYHODCR.js.map +1 -0
- package/data/index.cjs +1 -1
- package/data/index.d.cts +116 -373
- package/data/index.d.ts +116 -373
- package/data/index.js +1 -1
- package/index.cjs +14 -47
- package/index.cjs.map +1 -1
- package/index.d.cts +505 -168
- package/index.d.ts +505 -168
- package/index.js +14 -47
- package/index.js.map +1 -1
- package/package.json +3 -14
- package/utilityTypes-0b50gROn.d.cts +1122 -0
- package/utilityTypes-0b50gROn.d.ts +1122 -0
- package/chunk-5EPBCOO4.js +0 -8
- package/chunk-5EPBCOO4.js.map +0 -1
- package/chunk-SBJR5ZQJ.cjs +0 -8
- package/chunk-SBJR5ZQJ.cjs.map +0 -1
- package/types-qmW7FFqN.d.cts +0 -880
- package/types-qmW7FFqN.d.ts +0 -880
package/index.d.cts
CHANGED
@@ -1,25 +1,401 @@
|
|
1
|
-
import { T as
|
2
|
-
|
3
|
-
import {
|
1
|
+
import { T as TgpuNamable, D as Default, F as F32, U as U32, I as I32, V as Vec4f, a as Vec4u, b as Vec4i, c as UnionToIntersection, A as AnyData, d as Infer, E as Exotic, P as Prettify, M as Mutable, O as OmitProps, B as BaseWgslData, e as AnyWgslData } from './utilityTypes-0b50gROn.cjs';
|
2
|
+
import * as smol from 'tinyest';
|
3
|
+
import { Block } from 'tinyest';
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
/**
|
6
|
+
* Information extracted from transpiling a JS function.
|
7
|
+
*/
|
8
|
+
type TranspilationResult = {
|
9
|
+
argNames: string[];
|
10
|
+
body: smol.Block;
|
11
|
+
/**
|
12
|
+
* All identifiers found in the function code that are not declared in the
|
13
|
+
* function itself, or in the block that is accessing that identifier.
|
14
|
+
*/
|
15
|
+
externalNames: string[];
|
16
|
+
};
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Used to transpile JS resources into SMoL on demand.
|
20
|
+
*/
|
21
|
+
interface JitTranspiler {
|
22
|
+
transpileFn(rawJs: string): TranspilationResult;
|
8
23
|
}
|
9
24
|
|
10
|
-
|
25
|
+
interface NameRegistry {
|
26
|
+
/**
|
27
|
+
* Creates a valid WGSL identifier, each guaranteed to be unique
|
28
|
+
* in the lifetime of a single resolution process.
|
29
|
+
* @param primer Used in the generation process, makes the identifier more recognizable.
|
30
|
+
*/
|
31
|
+
makeUnique(primer?: string): string;
|
32
|
+
}
|
11
33
|
|
12
|
-
interface
|
13
|
-
|
34
|
+
interface NotAllowed<TMsg> {
|
35
|
+
reason: TMsg;
|
36
|
+
}
|
37
|
+
type ExtensionGuard<TFlag, TMsg, TAllowed> = boolean extends TFlag ? NotAllowed<TMsg> : TAllowed;
|
38
|
+
interface Storage {
|
39
|
+
usableAsStorage: true;
|
14
40
|
}
|
41
|
+
declare const Storage: Storage;
|
42
|
+
declare function isUsableAsStorage<T>(value: T): value is T & Storage;
|
43
|
+
|
44
|
+
interface TgpuComputePipeline extends TgpuNamable {
|
45
|
+
readonly resourceType: 'compute-pipeline';
|
46
|
+
readonly label: string | undefined;
|
47
|
+
with(bindGroupLayout: TgpuBindGroupLayout, bindGroup: TgpuBindGroup): TgpuComputePipeline;
|
48
|
+
dispatchWorkgroups(x: number, y?: number | undefined, z?: number | undefined): void;
|
49
|
+
}
|
50
|
+
|
51
|
+
type TextureProps = {
|
52
|
+
size: readonly number[];
|
53
|
+
format: GPUTextureFormat;
|
54
|
+
viewFormats?: GPUTextureFormat[] | undefined;
|
55
|
+
dimension?: GPUTextureDimension | undefined;
|
56
|
+
mipLevelCount?: number | undefined;
|
57
|
+
sampleCount?: number | undefined;
|
58
|
+
};
|
59
|
+
|
60
|
+
declare const texelFormatToChannelType: {
|
61
|
+
r8unorm: F32;
|
62
|
+
r8snorm: F32;
|
63
|
+
r8uint: U32;
|
64
|
+
r8sint: I32;
|
65
|
+
r16uint: U32;
|
66
|
+
r16sint: I32;
|
67
|
+
r16float: F32;
|
68
|
+
rg8unorm: F32;
|
69
|
+
rg8snorm: F32;
|
70
|
+
rg8uint: U32;
|
71
|
+
rg8sint: I32;
|
72
|
+
r32uint: U32;
|
73
|
+
r32sint: I32;
|
74
|
+
r32float: F32;
|
75
|
+
rg16uint: U32;
|
76
|
+
rg16sint: I32;
|
77
|
+
rg16float: F32;
|
78
|
+
rgba8unorm: F32;
|
79
|
+
'rgba8unorm-srgb': F32;
|
80
|
+
rgba8snorm: F32;
|
81
|
+
rgba8uint: U32;
|
82
|
+
rgba8sint: I32;
|
83
|
+
bgra8unorm: F32;
|
84
|
+
'bgra8unorm-srgb': F32;
|
85
|
+
rgb9e5ufloat: F32;
|
86
|
+
rgb10a2uint: U32;
|
87
|
+
rgb10a2unorm: F32;
|
88
|
+
rg11b10ufloat: F32;
|
89
|
+
rg32uint: U32;
|
90
|
+
rg32sint: I32;
|
91
|
+
rg32float: F32;
|
92
|
+
rgba16uint: U32;
|
93
|
+
rgba16sint: I32;
|
94
|
+
rgba16float: F32;
|
95
|
+
rgba32uint: U32;
|
96
|
+
rgba32sint: I32;
|
97
|
+
rgba32float: F32;
|
98
|
+
stencil8: F32;
|
99
|
+
depth16unorm: F32;
|
100
|
+
depth24plus: F32;
|
101
|
+
'depth24plus-stencil8': F32;
|
102
|
+
depth32float: F32;
|
103
|
+
'depth32float-stencil8': F32;
|
104
|
+
'bc1-rgba-unorm': F32;
|
105
|
+
'bc1-rgba-unorm-srgb': F32;
|
106
|
+
'bc2-rgba-unorm': F32;
|
107
|
+
'bc2-rgba-unorm-srgb': F32;
|
108
|
+
'bc3-rgba-unorm': F32;
|
109
|
+
'bc3-rgba-unorm-srgb': F32;
|
110
|
+
'bc4-r-unorm': F32;
|
111
|
+
'bc4-r-snorm': F32;
|
112
|
+
'bc5-rg-unorm': F32;
|
113
|
+
'bc5-rg-snorm': F32;
|
114
|
+
'bc6h-rgb-ufloat': F32;
|
115
|
+
'bc6h-rgb-float': F32;
|
116
|
+
'bc7-rgba-unorm': F32;
|
117
|
+
'bc7-rgba-unorm-srgb': F32;
|
118
|
+
'etc2-rgb8unorm': F32;
|
119
|
+
'etc2-rgb8unorm-srgb': F32;
|
120
|
+
'etc2-rgb8a1unorm': F32;
|
121
|
+
'etc2-rgb8a1unorm-srgb': F32;
|
122
|
+
'etc2-rgba8unorm': F32;
|
123
|
+
'etc2-rgba8unorm-srgb': F32;
|
124
|
+
'eac-r11unorm': F32;
|
125
|
+
'eac-r11snorm': F32;
|
126
|
+
'eac-rg11unorm': F32;
|
127
|
+
'eac-rg11snorm': F32;
|
128
|
+
'astc-4x4-unorm': F32;
|
129
|
+
'astc-4x4-unorm-srgb': F32;
|
130
|
+
'astc-5x4-unorm': F32;
|
131
|
+
'astc-5x4-unorm-srgb': F32;
|
132
|
+
'astc-5x5-unorm': F32;
|
133
|
+
'astc-5x5-unorm-srgb': F32;
|
134
|
+
'astc-6x5-unorm': F32;
|
135
|
+
'astc-6x5-unorm-srgb': F32;
|
136
|
+
'astc-6x6-unorm': F32;
|
137
|
+
'astc-6x6-unorm-srgb': F32;
|
138
|
+
'astc-8x5-unorm': F32;
|
139
|
+
'astc-8x5-unorm-srgb': F32;
|
140
|
+
'astc-8x6-unorm': F32;
|
141
|
+
'astc-8x6-unorm-srgb': F32;
|
142
|
+
'astc-8x8-unorm': F32;
|
143
|
+
'astc-8x8-unorm-srgb': F32;
|
144
|
+
'astc-10x5-unorm': F32;
|
145
|
+
'astc-10x5-unorm-srgb': F32;
|
146
|
+
'astc-10x6-unorm': F32;
|
147
|
+
'astc-10x6-unorm-srgb': F32;
|
148
|
+
'astc-10x8-unorm': F32;
|
149
|
+
'astc-10x8-unorm-srgb': F32;
|
150
|
+
'astc-10x10-unorm': F32;
|
151
|
+
'astc-10x10-unorm-srgb': F32;
|
152
|
+
'astc-12x10-unorm': F32;
|
153
|
+
'astc-12x10-unorm-srgb': F32;
|
154
|
+
'astc-12x12-unorm': F32;
|
155
|
+
'astc-12x12-unorm-srgb': F32;
|
156
|
+
};
|
157
|
+
type TexelFormatToChannelType = typeof texelFormatToChannelType;
|
158
|
+
/**
|
159
|
+
* https://www.w3.org/TR/WGSL/#storage-texel-formats
|
160
|
+
*/
|
161
|
+
type StorageTextureTexelFormat = 'rgba8unorm' | 'rgba8snorm' | 'rgba8uint' | 'rgba8sint' | 'rgba16uint' | 'rgba16sint' | 'rgba16float' | 'r32uint' | 'r32sint' | 'r32float' | 'rg32uint' | 'rg32sint' | 'rg32float' | 'rgba32uint' | 'rgba32sint' | 'rgba32float' | 'bgra8unorm';
|
162
|
+
declare const texelFormatToDataType: {
|
163
|
+
readonly rgba8unorm: Vec4f;
|
164
|
+
readonly rgba8snorm: Vec4f;
|
165
|
+
readonly rgba8uint: Vec4u;
|
166
|
+
readonly rgba8sint: Vec4i;
|
167
|
+
readonly rgba16uint: Vec4u;
|
168
|
+
readonly rgba16sint: Vec4i;
|
169
|
+
readonly rgba16float: Vec4f;
|
170
|
+
readonly r32uint: Vec4u;
|
171
|
+
readonly r32sint: Vec4i;
|
172
|
+
readonly r32float: Vec4f;
|
173
|
+
readonly rg32uint: Vec4u;
|
174
|
+
readonly rg32sint: Vec4i;
|
175
|
+
readonly rg32float: Vec4f;
|
176
|
+
readonly rgba32uint: Vec4u;
|
177
|
+
readonly rgba32sint: Vec4i;
|
178
|
+
readonly rgba32float: Vec4f;
|
179
|
+
readonly bgra8unorm: Vec4f;
|
180
|
+
};
|
181
|
+
type TexelFormatToDataType = typeof texelFormatToDataType;
|
182
|
+
type TexelFormatToDataTypeOrNever<T> = T extends keyof TexelFormatToDataType ? TexelFormatToDataType[T] : never;
|
183
|
+
/**
|
184
|
+
* Represents what formats a storage view can choose from based on its owner texture's props.
|
185
|
+
*/
|
186
|
+
type StorageFormatOptions<TProps extends TextureProps> = Extract<TProps['format'] | Default<TProps['viewFormats'], []>[number], StorageTextureTexelFormat>;
|
187
|
+
/**
|
188
|
+
* Represents what formats a sampled view can choose from based on its owner texture's props.
|
189
|
+
*/
|
190
|
+
type SampledFormatOptions<TProps extends TextureProps> = TProps['format'] | Default<TProps['viewFormats'], []>[number];
|
191
|
+
|
192
|
+
interface Sampled {
|
193
|
+
usableAsSampled: true;
|
194
|
+
}
|
195
|
+
interface Render {
|
196
|
+
usableAsRender: true;
|
197
|
+
}
|
198
|
+
type LiteralToExtensionMap = {
|
199
|
+
storage: Storage;
|
200
|
+
sampled: Sampled;
|
201
|
+
render: Render;
|
202
|
+
};
|
203
|
+
type AllowedUsages<TProps extends TextureProps> = 'sampled' | 'render' | (TProps['format'] extends StorageTextureTexelFormat ? 'storage' : never);
|
204
|
+
declare function isUsableAsSampled<T>(value: T): value is T & Sampled;
|
205
|
+
declare function isUsableAsRender<T>(value: T): value is T & Render;
|
206
|
+
|
207
|
+
type ChannelData = U32 | I32 | F32;
|
208
|
+
type TexelData = Vec4u | Vec4i | Vec4f;
|
209
|
+
/**
|
210
|
+
* @param TProps all properties that distinguish this texture apart from other textures on the type level.
|
211
|
+
*/
|
212
|
+
interface TgpuTexture<TProps extends TextureProps = TextureProps> extends TgpuNamable {
|
213
|
+
readonly resourceType: 'texture';
|
214
|
+
readonly props: TProps;
|
215
|
+
readonly label: string | undefined;
|
216
|
+
readonly usableAsStorage: boolean;
|
217
|
+
readonly usableAsSampled: boolean;
|
218
|
+
readonly usableAsRender: boolean;
|
219
|
+
$usage<T extends AllowedUsages<TProps>[]>(...usages: T): this & UnionToIntersection<LiteralToExtensionMap[T[number]]>;
|
220
|
+
asReadonly<TDimension extends StorageTextureDimension, TFormat extends StorageFormatOptions<TProps>>(params?: TextureViewParams<TDimension, TFormat>): ExtensionGuard<this['usableAsStorage'], "missing .$usage('storage')", TgpuReadonlyTexture<StorageTextureDimension extends TDimension ? Default<TProps['dimension'], '2d'> : TDimension, TexelFormatToDataTypeOrNever<StorageFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat>>>;
|
221
|
+
asWriteonly<TDimension extends StorageTextureDimension, TFormat extends StorageFormatOptions<TProps>>(params?: TextureViewParams<TDimension, TFormat>): ExtensionGuard<this['usableAsStorage'], "missing .$usage('storage')", TgpuWriteonlyTexture<StorageTextureDimension extends TDimension ? Default<TProps['dimension'], '2d'> : TDimension, TexelFormatToDataTypeOrNever<StorageFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat>>>;
|
222
|
+
asMutable<TDimension extends StorageTextureDimension, TFormat extends StorageFormatOptions<TProps>>(params?: TextureViewParams<TDimension, TFormat>): ExtensionGuard<this['usableAsStorage'], "missing .$usage('storage')", TgpuMutableTexture<StorageTextureDimension extends TDimension ? Default<TProps['dimension'], '2d'> : TDimension, TexelFormatToDataTypeOrNever<StorageFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat>>>;
|
223
|
+
asSampled<TDimension extends GPUTextureViewDimension, TFormat extends SampledFormatOptions<TProps>>(params?: TextureViewParams<TDimension, TFormat>): ExtensionGuard<this['usableAsSampled'], "missing .$usage('sampled')", TgpuSampledTexture<GPUTextureViewDimension extends TDimension ? Default<TProps['dimension'], '2d'> : TDimension, TexelFormatToChannelType[SampledFormatOptions<TProps> extends TFormat ? TProps['format'] : TFormat]>>;
|
224
|
+
destroy(): void;
|
225
|
+
}
|
226
|
+
type StorageTextureAccess = 'readonly' | 'writeonly' | 'mutable';
|
227
|
+
/**
|
228
|
+
* Based on @see GPUTextureViewDimension
|
229
|
+
* https://www.w3.org/TR/WGSL/#texture-depth
|
230
|
+
*/
|
231
|
+
type StorageTextureDimension = '1d' | '2d' | '2d-array' | '3d';
|
232
|
+
type TextureViewParams<TDimension extends GPUTextureViewDimension | undefined, TFormat extends GPUTextureFormat | undefined> = {
|
233
|
+
format?: TFormat;
|
234
|
+
dimension?: TDimension;
|
235
|
+
aspect?: GPUTextureAspect;
|
236
|
+
baseMipLevel?: number;
|
237
|
+
mipLevelCount?: number;
|
238
|
+
baseArrayLayout?: number;
|
239
|
+
arrayLayerCount?: number;
|
240
|
+
};
|
241
|
+
interface TgpuStorageTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> {
|
242
|
+
readonly resourceType: 'texture-storage-view';
|
243
|
+
readonly dimension: TDimension;
|
244
|
+
readonly texelDataType: TData;
|
245
|
+
readonly access: StorageTextureAccess;
|
246
|
+
}
|
247
|
+
/**
|
248
|
+
* A texture accessed as "readonly" storage on the GPU.
|
249
|
+
*/
|
250
|
+
interface TgpuReadonlyTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> extends TgpuStorageTexture<TDimension, TData>, TgpuResolvable {
|
251
|
+
readonly access: 'readonly';
|
252
|
+
}
|
253
|
+
/**
|
254
|
+
* A texture accessed as "writeonly" storage on the GPU.
|
255
|
+
*/
|
256
|
+
interface TgpuWriteonlyTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> extends TgpuStorageTexture<TDimension, TData>, TgpuResolvable {
|
257
|
+
readonly access: 'writeonly';
|
258
|
+
}
|
259
|
+
/**
|
260
|
+
* A texture accessed as "mutable" (or read_write) storage on the GPU.
|
261
|
+
*/
|
262
|
+
interface TgpuMutableTexture<TDimension extends StorageTextureDimension = StorageTextureDimension, TData extends TexelData = TexelData> extends TgpuStorageTexture<TDimension, TData>, TgpuResolvable {
|
263
|
+
readonly access: 'mutable';
|
264
|
+
}
|
265
|
+
/**
|
266
|
+
* A texture accessed as sampled on the GPU.
|
267
|
+
*/
|
268
|
+
interface TgpuSampledTexture<TDimension extends GPUTextureViewDimension = GPUTextureViewDimension, TData extends ChannelData = ChannelData> extends TgpuResolvable {
|
269
|
+
readonly resourceType: 'texture-sampled-view';
|
270
|
+
readonly dimension: TDimension;
|
271
|
+
readonly channelDataType: TData;
|
272
|
+
}
|
273
|
+
declare function isTexture<T extends TgpuTexture>(value: unknown | T): value is T;
|
274
|
+
declare function isStorageTextureView<T extends TgpuReadonlyTexture | TgpuWriteonlyTexture | TgpuMutableTexture>(value: unknown | T): value is T;
|
275
|
+
declare function isSampledTextureView<T extends TgpuSampledTexture>(value: unknown | T): value is T;
|
276
|
+
type TgpuAnyTextureView = TgpuReadonlyTexture | TgpuWriteonlyTexture | TgpuMutableTexture | TgpuSampledTexture;
|
15
277
|
|
16
278
|
interface Unwrapper {
|
17
279
|
readonly device: GPUDevice;
|
18
|
-
unwrap(resource:
|
280
|
+
unwrap(resource: TgpuComputePipeline): GPUComputePipeline;
|
19
281
|
unwrap(resource: TgpuBindGroupLayout): GPUBindGroupLayout;
|
20
282
|
unwrap(resource: TgpuBindGroup): GPUBindGroup;
|
283
|
+
unwrap(resource: TgpuBuffer$1<AnyData>): GPUBuffer;
|
284
|
+
unwrap(resource: TgpuTexture): GPUTexture;
|
285
|
+
unwrap(resource: TgpuReadonlyTexture | TgpuWriteonlyTexture | TgpuMutableTexture | TgpuSampledTexture): GPUTextureView;
|
21
286
|
}
|
22
287
|
|
288
|
+
type CreateTextureOptions<TSize, TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormat extends GPUTextureFormat, TDimension extends GPUTextureDimension> = {
|
289
|
+
/**
|
290
|
+
* The width, height, and depth or layer count of the texture.
|
291
|
+
*/
|
292
|
+
size: TSize;
|
293
|
+
/**
|
294
|
+
* The format of the texture.
|
295
|
+
*/
|
296
|
+
format: TFormat;
|
297
|
+
/**
|
298
|
+
* The number of mip levels the texture will contain.
|
299
|
+
* @default 1
|
300
|
+
*/
|
301
|
+
mipLevelCount?: TMipLevelCount | undefined;
|
302
|
+
/**
|
303
|
+
* The sample count of the texture. A sampleCount > 1 indicates a multisampled texture.
|
304
|
+
* @default 1
|
305
|
+
*/
|
306
|
+
sampleCount?: TSampleCount | undefined;
|
307
|
+
/**
|
308
|
+
* Specifies extra formats (in addition to the texture's actual format) that can be used
|
309
|
+
* when creating views of this texture.
|
310
|
+
* @default []
|
311
|
+
*/
|
312
|
+
viewFormats?: TViewFormat[] | undefined;
|
313
|
+
/**
|
314
|
+
* Whether the texture is one-dimensional, an array of two-dimensional layers, or three-dimensional.
|
315
|
+
* @default '2d'
|
316
|
+
*/
|
317
|
+
dimension?: TDimension | undefined;
|
318
|
+
};
|
319
|
+
type CreateTextureResult<TSize extends readonly number[], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormat extends GPUTextureFormat, TDimension extends GPUTextureDimension> = Prettify<{
|
320
|
+
size: Mutable<TSize>;
|
321
|
+
format: TFormat;
|
322
|
+
} & OmitProps<{
|
323
|
+
dimension: GPUTextureDimension extends TDimension ? undefined : TDimension extends '2d' ? undefined : TDimension;
|
324
|
+
mipLevelCount: number extends TMipLevelCount ? undefined : TMipLevelCount extends 1 ? undefined : TMipLevelCount;
|
325
|
+
sampleCount: number extends TSampleCount ? undefined : TSampleCount extends 1 ? undefined : TSampleCount;
|
326
|
+
viewFormats: GPUTextureFormat extends TViewFormat ? undefined : TViewFormat[] extends never[] ? undefined : TViewFormat[];
|
327
|
+
}, undefined>>;
|
328
|
+
interface TgpuRoot extends Unwrapper {
|
329
|
+
/**
|
330
|
+
* The GPU device associated with this root.
|
331
|
+
*/
|
332
|
+
readonly device: GPUDevice;
|
333
|
+
/**
|
334
|
+
* @param typeSchema The type of data that this buffer will hold.
|
335
|
+
* @param initial The initial value of the buffer. (optional)
|
336
|
+
*/
|
337
|
+
createBuffer<TData extends AnyData>(typeSchema: TData, initial?: Infer<Exotic<TData>> | undefined): TgpuBuffer$1<Exotic<TData>>;
|
338
|
+
/**
|
339
|
+
* @param typeSchema The type of data that this buffer will hold.
|
340
|
+
* @param gpuBuffer A vanilla WebGPU buffer.
|
341
|
+
*/
|
342
|
+
createBuffer<TData extends AnyData>(typeSchema: TData, gpuBuffer: GPUBuffer): TgpuBuffer$1<Exotic<TData>>;
|
343
|
+
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>>;
|
344
|
+
destroy(): void;
|
345
|
+
}
|
346
|
+
|
347
|
+
interface Uniform {
|
348
|
+
usableAsUniform: true;
|
349
|
+
}
|
350
|
+
declare const Uniform: Uniform;
|
351
|
+
interface Vertex {
|
352
|
+
usableAsVertex: true;
|
353
|
+
}
|
354
|
+
declare const Vertex: Vertex;
|
355
|
+
type LiteralToUsageType<T extends 'uniform' | 'storage' | 'vertex'> = T extends 'uniform' ? Uniform : T extends 'storage' ? Storage : T extends 'vertex' ? Vertex : never;
|
356
|
+
interface TgpuBuffer$1<TData extends AnyData> extends TgpuNamable {
|
357
|
+
readonly resourceType: 'buffer';
|
358
|
+
readonly dataType: TData;
|
359
|
+
readonly initial?: Infer<TData> | undefined;
|
360
|
+
readonly label: string | undefined;
|
361
|
+
readonly buffer: GPUBuffer;
|
362
|
+
readonly device: GPUDevice;
|
363
|
+
readonly destroyed: boolean;
|
364
|
+
$usage<T extends ('uniform' | 'storage' | 'vertex')[]>(...usages: T): this & UnionToIntersection<LiteralToUsageType<T[number]>>;
|
365
|
+
$addFlags(flags: GPUBufferUsageFlags): this;
|
366
|
+
$device(device: GPUDevice): this;
|
367
|
+
write(data: Infer<TData> | TgpuBuffer$1<TData>): void;
|
368
|
+
read(): Promise<Infer<TData>>;
|
369
|
+
destroy(): void;
|
370
|
+
}
|
371
|
+
declare function isBuffer<T extends TgpuBuffer$1<AnyData>>(value: T | unknown): value is T;
|
372
|
+
declare function isUsableAsUniform<T extends TgpuBuffer$1<AnyData>>(buffer: T): buffer is T & Uniform;
|
373
|
+
declare function isUsableAsVertex<T extends TgpuBuffer$1<AnyData>>(buffer: T): buffer is T & Vertex;
|
374
|
+
|
375
|
+
interface TgpuBufferUsage<TData extends BaseWgslData, TUsage extends BindableBufferUsage = BindableBufferUsage> extends TgpuResolvable {
|
376
|
+
readonly resourceType: 'buffer-usage';
|
377
|
+
readonly usage: TUsage;
|
378
|
+
readonly '~repr': Infer<TData>;
|
379
|
+
value: Infer<TData>;
|
380
|
+
}
|
381
|
+
interface TgpuBufferUniform$1<TData extends BaseWgslData> extends TgpuBufferUsage<TData, 'uniform'> {
|
382
|
+
readonly value: Infer<TData>;
|
383
|
+
}
|
384
|
+
interface TgpuBufferReadonly$1<TData extends BaseWgslData> extends TgpuBufferUsage<TData, 'readonly'> {
|
385
|
+
readonly value: Infer<TData>;
|
386
|
+
}
|
387
|
+
interface TgpuBufferMutable$1<TData extends BaseWgslData> extends TgpuBufferUsage<TData, 'mutable'> {
|
388
|
+
}
|
389
|
+
|
390
|
+
interface TgpuSampler {
|
391
|
+
readonly resourceType: 'sampler';
|
392
|
+
}
|
393
|
+
interface TgpuComparisonSampler {
|
394
|
+
readonly resourceType: 'sampler-comparison';
|
395
|
+
}
|
396
|
+
declare function isSampler(resource: unknown): resource is TgpuSampler;
|
397
|
+
declare function isComparisonSampler(resource: unknown): resource is TgpuComparisonSampler;
|
398
|
+
|
23
399
|
type TgpuLayoutEntryBase = {
|
24
400
|
/**
|
25
401
|
* Limits this resource's visibility to specific shader stages.
|
@@ -33,10 +409,10 @@ type TgpuLayoutEntryBase = {
|
|
33
409
|
visibility?: TgpuShaderStage[];
|
34
410
|
};
|
35
411
|
type TgpuLayoutUniform = TgpuLayoutEntryBase & {
|
36
|
-
uniform:
|
412
|
+
uniform: AnyWgslData;
|
37
413
|
};
|
38
414
|
type TgpuLayoutStorage = TgpuLayoutEntryBase & {
|
39
|
-
storage:
|
415
|
+
storage: AnyWgslData | ((arrayLength: number) => AnyWgslData);
|
40
416
|
/** @default 'readonly' */
|
41
417
|
access?: 'mutable' | 'readonly';
|
42
418
|
};
|
@@ -61,23 +437,32 @@ type TgpuLayoutTexture<TSampleType extends GPUTextureSampleType = GPUTextureSamp
|
|
61
437
|
*/
|
62
438
|
multisampled?: boolean;
|
63
439
|
};
|
64
|
-
type TgpuLayoutStorageTexture<TFormat extends
|
440
|
+
type TgpuLayoutStorageTexture<TFormat extends StorageTextureTexelFormat = StorageTextureTexelFormat> = TgpuLayoutEntryBase & {
|
65
441
|
storageTexture: TFormat;
|
66
442
|
/** @default 'writeonly' */
|
67
443
|
access?: 'readonly' | 'writeonly' | 'mutable';
|
68
444
|
/** @default '2d' */
|
69
|
-
viewDimension?:
|
445
|
+
viewDimension?: StorageTextureDimension;
|
70
446
|
};
|
71
447
|
type TgpuLayoutExternalTexture = TgpuLayoutEntryBase & {
|
72
448
|
externalTexture: Record<string, never>;
|
73
449
|
};
|
74
450
|
type TgpuLayoutEntry = TgpuLayoutUniform | TgpuLayoutStorage | TgpuLayoutSampler | TgpuLayoutTexture | TgpuLayoutStorageTexture | TgpuLayoutExternalTexture;
|
75
|
-
type UnwrapRuntimeConstructorInner<T extends
|
76
|
-
type UnwrapRuntimeConstructor<T extends
|
451
|
+
type UnwrapRuntimeConstructorInner<T extends BaseWgslData | ((_: number) => BaseWgslData)> = T extends BaseWgslData ? T : T extends (_: number) => infer Return ? Return : never;
|
452
|
+
type UnwrapRuntimeConstructor<T extends AnyData | ((_: number) => AnyData)> = T extends unknown ? UnwrapRuntimeConstructorInner<T> : never;
|
77
453
|
interface TgpuBindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>> extends TgpuNamable {
|
78
454
|
readonly resourceType: 'bind-group-layout';
|
79
455
|
readonly label: string | undefined;
|
80
456
|
readonly entries: Entries;
|
457
|
+
readonly bound: {
|
458
|
+
[K in keyof Entries]: BindLayoutEntry<Entries[K]>;
|
459
|
+
};
|
460
|
+
/**
|
461
|
+
* An explicit numeric index assigned to this bind group layout. If undefined, a unique
|
462
|
+
* index is assigned automatically during resolution. This can be changed with the
|
463
|
+
* `.$idx()` method.
|
464
|
+
*/
|
465
|
+
readonly index: number | undefined;
|
81
466
|
populate(entries: {
|
82
467
|
[K in keyof OmitProps<Entries, null>]: LayoutEntryToInput<Entries[K]>;
|
83
468
|
}): TgpuBindGroup<Entries>;
|
@@ -90,144 +475,107 @@ interface TgpuBindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | n
|
|
90
475
|
}
|
91
476
|
type StorageUsageForEntry<T extends TgpuLayoutStorage> = T extends {
|
92
477
|
access?: infer Access;
|
93
|
-
} ? 'mutable' | 'readonly' extends Access ? TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>> | TgpuBufferMutable<UnwrapRuntimeConstructor<T['storage']>> : 'readonly' extends Access ? TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>> : 'mutable' extends Access ? TgpuBufferMutable<UnwrapRuntimeConstructor<T['storage']>> : TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>> | TgpuBufferMutable<UnwrapRuntimeConstructor<T['storage']>> : TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>>;
|
94
|
-
type LayoutEntryToInput<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ?
|
95
|
-
|
478
|
+
} ? 'mutable' | 'readonly' extends Access ? TgpuBufferReadonly$1<UnwrapRuntimeConstructor<T['storage']>> | TgpuBufferMutable$1<UnwrapRuntimeConstructor<T['storage']>> : 'readonly' extends Access ? TgpuBufferReadonly$1<UnwrapRuntimeConstructor<T['storage']>> : 'mutable' extends Access ? TgpuBufferMutable$1<UnwrapRuntimeConstructor<T['storage']>> : TgpuBufferReadonly$1<UnwrapRuntimeConstructor<T['storage']>> | TgpuBufferMutable$1<UnwrapRuntimeConstructor<T['storage']>> : TgpuBufferReadonly$1<UnwrapRuntimeConstructor<T['storage']>>;
|
479
|
+
type LayoutEntryToInput<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? (TgpuBuffer$1<UnwrapRuntimeConstructor<T['uniform']>> & Uniform) | GPUBuffer : T extends TgpuLayoutStorage ? (TgpuBuffer$1<UnwrapRuntimeConstructor<T['storage']>> & Storage) | GPUBuffer : T extends TgpuLayoutSampler ? GPUSampler : T extends TgpuLayoutTexture ? // TODO: Allow sampled usages here
|
480
|
+
GPUTextureView | TgpuTexture : T extends TgpuLayoutStorageTexture ? // TODO: Allow storage usages here
|
481
|
+
GPUTextureView | TgpuTexture : T extends TgpuLayoutExternalTexture ? GPUExternalTexture : never;
|
482
|
+
type BindLayoutEntry<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? TgpuBufferUniform$1<UnwrapRuntimeConstructor<T['uniform']>> : T extends TgpuLayoutStorage ? StorageUsageForEntry<T> : T extends TgpuLayoutSampler ? TgpuSampler : never;
|
96
483
|
type TgpuBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>> = {
|
97
484
|
readonly resourceType: 'bind-group';
|
98
485
|
readonly layout: TgpuBindGroupLayout<Entries>;
|
99
486
|
unwrap(unwrapper: Unwrapper): GPUBindGroup;
|
100
487
|
};
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
type
|
105
|
-
|
488
|
+
type ExoticEntry<T> = T extends Record<string | number | symbol, unknown> ? {
|
489
|
+
[Key in keyof T]: T[Key] extends BaseWgslData ? Exotic<T[Key]> : T[Key] extends (...args: infer TArgs) => infer TReturn ? (...args: TArgs) => Exotic<TReturn> : T[Key];
|
490
|
+
} : T;
|
491
|
+
type ExoticEntries<T extends Record<string, TgpuLayoutEntry | null>> = {
|
492
|
+
[BindingKey in keyof T]: ExoticEntry<T[BindingKey]>;
|
493
|
+
};
|
494
|
+
declare function bindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | null>>(entries: Entries): TgpuBindGroupLayout<Prettify<ExoticEntries<Entries>>>;
|
106
495
|
|
107
|
-
type
|
108
|
-
|
496
|
+
type Wgsl = string | number | boolean | TgpuResolvable | AnyWgslData;
|
497
|
+
declare const UnknownData: unique symbol;
|
498
|
+
type UnknownData = typeof UnknownData;
|
499
|
+
type Resource = {
|
500
|
+
value: unknown;
|
501
|
+
dataType: AnyWgslData | UnknownData;
|
109
502
|
};
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
interface TgpuAnyTexture {
|
117
|
-
readonly descriptor: Omit<GPUTextureDescriptor, 'usage'>;
|
118
|
-
get flags(): GPUTextureUsageFlags;
|
119
|
-
}
|
120
|
-
interface TgpuTextureExternal extends TgpuRenderResource, TgpuNamable {
|
121
|
-
readonly descriptor: Optional<GPUExternalTextureDescriptor>;
|
122
|
-
get source(): HTMLVideoElement | VideoFrame | undefined;
|
503
|
+
type TgpuShaderStage = 'compute' | 'vertex' | 'fragment';
|
504
|
+
interface FnToWgslOptions {
|
505
|
+
args: Resource[];
|
506
|
+
returnType: AnyWgslData;
|
507
|
+
body: Block;
|
508
|
+
externalMap: Record<string, unknown>;
|
123
509
|
}
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
readonly
|
131
|
-
|
132
|
-
* @param typeSchema The type of data that this buffer will hold.
|
133
|
-
* @param initial The initial value of the buffer. (optional)
|
134
|
-
*/
|
135
|
-
createBuffer<TData extends AnyTgpuData>(typeSchema: TData, initial?: Parsed<TData> | TgpuPlum<Parsed<TData>> | undefined): TgpuBuffer<TData>;
|
510
|
+
/**
|
511
|
+
* Passed into each resolvable item. All items in a tree share a resolution ctx,
|
512
|
+
* but there can be layers added and removed from the item stack when going down
|
513
|
+
* and up the tree.
|
514
|
+
*/
|
515
|
+
interface ResolutionCtx {
|
516
|
+
readonly names: NameRegistry;
|
517
|
+
addDeclaration(declaration: string): void;
|
136
518
|
/**
|
137
|
-
*
|
138
|
-
*
|
519
|
+
* Reserves a bind group number, and returns a placeholder that will be replaced
|
520
|
+
* with a concrete number at the end of the resolution process.
|
139
521
|
*/
|
140
|
-
|
141
|
-
unwrap(resource: TgpuBuffer<AnyTgpuData>): GPUBuffer;
|
142
|
-
unwrap(resource: TgpuBindGroupLayout): GPUBindGroupLayout;
|
143
|
-
unwrap(resource: TgpuBindGroup): GPUBindGroup;
|
144
|
-
destroy(): void;
|
145
|
-
}
|
146
|
-
interface ExperimentalTgpuRoot extends TgpuRoot {
|
147
|
-
readonly jitTranspiler?: JitTranspiler | undefined;
|
522
|
+
allocateLayoutEntry(layout: TgpuBindGroupLayout): string;
|
148
523
|
/**
|
149
|
-
*
|
150
|
-
*
|
524
|
+
* Reserves a spot in the catch-all bind group, without the indirection of a bind-group.
|
525
|
+
* This means the resource is 'fixed', and cannot be swapped between code execution.
|
151
526
|
*/
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
setSource(texture: TgpuTextureExternal, source: HTMLVideoElement | VideoFrame): void;
|
157
|
-
isDirty(texture: TgpuTextureExternal): boolean;
|
158
|
-
markClean(texture: TgpuTextureExternal): void;
|
159
|
-
textureFor(view: TgpuAnyTexture | TgpuAnyTextureView): GPUTexture;
|
160
|
-
viewFor(view: TgpuAnyTextureView): GPUTextureView;
|
161
|
-
externalTextureFor(texture: TgpuTextureExternal): GPUExternalTexture;
|
162
|
-
samplerFor(sampler: TgpuSampler): GPUSampler;
|
527
|
+
allocateFixedEntry(layoutEntry: TgpuLayoutEntry, resource: object): {
|
528
|
+
group: string;
|
529
|
+
binding: number;
|
530
|
+
};
|
163
531
|
/**
|
164
|
-
*
|
165
|
-
*
|
532
|
+
* Unwraps all layers of slot indirection and returns the concrete value if available.
|
533
|
+
* @throws {MissingSlotValueError}
|
166
534
|
*/
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
code: TgpuCode | BoundTgpuCode;
|
174
|
-
output: {
|
175
|
-
[K in symbol]: string;
|
176
|
-
} & {
|
177
|
-
[K in string]: AnyTgpuData;
|
178
|
-
};
|
535
|
+
unwrap<T>(eventual: Eventual<T>): T;
|
536
|
+
resolve(item: Wgsl, slotValueOverrides?: SlotValuePair<unknown>[]): string;
|
537
|
+
transpileFn(fn: string): {
|
538
|
+
argNames: string[];
|
539
|
+
body: Block;
|
540
|
+
externalNames: string[];
|
179
541
|
};
|
180
|
-
|
181
|
-
|
182
|
-
|
542
|
+
fnToWgsl(options: FnToWgslOptions): {
|
543
|
+
head: Wgsl;
|
544
|
+
body: Wgsl;
|
183
545
|
};
|
184
|
-
primitive: GPUPrimitiveState;
|
185
|
-
externalLayouts?: GPUBindGroupLayout[];
|
186
|
-
label?: string;
|
187
|
-
}
|
188
|
-
interface ComputePipelineOptions {
|
189
|
-
code: TgpuCode | BoundTgpuCode;
|
190
|
-
workgroupSize?: readonly [number, number?, number?];
|
191
|
-
externalLayouts?: GPUBindGroupLayout[];
|
192
|
-
label?: string;
|
193
|
-
}
|
194
|
-
type RenderPipelineExecutorOptions = GPURenderPassDescriptor & {
|
195
|
-
vertexCount: number;
|
196
|
-
instanceCount?: number;
|
197
|
-
firstVertex?: number;
|
198
|
-
firstInstance?: number;
|
199
|
-
externalBindGroups?: GPUBindGroup[];
|
200
|
-
};
|
201
|
-
interface RenderPipelineExecutor {
|
202
|
-
execute(options: RenderPipelineExecutorOptions): void;
|
203
546
|
}
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
};
|
208
|
-
interface ComputePipelineExecutor {
|
209
|
-
execute(options?: ComputePipelineExecutorOptions): void;
|
547
|
+
interface TgpuResolvable {
|
548
|
+
readonly label?: string | undefined;
|
549
|
+
resolve(ctx: ResolutionCtx): string;
|
210
550
|
}
|
211
|
-
|
212
551
|
/**
|
213
|
-
*
|
552
|
+
* Represents a value that is available at resolution time.
|
214
553
|
*/
|
215
|
-
type
|
216
|
-
|
217
|
-
|
554
|
+
type Eventual<T> = T | TgpuSlot<T>;
|
555
|
+
type SlotValuePair<T> = [TgpuSlot<T>, T];
|
556
|
+
type BindableBufferUsage = 'uniform' | 'readonly' | 'mutable';
|
557
|
+
interface TgpuSlot<T> extends TgpuNamable {
|
558
|
+
readonly __brand: 'TgpuSlot';
|
559
|
+
readonly defaultValue: T | undefined;
|
560
|
+
readonly label?: string | undefined;
|
218
561
|
/**
|
219
|
-
*
|
220
|
-
*
|
562
|
+
* Used to determine if code generated using either value `a` or `b` in place
|
563
|
+
* of the slot will be equivalent. Defaults to `Object.is`.
|
221
564
|
*/
|
222
|
-
|
223
|
-
|
565
|
+
areEqual(a: T, b: T): boolean;
|
566
|
+
readonly value: Infer<T>;
|
567
|
+
}
|
224
568
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
569
|
+
interface TgpuResolveOptions {
|
570
|
+
input: string | TgpuResolvable | AnyWgslData | (string | TgpuResolvable | AnyWgslData)[];
|
571
|
+
extraDependencies?: Record<string, TgpuResolvable | AnyWgslData | string | number> | undefined;
|
572
|
+
/**
|
573
|
+
* @default 'random'
|
574
|
+
*/
|
575
|
+
names?: 'strict' | 'random' | undefined;
|
576
|
+
jitTranspiler?: JitTranspiler | undefined;
|
230
577
|
}
|
578
|
+
declare function resolve(options: TgpuResolveOptions): string;
|
231
579
|
|
232
580
|
/**
|
233
581
|
* Options passed into {@link init}.
|
@@ -235,6 +583,8 @@ interface JitTranspiler {
|
|
235
583
|
type InitOptions = {
|
236
584
|
adapter?: GPURequestAdapterOptions | undefined;
|
237
585
|
device?: GPUDeviceDescriptor | undefined;
|
586
|
+
/** @default 'random' */
|
587
|
+
unstable_names?: 'random' | 'strict' | undefined;
|
238
588
|
unstable_jitTranspiler?: JitTranspiler | undefined;
|
239
589
|
};
|
240
590
|
/**
|
@@ -242,6 +592,8 @@ type InitOptions = {
|
|
242
592
|
*/
|
243
593
|
type InitFromDeviceOptions = {
|
244
594
|
device: GPUDevice;
|
595
|
+
/** @default 'random' */
|
596
|
+
unstable_names?: 'random' | 'strict' | undefined;
|
245
597
|
unstable_jitTranspiler?: JitTranspiler | undefined;
|
246
598
|
};
|
247
599
|
/**
|
@@ -262,7 +614,7 @@ type InitFromDeviceOptions = {
|
|
262
614
|
* const root = await tgpu.init({ adapter: adapterOptions, device: deviceDescriptor });
|
263
615
|
* ```
|
264
616
|
*/
|
265
|
-
declare function init(options?: InitOptions): Promise<
|
617
|
+
declare function init(options?: InitOptions): Promise<TgpuRoot>;
|
266
618
|
/**
|
267
619
|
* Creates a root from the given device, instead of requesting it like @see init.
|
268
620
|
*
|
@@ -272,63 +624,48 @@ declare function init(options?: InitOptions): Promise<ExperimentalTgpuRoot>;
|
|
272
624
|
* const root = tgpu.initFromDevice({ device });
|
273
625
|
* ```
|
274
626
|
*/
|
275
|
-
declare function initFromDevice(options: InitFromDeviceOptions):
|
627
|
+
declare function initFromDevice(options: InitFromDeviceOptions): TgpuRoot;
|
276
628
|
|
277
629
|
/**
|
278
|
-
*
|
279
|
-
*
|
280
|
-
*
|
281
|
-
* @param initial The initial value of the buffer. (optional)
|
282
|
-
*/
|
283
|
-
declare function createBuffer<TData extends AnyTgpuData>(typeSchema: TData, initial?: Parsed<TData> | TgpuPlum<Parsed<TData>> | undefined): TgpuBuffer<TData>;
|
284
|
-
/**
|
285
|
-
* @deprecated Use the `root.createBuffer` API instead, accessible through `await tgpu.init()`
|
630
|
+
* An error that happens during resolution of WGSL code.
|
631
|
+
* Contains a trace of all ancestor resolvables in
|
632
|
+
* which this error originated.
|
286
633
|
*
|
287
|
-
* @
|
288
|
-
* @param gpuBuffer A vanilla WebGPU buffer.
|
634
|
+
* @category Errors
|
289
635
|
*/
|
290
|
-
declare
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
636
|
+
declare class ResolutionError extends Error {
|
637
|
+
readonly cause: unknown;
|
638
|
+
readonly trace: (TgpuResolvable | AnyWgslData)[];
|
639
|
+
constructor(cause: unknown, trace: (TgpuResolvable | AnyWgslData)[]);
|
640
|
+
appendToTrace(ancestor: TgpuResolvable | AnyWgslData): ResolutionError;
|
641
|
+
}
|
295
642
|
/**
|
296
643
|
* @category Errors
|
297
644
|
*/
|
298
|
-
declare class
|
299
|
-
constructor();
|
645
|
+
declare class NotUniformError extends Error {
|
646
|
+
constructor(value: TgpuBuffer$1<AnyData>);
|
300
647
|
}
|
301
648
|
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
dot<T extends vecBase>(lhs: T, rhs: T): number;
|
307
|
-
normalize: <T extends vecBase>(v: T) => T;
|
308
|
-
cross<T extends vec3f | vec3i | vec3u>(a: T, b: T): T;
|
309
|
-
fract(a: number): number;
|
310
|
-
length<T extends vecBase>(vector: T): number;
|
311
|
-
sin(radians: number): number;
|
312
|
-
cos(radians: number): number;
|
313
|
-
};
|
649
|
+
type TgpuBuffer<TData extends AnyData> = TgpuBuffer$1<Exotic<TData>>;
|
650
|
+
type TgpuBufferMutable<TData extends AnyData> = TgpuBufferMutable$1<Exotic<TData>>;
|
651
|
+
type TgpuBufferReadonly<TData extends AnyData> = TgpuBufferReadonly$1<Exotic<TData>>;
|
652
|
+
type TgpuBufferUniform<TData extends AnyData> = TgpuBufferUniform$1<Exotic<TData>>;
|
314
653
|
|
315
654
|
/**
|
316
655
|
* @module typegpu
|
317
656
|
*/
|
318
657
|
|
319
658
|
declare const tgpu: {
|
320
|
-
/** @deprecated Use `'uniform'` string literal instead. */
|
659
|
+
/** @hidden @deprecated Use `'uniform'` string literal instead. */
|
321
660
|
Uniform: "uniform";
|
322
|
-
/** @deprecated Use `'storage'` string literal instead. */
|
661
|
+
/** @hidden @deprecated Use `'storage'` string literal instead. */
|
323
662
|
Storage: "storage";
|
324
|
-
/** @deprecated Use `'vertex'` string literal instead. */
|
663
|
+
/** @hidden @deprecated Use `'vertex'` string literal instead. */
|
325
664
|
Vertex: "vertex";
|
326
665
|
bindGroupLayout: typeof bindGroupLayout;
|
327
666
|
init: typeof init;
|
328
667
|
initFromDevice: typeof initFromDevice;
|
329
|
-
|
330
|
-
read: typeof read;
|
331
|
-
write: typeof write;
|
668
|
+
resolve: typeof resolve;
|
332
669
|
};
|
333
670
|
|
334
|
-
export {
|
671
|
+
export { type BindLayoutEntry, type InitFromDeviceOptions, type InitOptions, type LayoutEntryToInput, NotUniformError, type Render, ResolutionError, type Sampled, Storage, type TextureProps, type TgpuAnyTextureView, type TgpuBindGroup, type TgpuBindGroupLayout, type TgpuBuffer, type TgpuBufferMutable, type TgpuBufferReadonly, type TgpuBufferUniform, type TgpuLayoutEntry, type TgpuLayoutExternalTexture, type TgpuLayoutSampler, type TgpuLayoutStorage, type TgpuLayoutStorageTexture, type TgpuLayoutTexture, type TgpuLayoutUniform, type TgpuMutableTexture, type TgpuReadonlyTexture, type TgpuRoot, type TgpuSampledTexture, type TgpuSampler, type TgpuTexture, type TgpuWriteonlyTexture, Uniform, Vertex, tgpu as default, isBuffer, isComparisonSampler, isSampledTextureView, isSampler, isStorageTextureView, isTexture, isUsableAsRender, isUsableAsSampled, isUsableAsStorage, isUsableAsUniform, isUsableAsVertex, tgpu };
|