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/std/subgroup.d.ts
CHANGED
|
@@ -22,26 +22,26 @@ interface IdentityNumOrVecWithMask {
|
|
|
22
22
|
(e: number, mask: number): number;
|
|
23
23
|
<T extends AnyNumericVecInstance>(e: T, mask: number): T;
|
|
24
24
|
}
|
|
25
|
-
declare const subgroupAdd: DualFn
|
|
26
|
-
declare const subgroupExclusiveAdd: DualFn
|
|
27
|
-
declare const subgroupInclusiveAdd: DualFn
|
|
28
|
-
declare const subgroupAll: DualFn
|
|
29
|
-
declare const subgroupAnd: DualFn
|
|
30
|
-
declare const subgroupAny: DualFn
|
|
31
|
-
declare const subgroupBallot: DualFn
|
|
32
|
-
declare const subgroupBroadcast: DualFn
|
|
33
|
-
declare const subgroupBroadcastFirst: DualFn
|
|
34
|
-
declare const subgroupElect: DualFn
|
|
35
|
-
declare const subgroupMax: DualFn
|
|
36
|
-
declare const subgroupMin: DualFn
|
|
37
|
-
declare const subgroupMul: DualFn
|
|
38
|
-
declare const subgroupExclusiveMul: DualFn
|
|
39
|
-
declare const subgroupInclusiveMul: DualFn
|
|
40
|
-
declare const subgroupOr: DualFn
|
|
41
|
-
declare const subgroupShuffle: DualFn
|
|
42
|
-
declare const subgroupShuffleDown: DualFn
|
|
43
|
-
declare const subgroupShuffleUp: DualFn
|
|
44
|
-
declare const subgroupShuffleXor: DualFn
|
|
45
|
-
declare const subgroupXor: DualFn
|
|
25
|
+
declare const subgroupAdd: DualFn;
|
|
26
|
+
declare const subgroupExclusiveAdd: DualFn;
|
|
27
|
+
declare const subgroupInclusiveAdd: DualFn;
|
|
28
|
+
declare const subgroupAll: DualFn;
|
|
29
|
+
declare const subgroupAnd: DualFn;
|
|
30
|
+
declare const subgroupAny: DualFn;
|
|
31
|
+
declare const subgroupBallot: DualFn;
|
|
32
|
+
declare const subgroupBroadcast: DualFn;
|
|
33
|
+
declare const subgroupBroadcastFirst: DualFn;
|
|
34
|
+
declare const subgroupElect: DualFn;
|
|
35
|
+
declare const subgroupMax: DualFn;
|
|
36
|
+
declare const subgroupMin: DualFn;
|
|
37
|
+
declare const subgroupMul: DualFn;
|
|
38
|
+
declare const subgroupExclusiveMul: DualFn;
|
|
39
|
+
declare const subgroupInclusiveMul: DualFn;
|
|
40
|
+
declare const subgroupOr: DualFn;
|
|
41
|
+
declare const subgroupShuffle: DualFn;
|
|
42
|
+
declare const subgroupShuffleDown: DualFn;
|
|
43
|
+
declare const subgroupShuffleUp: DualFn;
|
|
44
|
+
declare const subgroupShuffleXor: DualFn;
|
|
45
|
+
declare const subgroupXor: DualFn;
|
|
46
46
|
//#endregion
|
|
47
47
|
export { subgroupAdd, subgroupAll, subgroupAnd, subgroupAny, subgroupBallot, subgroupBroadcast, subgroupBroadcastFirst, subgroupElect, subgroupExclusiveAdd, subgroupExclusiveMul, subgroupInclusiveAdd, subgroupInclusiveMul, subgroupMax, subgroupMin, subgroupMul, subgroupOr, subgroupShuffle, subgroupShuffleDown, subgroupShuffleUp, subgroupShuffleXor, subgroupXor };
|
package/std/subgroup.js
CHANGED
|
@@ -3,7 +3,6 @@ import { unify } from "../tgsl/conversion.js";
|
|
|
3
3
|
import { bool, i32, u32 } from "../data/numeric.js";
|
|
4
4
|
import { vec4u } from "../data/vector.js";
|
|
5
5
|
import { dualImpl } from "../core/function/dualImpl.js";
|
|
6
|
-
|
|
7
6
|
//#region src/std/subgroup.ts
|
|
8
7
|
const errorMessage = "Subgroup operations can only be used in the GPU context.";
|
|
9
8
|
const subgroupAdd = dualImpl({
|
|
@@ -215,6 +214,5 @@ const subgroupXor = dualImpl({
|
|
|
215
214
|
normalImpl: errorMessage,
|
|
216
215
|
codegenImpl: (_ctx, [e]) => stitch`subgroupXor(${e})`
|
|
217
216
|
});
|
|
218
|
-
|
|
219
217
|
//#endregion
|
|
220
|
-
export { subgroupAdd, subgroupAll, subgroupAnd, subgroupAny, subgroupBallot, subgroupBroadcast, subgroupBroadcastFirst, subgroupElect, subgroupExclusiveAdd, subgroupExclusiveMul, subgroupInclusiveAdd, subgroupInclusiveMul, subgroupMax, subgroupMin, subgroupMul, subgroupOr, subgroupShuffle, subgroupShuffleDown, subgroupShuffleUp, subgroupShuffleXor, subgroupXor };
|
|
218
|
+
export { subgroupAdd, subgroupAll, subgroupAnd, subgroupAny, subgroupBallot, subgroupBroadcast, subgroupBroadcastFirst, subgroupElect, subgroupExclusiveAdd, subgroupExclusiveMul, subgroupInclusiveAdd, subgroupInclusiveMul, subgroupMax, subgroupMin, subgroupMul, subgroupOr, subgroupShuffle, subgroupShuffleDown, subgroupShuffleUp, subgroupShuffleXor, subgroupXor };
|
package/std/texture.d.ts
CHANGED
|
@@ -15,13 +15,13 @@ declare function sampleCpu<T extends textureCubeArray>(texture: T, sampler: samp
|
|
|
15
15
|
declare function sampleCpu<T extends textureDepth2d>(texture: T, sampler: sampler, coords: v2f, offset?: v2i): number;
|
|
16
16
|
declare function sampleCpu<T extends textureDepth2dArray>(texture: T, sampler: sampler, coords: v2f, arrayIndex: number, offset?: v2i): number;
|
|
17
17
|
declare function sampleCpu<T extends textureDepthCube>(texture: T, sampler: sampler, coords: v3f, arrayIndex?: number): number;
|
|
18
|
-
declare const textureSample: DualFn
|
|
18
|
+
declare const textureSample: DualFn;
|
|
19
19
|
declare function sampleBiasCpu<T extends texture1d>(texture: T, sampler: sampler, coords: number, bias: number): v4f;
|
|
20
20
|
declare function sampleBiasCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, bias: number, offset?: v2i): v4f;
|
|
21
21
|
declare function sampleBiasCpu<T extends texture2dArray>(texture: T, sampler: sampler, coords: v2f, arrayIndex: number, bias: number, offset?: v2i): v4f;
|
|
22
22
|
declare function sampleBiasCpu<T extends texture3d | textureCube>(texture: T, sampler: sampler, coords: v3f, bias: number, offset?: v3i): v4f;
|
|
23
23
|
declare function sampleBiasCpu<T extends textureCubeArray>(texture: T, sampler: sampler, coords: v3f, arrayIndex: number, bias: number): v4f;
|
|
24
|
-
declare const textureSampleBias: DualFn
|
|
24
|
+
declare const textureSampleBias: DualFn;
|
|
25
25
|
declare function sampleLevelCpu<T extends texture1d>(texture: T, sampler: sampler, coords: number, level: number): v4f;
|
|
26
26
|
declare function sampleLevelCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, level: number): v4f;
|
|
27
27
|
declare function sampleLevelCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, level: number, offset: v2i): v4f;
|
|
@@ -36,7 +36,7 @@ declare function sampleLevelCpu<T extends textureDepth2dArray>(texture: T, sampl
|
|
|
36
36
|
declare function sampleLevelCpu<T extends textureDepth2dArray>(texture: T, sampler: sampler, coords: v2f, arrayIndex: number, level: number, offset: v2i): number;
|
|
37
37
|
declare function sampleLevelCpu<T extends textureDepthCube>(texture: T, sampler: sampler, coords: v3f, level: number): number;
|
|
38
38
|
declare function sampleLevelCpu<T extends textureCubeArray>(texture: T, sampler: sampler, coords: v3f, arrayIndex: number, level: number): number;
|
|
39
|
-
declare const textureSampleLevel: DualFn
|
|
39
|
+
declare const textureSampleLevel: DualFn;
|
|
40
40
|
type PrimitiveToLoadedType = {
|
|
41
41
|
f32: v4f;
|
|
42
42
|
i32: v4i;
|
|
@@ -56,19 +56,19 @@ declare function textureLoadCpu<T extends textureStorage1d>(texture: T, coords:
|
|
|
56
56
|
declare function textureLoadCpu<T extends textureStorage2d>(texture: T, coords: v2i | v2u): TexelFormatToInstanceType<T[typeof $internal][0]>;
|
|
57
57
|
declare function textureLoadCpu<T extends textureStorage2dArray>(texture: T, coords: v2i | v2u, arrayIndex: number): TexelFormatToInstanceType<T[typeof $internal][0]>;
|
|
58
58
|
declare function textureLoadCpu<T extends textureStorage3d>(texture: T, coords: v3i | v3u): TexelFormatToInstanceType<T[typeof $internal][0]>;
|
|
59
|
-
declare const textureLoad: DualFn
|
|
59
|
+
declare const textureLoad: DualFn;
|
|
60
60
|
declare function textureStoreCpu<T extends textureStorage1d>(texture: T, coords: number, value: TexelFormatToInstanceType<T[typeof $internal][0]>): void;
|
|
61
61
|
declare function textureStoreCpu<T extends textureStorage2d>(texture: T, coords: v2i | v2u, value: TexelFormatToInstanceType<T[typeof $internal][0]>): void;
|
|
62
62
|
declare function textureStoreCpu<T extends textureStorage2dArray>(texture: T, coords: v2i | v2u, arrayIndex: number, value: TexelFormatToInstanceType<T[typeof $internal][0]>): void;
|
|
63
63
|
declare function textureStoreCpu<T extends textureStorage3d>(texture: T, coords: v3i | v3u, value: TexelFormatToInstanceType<T[typeof $internal][0]>): void;
|
|
64
|
-
declare const textureStore: DualFn
|
|
64
|
+
declare const textureStore: DualFn;
|
|
65
65
|
declare function textureDimensionsCpu<T extends texture1d | textureStorage1d>(texture: T): number;
|
|
66
66
|
declare function textureDimensionsCpu<T extends texture1d>(texture: T, level: number): number;
|
|
67
67
|
declare function textureDimensionsCpu<T extends texture2d | texture2dArray | textureCube | textureCubeArray | textureStorage2d | textureStorage2dArray | textureExternal>(texture: T): v2u;
|
|
68
68
|
declare function textureDimensionsCpu<T extends texture2d | texture2dArray | textureCube | textureCubeArray>(texture: T, level: number): v2u;
|
|
69
69
|
declare function textureDimensionsCpu<T extends texture3d | textureStorage3d>(texture: T): v3u;
|
|
70
70
|
declare function textureDimensionsCpu<T extends texture3d>(texture: T, level: number): v3u;
|
|
71
|
-
declare const textureDimensions: DualFn
|
|
71
|
+
declare const textureDimensions: DualFn;
|
|
72
72
|
type Gather2dArgs<T extends texture2d = texture2d> = [component: number, texture: T, sampler: sampler, coords: v2f, offset?: v2i];
|
|
73
73
|
type Gather2dArrayArgs<T extends texture2dArray = texture2dArray> = [component: number, texture: T, sampler: sampler, coords: v2f, arrayIndex: number, offset?: v2i];
|
|
74
74
|
type GatherCubeArgs<T extends textureCube = textureCube> = [component: number, texture: T, sampler: sampler, coords: v3f];
|
|
@@ -87,22 +87,31 @@ type TextureGatherCpuFn = {
|
|
|
87
87
|
(...args: GatherDepthCubeArgs): v4f;
|
|
88
88
|
(...args: GatherDepthCubeArrayArgs): v4f;
|
|
89
89
|
};
|
|
90
|
-
declare const textureGather: DualFn
|
|
90
|
+
declare const textureGather: DualFn;
|
|
91
91
|
declare function textureSampleCompareCpu<T extends textureDepth2d>(texture: T, sampler: comparisonSampler, coords: v2f, depthRef: number): number;
|
|
92
92
|
declare function textureSampleCompareCpu<T extends textureDepth2d>(texture: T, sampler: comparisonSampler, coords: v2f, depthRef: number, offset: v2i): number;
|
|
93
93
|
declare function textureSampleCompareCpu<T extends textureDepth2dArray>(texture: T, sampler: comparisonSampler, coords: v2f, arrayIndex: number, depthRef: number): number;
|
|
94
94
|
declare function textureSampleCompareCpu<T extends textureDepth2dArray>(texture: T, sampler: comparisonSampler, coords: v2f, arrayIndex: number, depthRef: number, offset: v2i): number;
|
|
95
95
|
declare function textureSampleCompareCpu<T extends textureDepthCube>(texture: T, sampler: comparisonSampler, coords: v3f, depthRef: number): number;
|
|
96
96
|
declare function textureSampleCompareCpu<T extends textureDepthCubeArray>(texture: T, sampler: comparisonSampler, coords: v3f, arrayIndex: number, depthRef: number): number;
|
|
97
|
-
declare const textureSampleCompare: DualFn
|
|
97
|
+
declare const textureSampleCompare: DualFn;
|
|
98
98
|
declare function textureSampleCompareLevelCpu<T extends textureDepth2d>(texture: T, sampler: comparisonSampler, coords: v2f, depthRef: number): number;
|
|
99
99
|
declare function textureSampleCompareLevelCpu<T extends textureDepth2d>(texture: T, sampler: comparisonSampler, coords: v2f, depthRef: number, offset: v2i): number;
|
|
100
100
|
declare function textureSampleCompareLevelCpu<T extends textureDepth2dArray>(texture: T, sampler: comparisonSampler, coords: v2f, arrayIndex: number, depthRef: number): number;
|
|
101
101
|
declare function textureSampleCompareLevelCpu<T extends textureDepth2dArray>(texture: T, sampler: comparisonSampler, coords: v2f, arrayIndex: number, depthRef: number, offset: v2i): number;
|
|
102
102
|
declare function textureSampleCompareLevelCpu<T extends textureDepthCube>(texture: T, sampler: comparisonSampler, coords: v3f, depthRef: number): number;
|
|
103
103
|
declare function textureSampleCompareLevelCpu<T extends textureDepthCubeArray>(texture: T, sampler: comparisonSampler, coords: v3f, arrayIndex: number, depthRef: number): number;
|
|
104
|
-
declare const textureSampleCompareLevel: DualFn
|
|
104
|
+
declare const textureSampleCompareLevel: DualFn;
|
|
105
105
|
declare function textureSampleBaseClampToEdgeCpu<T extends texture2d | textureExternal>(_texture: T, _sampler: sampler, _coords: v2f): v4f;
|
|
106
|
-
declare
|
|
106
|
+
declare function sampleGradCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, ddx: v2f, ddy: v2f): v4f;
|
|
107
|
+
declare function sampleGradCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, ddx: v2f, ddy: v2f, offset: v2i): v4f;
|
|
108
|
+
declare function sampleGradCpu<T extends texture2dArray>(texture: T, sampler: sampler, coords: v2f, arrayIndex: number, ddx: v2f, ddy: v2f): v4f;
|
|
109
|
+
declare function sampleGradCpu<T extends texture2dArray>(texture: T, sampler: sampler, coords: v2f, arrayIndex: number, ddx: v2f, ddy: v2f, offset: v2i): v4f;
|
|
110
|
+
declare function sampleGradCpu<T extends texture3d>(texture: T, sampler: sampler, coords: v3f, ddx: v3f, ddy: v3f): v4f;
|
|
111
|
+
declare function sampleGradCpu<T extends texture3d>(texture: T, sampler: sampler, coords: v3f, ddx: v3f, ddy: v3f, offset: v3i): v4f;
|
|
112
|
+
declare function sampleGradCpu<T extends textureCube>(texture: T, sampler: sampler, coords: v3f, ddx: v3f, ddy: v3f): v4f;
|
|
113
|
+
declare function sampleGradCpu<T extends textureCubeArray>(texture: T, sampler: sampler, coords: v3f, arrayIndex: number, ddx: v3f, ddy: v3f): v4f;
|
|
114
|
+
declare const textureSampleGrad: DualFn;
|
|
115
|
+
declare const textureSampleBaseClampToEdge: DualFn;
|
|
107
116
|
//#endregion
|
|
108
|
-
export { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleLevel, textureStore };
|
|
117
|
+
export { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleGrad, textureSampleLevel, textureStore };
|
package/std/texture.js
CHANGED
|
@@ -5,7 +5,6 @@ import { vec2u, vec3u, vec4f, vec4i, vec4u } from "../data/vector.js";
|
|
|
5
5
|
import { MissingCpuImplError, dualImpl } from "../core/function/dualImpl.js";
|
|
6
6
|
import { isWgslExternalTexture, isWgslTexture } from "../data/texture.js";
|
|
7
7
|
import { getTextureFormatInfo } from "../core/texture/textureFormats.js";
|
|
8
|
-
|
|
9
8
|
//#region src/std/texture.ts
|
|
10
9
|
function sampleCpu(_texture, _sampler, _coords, _offsetOrArrayIndex, _maybeOffset) {
|
|
11
10
|
throw new MissingCpuImplError("Texture sampling relies on GPU resources and cannot be executed outside of a draw call");
|
|
@@ -183,6 +182,18 @@ const textureSampleCompareLevel = dualImpl({
|
|
|
183
182
|
function textureSampleBaseClampToEdgeCpu(_texture, _sampler, _coords) {
|
|
184
183
|
throw new MissingCpuImplError("Texture sampling with base clamp to edge is not supported outside of GPU mode.");
|
|
185
184
|
}
|
|
185
|
+
function sampleGradCpu(_texture, _sampler, _coords, _ddxOrArrayIndex, _ddyOrDdx, _offsetOrDdy, _maybeOffset) {
|
|
186
|
+
throw new MissingCpuImplError("Texture sampling with gradients relies on GPU resources and cannot be executed outside of a draw call");
|
|
187
|
+
}
|
|
188
|
+
const textureSampleGrad = dualImpl({
|
|
189
|
+
name: "textureSampleGrad",
|
|
190
|
+
normalImpl: sampleGradCpu,
|
|
191
|
+
codegenImpl: (_ctx, args) => stitch`textureSampleGrad(${args})`,
|
|
192
|
+
signature: (...args) => ({
|
|
193
|
+
argTypes: args,
|
|
194
|
+
returnType: vec4f
|
|
195
|
+
})
|
|
196
|
+
});
|
|
186
197
|
const textureSampleBaseClampToEdge = dualImpl({
|
|
187
198
|
name: "textureSampleBaseClampToEdge",
|
|
188
199
|
normalImpl: textureSampleBaseClampToEdgeCpu,
|
|
@@ -192,6 +203,5 @@ const textureSampleBaseClampToEdge = dualImpl({
|
|
|
192
203
|
returnType: vec4f
|
|
193
204
|
})
|
|
194
205
|
});
|
|
195
|
-
|
|
196
206
|
//#endregion
|
|
197
|
-
export { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleLevel, textureStore };
|
|
207
|
+
export { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleGrad, textureSampleLevel, textureStore };
|
package/tgpu.js
CHANGED
|
@@ -15,7 +15,6 @@ import { accessor, mutableAccessor } from "./core/slot/accessor.js";
|
|
|
15
15
|
import { fragmentFn } from "./core/function/tgpuFragmentFn.js";
|
|
16
16
|
import { vertexFn } from "./core/function/tgpuVertexFn.js";
|
|
17
17
|
import { tgpuUnstable_exports } from "./tgpuUnstable.js";
|
|
18
|
-
|
|
19
18
|
//#region src/tgpu.ts
|
|
20
19
|
var tgpu_exports = /* @__PURE__ */ __exportAll({
|
|
21
20
|
accessor: () => accessor,
|
|
@@ -39,6 +38,5 @@ var tgpu_exports = /* @__PURE__ */ __exportAll({
|
|
|
39
38
|
workgroupVar: () => workgroupVar,
|
|
40
39
|
"~unstable": () => tgpuUnstable_exports
|
|
41
40
|
});
|
|
42
|
-
|
|
43
41
|
//#endregion
|
|
44
|
-
export { tgpu_exports };
|
|
42
|
+
export { tgpu_exports };
|
package/tgpuBindGroupLayout.js
CHANGED
|
@@ -3,16 +3,15 @@ import { getName, setName } from "./shared/meta.js";
|
|
|
3
3
|
import { NotUniformError } from "./errors.js";
|
|
4
4
|
import { safeStringify } from "./shared/stringify.js";
|
|
5
5
|
import { f32, i32, u32 } from "./data/numeric.js";
|
|
6
|
-
import { comparisonSampler, sampler } from "./data/sampler.js";
|
|
7
|
-
import { textureDescriptorToSchema } from "./data/texture.js";
|
|
8
6
|
import { NotStorageError, isUsableAsStorage } from "./extension.js";
|
|
9
7
|
import { TgpuLaidOutBufferImpl, isUsableAsUniform } from "./core/buffer/bufferUsage.js";
|
|
10
8
|
import { isBuffer } from "./core/buffer/buffer.js";
|
|
9
|
+
import { comparisonSampler, sampler } from "./data/sampler.js";
|
|
11
10
|
import { TgpuLaidOutSamplerImpl, isComparisonSampler, isSampler } from "./core/sampler/sampler.js";
|
|
11
|
+
import { textureDescriptorToSchema } from "./data/texture.js";
|
|
12
12
|
import { TgpuExternalTextureImpl } from "./core/texture/externalTexture.js";
|
|
13
13
|
import { TgpuLaidOutTextureViewImpl, isTexture, isTextureView } from "./core/texture/texture.js";
|
|
14
14
|
import { NotSampledError, isUsableAsSampled } from "./core/texture/usageExtension.js";
|
|
15
|
-
|
|
16
15
|
//#region src/tgpuBindGroupLayout.ts
|
|
17
16
|
/**
|
|
18
17
|
* Converts legacy entries to new API format
|
|
@@ -84,11 +83,12 @@ const DEFAULT_READONLY_VISIBILITY = [
|
|
|
84
83
|
"fragment"
|
|
85
84
|
];
|
|
86
85
|
var TgpuBindGroupLayoutImpl = class {
|
|
86
|
+
#index;
|
|
87
87
|
[$internal];
|
|
88
|
-
_index;
|
|
89
88
|
resourceType = "bind-group-layout";
|
|
90
89
|
value = {};
|
|
91
90
|
$ = this.value;
|
|
91
|
+
entries;
|
|
92
92
|
get [$gpuValueOf]() {
|
|
93
93
|
return this.$;
|
|
94
94
|
}
|
|
@@ -126,7 +126,7 @@ var TgpuBindGroupLayoutImpl = class {
|
|
|
126
126
|
return `bindGroupLayout:${getName(this) ?? "<unnamed>"}`;
|
|
127
127
|
}
|
|
128
128
|
get index() {
|
|
129
|
-
return this
|
|
129
|
+
return this.#index;
|
|
130
130
|
}
|
|
131
131
|
$name(label) {
|
|
132
132
|
setName(this, label);
|
|
@@ -136,7 +136,7 @@ var TgpuBindGroupLayoutImpl = class {
|
|
|
136
136
|
return this[$internal].bound;
|
|
137
137
|
}
|
|
138
138
|
$idx(index) {
|
|
139
|
-
this
|
|
139
|
+
this.#index = index;
|
|
140
140
|
return this;
|
|
141
141
|
}
|
|
142
142
|
unwrap(unwrapper) {
|
|
@@ -188,6 +188,8 @@ var TgpuBindGroupLayoutImpl = class {
|
|
|
188
188
|
};
|
|
189
189
|
var TgpuBindGroupImpl = class {
|
|
190
190
|
resourceType = "bind-group";
|
|
191
|
+
layout;
|
|
192
|
+
entries;
|
|
191
193
|
constructor(layout, entries) {
|
|
192
194
|
this.layout = layout;
|
|
193
195
|
this.entries = entries;
|
|
@@ -266,6 +268,5 @@ var TgpuBindGroupImpl = class {
|
|
|
266
268
|
});
|
|
267
269
|
}
|
|
268
270
|
};
|
|
269
|
-
|
|
270
271
|
//#endregion
|
|
271
|
-
export { TgpuBindGroupImpl, bindGroupLayout, isBindGroup, isBindGroupLayout };
|
|
272
|
+
export { TgpuBindGroupImpl, bindGroupLayout, isBindGroup, isBindGroupLayout };
|
package/tgpuUnstable.js
CHANGED
|
@@ -14,7 +14,6 @@ import { vertexFn } from "./core/function/tgpuVertexFn.js";
|
|
|
14
14
|
import { declare } from "./core/declare/tgpuDeclare.js";
|
|
15
15
|
import { rawCodeSnippet } from "./core/rawCodeSnippet/tgpuRawCodeSnippet.js";
|
|
16
16
|
import { simulate } from "./core/simulate/tgpuSimulate.js";
|
|
17
|
-
|
|
18
17
|
//#region src/tgpuUnstable.ts
|
|
19
18
|
var tgpuUnstable_exports = /* @__PURE__ */ __exportAll({
|
|
20
19
|
accessor: () => _accessor,
|
|
@@ -61,6 +60,5 @@ const _privateVar = privateVar;
|
|
|
61
60
|
const _workgroupVar = workgroupVar;
|
|
62
61
|
/** @deprecated This feature is now stable, use tgpu.vertexLayout. */
|
|
63
62
|
const _vertexLayout = vertexLayout;
|
|
64
|
-
|
|
65
63
|
//#endregion
|
|
66
|
-
export { tgpuUnstable_exports };
|
|
64
|
+
export { tgpuUnstable_exports };
|
package/tgsl/accessIndex.js
CHANGED
|
@@ -4,10 +4,9 @@ import { isEphemeralSnippet, snip } from "../data/snippet.js";
|
|
|
4
4
|
import { isKnownAtComptime } from "../types.js";
|
|
5
5
|
import { stitch } from "../core/resolve/stitch.js";
|
|
6
6
|
import { derefSnippet } from "../data/ref.js";
|
|
7
|
-
import { vec2f, vec3f, vec4f } from "../data/vector.js";
|
|
8
7
|
import { coerceToSnippet } from "./generationHelpers.js";
|
|
8
|
+
import { vec2f, vec3f, vec4f } from "../data/vector.js";
|
|
9
9
|
import { accessProp } from "./accessProp.js";
|
|
10
|
-
|
|
11
10
|
//#region src/tgsl/accessIndex.ts
|
|
12
11
|
const indexableTypeToResult = {
|
|
13
12
|
mat2x2f: vec2f,
|
|
@@ -40,6 +39,5 @@ function accessIndex(target, indexArg) {
|
|
|
40
39
|
if (isKnownAtComptime(target) && isKnownAtComptime(index) || target.dataType === UnknownData) return coerceToSnippet(target.value[index.value]);
|
|
41
40
|
if (isWgslStruct(target.dataType) && isKnownAtComptime(index) && typeof index.value === "string") return accessProp(target, index.value);
|
|
42
41
|
}
|
|
43
|
-
|
|
44
42
|
//#endregion
|
|
45
|
-
export { accessIndex };
|
|
43
|
+
export { accessIndex };
|
package/tgsl/accessProp.js
CHANGED
|
@@ -6,11 +6,11 @@ import { isKnownAtComptime } from "../types.js";
|
|
|
6
6
|
import { stitch } from "../core/resolve/stitch.js";
|
|
7
7
|
import { derefSnippet } from "../data/ref.js";
|
|
8
8
|
import { abstractInt, bool, f16, f32, i32, u32 } from "../data/numeric.js";
|
|
9
|
+
import { coerceToSnippet } from "./generationHelpers.js";
|
|
9
10
|
import { vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u } from "../data/vector.js";
|
|
10
11
|
import { AutoStruct } from "../data/autoStruct.js";
|
|
11
|
-
import {
|
|
12
|
-
import { add, div, mod, mul, sub } from "../std/operators.js";
|
|
13
|
-
|
|
12
|
+
import { EntryInputRouter } from "../core/function/entryInputRouter.js";
|
|
13
|
+
import { add, bitShiftLeft, bitShiftRight, div, mod, mul, sub } from "../std/operators.js";
|
|
14
14
|
//#region src/tgsl/accessProp.ts
|
|
15
15
|
const infixKinds = [
|
|
16
16
|
"vec2f",
|
|
@@ -34,7 +34,9 @@ const infixOperators = {
|
|
|
34
34
|
sub,
|
|
35
35
|
mul,
|
|
36
36
|
div,
|
|
37
|
-
mod
|
|
37
|
+
mod,
|
|
38
|
+
bitShiftLeft,
|
|
39
|
+
bitShiftRight
|
|
38
40
|
};
|
|
39
41
|
const swizzleLenToType = {
|
|
40
42
|
f: {
|
|
@@ -89,6 +91,7 @@ function accessProp(target, propName) {
|
|
|
89
91
|
if (!result) return;
|
|
90
92
|
return snip(stitch`${target}.${result.prop}`, result.type, "argument");
|
|
91
93
|
}
|
|
94
|
+
if (target.dataType instanceof EntryInputRouter) return target.dataType.accessProp(propName);
|
|
92
95
|
if (isPtr(target.dataType)) {
|
|
93
96
|
const derefed = derefSnippet(target);
|
|
94
97
|
if (propName === "$") return derefed;
|
|
@@ -108,6 +111,5 @@ function accessProp(target, propName) {
|
|
|
108
111
|
}
|
|
109
112
|
if (isKnownAtComptime(target) || target.dataType === UnknownData) return coerceToSnippet(target.value[propName]);
|
|
110
113
|
}
|
|
111
|
-
|
|
112
114
|
//#endregion
|
|
113
|
-
export { accessProp, infixOperators };
|
|
115
|
+
export { accessProp, infixOperators };
|
|
@@ -5,7 +5,6 @@ import { sizeOf } from "../../data/sizeOf.js";
|
|
|
5
5
|
import { mat2x2f, mat3x3f, mat4x4f } from "../../data/matrix.js";
|
|
6
6
|
import { bitcastU32toF32, bitcastU32toI32 } from "../../std/bitcast.js";
|
|
7
7
|
import { unpack2x16float } from "../../std/packing.js";
|
|
8
|
-
|
|
9
8
|
//#region src/tgsl/consoleLog/deserializers.ts
|
|
10
9
|
const toF = (n) => bitcastU32toF32(n ?? 0);
|
|
11
10
|
const toI = (n) => bitcastU32toI32(n ?? 0);
|
|
@@ -112,6 +111,5 @@ function logDataFromGPU(resources) {
|
|
|
112
111
|
dataBuffer.buffer.clear();
|
|
113
112
|
indexBuffer.buffer.clear();
|
|
114
113
|
}
|
|
115
|
-
|
|
116
114
|
//#endregion
|
|
117
|
-
export { logDataFromGPU };
|
|
115
|
+
export { logDataFromGPU };
|
|
@@ -4,14 +4,13 @@ import { UnknownData } from "../../data/dataTypes.js";
|
|
|
4
4
|
import { snip } from "../../data/snippet.js";
|
|
5
5
|
import { stitch } from "../../core/resolve/stitch.js";
|
|
6
6
|
import { u32 } from "../../data/numeric.js";
|
|
7
|
-
import { struct } from "../../data/struct.js";
|
|
8
7
|
import { concretizeSnippets } from "../generationHelpers.js";
|
|
8
|
+
import { struct } from "../../data/struct.js";
|
|
9
9
|
import { shaderStageSlot } from "../../core/slot/internalSlots.js";
|
|
10
10
|
import { arrayOf } from "../../data/array.js";
|
|
11
11
|
import { atomic } from "../../data/atomic.js";
|
|
12
12
|
import { createLoggingFunction } from "./serializers.js";
|
|
13
13
|
import { supportedLogOps } from "./types.js";
|
|
14
|
-
|
|
15
14
|
//#region src/tgsl/consoleLog/logGenerator.ts
|
|
16
15
|
const defaultOptions = {
|
|
17
16
|
logCountLimit: 64,
|
|
@@ -81,6 +80,5 @@ var LogGeneratorImpl = class {
|
|
|
81
80
|
};
|
|
82
81
|
}
|
|
83
82
|
};
|
|
84
|
-
|
|
85
83
|
//#endregion
|
|
86
|
-
export { LogGeneratorImpl, LogGeneratorNullImpl };
|
|
84
|
+
export { LogGeneratorImpl, LogGeneratorNullImpl };
|
|
@@ -7,7 +7,6 @@ import { mat2x2f, mat3x3f, mat4x4f } from "../../data/matrix.js";
|
|
|
7
7
|
import { fn } from "../../core/function/tgpuFn.js";
|
|
8
8
|
import { slot } from "../../core/slot/slot.js";
|
|
9
9
|
import { privateVar } from "../../core/variable/tgpuVariable.js";
|
|
10
|
-
|
|
11
10
|
//#region src/tgsl/consoleLog/serializers.ts
|
|
12
11
|
const dataBlockIndex = privateVar(u32, 0).$name("dataBlockIndex");
|
|
13
12
|
const dataByteIndex = privateVar(u32, 0).$name("dataByteIndex");
|
|
@@ -19,99 +18,99 @@ const nextByteIndex = fn([], u32)`() {
|
|
|
19
18
|
}`.$uses({ dataByteIndex }).$name("nextByteIndex");
|
|
20
19
|
const nextU32 = "dataBuffer[dataBlockIndex].serializedData[nextByteIndex()]";
|
|
21
20
|
const serializerMap = {
|
|
22
|
-
f32: fn([f32])`(n)
|
|
21
|
+
f32: fn([f32])`(n) {
|
|
23
22
|
${nextU32} = bitcast<u32>(n);
|
|
24
23
|
}`,
|
|
25
|
-
f16: fn([f16])`(n)
|
|
24
|
+
f16: fn([f16])`(n) {
|
|
26
25
|
${nextU32} = pack2x16float(vec2f(f32(n), 0.0));
|
|
27
26
|
}`,
|
|
28
|
-
i32: fn([i32])`(n)
|
|
27
|
+
i32: fn([i32])`(n) {
|
|
29
28
|
${nextU32} = bitcast<u32>(n);
|
|
30
29
|
}`,
|
|
31
|
-
u32: fn([u32])`(n)
|
|
30
|
+
u32: fn([u32])`(n) {
|
|
32
31
|
${nextU32} = n;
|
|
33
32
|
}`,
|
|
34
|
-
bool: fn([bool])`(b)
|
|
33
|
+
bool: fn([bool])`(b) {
|
|
35
34
|
${nextU32} = u32(b);
|
|
36
35
|
}`,
|
|
37
|
-
vec2f: fn([vec2f])`(v)
|
|
36
|
+
vec2f: fn([vec2f])`(v) {
|
|
38
37
|
${nextU32} = bitcast<u32>(v.x);
|
|
39
38
|
${nextU32} = bitcast<u32>(v.y);
|
|
40
39
|
}`,
|
|
41
|
-
vec3f: fn([vec3f])`(v)
|
|
40
|
+
vec3f: fn([vec3f])`(v) {
|
|
42
41
|
${nextU32} = bitcast<u32>(v.x);
|
|
43
42
|
${nextU32} = bitcast<u32>(v.y);
|
|
44
43
|
${nextU32} = bitcast<u32>(v.z);
|
|
45
44
|
}`,
|
|
46
|
-
vec4f: fn([vec4f])`(v)
|
|
45
|
+
vec4f: fn([vec4f])`(v) {
|
|
47
46
|
${nextU32} = bitcast<u32>(v.x);
|
|
48
47
|
${nextU32} = bitcast<u32>(v.y);
|
|
49
48
|
${nextU32} = bitcast<u32>(v.z);
|
|
50
49
|
${nextU32} = bitcast<u32>(v.w);
|
|
51
50
|
}`,
|
|
52
|
-
vec2h: fn([vec2h])`(v)
|
|
51
|
+
vec2h: fn([vec2h])`(v) {
|
|
53
52
|
${nextU32} = pack2x16float(vec2f(f32(v.x), f32(v.y)));
|
|
54
53
|
}`,
|
|
55
|
-
vec3h: fn([vec3h])`(v)
|
|
54
|
+
vec3h: fn([vec3h])`(v) {
|
|
56
55
|
${nextU32} = pack2x16float(vec2f(f32(v.x), f32(v.y)));
|
|
57
56
|
${nextU32} = pack2x16float(vec2f(f32(v.z), 0.0));
|
|
58
57
|
}`,
|
|
59
|
-
vec4h: fn([vec4h])`(v)
|
|
58
|
+
vec4h: fn([vec4h])`(v) {
|
|
60
59
|
${nextU32} = pack2x16float(vec2f(f32(v.x), f32(v.y)));
|
|
61
60
|
${nextU32} = pack2x16float(vec2f(f32(v.z), f32(v.w)));
|
|
62
61
|
}`,
|
|
63
|
-
vec2i: fn([vec2i])`(v)
|
|
62
|
+
vec2i: fn([vec2i])`(v) {
|
|
64
63
|
${nextU32} = bitcast<u32>(v.x);
|
|
65
64
|
${nextU32} = bitcast<u32>(v.y);
|
|
66
65
|
}`,
|
|
67
|
-
vec3i: fn([vec3i])`(v)
|
|
66
|
+
vec3i: fn([vec3i])`(v) {
|
|
68
67
|
${nextU32} = bitcast<u32>(v.x);
|
|
69
68
|
${nextU32} = bitcast<u32>(v.y);
|
|
70
69
|
${nextU32} = bitcast<u32>(v.z);
|
|
71
70
|
}`,
|
|
72
|
-
vec4i: fn([vec4i])`(v)
|
|
71
|
+
vec4i: fn([vec4i])`(v) {
|
|
73
72
|
${nextU32} = bitcast<u32>(v.x);
|
|
74
73
|
${nextU32} = bitcast<u32>(v.y);
|
|
75
74
|
${nextU32} = bitcast<u32>(v.z);
|
|
76
75
|
${nextU32} = bitcast<u32>(v.w);
|
|
77
76
|
}`,
|
|
78
|
-
vec2u: fn([vec2u])`(v)
|
|
77
|
+
vec2u: fn([vec2u])`(v) {
|
|
79
78
|
${nextU32} = v.x;
|
|
80
79
|
${nextU32} = v.y;
|
|
81
80
|
}`,
|
|
82
|
-
vec3u: fn([vec3u])`(v)
|
|
81
|
+
vec3u: fn([vec3u])`(v) {
|
|
83
82
|
${nextU32} = v.x;
|
|
84
83
|
${nextU32} = v.y;
|
|
85
84
|
${nextU32} = v.z;
|
|
86
85
|
}`,
|
|
87
|
-
vec4u: fn([vec4u])`(v)
|
|
86
|
+
vec4u: fn([vec4u])`(v) {
|
|
88
87
|
${nextU32} = v.x;
|
|
89
88
|
${nextU32} = v.y;
|
|
90
89
|
${nextU32} = v.z;
|
|
91
90
|
${nextU32} = v.w;
|
|
92
91
|
}`,
|
|
93
|
-
"vec2<bool>": fn([vec2b])`(v)
|
|
92
|
+
"vec2<bool>": fn([vec2b])`(v) {
|
|
94
93
|
${nextU32} = u32(v.x);
|
|
95
94
|
${nextU32} = u32(v.y);
|
|
96
95
|
}`,
|
|
97
|
-
"vec3<bool>": fn([vec3b])`(v)
|
|
96
|
+
"vec3<bool>": fn([vec3b])`(v) {
|
|
98
97
|
${nextU32} = u32(v.x);
|
|
99
98
|
${nextU32} = u32(v.y);
|
|
100
99
|
${nextU32} = u32(v.z);
|
|
101
100
|
}`,
|
|
102
|
-
"vec4<bool>": fn([vec4b])`(v)
|
|
101
|
+
"vec4<bool>": fn([vec4b])`(v) {
|
|
103
102
|
${nextU32} = u32(v.x);
|
|
104
103
|
${nextU32} = u32(v.y);
|
|
105
104
|
${nextU32} = u32(v.z);
|
|
106
105
|
${nextU32} = u32(v.w);
|
|
107
106
|
}`,
|
|
108
|
-
mat2x2f: fn([mat2x2f])`(m)
|
|
107
|
+
mat2x2f: fn([mat2x2f])`(m) {
|
|
109
108
|
${nextU32} = bitcast<u32>(m[0][0]);
|
|
110
109
|
${nextU32} = bitcast<u32>(m[0][1]);
|
|
111
110
|
${nextU32} = bitcast<u32>(m[1][0]);
|
|
112
111
|
${nextU32} = bitcast<u32>(m[1][1]);
|
|
113
112
|
}`,
|
|
114
|
-
mat3x3f: fn([mat3x3f])`(m)
|
|
113
|
+
mat3x3f: fn([mat3x3f])`(m) {
|
|
115
114
|
${nextU32} = bitcast<u32>(m[0][0]);
|
|
116
115
|
${nextU32} = bitcast<u32>(m[0][1]);
|
|
117
116
|
${nextU32} = bitcast<u32>(m[0][2]);
|
|
@@ -125,7 +124,7 @@ const serializerMap = {
|
|
|
125
124
|
${nextU32} = bitcast<u32>(m[2][2]);
|
|
126
125
|
${nextU32} = 0u;
|
|
127
126
|
}`,
|
|
128
|
-
mat4x4f: fn([mat4x4f])`(m)
|
|
127
|
+
mat4x4f: fn([mat4x4f])`(m) {
|
|
129
128
|
${nextU32} = bitcast<u32>(m[0][0]);
|
|
130
129
|
${nextU32} = bitcast<u32>(m[0][1]);
|
|
131
130
|
${nextU32} = bitcast<u32>(m[0][2]);
|
|
@@ -220,6 +219,5 @@ function createLoggingFunction(id, dataTypes, dataBuffer, indexBuffer, logOption
|
|
|
220
219
|
compoundSerializer
|
|
221
220
|
}).$name(`log${id}`);
|
|
222
221
|
}
|
|
223
|
-
|
|
224
222
|
//#endregion
|
|
225
|
-
export { createLoggingFunction };
|
|
223
|
+
export { createLoggingFunction };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import "../../data/snippet.js";
|
|
2
1
|
import { TgpuMutable } from "../../core/buffer/bufferShorthand.js";
|
|
3
|
-
import "../generationHelpers.js";
|
|
4
2
|
import { AnyWgslData, Atomic, U32, WgslArray, WgslStruct } from "../../data/wgslTypes.js";
|
|
5
3
|
|
|
6
4
|
//#region src/tgsl/consoleLog/types.d.ts
|
package/tgsl/consoleLog/types.js
CHANGED
package/tgsl/conversion.js
CHANGED
|
@@ -8,7 +8,6 @@ import { RefOperator, derefSnippet } from "../data/ref.js";
|
|
|
8
8
|
import { schemaCallWrapperGPU } from "../data/schemaCallWrapper.js";
|
|
9
9
|
import { safeStringify } from "../shared/stringify.js";
|
|
10
10
|
import { assertExhaustive } from "../shared/utilityTypes.js";
|
|
11
|
-
|
|
12
11
|
//#region src/tgsl/conversion.ts
|
|
13
12
|
const INFINITE_RANK = {
|
|
14
13
|
rank: Number.POSITIVE_INFINITY,
|
|
@@ -195,6 +194,5 @@ function convertStructValues(ctx, structType, values) {
|
|
|
195
194
|
return convertToCommonType(ctx, [val], [targetType])?.[0] ?? val;
|
|
196
195
|
});
|
|
197
196
|
}
|
|
198
|
-
|
|
199
197
|
//#endregion
|
|
200
|
-
export { convertStructValues, convertToCommonType, getBestConversion, tryConvertSnippet, unify };
|
|
198
|
+
export { convertStructValues, convertToCommonType, getBestConversion, tryConvertSnippet, unify };
|
package/tgsl/forOfUtils.js
CHANGED
|
@@ -5,11 +5,11 @@ import { isEphemeralSnippet, snip } from "../data/snippet.js";
|
|
|
5
5
|
import { WgslTypeError, invariant } from "../errors.js";
|
|
6
6
|
import { stitch } from "../core/resolve/stitch.js";
|
|
7
7
|
import { createPtrFromOrigin, implicitFrom } from "../data/ptr.js";
|
|
8
|
-
import { u32 } from "../data/numeric.js";
|
|
8
|
+
import { i32, u32 } from "../data/numeric.js";
|
|
9
9
|
import { ArrayExpression, concretize } from "./generationHelpers.js";
|
|
10
10
|
import { accessIndex } from "./accessIndex.js";
|
|
11
11
|
import { arrayLength } from "../std/array.js";
|
|
12
|
-
|
|
12
|
+
import { isTgpuRange } from "../std/range.js";
|
|
13
13
|
//#region src/tgsl/forOfUtils.ts
|
|
14
14
|
function getLoopVarKind(elementSnippet) {
|
|
15
15
|
return elementSnippet.origin === "constant-tgpu-const-ref" ? "const" : "let";
|
|
@@ -30,16 +30,42 @@ function getElementType(elementSnippet, iterableSnippet) {
|
|
|
30
30
|
}
|
|
31
31
|
return implicitFrom(elementType);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function getRangeSnippets(ctx, iterableSnippet, unroll = false) {
|
|
34
34
|
const { value, dataType } = iterableSnippet;
|
|
35
|
-
if (
|
|
36
|
-
|
|
35
|
+
if (isTgpuRange(value)) return {
|
|
36
|
+
start: snip(value.start, i32, "constant"),
|
|
37
|
+
end: snip(value.end, i32, "constant"),
|
|
38
|
+
step: snip(value.step, i32, "constant"),
|
|
39
|
+
comparison: value.step < 0 ? ">" : "<"
|
|
40
|
+
};
|
|
41
|
+
if (!unroll && isEphemeralSnippet(iterableSnippet)) throw new Error(`\`for ... of ...\` loops only support std.range or iterables stored in variables.
|
|
42
|
+
-----
|
|
43
|
+
You can wrap iterable with \`tgpu.unroll(...)\`. If iterable is known at comptime, the loop will be unrolled.
|
|
44
|
+
-----`);
|
|
45
|
+
const defaults = {
|
|
46
|
+
start: snip(0, u32, "constant"),
|
|
47
|
+
step: snip(1, u32, "constant"),
|
|
48
|
+
comparison: "<"
|
|
49
|
+
};
|
|
50
|
+
if (isWgslArray(dataType)) return {
|
|
51
|
+
...defaults,
|
|
52
|
+
end: dataType.elementCount > 0 ? snip(dataType.elementCount, u32, "constant") : arrayLength[$gpuCallable].call(ctx, [iterableSnippet])
|
|
53
|
+
};
|
|
54
|
+
if (isVec(dataType)) return {
|
|
55
|
+
...defaults,
|
|
56
|
+
end: snip(dataType.componentCount, u32, "constant")
|
|
57
|
+
};
|
|
37
58
|
if (unroll) {
|
|
38
|
-
if (Array.isArray(value)) return
|
|
39
|
-
|
|
59
|
+
if (Array.isArray(value)) return {
|
|
60
|
+
...defaults,
|
|
61
|
+
end: snip(value.length, u32, "constant")
|
|
62
|
+
};
|
|
63
|
+
if (value instanceof ArrayExpression) return {
|
|
64
|
+
...defaults,
|
|
65
|
+
end: snip(value.elements.length, u32, "constant")
|
|
66
|
+
};
|
|
40
67
|
}
|
|
41
68
|
throw new WgslTypeError("`for ... of ...` loops only support array or vector iterables");
|
|
42
69
|
}
|
|
43
|
-
|
|
44
70
|
//#endregion
|
|
45
|
-
export {
|
|
71
|
+
export { getElementSnippet, getElementType, getLoopVarKind, getRangeSnippets };
|