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/boolean.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { DualFn } from "../types.js";
|
|
|
2
2
|
import { AnyBooleanVecInstance, AnyFloatVecInstance, AnyNumericVecInstance, AnyVec2Instance, AnyVec3Instance, AnyVecInstance, v2b, v3b, v4b } from "../data/wgslTypes.js";
|
|
3
3
|
|
|
4
4
|
//#region src/std/boolean.d.ts
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* Checks whether `lhs == rhs` on all components.
|
|
7
8
|
* Equivalent to `all(eq(lhs, rhs))`.
|
|
@@ -9,7 +10,7 @@ import { AnyBooleanVecInstance, AnyFloatVecInstance, AnyNumericVecInstance, AnyV
|
|
|
9
10
|
* allEq(vec2f(0.0, 1.0), vec2f(0.0, 2.0)) // returns false
|
|
10
11
|
* allEq(vec3u(0, 1, 2), vec3u(0, 1, 2)) // returns true
|
|
11
12
|
*/
|
|
12
|
-
declare const allEq: DualFn
|
|
13
|
+
declare const allEq: DualFn<(<T extends AnyVecInstance>(lhs: T, rhs: T) => boolean)>;
|
|
13
14
|
/**
|
|
14
15
|
* Checks **component-wise** whether `lhs == rhs`.
|
|
15
16
|
* This function does **not** return `bool`, for that use-case, wrap the result in `all`, or use `allEq`.
|
|
@@ -19,7 +20,7 @@ declare const allEq: DualFn;
|
|
|
19
20
|
* all(eq(vec4i(4, 3, 2, 1), vec4i(4, 3, 2, 1))) // returns true
|
|
20
21
|
* allEq(vec4i(4, 3, 2, 1), vec4i(4, 3, 2, 1)) // returns true
|
|
21
22
|
*/
|
|
22
|
-
declare const eq: DualFn
|
|
23
|
+
declare const eq: DualFn<(<T extends AnyVecInstance>(lhs: T, rhs: T) => T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b)>;
|
|
23
24
|
/**
|
|
24
25
|
* Checks **component-wise** whether `lhs != rhs`.
|
|
25
26
|
* This function does **not** return `bool`, for that use-case, wrap the result in `any`.
|
|
@@ -28,7 +29,7 @@ declare const eq: DualFn;
|
|
|
28
29
|
* ne(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(true, false, true)
|
|
29
30
|
* any(ne(vec4i(4, 3, 2, 1), vec4i(4, 2, 2, 1))) // returns true
|
|
30
31
|
*/
|
|
31
|
-
declare const ne: DualFn
|
|
32
|
+
declare const ne: DualFn<(<T extends AnyVecInstance>(lhs: T, rhs: T) => VecInstanceToBooleanVecInstance<T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b>)>;
|
|
32
33
|
/**
|
|
33
34
|
* Checks **component-wise** whether `lhs < rhs`.
|
|
34
35
|
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
|
@@ -37,7 +38,7 @@ declare const ne: DualFn;
|
|
|
37
38
|
* lt(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(true, false, false)
|
|
38
39
|
* all(lt(vec4i(1, 2, 3, 4), vec4i(2, 3, 4, 5))) // returns true
|
|
39
40
|
*/
|
|
40
|
-
declare const lt: DualFn
|
|
41
|
+
declare const lt: DualFn<(<T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b)>;
|
|
41
42
|
/**
|
|
42
43
|
* Checks **component-wise** whether `lhs <= rhs`.
|
|
43
44
|
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
|
@@ -46,7 +47,7 @@ declare const lt: DualFn;
|
|
|
46
47
|
* le(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(true, true, false)
|
|
47
48
|
* all(le(vec4i(1, 2, 3, 4), vec4i(2, 3, 3, 5))) // returns true
|
|
48
49
|
*/
|
|
49
|
-
declare const le: DualFn
|
|
50
|
+
declare const le: DualFn<(<T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b)>;
|
|
50
51
|
/**
|
|
51
52
|
* Checks **component-wise** whether `lhs > rhs`.
|
|
52
53
|
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
|
@@ -55,7 +56,7 @@ declare const le: DualFn;
|
|
|
55
56
|
* gt(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(false, false, true)
|
|
56
57
|
* all(gt(vec4i(2, 3, 4, 5), vec4i(1, 2, 3, 4))) // returns true
|
|
57
58
|
*/
|
|
58
|
-
declare const gt: DualFn
|
|
59
|
+
declare const gt: DualFn<(<T extends AnyNumericVecInstance>(lhs: T, rhs: T) => VecInstanceToBooleanVecInstance<VecInstanceToBooleanVecInstance<VecInstanceToBooleanVecInstance<T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b>>>)>;
|
|
59
60
|
/**
|
|
60
61
|
* Checks **component-wise** whether `lhs >= rhs`.
|
|
61
62
|
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
|
@@ -64,7 +65,7 @@ declare const gt: DualFn;
|
|
|
64
65
|
* ge(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(false, true, true)
|
|
65
66
|
* all(ge(vec4i(2, 2, 4, 5), vec4i(1, 2, 3, 4))) // returns true
|
|
66
67
|
*/
|
|
67
|
-
declare const ge: DualFn
|
|
68
|
+
declare const ge: DualFn<(<T extends AnyNumericVecInstance>(lhs: T, rhs: T) => VecInstanceToBooleanVecInstance<T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b>)>;
|
|
68
69
|
type VecInstanceToBooleanVecInstance<T extends AnyVecInstance> = T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b;
|
|
69
70
|
declare function cpuNot(value: boolean): boolean;
|
|
70
71
|
declare function cpuNot(value: number): boolean;
|
|
@@ -85,35 +86,35 @@ declare function cpuNot(value: unknown): boolean;
|
|
|
85
86
|
* not({a: 1882}) // returns false
|
|
86
87
|
* not(NaN) // returns false **as in WGSL**
|
|
87
88
|
*/
|
|
88
|
-
declare const not: DualFn
|
|
89
|
+
declare const not: DualFn<typeof cpuNot>;
|
|
89
90
|
/**
|
|
90
91
|
* Returns **component-wise** logical `or` result.
|
|
91
92
|
* @example
|
|
92
93
|
* or(vec2b(false, true), vec2b(false, false)) // returns vec2b(false, true)
|
|
93
94
|
* or(vec3b(true, true, false), vec3b(false, true, false)) // returns vec3b(true, true, false)
|
|
94
95
|
*/
|
|
95
|
-
declare const or: DualFn
|
|
96
|
+
declare const or: DualFn<(<T extends AnyBooleanVecInstance>(lhs: T, rhs: T) => T)>;
|
|
96
97
|
/**
|
|
97
98
|
* Returns **component-wise** logical `and` result.
|
|
98
99
|
* @example
|
|
99
100
|
* and(vec2b(false, true), vec2b(true, true)) // returns vec2b(false, true)
|
|
100
101
|
* and(vec3b(true, true, false), vec3b(false, true, false)) // returns vec3b(false, true, false)
|
|
101
102
|
*/
|
|
102
|
-
declare const and: DualFn
|
|
103
|
+
declare const and: DualFn<(<T extends AnyBooleanVecInstance>(lhs: T, rhs: T) => VecInstanceToBooleanVecInstance<VecInstanceToBooleanVecInstance<T>>)>;
|
|
103
104
|
/**
|
|
104
105
|
* Returns `true` if each component of `value` is true.
|
|
105
106
|
* @example
|
|
106
107
|
* all(vec2b(false, true)) // returns false
|
|
107
108
|
* all(vec3b(true, true, true)) // returns true
|
|
108
109
|
*/
|
|
109
|
-
declare const all: DualFn
|
|
110
|
+
declare const all: DualFn<(value: AnyBooleanVecInstance) => boolean>;
|
|
110
111
|
/**
|
|
111
112
|
* Returns `true` if any component of `value` is true.
|
|
112
113
|
* @example
|
|
113
114
|
* any(vec2b(false, true)) // returns true
|
|
114
115
|
* any(vec3b(false, false, false)) // returns false
|
|
115
116
|
*/
|
|
116
|
-
declare const any: DualFn
|
|
117
|
+
declare const any: DualFn<(value: AnyBooleanVecInstance) => boolean>;
|
|
117
118
|
/**
|
|
118
119
|
* Checks whether the given elements differ by at most the `precision` value.
|
|
119
120
|
* Checks all elements of `lhs` and `rhs` if arguments are vectors.
|
|
@@ -123,7 +124,7 @@ declare const any: DualFn;
|
|
|
123
124
|
*
|
|
124
125
|
* @param {number} precision argument that specifies the maximum allowed difference, 0.01 by default.
|
|
125
126
|
*/
|
|
126
|
-
declare const isCloseTo: DualFn
|
|
127
|
+
declare const isCloseTo: DualFn<(<T extends AnyFloatVecInstance | number>(lhs: T, rhs: T, precision?: number) => boolean)>;
|
|
127
128
|
declare function cpuSelect(f: boolean, t: boolean, cond: boolean): boolean;
|
|
128
129
|
declare function cpuSelect(f: number, t: number, cond: boolean): number;
|
|
129
130
|
declare function cpuSelect<T extends AnyVecInstance>(f: T, t: T, cond: boolean | (T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b)): T;
|
|
@@ -136,6 +137,6 @@ declare function cpuSelect<T extends AnyVecInstance>(f: T, t: T, cond: boolean |
|
|
|
136
137
|
* select(vec2i(1, 2), vec2i(3, 4), true) // returns vec2i(3, 4)
|
|
137
138
|
* select(vec2i(1, 2), vec2i(3, 4), vec2b(false, true)) // returns vec2i(1, 4)
|
|
138
139
|
*/
|
|
139
|
-
declare const select: DualFn
|
|
140
|
+
declare const select: DualFn<typeof cpuSelect>;
|
|
140
141
|
//#endregion
|
|
141
142
|
export { all, allEq, and, any, eq, ge, gt, isCloseTo, le, lt, ne, not, or, select };
|
package/std/boolean.js
CHANGED
|
@@ -7,6 +7,7 @@ import { vec2b, vec3b, vec4b } from "../data/vector.js";
|
|
|
7
7
|
import { dualImpl } from "../core/function/dualImpl.js";
|
|
8
8
|
import { VectorOps } from "../data/vectorOps.js";
|
|
9
9
|
import { sub } from "./operators.js";
|
|
10
|
+
|
|
10
11
|
//#region src/std/boolean.ts
|
|
11
12
|
function correspondingBooleanVectorSchema(dataType) {
|
|
12
13
|
if (dataType.type.includes("2")) return vec2b;
|
|
@@ -295,5 +296,6 @@ const select = dualImpl({
|
|
|
295
296
|
normalImpl: cpuSelect,
|
|
296
297
|
codegenImpl: (_ctx, [f, t, cond]) => stitch`select(${f}, ${t}, ${cond})`
|
|
297
298
|
});
|
|
299
|
+
|
|
298
300
|
//#endregion
|
|
299
|
-
export { all, allEq, and, any, eq, ge, gt, isCloseTo, le, lt, ne, not, or, select };
|
|
301
|
+
export { all, allEq, and, any, eq, ge, gt, isCloseTo, le, lt, ne, not, or, select };
|
package/std/derivative.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import { AnyFloat32VecInstance } from "../data/wgslTypes.js";
|
|
|
3
3
|
|
|
4
4
|
//#region src/std/derivative.d.ts
|
|
5
5
|
type DerivativeSignature = ((value: number) => number) & (<T extends AnyFloat32VecInstance>(value: T) => T);
|
|
6
|
-
declare const dpdx: DualFn
|
|
7
|
-
declare const dpdxCoarse: DualFn
|
|
8
|
-
declare const dpdxFine: DualFn
|
|
9
|
-
declare const dpdy: DualFn
|
|
10
|
-
declare const dpdyCoarse: DualFn
|
|
11
|
-
declare const dpdyFine: DualFn
|
|
12
|
-
declare const fwidth: DualFn
|
|
13
|
-
declare const fwidthCoarse: DualFn
|
|
14
|
-
declare const fwidthFine: DualFn
|
|
6
|
+
declare const dpdx: DualFn<DerivativeSignature>;
|
|
7
|
+
declare const dpdxCoarse: DualFn<DerivativeSignature>;
|
|
8
|
+
declare const dpdxFine: DualFn<DerivativeSignature>;
|
|
9
|
+
declare const dpdy: DualFn<DerivativeSignature>;
|
|
10
|
+
declare const dpdyCoarse: DualFn<DerivativeSignature>;
|
|
11
|
+
declare const dpdyFine: DualFn<DerivativeSignature>;
|
|
12
|
+
declare const fwidth: DualFn<DerivativeSignature>;
|
|
13
|
+
declare const fwidthCoarse: DualFn<DerivativeSignature>;
|
|
14
|
+
declare const fwidthFine: DualFn<DerivativeSignature>;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { dpdx, dpdxCoarse, dpdxFine, dpdy, dpdyCoarse, dpdyFine, fwidth, fwidthCoarse, fwidthFine };
|
package/std/derivative.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { stitch } from "../core/resolve/stitch.js";
|
|
2
2
|
import { dualImpl } from "../core/function/dualImpl.js";
|
|
3
|
+
|
|
3
4
|
//#region src/std/derivative.ts
|
|
4
5
|
const derivativeNormalError = "Derivative builtins are not allowed on the CPU";
|
|
5
6
|
const dpdx = dualImpl({
|
|
@@ -83,5 +84,6 @@ const fwidthFine = dualImpl({
|
|
|
83
84
|
}),
|
|
84
85
|
codegenImpl: (_ctx, [value]) => stitch`fwidthFine(${value})`
|
|
85
86
|
});
|
|
87
|
+
|
|
86
88
|
//#endregion
|
|
87
|
-
export { dpdx, dpdxCoarse, dpdxFine, dpdy, dpdyCoarse, dpdyFine, fwidth, fwidthCoarse, fwidthFine };
|
|
89
|
+
export { dpdx, dpdxCoarse, dpdxFine, dpdy, dpdyCoarse, dpdyFine, fwidth, fwidthCoarse, fwidthFine };
|
package/std/discard.d.ts
CHANGED
package/std/discard.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Void } from "../data/wgslTypes.js";
|
|
2
2
|
import { dualImpl } from "../core/function/dualImpl.js";
|
|
3
|
+
|
|
3
4
|
//#region src/std/discard.ts
|
|
4
5
|
const discard = dualImpl({
|
|
5
6
|
name: "discard",
|
|
@@ -10,5 +11,6 @@ const discard = dualImpl({
|
|
|
10
11
|
},
|
|
11
12
|
codegenImpl: () => "discard;"
|
|
12
13
|
});
|
|
14
|
+
|
|
13
15
|
//#endregion
|
|
14
|
-
export { discard };
|
|
16
|
+
export { discard };
|
package/std/extensions.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { WgslExtension } from "../wgslExtensions.js";
|
|
2
2
|
import { TgpuComptime } from "../core/function/comptime.js";
|
|
3
|
+
import "../indexNamedExports.js";
|
|
4
|
+
|
|
3
5
|
//#region src/std/extensions.d.ts
|
|
4
|
-
declare const extensionEnabled: TgpuComptime
|
|
6
|
+
declare const extensionEnabled: TgpuComptime<(extensionName: WgslExtension) => boolean>;
|
|
5
7
|
//#endregion
|
|
6
8
|
export { extensionEnabled };
|
package/std/extensions.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getResolutionCtx } from "../execMode.js";
|
|
2
2
|
import { comptime } from "../core/function/comptime.js";
|
|
3
3
|
import { wgslExtensions } from "../wgslExtensions.js";
|
|
4
|
+
|
|
4
5
|
//#region src/std/extensions.ts
|
|
5
6
|
const extensionEnabled = comptime((extensionName) => {
|
|
6
7
|
const resolutionCtx = getResolutionCtx();
|
|
@@ -8,5 +9,6 @@ const extensionEnabled = comptime((extensionName) => {
|
|
|
8
9
|
if (typeof extensionName !== "string" || !wgslExtensions.includes(extensionName)) throw new Error(`extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: '${extensionName}'`);
|
|
9
10
|
return (resolutionCtx.enableExtensions ?? []).includes(extensionName);
|
|
10
11
|
});
|
|
12
|
+
|
|
11
13
|
//#endregion
|
|
12
|
-
export { extensionEnabled };
|
|
14
|
+
export { extensionEnabled };
|
package/std/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __export } from "../_virtual/rolldown_runtime.js";
|
|
2
2
|
import { identity2, identity3, identity4, rotationX4, rotationY4, rotationZ4, scaling4, translation4 } from "../data/matrix.js";
|
|
3
3
|
import { add, bitShiftLeft, bitShiftRight, div, mod, mul, neg, sub } from "./operators.js";
|
|
4
4
|
import { 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 } from "./numeric.js";
|
|
@@ -14,8 +14,9 @@ import { dpdx, dpdxCoarse, dpdxFine, dpdy, dpdyCoarse, dpdyFine, fwidth, fwidthC
|
|
|
14
14
|
import { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleGrad, textureSampleLevel, textureStore } from "./texture.js";
|
|
15
15
|
import { subgroupAdd, subgroupAll, subgroupAnd, subgroupAny, subgroupBallot, subgroupBroadcast, subgroupBroadcastFirst, subgroupElect, subgroupExclusiveAdd, subgroupExclusiveMul, subgroupInclusiveAdd, subgroupInclusiveMul, subgroupMax, subgroupMin, subgroupMul, subgroupOr, subgroupShuffle, subgroupShuffleDown, subgroupShuffleUp, subgroupShuffleXor, subgroupXor } from "./subgroup.js";
|
|
16
16
|
import { extensionEnabled } from "./extensions.js";
|
|
17
|
+
|
|
17
18
|
//#region src/std/index.ts
|
|
18
|
-
var std_exports = /* @__PURE__ */
|
|
19
|
+
var std_exports = /* @__PURE__ */ __export({
|
|
19
20
|
abs: () => abs,
|
|
20
21
|
acos: () => acos,
|
|
21
22
|
acosh: () => acosh,
|
|
@@ -176,5 +177,6 @@ var std_exports = /* @__PURE__ */ __exportAll({
|
|
|
176
177
|
unpack4x8unorm: () => unpack4x8unorm,
|
|
177
178
|
workgroupBarrier: () => workgroupBarrier
|
|
178
179
|
});
|
|
180
|
+
|
|
179
181
|
//#endregion
|
|
180
|
-
export { abs, acos, acosh, add, all, allEq, and, any, arrayLength, asin, asinh, atan, atan2, atanh, atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, bitShiftLeft, bitShiftRight, bitcastU32toF32, bitcastU32toI32, ceil, clamp, cos, cosh, countLeadingZeros, countOneBits, countTrailingZeros, cross, degrees, determinant, discard, distance, div, dot, dot4I8Packed, dot4U8Packed, dpdx, dpdxCoarse, dpdxFine, dpdy, dpdyCoarse, dpdyFine, eq, exp, exp2, extensionEnabled, extractBits, faceForward, firstLeadingBit, firstTrailingBit, floor, fma, fract, frexp, fwidth, fwidthCoarse, fwidthFine, ge, gt, identity2, identity3, identity4, insertBits, inverseSqrt, isCloseTo, ldexp, le, length, log, log2, lt, max, min, mix, mod, modf, mul, ne, neg, normalize, not, or, pack2x16float, pack4x8unorm, pow, quantizeToF16, radians, range, reflect, refract, reverseBits, rotateX4, rotateY4, rotateZ4, rotationX4, rotationY4, rotationZ4, round, saturate, scale4, scaling4, select, sign, sin, sinh, smoothstep, sqrt, std_exports, step, storageBarrier, sub, subgroupAdd, subgroupAll, subgroupAnd, subgroupAny, subgroupBallot, subgroupBroadcast, subgroupBroadcastFirst, subgroupElect, subgroupExclusiveAdd, subgroupExclusiveMul, subgroupInclusiveAdd, subgroupInclusiveMul, subgroupMax, subgroupMin, subgroupMul, subgroupOr, subgroupShuffle, subgroupShuffleDown, subgroupShuffleUp, subgroupShuffleXor, subgroupXor, tan, tanh, textureBarrier, textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleGrad, textureSampleLevel, textureStore, translate4, translation4, transpose, trunc, unpack2x16float, unpack4x8unorm, workgroupBarrier };
|
|
182
|
+
export { abs, acos, acosh, add, all, allEq, and, any, arrayLength, asin, asinh, atan, atan2, atanh, atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, bitShiftLeft, bitShiftRight, bitcastU32toF32, bitcastU32toI32, ceil, clamp, cos, cosh, countLeadingZeros, countOneBits, countTrailingZeros, cross, degrees, determinant, discard, distance, div, dot, dot4I8Packed, dot4U8Packed, dpdx, dpdxCoarse, dpdxFine, dpdy, dpdyCoarse, dpdyFine, eq, exp, exp2, extensionEnabled, extractBits, faceForward, firstLeadingBit, firstTrailingBit, floor, fma, fract, frexp, fwidth, fwidthCoarse, fwidthFine, ge, gt, identity2, identity3, identity4, insertBits, inverseSqrt, isCloseTo, ldexp, le, length, log, log2, lt, max, min, mix, mod, modf, mul, ne, neg, normalize, not, or, pack2x16float, pack4x8unorm, pow, quantizeToF16, radians, range, reflect, refract, reverseBits, rotateX4, rotateY4, rotateZ4, rotationX4, rotationY4, rotationZ4, round, saturate, scale4, scaling4, select, sign, sin, sinh, smoothstep, sqrt, std_exports, step, storageBarrier, sub, subgroupAdd, subgroupAll, subgroupAnd, subgroupAny, subgroupBallot, subgroupBroadcast, subgroupBroadcastFirst, subgroupElect, subgroupExclusiveAdd, subgroupExclusiveMul, subgroupInclusiveAdd, subgroupInclusiveMul, subgroupMax, subgroupMin, subgroupMul, subgroupOr, subgroupShuffle, subgroupShuffleDown, subgroupShuffleUp, subgroupShuffleXor, subgroupXor, tan, tanh, textureBarrier, textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleGrad, textureSampleLevel, textureStore, translate4, translation4, transpose, trunc, unpack2x16float, unpack4x8unorm, workgroupBarrier };
|
package/std/matrix.d.ts
CHANGED
|
@@ -2,40 +2,41 @@ import { DualFn } from "../types.js";
|
|
|
2
2
|
import { m4x4f, v3f } from "../data/wgslTypes.js";
|
|
3
3
|
|
|
4
4
|
//#region src/std/matrix.d.ts
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* Translates the given 4-by-4 matrix by the given vector.
|
|
7
8
|
* @param {m4x4f} matrix - The matrix to be modified.
|
|
8
9
|
* @param {v3f} vector - The vector by which to translate the matrix.
|
|
9
10
|
* @returns {m4x4f} The translated matrix.
|
|
10
11
|
*/
|
|
11
|
-
declare const translate4: DualFn
|
|
12
|
+
declare const translate4: DualFn<(matrix: m4x4f, vector: v3f) => m4x4f>;
|
|
12
13
|
/**
|
|
13
14
|
* Scales the given 4-by-4 matrix in each dimension by an amount given by the corresponding entry in the given vector.
|
|
14
15
|
* @param {m4x4f} matrix - The matrix to be modified.
|
|
15
16
|
* @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.
|
|
16
17
|
* @returns {m4x4f} The scaled matrix.
|
|
17
18
|
*/
|
|
18
|
-
declare const scale4: DualFn
|
|
19
|
+
declare const scale4: DualFn<(matrix: m4x4f, vector: v3f) => m4x4f>;
|
|
19
20
|
/**
|
|
20
21
|
* Rotates the given 4-by-4 matrix around the x-axis by the given angle.
|
|
21
22
|
* @param {m4x4f} matrix - The matrix to be modified.
|
|
22
23
|
* @param {number} angle - The angle by which to rotate (in radians).
|
|
23
24
|
* @returns {m4x4f} The rotated matrix.
|
|
24
25
|
*/
|
|
25
|
-
declare const rotateX4: DualFn
|
|
26
|
+
declare const rotateX4: DualFn<(matrix: m4x4f, angle: number) => m4x4f>;
|
|
26
27
|
/**
|
|
27
28
|
* Rotates the given 4-by-4 matrix around the y-axis by the given angle.
|
|
28
29
|
* @param {m4x4f} matrix - The matrix to be modified.
|
|
29
30
|
* @param {number} angle - The angle by which to rotate (in radians).
|
|
30
31
|
* @returns {m4x4f} The rotated matrix.
|
|
31
32
|
*/
|
|
32
|
-
declare const rotateY4: DualFn
|
|
33
|
+
declare const rotateY4: DualFn<(matrix: m4x4f, angle: number) => m4x4f>;
|
|
33
34
|
/**
|
|
34
35
|
* Rotates the given 4-by-4 matrix around the z-axis by the given angle.
|
|
35
36
|
* @param {m4x4f} matrix - The matrix to be modified.
|
|
36
37
|
* @param {number} angle - The angle by which to rotate (in radians).
|
|
37
38
|
* @returns {m4x4f} The rotated matrix.
|
|
38
39
|
*/
|
|
39
|
-
declare const rotateZ4: DualFn
|
|
40
|
+
declare const rotateZ4: DualFn<(matrix: m4x4f, angle: number) => m4x4f>;
|
|
40
41
|
//#endregion
|
|
41
42
|
export { rotateX4, rotateY4, rotateZ4, scale4, translate4 };
|
package/std/matrix.js
CHANGED
|
@@ -5,6 +5,7 @@ import { vec3f } from "../data/vector.js";
|
|
|
5
5
|
import { dualImpl } from "../core/function/dualImpl.js";
|
|
6
6
|
import { mat4x4f, rotationX4, rotationY4, rotationZ4, scaling4, translation4 } from "../data/matrix.js";
|
|
7
7
|
import { mul } from "./operators.js";
|
|
8
|
+
|
|
8
9
|
//#region src/std/matrix.ts
|
|
9
10
|
const gpuTranslation4 = translation4[$gpuCallable].call.bind(translation4);
|
|
10
11
|
const gpuScaling4 = scaling4[$gpuCallable].call.bind(scaling4);
|
|
@@ -81,5 +82,6 @@ const rotateZ4 = dualImpl({
|
|
|
81
82
|
signature: rotateSignature,
|
|
82
83
|
codegenImpl: (ctx, [matrix, angle]) => stitch`(${gpuRotationZ4(ctx, [angle])} * ${matrix})`
|
|
83
84
|
});
|
|
85
|
+
|
|
84
86
|
//#endregion
|
|
85
|
-
export { rotateX4, rotateY4, rotateZ4, scale4, translate4 };
|
|
87
|
+
export { rotateX4, rotateY4, rotateZ4, scale4, translate4 };
|