typegpu 0.11.8 → 0.12.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/builtin.d.ts +51 -53
- package/builtin.js +30 -34
- package/common/fullScreenTriangle.d.ts +2 -10
- package/common/fullScreenTriangle.js +20 -28
- package/common/index.d.ts +2 -9
- package/common/index.js +3 -12
- package/common/writeSoA.d.ts +11 -12
- package/common/writeSoA.js +88 -76
- package/core/buffer/buffer.d.ts +79 -62
- package/core/buffer/buffer.js +279 -205
- package/core/buffer/bufferBinding.d.ts +71 -0
- package/core/buffer/bufferBinding.js +154 -0
- package/core/buffer/bufferUsage.d.ts +14 -45
- package/core/buffer/bufferUsage.js +1 -171
- package/core/buffer/laidOutBuffer.d.ts +25 -0
- package/core/buffer/laidOutBuffer.js +55 -0
- package/core/commandEncoder/attachments.d.ts +125 -0
- package/core/commandEncoder/attachments.js +29 -0
- package/core/commandEncoder/commandEncoder.d.ts +53 -0
- package/core/commandEncoder/commandEncoder.js +56 -0
- package/core/commandEncoder/computePass.d.ts +58 -0
- package/core/commandEncoder/computePass.js +63 -0
- package/core/commandEncoder/renderPass.d.ts +121 -0
- package/core/commandEncoder/renderPass.js +196 -0
- package/core/constant/tgpuConstant.d.ts +26 -26
- package/core/constant/tgpuConstant.js +76 -65
- package/core/declare/tgpuDeclare.d.ts +3 -6
- package/core/declare/tgpuDeclare.js +37 -38
- package/core/function/autoIO.d.ts +61 -33
- package/core/function/autoIO.js +68 -73
- package/core/function/comptime.d.ts +11 -13
- package/core/function/comptime.js +60 -52
- package/core/function/createCallableSchema.d.ts +16 -0
- package/core/function/createCallableSchema.js +50 -40
- package/core/function/dualImpl.d.ts +44 -0
- package/core/function/dualImpl.js +71 -50
- package/core/function/entryInputRouter.d.ts +26 -0
- package/core/function/entryInputRouter.js +31 -33
- package/core/function/extractArgs.d.ts +38 -0
- package/core/function/extractArgs.js +202 -200
- package/core/function/fnCore.d.ts +44 -0
- package/core/function/fnCore.js +148 -92
- package/core/function/fnTypes.d.ts +31 -29
- package/core/function/fnTypes.js +1 -0
- package/core/function/ioSchema.d.ts +12 -10
- package/core/function/ioSchema.js +65 -47
- package/core/function/shelllessImpl.d.ts +9 -12
- package/core/function/shelllessImpl.js +18 -20
- package/core/function/templateUtils.d.ts +2 -0
- package/core/function/templateUtils.js +9 -8
- package/core/function/tgpuComputeFn.d.ts +26 -28
- package/core/function/tgpuComputeFn.js +47 -48
- package/core/function/tgpuFn.d.ts +34 -37
- package/core/function/tgpuFn.js +179 -153
- package/core/function/tgpuFragmentFn.d.ts +52 -53
- package/core/function/tgpuFragmentFn.js +63 -56
- package/core/function/tgpuVertexFn.d.ts +36 -39
- package/core/function/tgpuVertexFn.js +56 -53
- package/core/pipeline/computePipeline.d.ts +141 -53
- package/core/pipeline/computePipeline.js +291 -225
- package/core/pipeline/connectAttachmentToShader.d.ts +4 -0
- package/core/pipeline/connectAttachmentToShader.js +25 -22
- package/core/pipeline/connectTargetsToShader.d.ts +3 -0
- package/core/pipeline/connectTargetsToShader.js +29 -27
- package/core/pipeline/drawState.d.ts +52 -0
- package/core/pipeline/drawState.js +225 -0
- package/core/pipeline/limitsOverflow.d.ts +2 -0
- package/core/pipeline/limitsOverflow.js +13 -10
- package/core/pipeline/performanceTracker.d.ts +14 -0
- package/core/pipeline/performanceTracker.js +34 -0
- package/core/pipeline/pipelineUtils.d.ts +18 -0
- package/core/pipeline/pipelineUtils.js +54 -25
- package/core/pipeline/priors.d.ts +1 -0
- package/core/pipeline/priors.js +12 -0
- package/core/pipeline/renderPipeline.d.ts +246 -261
- package/core/pipeline/renderPipeline.js +487 -480
- package/core/pipeline/timeable.d.ts +28 -18
- package/core/pipeline/timeable.js +90 -52
- package/core/pipeline/typeGuards.d.ts +17 -0
- package/core/pipeline/typeGuards.js +52 -22
- package/core/querySet/querySet.d.ts +26 -21
- package/core/querySet/querySet.js +127 -103
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +13 -18
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +90 -93
- package/core/resolve/externals.d.ts +25 -7
- package/core/resolve/externals.js +79 -62
- package/core/resolve/namespace.d.ts +22 -25
- package/core/resolve/namespace.js +16 -21
- package/core/resolve/resolvableString.d.ts +7 -0
- package/core/resolve/resolvableString.js +13 -0
- package/core/resolve/resolveData.d.ts +10 -0
- package/core/resolve/resolveData.js +162 -121
- package/core/resolve/stitch.d.ts +8 -0
- package/core/resolve/stitch.js +23 -21
- package/core/resolve/tgpuResolve.d.ts +55 -53
- package/core/resolve/tgpuResolve.js +106 -55
- package/core/root/configurableImpl.d.ts +10 -0
- package/core/root/configurableImpl.js +17 -19
- package/core/root/init.d.ts +76 -38
- package/core/root/init.js +346 -454
- package/core/root/rootTypes.d.ts +461 -627
- package/core/root/rootTypes.js +1 -0
- package/core/sampler/sampler.d.ts +50 -31
- package/core/sampler/sampler.js +120 -113
- package/core/simulate/tgpuSimulate.d.ts +9 -12
- package/core/simulate/tgpuSimulate.js +68 -71
- package/core/slot/accessor.d.ts +36 -13
- package/core/slot/accessor.js +138 -91
- package/core/slot/internalSlots.d.ts +2 -0
- package/core/slot/internalSlots.js +1 -6
- package/core/slot/lazy.d.ts +2 -6
- package/core/slot/lazy.js +71 -39
- package/core/slot/slot.d.ts +2 -6
- package/core/slot/slot.js +45 -38
- package/core/slot/slotTypes.d.ts +78 -80
- package/core/slot/slotTypes.js +11 -16
- package/core/texture/externalTexture.d.ts +20 -11
- package/core/texture/externalTexture.js +46 -46
- package/core/texture/texture.d.ts +152 -97
- package/core/texture/texture.js +407 -314
- package/core/texture/textureFormats.d.ts +42 -23
- package/core/texture/textureFormats.js +104 -75
- package/core/texture/textureProps.d.ts +7 -10
- package/core/texture/textureProps.js +1 -0
- package/core/texture/textureUtils.d.ts +8 -0
- package/core/texture/textureUtils.js +185 -179
- package/core/texture/usageExtension.d.ts +21 -18
- package/core/texture/usageExtension.js +13 -17
- package/core/unroll/tgpuUnroll.d.ts +20 -19
- package/core/unroll/tgpuUnroll.js +82 -91
- package/core/valueProxyUtils.d.ts +3 -0
- package/core/valueProxyUtils.js +52 -41
- package/core/variable/tgpuVariable.d.ts +26 -27
- package/core/variable/tgpuVariable.js +93 -96
- package/core/vertexLayout/connectAttributesToShader.d.ts +9 -0
- package/core/vertexLayout/connectAttributesToShader.js +61 -56
- package/core/vertexLayout/vertexAttribute.d.ts +21 -17
- package/core/vertexLayout/vertexAttribute.js +1 -0
- package/core/vertexLayout/vertexLayout.d.ts +24 -18
- package/core/vertexLayout/vertexLayout.js +130 -99
- package/core/whitespaces.d.ts +2 -0
- package/core/whitespaces.js +16 -0
- package/data/alignIO.d.ts +7 -0
- package/data/alignIO.js +13 -13
- package/data/alignmentOf.d.ts +5 -8
- package/data/alignmentOf.js +90 -75
- package/data/array.d.ts +6 -9
- package/data/array.js +48 -40
- package/data/atomic.d.ts +2 -7
- package/data/atomic.js +26 -23
- package/data/attributes.d.ts +19 -21
- package/data/attributes.js +192 -132
- package/data/autoStruct.d.ts +36 -3
- package/data/autoStruct.js +84 -81
- package/data/compiledIO.d.ts +5 -0
- package/data/compiledIO.js +231 -214
- package/data/dataIO.d.ts +13 -11
- package/data/dataIO.js +643 -589
- package/data/dataTypes.d.ts +83 -65
- package/data/dataTypes.js +66 -68
- package/data/deepEqual.d.ts +2 -7
- package/data/deepEqual.js +80 -55
- package/data/disarray.d.ts +6 -10
- package/data/disarray.js +52 -46
- package/data/float16Conversion.d.ts +4 -0
- package/data/float16Conversion.js +7 -0
- package/data/getLongestContiguousPrefix.d.ts +4 -8
- package/data/getLongestContiguousPrefix.js +6 -11
- package/data/index.d.ts +30 -31
- package/data/index.js +39 -172
- package/data/instanceToSchema.d.ts +24 -27
- package/data/instanceToSchema.js +1 -0
- package/data/isContiguous.d.ts +4 -8
- package/data/isContiguous.js +6 -11
- package/data/matrix.d.ts +21 -21
- package/data/matrix.js +513 -505
- package/data/numberOps.d.ts +6 -0
- package/data/numberOps.js +26 -20
- package/data/numeric.d.ts +21 -12
- package/data/numeric.js +287 -192
- package/data/offsetUtils.d.ts +9 -13
- package/data/offsetUtils.js +204 -144
- package/data/offsets.d.ts +8 -0
- package/data/offsets.js +33 -33
- package/data/partialIO.d.ts +13 -8
- package/data/partialIO.js +124 -113
- package/data/ptr.d.ts +12 -12
- package/data/ptr.js +42 -44
- package/data/ref.d.ts +40 -27
- package/data/ref.js +125 -95
- package/data/sampler.d.ts +99 -101
- package/data/sampler.js +17 -21
- package/data/schemaCallWrapper.d.ts +19 -0
- package/data/schemaCallWrapper.js +31 -26
- package/data/schemaMemoryLayout.d.ts +8 -0
- package/data/schemaMemoryLayout.js +213 -185
- package/data/sizeOf.d.ts +4 -8
- package/data/sizeOf.js +6 -11
- package/data/snippet.d.ts +96 -20
- package/data/snippet.js +75 -86
- package/data/struct.d.ts +4 -7
- package/data/struct.js +51 -39
- package/data/texture.d.ts +253 -250
- package/data/texture.js +238 -200
- package/data/unstruct.d.ts +2 -7
- package/data/unstruct.js +43 -37
- package/data/vector.d.ts +33 -21
- package/data/vector.js +234 -221
- package/data/vectorImpl.d.ts +231 -0
- package/data/vectorImpl.js +563 -515
- package/data/vectorOps.d.ts +63 -0
- package/data/vectorOps.js +642 -630
- package/data/vertexFormatData.d.ts +181 -184
- package/data/vertexFormatData.js +104 -106
- package/data/wgslTypes.d.ts +665 -600
- package/data/wgslTypes.js +220 -198
- package/errors.d.ts +50 -24
- package/errors.js +146 -120
- package/execMode.d.ts +16 -0
- package/execMode.js +47 -40
- package/extension.d.ts +13 -8
- package/extension.js +10 -16
- package/getGPUValue.d.ts +1 -0
- package/getGPUValue.js +2 -7
- package/index.d.ts +28 -68
- package/index.js +8 -28
- package/indexNamedExports.d.ts +69 -42
- package/indexNamedExports.js +25 -0
- package/internal.d.ts +16 -0
- package/internal.js +12 -0
- package/mathUtils.d.ts +5 -0
- package/mathUtils.js +7 -11
- package/memo.d.ts +11 -0
- package/memo.js +20 -22
- package/minify.d.ts +5 -0
- package/minify.js +93 -0
- package/nameUtils.d.ts +29 -0
- package/nameUtils.js +428 -398
- package/package.json +9 -3
- package/resolutionCtx.d.ts +162 -22
- package/resolutionCtx.js +911 -624
- package/serial/registry.d.ts +15 -0
- package/serial/registry.js +106 -0
- package/serial/restore.d.ts +49 -0
- package/serial/restore.js +68 -0
- package/serial/schema.d.ts +58 -0
- package/serial/schema.js +209 -0
- package/serial/types.d.ts +5 -0
- package/serial/types.js +1 -0
- package/shared/env.d.ts +9 -0
- package/shared/env.js +9 -12
- package/shared/generators.d.ts +4 -0
- package/shared/generators.js +10 -12
- package/shared/meta.d.ts +29 -14
- package/shared/meta.js +71 -55
- package/shared/normalizeMetadata.d.ts +32 -27
- package/shared/normalizeMetadata.js +23 -36
- package/shared/repr.d.ts +73 -55
- package/shared/repr.js +1 -0
- package/shared/soul.d.ts +17 -0
- package/shared/soul.js +1 -0
- package/shared/stringify.d.ts +2 -0
- package/shared/stringify.js +29 -20
- package/shared/symbols.d.ts +26 -20
- package/shared/symbols.js +79 -79
- package/shared/tseynit.d.ts +2 -0
- package/shared/tseynit.js +160 -75
- package/shared/utilityTypes.d.ts +30 -14
- package/shared/utilityTypes.js +2 -6
- package/shared/vertexFormat.d.ts +41 -43
- package/shared/vertexFormat.js +59 -62
- package/std/array.d.ts +2 -7
- package/std/array.js +18 -23
- package/std/atomic.d.ts +14 -18
- package/std/atomic.js +96 -95
- package/std/bitcast.d.ts +193 -10
- package/std/bitcast.js +309 -39
- package/std/boolean.d.ts +19 -33
- package/std/boolean.js +296 -288
- package/std/copy.d.ts +2 -7
- package/std/copy.js +27 -24
- package/std/derivative.d.ts +11 -15
- package/std/derivative.js +56 -79
- package/std/discard.d.ts +1 -6
- package/std/discard.js +7 -14
- package/std/environment.d.ts +19 -14
- package/std/environment.js +71 -51
- package/std/extensions.d.ts +2 -8
- package/std/extensions.js +10 -11
- package/std/index.d.ts +20 -24
- package/std/index.js +32 -187
- package/std/matrix.d.ts +6 -12
- package/std/matrix.js +60 -69
- package/std/numeric.d.ts +143 -146
- package/std/numeric.js +858 -749
- package/std/operators.d.ts +19 -27
- package/std/operators.js +227 -193
- package/std/packing.d.ts +5 -11
- package/std/packing.js +67 -75
- package/std/range.d.ts +6 -11
- package/std/range.js +48 -36
- package/std/subgroup.d.ts +33 -37
- package/std/subgroup.js +180 -217
- package/std/texture.d.ts +70 -38
- package/std/texture.js +176 -172
- package/taskQueue.d.ts +6 -0
- package/taskQueue.js +30 -0
- package/tgpu.d.ts +16 -0
- package/tgpu.js +17 -44
- package/tgpuBindGroupLayout.d.ts +132 -152
- package/tgpuBindGroupLayout.js +346 -268
- package/tgpuLogger.d.ts +34 -0
- package/tgpuLogger.js +63 -0
- package/tgpuUnstable.d.ts +16 -22
- package/tgpuUnstable.js +13 -35
- package/tgsl/accessIndex.d.ts +2 -0
- package/tgsl/accessIndex.js +76 -33
- package/tgsl/accessProp.d.ts +2 -0
- package/tgsl/accessProp.js +142 -100
- package/tgsl/accessStructProp.d.ts +5 -0
- package/tgsl/accessStructProp.js +18 -0
- package/tgsl/consoleLog/deserializers.d.ts +13 -0
- package/tgsl/consoleLog/deserializers.js +119 -103
- package/tgsl/consoleLog/logGenerator.d.ts +21 -0
- package/tgsl/consoleLog/logGenerator.js +85 -80
- package/tgsl/consoleLog/serializers.d.ts +21 -0
- package/tgsl/consoleLog/serializers.js +119 -100
- package/tgsl/consoleLog/types.d.ts +40 -39
- package/tgsl/consoleLog/types.js +1 -0
- package/tgsl/conversion.d.ts +33 -0
- package/tgsl/conversion.js +272 -193
- package/tgsl/forOfUtils.d.ts +15 -0
- package/tgsl/forOfUtils.js +85 -70
- package/tgsl/generationHelpers.d.ts +22 -39
- package/tgsl/generationHelpers.js +85 -58
- package/tgsl/infixDispatch.d.ts +70 -0
- package/tgsl/infixDispatch.js +48 -46
- package/tgsl/jsPolyfills.d.ts +16 -19
- package/tgsl/jsPolyfills.js +44 -42
- package/tgsl/makeDereferenceable.d.ts +48 -0
- package/tgsl/makeDereferenceable.js +86 -0
- package/tgsl/makeResolvable.d.ts +22 -0
- package/tgsl/makeResolvable.js +33 -0
- package/tgsl/shaderGenerator.d.ts +77 -17
- package/tgsl/shaderGenerator.js +1 -0
- package/tgsl/shellless.d.ts +6 -9
- package/tgsl/shellless.js +73 -43
- package/tgsl/wgslGenerator.d.ts +66 -59
- package/tgsl/wgslGenerator.js +1344 -747
- package/types.d.ts +287 -221
- package/types.js +61 -44
- package/unwrapper.d.ts +31 -26
- package/unwrapper.js +1 -0
- package/wgslExtensions.d.ts +3 -5
- package/wgslExtensions.js +12 -16
- package/_virtual/rolldown_runtime.js +0 -13
- package/core/buffer/bufferShorthand.d.ts +0 -50
- package/core/buffer/bufferShorthand.js +0 -55
- package/core/pipeline/applyPipelineState.js +0 -37
- package/package.js +0 -5
- package/tgsl/shaderGenerator_members.d.ts +0 -33
- package/tgsl/shaderGenerator_members.js +0 -12
package/core/root/rootTypes.d.ts
CHANGED
|
@@ -1,146 +1,124 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
with(bindGroup: TgpuBindGroup): TgpuGuardedComputePipeline<TArgs>;
|
|
37
|
-
/**
|
|
38
|
-
* Returns a pipeline wrapper that encodes dispatches into the provided
|
|
39
|
-
* command encoder instead of submitting them immediately.
|
|
40
|
-
* Analogous to `TgpuComputePipeline.with(encoder)`.
|
|
41
|
-
*/
|
|
42
|
-
with(encoder: GPUCommandEncoder): TgpuGuardedComputePipeline<TArgs>;
|
|
43
|
-
/**
|
|
44
|
-
* Returns a pipeline wrapper with the given performance callback attached.
|
|
45
|
-
* Analogous to `TgpuComputePipeline.withPerformanceCallback(callback)`.
|
|
46
|
-
*/
|
|
47
|
-
withPerformanceCallback(callback: (start: bigint, end: bigint) => void | Promise<void>): TgpuGuardedComputePipeline<TArgs>;
|
|
48
|
-
/**
|
|
49
|
-
* Returns a pipeline wrapper with the given timestamp writes configuration.
|
|
50
|
-
* Analogous to `TgpuComputePipeline.withTimestampWrites(options)`.
|
|
51
|
-
*/
|
|
52
|
-
withTimestampWrites(options: {
|
|
53
|
-
querySet: TgpuQuerySet<'timestamp'> | GPUQuerySet;
|
|
54
|
-
beginningOfPassWriteIndex?: number;
|
|
55
|
-
endOfPassWriteIndex?: number;
|
|
56
|
-
}): TgpuGuardedComputePipeline<TArgs>;
|
|
57
|
-
/**
|
|
58
|
-
* Dispatches the pipeline.
|
|
59
|
-
* Unlike `TgpuComputePipeline.dispatchWorkgroups()`, this method takes in the
|
|
60
|
-
* number of threads to run in each dimension.
|
|
61
|
-
*
|
|
62
|
-
* Under the hood, the number of expected threads is sent as a uniform, and
|
|
63
|
-
* "guarded" by a bounds check.
|
|
64
|
-
*/
|
|
65
|
-
dispatchThreads(...args: TArgs): void;
|
|
66
|
-
/**
|
|
67
|
-
* The underlying pipeline used during `dispatchThreads`.
|
|
68
|
-
*/
|
|
69
|
-
pipeline: TgpuComputePipeline;
|
|
70
|
-
/**
|
|
71
|
-
* The buffer used to automatically pass the thread count to the underlying pipeline during `dispatchThreads`.
|
|
72
|
-
* For pipelines with a dimension count lower than 3, the remaining coordinates are expected to be 1.
|
|
73
|
-
*/
|
|
74
|
-
sizeUniform: TgpuUniform<Vec3u>;
|
|
1
|
+
import type { AnyComputeBuiltin, AnyFragmentInputBuiltin, OmitBuiltins } from '../../builtin.ts';
|
|
2
|
+
import type { TgpuQuerySet } from '../querySet/querySet.ts';
|
|
3
|
+
import type { AnyData } from '../../data/dataTypes.ts';
|
|
4
|
+
import type { InstanceToSchema } from '../../data/instanceToSchema.ts';
|
|
5
|
+
import type { WgslComparisonSamplerProps, WgslSamplerProps } from '../../data/sampler.ts';
|
|
6
|
+
import type { AnyWgslData, BaseData, v3u, v4f, Vec3u, Void } from '../../data/wgslTypes.ts';
|
|
7
|
+
import type { TgpuNamable } from '../../shared/meta.ts';
|
|
8
|
+
import type { TgpuSoul } from '../../shared/soul.ts';
|
|
9
|
+
import type { ExtractInvalidSchemaError, InferGPURecord, InferInput, IsValidBufferSchema, IsValidStorageSchema, IsValidUniformSchema } from '../../shared/repr.ts';
|
|
10
|
+
import { $internal, $soul } from '../../shared/symbols.ts';
|
|
11
|
+
import type { Assume, Mutable, OmitProps, Prettify } from '../../shared/utilityTypes.ts';
|
|
12
|
+
import type { ExtractBindGroupInputFromLayout, TgpuBindGroup, TgpuBindGroupLayout, TgpuLayoutEntry } from '../../tgpuBindGroupLayout.ts';
|
|
13
|
+
import type { LogGeneratorOptions } from '../../tgsl/consoleLog/types.ts';
|
|
14
|
+
import type { ShaderGeneratorClass } from '../../tgsl/shaderGenerator.ts';
|
|
15
|
+
import type { Unwrapper } from '../../unwrapper.ts';
|
|
16
|
+
import type { TgpuBuffer } from '../buffer/buffer.ts';
|
|
17
|
+
import type { TgpuMutable, TgpuReadonly, TgpuUniform } from '../buffer/bufferBinding.ts';
|
|
18
|
+
import type { AnyAutoCustoms, AutoFragmentIn, AutoFragmentOut, AutoVertexIn, AutoVertexOut } from '../function/autoIO.ts';
|
|
19
|
+
import type { IORecord } from '../function/fnTypes.ts';
|
|
20
|
+
import type { TgpuFragmentFn, VertexOutToVarying } from '../function/tgpuFragmentFn.ts';
|
|
21
|
+
import type { TgpuVertexFn } from '../function/tgpuVertexFn.ts';
|
|
22
|
+
import type { TgpuCommandEncoder } from '../commandEncoder/commandEncoder.ts';
|
|
23
|
+
import type { TgpuRenderBundleEncoder } from '../commandEncoder/renderPass.ts';
|
|
24
|
+
import type { TgpuComputePipeline } from '../pipeline/computePipeline.ts';
|
|
25
|
+
import type { FragmentOutToTargets, TgpuRenderPipeline } from '../pipeline/renderPipeline.ts';
|
|
26
|
+
import type { TgpuFixedComparisonSampler, TgpuFixedSampler } from '../sampler/sampler.ts';
|
|
27
|
+
import type { Eventual, TgpuAccessor, TgpuMutableAccessor, TgpuSlot } from '../slot/slotTypes.ts';
|
|
28
|
+
import type { TgpuTexture } from '../texture/texture.ts';
|
|
29
|
+
import type { AttribRecordToDefaultDataTypes, LayoutToAllowedAttribs } from '../vertexLayout/vertexAttribute.ts';
|
|
30
|
+
export interface TgpuRootSoul extends TgpuSoul<'root'> {
|
|
31
|
+
readonly device: GPUDevice;
|
|
32
|
+
readonly nameRegistrySetting: 'random' | 'strict';
|
|
33
|
+
readonly logOptions: LogGeneratorOptions;
|
|
34
|
+
readonly minify: boolean;
|
|
35
|
+
readonly nonTransferablePriors?: string[] | undefined;
|
|
75
36
|
}
|
|
76
|
-
interface
|
|
77
|
-
|
|
37
|
+
export interface TgpuGuardedComputePipelineSoul extends TgpuSoul<'guarded-compute-pipeline'> {
|
|
38
|
+
readonly device: GPUDevice;
|
|
39
|
+
readonly pipeline: TgpuComputePipeline;
|
|
40
|
+
readonly sizeUniform: TgpuUniform<Vec3u>;
|
|
41
|
+
readonly workgroupSize: v3u;
|
|
78
42
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
43
|
+
export interface TgpuGuardedComputePipeline<TArgs extends number[] = number[]> extends TgpuNamable {
|
|
44
|
+
readonly resourceType: 'guarded-compute-pipeline';
|
|
45
|
+
readonly [$soul]: TgpuGuardedComputePipelineSoul;
|
|
46
|
+
/**
|
|
47
|
+
* Returns a pipeline wrapper with the specified bind group bound.
|
|
48
|
+
* Analogous to `TgpuComputePipeline.with(bindGroup)`.
|
|
49
|
+
*/
|
|
50
|
+
with(bindGroup: TgpuBindGroup): TgpuGuardedComputePipeline<TArgs>;
|
|
51
|
+
/**
|
|
52
|
+
* Returns a pipeline wrapper with the given performance callback attached.
|
|
53
|
+
* Analogous to `TgpuComputePipeline.withPerformanceCallback(callback)`.
|
|
54
|
+
*/
|
|
55
|
+
withPerformanceCallback(callback: (start: bigint, end: bigint) => void | Promise<void>): TgpuGuardedComputePipeline<TArgs>;
|
|
56
|
+
/**
|
|
57
|
+
* Returns a pipeline wrapper with the given timestamp writes configuration.
|
|
58
|
+
* Analogous to `TgpuComputePipeline.withTimestampWrites(options)`.
|
|
59
|
+
*/
|
|
60
|
+
withTimestampWrites(options: {
|
|
61
|
+
querySet: TgpuQuerySet<'timestamp'> | GPUQuerySet;
|
|
62
|
+
beginningOfPassWriteIndex?: number;
|
|
63
|
+
endOfPassWriteIndex?: number;
|
|
64
|
+
}): TgpuGuardedComputePipeline<TArgs>;
|
|
65
|
+
/**
|
|
66
|
+
* Dispatches the pipeline.
|
|
67
|
+
* Unlike `TgpuComputePipeline.dispatchWorkgroups()`, this method takes in the
|
|
68
|
+
* number of threads to run in each dimension.
|
|
69
|
+
*
|
|
70
|
+
* Under the hood, the number of expected threads is sent as a uniform, and
|
|
71
|
+
* "guarded" by a bounds check.
|
|
72
|
+
*/
|
|
73
|
+
dispatchThreads(...args: TArgs): void;
|
|
74
|
+
/**
|
|
75
|
+
* Immediately resolves the pipeline, then awaits `device.createComputePipelineAsync()`.
|
|
76
|
+
* NOTE: it is not necessary to initialize pipelines manually.
|
|
77
|
+
*/
|
|
78
|
+
initAsync(): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Immediately resolves the pipeline and creates WebGPU resources.
|
|
81
|
+
* NOTE: it is not necessary to initialize pipelines manually.
|
|
82
|
+
*/
|
|
83
|
+
initSync(): void;
|
|
84
|
+
/**
|
|
85
|
+
* The underlying pipeline used during `dispatchThreads`.
|
|
86
|
+
*/
|
|
87
|
+
pipeline: TgpuComputePipeline;
|
|
88
|
+
/**
|
|
89
|
+
* The buffer used to automatically pass the thread count to the underlying pipeline during `dispatchThreads`.
|
|
90
|
+
* For pipelines with a dimension count lower than 3, the remaining coordinates are expected to be 1.
|
|
91
|
+
*/
|
|
92
|
+
sizeUniform: TgpuUniform<Vec3u>;
|
|
115
93
|
}
|
|
116
|
-
interface Withable<TSelf> {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
94
|
+
export interface Withable<TSelf> {
|
|
95
|
+
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TSelf;
|
|
96
|
+
with<T extends BaseData>(accessor: TgpuAccessor<T>, value: TgpuAccessor.In<NoInfer<T>>): TSelf;
|
|
97
|
+
with<T extends BaseData>(accessor: TgpuMutableAccessor<T>, value: TgpuMutableAccessor.In<NoInfer<T>>): TSelf;
|
|
120
98
|
}
|
|
121
|
-
interface Withable_Deprecated<TSelf> {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
99
|
+
export interface Withable_Deprecated<TSelf> {
|
|
100
|
+
/**
|
|
101
|
+
* @deprecated This feature is stable, remove the `['~unstable']`
|
|
102
|
+
* @param slot
|
|
103
|
+
* @param value
|
|
104
|
+
*/
|
|
105
|
+
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TSelf;
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated This feature is stable, remove the `['~unstable']`
|
|
108
|
+
* @param slot
|
|
109
|
+
* @param value
|
|
110
|
+
*/
|
|
111
|
+
with<T extends BaseData>(accessor: TgpuAccessor<T>, value: TgpuAccessor.In<NoInfer<T>>): TSelf;
|
|
112
|
+
/**
|
|
113
|
+
* @deprecated This feature is stable, remove the `['~unstable']`
|
|
114
|
+
* @param slot
|
|
115
|
+
* @param value
|
|
116
|
+
*/
|
|
117
|
+
with<T extends BaseData>(accessor: TgpuMutableAccessor<T>, value: TgpuMutableAccessor.In<NoInfer<T>>): TSelf;
|
|
140
118
|
}
|
|
141
|
-
interface Configurable extends Withable<Configurable> {
|
|
142
|
-
|
|
143
|
-
|
|
119
|
+
export interface Configurable extends Withable<Configurable> {
|
|
120
|
+
readonly bindings: [slot: TgpuSlot<unknown>, value: unknown][];
|
|
121
|
+
pipe(transform: (cfg: Configurable) => Configurable): Configurable;
|
|
144
122
|
}
|
|
145
123
|
/**
|
|
146
124
|
* Gets rid of builtins, and turns instances into schemas
|
|
@@ -148,501 +126,357 @@ interface Configurable extends Withable<Configurable> {
|
|
|
148
126
|
* @example d.builtin.position => d.Void
|
|
149
127
|
* @example { a: d.v4f, $fragDepth: number } => { a: d.Vec4f }
|
|
150
128
|
*/
|
|
151
|
-
type NormalizeOutput<T
|
|
152
|
-
|
|
153
|
-
} | number | boolean ? [OmitBuiltins<InstanceToSchema<T
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
* @deprecated Use `root.createRenderPipeline` instead.
|
|
229
|
-
*/
|
|
230
|
-
withVertex<VertexIn extends TgpuVertexFn.In, VertexOut extends TgpuVertexFn.Out>(entryFn: TgpuVertexFn<VertexIn, VertexOut>, ...args: OptionalArgs<LayoutToAllowedAttribs<OmitBuiltins<VertexIn>>>): WithVertex<VertexOut>;
|
|
231
|
-
pipe(transform: (cfg: Configurable) => Configurable): WithBinding;
|
|
129
|
+
type NormalizeOutput<T> = T extends {
|
|
130
|
+
readonly [$internal]: unknown;
|
|
131
|
+
} | number | boolean ? [OmitBuiltins<InstanceToSchema<T>>] extends [never] ? Void : OmitBuiltins<InstanceToSchema<T>> : {
|
|
132
|
+
[K in keyof OmitBuiltins<T>]: InstanceToSchema<OmitBuiltins<T>[K]>;
|
|
133
|
+
};
|
|
134
|
+
export interface WithBinding extends Withable<WithBinding> {
|
|
135
|
+
createComputePipeline<ComputeIn extends IORecord<AnyComputeBuiltin>>(descriptor: TgpuComputePipeline.Descriptor<ComputeIn>): TgpuComputePipeline;
|
|
136
|
+
createRenderPipeline<TVertexIn extends TgpuVertexFn.In = Record<string, any>, TAttribs extends LayoutToAllowedAttribs<TVertexIn> = LayoutToAllowedAttribs<TVertexIn>, TVertexOut = unknown, TFragmentOut = unknown>(descriptor: TgpuRenderPipeline.DescriptorBase & {
|
|
137
|
+
attribs?: TAttribs;
|
|
138
|
+
vertex: TgpuVertexFn<TVertexIn, Assume<TVertexOut, TgpuVertexFn.Out>> | ((input: AutoVertexIn<Assume<InferGPURecord<AttribRecordToDefaultDataTypes<TAttribs>>, AnyAutoCustoms>>) => AutoVertexOut<Assume<TVertexOut, AnyAutoCustoms>>);
|
|
139
|
+
fragment: TgpuFragmentFn<VertexOutToVarying<TVertexOut> & Record<string, AnyFragmentInputBuiltin>, Assume<TFragmentOut, TgpuFragmentFn.Out>> | ((input: AutoFragmentIn<Assume<InferGPURecord<VertexOutToVarying<TVertexOut>>, AnyAutoCustoms>>) => AutoFragmentOut<Assume<TFragmentOut, AnyAutoCustoms | v4f>>);
|
|
140
|
+
targets?: FragmentOutToTargets<NoInfer<TFragmentOut>>;
|
|
141
|
+
}): TgpuRenderPipeline<NormalizeOutput<TFragmentOut>>;
|
|
142
|
+
createRenderPipeline<TVertexIn extends TgpuVertexFn.In = Record<string, any>, TAttribs extends LayoutToAllowedAttribs<TVertexIn> = LayoutToAllowedAttribs<TVertexIn>, TVertexOut extends TgpuVertexFn.Out = TgpuVertexFn.Out>(descriptor: TgpuRenderPipeline.DescriptorBase & {
|
|
143
|
+
attribs?: TAttribs;
|
|
144
|
+
vertex: TgpuVertexFn<TVertexIn, Assume<TVertexOut, TgpuVertexFn.Out>> | ((input: AutoVertexIn<Assume<InferGPURecord<AttribRecordToDefaultDataTypes<TAttribs>>, AnyAutoCustoms>>) => AutoVertexOut<Assume<TVertexOut, AnyAutoCustoms>>);
|
|
145
|
+
fragment?: undefined | TgpuFragmentFn<VertexOutToVarying<OmitBuiltins<TVertexOut>> & Record<string, AnyFragmentInputBuiltin>, Record<string, never> | Void> | ((input: AutoFragmentIn<Assume<InferGPURecord<OmitBuiltins<NoInfer<TVertexOut>>>, AnyAutoCustoms>>) => AutoFragmentOut<undefined>);
|
|
146
|
+
targets?: undefined;
|
|
147
|
+
}): TgpuRenderPipeline<Void>;
|
|
148
|
+
createRenderPipeline<TVertexIn extends TgpuVertexFn.In = Record<string, any>, TAttribs extends LayoutToAllowedAttribs<TVertexIn> = LayoutToAllowedAttribs<TVertexIn>, TVertexOut extends TgpuVertexFn.Out = TgpuVertexFn.Out, TFragmentOut = unknown>(descriptor: TgpuRenderPipeline.DescriptorBase & ({
|
|
149
|
+
attribs?: TAttribs;
|
|
150
|
+
vertex: TgpuVertexFn<TVertexIn, Assume<TVertexOut, TgpuVertexFn.Out>> | ((input: AutoVertexIn<Assume<InferGPURecord<AttribRecordToDefaultDataTypes<TAttribs>>, AnyAutoCustoms>>) => AutoVertexOut<Assume<TVertexOut, AnyAutoCustoms>>);
|
|
151
|
+
fragment: ((input: AutoFragmentIn<Assume<InferGPURecord<OmitBuiltins<NoInfer<TVertexOut>>>, AnyAutoCustoms>>) => AutoFragmentOut<Assume<TFragmentOut, AnyAutoCustoms | v4f>>) | TgpuFragmentFn<VertexOutToVarying<OmitBuiltins<TVertexOut>> & Record<string, AnyFragmentInputBuiltin>, Assume<TFragmentOut, TgpuFragmentFn.Out>>;
|
|
152
|
+
targets?: FragmentOutToTargets<NoInfer<TFragmentOut>>;
|
|
153
|
+
} | {
|
|
154
|
+
attribs?: TAttribs;
|
|
155
|
+
vertex: TgpuVertexFn<TVertexIn, Assume<TVertexOut, TgpuVertexFn.Out>> | ((input: AutoVertexIn<Assume<InferGPURecord<AttribRecordToDefaultDataTypes<TAttribs>>, AnyAutoCustoms>>) => AutoVertexOut<Assume<TVertexOut, AnyAutoCustoms>>);
|
|
156
|
+
fragment?: undefined | TgpuFragmentFn<VertexOutToVarying<OmitBuiltins<TVertexOut>> & Record<string, AnyFragmentInputBuiltin>, Record<string, never>> | ((input: AutoFragmentIn<Assume<InferGPURecord<OmitBuiltins<NoInfer<TVertexOut>>>, AnyAutoCustoms>>) => AutoFragmentOut<undefined>);
|
|
157
|
+
targets?: undefined;
|
|
158
|
+
})): TgpuRenderPipeline<NormalizeOutput<TFragmentOut>> | TgpuRenderPipeline<Void>;
|
|
159
|
+
/**
|
|
160
|
+
* Creates a compute pipeline that executes the given callback in an exact number of threads.
|
|
161
|
+
* This is different from `createComputePipeline()` in that it does a bounds check on the
|
|
162
|
+
* thread id, where as regular pipelines do not and work in units of workgroups.
|
|
163
|
+
*
|
|
164
|
+
* @param callback A function converted to WGSL and executed on the GPU.
|
|
165
|
+
* It can accept up to 3 parameters (x, y, z) which correspond to the global invocation ID
|
|
166
|
+
* of the executing thread.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* If no parameters are provided, the callback will be executed once, in a single thread.
|
|
170
|
+
*
|
|
171
|
+
* ```ts
|
|
172
|
+
* const fooPipeline = root
|
|
173
|
+
* .createGuardedComputePipeline(() => {
|
|
174
|
+
* 'use gpu';
|
|
175
|
+
* console.log('Hello, GPU!');
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* fooPipeline.dispatchThreads();
|
|
179
|
+
* // [GPU] Hello, GPU!
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* One parameter means n-threads will be executed in parallel.
|
|
184
|
+
*
|
|
185
|
+
* ```ts
|
|
186
|
+
* const fooPipeline = root
|
|
187
|
+
* .createGuardedComputePipeline((x) => {
|
|
188
|
+
* 'use gpu';
|
|
189
|
+
* if (x % 16 === 0) {
|
|
190
|
+
* // Logging every 16th thread
|
|
191
|
+
* console.log('I am the', x, 'thread');
|
|
192
|
+
* }
|
|
193
|
+
* });
|
|
194
|
+
*
|
|
195
|
+
* // executing 512 threads
|
|
196
|
+
* fooPipeline.dispatchThreads(512);
|
|
197
|
+
* // [GPU] I am the 256 thread
|
|
198
|
+
* // [GPU] I am the 272 thread
|
|
199
|
+
* // ... (30 hidden logs)
|
|
200
|
+
* // [GPU] I am the 16 thread
|
|
201
|
+
* // [GPU] I am the 240 thread
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
createGuardedComputePipeline<TArgs extends number[]>(callback: (...args: TArgs) => void): TgpuGuardedComputePipeline<TArgs>;
|
|
205
|
+
pipe(transform: (cfg: Configurable) => Configurable): WithBinding;
|
|
232
206
|
}
|
|
233
207
|
type SrgbVariants = {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
208
|
+
rgba8unorm: 'rgba8unorm-srgb';
|
|
209
|
+
bgra8unorm: 'bgra8unorm-srgb';
|
|
210
|
+
'bc1-rgba-unorm': 'bc1-rgba-unorm-srgb';
|
|
211
|
+
'bc2-rgba-unorm': 'bc2-rgba-unorm-srgb';
|
|
212
|
+
'bc3-rgba-unorm': 'bc3-rgba-unorm-srgb';
|
|
213
|
+
'bc7-rgba-unorm': 'bc7-rgba-unorm-srgb';
|
|
214
|
+
'etc2-rgb8unorm': 'etc2-rgb8unorm-srgb';
|
|
215
|
+
'etc2-rgb8a1unorm': 'etc2-rgb8a1unorm-srgb';
|
|
216
|
+
'etc2-rgba8unorm': 'etc2-rgba8unorm-srgb';
|
|
217
|
+
'astc-4x4-unorm': 'astc-4x4-unorm-srgb';
|
|
218
|
+
'astc-5x4-unorm': 'astc-5x4-unorm-srgb';
|
|
219
|
+
'astc-5x5-unorm': 'astc-5x5-unorm-srgb';
|
|
220
|
+
'astc-6x5-unorm': 'astc-6x5-unorm-srgb';
|
|
221
|
+
'astc-6x6-unorm': 'astc-6x6-unorm-srgb';
|
|
222
|
+
'astc-8x5-unorm': 'astc-8x5-unorm-srgb';
|
|
223
|
+
'astc-8x6-unorm': 'astc-8x6-unorm-srgb';
|
|
224
|
+
'astc-8x8-unorm': 'astc-8x8-unorm-srgb';
|
|
225
|
+
'astc-10x5-unorm': 'astc-10x5-unorm-srgb';
|
|
226
|
+
'astc-10x6-unorm': 'astc-10x6-unorm-srgb';
|
|
227
|
+
'astc-10x8-unorm': 'astc-10x8-unorm-srgb';
|
|
228
|
+
'astc-10x10-unorm': 'astc-10x10-unorm-srgb';
|
|
229
|
+
'astc-12x10-unorm': 'astc-12x10-unorm-srgb';
|
|
230
|
+
'astc-12x12-unorm': 'astc-12x12-unorm-srgb';
|
|
257
231
|
};
|
|
258
|
-
type SrgbVariantOrSelf<T
|
|
259
|
-
type CreateTextureOptions<TSize, TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension> = {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
232
|
+
type SrgbVariantOrSelf<T extends GPUTextureFormat> = T extends keyof SrgbVariants ? (SrgbVariants[T] | T)[] | undefined : T extends `${infer Base}-srgb` ? Base extends keyof SrgbVariants ? (T | SrgbVariants[Base])[] | undefined : T[] | undefined : T[] | undefined;
|
|
233
|
+
export type CreateTextureOptions<TSize, TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension> = {
|
|
234
|
+
/**
|
|
235
|
+
* The width, height, and depth or layer count of the texture.
|
|
236
|
+
*/
|
|
237
|
+
size: TSize;
|
|
238
|
+
/**
|
|
239
|
+
* The format of the texture.
|
|
240
|
+
*/
|
|
241
|
+
format: TFormat;
|
|
242
|
+
/**
|
|
243
|
+
* The number of mip levels the texture will contain.
|
|
244
|
+
* @default 1
|
|
245
|
+
*/
|
|
246
|
+
mipLevelCount?: TMipLevelCount | undefined;
|
|
247
|
+
/**
|
|
248
|
+
* The sample count of the texture. A sampleCount > 1 indicates a multisampled texture.
|
|
249
|
+
* @default 1
|
|
250
|
+
*/
|
|
251
|
+
sampleCount?: TSampleCount | undefined;
|
|
252
|
+
/**
|
|
253
|
+
* Specifies extra formats (in addition to the texture's actual format) that can be used
|
|
254
|
+
* when creating views of this texture.
|
|
255
|
+
* @default []
|
|
256
|
+
*/
|
|
257
|
+
viewFormats?: TViewFormats extends SrgbVariantOrSelf<NoInfer<TFormat>> ? TViewFormats : SrgbVariantOrSelf<NoInfer<TFormat>>;
|
|
258
|
+
/**
|
|
259
|
+
* Whether the texture is one-dimensional, an array of two-dimensional layers, or three-dimensional.
|
|
260
|
+
* @default '2d'
|
|
261
|
+
*/
|
|
262
|
+
dimension?: TDimension | undefined;
|
|
289
263
|
};
|
|
290
|
-
type CreateTextureResult<TSize extends readonly number[], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension> = Prettify<{
|
|
291
|
-
|
|
292
|
-
|
|
264
|
+
export type CreateTextureResult<TSize extends readonly number[], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension> = Prettify<{
|
|
265
|
+
size: Mutable<TSize>;
|
|
266
|
+
format: TFormat;
|
|
293
267
|
} & OmitProps<{
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
268
|
+
dimension: GPUTextureDimension extends TDimension ? undefined : TDimension extends '2d' ? undefined : TDimension;
|
|
269
|
+
mipLevelCount: number extends TMipLevelCount ? undefined : TMipLevelCount extends 1 ? undefined : TMipLevelCount;
|
|
270
|
+
sampleCount: number extends TSampleCount ? undefined : TSampleCount extends 1 ? undefined : TSampleCount;
|
|
271
|
+
viewFormats: GPUTextureFormat[] extends TViewFormats ? undefined : TViewFormats extends never[] ? undefined : TViewFormats extends SrgbVariantOrSelf<TFormat> ? TViewFormats : never;
|
|
298
272
|
}, undefined>>;
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
*/
|
|
313
|
-
setIndexBuffer<TData extends WgslArray | Disarray>(buffer: TgpuBuffer<TData> | GPUBuffer, indexFormat: GPUIndexFormat, offset?: GPUSize64, size?: GPUSize64): void;
|
|
314
|
-
/**
|
|
315
|
-
* Binds a vertex buffer to the given vertex layout for subsequent draw calls.
|
|
316
|
-
* @param vertexLayout - The vertex layout describing the buffer's structure.
|
|
317
|
-
* @param buffer - The vertex buffer to bind.
|
|
318
|
-
* @param offset - Offset in bytes into `buffer`. Defaults to `0`.
|
|
319
|
-
* @param size - Size in bytes to bind. Defaults to the remainder of the buffer.
|
|
320
|
-
*/
|
|
321
|
-
setVertexBuffer<TData extends WgslArray | Disarray>(vertexLayout: TgpuVertexLayout<TData>, buffer: (TgpuBuffer<TData> & VertexFlag) | GPUBuffer, offset?: GPUSize64, size?: GPUSize64): void;
|
|
322
|
-
/**
|
|
323
|
-
* Associates a bind group with the given layout for subsequent draw calls.
|
|
324
|
-
* @param bindGroupLayout - The layout the bind group conforms to.
|
|
325
|
-
* @param bindGroup - The bind group to associate.
|
|
326
|
-
*/
|
|
327
|
-
setBindGroup<Entries extends Record<string, TgpuLayoutEntry | null>>(bindGroupLayout: TgpuBindGroupLayout<Entries>, bindGroup: TgpuBindGroup<Entries> | GPUBindGroup): void;
|
|
328
|
-
/**
|
|
329
|
-
* Draws primitives.
|
|
330
|
-
* @param vertexCount - The number of vertices to draw.
|
|
331
|
-
* @param instanceCount - The number of instances to draw.
|
|
332
|
-
* @param firstVertex - Offset into the vertex buffers, in vertices, to begin drawing from.
|
|
333
|
-
* @param firstInstance - First instance to draw.
|
|
334
|
-
*/
|
|
335
|
-
draw(vertexCount: number, instanceCount?: number, firstVertex?: number, firstInstance?: number): void;
|
|
336
|
-
/**
|
|
337
|
-
* Draws indexed primitives.
|
|
338
|
-
* @param indexCount - The number of indices to draw.
|
|
339
|
-
* @param instanceCount - The number of instances to draw.
|
|
340
|
-
* @param firstIndex - Offset into the index buffer, in indices, begin drawing from.
|
|
341
|
-
* @param baseVertex - Added to each index value before indexing into the vertex buffers.
|
|
342
|
-
* @param firstInstance - First instance to draw.
|
|
343
|
-
*/
|
|
344
|
-
drawIndexed(indexCount: number, instanceCount?: number, firstIndex?: number, baseVertex?: number, firstInstance?: number): void;
|
|
345
|
-
/**
|
|
346
|
-
* Draws primitives using parameters read from a {@link GPUBuffer}.
|
|
347
|
-
* @param indirectBuffer - Buffer containing the indirect draw parameters.
|
|
348
|
-
* @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.
|
|
349
|
-
*/
|
|
350
|
-
drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): void;
|
|
351
|
-
/**
|
|
352
|
-
* Draws indexed primitives using parameters read from a {@link GPUBuffer}.
|
|
353
|
-
* @param indirectBuffer - Buffer containing the indirect drawIndexed parameters.
|
|
354
|
-
* @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.
|
|
355
|
-
*/
|
|
356
|
-
drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): void;
|
|
357
|
-
}
|
|
358
|
-
interface RenderPass extends RenderBundleEncoderPass {
|
|
359
|
-
/**
|
|
360
|
-
* Sets the viewport used during the rasterization stage to linearly map from
|
|
361
|
-
* NDC (i.e., normalized device coordinates) to viewport coordinates.
|
|
362
|
-
* @param x - Minimum X value of the viewport in pixels.
|
|
363
|
-
* @param y - Minimum Y value of the viewport in pixels.
|
|
364
|
-
* @param width - Width of the viewport in pixels.
|
|
365
|
-
* @param height - Height of the viewport in pixels.
|
|
366
|
-
* @param minDepth - Minimum depth value of the viewport.
|
|
367
|
-
* @param maxDepth - Maximum depth value of the viewport.
|
|
368
|
-
*/
|
|
369
|
-
setViewport(x: number, y: number, width: number, height: number, minDepth: number, maxDepth: number): void;
|
|
370
|
-
/**
|
|
371
|
-
* Sets the scissor rectangle used during the rasterization stage.
|
|
372
|
-
* After transformation into viewport coordinates any fragments which fall outside the scissor
|
|
373
|
-
* rectangle will be discarded.
|
|
374
|
-
* @param x - Minimum X value of the scissor rectangle in pixels.
|
|
375
|
-
* @param y - Minimum Y value of the scissor rectangle in pixels.
|
|
376
|
-
* @param width - Width of the scissor rectangle in pixels.
|
|
377
|
-
* @param height - Height of the scissor rectangle in pixels.
|
|
378
|
-
*/
|
|
379
|
-
setScissorRect(x: number, y: number, width: number, height: number): void;
|
|
380
|
-
/**
|
|
381
|
-
* Sets the constant blend color and alpha values used with {@link GPUBlendFactor#constant}
|
|
382
|
-
* and {@link GPUBlendFactor#"one-minus-constant"} {@link GPUBlendFactor}s.
|
|
383
|
-
* @param color - The color to use when blending.
|
|
384
|
-
*/
|
|
385
|
-
setBlendConstant(color: GPUColor): void;
|
|
386
|
-
/**
|
|
387
|
-
* Sets the {@link RenderState#[[stencilReference]]} value used during stencil tests with
|
|
388
|
-
* the {@link GPUStencilOperation#"replace"} {@link GPUStencilOperation}.
|
|
389
|
-
* @param reference - The new stencil reference value.
|
|
390
|
-
*/
|
|
391
|
-
setStencilReference(reference: GPUStencilValue): void;
|
|
392
|
-
/**
|
|
393
|
-
* @param queryIndex - The index of the query in the query set.
|
|
394
|
-
*/
|
|
395
|
-
beginOcclusionQuery(queryIndex: GPUSize32): void;
|
|
396
|
-
endOcclusionQuery(): void;
|
|
397
|
-
/**
|
|
398
|
-
* Executes the commands previously recorded into the given {@link GPURenderBundle}s as part of
|
|
399
|
-
* this render pass.
|
|
400
|
-
* When a {@link GPURenderBundle} is executed, it does not inherit the render pass's pipeline, bind
|
|
401
|
-
* groups, or vertex and index buffers. After a {@link GPURenderBundle} has executed, the render
|
|
402
|
-
* pass's pipeline, bind group, and vertex/index buffer state is cleared
|
|
403
|
-
* (to the initial, empty values).
|
|
404
|
-
* Note: The state is cleared, not restored to the previous state.
|
|
405
|
-
* This occurs even if zero {@link GPURenderBundle|GPURenderBundles} are executed.
|
|
406
|
-
* @param bundles - List of render bundles to execute.
|
|
407
|
-
*/
|
|
408
|
-
executeBundles(bundles: Iterable<GPURenderBundle>): undefined;
|
|
409
|
-
setPipeline(pipeline: TgpuRenderPipeline): void;
|
|
410
|
-
/**
|
|
411
|
-
* Sets the current index buffer.
|
|
412
|
-
* @param buffer - Buffer containing index data to use for subsequent drawing commands.
|
|
413
|
-
* @param indexFormat - Format of the index data contained in `buffer`.
|
|
414
|
-
* @param offset - Offset in bytes into `buffer` where the index data begins. Defaults to `0`.
|
|
415
|
-
* @param size - Size in bytes of the index data in `buffer`.
|
|
416
|
-
* Defaults to the size of the buffer minus the offset.
|
|
417
|
-
*/
|
|
418
|
-
setIndexBuffer<TData extends WgslArray | Disarray>(buffer: TgpuBuffer<TData> | GPUBuffer, indexFormat: GPUIndexFormat, offset?: GPUSize64, size?: GPUSize64): void;
|
|
419
|
-
setVertexBuffer<TData extends WgslArray | Disarray>(vertexLayout: TgpuVertexLayout<TData>, buffer: (TgpuBuffer<TData> & VertexFlag) | GPUBuffer, offset?: GPUSize64, size?: GPUSize64): void;
|
|
420
|
-
setBindGroup<Entries extends Record<string, TgpuLayoutEntry | null>>(bindGroupLayout: TgpuBindGroupLayout<Entries>, bindGroup: TgpuBindGroup<Entries> | GPUBindGroup): void;
|
|
421
|
-
/**
|
|
422
|
-
* Draws primitives.
|
|
423
|
-
* @param vertexCount - The number of vertices to draw.
|
|
424
|
-
* @param instanceCount - The number of instances to draw.
|
|
425
|
-
* @param firstVertex - Offset into the vertex buffers, in vertices, to begin drawing from.
|
|
426
|
-
* @param firstInstance - First instance to draw.
|
|
427
|
-
*/
|
|
428
|
-
draw(vertexCount: number, instanceCount?: number, firstVertex?: number, firstInstance?: number): void;
|
|
429
|
-
/**
|
|
430
|
-
* Draws indexed primitives.
|
|
431
|
-
* @param indexCount - The number of indices to draw.
|
|
432
|
-
* @param instanceCount - The number of instances to draw.
|
|
433
|
-
* @param firstIndex - Offset into the index buffer, in indices, begin drawing from.
|
|
434
|
-
* @param baseVertex - Added to each index value before indexing into the vertex buffers.
|
|
435
|
-
* @param firstInstance - First instance to draw.
|
|
436
|
-
*/
|
|
437
|
-
drawIndexed(indexCount: number, instanceCount?: number, firstIndex?: number, baseVertex?: number, firstInstance?: number): void;
|
|
438
|
-
/**
|
|
439
|
-
* Draws primitives using parameters read from a {@link GPUBuffer}.
|
|
440
|
-
* Packed block of **four 32-bit unsigned integer values (16 bytes total)**, given in the same
|
|
441
|
-
* order as the arguments for {@link GPURenderEncoderBase#draw}. For example:
|
|
442
|
-
* @param indirectBuffer - Buffer containing the indirect draw parameters.
|
|
443
|
-
* @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.
|
|
444
|
-
*/
|
|
445
|
-
drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): void;
|
|
446
|
-
/**
|
|
447
|
-
* Draws indexed primitives using parameters read from a {@link GPUBuffer}.
|
|
448
|
-
* Tightly packed block of **five 32-bit unsigned integer values (20 bytes total)**, given in
|
|
449
|
-
* the same order as the arguments for {@link GPURenderEncoderBase#drawIndexed}. For example:
|
|
450
|
-
* @param indirectBuffer - Buffer containing the indirect drawIndexed parameters.
|
|
451
|
-
* @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.
|
|
452
|
-
*/
|
|
453
|
-
drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): void;
|
|
454
|
-
}
|
|
455
|
-
type ValidateBufferSchema<TData extends BaseData> = IsValidBufferSchema<TData> extends false ? ExtractInvalidSchemaError<TData, '(Error) '> : TData;
|
|
456
|
-
type ValidateStorageSchema<TData extends BaseData> = IsValidStorageSchema<TData> extends false ? ExtractInvalidSchemaError<TData, '(Error) '> : TData;
|
|
457
|
-
type ValidateUniformSchema<TData extends BaseData> = IsValidUniformSchema<TData> extends false ? ExtractInvalidSchemaError<TData, '(Error) '> : TData;
|
|
458
|
-
type ConfigureContextOptions = {
|
|
459
|
-
/**
|
|
460
|
-
* The canvas for which a context will be created and configured.
|
|
461
|
-
*/
|
|
462
|
-
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
463
|
-
/**
|
|
464
|
-
* Passed to `context.configure()`.
|
|
465
|
-
* Defaults to `navigator.gpu.getPreferredCanvasFormat()` if not provided.
|
|
466
|
-
*/
|
|
467
|
-
format?: GPUTextureFormat;
|
|
273
|
+
export type ValidateBufferSchema<TData extends BaseData> = IsValidBufferSchema<TData> extends false ? ExtractInvalidSchemaError<TData, '(Error) '> : TData;
|
|
274
|
+
export type ValidateStorageSchema<TData extends BaseData> = IsValidStorageSchema<TData> extends false ? ExtractInvalidSchemaError<TData, '(Error) '> : TData;
|
|
275
|
+
export type ValidateUniformSchema<TData extends BaseData> = IsValidUniformSchema<TData> extends false ? ExtractInvalidSchemaError<TData, '(Error) '> : TData;
|
|
276
|
+
export type ConfigureContextOptions = {
|
|
277
|
+
/**
|
|
278
|
+
* The canvas for which a context will be created and configured.
|
|
279
|
+
*/
|
|
280
|
+
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
281
|
+
/**
|
|
282
|
+
* Passed to `context.configure()`.
|
|
283
|
+
* Defaults to `navigator.gpu.getPreferredCanvasFormat()` if not provided.
|
|
284
|
+
*/
|
|
285
|
+
format?: GPUTextureFormat;
|
|
468
286
|
} & Omit<GPUCanvasConfiguration, 'device' | 'format'>;
|
|
469
|
-
interface TgpuRoot extends Unwrapper, WithBinding {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
287
|
+
export interface TgpuRoot extends Unwrapper, WithBinding {
|
|
288
|
+
readonly resourceType: 'root';
|
|
289
|
+
readonly [$soul]: TgpuRootSoul;
|
|
290
|
+
[$internal]: {
|
|
291
|
+
logOptions: LogGeneratorOptions;
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* The GPU device associated with this root.
|
|
295
|
+
*/
|
|
296
|
+
readonly device: GPUDevice;
|
|
297
|
+
/**
|
|
298
|
+
* Creates and configures context for the provided canvas.
|
|
299
|
+
* Automatically sets the format to `navigator.gpu.getPreferredCanvasFormat()` if not provided.
|
|
300
|
+
* @throws An error if no context could be obtained
|
|
301
|
+
*/
|
|
302
|
+
configureContext(options: ConfigureContextOptions): GPUCanvasContext;
|
|
303
|
+
/**
|
|
304
|
+
* Allocates memory on the GPU, allows passing data between host and shader.
|
|
305
|
+
*
|
|
306
|
+
* @remarks
|
|
307
|
+
* Typed wrapper around a GPUBuffer.
|
|
308
|
+
*
|
|
309
|
+
* @param typeSchema The type of data that this buffer will hold.
|
|
310
|
+
* @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
|
|
311
|
+
*/
|
|
312
|
+
createBuffer<TData extends AnyData>(typeSchema: ValidateBufferSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuBuffer<TData>;
|
|
313
|
+
/**
|
|
314
|
+
* Allocates memory on the GPU, allows passing data between host and shader.
|
|
315
|
+
*
|
|
316
|
+
* @remarks
|
|
317
|
+
* Typed wrapper around a GPUBuffer.
|
|
318
|
+
*
|
|
319
|
+
* @param typeSchema The type of data that this buffer will hold.
|
|
320
|
+
* @param gpuBuffer A vanilla WebGPU buffer.
|
|
321
|
+
*/
|
|
322
|
+
createBuffer<TData extends AnyData>(typeSchema: ValidateBufferSchema<TData>, gpuBuffer: GPUBuffer): TgpuBuffer<TData>;
|
|
323
|
+
/**
|
|
324
|
+
* Allocates memory on the GPU, allows passing data between host and shader.
|
|
325
|
+
* Read-only on the GPU, optimized for small data. For a general-purpose buffer,
|
|
326
|
+
* use {@link TgpuRoot.createBuffer}.
|
|
327
|
+
*
|
|
328
|
+
* @param typeSchema The type of data that this buffer will hold.
|
|
329
|
+
* @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
|
|
330
|
+
*/
|
|
331
|
+
createUniform<TData extends AnyWgslData>(typeSchema: ValidateUniformSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuUniform<TData>;
|
|
332
|
+
/**
|
|
333
|
+
* Allocates memory on the GPU, allows passing data between host and shader.
|
|
334
|
+
* Read-only on the GPU, optimized for small data. For a general-purpose buffer,
|
|
335
|
+
* use {@link TgpuRoot.createBuffer}.
|
|
336
|
+
*
|
|
337
|
+
* @param typeSchema The type of data that this buffer will hold.
|
|
338
|
+
* @param gpuBuffer A vanilla WebGPU buffer.
|
|
339
|
+
*/
|
|
340
|
+
createUniform<TData extends AnyWgslData>(typeSchema: ValidateUniformSchema<TData>, gpuBuffer: GPUBuffer): TgpuUniform<TData>;
|
|
341
|
+
/**
|
|
342
|
+
* Allocates memory on the GPU, allows passing data between host and shader.
|
|
343
|
+
* Can be mutated in-place on the GPU. For a general-purpose buffer,
|
|
344
|
+
* use {@link TgpuRoot.createBuffer}.
|
|
345
|
+
*
|
|
346
|
+
* @param typeSchema The type of data that this buffer will hold.
|
|
347
|
+
* @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
|
|
348
|
+
*/
|
|
349
|
+
createMutable<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuMutable<TData>;
|
|
350
|
+
/**
|
|
351
|
+
* Allocates memory on the GPU, allows passing data between host and shader.
|
|
352
|
+
* Can be mutated in-place on the GPU. For a general-purpose buffer,
|
|
353
|
+
* use {@link TgpuRoot.createBuffer}.
|
|
354
|
+
*
|
|
355
|
+
* @param typeSchema The type of data that this buffer will hold.
|
|
356
|
+
* @param gpuBuffer A vanilla WebGPU buffer.
|
|
357
|
+
*/
|
|
358
|
+
createMutable<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, gpuBuffer: GPUBuffer): TgpuMutable<TData>;
|
|
359
|
+
/**
|
|
360
|
+
* Allocates memory on the GPU, allows passing data between host and shader.
|
|
361
|
+
* Read-only on the GPU, optimized for large data. For a general-purpose buffer,
|
|
362
|
+
* use {@link TgpuRoot.createBuffer}.
|
|
363
|
+
*
|
|
364
|
+
* @param typeSchema The type of data that this buffer will hold.
|
|
365
|
+
* @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
|
|
366
|
+
*/
|
|
367
|
+
createReadonly<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuReadonly<TData>;
|
|
368
|
+
/**
|
|
369
|
+
* Allocates memory on the GPU, allows passing data between host and shader.
|
|
370
|
+
* Read-only on the GPU, optimized for large data. For a general-purpose buffer,
|
|
371
|
+
* use {@link TgpuRoot.createBuffer}.
|
|
372
|
+
*
|
|
373
|
+
* @param typeSchema The type of data that this buffer will hold.
|
|
374
|
+
* @param gpuBuffer A vanilla WebGPU buffer.
|
|
375
|
+
*/
|
|
376
|
+
createReadonly<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, gpuBuffer: GPUBuffer): TgpuReadonly<TData>;
|
|
377
|
+
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, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension>(props: CreateTextureOptions<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>): TgpuTexture<CreateTextureResult<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>>;
|
|
378
|
+
createSampler(props: WgslSamplerProps): TgpuFixedSampler;
|
|
379
|
+
createComparisonSampler(props: WgslComparisonSamplerProps): TgpuFixedComparisonSampler;
|
|
380
|
+
/**
|
|
381
|
+
* Creates a query set for collecting timestamps or occlusion queries.
|
|
382
|
+
*
|
|
383
|
+
* @remarks
|
|
384
|
+
* Typed wrapper around a GPUQuerySet.
|
|
385
|
+
*
|
|
386
|
+
* @param type The type of queries to collect ('occlusion' or 'timestamp').
|
|
387
|
+
* @param count The number of queries in the set.
|
|
388
|
+
* @param rawQuerySet An optional pre-existing GPUQuerySet to use instead of creating a new one.
|
|
389
|
+
*/
|
|
390
|
+
createQuerySet<T extends GPUQueryType>(type: T, count: number, rawQuerySet?: GPUQuerySet): TgpuQuerySet<T>;
|
|
391
|
+
/**
|
|
392
|
+
* Creates a group of resources that can be bound to a shader based on a specified layout.
|
|
393
|
+
*
|
|
394
|
+
* @remarks
|
|
395
|
+
* Typed wrapper around a GPUBindGroup.
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* const fooLayout = tgpu.bindGroupLayout({
|
|
399
|
+
* foo: { uniform: d.vec3f },
|
|
400
|
+
* bar: { texture: d.texture2d(d.f32) },
|
|
401
|
+
* });
|
|
402
|
+
*
|
|
403
|
+
* const fooBuffer = ...;
|
|
404
|
+
* const barTexture = ...;
|
|
405
|
+
*
|
|
406
|
+
* const fooBindGroup = root.createBindGroup(fooLayout, {
|
|
407
|
+
* foo: fooBuffer,
|
|
408
|
+
* bar: barTexture,
|
|
409
|
+
* });
|
|
410
|
+
*
|
|
411
|
+
* @param layout Layout describing the bind group to be created.
|
|
412
|
+
* @param entries A record with values being the resources populating the bind group
|
|
413
|
+
* and keys being their associated names, matching the layout keys.
|
|
414
|
+
*/
|
|
415
|
+
createBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>>(layout: TgpuBindGroupLayout<Entries>, entries: ExtractBindGroupInputFromLayout<Entries>): TgpuBindGroup<Entries>;
|
|
416
|
+
/**
|
|
417
|
+
* Retrieves a read-only list of all enabled features of the GPU device.
|
|
418
|
+
* @returns A set of strings representing the enabled features.
|
|
419
|
+
*/
|
|
420
|
+
get enabledFeatures(): ReadonlySet<GPUFeatureName>;
|
|
421
|
+
/**
|
|
422
|
+
* Destroys all underlying resources (i.e. buffers...) created through this root object.
|
|
423
|
+
* If the object is created via `tgpu.init` instead of `tgpu.initFromDevice`,
|
|
424
|
+
* then the inner GPU device is destroyed as well.
|
|
425
|
+
*/
|
|
426
|
+
destroy(): void;
|
|
427
|
+
'~unstable': Pick<ExperimentalTgpuRoot, 'createCommandEncoder' | 'createComparisonSampler' | 'createGuardedComputePipeline' | 'createRenderBundleEncoder' | 'createSampler' | 'createTexture' | 'nameRegistrySetting' | 'shaderGeneratorClass' | 'pipe' | 'with'>;
|
|
608
428
|
}
|
|
609
|
-
interface ExperimentalTgpuRoot extends Omit<TgpuRoot, 'with'>, Withable_Deprecated<WithBinding> {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
429
|
+
export interface ExperimentalTgpuRoot extends Omit<TgpuRoot, 'with'>, Withable_Deprecated<WithBinding> {
|
|
430
|
+
readonly nameRegistrySetting: 'strict' | 'random';
|
|
431
|
+
readonly minify: boolean;
|
|
432
|
+
readonly shaderGeneratorClass?: ShaderGeneratorClass | undefined;
|
|
433
|
+
/** @deprecated Use `root.createTexture` instead. */
|
|
434
|
+
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, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension>(props: CreateTextureOptions<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>): TgpuTexture<CreateTextureResult<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>>;
|
|
435
|
+
/**
|
|
436
|
+
* Creates a {@link TgpuCommandEncoder} for batching multiple render/compute
|
|
437
|
+
* passes (and draws within them) into a single submission.
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```ts
|
|
441
|
+
* const encoder = root['~unstable'].createCommandEncoder();
|
|
442
|
+
* const pass = encoder.beginRenderPass({
|
|
443
|
+
* colorAttachments: [{ view: msaaTexture, resolveTarget: context }],
|
|
444
|
+
* });
|
|
445
|
+
* scenePipeline.with(pass).draw(vertexCount);
|
|
446
|
+
* skyPipeline.with(pass).draw(3);
|
|
447
|
+
* pass.end();
|
|
448
|
+
* encoder.submit();
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
createCommandEncoder(descriptor?: GPUCommandEncoderDescriptor): TgpuCommandEncoder;
|
|
452
|
+
/**
|
|
453
|
+
* Creates a {@link TgpuRenderBundleEncoder} for recording draw commands into
|
|
454
|
+
* a {@link GPURenderBundle}. Call `finish()` on the encoder to obtain the
|
|
455
|
+
* bundle, replayable in a render pass via `pass.executeBundles`.
|
|
456
|
+
*
|
|
457
|
+
* The caller is responsible for ensuring that the `descriptor` (e.g.
|
|
458
|
+
* `colorFormats`, `depthStencilFormat`) is compatible with the render pass
|
|
459
|
+
* in which the bundle will be executed.
|
|
460
|
+
*
|
|
461
|
+
* @param descriptor - Describes the formats the bundle must be compatible with.
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* ```ts
|
|
465
|
+
* const bundleEncoder = root['~unstable'].createRenderBundleEncoder({
|
|
466
|
+
* colorFormats: ['rgba8unorm'],
|
|
467
|
+
* });
|
|
468
|
+
* scenePipeline.with(bundleEncoder).draw(vertexCount);
|
|
469
|
+
* const bundle = bundleEncoder.finish();
|
|
470
|
+
* ```
|
|
471
|
+
*/
|
|
472
|
+
createRenderBundleEncoder(descriptor: GPURenderBundleEncoderDescriptor): TgpuRenderBundleEncoder;
|
|
473
|
+
/** @deprecated Use `root.createSampler` instead. */
|
|
474
|
+
createSampler(props: WgslSamplerProps): TgpuFixedSampler;
|
|
475
|
+
/** @deprecated Use `root.createComparisonSampler` instead. */
|
|
476
|
+
createComparisonSampler(props: WgslComparisonSamplerProps): TgpuFixedComparisonSampler;
|
|
477
|
+
/** @deprecated This feature is now stable, use `root.createGuardedComputePipeline`. */
|
|
478
|
+
createGuardedComputePipeline<TArgs extends number[]>(callback: (...args: TArgs) => void): TgpuGuardedComputePipeline<TArgs>;
|
|
479
|
+
/** @deprecated This feature is now stable, use `root.pipe`. */
|
|
480
|
+
pipe(transform: (cfg: Configurable) => Configurable): WithBinding;
|
|
646
481
|
}
|
|
647
|
-
|
|
648
|
-
export { Configurable, ExperimentalTgpuRoot, TgpuGuardedComputePipeline, TgpuRoot, ValidateBufferSchema, ValidateStorageSchema, ValidateUniformSchema, WithBinding, WithCompute, WithFragment, WithVertex, Withable };
|
|
482
|
+
export {};
|