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/numeric.d.ts
CHANGED
|
@@ -6,195 +6,249 @@ import { Infer } from "../shared/repr.js";
|
|
|
6
6
|
type NumVec = AnyNumericVecInstance;
|
|
7
7
|
declare function cpuAbs(value: number): number;
|
|
8
8
|
declare function cpuAbs<T extends NumVec | number>(value: T): T;
|
|
9
|
-
declare const abs: DualFn
|
|
9
|
+
declare const abs: DualFn<typeof cpuAbs>;
|
|
10
10
|
declare function cpuAcos(value: number): number;
|
|
11
11
|
declare function cpuAcos<T extends AnyFloatVecInstance>(value: T): T;
|
|
12
|
-
declare const acos: DualFn
|
|
12
|
+
declare const acos: DualFn<typeof cpuAcos>;
|
|
13
13
|
declare function cpuAcosh(value: number): number;
|
|
14
14
|
declare function cpuAcosh<T extends AnyFloatVecInstance>(value: T): T;
|
|
15
|
-
declare const acosh: DualFn
|
|
15
|
+
declare const acosh: DualFn<typeof cpuAcosh>;
|
|
16
16
|
declare function cpuAsin(value: number): number;
|
|
17
17
|
declare function cpuAsin<T extends AnyFloatVecInstance>(value: T): T;
|
|
18
|
-
declare const asin: DualFn
|
|
18
|
+
declare const asin: DualFn<typeof cpuAsin>;
|
|
19
19
|
declare function cpuAsinh(value: number): number;
|
|
20
20
|
declare function cpuAsinh<T extends AnyFloatVecInstance>(value: T): T;
|
|
21
|
-
declare const asinh: DualFn
|
|
21
|
+
declare const asinh: DualFn<typeof cpuAsinh>;
|
|
22
22
|
declare function cpuAtan(value: number): number;
|
|
23
23
|
declare function cpuAtan<T extends AnyFloatVecInstance>(value: T): T;
|
|
24
|
-
declare const atan: DualFn
|
|
24
|
+
declare const atan: DualFn<typeof cpuAtan>;
|
|
25
25
|
declare function cpuAtanh(value: number): number;
|
|
26
26
|
declare function cpuAtanh<T extends AnyFloatVecInstance>(value: T): T;
|
|
27
|
-
declare const atanh: DualFn
|
|
27
|
+
declare const atanh: DualFn<typeof cpuAtanh>;
|
|
28
28
|
declare function cpuAtan2(y: number, x: number): number;
|
|
29
29
|
declare function cpuAtan2<T extends AnyFloatVecInstance>(y: T, x: T): T;
|
|
30
|
-
declare const atan2: DualFn
|
|
30
|
+
declare const atan2: DualFn<typeof cpuAtan2>;
|
|
31
31
|
declare function cpuCeil(value: number): number;
|
|
32
32
|
declare function cpuCeil<T extends AnyFloatVecInstance>(value: T): T;
|
|
33
|
-
declare const ceil: DualFn
|
|
33
|
+
declare const ceil: DualFn<typeof cpuCeil>;
|
|
34
34
|
declare function cpuClamp(value: number, low: number, high: number): number;
|
|
35
35
|
declare function cpuClamp<T extends NumVec | number>(value: T, low: T, high: T): T;
|
|
36
|
-
declare const clamp: DualFn
|
|
36
|
+
declare const clamp: DualFn<typeof cpuClamp>;
|
|
37
37
|
declare function cpuCos(value: number): number;
|
|
38
38
|
declare function cpuCos<T extends AnyFloatVecInstance>(value: T): T;
|
|
39
|
-
declare const cos: DualFn
|
|
39
|
+
declare const cos: DualFn<typeof cpuCos>;
|
|
40
40
|
declare function cpuCosh(value: number): number;
|
|
41
41
|
declare function cpuCosh<T extends AnyFloatVecInstance>(value: T): T;
|
|
42
|
-
declare const cosh: DualFn
|
|
42
|
+
declare const cosh: DualFn<typeof cpuCosh>;
|
|
43
43
|
declare function cpuCountLeadingZeros(value: number): number;
|
|
44
44
|
declare function cpuCountLeadingZeros<T extends AnyIntegerVecInstance>(value: T): T;
|
|
45
|
-
declare const countLeadingZeros: DualFn
|
|
45
|
+
declare const countLeadingZeros: DualFn<typeof cpuCountLeadingZeros>;
|
|
46
46
|
declare function cpuCountOneBits(value: number): number;
|
|
47
47
|
declare function cpuCountOneBits<T extends AnyIntegerVecInstance>(value: T): T;
|
|
48
|
-
declare const countOneBits: DualFn
|
|
48
|
+
declare const countOneBits: DualFn<typeof cpuCountOneBits>;
|
|
49
49
|
declare function cpuCountTrailingZeros(value: number): number;
|
|
50
50
|
declare function cpuCountTrailingZeros<T extends AnyIntegerVecInstance>(value: T): T;
|
|
51
|
-
declare const countTrailingZeros: DualFn
|
|
52
|
-
declare const cross: DualFn
|
|
51
|
+
declare const countTrailingZeros: DualFn<typeof cpuCountTrailingZeros>;
|
|
52
|
+
declare const cross: DualFn<(<T extends v3f | v3h>(a: T, b: T) => T)>;
|
|
53
53
|
declare function cpuDegrees(value: number): number;
|
|
54
54
|
declare function cpuDegrees<T extends AnyFloatVecInstance>(value: T): T;
|
|
55
|
-
declare const degrees: DualFn
|
|
56
|
-
declare const determinant: DualFn
|
|
55
|
+
declare const degrees: DualFn<typeof cpuDegrees>;
|
|
56
|
+
declare const determinant: DualFn<(value: AnyMatInstance) => number>;
|
|
57
57
|
declare function cpuDistance(a: number, b: number): number;
|
|
58
58
|
declare function cpuDistance<T extends AnyFloatVecInstance>(a: T, b: T): number;
|
|
59
|
-
declare const distance: DualFn
|
|
60
|
-
declare const dot: DualFn
|
|
61
|
-
declare const dot4U8Packed: DualFn
|
|
62
|
-
declare const dot4I8Packed: DualFn
|
|
59
|
+
declare const distance: DualFn<typeof cpuDistance>;
|
|
60
|
+
declare const dot: DualFn<(<T extends NumVec>(lhs: T, rhs: T) => number)>;
|
|
61
|
+
declare const dot4U8Packed: DualFn<(e1: number, e2: number) => number>;
|
|
62
|
+
declare const dot4I8Packed: DualFn<(e1: number, e2: number) => number>;
|
|
63
63
|
declare function cpuExp(value: number): number;
|
|
64
64
|
declare function cpuExp<T extends AnyFloatVecInstance>(value: T): T;
|
|
65
|
-
declare const exp: DualFn
|
|
65
|
+
declare const exp: DualFn<typeof cpuExp>;
|
|
66
66
|
declare function cpuExp2(value: number): number;
|
|
67
67
|
declare function cpuExp2<T extends AnyFloatVecInstance>(value: T): T;
|
|
68
|
-
declare const exp2: DualFn
|
|
68
|
+
declare const exp2: DualFn<typeof cpuExp2>;
|
|
69
69
|
declare function cpuExtractBits(e: number, offset: number, count: number): number;
|
|
70
70
|
declare function cpuExtractBits<T extends AnyIntegerVecInstance>(e: T, offset: number, count: number): T;
|
|
71
|
-
declare const extractBits: DualFn
|
|
72
|
-
declare const faceForward: DualFn
|
|
71
|
+
declare const extractBits: DualFn<typeof cpuExtractBits>;
|
|
72
|
+
declare const faceForward: DualFn<(<T extends AnyFloatVecInstance>(e1: T, e2: T, e3: T) => T)>;
|
|
73
73
|
declare function cpuFirstLeadingBit(value: number): number;
|
|
74
74
|
declare function cpuFirstLeadingBit<T extends AnyIntegerVecInstance>(value: T): T;
|
|
75
|
-
declare const firstLeadingBit: DualFn
|
|
75
|
+
declare const firstLeadingBit: DualFn<typeof cpuFirstLeadingBit>;
|
|
76
76
|
declare function cpuFirstTrailingBit(value: number): number;
|
|
77
77
|
declare function cpuFirstTrailingBit<T extends AnyIntegerVecInstance>(value: T): T;
|
|
78
|
-
declare const firstTrailingBit: DualFn
|
|
78
|
+
declare const firstTrailingBit: DualFn<typeof cpuFirstTrailingBit>;
|
|
79
79
|
declare function cpuFloor(value: number): number;
|
|
80
80
|
declare function cpuFloor<T extends AnyFloatVecInstance>(value: T): T;
|
|
81
|
-
declare const floor: DualFn
|
|
81
|
+
declare const floor: DualFn<typeof cpuFloor>;
|
|
82
82
|
declare function cpuFma(e1: number, e2: number, e3: number): number;
|
|
83
83
|
declare function cpuFma<T extends AnyFloatVecInstance>(e1: T, e2: T, e3: T): T;
|
|
84
|
-
declare const fma: DualFn
|
|
84
|
+
declare const fma: DualFn<typeof cpuFma>;
|
|
85
85
|
declare function cpuFract(value: number): number;
|
|
86
86
|
declare function cpuFract<T extends AnyFloatVecInstance>(value: T): T;
|
|
87
|
-
declare const fract: DualFn
|
|
87
|
+
declare const fract: DualFn<typeof cpuFract>;
|
|
88
88
|
declare const FrexpResults: {
|
|
89
|
-
readonly f32: WgslStruct
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
readonly
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
readonly
|
|
89
|
+
readonly f32: WgslStruct<{
|
|
90
|
+
fract: F32;
|
|
91
|
+
exp: I32;
|
|
92
|
+
}>;
|
|
93
|
+
readonly f16: WgslStruct<{
|
|
94
|
+
fract: F16;
|
|
95
|
+
exp: I32;
|
|
96
|
+
}>;
|
|
97
|
+
readonly abstractFloat: WgslStruct<{
|
|
98
|
+
fract: AbstractFloat;
|
|
99
|
+
exp: AbstractInt;
|
|
100
|
+
}>;
|
|
101
|
+
readonly vec2f: WgslStruct<{
|
|
102
|
+
fract: Vec2f;
|
|
103
|
+
exp: Vec2i;
|
|
104
|
+
}>;
|
|
105
|
+
readonly vec3f: WgslStruct<{
|
|
106
|
+
fract: Vec3f;
|
|
107
|
+
exp: Vec3i;
|
|
108
|
+
}>;
|
|
109
|
+
readonly vec4f: WgslStruct<{
|
|
110
|
+
fract: Vec4f;
|
|
111
|
+
exp: Vec4i;
|
|
112
|
+
}>;
|
|
113
|
+
readonly vec2h: WgslStruct<{
|
|
114
|
+
fract: Vec2h;
|
|
115
|
+
exp: Vec2i;
|
|
116
|
+
}>;
|
|
117
|
+
readonly vec3h: WgslStruct<{
|
|
118
|
+
fract: Vec3h;
|
|
119
|
+
exp: Vec3i;
|
|
120
|
+
}>;
|
|
121
|
+
readonly vec4h: WgslStruct<{
|
|
122
|
+
fract: Vec4h;
|
|
123
|
+
exp: Vec4i;
|
|
124
|
+
}>;
|
|
98
125
|
};
|
|
99
126
|
type FrexpOverload = {
|
|
100
127
|
(value: number): Infer<(typeof FrexpResults)['f32']>;
|
|
101
128
|
<T extends AnyFloatVecInstance>(value: T): Infer<(typeof FrexpResults)[T['kind']]>;
|
|
102
129
|
};
|
|
103
|
-
declare const frexp: DualFn
|
|
130
|
+
declare const frexp: DualFn<FrexpOverload>;
|
|
104
131
|
declare function cpuInsertBits(e: number, newbits: number, offset: number, count: number): number;
|
|
105
132
|
declare function cpuInsertBits<T extends AnyIntegerVecInstance>(e: T, newbits: T, offset: number, count: number): T;
|
|
106
|
-
declare const insertBits: DualFn
|
|
133
|
+
declare const insertBits: DualFn<typeof cpuInsertBits>;
|
|
107
134
|
declare function cpuInverseSqrt(value: number): number;
|
|
108
135
|
declare function cpuInverseSqrt<T extends AnyFloatVecInstance>(value: T): T;
|
|
109
|
-
declare const inverseSqrt: DualFn
|
|
136
|
+
declare const inverseSqrt: DualFn<typeof cpuInverseSqrt>;
|
|
110
137
|
declare function cpuLdexp(e1: number, e2: number): number;
|
|
111
138
|
declare function cpuLdexp<T extends v2f | v2h>(e1: T, e2: v2i): T;
|
|
112
139
|
declare function cpuLdexp<T extends v3f | v3h>(e1: T, e2: v3i): T;
|
|
113
140
|
declare function cpuLdexp<T extends v4f | v4h>(e1: T, e2: v4i): T;
|
|
114
|
-
declare const ldexp: DualFn
|
|
141
|
+
declare const ldexp: DualFn<typeof cpuLdexp>;
|
|
115
142
|
declare function cpuLength(value: number): number;
|
|
116
143
|
declare function cpuLength<T extends AnyFloatVecInstance>(value: T): number;
|
|
117
|
-
declare const length: DualFn
|
|
144
|
+
declare const length: DualFn<typeof cpuLength>;
|
|
118
145
|
declare function cpuLog(value: number): number;
|
|
119
146
|
declare function cpuLog<T extends AnyFloatVecInstance>(value: T): T;
|
|
120
|
-
declare const log: DualFn
|
|
147
|
+
declare const log: DualFn<typeof cpuLog>;
|
|
121
148
|
declare function cpuLog2(value: number): number;
|
|
122
149
|
declare function cpuLog2<T extends AnyFloatVecInstance>(value: T): T;
|
|
123
|
-
declare const log2: DualFn
|
|
150
|
+
declare const log2: DualFn<typeof cpuLog2>;
|
|
124
151
|
type VariadicOverload = {
|
|
125
152
|
(fst: number, ...rest: number[]): number;
|
|
126
153
|
<T extends NumVec>(fst: T, ...rest: T[]): T;
|
|
127
154
|
};
|
|
128
|
-
declare const max: DualFn
|
|
129
|
-
declare const min: DualFn
|
|
155
|
+
declare const max: DualFn<VariadicOverload>;
|
|
156
|
+
declare const min: DualFn<VariadicOverload>;
|
|
130
157
|
declare function cpuMix(e1: number, e2: number, e3: number): number;
|
|
131
158
|
declare function cpuMix<T extends AnyFloatVecInstance>(e1: T, e2: T, e3: number): T;
|
|
132
159
|
declare function cpuMix<T extends AnyFloatVecInstance>(e1: T, e2: T, e3: T): T;
|
|
133
|
-
declare const mix: DualFn
|
|
160
|
+
declare const mix: DualFn<typeof cpuMix>;
|
|
134
161
|
declare const ModfResult: {
|
|
135
|
-
readonly f32: WgslStruct
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
readonly
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
readonly
|
|
162
|
+
readonly f32: WgslStruct<{
|
|
163
|
+
fract: F32;
|
|
164
|
+
whole: F32;
|
|
165
|
+
}>;
|
|
166
|
+
readonly f16: WgslStruct<{
|
|
167
|
+
fract: F16;
|
|
168
|
+
whole: F16;
|
|
169
|
+
}>;
|
|
170
|
+
readonly abstractFloat: WgslStruct<{
|
|
171
|
+
fract: AbstractFloat;
|
|
172
|
+
whole: AbstractFloat;
|
|
173
|
+
}>;
|
|
174
|
+
readonly vec2f: WgslStruct<{
|
|
175
|
+
fract: Vec2f;
|
|
176
|
+
whole: Vec2f;
|
|
177
|
+
}>;
|
|
178
|
+
readonly vec3f: WgslStruct<{
|
|
179
|
+
fract: Vec3f;
|
|
180
|
+
whole: Vec3f;
|
|
181
|
+
}>;
|
|
182
|
+
readonly vec4f: WgslStruct<{
|
|
183
|
+
fract: Vec4f;
|
|
184
|
+
whole: Vec4f;
|
|
185
|
+
}>;
|
|
186
|
+
readonly vec2h: WgslStruct<{
|
|
187
|
+
fract: Vec2h;
|
|
188
|
+
whole: Vec2h;
|
|
189
|
+
}>;
|
|
190
|
+
readonly vec3h: WgslStruct<{
|
|
191
|
+
fract: Vec3h;
|
|
192
|
+
whole: Vec3h;
|
|
193
|
+
}>;
|
|
194
|
+
readonly vec4h: WgslStruct<{
|
|
195
|
+
fract: Vec4h;
|
|
196
|
+
whole: Vec4h;
|
|
197
|
+
}>;
|
|
144
198
|
};
|
|
145
199
|
type ModfOverload = {
|
|
146
200
|
(value: number): Infer<(typeof ModfResult)['f32']>;
|
|
147
201
|
<T extends AnyFloatVecInstance>(value: T): Infer<(typeof ModfResult)[T['kind']]>;
|
|
148
202
|
};
|
|
149
203
|
declare const modf: ModfOverload;
|
|
150
|
-
declare const normalize: DualFn
|
|
204
|
+
declare const normalize: DualFn<(<T extends AnyFloatVecInstance>(v: T) => T)>;
|
|
151
205
|
declare function powCpu(base: number, exponent: number): number;
|
|
152
206
|
declare function powCpu<T extends AnyFloatVecInstance>(base: T, exponent: T): T;
|
|
153
|
-
declare const pow: DualFn
|
|
207
|
+
declare const pow: DualFn<typeof powCpu>;
|
|
154
208
|
declare function cpuQuantizeToF16(value: number): number;
|
|
155
209
|
declare function cpuQuantizeToF16<T extends AnyFloat32VecInstance>(value: T): T;
|
|
156
|
-
declare const quantizeToF16: DualFn
|
|
210
|
+
declare const quantizeToF16: DualFn<typeof cpuQuantizeToF16>;
|
|
157
211
|
declare function cpuRadians(value: number): number;
|
|
158
212
|
declare function cpuRadians<T extends AnyFloatVecInstance | number>(value: T): T;
|
|
159
|
-
declare const radians: DualFn
|
|
160
|
-
declare const reflect: DualFn
|
|
161
|
-
declare const refract: DualFn
|
|
213
|
+
declare const radians: DualFn<typeof cpuRadians>;
|
|
214
|
+
declare const reflect: DualFn<(<T extends AnyFloatVecInstance>(e1: T, e2: T) => T)>;
|
|
215
|
+
declare const refract: DualFn<(<T extends AnyFloatVecInstance>(e1: T, e2: T, e3: number) => T)>;
|
|
162
216
|
declare function cpuReverseBits(value: number): number;
|
|
163
217
|
declare function cpuReverseBits<T extends AnyIntegerVecInstance>(value: T): T;
|
|
164
|
-
declare const reverseBits: DualFn
|
|
218
|
+
declare const reverseBits: DualFn<typeof cpuReverseBits>;
|
|
165
219
|
declare function cpuRound(value: number): number;
|
|
166
220
|
declare function cpuRound<T extends AnyFloatVecInstance>(value: T): T;
|
|
167
|
-
declare const round: DualFn
|
|
221
|
+
declare const round: DualFn<typeof cpuRound>;
|
|
168
222
|
declare function cpuSaturate(value: number): number;
|
|
169
223
|
declare function cpuSaturate<T extends AnyFloatVecInstance>(value: T): T;
|
|
170
|
-
declare const saturate: DualFn
|
|
224
|
+
declare const saturate: DualFn<typeof cpuSaturate>;
|
|
171
225
|
declare function cpuSign(e: number): number;
|
|
172
226
|
declare function cpuSign<T extends AnySignedVecInstance>(e: T): T;
|
|
173
|
-
declare const sign: DualFn
|
|
227
|
+
declare const sign: DualFn<typeof cpuSign>;
|
|
174
228
|
declare function cpuSin(value: number): number;
|
|
175
229
|
declare function cpuSin<T extends AnyFloatVecInstance>(value: T): T;
|
|
176
|
-
declare const sin: DualFn
|
|
230
|
+
declare const sin: DualFn<typeof cpuSin>;
|
|
177
231
|
declare function cpuSinh(value: number): number;
|
|
178
232
|
declare function cpuSinh<T extends AnyFloatVecInstance>(value: T): T;
|
|
179
|
-
declare const sinh: DualFn
|
|
233
|
+
declare const sinh: DualFn<typeof cpuSinh>;
|
|
180
234
|
declare function cpuSmoothstep(edge0: number, edge1: number, x: number): number;
|
|
181
235
|
declare function cpuSmoothstep<T extends AnyFloatVecInstance>(edge0: T, edge1: T, x: T): T;
|
|
182
|
-
declare const smoothstep: DualFn
|
|
236
|
+
declare const smoothstep: DualFn<typeof cpuSmoothstep>;
|
|
183
237
|
declare function cpuSqrt(value: number): number;
|
|
184
238
|
declare function cpuSqrt<T extends AnyFloatVecInstance>(value: T): T;
|
|
185
|
-
declare const sqrt: DualFn
|
|
239
|
+
declare const sqrt: DualFn<typeof cpuSqrt>;
|
|
186
240
|
declare function cpuStep(edge: number, x: number): number;
|
|
187
241
|
declare function cpuStep<T extends AnyFloatVecInstance | number>(edge: T, x: T): T;
|
|
188
|
-
declare const step: DualFn
|
|
242
|
+
declare const step: DualFn<typeof cpuStep>;
|
|
189
243
|
declare function cpuTan(value: number): number;
|
|
190
244
|
declare function cpuTan<T extends AnyFloatVecInstance>(value: T): T;
|
|
191
|
-
declare const tan: DualFn
|
|
245
|
+
declare const tan: DualFn<typeof cpuTan>;
|
|
192
246
|
declare function cpuTanh(value: number): number;
|
|
193
247
|
declare function cpuTanh<T extends AnyFloatVecInstance>(value: T): T;
|
|
194
|
-
declare const tanh: DualFn
|
|
195
|
-
declare const transpose: DualFn
|
|
248
|
+
declare const tanh: DualFn<typeof cpuTanh>;
|
|
249
|
+
declare const transpose: DualFn<(<T extends AnyMatInstance>(e: T) => T)>;
|
|
196
250
|
declare function cpuTrunc(value: number): number;
|
|
197
251
|
declare function cpuTrunc<T extends AnyFloatVecInstance>(value: T): T;
|
|
198
|
-
declare const trunc: DualFn
|
|
252
|
+
declare const trunc: DualFn<typeof cpuTrunc>;
|
|
199
253
|
//#endregion
|
|
200
254
|
export { abs, acos, acosh, asin, asinh, atan, atan2, atanh, ceil, clamp, cos, cosh, countLeadingZeros, countOneBits, countTrailingZeros, cross, degrees, determinant, distance, dot, dot4I8Packed, dot4U8Packed, exp, exp2, extractBits, faceForward, firstLeadingBit, firstTrailingBit, floor, fma, fract, frexp, insertBits, inverseSqrt, ldexp, length, log, log2, max, min, mix, modf, normalize, pow, quantizeToF16, radians, reflect, refract, reverseBits, round, saturate, sign, sin, sinh, smoothstep, sqrt, step, tan, tanh, transpose, trunc };
|
package/std/numeric.js
CHANGED
|
@@ -10,6 +10,7 @@ import { mat2x2f, mat3x3f, mat4x4f } from "../data/matrix.js";
|
|
|
10
10
|
import { smoothstepScalar } from "../data/numberOps.js";
|
|
11
11
|
import { VectorOps } from "../data/vectorOps.js";
|
|
12
12
|
import { mul, sub } from "./operators.js";
|
|
13
|
+
|
|
13
14
|
//#region src/std/numeric.ts
|
|
14
15
|
const unaryIdentitySignature = (arg) => {
|
|
15
16
|
return {
|
|
@@ -710,10 +711,10 @@ const reverseBits = dualImpl({
|
|
|
710
711
|
});
|
|
711
712
|
function cpuRound(value) {
|
|
712
713
|
if (typeof value === "number") {
|
|
713
|
-
const floor = Math.floor(value);
|
|
714
|
-
if (value === floor + .5) {
|
|
715
|
-
if (floor % 2 === 0) return floor;
|
|
716
|
-
return floor + 1;
|
|
714
|
+
const floor$1 = Math.floor(value);
|
|
715
|
+
if (value === floor$1 + .5) {
|
|
716
|
+
if (floor$1 % 2 === 0) return floor$1;
|
|
717
|
+
return floor$1 + 1;
|
|
717
718
|
}
|
|
718
719
|
return Math.round(value);
|
|
719
720
|
}
|
|
@@ -841,5 +842,6 @@ const trunc = dualImpl({
|
|
|
841
842
|
normalImpl: "CPU implementation for trunc not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",
|
|
842
843
|
codegenImpl: (_ctx, [value]) => stitch`trunc(${value})`
|
|
843
844
|
});
|
|
845
|
+
|
|
844
846
|
//#endregion
|
|
845
|
-
export { abs, acos, acosh, asin, asinh, atan, atan2, atanh, ceil, clamp, cos, cosh, countLeadingZeros, countOneBits, countTrailingZeros, cross, degrees, determinant, distance, dot, dot4I8Packed, dot4U8Packed, exp, exp2, extractBits, faceForward, firstLeadingBit, firstTrailingBit, floor, fma, fract, frexp, insertBits, inverseSqrt, ldexp, length, log, log2, max, min, mix, modf, normalize, pow, quantizeToF16, radians, reflect, refract, reverseBits, round, saturate, sign, sin, sinh, smoothstep, sqrt, step, tan, tanh, transpose, trunc };
|
|
847
|
+
export { abs, acos, acosh, asin, asinh, atan, atan2, atanh, ceil, clamp, cos, cosh, countLeadingZeros, countOneBits, countTrailingZeros, cross, degrees, determinant, distance, dot, dot4I8Packed, dot4U8Packed, exp, exp2, extractBits, faceForward, firstLeadingBit, firstTrailingBit, floor, fma, fract, frexp, insertBits, inverseSqrt, ldexp, length, log, log2, max, min, mix, modf, normalize, pow, quantizeToF16, radians, reflect, refract, reverseBits, round, saturate, sign, sin, sinh, smoothstep, sqrt, step, tan, tanh, transpose, trunc };
|
package/std/operators.d.ts
CHANGED
|
@@ -9,13 +9,13 @@ declare function cpuAdd<T extends NumVec>(lhs: number, rhs: T): T;
|
|
|
9
9
|
declare function cpuAdd<T extends NumVec>(lhs: T, rhs: number): T;
|
|
10
10
|
declare function cpuAdd<T extends NumVec | Mat>(lhs: T, rhs: T): T;
|
|
11
11
|
declare function cpuAdd<Lhs extends number | NumVec | Mat, Rhs extends (Lhs extends number ? number | NumVec : Lhs extends NumVec ? number | Lhs : Lhs extends Mat ? Lhs : never)>(lhs: Lhs, rhs: Rhs): Lhs | Rhs;
|
|
12
|
-
declare const add: DualFn
|
|
12
|
+
declare const add: DualFn<typeof cpuAdd>;
|
|
13
13
|
declare function cpuSub(lhs: number, rhs: number): number;
|
|
14
14
|
declare function cpuSub<T extends NumVec>(lhs: number, rhs: T): T;
|
|
15
15
|
declare function cpuSub<T extends NumVec>(lhs: T, rhs: number): T;
|
|
16
16
|
declare function cpuSub<T extends NumVec | Mat>(lhs: T, rhs: T): T;
|
|
17
17
|
declare function cpuSub<Lhs extends number | NumVec | Mat, Rhs extends (Lhs extends number ? number | NumVec : Lhs extends NumVec ? number | Lhs : Lhs extends Mat ? Lhs : never)>(lhs: Lhs, rhs: Rhs): Lhs | Rhs;
|
|
18
|
-
declare const sub: DualFn
|
|
18
|
+
declare const sub: DualFn<typeof cpuSub>;
|
|
19
19
|
declare function cpuMul(lhs: number, rhs: number): number;
|
|
20
20
|
declare function cpuMul<MV extends NumVec | Mat>(lhs: number, rhs: MV): MV;
|
|
21
21
|
declare function cpuMul<MV extends NumVec | Mat>(lhs: MV, rhs: number): MV;
|
|
@@ -24,12 +24,12 @@ declare function cpuMul<M extends Mat, V extends vBaseForMat<M>>(lhs: V, rhs: M)
|
|
|
24
24
|
declare function cpuMul<M extends Mat, V extends vBaseForMat<M>>(lhs: M, rhs: V): V;
|
|
25
25
|
declare function cpuMul<M extends Mat>(lhs: M, rhs: M): M;
|
|
26
26
|
declare function cpuMul<Lhs extends number | NumVec | Mat, Rhs extends (Lhs extends number ? number | NumVec | Mat : Lhs extends NumVec ? number | Lhs | mBaseForVec<Lhs> : Lhs extends Mat ? number | vBaseForMat<Lhs> | Lhs : never)>(lhs: Lhs, rhs: Rhs): Lhs | Rhs;
|
|
27
|
-
declare const mul: DualFn
|
|
27
|
+
declare const mul: DualFn<typeof cpuMul>;
|
|
28
28
|
declare function cpuDiv(lhs: number, rhs: number): number;
|
|
29
29
|
declare function cpuDiv<T extends NumVec>(lhs: T, rhs: T): T;
|
|
30
30
|
declare function cpuDiv<T extends NumVec>(lhs: number, rhs: T): T;
|
|
31
31
|
declare function cpuDiv<T extends NumVec>(lhs: T, rhs: number): T;
|
|
32
|
-
declare const div: DualFn
|
|
32
|
+
declare const div: DualFn<typeof cpuDiv>;
|
|
33
33
|
type ModOverload = {
|
|
34
34
|
(a: number, b: number): number;
|
|
35
35
|
<T extends NumVec>(a: T, b: T): T;
|
|
@@ -40,17 +40,17 @@ type ModOverload = {
|
|
|
40
40
|
* @privateRemarks
|
|
41
41
|
* Both JS and WGSL implementations use truncated definition of modulo
|
|
42
42
|
*/
|
|
43
|
-
declare const mod: DualFn
|
|
43
|
+
declare const mod: DualFn<ModOverload>;
|
|
44
44
|
declare function cpuNeg(value: number): number;
|
|
45
45
|
declare function cpuNeg<T extends NumVec>(value: T): T;
|
|
46
|
-
declare const neg: DualFn
|
|
46
|
+
declare const neg: DualFn<typeof cpuNeg>;
|
|
47
47
|
declare function cpuBitShiftLeft(lhs: number, rhs: number): number;
|
|
48
48
|
declare function cpuBitShiftLeft<T extends AnyIntegerVecInstance>(lhs: T, rhs: number): T;
|
|
49
49
|
declare function cpuBitShiftLeft<T extends AnyIntegerVecInstance>(lhs: T, rhs: vecIToVecU<T>): T;
|
|
50
|
-
declare const bitShiftLeft: DualFn
|
|
50
|
+
declare const bitShiftLeft: DualFn<typeof cpuBitShiftLeft>;
|
|
51
51
|
declare function cpuBitShiftRight(lhs: number, rhs: number): number;
|
|
52
52
|
declare function cpuBitShiftRight<T extends AnyIntegerVecInstance>(lhs: T, rhs: number): T;
|
|
53
53
|
declare function cpuBitShiftRight<T extends AnyIntegerVecInstance>(lhs: T, rhs: vecIToVecU<T>): T;
|
|
54
|
-
declare const bitShiftRight: DualFn
|
|
54
|
+
declare const bitShiftRight: DualFn<typeof cpuBitShiftRight>;
|
|
55
55
|
//#endregion
|
|
56
56
|
export { add, bitShiftLeft, bitShiftRight, div, mod, mul, neg, sub };
|
package/std/operators.js
CHANGED
|
@@ -6,6 +6,7 @@ import { abstractFloat, f16, f32, i32, u32 } from "../data/numeric.js";
|
|
|
6
6
|
import { vec2i, vec2u, vec3i, vec3u, vec4i, vec4u, vecTypeToConstructor } from "../data/vector.js";
|
|
7
7
|
import { dualImpl } from "../core/function/dualImpl.js";
|
|
8
8
|
import { VectorOps } from "../data/vectorOps.js";
|
|
9
|
+
|
|
9
10
|
//#region src/std/operators.ts
|
|
10
11
|
const getPrimitive = (t) => "primitive" in t ? t.primitive : t;
|
|
11
12
|
const makeBinarySignature = (opts) => (lhs, rhs) => {
|
|
@@ -18,11 +19,11 @@ const makeBinarySignature = (opts) => (lhs, rhs) => {
|
|
|
18
19
|
const lhsC = isVec(lhs) || isMat(lhs);
|
|
19
20
|
const rhsC = isVec(rhs) || isMat(rhs);
|
|
20
21
|
if (!lhsC && !rhsC) {
|
|
21
|
-
const unified = unify([lhs, rhs], restrict);
|
|
22
|
-
if (!unified) return fail("incompatible scalar types");
|
|
22
|
+
const unified$1 = unify([lhs, rhs], restrict);
|
|
23
|
+
if (!unified$1) return fail("incompatible scalar types");
|
|
23
24
|
return {
|
|
24
|
-
argTypes: unified,
|
|
25
|
-
returnType: unified[0]
|
|
25
|
+
argTypes: unified$1,
|
|
26
|
+
returnType: unified$1[0]
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
29
|
if (lhsC && rhsC) {
|
|
@@ -223,5 +224,6 @@ const bitShiftRight = dualImpl({
|
|
|
223
224
|
return stitch`(${lhs} >> ${rhs})`;
|
|
224
225
|
}
|
|
225
226
|
});
|
|
227
|
+
|
|
226
228
|
//#endregion
|
|
227
|
-
export { add, bitShiftLeft, bitShiftRight, div, mod, mul, neg, sub };
|
|
229
|
+
export { add, bitShiftLeft, bitShiftRight, div, mod, mul, neg, sub };
|
package/std/packing.d.ts
CHANGED
|
@@ -2,25 +2,26 @@ import { DualFn } from "../types.js";
|
|
|
2
2
|
import { v2f, v4f } from "../data/wgslTypes.js";
|
|
3
3
|
|
|
4
4
|
//#region src/std/packing.d.ts
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* @privateRemarks
|
|
7
8
|
* https://gpuweb.github.io/gpuweb/wgsl/#unpack2x16float-builtin
|
|
8
9
|
*/
|
|
9
|
-
declare const unpack2x16float: DualFn
|
|
10
|
+
declare const unpack2x16float: DualFn<(e: number) => v2f>;
|
|
10
11
|
/**
|
|
11
12
|
* @privateRemarks
|
|
12
13
|
* https://gpuweb.github.io/gpuweb/wgsl/#pack2x16float-builtin
|
|
13
14
|
*/
|
|
14
|
-
declare const pack2x16float: DualFn
|
|
15
|
+
declare const pack2x16float: DualFn<(e: v2f) => number>;
|
|
15
16
|
/**
|
|
16
17
|
* @privateRemarks
|
|
17
18
|
* https://gpuweb.github.io/gpuweb/wgsl/#unpack4x8unorm-builtin
|
|
18
19
|
*/
|
|
19
|
-
declare const unpack4x8unorm: DualFn
|
|
20
|
+
declare const unpack4x8unorm: DualFn<(e: number) => v4f>;
|
|
20
21
|
/**
|
|
21
22
|
* @privateRemarks
|
|
22
23
|
* https://gpuweb.github.io/gpuweb/wgsl/#pack4x8unorm-builtin
|
|
23
24
|
*/
|
|
24
|
-
declare const pack4x8unorm: DualFn
|
|
25
|
+
declare const pack4x8unorm: DualFn<(e: v4f) => number>;
|
|
25
26
|
//#endregion
|
|
26
27
|
export { pack2x16float, pack4x8unorm, unpack2x16float, unpack4x8unorm };
|
package/std/packing.js
CHANGED
|
@@ -3,6 +3,7 @@ import { u32 } from "../data/numeric.js";
|
|
|
3
3
|
import { vec2f, vec4f } from "../data/vector.js";
|
|
4
4
|
import { dualImpl } from "../core/function/dualImpl.js";
|
|
5
5
|
import * as TB from "typed-binary";
|
|
6
|
+
|
|
6
7
|
//#region src/std/packing.ts
|
|
7
8
|
/**
|
|
8
9
|
* @privateRemarks
|
|
@@ -80,5 +81,6 @@ const pack4x8unorm = dualImpl({
|
|
|
80
81
|
},
|
|
81
82
|
codegenImpl: (_ctx, [e]) => stitch`pack4x8unorm(${e})`
|
|
82
83
|
});
|
|
84
|
+
|
|
83
85
|
//#endregion
|
|
84
|
-
export { pack2x16float, pack4x8unorm, unpack2x16float, unpack4x8unorm };
|
|
86
|
+
export { pack2x16float, pack4x8unorm, unpack2x16float, unpack4x8unorm };
|
package/std/range.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { TgpuComptime } from "../core/function/comptime.js";
|
|
2
|
+
import "../indexNamedExports.js";
|
|
3
|
+
|
|
2
4
|
//#region src/std/range.d.ts
|
|
3
5
|
interface TgpuRange extends Array<number> {
|
|
4
6
|
start: number;
|
|
@@ -19,6 +21,6 @@ interface TgpuRange extends Array<number> {
|
|
|
19
21
|
*
|
|
20
22
|
* Can also be combined with `tgpu.unroll` to unroll a specific number of iterations.
|
|
21
23
|
*/
|
|
22
|
-
declare const range: TgpuComptime
|
|
24
|
+
declare const range: TgpuComptime<((end: number) => TgpuRange) & ((start: number, end?: number, step?: number) => TgpuRange)>;
|
|
23
25
|
//#endregion
|
|
24
26
|
export { range };
|
package/std/range.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { comptime } from "../core/function/comptime.js";
|
|
2
|
+
|
|
2
3
|
//#region src/std/range.ts
|
|
3
4
|
/**
|
|
4
5
|
* Returns an array of values between `start` (inclusive) and `end` (exclusive) with the given `step`.
|
|
@@ -34,5 +35,6 @@ const range = comptime((start, end, step = 1) => {
|
|
|
34
35
|
function isTgpuRange(value) {
|
|
35
36
|
return Array.isArray(value) && "start" in value && "end" in value && "step" in value;
|
|
36
37
|
}
|
|
38
|
+
|
|
37
39
|
//#endregion
|
|
38
|
-
export { isTgpuRange, range };
|
|
40
|
+
export { isTgpuRange, range };
|
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<IdentityNumOrVec>;
|
|
26
|
+
declare const subgroupExclusiveAdd: DualFn<IdentityNumOrVec>;
|
|
27
|
+
declare const subgroupInclusiveAdd: DualFn<IdentityNumOrVec>;
|
|
28
|
+
declare const subgroupAll: DualFn<(e: boolean) => boolean>;
|
|
29
|
+
declare const subgroupAnd: DualFn<IdentityIntNumOrVec>;
|
|
30
|
+
declare const subgroupAny: DualFn<(e: boolean) => boolean>;
|
|
31
|
+
declare const subgroupBallot: DualFn<(e: boolean) => v4u>;
|
|
32
|
+
declare const subgroupBroadcast: DualFn<IdentityNumOrVecWithIdx>;
|
|
33
|
+
declare const subgroupBroadcastFirst: DualFn<IdentityNumOrVec>;
|
|
34
|
+
declare const subgroupElect: DualFn<() => boolean>;
|
|
35
|
+
declare const subgroupMax: DualFn<IdentityNumOrVec>;
|
|
36
|
+
declare const subgroupMin: DualFn<IdentityNumOrVec>;
|
|
37
|
+
declare const subgroupMul: DualFn<IdentityNumOrVec>;
|
|
38
|
+
declare const subgroupExclusiveMul: DualFn<IdentityNumOrVec>;
|
|
39
|
+
declare const subgroupInclusiveMul: DualFn<IdentityNumOrVec>;
|
|
40
|
+
declare const subgroupOr: DualFn<IdentityIntNumOrVec>;
|
|
41
|
+
declare const subgroupShuffle: DualFn<IdentityNumOrVecWithIdx>;
|
|
42
|
+
declare const subgroupShuffleDown: DualFn<IdentityNumOrVecWithDelta>;
|
|
43
|
+
declare const subgroupShuffleUp: DualFn<IdentityNumOrVecWithDelta>;
|
|
44
|
+
declare const subgroupShuffleXor: DualFn<IdentityNumOrVecWithMask>;
|
|
45
|
+
declare const subgroupXor: DualFn<IdentityIntNumOrVec>;
|
|
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,6 +3,7 @@ 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
|
+
|
|
6
7
|
//#region src/std/subgroup.ts
|
|
7
8
|
const errorMessage = "Subgroup operations can only be used in the GPU context.";
|
|
8
9
|
const subgroupAdd = dualImpl({
|
|
@@ -214,5 +215,6 @@ const subgroupXor = dualImpl({
|
|
|
214
215
|
normalImpl: errorMessage,
|
|
215
216
|
codegenImpl: (_ctx, [e]) => stitch`subgroupXor(${e})`
|
|
216
217
|
});
|
|
218
|
+
|
|
217
219
|
//#endregion
|
|
218
|
-
export { subgroupAdd, subgroupAll, subgroupAnd, subgroupAny, subgroupBallot, subgroupBroadcast, subgroupBroadcastFirst, subgroupElect, subgroupExclusiveAdd, subgroupExclusiveMul, subgroupInclusiveAdd, subgroupInclusiveMul, subgroupMax, subgroupMin, subgroupMul, subgroupOr, subgroupShuffle, subgroupShuffleDown, subgroupShuffleUp, subgroupShuffleXor, subgroupXor };
|
|
220
|
+
export { subgroupAdd, subgroupAll, subgroupAnd, subgroupAny, subgroupBallot, subgroupBroadcast, subgroupBroadcastFirst, subgroupElect, subgroupExclusiveAdd, subgroupExclusiveMul, subgroupInclusiveAdd, subgroupInclusiveMul, subgroupMax, subgroupMin, subgroupMul, subgroupOr, subgroupShuffle, subgroupShuffleDown, subgroupShuffleUp, subgroupShuffleXor, subgroupXor };
|