typegpu 0.11.1 → 0.11.2
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 → rolldown_runtime.js} +4 -4
- package/builtin.js +3 -1
- package/common/fullScreenTriangle.d.ts +6 -1
- package/common/fullScreenTriangle.js +3 -1
- package/common/index.js +5 -3
- package/common/writeSoA.js +3 -1
- package/core/buffer/buffer.d.ts +3 -0
- package/core/buffer/buffer.js +5 -3
- package/core/buffer/bufferShorthand.d.ts +2 -0
- package/core/buffer/bufferShorthand.js +3 -1
- package/core/buffer/bufferUsage.d.ts +2 -0
- package/core/buffer/bufferUsage.js +3 -1
- package/core/constant/tgpuConstant.d.ts +2 -1
- package/core/constant/tgpuConstant.js +3 -1
- package/core/declare/tgpuDeclare.js +3 -1
- package/core/function/autoIO.d.ts +3 -0
- package/core/function/autoIO.js +3 -1
- package/core/function/comptime.js +3 -1
- package/core/function/createCallableSchema.js +3 -1
- package/core/function/dualImpl.js +3 -1
- package/core/function/entryInputRouter.js +3 -1
- package/core/function/extractArgs.js +2 -1
- package/core/function/fnCore.js +8 -6
- package/core/function/fnTypes.d.ts +2 -0
- package/core/function/ioSchema.d.ts +1 -0
- package/core/function/ioSchema.js +3 -1
- package/core/function/shelllessImpl.d.ts +1 -0
- package/core/function/shelllessImpl.js +3 -1
- package/core/function/templateUtils.js +2 -1
- package/core/function/tgpuComputeFn.d.ts +1 -0
- package/core/function/tgpuComputeFn.js +3 -1
- package/core/function/tgpuFn.d.ts +1 -0
- package/core/function/tgpuFn.js +16 -14
- package/core/function/tgpuFragmentFn.js +3 -1
- package/core/function/tgpuVertexFn.js +3 -1
- package/core/pipeline/applyPipelineState.js +3 -1
- package/core/pipeline/computePipeline.d.ts +4 -0
- package/core/pipeline/computePipeline.js +8 -6
- package/core/pipeline/connectAttachmentToShader.js +3 -1
- package/core/pipeline/connectTargetsToShader.js +3 -1
- package/core/pipeline/limitsOverflow.js +2 -1
- package/core/pipeline/pipelineUtils.js +6 -4
- package/core/pipeline/renderPipeline.js +21 -19
- package/core/pipeline/timeable.d.ts +2 -0
- package/core/pipeline/timeable.js +3 -1
- package/core/pipeline/typeGuards.js +3 -1
- package/core/querySet/querySet.d.ts +2 -0
- package/core/querySet/querySet.js +3 -1
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +1 -0
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +3 -1
- package/core/resolve/externals.d.ts +3 -0
- package/core/resolve/externals.js +7 -5
- package/core/resolve/namespace.js +6 -4
- package/core/resolve/resolveData.js +3 -1
- package/core/resolve/stitch.js +3 -1
- package/core/resolve/tgpuResolve.js +7 -5
- package/core/root/configurableImpl.js +3 -1
- package/core/root/init.d.ts +10 -2
- package/core/root/init.js +4 -2
- package/core/root/rootTypes.d.ts +11 -11
- package/core/sampler/sampler.d.ts +4 -0
- package/core/sampler/sampler.js +3 -1
- package/core/simulate/tgpuSimulate.js +6 -4
- package/core/slot/accessor.d.ts +4 -0
- package/core/slot/accessor.js +3 -1
- package/core/slot/internalSlots.js +3 -1
- package/core/slot/lazy.js +3 -1
- package/core/slot/slot.js +3 -1
- package/core/slot/slotTypes.js +3 -1
- package/core/texture/externalTexture.d.ts +6 -0
- package/core/texture/externalTexture.js +3 -1
- package/core/texture/texture.d.ts +4 -0
- package/core/texture/texture.js +6 -4
- package/core/texture/textureFormats.js +3 -1
- package/core/texture/textureUtils.js +3 -1
- package/core/texture/usageExtension.js +3 -1
- package/core/unroll/tgpuUnroll.d.ts +3 -1
- package/core/unroll/tgpuUnroll.js +3 -1
- package/core/valueProxyUtils.js +7 -5
- package/core/variable/tgpuVariable.d.ts +3 -1
- package/core/variable/tgpuVariable.js +3 -1
- package/core/vertexLayout/connectAttributesToShader.js +3 -1
- package/core/vertexLayout/vertexAttribute.d.ts +1 -0
- package/core/vertexLayout/vertexLayout.js +7 -5
- package/data/alignIO.js +3 -1
- package/data/alignmentOf.d.ts +2 -0
- package/data/alignmentOf.js +3 -1
- package/data/array.js +3 -1
- package/data/atomic.d.ts +1 -0
- package/data/atomic.js +3 -1
- package/data/attributes.js +7 -5
- package/data/autoStruct.d.ts +3 -1
- package/data/autoStruct.js +3 -1
- package/data/compiledIO.js +39 -37
- package/data/dataIO.js +22 -20
- package/data/dataTypes.d.ts +9 -4
- package/data/dataTypes.js +3 -1
- package/data/deepEqual.d.ts +1 -0
- package/data/deepEqual.js +3 -1
- package/data/disarray.d.ts +3 -1
- package/data/disarray.js +3 -1
- package/data/getLongestContiguousPrefix.d.ts +2 -0
- package/data/getLongestContiguousPrefix.js +3 -1
- package/data/index.js +5 -6
- package/data/isContiguous.d.ts +2 -0
- package/data/isContiguous.js +3 -1
- package/data/matrix.d.ts +11 -8
- package/data/matrix.js +3 -1
- package/data/numberOps.js +2 -1
- package/data/numeric.d.ts +1 -0
- package/data/numeric.js +3 -1
- package/data/offsetUtils.d.ts +1 -0
- package/data/offsetUtils.js +3 -1
- package/data/offsets.js +5 -3
- package/data/partialIO.js +3 -1
- package/data/ptr.d.ts +1 -0
- package/data/ptr.js +3 -1
- package/data/ref.d.ts +3 -0
- package/data/ref.js +5 -3
- package/data/sampler.js +3 -1
- package/data/schemaCallWrapper.js +3 -1
- package/data/schemaMemoryLayout.js +3 -1
- package/data/sizeOf.d.ts +2 -0
- package/data/sizeOf.js +3 -1
- package/data/snippet.js +3 -1
- package/data/struct.d.ts +1 -0
- package/data/struct.js +3 -1
- package/data/texture.js +3 -1
- package/data/unstruct.d.ts +1 -0
- package/data/unstruct.js +3 -1
- package/data/vector.d.ts +1 -0
- package/data/vector.js +3 -1
- package/data/vectorImpl.js +3 -1
- package/data/vectorOps.js +3 -1
- package/data/vertexFormatData.js +3 -1
- package/data/wgslTypes.d.ts +2 -0
- package/data/wgslTypes.js +3 -1
- package/errors.d.ts +1 -0
- package/errors.js +3 -1
- package/execMode.js +3 -1
- package/extension.d.ts +1 -0
- package/extension.js +3 -1
- package/getGPUValue.js +3 -1
- package/index.js +3 -4
- package/indexNamedExports.d.ts +1 -0
- package/mathUtils.js +2 -1
- package/memo.js +2 -1
- package/nameRegistry.js +3 -1
- package/package.js +3 -2
- package/package.json +1 -1
- package/resolutionCtx.d.ts +11 -0
- package/resolutionCtx.js +6 -4
- package/shared/env.js +2 -1
- package/shared/generators.js +2 -1
- package/shared/meta.js +3 -1
- package/shared/repr.d.ts +1 -0
- package/shared/stringify.js +3 -1
- package/shared/symbols.js +42 -10
- package/shared/utilityTypes.js +2 -1
- package/shared/vertexFormat.js +2 -1
- package/std/array.d.ts +1 -1
- package/std/array.js +3 -1
- package/std/atomic.d.ts +12 -12
- package/std/atomic.js +3 -1
- package/std/bitcast.d.ts +2 -2
- package/std/bitcast.js +3 -1
- package/std/boolean.d.ts +15 -14
- package/std/boolean.js +3 -1
- package/std/derivative.d.ts +9 -9
- package/std/derivative.js +3 -1
- package/std/discard.d.ts +1 -1
- package/std/discard.js +3 -1
- package/std/extensions.d.ts +3 -1
- package/std/extensions.js +3 -1
- package/std/index.js +5 -3
- package/std/matrix.d.ts +6 -5
- package/std/matrix.js +3 -1
- package/std/numeric.d.ts +132 -78
- package/std/numeric.js +7 -5
- package/std/operators.d.ts +8 -8
- package/std/operators.js +7 -5
- package/std/packing.d.ts +5 -4
- package/std/packing.js +3 -1
- package/std/range.d.ts +3 -1
- package/std/range.js +3 -1
- package/std/subgroup.d.ts +21 -21
- package/std/subgroup.js +3 -1
- package/std/texture.d.ts +11 -11
- package/std/texture.js +9 -7
- package/tgpu.js +5 -3
- package/tgpuBindGroupLayout.d.ts +11 -7
- package/tgpuBindGroupLayout.js +3 -1
- package/tgpuUnstable.js +5 -3
- package/tgsl/accessIndex.js +3 -1
- package/tgsl/accessProp.js +3 -1
- package/tgsl/consoleLog/deserializers.js +3 -1
- package/tgsl/consoleLog/logGenerator.js +3 -1
- package/tgsl/consoleLog/serializers.js +3 -1
- package/tgsl/consoleLog/types.d.ts +3 -0
- package/tgsl/consoleLog/types.js +2 -1
- package/tgsl/conversion.js +3 -1
- package/tgsl/forOfUtils.js +3 -1
- package/tgsl/generationHelpers.d.ts +1 -0
- package/tgsl/generationHelpers.js +3 -1
- package/tgsl/math.js +3 -1
- package/tgsl/shaderGenerator.d.ts +2 -0
- package/tgsl/shaderGenerator_members.js +5 -3
- package/tgsl/shellless.js +3 -1
- package/tgsl/wgslGenerator.js +21 -18
- package/types.d.ts +0 -1
- package/types.js +3 -1
- package/wgslExtensions.js +2 -1
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<typeof sampleCpu>;
|
|
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<typeof sampleBiasCpu>;
|
|
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<typeof sampleLevelCpu>;
|
|
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<typeof textureLoadCpu>;
|
|
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<typeof textureStoreCpu>;
|
|
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<typeof textureDimensionsCpu>;
|
|
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,21 +87,21 @@ type TextureGatherCpuFn = {
|
|
|
87
87
|
(...args: GatherDepthCubeArgs): v4f;
|
|
88
88
|
(...args: GatherDepthCubeArrayArgs): v4f;
|
|
89
89
|
};
|
|
90
|
-
declare const textureGather: DualFn
|
|
90
|
+
declare const textureGather: DualFn<TextureGatherCpuFn>;
|
|
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<typeof textureSampleCompareCpu>;
|
|
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<typeof textureSampleCompareLevelCpu>;
|
|
105
105
|
declare function textureSampleBaseClampToEdgeCpu<T extends texture2d | textureExternal>(_texture: T, _sampler: sampler, _coords: v2f): v4f;
|
|
106
106
|
declare function sampleGradCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, ddx: v2f, ddy: v2f): v4f;
|
|
107
107
|
declare function sampleGradCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, ddx: v2f, ddy: v2f, offset: v2i): v4f;
|
|
@@ -111,7 +111,7 @@ declare function sampleGradCpu<T extends texture3d>(texture: T, sampler: sampler
|
|
|
111
111
|
declare function sampleGradCpu<T extends texture3d>(texture: T, sampler: sampler, coords: v3f, ddx: v3f, ddy: v3f, offset: v3i): v4f;
|
|
112
112
|
declare function sampleGradCpu<T extends textureCube>(texture: T, sampler: sampler, coords: v3f, ddx: v3f, ddy: v3f): v4f;
|
|
113
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
|
|
114
|
+
declare const textureSampleGrad: DualFn<typeof sampleGradCpu>;
|
|
115
|
+
declare const textureSampleBaseClampToEdge: DualFn<typeof textureSampleBaseClampToEdgeCpu>;
|
|
116
116
|
//#endregion
|
|
117
117
|
export { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleGrad, textureSampleLevel, textureStore };
|
package/std/texture.js
CHANGED
|
@@ -5,6 +5,7 @@ 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
|
+
|
|
8
9
|
//#region src/std/texture.ts
|
|
9
10
|
function sampleCpu(_texture, _sampler, _coords, _offsetOrArrayIndex, _maybeOffset) {
|
|
10
11
|
throw new MissingCpuImplError("Texture sampling relies on GPU resources and cannot be executed outside of a draw call");
|
|
@@ -123,14 +124,14 @@ const textureGather = dualImpl({
|
|
|
123
124
|
codegenImpl: (_ctx, args) => stitch`textureGather(${args})`,
|
|
124
125
|
signature: (...args) => {
|
|
125
126
|
if (args[0].type.startsWith("texture")) {
|
|
126
|
-
const [texture, sampler, coords, _, ...rest] = args;
|
|
127
|
+
const [texture$1, sampler$1, coords$1, _$1, ...rest$1] = args;
|
|
127
128
|
return {
|
|
128
|
-
argTypes: texture.type === "texture_depth_2d_array" || texture.type === "texture_depth_cube_array" ? [
|
|
129
|
-
texture,
|
|
130
|
-
sampler,
|
|
131
|
-
coords,
|
|
129
|
+
argTypes: texture$1.type === "texture_depth_2d_array" || texture$1.type === "texture_depth_cube_array" ? [
|
|
130
|
+
texture$1,
|
|
131
|
+
sampler$1,
|
|
132
|
+
coords$1,
|
|
132
133
|
[u32, i32],
|
|
133
|
-
...rest
|
|
134
|
+
...rest$1
|
|
134
135
|
] : args,
|
|
135
136
|
returnType: vec4f
|
|
136
137
|
};
|
|
@@ -203,5 +204,6 @@ const textureSampleBaseClampToEdge = dualImpl({
|
|
|
203
204
|
returnType: vec4f
|
|
204
205
|
})
|
|
205
206
|
});
|
|
207
|
+
|
|
206
208
|
//#endregion
|
|
207
|
-
export { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleGrad, textureSampleLevel, textureStore };
|
|
209
|
+
export { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleGrad, textureSampleLevel, textureStore };
|
package/tgpu.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __export } from "./_virtual/rolldown_runtime.js";
|
|
2
2
|
import { comptime } from "./core/function/comptime.js";
|
|
3
3
|
import { constant } from "./core/constant/tgpuConstant.js";
|
|
4
4
|
import { fn } from "./core/function/tgpuFn.js";
|
|
@@ -15,8 +15,9 @@ 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
|
+
|
|
18
19
|
//#region src/tgpu.ts
|
|
19
|
-
var tgpu_exports = /* @__PURE__ */
|
|
20
|
+
var tgpu_exports = /* @__PURE__ */ __export({
|
|
20
21
|
accessor: () => accessor,
|
|
21
22
|
bindGroupLayout: () => bindGroupLayout,
|
|
22
23
|
comptime: () => comptime,
|
|
@@ -38,5 +39,6 @@ var tgpu_exports = /* @__PURE__ */ __exportAll({
|
|
|
38
39
|
workgroupVar: () => workgroupVar,
|
|
39
40
|
"~unstable": () => tgpuUnstable_exports
|
|
40
41
|
});
|
|
42
|
+
|
|
41
43
|
//#endregion
|
|
42
|
-
export { tgpu_exports };
|
|
44
|
+
export { tgpu_exports };
|
package/tgpuBindGroupLayout.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { PropsForSchema, TgpuTexture, TgpuTextureView } from "./core/texture/tex
|
|
|
17
17
|
import { InferGPU, MemIdentity } from "./shared/repr.js";
|
|
18
18
|
|
|
19
19
|
//#region src/tgpuBindGroupLayout.d.ts
|
|
20
|
+
|
|
20
21
|
type TgpuLayoutEntryBase = {
|
|
21
22
|
/**
|
|
22
23
|
* Limits this resource's visibility to specific shader stages.
|
|
@@ -33,7 +34,8 @@ type TgpuLayoutUniform = TgpuLayoutEntryBase & {
|
|
|
33
34
|
uniform: BaseData;
|
|
34
35
|
};
|
|
35
36
|
type TgpuLayoutStorage = TgpuLayoutEntryBase & {
|
|
36
|
-
storage: BaseData | ((arrayLength: number) => BaseData);
|
|
37
|
+
storage: BaseData | ((arrayLength: number) => BaseData);
|
|
38
|
+
/** @default 'readonly' */
|
|
37
39
|
access?: 'mutable' | 'readonly';
|
|
38
40
|
};
|
|
39
41
|
type TgpuLayoutSampler = TgpuLayoutEntryBase & {
|
|
@@ -42,12 +44,12 @@ type TgpuLayoutSampler = TgpuLayoutEntryBase & {
|
|
|
42
44
|
type TgpuLayoutComparisonSampler = TgpuLayoutEntryBase & {
|
|
43
45
|
sampler: 'comparison';
|
|
44
46
|
};
|
|
45
|
-
type TgpuLayoutTexture<TSchema extends WgslTexture = WgslTexture> = TgpuLayoutEntryBase & {
|
|
46
|
-
texture: TSchema;
|
|
47
|
+
type TgpuLayoutTexture<TSchema$1 extends WgslTexture = WgslTexture> = TgpuLayoutEntryBase & {
|
|
48
|
+
texture: TSchema$1;
|
|
47
49
|
sampleType?: GPUTextureSampleType;
|
|
48
50
|
};
|
|
49
|
-
type TgpuLayoutStorageTexture<TSchema extends WgslStorageTexture = WgslStorageTexture> = TgpuLayoutEntryBase & {
|
|
50
|
-
storageTexture: TSchema;
|
|
51
|
+
type TgpuLayoutStorageTexture<TSchema$1 extends WgslStorageTexture = WgslStorageTexture> = TgpuLayoutEntryBase & {
|
|
52
|
+
storageTexture: TSchema$1;
|
|
51
53
|
};
|
|
52
54
|
type TgpuLayoutExternalTexture = TgpuLayoutEntryBase & {
|
|
53
55
|
externalTexture: WgslExternalTexture;
|
|
@@ -71,8 +73,10 @@ type TgpuLegacyLayoutTexture<TSampleType extends GPUTextureSampleType = GPUTextu
|
|
|
71
73
|
multisampled?: boolean;
|
|
72
74
|
};
|
|
73
75
|
type TgpuLegacyLayoutStorageTexture<TFormat extends StorageTextureFormats = StorageTextureFormats> = TgpuLayoutEntryBase & {
|
|
74
|
-
storageTexture: TFormat;
|
|
75
|
-
|
|
76
|
+
storageTexture: TFormat;
|
|
77
|
+
/** @default 'writeonly' */
|
|
78
|
+
access?: 'readonly' | 'writeonly' | 'mutable';
|
|
79
|
+
/** @default '2d' */
|
|
76
80
|
viewDimension?: StorageTextureDimension;
|
|
77
81
|
};
|
|
78
82
|
type TgpuLegacyLayoutExternalTexture = TgpuLayoutEntryBase & {
|
package/tgpuBindGroupLayout.js
CHANGED
|
@@ -12,6 +12,7 @@ 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
|
+
|
|
15
16
|
//#region src/tgpuBindGroupLayout.ts
|
|
16
17
|
/**
|
|
17
18
|
* Converts legacy entries to new API format
|
|
@@ -268,5 +269,6 @@ var TgpuBindGroupImpl = class {
|
|
|
268
269
|
});
|
|
269
270
|
}
|
|
270
271
|
};
|
|
272
|
+
|
|
271
273
|
//#endregion
|
|
272
|
-
export { TgpuBindGroupImpl, bindGroupLayout, isBindGroup, isBindGroupLayout };
|
|
274
|
+
export { TgpuBindGroupImpl, bindGroupLayout, isBindGroup, isBindGroupLayout };
|
package/tgpuUnstable.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __export } from "./_virtual/rolldown_runtime.js";
|
|
2
2
|
import { comptime } from "./core/function/comptime.js";
|
|
3
3
|
import { constant } from "./core/constant/tgpuConstant.js";
|
|
4
4
|
import { fn } from "./core/function/tgpuFn.js";
|
|
@@ -14,8 +14,9 @@ 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
|
+
|
|
17
18
|
//#region src/tgpuUnstable.ts
|
|
18
|
-
var tgpuUnstable_exports = /* @__PURE__ */
|
|
19
|
+
var tgpuUnstable_exports = /* @__PURE__ */ __export({
|
|
19
20
|
accessor: () => _accessor,
|
|
20
21
|
comptime: () => _comptime,
|
|
21
22
|
computeFn: () => _computeFn,
|
|
@@ -60,5 +61,6 @@ const _privateVar = privateVar;
|
|
|
60
61
|
const _workgroupVar = workgroupVar;
|
|
61
62
|
/** @deprecated This feature is now stable, use tgpu.vertexLayout. */
|
|
62
63
|
const _vertexLayout = vertexLayout;
|
|
64
|
+
|
|
63
65
|
//#endregion
|
|
64
|
-
export { tgpuUnstable_exports };
|
|
66
|
+
export { tgpuUnstable_exports };
|
package/tgsl/accessIndex.js
CHANGED
|
@@ -7,6 +7,7 @@ import { derefSnippet } from "../data/ref.js";
|
|
|
7
7
|
import { coerceToSnippet } from "./generationHelpers.js";
|
|
8
8
|
import { vec2f, vec3f, vec4f } from "../data/vector.js";
|
|
9
9
|
import { accessProp } from "./accessProp.js";
|
|
10
|
+
|
|
10
11
|
//#region src/tgsl/accessIndex.ts
|
|
11
12
|
const indexableTypeToResult = {
|
|
12
13
|
mat2x2f: vec2f,
|
|
@@ -39,5 +40,6 @@ function accessIndex(target, indexArg) {
|
|
|
39
40
|
if (isKnownAtComptime(target) && isKnownAtComptime(index) || target.dataType === UnknownData) return coerceToSnippet(target.value[index.value]);
|
|
40
41
|
if (isWgslStruct(target.dataType) && isKnownAtComptime(index) && typeof index.value === "string") return accessProp(target, index.value);
|
|
41
42
|
}
|
|
43
|
+
|
|
42
44
|
//#endregion
|
|
43
|
-
export { accessIndex };
|
|
45
|
+
export { accessIndex };
|
package/tgsl/accessProp.js
CHANGED
|
@@ -11,6 +11,7 @@ import { vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, v
|
|
|
11
11
|
import { AutoStruct } from "../data/autoStruct.js";
|
|
12
12
|
import { EntryInputRouter } from "../core/function/entryInputRouter.js";
|
|
13
13
|
import { add, bitShiftLeft, bitShiftRight, div, mod, mul, sub } from "../std/operators.js";
|
|
14
|
+
|
|
14
15
|
//#region src/tgsl/accessProp.ts
|
|
15
16
|
const infixKinds = [
|
|
16
17
|
"vec2f",
|
|
@@ -111,5 +112,6 @@ function accessProp(target, propName) {
|
|
|
111
112
|
}
|
|
112
113
|
if (isKnownAtComptime(target) || target.dataType === UnknownData) return coerceToSnippet(target.value[propName]);
|
|
113
114
|
}
|
|
115
|
+
|
|
114
116
|
//#endregion
|
|
115
|
-
export { accessProp, infixOperators };
|
|
117
|
+
export { accessProp, infixOperators };
|
|
@@ -5,6 +5,7 @@ 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
|
+
|
|
8
9
|
//#region src/tgsl/consoleLog/deserializers.ts
|
|
9
10
|
const toF = (n) => bitcastU32toF32(n ?? 0);
|
|
10
11
|
const toI = (n) => bitcastU32toI32(n ?? 0);
|
|
@@ -111,5 +112,6 @@ function logDataFromGPU(resources) {
|
|
|
111
112
|
dataBuffer.buffer.clear();
|
|
112
113
|
indexBuffer.buffer.clear();
|
|
113
114
|
}
|
|
115
|
+
|
|
114
116
|
//#endregion
|
|
115
|
-
export { logDataFromGPU };
|
|
117
|
+
export { logDataFromGPU };
|
|
@@ -11,6 +11,7 @@ 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
|
+
|
|
14
15
|
//#region src/tgsl/consoleLog/logGenerator.ts
|
|
15
16
|
const defaultOptions = {
|
|
16
17
|
logCountLimit: 64,
|
|
@@ -80,5 +81,6 @@ var LogGeneratorImpl = class {
|
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
83
|
};
|
|
84
|
+
|
|
83
85
|
//#endregion
|
|
84
|
-
export { LogGeneratorImpl, LogGeneratorNullImpl };
|
|
86
|
+
export { LogGeneratorImpl, LogGeneratorNullImpl };
|
|
@@ -7,6 +7,7 @@ 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
|
+
|
|
10
11
|
//#region src/tgsl/consoleLog/serializers.ts
|
|
11
12
|
const dataBlockIndex = privateVar(u32, 0).$name("dataBlockIndex");
|
|
12
13
|
const dataByteIndex = privateVar(u32, 0).$name("dataByteIndex");
|
|
@@ -219,5 +220,6 @@ function createLoggingFunction(id, dataTypes, dataBuffer, indexBuffer, logOption
|
|
|
219
220
|
compoundSerializer
|
|
220
221
|
}).$name(`log${id}`);
|
|
221
222
|
}
|
|
223
|
+
|
|
222
224
|
//#endregion
|
|
223
|
-
export { createLoggingFunction };
|
|
225
|
+
export { createLoggingFunction };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import "../../data/snippet.js";
|
|
1
2
|
import { TgpuMutable } from "../../core/buffer/bufferShorthand.js";
|
|
3
|
+
import "../generationHelpers.js";
|
|
2
4
|
import { AnyWgslData, Atomic, U32, WgslArray, WgslStruct } from "../../data/wgslTypes.js";
|
|
3
5
|
|
|
4
6
|
//#region src/tgsl/consoleLog/types.d.ts
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* Options for configuring GPU log generation.
|
|
7
10
|
*/
|
package/tgsl/consoleLog/types.js
CHANGED
package/tgsl/conversion.js
CHANGED
|
@@ -8,6 +8,7 @@ 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
|
+
|
|
11
12
|
//#region src/tgsl/conversion.ts
|
|
12
13
|
const INFINITE_RANK = {
|
|
13
14
|
rank: Number.POSITIVE_INFINITY,
|
|
@@ -194,5 +195,6 @@ function convertStructValues(ctx, structType, values) {
|
|
|
194
195
|
return convertToCommonType(ctx, [val], [targetType])?.[0] ?? val;
|
|
195
196
|
});
|
|
196
197
|
}
|
|
198
|
+
|
|
197
199
|
//#endregion
|
|
198
|
-
export { convertStructValues, convertToCommonType, getBestConversion, tryConvertSnippet, unify };
|
|
200
|
+
export { convertStructValues, convertToCommonType, getBestConversion, tryConvertSnippet, unify };
|
package/tgsl/forOfUtils.js
CHANGED
|
@@ -10,6 +10,7 @@ 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
14
|
//#region src/tgsl/forOfUtils.ts
|
|
14
15
|
function getLoopVarKind(elementSnippet) {
|
|
15
16
|
return elementSnippet.origin === "constant-tgpu-const-ref" ? "const" : "let";
|
|
@@ -67,5 +68,6 @@ You can wrap iterable with \`tgpu.unroll(...)\`. If iterable is known at comptim
|
|
|
67
68
|
}
|
|
68
69
|
throw new WgslTypeError("`for ... of ...` loops only support array or vector iterables");
|
|
69
70
|
}
|
|
71
|
+
|
|
70
72
|
//#endregion
|
|
71
|
-
export { getElementSnippet, getElementType, getLoopVarKind, getRangeSnippets };
|
|
73
|
+
export { getElementSnippet, getElementType, getLoopVarKind, getRangeSnippets };
|
|
@@ -7,6 +7,7 @@ import { getOwnSnippet } from "../types.js";
|
|
|
7
7
|
import { stitch } from "../core/resolve/stitch.js";
|
|
8
8
|
import { isRef } from "../data/ref.js";
|
|
9
9
|
import { abstractFloat, abstractInt, bool, f32, i32 } from "../data/numeric.js";
|
|
10
|
+
|
|
10
11
|
//#region src/tgsl/generationHelpers.ts
|
|
11
12
|
function numericLiteralToSnippet(value) {
|
|
12
13
|
if (value >= 2 ** 63 || value < -(2 ** 63)) return snip(value, abstractFloat, "constant");
|
|
@@ -63,5 +64,6 @@ var ArrayExpression = class {
|
|
|
63
64
|
return snip(stitch`${`array<${ctx.resolve(this.type.elementType).value}, ${this.elements.length}>`}(${this.elements})`, this.type, "runtime");
|
|
64
65
|
}
|
|
65
66
|
};
|
|
67
|
+
|
|
66
68
|
//#endregion
|
|
67
|
-
export { ArrayExpression, coerceToSnippet, concretize, concretizeSnippets, numericLiteralToSnippet };
|
|
69
|
+
export { ArrayExpression, coerceToSnippet, concretize, concretizeSnippets, numericLiteralToSnippet };
|
package/tgsl/math.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { f32 } from "../data/numeric.js";
|
|
2
2
|
import { abs, acos, acosh, asin, asinh, atan, atan2, atanh, ceil, cos, cosh, countLeadingZeros, exp, floor, log, log2, max, min, pow, sign, sin, sinh, sqrt, tan, tanh, trunc } from "../std/numeric.js";
|
|
3
|
+
|
|
3
4
|
//#region src/tgsl/math.ts
|
|
4
5
|
const mathToStd = {
|
|
5
6
|
abs,
|
|
@@ -39,5 +40,6 @@ const mathToStd = {
|
|
|
39
40
|
imul: void 0,
|
|
40
41
|
round: void 0
|
|
41
42
|
};
|
|
43
|
+
|
|
42
44
|
//#endregion
|
|
43
|
-
export { mathToStd };
|
|
45
|
+
export { mathToStd };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ResolvedSnippet, Snippet } from "../data/snippet.js";
|
|
2
2
|
import { GenerationCtx } from "./generationHelpers.js";
|
|
3
|
+
import "./shaderGenerator_members.js";
|
|
3
4
|
import { BaseData } from "../data/wgslTypes.js";
|
|
4
5
|
import { Block } from "tinyest";
|
|
5
6
|
|
|
6
7
|
//#region src/tgsl/shaderGenerator.d.ts
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* **NOTE: This is an unstable API and may change in the future.**
|
|
9
11
|
*
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __export } from "../_virtual/rolldown_runtime.js";
|
|
2
2
|
import { UnknownData } from "../data/dataTypes.js";
|
|
3
|
+
|
|
3
4
|
//#region src/tgsl/shaderGenerator_members.ts
|
|
4
|
-
var shaderGenerator_members_exports = /* @__PURE__ */
|
|
5
|
+
var shaderGenerator_members_exports = /* @__PURE__ */ __export({ UnknownData: () => UnknownData });
|
|
6
|
+
|
|
5
7
|
//#endregion
|
|
6
|
-
export { shaderGenerator_members_exports };
|
|
8
|
+
export { shaderGenerator_members_exports };
|
package/tgsl/shellless.js
CHANGED
|
@@ -5,6 +5,7 @@ import { WgslTypeError } from "../errors.js";
|
|
|
5
5
|
import { RefOperator } from "../data/ref.js";
|
|
6
6
|
import { concretize } from "./generationHelpers.js";
|
|
7
7
|
import { createShelllessImpl } from "../core/function/shelllessImpl.js";
|
|
8
|
+
|
|
8
9
|
//#region src/tgsl/shellless.ts
|
|
9
10
|
function shallowEqualSchemas(a, b) {
|
|
10
11
|
if (a.type !== b.type) return false;
|
|
@@ -42,5 +43,6 @@ var ShelllessRepository = class {
|
|
|
42
43
|
return shellless;
|
|
43
44
|
}
|
|
44
45
|
};
|
|
46
|
+
|
|
45
47
|
//#endregion
|
|
46
|
-
export { ShelllessRepository };
|
|
48
|
+
export { ShelllessRepository };
|
package/tgsl/wgslGenerator.js
CHANGED
|
@@ -27,6 +27,7 @@ import { mathToStd } from "./math.js";
|
|
|
27
27
|
import { isTgpuRange } from "../std/range.js";
|
|
28
28
|
import { getElementSnippet, getElementType, getLoopVarKind, getRangeSnippets } from "./forOfUtils.js";
|
|
29
29
|
import * as tinyest from "tinyest";
|
|
30
|
+
|
|
30
31
|
//#region src/tgsl/wgslGenerator.ts
|
|
31
32
|
const { NodeTypeCatalog: NODE } = tinyest;
|
|
32
33
|
const parenthesizedOps = [
|
|
@@ -215,12 +216,12 @@ ${this.ctx.pre}}`;
|
|
|
215
216
|
const lhsExpr = this._expression(lhs);
|
|
216
217
|
if ((op === "||" || op === "&&") && isKnownAtComptime(lhsExpr)) {
|
|
217
218
|
if (!(op === "&&" ? lhsExpr.value : !lhsExpr.value)) return snip(op === "||", bool, "constant");
|
|
218
|
-
const rhsExpr = this._expression(rhs);
|
|
219
|
-
if (rhsExpr.dataType === UnknownData) throw new WgslTypeError(`Right-hand side of '${op}' is of unknown type`);
|
|
220
|
-
if (isKnownAtComptime(rhsExpr)) return snip(!!rhsExpr.value, bool, "constant");
|
|
221
|
-
const convRhs = tryConvertSnippet(this.ctx, rhsExpr, bool, false);
|
|
222
|
-
const rhsStr = this.ctx.resolve(convRhs.value, convRhs.dataType).value;
|
|
223
|
-
return snip(rhsStr, bool, "runtime");
|
|
219
|
+
const rhsExpr$1 = this._expression(rhs);
|
|
220
|
+
if (rhsExpr$1.dataType === UnknownData) throw new WgslTypeError(`Right-hand side of '${op}' is of unknown type`);
|
|
221
|
+
if (isKnownAtComptime(rhsExpr$1)) return snip(!!rhsExpr$1.value, bool, "constant");
|
|
222
|
+
const convRhs$1 = tryConvertSnippet(this.ctx, rhsExpr$1, bool, false);
|
|
223
|
+
const rhsStr$1 = this.ctx.resolve(convRhs$1.value, convRhs$1.dataType).value;
|
|
224
|
+
return snip(rhsStr$1, bool, "runtime");
|
|
224
225
|
}
|
|
225
226
|
const rhsExpr = this._expression(rhs);
|
|
226
227
|
if (rhsExpr.value instanceof RefOperator) throw new WgslTypeError(stitch`Cannot assign a ref to an existing variable '${lhsExpr}', define a new variable instead.`);
|
|
@@ -439,8 +440,8 @@ ${this.ctx.pre}}`;
|
|
|
439
440
|
_statement(statement) {
|
|
440
441
|
if (typeof statement === "string") {
|
|
441
442
|
const id = this._identifier(statement);
|
|
442
|
-
const resolved = id.value && this.ctx.resolve(id.value).value;
|
|
443
|
-
return resolved ? `${this.ctx.pre}${resolved};` : "";
|
|
443
|
+
const resolved$1 = id.value && this.ctx.resolve(id.value).value;
|
|
444
|
+
return resolved$1 ? `${this.ctx.pre}${resolved$1};` : "";
|
|
444
445
|
}
|
|
445
446
|
if (typeof statement === "boolean") return `${this.ctx.pre}${statement ? "true" : "false"};`;
|
|
446
447
|
if (statement[0] === NODE.return) {
|
|
@@ -500,12 +501,12 @@ ${this.ctx.pre}else ${alternate}`;
|
|
|
500
501
|
}
|
|
501
502
|
if (!ephemeral) {
|
|
502
503
|
if (stmtType === NODE.let) {
|
|
503
|
-
const rhsStr = this.ctx.resolve(eq.value).value;
|
|
504
|
+
const rhsStr$1 = this.ctx.resolve(eq.value).value;
|
|
504
505
|
const rhsTypeStr = this.ctx.resolve(unptr(eq.dataType)).value;
|
|
505
|
-
throw new WgslTypeError(`'let ${rawId} = ${rhsStr}' is invalid, because references cannot be assigned to 'let' variable declarations.
|
|
506
|
+
throw new WgslTypeError(`'let ${rawId} = ${rhsStr$1}' is invalid, because references cannot be assigned to 'let' variable declarations.
|
|
506
507
|
-----
|
|
507
|
-
- Try 'let ${rawId} = ${rhsTypeStr}(${rhsStr})' if you need to reassign '${rawId}' later
|
|
508
|
-
- Try 'const ${rawId} = ${rhsStr}' if you won't reassign '${rawId}' later.
|
|
508
|
+
- Try 'let ${rawId} = ${rhsTypeStr}(${rhsStr$1})' if you need to reassign '${rawId}' later
|
|
509
|
+
- Try 'const ${rawId} = ${rhsStr$1}' if you won't reassign '${rawId}' later.
|
|
509
510
|
-----`);
|
|
510
511
|
}
|
|
511
512
|
if (eq.origin === "constant-tgpu-const-ref") varType = "const";
|
|
@@ -524,12 +525,12 @@ ${this.ctx.pre}else ${alternate}`;
|
|
|
524
525
|
else if (naturallyEphemeral) varType = eq.origin === "constant" ? "const" : "let";
|
|
525
526
|
} else if (eq.origin === "argument") {
|
|
526
527
|
if (!naturallyEphemeral) {
|
|
527
|
-
const rhsStr = this.ctx.resolve(eq.value).value;
|
|
528
|
+
const rhsStr$1 = this.ctx.resolve(eq.value).value;
|
|
528
529
|
const rhsTypeStr = this.ctx.resolve(unptr(eq.dataType)).value;
|
|
529
|
-
throw new WgslTypeError(`'let ${rawId} = ${rhsStr}' is invalid, because references to arguments cannot be assigned to 'let' variable declarations.
|
|
530
|
+
throw new WgslTypeError(`'let ${rawId} = ${rhsStr$1}' is invalid, because references to arguments cannot be assigned to 'let' variable declarations.
|
|
530
531
|
-----
|
|
531
|
-
- Try 'let ${rawId} = ${rhsTypeStr}(${rhsStr})' if you need to reassign '${rawId}' later
|
|
532
|
-
- Try 'const ${rawId} = ${rhsStr}' if you won't reassign '${rawId}' later.
|
|
532
|
+
- Try 'let ${rawId} = ${rhsTypeStr}(${rhsStr$1})' if you need to reassign '${rawId}' later
|
|
533
|
+
- Try 'const ${rawId} = ${rhsStr$1}' if you won't reassign '${rawId}' later.
|
|
533
534
|
-----`);
|
|
534
535
|
}
|
|
535
536
|
}
|
|
@@ -591,7 +592,7 @@ ${this.ctx.pre}else ${alternate}`;
|
|
|
591
592
|
const length = range.end.value;
|
|
592
593
|
if (length === 0) return "";
|
|
593
594
|
const { value } = iterableSnippet;
|
|
594
|
-
const elements = isTgpuRange(value) ? value.map((i) => coerceToSnippet(i)) : value instanceof ArrayExpression ? value.elements : Array.from({ length }, (_, i) => getElementSnippet(iterableSnippet, snip(i, u32, "constant")));
|
|
595
|
+
const elements = isTgpuRange(value) ? value.map((i) => coerceToSnippet(i)) : value instanceof ArrayExpression ? value.elements : Array.from({ length }, (_$1, i) => getElementSnippet(iterableSnippet, snip(i, u32, "constant")));
|
|
595
596
|
if (isEphemeralSnippet(elements[0]) && !isNaturallyEphemeral(elements[0]?.dataType)) throw new WgslTypeError("Cannot unroll loop. The elements of iterable are emphemeral but not naturally ephemeral.");
|
|
596
597
|
return elements.map((e, i) => `${this.ctx.pre}// unrolled iteration #${i}\n${this.ctx.pre}${this._block(blockified, { [originalLoopVarName]: e })}`).join("\n");
|
|
597
598
|
}
|
|
@@ -644,5 +645,7 @@ function blockifySingleStatement(statement) {
|
|
|
644
645
|
return typeof statement !== "object" || statement[0] !== NODE.block ? [NODE.block, [statement]] : statement;
|
|
645
646
|
}
|
|
646
647
|
const wgslGenerator = new WgslGenerator();
|
|
648
|
+
var wgslGenerator_default = wgslGenerator;
|
|
649
|
+
|
|
647
650
|
//#endregion
|
|
648
|
-
export { WgslGenerator,
|
|
651
|
+
export { WgslGenerator, wgslGenerator_default as default };
|
package/types.d.ts
CHANGED
|
@@ -86,7 +86,6 @@ interface ItemStateStack {
|
|
|
86
86
|
* The return type of the function. If undefined, the type should be inferred
|
|
87
87
|
* from the implementation (relevant for shellless functions).
|
|
88
88
|
*/
|
|
89
|
-
|
|
90
89
|
returnType: BaseData | undefined, externalMap: Record<string, unknown>): FunctionScopeLayer;
|
|
91
90
|
pushBlockScope(): void;
|
|
92
91
|
setBlockExternals(externals: Record<string, Snippet>): void;
|
package/types.js
CHANGED
|
@@ -2,6 +2,7 @@ import { $cast, $gpuCallable, $ownSnippet, $resolve } from "./shared/symbols.js"
|
|
|
2
2
|
import { isWgslData } from "./data/wgslTypes.js";
|
|
3
3
|
import { UnknownData } from "./data/dataTypes.js";
|
|
4
4
|
import { isLazy, isProviding, isSlot } from "./core/slot/slotTypes.js";
|
|
5
|
+
|
|
5
6
|
//#region src/types.ts
|
|
6
7
|
var NormalState = class {
|
|
7
8
|
type = "normal";
|
|
@@ -39,5 +40,6 @@ function isWgsl(value) {
|
|
|
39
40
|
function isGPUBuffer(value) {
|
|
40
41
|
return !!value && typeof value === "object" && "getMappedRange" in value && "mapAsync" in value;
|
|
41
42
|
}
|
|
43
|
+
|
|
42
44
|
//#endregion
|
|
43
|
-
export { CodegenState, NormalState, SimulationState, getOwnSnippet, hasCast, isGPUBuffer, isGPUCallable, isKnownAtComptime, isSelfResolvable, isWgsl };
|
|
45
|
+
export { CodegenState, NormalState, SimulationState, getOwnSnippet, hasCast, isGPUBuffer, isGPUCallable, isKnownAtComptime, isSelfResolvable, isWgsl };
|
package/wgslExtensions.js
CHANGED