typegpu 0.10.2 → 0.11.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/_virtual/_rolldown/runtime.js +6 -11
- package/builtin.js +1 -3
- package/common/fullScreenTriangle.d.ts +1 -5
- package/common/fullScreenTriangle.js +1 -3
- package/common/index.d.ts +3 -2
- package/common/index.js +6 -4
- package/common/writeSoA.d.ts +16 -0
- package/common/writeSoA.js +90 -0
- package/core/buffer/buffer.d.ts +12 -7
- package/core/buffer/buffer.js +102 -53
- package/core/buffer/bufferShorthand.d.ts +5 -5
- package/core/buffer/bufferShorthand.js +9 -5
- package/core/buffer/bufferUsage.d.ts +0 -2
- package/core/buffer/bufferUsage.js +6 -4
- package/core/constant/tgpuConstant.d.ts +2 -1
- package/core/constant/tgpuConstant.js +8 -7
- package/core/declare/tgpuDeclare.js +8 -9
- package/core/function/autoIO.d.ts +7 -6
- package/core/function/autoIO.js +1 -3
- package/core/function/comptime.js +1 -3
- package/core/function/createCallableSchema.js +4 -6
- package/core/function/dualImpl.js +1 -3
- package/core/function/entryInputRouter.js +39 -0
- package/core/function/extractArgs.js +2 -2
- package/core/function/fnCore.js +19 -8
- package/core/function/fnTypes.d.ts +14 -8
- package/core/function/ioSchema.js +24 -3
- package/core/function/shelllessImpl.js +1 -3
- package/core/function/templateUtils.js +1 -2
- package/core/function/tgpuComputeFn.d.ts +2 -3
- package/core/function/tgpuComputeFn.js +9 -16
- package/core/function/tgpuFn.d.ts +2 -2
- package/core/function/tgpuFn.js +1 -3
- package/core/function/tgpuFragmentFn.d.ts +5 -1
- package/core/function/tgpuFragmentFn.js +5 -10
- package/core/function/tgpuVertexFn.d.ts +4 -0
- package/core/function/tgpuVertexFn.js +6 -12
- package/core/pipeline/applyPipelineState.js +1 -3
- package/core/pipeline/computePipeline.d.ts +2 -6
- package/core/pipeline/computePipeline.js +64 -63
- package/core/pipeline/connectAttachmentToShader.js +1 -3
- package/core/pipeline/connectTargetsToShader.js +1 -3
- package/core/pipeline/limitsOverflow.js +1 -2
- package/core/pipeline/pipelineUtils.js +29 -0
- package/core/pipeline/renderPipeline.d.ts +23 -5
- package/core/pipeline/renderPipeline.js +32 -14
- package/core/pipeline/timeable.d.ts +0 -3
- package/core/pipeline/timeable.js +3 -9
- package/core/pipeline/typeGuards.js +1 -3
- package/core/querySet/querySet.d.ts +0 -2
- package/core/querySet/querySet.js +37 -36
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +1 -3
- package/core/resolve/externals.d.ts +0 -2
- package/core/resolve/externals.js +2 -4
- package/core/resolve/namespace.js +1 -3
- package/core/resolve/resolveData.js +1 -3
- package/core/resolve/stitch.js +1 -3
- package/core/resolve/tgpuResolve.d.ts +3 -1
- package/core/resolve/tgpuResolve.js +3 -5
- package/core/root/configurableImpl.js +2 -3
- package/core/root/init.d.ts +0 -5
- package/core/root/init.js +35 -28
- package/core/root/rootTypes.d.ts +25 -5
- package/core/sampler/sampler.d.ts +0 -4
- package/core/sampler/sampler.js +3 -3
- package/core/simulate/tgpuSimulate.js +1 -3
- package/core/slot/accessor.d.ts +0 -4
- package/core/slot/accessor.js +1 -3
- package/core/slot/internalSlots.js +1 -3
- package/core/slot/lazy.js +1 -3
- package/core/slot/slot.js +2 -3
- package/core/slot/slotTypes.js +1 -3
- package/core/texture/externalTexture.d.ts +0 -6
- package/core/texture/externalTexture.js +2 -3
- package/core/texture/texture.d.ts +0 -4
- package/core/texture/texture.js +5 -3
- package/core/texture/textureFormats.js +1 -3
- package/core/texture/textureUtils.js +1 -3
- package/core/texture/usageExtension.js +1 -3
- package/core/unroll/tgpuUnroll.d.ts +58 -3
- package/core/unroll/tgpuUnroll.js +63 -5
- package/core/valueProxyUtils.js +1 -3
- package/core/variable/tgpuVariable.js +1 -3
- package/core/vertexLayout/connectAttributesToShader.js +1 -3
- package/core/vertexLayout/vertexLayout.js +9 -9
- package/data/alignIO.js +1 -2
- package/data/alignmentOf.d.ts +0 -1
- package/data/alignmentOf.js +1 -3
- package/data/array.d.ts +1 -3
- package/data/array.js +2 -4
- package/data/atomic.js +2 -3
- package/data/attributes.js +3 -3
- package/data/autoStruct.d.ts +1 -3
- package/data/autoStruct.js +1 -3
- package/data/compiledIO.js +83 -86
- package/data/dataIO.js +46 -39
- package/data/dataTypes.d.ts +7 -7
- package/data/dataTypes.js +6 -3
- package/data/deepEqual.js +1 -3
- package/data/disarray.d.ts +1 -3
- package/data/disarray.js +1 -3
- package/data/getLongestContiguousPrefix.d.ts +0 -1
- package/data/getLongestContiguousPrefix.js +1 -3
- package/data/index.d.ts +3 -3
- package/data/index.js +10 -3
- package/data/isContiguous.d.ts +0 -1
- package/data/isContiguous.js +1 -3
- package/data/matrix.d.ts +8 -10
- package/data/matrix.js +32 -18
- package/data/numberOps.js +1 -2
- package/data/numeric.js +16 -29
- package/data/offsetUtils.d.ts +2 -2
- package/data/offsetUtils.js +3 -5
- package/data/offsets.js +1 -3
- package/data/partialIO.js +84 -39
- package/data/ptr.d.ts +0 -1
- package/data/ptr.js +1 -3
- package/data/ref.d.ts +0 -3
- package/data/ref.js +1 -3
- package/data/sampler.js +1 -3
- package/data/schemaCallWrapper.js +1 -3
- package/data/schemaMemoryLayout.js +1 -3
- package/data/sizeOf.d.ts +0 -1
- package/data/sizeOf.js +1 -3
- package/data/snippet.js +12 -3
- package/data/struct.js +1 -3
- package/data/texture.js +1 -3
- package/data/unstruct.js +1 -3
- package/data/vector.js +4 -12
- package/data/vectorImpl.js +27 -28
- package/data/vectorOps.js +20 -3
- package/data/vertexFormatData.js +2 -3
- package/data/wgslTypes.d.ts +39 -11
- package/data/wgslTypes.js +10 -3
- package/errors.js +6 -3
- package/execMode.js +1 -3
- package/extension.js +1 -3
- package/getGPUValue.js +1 -3
- package/index.d.ts +4 -2
- package/index.js +3 -3
- package/indexNamedExports.d.ts +3 -1
- package/mathUtils.js +1 -2
- package/memo.js +8 -8
- package/nameRegistry.js +1 -3
- package/package.js +2 -3
- package/package.json +7 -7
- package/resolutionCtx.d.ts +0 -10
- package/resolutionCtx.js +84 -18
- package/shared/env.js +1 -2
- package/shared/generators.js +1 -2
- package/shared/meta.js +1 -3
- package/shared/repr.d.ts +32 -2
- package/shared/stringify.js +1 -3
- package/shared/symbols.d.ts +10 -1
- package/shared/symbols.js +10 -33
- package/shared/utilityTypes.d.ts +6 -2
- package/shared/utilityTypes.js +1 -2
- package/shared/vertexFormat.js +1 -2
- package/std/array.d.ts +1 -1
- package/std/array.js +1 -3
- package/std/atomic.d.ts +12 -12
- package/std/atomic.js +1 -3
- package/std/bitcast.d.ts +2 -2
- package/std/bitcast.js +1 -3
- package/std/boolean.d.ts +30 -16
- package/std/boolean.js +37 -12
- package/std/derivative.d.ts +9 -9
- package/std/derivative.js +1 -3
- package/std/discard.d.ts +1 -1
- package/std/discard.js +1 -3
- package/std/extensions.d.ts +1 -3
- package/std/extensions.js +1 -3
- package/std/index.d.ts +5 -4
- package/std/index.js +8 -5
- package/std/matrix.d.ts +5 -5
- package/std/matrix.js +1 -3
- package/std/numeric.d.ts +78 -132
- package/std/numeric.js +1 -3
- package/std/operators.d.ts +16 -8
- package/std/operators.js +80 -6
- package/std/packing.d.ts +4 -4
- package/std/packing.js +1 -3
- package/std/range.d.ts +24 -0
- package/std/range.js +38 -0
- package/std/subgroup.d.ts +21 -21
- package/std/subgroup.js +1 -3
- package/std/texture.d.ts +20 -11
- package/std/texture.js +13 -3
- package/tgpu.js +1 -3
- package/tgpuBindGroupLayout.js +9 -8
- package/tgpuUnstable.js +1 -3
- package/tgsl/accessIndex.js +2 -4
- package/tgsl/accessProp.js +8 -6
- package/tgsl/consoleLog/deserializers.js +1 -3
- package/tgsl/consoleLog/logGenerator.js +2 -4
- package/tgsl/consoleLog/serializers.js +24 -26
- package/tgsl/consoleLog/types.d.ts +0 -2
- package/tgsl/consoleLog/types.js +1 -2
- package/tgsl/conversion.js +1 -3
- package/tgsl/forOfUtils.js +35 -9
- package/tgsl/generationHelpers.js +3 -3
- package/tgsl/math.js +1 -3
- package/tgsl/shaderGenerator.d.ts +10 -8
- package/tgsl/shaderGenerator_members.d.ts +2 -0
- package/tgsl/shaderGenerator_members.js +6 -0
- package/tgsl/shellless.js +1 -8
- package/tgsl/wgslGenerator.d.ts +36 -0
- package/tgsl/wgslGenerator.js +144 -81
- package/types.d.ts +14 -4
- package/types.js +3 -3
- package/wgslExtensions.js +1 -2
package/core/sampler/sampler.js
CHANGED
|
@@ -4,7 +4,6 @@ import { snip } from "../../data/snippet.js";
|
|
|
4
4
|
import { inCodegenMode } from "../../execMode.js";
|
|
5
5
|
import { valueProxyHandler } from "../valueProxyUtils.js";
|
|
6
6
|
import { comparisonSampler, sampler } from "../../data/sampler.js";
|
|
7
|
-
|
|
8
7
|
//#region src/core/sampler/sampler.ts
|
|
9
8
|
function INTERNAL_createSampler(props, branch) {
|
|
10
9
|
return new TgpuFixedSamplerImpl(sampler(), props, branch);
|
|
@@ -23,6 +22,7 @@ function isComparisonSampler(resource) {
|
|
|
23
22
|
var TgpuLaidOutSamplerImpl = class {
|
|
24
23
|
[$internal] = { unwrap: void 0 };
|
|
25
24
|
resourceType;
|
|
25
|
+
schema;
|
|
26
26
|
#membership;
|
|
27
27
|
constructor(schema, membership) {
|
|
28
28
|
this.schema = schema;
|
|
@@ -61,6 +61,7 @@ var TgpuLaidOutSamplerImpl = class {
|
|
|
61
61
|
var TgpuFixedSamplerImpl = class {
|
|
62
62
|
[$internal];
|
|
63
63
|
resourceType;
|
|
64
|
+
schema;
|
|
64
65
|
#filtering;
|
|
65
66
|
#sampler = null;
|
|
66
67
|
#props;
|
|
@@ -111,6 +112,5 @@ var TgpuFixedSamplerImpl = class {
|
|
|
111
112
|
return `${this.resourceType}:${getName(this) ?? "<unnamed>"}`;
|
|
112
113
|
}
|
|
113
114
|
};
|
|
114
|
-
|
|
115
115
|
//#endregion
|
|
116
|
-
export { INTERNAL_createComparisonSampler, INTERNAL_createSampler, TgpuLaidOutSamplerImpl, isComparisonSampler, isSampler };
|
|
116
|
+
export { INTERNAL_createComparisonSampler, INTERNAL_createSampler, TgpuLaidOutSamplerImpl, isComparisonSampler, isSampler };
|
|
@@ -3,7 +3,6 @@ import { getResolutionCtx, provideCtx } from "../../execMode.js";
|
|
|
3
3
|
import { namespace } from "../resolve/namespace.js";
|
|
4
4
|
import wgslGenerator from "../../tgsl/wgslGenerator.js";
|
|
5
5
|
import { ResolutionCtxImpl } from "../../resolutionCtx.js";
|
|
6
|
-
|
|
7
6
|
//#region src/core/simulate/tgpuSimulate.ts
|
|
8
7
|
/**
|
|
9
8
|
* Runs the provided callback in a simulated environment, giving
|
|
@@ -71,6 +70,5 @@ function simulate(callback) {
|
|
|
71
70
|
ctx.popMode("simulate");
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
|
-
|
|
75
73
|
//#endregion
|
|
76
|
-
export { simulate };
|
|
74
|
+
export { simulate };
|
package/core/slot/accessor.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import "../../data/snippet.js";
|
|
2
1
|
import { TgpuAccessor, TgpuMutableAccessor } from "./slotTypes.js";
|
|
3
2
|
import { UnwrapRuntimeConstructor } from "../../tgpuBindGroupLayout.js";
|
|
4
|
-
import "../../types.js";
|
|
5
|
-
import "../../data/wgslTypes.js";
|
|
6
|
-
import "../../shared/repr.js";
|
|
7
3
|
import { AnyData } from "../../data/dataTypes.js";
|
|
8
4
|
|
|
9
5
|
//#region src/core/slot/accessor.d.ts
|
package/core/slot/accessor.js
CHANGED
|
@@ -8,7 +8,6 @@ import { schemaCallWrapper } from "../../data/schemaCallWrapper.js";
|
|
|
8
8
|
import { getGpuValueRecursively, valueProxyHandler } from "../valueProxyUtils.js";
|
|
9
9
|
import { isTgpuFn } from "../function/tgpuFn.js";
|
|
10
10
|
import { slot } from "./slot.js";
|
|
11
|
-
|
|
12
11
|
//#region src/core/slot/accessor.ts
|
|
13
12
|
function accessor(schemaOrConstructor, defaultValue) {
|
|
14
13
|
return new TgpuAccessorImpl(schemaOrConstructor, defaultValue);
|
|
@@ -92,6 +91,5 @@ var TgpuMutableAccessorImpl = class extends AccessorBase {
|
|
|
92
91
|
throw new Error("`tgpu.mutableAccessor` relies on GPU resources and cannot be accessed outside of a compute dispatch or draw call");
|
|
93
92
|
}
|
|
94
93
|
};
|
|
95
|
-
|
|
96
94
|
//#endregion
|
|
97
|
-
export { accessor, mutableAccessor };
|
|
95
|
+
export { accessor, mutableAccessor };
|
package/core/slot/lazy.js
CHANGED
|
@@ -2,7 +2,6 @@ import { $gpuValueOf, $internal, $providing } from "../../shared/symbols.js";
|
|
|
2
2
|
import { isAccessor, isMutableAccessor } from "./slotTypes.js";
|
|
3
3
|
import { getResolutionCtx } from "../../execMode.js";
|
|
4
4
|
import { getGpuValueRecursively } from "../valueProxyUtils.js";
|
|
5
|
-
|
|
6
5
|
//#region src/core/slot/lazy.ts
|
|
7
6
|
function lazy(compute) {
|
|
8
7
|
if (getResolutionCtx()) throw new Error("Cannot create tgpu.lazy objects during shader resolution.");
|
|
@@ -37,6 +36,5 @@ var TgpuLazyImpl = class TgpuLazyImpl {
|
|
|
37
36
|
}
|
|
38
37
|
};
|
|
39
38
|
TgpuLazyImpl.prototype.resourceType = "lazy";
|
|
40
|
-
|
|
41
39
|
//#endregion
|
|
42
|
-
export { lazy };
|
|
40
|
+
export { lazy };
|
package/core/slot/slot.js
CHANGED
|
@@ -2,7 +2,6 @@ import { $gpuValueOf, $internal } from "../../shared/symbols.js";
|
|
|
2
2
|
import { getName, setName } from "../../shared/meta.js";
|
|
3
3
|
import { getResolutionCtx } from "../../execMode.js";
|
|
4
4
|
import { getGpuValueRecursively } from "../valueProxyUtils.js";
|
|
5
|
-
|
|
6
5
|
//#region src/core/slot/slot.ts
|
|
7
6
|
function slot(defaultValue) {
|
|
8
7
|
return new TgpuSlotImpl(defaultValue);
|
|
@@ -10,6 +9,7 @@ function slot(defaultValue) {
|
|
|
10
9
|
var TgpuSlotImpl = class {
|
|
11
10
|
[$internal] = true;
|
|
12
11
|
resourceType = "slot";
|
|
12
|
+
defaultValue;
|
|
13
13
|
constructor(defaultValue = void 0) {
|
|
14
14
|
this.defaultValue = defaultValue;
|
|
15
15
|
}
|
|
@@ -35,6 +35,5 @@ var TgpuSlotImpl = class {
|
|
|
35
35
|
return this.value;
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
|
|
39
38
|
//#endregion
|
|
40
|
-
export { slot };
|
|
39
|
+
export { slot };
|
package/core/slot/slotTypes.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { $providing } from "../../shared/symbols.js";
|
|
2
|
-
|
|
3
2
|
//#region src/core/slot/slotTypes.ts
|
|
4
3
|
function isSlot(value) {
|
|
5
4
|
return value?.resourceType === "slot";
|
|
@@ -16,6 +15,5 @@ function isAccessor(value) {
|
|
|
16
15
|
function isMutableAccessor(value) {
|
|
17
16
|
return value?.resourceType === "mutable-accessor";
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
//#endregion
|
|
21
|
-
export { isAccessor, isLazy, isMutableAccessor, isProviding, isSlot };
|
|
19
|
+
export { isAccessor, isLazy, isMutableAccessor, isProviding, isSlot };
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import "../../data/snippet.js";
|
|
2
|
-
import "../../tgpuBindGroupLayout.js";
|
|
3
|
-
import "../../types.js";
|
|
4
|
-
import "../../data/texture.js";
|
|
5
|
-
import "../../shared/repr.js";
|
|
6
|
-
|
|
7
1
|
//#region src/core/texture/externalTexture.d.ts
|
|
8
2
|
interface TgpuExternalTexture {
|
|
9
3
|
readonly resourceType: 'external-texture';
|
|
@@ -4,11 +4,11 @@ import { snip } from "../../data/snippet.js";
|
|
|
4
4
|
import { inCodegenMode } from "../../execMode.js";
|
|
5
5
|
import { valueProxyHandler } from "../valueProxyUtils.js";
|
|
6
6
|
import { textureExternal } from "../../data/texture.js";
|
|
7
|
-
|
|
8
7
|
//#region src/core/texture/externalTexture.ts
|
|
9
8
|
var TgpuExternalTextureImpl = class {
|
|
10
9
|
resourceType = "external-texture";
|
|
11
10
|
[$internal] = true;
|
|
11
|
+
schema;
|
|
12
12
|
#membership;
|
|
13
13
|
constructor(schema, membership) {
|
|
14
14
|
this.schema = schema;
|
|
@@ -43,6 +43,5 @@ var TgpuExternalTextureImpl = class {
|
|
|
43
43
|
return `textureExternal:${getName(this) ?? "<unnamed>"}`;
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
-
|
|
47
46
|
//#endregion
|
|
48
|
-
export { TgpuExternalTextureImpl };
|
|
47
|
+
export { TgpuExternalTextureImpl };
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { TgpuNamable } from "../../shared/meta.js";
|
|
2
2
|
import { $gpuValueOf, $internal } from "../../shared/symbols.js";
|
|
3
3
|
import { Default, TypedArray, UnionToIntersection } from "../../shared/utilityTypes.js";
|
|
4
|
-
import "../../data/snippet.js";
|
|
5
4
|
import { TextureProps } from "./textureProps.js";
|
|
6
5
|
import { AllowedUsages, LiteralToExtensionMap } from "./usageExtension.js";
|
|
7
|
-
import "../../tgpuBindGroupLayout.js";
|
|
8
|
-
import "../root/rootTypes.js";
|
|
9
|
-
import "../../types.js";
|
|
10
6
|
import { F32 } from "../../data/wgslTypes.js";
|
|
11
7
|
import { TextureFormats, ViewDimensionToDimension } from "./textureFormats.js";
|
|
12
8
|
import { TextureSchemaForDescriptor, WgslStorageTexture, WgslTexture } from "../../data/texture.js";
|
package/core/texture/texture.js
CHANGED
|
@@ -6,7 +6,6 @@ import { valueProxyHandler } from "../valueProxyUtils.js";
|
|
|
6
6
|
import { isWgslStorageTexture, textureDescriptorToSchema } from "../../data/texture.js";
|
|
7
7
|
import { getTextureFormatInfo } from "./textureFormats.js";
|
|
8
8
|
import { generateTextureMipmaps, getImageSourceDimensions, resampleImage } from "./textureUtils.js";
|
|
9
|
-
|
|
10
9
|
//#region src/core/texture/texture.ts
|
|
11
10
|
function getDescriptorForProps(props) {
|
|
12
11
|
return {
|
|
@@ -27,6 +26,7 @@ function isTextureView(value) {
|
|
|
27
26
|
var TgpuTextureImpl = class {
|
|
28
27
|
[$internal];
|
|
29
28
|
resourceType = "texture";
|
|
29
|
+
props;
|
|
30
30
|
usableAsSampled = false;
|
|
31
31
|
usableAsStorage = false;
|
|
32
32
|
usableAsRender = false;
|
|
@@ -193,6 +193,7 @@ var TgpuTextureImpl = class {
|
|
|
193
193
|
var TgpuFixedTextureViewImpl = class {
|
|
194
194
|
[$internal];
|
|
195
195
|
resourceType = "texture-view";
|
|
196
|
+
schema;
|
|
196
197
|
#baseTexture;
|
|
197
198
|
#view;
|
|
198
199
|
#descriptor;
|
|
@@ -257,6 +258,7 @@ var TgpuLaidOutTextureViewImpl = class {
|
|
|
257
258
|
[$internal] = { unwrap: void 0 };
|
|
258
259
|
resourceType = "texture-view";
|
|
259
260
|
#membership;
|
|
261
|
+
schema;
|
|
260
262
|
constructor(schema, membership) {
|
|
261
263
|
this.schema = schema;
|
|
262
264
|
this.#membership = membership;
|
|
@@ -297,6 +299,7 @@ var TgpuLaidOutTextureViewImpl = class {
|
|
|
297
299
|
var TgpuTextureRenderViewImpl = class {
|
|
298
300
|
[$internal];
|
|
299
301
|
resourceType = "texture-view";
|
|
302
|
+
descriptor;
|
|
300
303
|
constructor(baseTexture, descriptor = {}) {
|
|
301
304
|
this.descriptor = descriptor;
|
|
302
305
|
this[$internal] = { unwrap: () => {
|
|
@@ -307,6 +310,5 @@ var TgpuTextureRenderViewImpl = class {
|
|
|
307
310
|
} };
|
|
308
311
|
}
|
|
309
312
|
};
|
|
310
|
-
|
|
311
313
|
//#endregion
|
|
312
|
-
export { INTERNAL_createTexture, TgpuLaidOutTextureViewImpl, isTexture, isTextureView };
|
|
314
|
+
export { INTERNAL_createTexture, TgpuLaidOutTextureViewImpl, isTexture, isTextureView };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { f32, i32, u32 } from "../../data/numeric.js";
|
|
2
2
|
import { vec4f, vec4i, vec4u } from "../../data/vector.js";
|
|
3
|
-
|
|
4
3
|
//#region src/core/texture/textureFormats.ts
|
|
5
4
|
const DEPTH_ASPECT_NON_COPYABLE = {
|
|
6
5
|
channelType: f32,
|
|
@@ -94,6 +93,5 @@ function getEffectiveSampleTypes(device, format) {
|
|
|
94
93
|
if (FLOAT32_FORMATS.has(format) && !device.features.has("float32-filterable")) return ["unfilterable-float"];
|
|
95
94
|
return getTextureFormatInfo(format).sampleTypes;
|
|
96
95
|
}
|
|
97
|
-
|
|
98
96
|
//#endregion
|
|
99
|
-
export { getEffectiveSampleTypes, getTextureFormatInfo };
|
|
97
|
+
export { getEffectiveSampleTypes, getTextureFormatInfo };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getEffectiveSampleTypes, getTextureFormatInfo } from "./textureFormats.js";
|
|
2
|
-
|
|
3
2
|
//#region src/core/texture/textureUtils.ts
|
|
4
3
|
function getImageSourceDimensions(source) {
|
|
5
4
|
const { videoWidth, videoHeight } = source;
|
|
@@ -219,6 +218,5 @@ function resampleImage(device, targetTexture, image, layer = 0) {
|
|
|
219
218
|
inputTexture.destroy();
|
|
220
219
|
renderTexture.destroy();
|
|
221
220
|
}
|
|
222
|
-
|
|
223
221
|
//#endregion
|
|
224
|
-
export { clearTextureUtilsCache, generateTextureMipmaps, getImageSourceDimensions, resampleImage };
|
|
222
|
+
export { clearTextureUtilsCache, generateTextureMipmaps, getImageSourceDimensions, resampleImage };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getName } from "../../shared/meta.js";
|
|
2
|
-
|
|
3
2
|
//#region src/core/texture/usageExtension.ts
|
|
4
3
|
function isUsableAsSampled(value) {
|
|
5
4
|
return !!value?.usableAsSampled;
|
|
@@ -16,6 +15,5 @@ var NotSampledError = class NotSampledError extends Error {
|
|
|
16
15
|
Object.setPrototypeOf(this, NotSampledError.prototype);
|
|
17
16
|
}
|
|
18
17
|
};
|
|
19
|
-
|
|
20
18
|
//#endregion
|
|
21
|
-
export { NotSampledError, isUsableAsRender, isUsableAsSampled };
|
|
19
|
+
export { NotSampledError, isUsableAsRender, isUsableAsSampled };
|
|
@@ -1,12 +1,67 @@
|
|
|
1
1
|
import { $internal } from "../../shared/symbols.js";
|
|
2
|
-
import "../../data/snippet.js";
|
|
3
2
|
import { GPUCallable } from "../../types.js";
|
|
4
3
|
|
|
5
4
|
//#region src/core/unroll/tgpuUnroll.d.ts
|
|
6
5
|
/**
|
|
7
|
-
* Marks an iterable to be unrolled by the
|
|
6
|
+
* Marks an iterable to be unrolled by the shader generator when used in a for loop.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const neighborOffsets = [d.vec2i(0, 1), d.vec2i(0, -1), d.vec2i(1, 0), d.vec2i(-1, 0)];
|
|
11
|
+
*
|
|
12
|
+
* // Unrolls into 4 blocks of code, one for each offset.
|
|
13
|
+
* for (const offset of tgpu.unroll(neighborOffsets)) {
|
|
14
|
+
* // ...
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* If you'd like to unroll over a range of numbers, use `tgpu.unroll(std.range(n))`.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* // (...)
|
|
23
|
+
* const FBM_OCTAVES = 3;
|
|
24
|
+
*
|
|
25
|
+
* function fbm(pos: d.v3f): number {
|
|
26
|
+
* 'use gpu';
|
|
27
|
+
* let sum = d.f32();
|
|
28
|
+
*
|
|
29
|
+
* // i = 0, 1, 2
|
|
30
|
+
* for (const i of tgpu.unroll(std.range(FBM_OCTAVES))) {
|
|
31
|
+
* sum +=
|
|
32
|
+
* noise3d(pos * (CLOUD_FREQUENCY * FBM_LACUNARITY ** i)) *
|
|
33
|
+
* (CLOUD_AMPLITUDE * FBM_PERSISTENCE ** i);
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* return sum;
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Generates:
|
|
42
|
+
*
|
|
43
|
+
* ```wgsl
|
|
44
|
+
* // (...)
|
|
45
|
+
*
|
|
46
|
+
* fn fbm(pos: vec3f) -> f32 {
|
|
47
|
+
* var sum = 0f;
|
|
48
|
+
* // unrolled iteration #0
|
|
49
|
+
* {
|
|
50
|
+
* sum += noise3d(pos * 1.4f) * 1f;
|
|
51
|
+
* }
|
|
52
|
+
* // unrolled iteration #1
|
|
53
|
+
* {
|
|
54
|
+
* sum += noise3d(pos * 2.8f) * 0.5f;
|
|
55
|
+
* }
|
|
56
|
+
* // unrolled iteration #2
|
|
57
|
+
* {
|
|
58
|
+
* sum += noise3d(pos * 5.6f) * 0.25f;
|
|
59
|
+
* }
|
|
60
|
+
* return sum;
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
8
63
|
*/
|
|
9
|
-
declare const unroll: (<T extends Iterable<unknown>>(
|
|
64
|
+
declare const unroll: (<T extends Iterable<unknown>>(iterable: T) => T) & GPUCallable & {
|
|
10
65
|
[$internal]: true;
|
|
11
66
|
};
|
|
12
67
|
//#endregion
|
|
@@ -2,7 +2,6 @@ import { $gpuCallable, $internal, $resolve } from "../../shared/symbols.js";
|
|
|
2
2
|
import { setName } from "../../shared/meta.js";
|
|
3
3
|
import { snip } from "../../data/snippet.js";
|
|
4
4
|
import { stitch } from "../resolve/stitch.js";
|
|
5
|
-
|
|
6
5
|
//#region src/core/unroll/tgpuUnroll.ts
|
|
7
6
|
/**
|
|
8
7
|
* The result of calling `tgpu.unroll(...)`. The code responsible for
|
|
@@ -11,6 +10,7 @@ import { stitch } from "../resolve/stitch.js";
|
|
|
11
10
|
*/
|
|
12
11
|
var UnrollableIterable = class {
|
|
13
12
|
[$internal] = true;
|
|
13
|
+
snippet;
|
|
14
14
|
constructor(snippet) {
|
|
15
15
|
this.snippet = snippet;
|
|
16
16
|
}
|
|
@@ -19,10 +19,69 @@ var UnrollableIterable = class {
|
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
|
-
* Marks an iterable to be unrolled by the
|
|
22
|
+
* Marks an iterable to be unrolled by the shader generator when used in a for loop.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const neighborOffsets = [d.vec2i(0, 1), d.vec2i(0, -1), d.vec2i(1, 0), d.vec2i(-1, 0)];
|
|
27
|
+
*
|
|
28
|
+
* // Unrolls into 4 blocks of code, one for each offset.
|
|
29
|
+
* for (const offset of tgpu.unroll(neighborOffsets)) {
|
|
30
|
+
* // ...
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* If you'd like to unroll over a range of numbers, use `tgpu.unroll(std.range(n))`.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* // (...)
|
|
39
|
+
* const FBM_OCTAVES = 3;
|
|
40
|
+
*
|
|
41
|
+
* function fbm(pos: d.v3f): number {
|
|
42
|
+
* 'use gpu';
|
|
43
|
+
* let sum = d.f32();
|
|
44
|
+
*
|
|
45
|
+
* // i = 0, 1, 2
|
|
46
|
+
* for (const i of tgpu.unroll(std.range(FBM_OCTAVES))) {
|
|
47
|
+
* sum +=
|
|
48
|
+
* noise3d(pos * (CLOUD_FREQUENCY * FBM_LACUNARITY ** i)) *
|
|
49
|
+
* (CLOUD_AMPLITUDE * FBM_PERSISTENCE ** i);
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* return sum;
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* Generates:
|
|
58
|
+
*
|
|
59
|
+
* ```wgsl
|
|
60
|
+
* // (...)
|
|
61
|
+
*
|
|
62
|
+
* fn fbm(pos: vec3f) -> f32 {
|
|
63
|
+
* var sum = 0f;
|
|
64
|
+
* // unrolled iteration #0
|
|
65
|
+
* {
|
|
66
|
+
* sum += noise3d(pos * 1.4f) * 1f;
|
|
67
|
+
* }
|
|
68
|
+
* // unrolled iteration #1
|
|
69
|
+
* {
|
|
70
|
+
* sum += noise3d(pos * 2.8f) * 0.5f;
|
|
71
|
+
* }
|
|
72
|
+
* // unrolled iteration #2
|
|
73
|
+
* {
|
|
74
|
+
* sum += noise3d(pos * 5.6f) * 0.25f;
|
|
75
|
+
* }
|
|
76
|
+
* return sum;
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
23
79
|
*/
|
|
24
80
|
const unroll = (() => {
|
|
25
|
-
|
|
81
|
+
function jsImpl(iterable) {
|
|
82
|
+
return iterable;
|
|
83
|
+
}
|
|
84
|
+
const impl = jsImpl;
|
|
26
85
|
setName(impl, "unroll");
|
|
27
86
|
impl.toString = () => "unroll";
|
|
28
87
|
impl[$internal] = true;
|
|
@@ -31,6 +90,5 @@ const unroll = (() => {
|
|
|
31
90
|
} };
|
|
32
91
|
return impl;
|
|
33
92
|
})();
|
|
34
|
-
|
|
35
93
|
//#endregion
|
|
36
|
-
export { UnrollableIterable, unroll };
|
|
94
|
+
export { UnrollableIterable, unroll };
|
package/core/valueProxyUtils.js
CHANGED
|
@@ -3,7 +3,6 @@ import { getOwnSnippet } from "../types.js";
|
|
|
3
3
|
import { getGPUValue } from "../getGPUValue.js";
|
|
4
4
|
import { accessProp } from "../tgsl/accessProp.js";
|
|
5
5
|
import { accessIndex } from "../tgsl/accessIndex.js";
|
|
6
|
-
|
|
7
6
|
//#region src/core/valueProxyUtils.ts
|
|
8
7
|
const valueProxyHandler = { get(target, prop) {
|
|
9
8
|
if (prop in target) return Reflect.get(target, prop);
|
|
@@ -39,6 +38,5 @@ function getGpuValueRecursively(value) {
|
|
|
39
38
|
}
|
|
40
39
|
return unwrapped;
|
|
41
40
|
}
|
|
42
|
-
|
|
43
41
|
//#endregion
|
|
44
|
-
export { getGpuValueRecursively, valueProxyHandler };
|
|
42
|
+
export { getGpuValueRecursively, valueProxyHandler };
|
|
@@ -6,7 +6,6 @@ import { IllegalVarAccessError } from "../../errors.js";
|
|
|
6
6
|
import { getExecMode, isInsideTgpuFn } from "../../execMode.js";
|
|
7
7
|
import { assertExhaustive } from "../../shared/utilityTypes.js";
|
|
8
8
|
import { valueProxyHandler } from "../valueProxyUtils.js";
|
|
9
|
-
|
|
10
9
|
//#region src/core/variable/tgpuVariable.ts
|
|
11
10
|
/**
|
|
12
11
|
* Defines a variable scoped to each entry function (private).
|
|
@@ -96,6 +95,5 @@ var TgpuVarImpl = class {
|
|
|
96
95
|
this.$ = v;
|
|
97
96
|
}
|
|
98
97
|
};
|
|
99
|
-
|
|
100
98
|
//#endregion
|
|
101
|
-
export { isVariable, privateVar, workgroupVar };
|
|
99
|
+
export { isVariable, privateVar, workgroupVar };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getCustomLocation, isData } from "../../data/dataTypes.js";
|
|
2
2
|
import { isBuiltin } from "../../data/attributes.js";
|
|
3
|
-
|
|
4
3
|
//#region src/core/vertexLayout/connectAttributesToShader.ts
|
|
5
4
|
function isAttribute(value) {
|
|
6
5
|
return typeof value?.format === "string";
|
|
@@ -54,6 +53,5 @@ function connectAttributesToShader(shaderInputLayout, attributes) {
|
|
|
54
53
|
bufferDefinitions
|
|
55
54
|
};
|
|
56
55
|
}
|
|
57
|
-
|
|
58
56
|
//#endregion
|
|
59
|
-
export { connectAttributesToShader, isAttribute };
|
|
57
|
+
export { connectAttributesToShader, isAttribute };
|
|
@@ -6,7 +6,6 @@ import { getCustomLocation, isLooseDecorated, isUnstruct } from "../../data/data
|
|
|
6
6
|
import { alignmentOf, customAlignmentOf } from "../../data/alignmentOf.js";
|
|
7
7
|
import { roundUp } from "../../mathUtils.js";
|
|
8
8
|
import { sizeOf } from "../../data/sizeOf.js";
|
|
9
|
-
|
|
10
9
|
//#region src/core/vertexLayout/vertexLayout.ts
|
|
11
10
|
function vertexLayout(schemaForCount, stepMode = "vertex") {
|
|
12
11
|
return new TgpuVertexLayoutImpl(schemaForCount, stepMode);
|
|
@@ -61,16 +60,18 @@ var TgpuVertexLayoutImpl = class {
|
|
|
61
60
|
resourceType = "vertex-layout";
|
|
62
61
|
stride;
|
|
63
62
|
attrib;
|
|
64
|
-
|
|
63
|
+
schemaForCount;
|
|
64
|
+
stepMode;
|
|
65
|
+
#customLocationMap = {};
|
|
65
66
|
constructor(schemaForCount, stepMode) {
|
|
66
67
|
this.schemaForCount = schemaForCount;
|
|
67
68
|
this.stepMode = stepMode;
|
|
68
69
|
const arraySchema = schemaForCount(0);
|
|
69
70
|
this.stride = roundUp(sizeOf(arraySchema.elementType), alignmentOf(arraySchema));
|
|
70
|
-
this.attrib = dataToContainedAttribs(this, arraySchema.elementType, 0, this
|
|
71
|
+
this.attrib = dataToContainedAttribs(this, arraySchema.elementType, 0, this.#customLocationMap);
|
|
71
72
|
}
|
|
72
73
|
get vertexLayout() {
|
|
73
|
-
if (this
|
|
74
|
+
if (this.#customLocationMap[defaultAttribEntry] !== void 0) {
|
|
74
75
|
if (typeof this.attrib.format !== "string" || typeof this.attrib.offset !== "number") throw new Error("Single attribute vertex layouts must have a format and offset.");
|
|
75
76
|
return {
|
|
76
77
|
arrayStride: this.stride,
|
|
@@ -78,18 +79,18 @@ var TgpuVertexLayoutImpl = class {
|
|
|
78
79
|
attributes: [{
|
|
79
80
|
format: this.attrib.format,
|
|
80
81
|
offset: this.attrib.offset,
|
|
81
|
-
shaderLocation: this
|
|
82
|
+
shaderLocation: this.#customLocationMap[defaultAttribEntry]
|
|
82
83
|
}]
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
|
-
if (!Object.keys(this.attrib).every((key) => this
|
|
86
|
+
if (!Object.keys(this.attrib).every((key) => this.#customLocationMap[key] !== void 0)) throw new Error("All attributes must have custom locations in order to unwrap a vertex layout.");
|
|
86
87
|
return {
|
|
87
88
|
arrayStride: this.stride,
|
|
88
89
|
stepMode: this.stepMode,
|
|
89
90
|
attributes: Object.entries(this.attrib).map(([key, attrib]) => ({
|
|
90
91
|
format: attrib.format,
|
|
91
92
|
offset: attrib.offset,
|
|
92
|
-
shaderLocation: this
|
|
93
|
+
shaderLocation: this.#customLocationMap[key]
|
|
93
94
|
}))
|
|
94
95
|
};
|
|
95
96
|
}
|
|
@@ -98,6 +99,5 @@ var TgpuVertexLayoutImpl = class {
|
|
|
98
99
|
return this;
|
|
99
100
|
}
|
|
100
101
|
};
|
|
101
|
-
|
|
102
102
|
//#endregion
|
|
103
|
-
export { isVertexLayout, vertexLayout };
|
|
103
|
+
export { isVertexLayout, vertexLayout };
|
package/data/alignIO.js
CHANGED
package/data/alignmentOf.d.ts
CHANGED
package/data/alignmentOf.js
CHANGED
|
@@ -2,7 +2,6 @@ import { isDecorated, isWgslArray, isWgslStruct } from "./wgslTypes.js";
|
|
|
2
2
|
import { getCustomAlignment, isDisarray, isLooseDecorated, isUnstruct } from "./dataTypes.js";
|
|
3
3
|
import { safeStringify } from "../shared/stringify.js";
|
|
4
4
|
import { packedFormats } from "./vertexFormatData.js";
|
|
5
|
-
|
|
6
5
|
//#region src/data/alignmentOf.ts
|
|
7
6
|
const knownAlignmentMap = {
|
|
8
7
|
f32: 4,
|
|
@@ -83,6 +82,5 @@ function customAlignmentOf(data) {
|
|
|
83
82
|
function PUBLIC_alignmentOf(schema) {
|
|
84
83
|
return alignmentOf(schema);
|
|
85
84
|
}
|
|
86
|
-
|
|
87
85
|
//#endregion
|
|
88
|
-
export { PUBLIC_alignmentOf, alignmentOf, customAlignmentOf };
|
|
86
|
+
export { PUBLIC_alignmentOf, alignmentOf, customAlignmentOf };
|
package/data/array.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { AnyWgslData, WgslArray } from "./wgslTypes.js";
|
|
2
2
|
import { TgpuComptime } from "../core/function/comptime.js";
|
|
3
|
-
import "../indexNamedExports.js";
|
|
4
|
-
|
|
5
3
|
//#region src/data/array.d.ts
|
|
6
4
|
interface WgslArrayConstructor {
|
|
7
5
|
<TElement extends AnyWgslData>(elementType: TElement): (elementCount: number) => WgslArray<TElement>;
|
|
@@ -23,6 +21,6 @@ interface WgslArrayConstructor {
|
|
|
23
21
|
* @param elementType The type of elements in the array.
|
|
24
22
|
* @param elementCount The number of elements in the array.
|
|
25
23
|
*/
|
|
26
|
-
declare const arrayOf: TgpuComptime
|
|
24
|
+
declare const arrayOf: TgpuComptime;
|
|
27
25
|
//#endregion
|
|
28
26
|
export { arrayOf };
|
package/data/array.js
CHANGED
|
@@ -2,7 +2,6 @@ import { $internal } from "../shared/symbols.js";
|
|
|
2
2
|
import { schemaCallWrapper } from "./schemaCallWrapper.js";
|
|
3
3
|
import { sizeOf } from "./sizeOf.js";
|
|
4
4
|
import { comptime } from "../core/function/comptime.js";
|
|
5
|
-
|
|
6
5
|
//#region src/data/array.ts
|
|
7
6
|
/**
|
|
8
7
|
* Creates an array schema that can be used to construct gpu buffers.
|
|
@@ -40,9 +39,8 @@ const WgslArrayImpl = {
|
|
|
40
39
|
[$internal]: true,
|
|
41
40
|
type: "array",
|
|
42
41
|
toString() {
|
|
43
|
-
return `arrayOf(${this.elementType}, ${this.elementCount})`;
|
|
42
|
+
return `arrayOf(${String(this.elementType)}, ${this.elementCount})`;
|
|
44
43
|
}
|
|
45
44
|
};
|
|
46
|
-
|
|
47
45
|
//#endregion
|
|
48
|
-
export { arrayOf };
|
|
46
|
+
export { arrayOf };
|
package/data/atomic.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { $internal } from "../shared/symbols.js";
|
|
2
|
-
|
|
3
2
|
//#region src/data/atomic.ts
|
|
4
3
|
/**
|
|
5
4
|
* Marks a concrete integer scalar type schema (u32 or i32) as a WGSL atomic.
|
|
@@ -16,10 +15,10 @@ function atomic(data) {
|
|
|
16
15
|
var AtomicImpl = class {
|
|
17
16
|
[$internal] = {};
|
|
18
17
|
type = "atomic";
|
|
18
|
+
inner;
|
|
19
19
|
constructor(inner) {
|
|
20
20
|
this.inner = inner;
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
|
|
24
23
|
//#endregion
|
|
25
|
-
export { atomic };
|
|
24
|
+
export { atomic };
|
package/data/attributes.js
CHANGED
|
@@ -3,7 +3,6 @@ import { isAlignAttrib, isBuiltinAttrib, isDecorated, isSizeAttrib, isWgslData }
|
|
|
3
3
|
import { isLooseData, isLooseDecorated } from "./dataTypes.js";
|
|
4
4
|
import { alignmentOf } from "./alignmentOf.js";
|
|
5
5
|
import { sizeOf } from "./sizeOf.js";
|
|
6
|
-
|
|
7
6
|
//#region src/data/attributes.ts
|
|
8
7
|
function attribute(data, attrib) {
|
|
9
8
|
if (isDecorated(data)) return new DecoratedImpl(data.inner, [attrib, ...data.attribs]);
|
|
@@ -114,6 +113,8 @@ function getAttributesString(field) {
|
|
|
114
113
|
}
|
|
115
114
|
var BaseDecoratedImpl = class {
|
|
116
115
|
[$internal] = {};
|
|
116
|
+
inner;
|
|
117
|
+
attribs;
|
|
117
118
|
constructor(inner, attribs) {
|
|
118
119
|
this.inner = inner;
|
|
119
120
|
this.attribs = attribs;
|
|
@@ -140,6 +141,5 @@ var LooseDecoratedImpl = class extends BaseDecoratedImpl {
|
|
|
140
141
|
[$internal] = {};
|
|
141
142
|
type = "loose-decorated";
|
|
142
143
|
};
|
|
143
|
-
|
|
144
144
|
//#endregion
|
|
145
|
-
export { align, attribute, getAttributesString, interpolate, invariant, isBuiltin, location, size };
|
|
145
|
+
export { align, attribute, getAttributesString, interpolate, invariant, isBuiltin, location, size };
|