typegpu 0.11.1 → 0.11.3
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 +5 -3
- 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 +13 -17
- package/core/function/extractArgs.js +2 -1
- package/core/function/fnCore.js +17 -11
- 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 +4 -2
- package/core/function/templateUtils.js +2 -1
- package/core/function/tgpuComputeFn.d.ts +1 -0
- package/core/function/tgpuComputeFn.js +4 -2
- package/core/function/tgpuFn.d.ts +1 -0
- package/core/function/tgpuFn.js +17 -15
- package/core/function/tgpuFragmentFn.js +4 -2
- package/core/function/tgpuVertexFn.js +4 -2
- 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.d.ts +3 -3
- 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 +19 -15
- 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.d.ts +1 -6
- 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 +4 -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 +86 -87
- 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 +5 -3
- package/tgsl/accessProp.js +10 -3
- package/tgsl/consoleLog/deserializers.js +3 -1
- package/tgsl/consoleLog/logGenerator.js +18 -9
- 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 +18 -6
- package/tgsl/forOfUtils.js +17 -7
- package/tgsl/generationHelpers.d.ts +1 -0
- package/tgsl/generationHelpers.js +3 -4
- package/tgsl/math.js +3 -1
- package/tgsl/shaderGenerator.d.ts +3 -2
- package/tgsl/shaderGenerator_members.d.ts +15 -2
- package/tgsl/shaderGenerator_members.js +5 -3
- package/tgsl/shellless.js +3 -1
- package/tgsl/wgslGenerator.d.ts +3 -1
- package/tgsl/wgslGenerator.js +54 -44
- package/types.d.ts +11 -7
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNaturallyEphemeral, isPtr, isVec, isWgslArray, isWgslStruct } from "../data/wgslTypes.js";
|
|
2
|
-
import { MatrixColumnsAccess,
|
|
2
|
+
import { MatrixColumnsAccess, isDisarray } from "../data/dataTypes.js";
|
|
3
3
|
import { isEphemeralSnippet, snip } from "../data/snippet.js";
|
|
4
4
|
import { isKnownAtComptime } from "../types.js";
|
|
5
5
|
import { stitch } from "../core/resolve/stitch.js";
|
|
@@ -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,
|
|
@@ -36,8 +37,9 @@ function accessIndex(target, indexArg) {
|
|
|
36
37
|
return snip(stitch`${target.value.matrix}[${index}]`, propType, target.origin);
|
|
37
38
|
}
|
|
38
39
|
if (target.dataType.type in indexableTypeToResult) throw new Error("The only way of accessing matrix elements in TypeGPU functions is through the 'columns' property.");
|
|
39
|
-
if (isKnownAtComptime(target) && isKnownAtComptime(index)
|
|
40
|
+
if (isKnownAtComptime(target) && isKnownAtComptime(index)) 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { $gpuCallable } from "../shared/symbols.js";
|
|
2
2
|
import { isMat, isNaturallyEphemeral, isPtr, isVec, isWgslArray, isWgslStruct } from "../data/wgslTypes.js";
|
|
3
3
|
import { InfixDispatch, MatrixColumnsAccess, UnknownData, isUnstruct, undecorate } from "../data/dataTypes.js";
|
|
4
|
-
import { isEphemeralSnippet, snip } from "../data/snippet.js";
|
|
4
|
+
import { isEphemeralSnippet, isSnippet, snip } from "../data/snippet.js";
|
|
5
5
|
import { isKnownAtComptime } from "../types.js";
|
|
6
6
|
import { stitch } from "../core/resolve/stitch.js";
|
|
7
7
|
import { derefSnippet } from "../data/ref.js";
|
|
@@ -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",
|
|
@@ -91,7 +92,12 @@ function accessProp(target, propName) {
|
|
|
91
92
|
if (!result) return;
|
|
92
93
|
return snip(stitch`${target}.${result.prop}`, result.type, "argument");
|
|
93
94
|
}
|
|
94
|
-
if (target.dataType instanceof EntryInputRouter)
|
|
95
|
+
if (target.dataType instanceof EntryInputRouter) {
|
|
96
|
+
const result = target.dataType.accessProp(propName);
|
|
97
|
+
if (isSnippet(result)) return result;
|
|
98
|
+
if (result) return accessProp(result.target, result.prop);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
95
101
|
if (isPtr(target.dataType)) {
|
|
96
102
|
const derefed = derefSnippet(target);
|
|
97
103
|
if (propName === "$") return derefed;
|
|
@@ -111,5 +117,6 @@ function accessProp(target, propName) {
|
|
|
111
117
|
}
|
|
112
118
|
if (isKnownAtComptime(target) || target.dataType === UnknownData) return coerceToSnippet(target.value[propName]);
|
|
113
119
|
}
|
|
120
|
+
|
|
114
121
|
//#endregion
|
|
115
|
-
export { accessProp, infixOperators };
|
|
122
|
+
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 };
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { $internal } from "../../shared/symbols.js";
|
|
2
2
|
import { Void } from "../../data/wgslTypes.js";
|
|
3
|
-
import { UnknownData } from "../../data/dataTypes.js";
|
|
3
|
+
import { UnknownData, unptr } from "../../data/dataTypes.js";
|
|
4
4
|
import { snip } from "../../data/snippet.js";
|
|
5
|
+
import { invariant } from "../../errors.js";
|
|
5
6
|
import { stitch } from "../../core/resolve/stitch.js";
|
|
7
|
+
import { convertToCommonType } from "../conversion.js";
|
|
6
8
|
import { u32 } from "../../data/numeric.js";
|
|
7
|
-
import {
|
|
9
|
+
import { concretizeSnippet } from "../generationHelpers.js";
|
|
8
10
|
import { struct } from "../../data/struct.js";
|
|
9
11
|
import { shaderStageSlot } from "../../core/slot/internalSlots.js";
|
|
10
12
|
import { arrayOf } from "../../data/array.js";
|
|
11
13
|
import { atomic } from "../../data/atomic.js";
|
|
12
14
|
import { createLoggingFunction } from "./serializers.js";
|
|
13
15
|
import { supportedLogOps } from "./types.js";
|
|
16
|
+
|
|
14
17
|
//#region src/tgsl/consoleLog/logGenerator.ts
|
|
15
18
|
const defaultOptions = {
|
|
16
19
|
logCountLimit: 64,
|
|
@@ -60,16 +63,21 @@ var LogGeneratorImpl = class {
|
|
|
60
63
|
console.warn(`Unsupported log method '${op}'.`);
|
|
61
64
|
return fallbackSnippet;
|
|
62
65
|
}
|
|
63
|
-
const concreteArgs = concretizeSnippets(args);
|
|
64
66
|
const id = this.#firstUnusedId++;
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
const concreteArgsWithStrings = args.map((arg) => {
|
|
68
|
+
if (arg.dataType === UnknownData) return arg;
|
|
69
|
+
const converted = convertToCommonType(ctx, [arg], [unptr(arg.dataType)])?.[0];
|
|
70
|
+
invariant(converted, `Internal error. Expected type ${arg.dataType} to be convertible to ${unptr(arg.dataType)}`);
|
|
71
|
+
return converted;
|
|
72
|
+
}).map(concretizeSnippet);
|
|
73
|
+
const concreteArgs = concreteArgsWithStrings.filter((arg) => arg.dataType !== UnknownData);
|
|
74
|
+
const logFn = createLoggingFunction(id, concreteArgs.map((e) => e.dataType), this.#dataBuffer, this.#indexBuffer, this.#options);
|
|
75
|
+
const functionSnippet = snip(stitch`${ctx.resolve(logFn).value}(${concreteArgs})`, Void, "runtime");
|
|
68
76
|
this.#logIdToMeta.set(id, {
|
|
69
77
|
op,
|
|
70
|
-
argTypes
|
|
78
|
+
argTypes: concreteArgsWithStrings.map((e) => e?.dataType === UnknownData ? e?.value : e?.dataType)
|
|
71
79
|
});
|
|
72
|
-
return
|
|
80
|
+
return functionSnippet;
|
|
73
81
|
}
|
|
74
82
|
get logResources() {
|
|
75
83
|
return this.#firstUnusedId === 1 ? void 0 : {
|
|
@@ -80,5 +88,6 @@ var LogGeneratorImpl = class {
|
|
|
80
88
|
};
|
|
81
89
|
}
|
|
82
90
|
};
|
|
91
|
+
|
|
83
92
|
//#endregion
|
|
84
|
-
export { LogGeneratorImpl, LogGeneratorNullImpl };
|
|
93
|
+
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,
|
|
@@ -89,14 +90,19 @@ function getImplicitConversionRank(src, dest) {
|
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
92
|
}
|
|
93
|
+
if ((trueSrc.type === "u32" || trueSrc.type === "i32") && trueDst.type === "abstractFloat") return {
|
|
94
|
+
rank: 1,
|
|
95
|
+
action: "cast",
|
|
96
|
+
targetType: trueDst.concretized
|
|
97
|
+
};
|
|
92
98
|
if (trueSrc.type === "abstractFloat") {
|
|
93
|
-
if (trueDst.type === "
|
|
99
|
+
if (trueDst.type === "i32") return {
|
|
94
100
|
rank: 2,
|
|
95
101
|
action: "cast",
|
|
96
102
|
targetType: trueDst
|
|
97
103
|
};
|
|
98
|
-
if (trueDst.type === "
|
|
99
|
-
rank:
|
|
104
|
+
if (trueDst.type === "u32") return {
|
|
105
|
+
rank: 3,
|
|
100
106
|
action: "cast",
|
|
101
107
|
targetType: trueDst
|
|
102
108
|
};
|
|
@@ -112,6 +118,10 @@ function getConversionRank(src, dest, allowImplicit) {
|
|
|
112
118
|
function findBestType(types, uniqueTypes, allowImplicit) {
|
|
113
119
|
let bestResult;
|
|
114
120
|
for (const targetType of uniqueTypes) {
|
|
121
|
+
/**
|
|
122
|
+
* The type we end up converting to. Will be different than `targetType` if `targetType === abstractFloat`
|
|
123
|
+
*/
|
|
124
|
+
let destType = targetType;
|
|
115
125
|
const details = [];
|
|
116
126
|
let sum = 0;
|
|
117
127
|
for (const sourceType of types) {
|
|
@@ -119,9 +129,10 @@ function findBestType(types, uniqueTypes, allowImplicit) {
|
|
|
119
129
|
sum += conversion.rank;
|
|
120
130
|
if (conversion.rank === Number.POSITIVE_INFINITY) break;
|
|
121
131
|
details.push(conversion);
|
|
132
|
+
if (conversion.action === "cast") destType = conversion.targetType;
|
|
122
133
|
}
|
|
123
134
|
if (sum < (bestResult?.sum ?? Number.POSITIVE_INFINITY)) bestResult = {
|
|
124
|
-
type:
|
|
135
|
+
type: destType,
|
|
125
136
|
details,
|
|
126
137
|
sum
|
|
127
138
|
};
|
|
@@ -167,7 +178,7 @@ function convertToCommonType(ctx, values, restrictTo, verbose = true) {
|
|
|
167
178
|
if (DEV && Array.isArray(restrictTo) && restrictTo.length === 0) console.warn("convertToCommonType was called with an empty restrictTo array, which prevents any conversions from being made. If you intend to allow all conversions, pass undefined instead. If this was intended call the function conditionally since the result will always be undefined.");
|
|
168
179
|
const conversion = getBestConversion(types, restrictTo);
|
|
169
180
|
if (!conversion) return;
|
|
170
|
-
if ((TEST || DEV) && verbose && conversion.hasImplicitConversions) console.warn(`Implicit conversions from [\n${values.map((v) => ` ${v.value}: ${safeStringify(v.dataType)}`).join(",\n")}\n] to ${conversion.targetType.type} are supported, but not recommended.
|
|
181
|
+
if ((TEST || DEV) && verbose && conversion.hasImplicitConversions) console.warn(`Implicit conversions from [\n${values.map((v) => ` ${ctx.resolveSnippet(v).value}: ${safeStringify(v.dataType)}`).join(",\n")}\n] to ${conversion.targetType.type} are supported, but not recommended.
|
|
171
182
|
Consider using explicit conversions instead.`);
|
|
172
183
|
return values.map((value, index) => {
|
|
173
184
|
const action = conversion.actions[index];
|
|
@@ -194,5 +205,6 @@ function convertStructValues(ctx, structType, values) {
|
|
|
194
205
|
return convertToCommonType(ctx, [val], [targetType])?.[0] ?? val;
|
|
195
206
|
});
|
|
196
207
|
}
|
|
208
|
+
|
|
197
209
|
//#endregion
|
|
198
|
-
export { convertStructValues, convertToCommonType, getBestConversion, tryConvertSnippet, unify };
|
|
210
|
+
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";
|
|
@@ -32,12 +33,20 @@ function getElementType(elementSnippet, iterableSnippet) {
|
|
|
32
33
|
}
|
|
33
34
|
function getRangeSnippets(ctx, iterableSnippet, unroll = false) {
|
|
34
35
|
const { value, dataType } = iterableSnippet;
|
|
35
|
-
if (isTgpuRange(value))
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
if (isTgpuRange(value)) {
|
|
37
|
+
const { start, end, step } = value;
|
|
38
|
+
const dataType$1 = [
|
|
39
|
+
start,
|
|
40
|
+
end,
|
|
41
|
+
step
|
|
42
|
+
].every((v) => v >= 0) ? u32 : i32;
|
|
43
|
+
return {
|
|
44
|
+
start: snip(start, dataType$1, "constant"),
|
|
45
|
+
end: snip(end, dataType$1, "constant"),
|
|
46
|
+
step: snip(step, dataType$1, "constant"),
|
|
47
|
+
comparison: step < 0 ? ">" : "<"
|
|
48
|
+
};
|
|
49
|
+
}
|
|
41
50
|
if (!unroll && isEphemeralSnippet(iterableSnippet)) throw new Error(`\`for ... of ...\` loops only support std.range or iterables stored in variables.
|
|
42
51
|
-----
|
|
43
52
|
You can wrap iterable with \`tgpu.unroll(...)\`. If iterable is known at comptime, the loop will be unrolled.
|
|
@@ -67,5 +76,6 @@ You can wrap iterable with \`tgpu.unroll(...)\`. If iterable is known at comptim
|
|
|
67
76
|
}
|
|
68
77
|
throw new WgslTypeError("`for ... of ...` loops only support array or vector iterables");
|
|
69
78
|
}
|
|
79
|
+
|
|
70
80
|
//#endregion
|
|
71
|
-
export { getElementSnippet, getElementType, getLoopVarKind, getRangeSnippets };
|
|
81
|
+
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");
|
|
@@ -24,9 +25,6 @@ function concretize(type) {
|
|
|
24
25
|
function concretizeSnippet(snippet) {
|
|
25
26
|
return snip(snippet.value, concretize(snippet.dataType), snippet.origin);
|
|
26
27
|
}
|
|
27
|
-
function concretizeSnippets(args) {
|
|
28
|
-
return args.map(concretizeSnippet);
|
|
29
|
-
}
|
|
30
28
|
function coerceToSnippet(value) {
|
|
31
29
|
if (isSnippet(value)) return value;
|
|
32
30
|
if (isRef(value)) throw new Error("Cannot use refs (d.ref(...)) from the outer scope.");
|
|
@@ -63,5 +61,6 @@ var ArrayExpression = class {
|
|
|
63
61
|
return snip(stitch`${`array<${ctx.resolve(this.type.elementType).value}, ${this.elements.length}>`}(${this.elements})`, this.type, "runtime");
|
|
64
62
|
}
|
|
65
63
|
};
|
|
64
|
+
|
|
66
65
|
//#endregion
|
|
67
|
-
export { ArrayExpression, coerceToSnippet, concretize,
|
|
66
|
+
export { ArrayExpression, coerceToSnippet, concretize, concretizeSnippet, 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,10 @@
|
|
|
1
1
|
import { ResolvedSnippet, Snippet } from "../data/snippet.js";
|
|
2
2
|
import { GenerationCtx } from "./generationHelpers.js";
|
|
3
|
+
import { FunctionDefinitionOptions } from "./shaderGenerator_members.js";
|
|
3
4
|
import { BaseData } from "../data/wgslTypes.js";
|
|
4
|
-
import { Block } from "tinyest";
|
|
5
5
|
|
|
6
6
|
//#region src/tgsl/shaderGenerator.d.ts
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
9
|
* **NOTE: This is an unstable API and may change in the future.**
|
|
9
10
|
*
|
|
@@ -12,7 +13,7 @@ import { Block } from "tinyest";
|
|
|
12
13
|
*/
|
|
13
14
|
interface ShaderGenerator {
|
|
14
15
|
initGenerator(ctx: GenerationCtx): void;
|
|
15
|
-
functionDefinition(
|
|
16
|
+
functionDefinition(options: FunctionDefinitionOptions): string;
|
|
16
17
|
typeInstantiation(schema: BaseData, args: readonly Snippet[]): ResolvedSnippet;
|
|
17
18
|
typeAnnotation(schema: BaseData): string;
|
|
18
19
|
}
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Origin, Snippet } from "../data/snippet.js";
|
|
2
|
+
import { FunctionArgument, ResolutionCtx, TgpuShaderStage } from "../types.js";
|
|
3
|
+
import { BaseData } from "../data/wgslTypes.js";
|
|
4
|
+
import { UnknownData } from "../data/dataTypes.js";
|
|
5
|
+
import { Block } from "tinyest";
|
|
6
|
+
|
|
7
|
+
//#region src/tgsl/shaderGenerator_members.d.ts
|
|
8
|
+
interface FunctionDefinitionOptions {
|
|
9
|
+
readonly functionType: 'normal' | TgpuShaderStage;
|
|
10
|
+
readonly args: readonly FunctionArgument[];
|
|
11
|
+
readonly body: Block;
|
|
12
|
+
determineReturnType(): BaseData;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { FunctionDefinitionOptions };
|
|
@@ -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 };
|