typegpu 0.10.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_virtual/_rolldown/runtime.js +6 -11
- package/builtin.js +1 -3
- package/common/fullScreenTriangle.d.ts +1 -5
- package/common/fullScreenTriangle.js +1 -3
- package/common/index.d.ts +3 -2
- package/common/index.js +6 -4
- package/common/writeSoA.d.ts +16 -0
- package/common/writeSoA.js +90 -0
- package/core/buffer/buffer.d.ts +12 -7
- package/core/buffer/buffer.js +102 -53
- package/core/buffer/bufferShorthand.d.ts +5 -5
- package/core/buffer/bufferShorthand.js +9 -5
- package/core/buffer/bufferUsage.d.ts +0 -2
- package/core/buffer/bufferUsage.js +6 -4
- package/core/constant/tgpuConstant.d.ts +2 -1
- package/core/constant/tgpuConstant.js +8 -7
- package/core/declare/tgpuDeclare.js +8 -9
- package/core/function/autoIO.d.ts +7 -6
- package/core/function/autoIO.js +1 -3
- package/core/function/comptime.js +1 -3
- package/core/function/createCallableSchema.js +4 -6
- package/core/function/dualImpl.js +1 -3
- package/core/function/entryInputRouter.js +39 -0
- package/core/function/extractArgs.js +2 -2
- package/core/function/fnCore.js +19 -8
- package/core/function/fnTypes.d.ts +14 -8
- package/core/function/ioSchema.js +24 -3
- package/core/function/shelllessImpl.js +1 -3
- package/core/function/templateUtils.js +1 -2
- package/core/function/tgpuComputeFn.d.ts +2 -3
- package/core/function/tgpuComputeFn.js +9 -16
- package/core/function/tgpuFn.d.ts +2 -2
- package/core/function/tgpuFn.js +1 -3
- package/core/function/tgpuFragmentFn.d.ts +5 -1
- package/core/function/tgpuFragmentFn.js +5 -10
- package/core/function/tgpuVertexFn.d.ts +4 -0
- package/core/function/tgpuVertexFn.js +6 -12
- package/core/pipeline/applyPipelineState.js +1 -3
- package/core/pipeline/computePipeline.d.ts +2 -6
- package/core/pipeline/computePipeline.js +64 -63
- package/core/pipeline/connectAttachmentToShader.js +1 -3
- package/core/pipeline/connectTargetsToShader.js +1 -3
- package/core/pipeline/limitsOverflow.js +1 -2
- package/core/pipeline/pipelineUtils.js +29 -0
- package/core/pipeline/renderPipeline.d.ts +23 -5
- package/core/pipeline/renderPipeline.js +32 -14
- package/core/pipeline/timeable.d.ts +0 -3
- package/core/pipeline/timeable.js +3 -9
- package/core/pipeline/typeGuards.js +1 -3
- package/core/querySet/querySet.d.ts +0 -2
- package/core/querySet/querySet.js +37 -36
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +1 -3
- package/core/resolve/externals.d.ts +0 -2
- package/core/resolve/externals.js +2 -4
- package/core/resolve/namespace.js +1 -3
- package/core/resolve/resolveData.js +1 -3
- package/core/resolve/stitch.js +1 -3
- package/core/resolve/tgpuResolve.d.ts +3 -1
- package/core/resolve/tgpuResolve.js +3 -5
- package/core/root/configurableImpl.js +2 -3
- package/core/root/init.d.ts +0 -5
- package/core/root/init.js +35 -28
- package/core/root/rootTypes.d.ts +25 -5
- package/core/sampler/sampler.d.ts +0 -4
- package/core/sampler/sampler.js +3 -3
- package/core/simulate/tgpuSimulate.js +1 -3
- package/core/slot/accessor.d.ts +0 -4
- package/core/slot/accessor.js +1 -3
- package/core/slot/internalSlots.js +1 -3
- package/core/slot/lazy.js +1 -3
- package/core/slot/slot.js +2 -3
- package/core/slot/slotTypes.js +1 -3
- package/core/texture/externalTexture.d.ts +0 -6
- package/core/texture/externalTexture.js +2 -3
- package/core/texture/texture.d.ts +0 -4
- package/core/texture/texture.js +5 -3
- package/core/texture/textureFormats.js +1 -3
- package/core/texture/textureUtils.js +1 -3
- package/core/texture/usageExtension.js +1 -3
- package/core/unroll/tgpuUnroll.d.ts +58 -3
- package/core/unroll/tgpuUnroll.js +63 -5
- package/core/valueProxyUtils.js +1 -3
- package/core/variable/tgpuVariable.js +1 -3
- package/core/vertexLayout/connectAttributesToShader.js +1 -3
- package/core/vertexLayout/vertexLayout.js +9 -9
- package/data/alignIO.js +1 -2
- package/data/alignmentOf.d.ts +0 -1
- package/data/alignmentOf.js +1 -3
- package/data/array.d.ts +1 -3
- package/data/array.js +2 -4
- package/data/atomic.js +2 -3
- package/data/attributes.js +3 -3
- package/data/autoStruct.d.ts +1 -3
- package/data/autoStruct.js +1 -3
- package/data/compiledIO.js +83 -86
- package/data/dataIO.js +46 -39
- package/data/dataTypes.d.ts +7 -7
- package/data/dataTypes.js +6 -3
- package/data/deepEqual.js +1 -3
- package/data/disarray.d.ts +1 -3
- package/data/disarray.js +1 -3
- package/data/getLongestContiguousPrefix.d.ts +0 -1
- package/data/getLongestContiguousPrefix.js +1 -3
- package/data/index.d.ts +3 -3
- package/data/index.js +10 -3
- package/data/isContiguous.d.ts +0 -1
- package/data/isContiguous.js +1 -3
- package/data/matrix.d.ts +8 -10
- package/data/matrix.js +32 -18
- package/data/numberOps.js +1 -2
- package/data/numeric.js +16 -29
- package/data/offsetUtils.d.ts +2 -2
- package/data/offsetUtils.js +3 -5
- package/data/offsets.js +1 -3
- package/data/partialIO.js +84 -39
- package/data/ptr.d.ts +0 -1
- package/data/ptr.js +1 -3
- package/data/ref.d.ts +0 -3
- package/data/ref.js +1 -3
- package/data/sampler.js +1 -3
- package/data/schemaCallWrapper.js +1 -3
- package/data/schemaMemoryLayout.js +1 -3
- package/data/sizeOf.d.ts +0 -1
- package/data/sizeOf.js +1 -3
- package/data/snippet.js +12 -3
- package/data/struct.js +1 -3
- package/data/texture.js +1 -3
- package/data/unstruct.js +1 -3
- package/data/vector.js +4 -12
- package/data/vectorImpl.js +27 -28
- package/data/vectorOps.js +20 -3
- package/data/vertexFormatData.js +2 -3
- package/data/wgslTypes.d.ts +39 -11
- package/data/wgslTypes.js +10 -3
- package/errors.js +6 -3
- package/execMode.js +1 -3
- package/extension.js +1 -3
- package/getGPUValue.js +1 -3
- package/index.d.ts +4 -2
- package/index.js +3 -3
- package/indexNamedExports.d.ts +3 -1
- package/mathUtils.js +1 -2
- package/memo.js +8 -8
- package/nameRegistry.js +1 -3
- package/package.js +2 -3
- package/package.json +7 -7
- package/resolutionCtx.d.ts +0 -10
- package/resolutionCtx.js +84 -18
- package/shared/env.js +1 -2
- package/shared/generators.js +1 -2
- package/shared/meta.js +1 -3
- package/shared/repr.d.ts +32 -2
- package/shared/stringify.js +1 -3
- package/shared/symbols.d.ts +10 -1
- package/shared/symbols.js +10 -33
- package/shared/utilityTypes.d.ts +6 -2
- package/shared/utilityTypes.js +1 -2
- package/shared/vertexFormat.js +1 -2
- package/std/array.d.ts +1 -1
- package/std/array.js +1 -3
- package/std/atomic.d.ts +12 -12
- package/std/atomic.js +1 -3
- package/std/bitcast.d.ts +2 -2
- package/std/bitcast.js +1 -3
- package/std/boolean.d.ts +30 -16
- package/std/boolean.js +37 -12
- package/std/derivative.d.ts +9 -9
- package/std/derivative.js +1 -3
- package/std/discard.d.ts +1 -1
- package/std/discard.js +1 -3
- package/std/extensions.d.ts +1 -3
- package/std/extensions.js +1 -3
- package/std/index.d.ts +5 -4
- package/std/index.js +8 -5
- package/std/matrix.d.ts +5 -5
- package/std/matrix.js +1 -3
- package/std/numeric.d.ts +78 -132
- package/std/numeric.js +1 -3
- package/std/operators.d.ts +16 -8
- package/std/operators.js +80 -6
- package/std/packing.d.ts +4 -4
- package/std/packing.js +1 -3
- package/std/range.d.ts +24 -0
- package/std/range.js +38 -0
- package/std/subgroup.d.ts +21 -21
- package/std/subgroup.js +1 -3
- package/std/texture.d.ts +20 -11
- package/std/texture.js +13 -3
- package/tgpu.js +1 -3
- package/tgpuBindGroupLayout.js +9 -8
- package/tgpuUnstable.js +1 -3
- package/tgsl/accessIndex.js +2 -4
- package/tgsl/accessProp.js +8 -6
- package/tgsl/consoleLog/deserializers.js +1 -3
- package/tgsl/consoleLog/logGenerator.js +2 -4
- package/tgsl/consoleLog/serializers.js +24 -26
- package/tgsl/consoleLog/types.d.ts +0 -2
- package/tgsl/consoleLog/types.js +1 -2
- package/tgsl/conversion.js +1 -3
- package/tgsl/forOfUtils.js +35 -9
- package/tgsl/generationHelpers.js +3 -3
- package/tgsl/math.js +1 -3
- package/tgsl/shaderGenerator.d.ts +10 -8
- package/tgsl/shaderGenerator_members.d.ts +2 -0
- package/tgsl/shaderGenerator_members.js +6 -0
- package/tgsl/shellless.js +1 -8
- package/tgsl/wgslGenerator.d.ts +36 -0
- package/tgsl/wgslGenerator.js +144 -81
- package/types.d.ts +14 -4
- package/types.js +3 -3
- package/wgslExtensions.js +1 -2
package/std/array.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import { DualFn } from "../types.js";
|
|
|
2
2
|
import { _ref } from "../data/ref.js";
|
|
3
3
|
|
|
4
4
|
//#region src/std/array.d.ts
|
|
5
|
-
declare const arrayLength: DualFn
|
|
5
|
+
declare const arrayLength: DualFn;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { arrayLength };
|
package/std/array.js
CHANGED
|
@@ -4,7 +4,6 @@ import { ptrFn } from "../data/ptr.js";
|
|
|
4
4
|
import { isRef } from "../data/ref.js";
|
|
5
5
|
import { abstractInt, u32 } from "../data/numeric.js";
|
|
6
6
|
import { dualImpl } from "../core/function/dualImpl.js";
|
|
7
|
-
|
|
8
7
|
//#region src/std/array.ts
|
|
9
8
|
const sizeOfPointedToArray = (dataType) => isPtr(dataType) && isWgslArray(dataType.inner) ? dataType.inner.elementCount : 0;
|
|
10
9
|
const arrayLength = dualImpl({
|
|
@@ -22,6 +21,5 @@ const arrayLength = dualImpl({
|
|
|
22
21
|
return length > 0 ? `${length}` : stitch`arrayLength(${a})`;
|
|
23
22
|
}
|
|
24
23
|
});
|
|
25
|
-
|
|
26
24
|
//#endregion
|
|
27
|
-
export { arrayLength };
|
|
25
|
+
export { arrayLength };
|
package/std/atomic.d.ts
CHANGED
|
@@ -3,17 +3,17 @@ import { atomicI32, atomicU32 } from "../data/wgslTypes.js";
|
|
|
3
3
|
|
|
4
4
|
//#region src/std/atomic.d.ts
|
|
5
5
|
type AnyAtomic = atomicI32 | atomicU32;
|
|
6
|
-
declare const workgroupBarrier: DualFn
|
|
7
|
-
declare const storageBarrier: DualFn
|
|
8
|
-
declare const textureBarrier: DualFn
|
|
9
|
-
declare const atomicLoad: DualFn
|
|
10
|
-
declare const atomicStore: DualFn
|
|
11
|
-
declare const atomicAdd: DualFn
|
|
12
|
-
declare const atomicSub: DualFn
|
|
13
|
-
declare const atomicMax: DualFn
|
|
14
|
-
declare const atomicMin: DualFn
|
|
15
|
-
declare const atomicAnd: DualFn
|
|
16
|
-
declare const atomicOr: DualFn
|
|
17
|
-
declare const atomicXor: DualFn
|
|
6
|
+
declare const workgroupBarrier: DualFn;
|
|
7
|
+
declare const storageBarrier: DualFn;
|
|
8
|
+
declare const textureBarrier: DualFn;
|
|
9
|
+
declare const atomicLoad: DualFn;
|
|
10
|
+
declare const atomicStore: DualFn;
|
|
11
|
+
declare const atomicAdd: DualFn;
|
|
12
|
+
declare const atomicSub: DualFn;
|
|
13
|
+
declare const atomicMax: DualFn;
|
|
14
|
+
declare const atomicMin: DualFn;
|
|
15
|
+
declare const atomicAnd: DualFn;
|
|
16
|
+
declare const atomicOr: DualFn;
|
|
17
|
+
declare const atomicXor: DualFn;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, storageBarrier, textureBarrier, workgroupBarrier };
|
package/std/atomic.js
CHANGED
|
@@ -3,7 +3,6 @@ import { stitch } from "../core/resolve/stitch.js";
|
|
|
3
3
|
import { safeStringify } from "../shared/stringify.js";
|
|
4
4
|
import { i32, u32 } from "../data/numeric.js";
|
|
5
5
|
import { dualImpl } from "../core/function/dualImpl.js";
|
|
6
|
-
|
|
7
6
|
//#region src/std/atomic.ts
|
|
8
7
|
const workgroupBarrier = dualImpl({
|
|
9
8
|
name: "workgroupBarrier",
|
|
@@ -108,6 +107,5 @@ const atomicXor = dualImpl({
|
|
|
108
107
|
signature: atomicOpSignature,
|
|
109
108
|
codegenImpl: (_ctx, [a, value]) => stitch`atomicXor(&${a}, ${value})`
|
|
110
109
|
});
|
|
111
|
-
|
|
112
110
|
//#endregion
|
|
113
|
-
export { atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, storageBarrier, textureBarrier, workgroupBarrier };
|
|
111
|
+
export { atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, storageBarrier, textureBarrier, workgroupBarrier };
|
package/std/bitcast.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { v2f, v2i, v2u, v3f, v3i, v3u, v4f, v4i, v4u } from "../data/wgslTypes.j
|
|
|
3
3
|
|
|
4
4
|
//#region src/std/bitcast.d.ts
|
|
5
5
|
type BitcastU32toF32Overload = ((value: number) => number) & ((value: v2u) => v2f) & ((value: v3u) => v3f) & ((value: v4u) => v4f);
|
|
6
|
-
declare const bitcastU32toF32: DualFn
|
|
6
|
+
declare const bitcastU32toF32: DualFn;
|
|
7
7
|
type BitcastU32toI32Overload = ((value: number) => number) & ((value: v2u) => v2i) & ((value: v3u) => v3i) & ((value: v4u) => v4i);
|
|
8
|
-
declare const bitcastU32toI32: DualFn
|
|
8
|
+
declare const bitcastU32toI32: DualFn;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { bitcastU32toF32, bitcastU32toI32 };
|
package/std/bitcast.js
CHANGED
|
@@ -6,7 +6,6 @@ import { vec2f, vec2i, vec3f, vec3i, vec4f, vec4i } from "../data/vector.js";
|
|
|
6
6
|
import { dualImpl } from "../core/function/dualImpl.js";
|
|
7
7
|
import { bitcastU32toF32Impl, bitcastU32toI32Impl } from "../data/numberOps.js";
|
|
8
8
|
import { VectorOps } from "../data/vectorOps.js";
|
|
9
|
-
|
|
10
9
|
//#region src/std/bitcast.ts
|
|
11
10
|
const bitcastU32toF32 = dualImpl({
|
|
12
11
|
name: "bitcastU32toF32",
|
|
@@ -38,6 +37,5 @@ const bitcastU32toI32 = dualImpl({
|
|
|
38
37
|
};
|
|
39
38
|
}
|
|
40
39
|
});
|
|
41
|
-
|
|
42
40
|
//#endregion
|
|
43
|
-
export { bitcastU32toF32, bitcastU32toI32 };
|
|
41
|
+
export { bitcastU32toF32, bitcastU32toI32 };
|
package/std/boolean.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { AnyBooleanVecInstance, AnyFloatVecInstance, AnyNumericVecInstance, AnyV
|
|
|
9
9
|
* allEq(vec2f(0.0, 1.0), vec2f(0.0, 2.0)) // returns false
|
|
10
10
|
* allEq(vec3u(0, 1, 2), vec3u(0, 1, 2)) // returns true
|
|
11
11
|
*/
|
|
12
|
-
declare const allEq: DualFn
|
|
12
|
+
declare const allEq: DualFn;
|
|
13
13
|
/**
|
|
14
14
|
* Checks **component-wise** whether `lhs == rhs`.
|
|
15
15
|
* This function does **not** return `bool`, for that use-case, wrap the result in `all`, or use `allEq`.
|
|
@@ -19,7 +19,7 @@ declare const allEq: DualFn<(<T extends AnyVecInstance>(lhs: T, rhs: T) => boole
|
|
|
19
19
|
* all(eq(vec4i(4, 3, 2, 1), vec4i(4, 3, 2, 1))) // returns true
|
|
20
20
|
* allEq(vec4i(4, 3, 2, 1), vec4i(4, 3, 2, 1)) // returns true
|
|
21
21
|
*/
|
|
22
|
-
declare const eq: DualFn
|
|
22
|
+
declare const eq: DualFn;
|
|
23
23
|
/**
|
|
24
24
|
* Checks **component-wise** whether `lhs != rhs`.
|
|
25
25
|
* This function does **not** return `bool`, for that use-case, wrap the result in `any`.
|
|
@@ -28,7 +28,7 @@ declare const eq: DualFn<(<T extends AnyVecInstance>(lhs: T, rhs: T) => T extend
|
|
|
28
28
|
* ne(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(true, false, true)
|
|
29
29
|
* any(ne(vec4i(4, 3, 2, 1), vec4i(4, 2, 2, 1))) // returns true
|
|
30
30
|
*/
|
|
31
|
-
declare const ne: DualFn
|
|
31
|
+
declare const ne: DualFn;
|
|
32
32
|
/**
|
|
33
33
|
* Checks **component-wise** whether `lhs < rhs`.
|
|
34
34
|
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
|
@@ -37,7 +37,7 @@ declare const ne: DualFn<(<T extends AnyVecInstance>(lhs: T, rhs: T) => T extend
|
|
|
37
37
|
* lt(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(true, false, false)
|
|
38
38
|
* all(lt(vec4i(1, 2, 3, 4), vec4i(2, 3, 4, 5))) // returns true
|
|
39
39
|
*/
|
|
40
|
-
declare const lt: DualFn
|
|
40
|
+
declare const lt: DualFn;
|
|
41
41
|
/**
|
|
42
42
|
* Checks **component-wise** whether `lhs <= rhs`.
|
|
43
43
|
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
|
@@ -46,7 +46,7 @@ declare const lt: DualFn<(<T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T
|
|
|
46
46
|
* le(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(true, true, false)
|
|
47
47
|
* all(le(vec4i(1, 2, 3, 4), vec4i(2, 3, 3, 5))) // returns true
|
|
48
48
|
*/
|
|
49
|
-
declare const le: DualFn
|
|
49
|
+
declare const le: DualFn;
|
|
50
50
|
/**
|
|
51
51
|
* Checks **component-wise** whether `lhs > rhs`.
|
|
52
52
|
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
|
@@ -55,7 +55,7 @@ declare const le: DualFn<(<T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T
|
|
|
55
55
|
* gt(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(false, false, true)
|
|
56
56
|
* all(gt(vec4i(2, 3, 4, 5), vec4i(1, 2, 3, 4))) // returns true
|
|
57
57
|
*/
|
|
58
|
-
declare const gt: DualFn
|
|
58
|
+
declare const gt: DualFn;
|
|
59
59
|
/**
|
|
60
60
|
* Checks **component-wise** whether `lhs >= rhs`.
|
|
61
61
|
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
|
@@ -64,42 +64,56 @@ declare const gt: DualFn<(<T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T
|
|
|
64
64
|
* ge(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(false, true, true)
|
|
65
65
|
* all(ge(vec4i(2, 2, 4, 5), vec4i(1, 2, 3, 4))) // returns true
|
|
66
66
|
*/
|
|
67
|
-
declare const ge: DualFn
|
|
67
|
+
declare const ge: DualFn;
|
|
68
|
+
type VecInstanceToBooleanVecInstance<T extends AnyVecInstance> = T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b;
|
|
69
|
+
declare function cpuNot(value: boolean): boolean;
|
|
70
|
+
declare function cpuNot(value: number): boolean;
|
|
71
|
+
declare function cpuNot<T extends AnyVecInstance>(value: T): VecInstanceToBooleanVecInstance<T>;
|
|
72
|
+
declare function cpuNot(value: unknown): boolean;
|
|
68
73
|
/**
|
|
69
|
-
* Returns
|
|
74
|
+
* Returns the logical negation of the given value.
|
|
75
|
+
* For scalars (bool, number), returns `!value`.
|
|
76
|
+
* For boolean vectors, returns **component-wise** `!value`.
|
|
77
|
+
* For numeric vectors, returns a boolean vector with component-wise truthiness negation.
|
|
78
|
+
* For all other types, returns the truthiness negation (in WGSL, this applies only if the value is known at compile-time).
|
|
70
79
|
* @example
|
|
71
|
-
* not(
|
|
80
|
+
* not(true) // returns false
|
|
81
|
+
* not(-1) // returns false
|
|
82
|
+
* not(0) // returns true
|
|
72
83
|
* not(vec3b(true, true, false)) // returns vec3b(false, false, true)
|
|
84
|
+
* not(vec3f(1.0, 0.0, -1.0)) // returns vec3b(false, true, false)
|
|
85
|
+
* not({a: 1882}) // returns false
|
|
86
|
+
* not(NaN) // returns false **as in WGSL**
|
|
73
87
|
*/
|
|
74
|
-
declare const not: DualFn
|
|
88
|
+
declare const not: DualFn;
|
|
75
89
|
/**
|
|
76
90
|
* Returns **component-wise** logical `or` result.
|
|
77
91
|
* @example
|
|
78
92
|
* or(vec2b(false, true), vec2b(false, false)) // returns vec2b(false, true)
|
|
79
93
|
* or(vec3b(true, true, false), vec3b(false, true, false)) // returns vec3b(true, true, false)
|
|
80
94
|
*/
|
|
81
|
-
declare const or: DualFn
|
|
95
|
+
declare const or: DualFn;
|
|
82
96
|
/**
|
|
83
97
|
* Returns **component-wise** logical `and` result.
|
|
84
98
|
* @example
|
|
85
99
|
* and(vec2b(false, true), vec2b(true, true)) // returns vec2b(false, true)
|
|
86
100
|
* and(vec3b(true, true, false), vec3b(false, true, false)) // returns vec3b(false, true, false)
|
|
87
101
|
*/
|
|
88
|
-
declare const and: DualFn
|
|
102
|
+
declare const and: DualFn;
|
|
89
103
|
/**
|
|
90
104
|
* Returns `true` if each component of `value` is true.
|
|
91
105
|
* @example
|
|
92
106
|
* all(vec2b(false, true)) // returns false
|
|
93
107
|
* all(vec3b(true, true, true)) // returns true
|
|
94
108
|
*/
|
|
95
|
-
declare const all: DualFn
|
|
109
|
+
declare const all: DualFn;
|
|
96
110
|
/**
|
|
97
111
|
* Returns `true` if any component of `value` is true.
|
|
98
112
|
* @example
|
|
99
113
|
* any(vec2b(false, true)) // returns true
|
|
100
114
|
* any(vec3b(false, false, false)) // returns false
|
|
101
115
|
*/
|
|
102
|
-
declare const any: DualFn
|
|
116
|
+
declare const any: DualFn;
|
|
103
117
|
/**
|
|
104
118
|
* Checks whether the given elements differ by at most the `precision` value.
|
|
105
119
|
* Checks all elements of `lhs` and `rhs` if arguments are vectors.
|
|
@@ -109,7 +123,7 @@ declare const any: DualFn<(value: AnyBooleanVecInstance) => boolean>;
|
|
|
109
123
|
*
|
|
110
124
|
* @param {number} precision argument that specifies the maximum allowed difference, 0.01 by default.
|
|
111
125
|
*/
|
|
112
|
-
declare const isCloseTo: DualFn
|
|
126
|
+
declare const isCloseTo: DualFn;
|
|
113
127
|
declare function cpuSelect(f: boolean, t: boolean, cond: boolean): boolean;
|
|
114
128
|
declare function cpuSelect(f: number, t: number, cond: boolean): number;
|
|
115
129
|
declare function cpuSelect<T extends AnyVecInstance>(f: T, t: T, cond: boolean | (T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b)): T;
|
|
@@ -122,6 +136,6 @@ declare function cpuSelect<T extends AnyVecInstance>(f: T, t: T, cond: boolean |
|
|
|
122
136
|
* select(vec2i(1, 2), vec2i(3, 4), true) // returns vec2i(3, 4)
|
|
123
137
|
* select(vec2i(1, 2), vec2i(3, 4), vec2b(false, true)) // returns vec2i(1, 4)
|
|
124
138
|
*/
|
|
125
|
-
declare const select: DualFn
|
|
139
|
+
declare const select: DualFn;
|
|
126
140
|
//#endregion
|
|
127
141
|
export { all, allEq, and, any, eq, ge, gt, isCloseTo, le, lt, ne, not, or, select };
|
package/std/boolean.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isVecInstance } from "../data/wgslTypes.js";
|
|
1
|
+
import { isBool, isNumericSchema, isVec, isVecBool, isVecInstance } from "../data/wgslTypes.js";
|
|
2
2
|
import { isSnippetNumeric, snip } from "../data/snippet.js";
|
|
3
3
|
import { stitch } from "../core/resolve/stitch.js";
|
|
4
4
|
import { unify } from "../tgsl/conversion.js";
|
|
@@ -7,7 +7,6 @@ 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
|
-
|
|
11
10
|
//#region src/std/boolean.ts
|
|
12
11
|
function correspondingBooleanVectorSchema(dataType) {
|
|
13
12
|
if (dataType.type.includes("2")) return vec2b;
|
|
@@ -135,21 +134,48 @@ const ge = dualImpl({
|
|
|
135
134
|
normalImpl: (lhs, rhs) => cpuNot(cpuLt(lhs, rhs)),
|
|
136
135
|
codegenImpl: (_ctx, [lhs, rhs]) => stitch`(${lhs} >= ${rhs})`
|
|
137
136
|
});
|
|
138
|
-
|
|
137
|
+
function cpuNot(value) {
|
|
138
|
+
if (typeof value === "number" && isNaN(value)) return false;
|
|
139
|
+
if (isVecInstance(value)) {
|
|
140
|
+
if (value.length === 2) return vec2b(cpuNot(value.x), cpuNot(value.y));
|
|
141
|
+
if (value.length === 3) return vec3b(cpuNot(value.x), cpuNot(value.y), cpuNot(value.z));
|
|
142
|
+
if (value.length === 4) return vec4b(cpuNot(value.x), cpuNot(value.y), cpuNot(value.z), cpuNot(value.w));
|
|
143
|
+
}
|
|
144
|
+
return !value;
|
|
145
|
+
}
|
|
139
146
|
/**
|
|
140
|
-
* Returns
|
|
147
|
+
* Returns the logical negation of the given value.
|
|
148
|
+
* For scalars (bool, number), returns `!value`.
|
|
149
|
+
* For boolean vectors, returns **component-wise** `!value`.
|
|
150
|
+
* For numeric vectors, returns a boolean vector with component-wise truthiness negation.
|
|
151
|
+
* For all other types, returns the truthiness negation (in WGSL, this applies only if the value is known at compile-time).
|
|
141
152
|
* @example
|
|
142
|
-
* not(
|
|
153
|
+
* not(true) // returns false
|
|
154
|
+
* not(-1) // returns false
|
|
155
|
+
* not(0) // returns true
|
|
143
156
|
* not(vec3b(true, true, false)) // returns vec3b(false, false, true)
|
|
157
|
+
* not(vec3f(1.0, 0.0, -1.0)) // returns vec3b(false, true, false)
|
|
158
|
+
* not({a: 1882}) // returns false
|
|
159
|
+
* not(NaN) // returns false **as in WGSL**
|
|
144
160
|
*/
|
|
145
161
|
const not = dualImpl({
|
|
146
162
|
name: "not",
|
|
147
|
-
signature: (
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
163
|
+
signature: (arg) => {
|
|
164
|
+
const returnType = isVec(arg) ? correspondingBooleanVectorSchema(arg) : bool;
|
|
165
|
+
return {
|
|
166
|
+
argTypes: [arg],
|
|
167
|
+
returnType
|
|
168
|
+
};
|
|
169
|
+
},
|
|
151
170
|
normalImpl: cpuNot,
|
|
152
|
-
codegenImpl: (_ctx, [arg]) =>
|
|
171
|
+
codegenImpl: (_ctx, [arg]) => {
|
|
172
|
+
const { dataType } = arg;
|
|
173
|
+
if (isBool(dataType)) return stitch`!${arg}`;
|
|
174
|
+
if (isNumericSchema(dataType)) return stitch`!bool(${arg})`;
|
|
175
|
+
if (isVecBool(dataType)) return stitch`!(${arg})`;
|
|
176
|
+
if (isVec(dataType)) return stitch`!(${`vec${dataType.componentCount}<bool>`}(${arg}))`;
|
|
177
|
+
return "false";
|
|
178
|
+
}
|
|
153
179
|
});
|
|
154
180
|
const cpuOr = (lhs, rhs) => VectorOps.or[lhs.kind](lhs, rhs);
|
|
155
181
|
/**
|
|
@@ -269,6 +295,5 @@ const select = dualImpl({
|
|
|
269
295
|
normalImpl: cpuSelect,
|
|
270
296
|
codegenImpl: (_ctx, [f, t, cond]) => stitch`select(${f}, ${t}, ${cond})`
|
|
271
297
|
});
|
|
272
|
-
|
|
273
298
|
//#endregion
|
|
274
|
-
export { all, allEq, and, any, eq, ge, gt, isCloseTo, le, lt, ne, not, or, select };
|
|
299
|
+
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;
|
|
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;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { dpdx, dpdxCoarse, dpdxFine, dpdy, dpdyCoarse, dpdyFine, fwidth, fwidthCoarse, fwidthFine };
|
package/std/derivative.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { stitch } from "../core/resolve/stitch.js";
|
|
2
2
|
import { dualImpl } from "../core/function/dualImpl.js";
|
|
3
|
-
|
|
4
3
|
//#region src/std/derivative.ts
|
|
5
4
|
const derivativeNormalError = "Derivative builtins are not allowed on the CPU";
|
|
6
5
|
const dpdx = dualImpl({
|
|
@@ -84,6 +83,5 @@ const fwidthFine = dualImpl({
|
|
|
84
83
|
}),
|
|
85
84
|
codegenImpl: (_ctx, [value]) => stitch`fwidthFine(${value})`
|
|
86
85
|
});
|
|
87
|
-
|
|
88
86
|
//#endregion
|
|
89
|
-
export { dpdx, dpdxCoarse, dpdxFine, dpdy, dpdyCoarse, dpdyFine, fwidth, fwidthCoarse, fwidthFine };
|
|
87
|
+
export { dpdx, dpdxCoarse, dpdxFine, dpdy, dpdyCoarse, dpdyFine, fwidth, fwidthCoarse, fwidthFine };
|
package/std/discard.d.ts
CHANGED
package/std/discard.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Void } from "../data/wgslTypes.js";
|
|
2
2
|
import { dualImpl } from "../core/function/dualImpl.js";
|
|
3
|
-
|
|
4
3
|
//#region src/std/discard.ts
|
|
5
4
|
const discard = dualImpl({
|
|
6
5
|
name: "discard",
|
|
@@ -11,6 +10,5 @@ const discard = dualImpl({
|
|
|
11
10
|
},
|
|
12
11
|
codegenImpl: () => "discard;"
|
|
13
12
|
});
|
|
14
|
-
|
|
15
13
|
//#endregion
|
|
16
|
-
export { discard };
|
|
14
|
+
export { discard };
|
package/std/extensions.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { WgslExtension } from "../wgslExtensions.js";
|
|
2
2
|
import { TgpuComptime } from "../core/function/comptime.js";
|
|
3
|
-
import "../indexNamedExports.js";
|
|
4
|
-
|
|
5
3
|
//#region src/std/extensions.d.ts
|
|
6
|
-
declare const extensionEnabled: TgpuComptime
|
|
4
|
+
declare const extensionEnabled: TgpuComptime;
|
|
7
5
|
//#endregion
|
|
8
6
|
export { extensionEnabled };
|
package/std/extensions.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getResolutionCtx } from "../execMode.js";
|
|
2
2
|
import { comptime } from "../core/function/comptime.js";
|
|
3
3
|
import { wgslExtensions } from "../wgslExtensions.js";
|
|
4
|
-
|
|
5
4
|
//#region src/std/extensions.ts
|
|
6
5
|
const extensionEnabled = comptime((extensionName) => {
|
|
7
6
|
const resolutionCtx = getResolutionCtx();
|
|
@@ -9,6 +8,5 @@ const extensionEnabled = comptime((extensionName) => {
|
|
|
9
8
|
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}'`);
|
|
10
9
|
return (resolutionCtx.enableExtensions ?? []).includes(extensionName);
|
|
11
10
|
});
|
|
12
|
-
|
|
13
11
|
//#endregion
|
|
14
|
-
export { extensionEnabled };
|
|
12
|
+
export { extensionEnabled };
|
package/std/index.d.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { identity2, identity3, identity4, rotationX4, rotationY4, rotationZ4, scaling4, translation4 } from "../data/matrix.js";
|
|
2
2
|
import { discard } from "./discard.js";
|
|
3
3
|
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";
|
|
4
|
-
import { add, div, mod, mul, neg, sub } from "./operators.js";
|
|
4
|
+
import { add, bitShiftLeft, bitShiftRight, div, mod, mul, neg, sub } from "./operators.js";
|
|
5
5
|
import { rotateX4, rotateY4, rotateZ4, scale4, translate4 } from "./matrix.js";
|
|
6
6
|
import { all, allEq, and, any, eq, ge, gt, isCloseTo, le, lt, ne, not, or, select } from "./boolean.js";
|
|
7
7
|
import { atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, storageBarrier, textureBarrier, workgroupBarrier } from "./atomic.js";
|
|
8
8
|
import { dpdx, dpdxCoarse, dpdxFine, dpdy, dpdyCoarse, dpdyFine, fwidth, fwidthCoarse, fwidthFine } from "./derivative.js";
|
|
9
9
|
import { arrayLength } from "./array.js";
|
|
10
10
|
import { pack2x16float, pack4x8unorm, unpack2x16float, unpack4x8unorm } from "./packing.js";
|
|
11
|
-
import { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleLevel, textureStore } from "./texture.js";
|
|
11
|
+
import { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleGrad, textureSampleLevel, textureStore } from "./texture.js";
|
|
12
12
|
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";
|
|
13
13
|
import { extensionEnabled } from "./extensions.js";
|
|
14
14
|
import { bitcastU32toF32, bitcastU32toI32 } from "./bitcast.js";
|
|
15
|
+
import { range } from "./range.js";
|
|
15
16
|
|
|
16
17
|
//#region src/std/index.d.ts
|
|
17
18
|
declare namespace index_d_exports {
|
|
18
|
-
export { abs, acos, acosh, add, all, allEq, and, any, arrayLength, asin, asinh, atan, atan2, atanh, atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, 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, reflect, refract, reverseBits, rotateX4, rotateY4, rotateZ4, rotationX4, rotationY4, rotationZ4, round, saturate, scale4, scaling4, select, sign, sin, sinh, smoothstep, sqrt, 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, textureSampleLevel, textureStore, translate4, translation4, transpose, trunc, unpack2x16float, unpack4x8unorm, workgroupBarrier };
|
|
19
|
+
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, 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 };
|
|
19
20
|
}
|
|
20
21
|
//#endregion
|
|
21
|
-
export { abs, acos, acosh, add, all, allEq, and, any, arrayLength, asin, asinh, atan, atan2, atanh, atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, 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, index_d_exports, 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, reflect, refract, reverseBits, rotateX4, rotateY4, rotateZ4, rotationX4, rotationY4, rotationZ4, round, saturate, scale4, scaling4, select, sign, sin, sinh, smoothstep, sqrt, 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, textureSampleLevel, textureStore, translate4, translation4, transpose, trunc, unpack2x16float, unpack4x8unorm, workgroupBarrier };
|
|
22
|
+
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, index_d_exports, 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, 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/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { identity2, identity3, identity4, rotationX4, rotationY4, rotationZ4, scaling4, translation4 } from "../data/matrix.js";
|
|
3
|
-
import { add, div, mod, mul, neg, sub } from "./operators.js";
|
|
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";
|
|
5
5
|
import { arrayLength } from "./array.js";
|
|
6
|
+
import { range } from "./range.js";
|
|
6
7
|
import { bitcastU32toF32, bitcastU32toI32 } from "./bitcast.js";
|
|
7
8
|
import { pack2x16float, pack4x8unorm, unpack2x16float, unpack4x8unorm } from "./packing.js";
|
|
8
9
|
import { all, allEq, and, any, eq, ge, gt, isCloseTo, le, lt, ne, not, or, select } from "./boolean.js";
|
|
@@ -10,10 +11,9 @@ import { discard } from "./discard.js";
|
|
|
10
11
|
import { rotateX4, rotateY4, rotateZ4, scale4, translate4 } from "./matrix.js";
|
|
11
12
|
import { atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, storageBarrier, textureBarrier, workgroupBarrier } from "./atomic.js";
|
|
12
13
|
import { dpdx, dpdxCoarse, dpdxFine, dpdy, dpdyCoarse, dpdyFine, fwidth, fwidthCoarse, fwidthFine } from "./derivative.js";
|
|
13
|
-
import { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleLevel, textureStore } from "./texture.js";
|
|
14
|
+
import { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleGrad, textureSampleLevel, textureStore } from "./texture.js";
|
|
14
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";
|
|
15
16
|
import { extensionEnabled } from "./extensions.js";
|
|
16
|
-
|
|
17
17
|
//#region src/std/index.ts
|
|
18
18
|
var std_exports = /* @__PURE__ */ __exportAll({
|
|
19
19
|
abs: () => abs,
|
|
@@ -39,6 +39,8 @@ var std_exports = /* @__PURE__ */ __exportAll({
|
|
|
39
39
|
atomicStore: () => atomicStore,
|
|
40
40
|
atomicSub: () => atomicSub,
|
|
41
41
|
atomicXor: () => atomicXor,
|
|
42
|
+
bitShiftLeft: () => bitShiftLeft,
|
|
43
|
+
bitShiftRight: () => bitShiftRight,
|
|
42
44
|
bitcastU32toF32: () => bitcastU32toF32,
|
|
43
45
|
bitcastU32toI32: () => bitcastU32toI32,
|
|
44
46
|
ceil: () => ceil,
|
|
@@ -108,6 +110,7 @@ var std_exports = /* @__PURE__ */ __exportAll({
|
|
|
108
110
|
pow: () => pow,
|
|
109
111
|
quantizeToF16: () => quantizeToF16,
|
|
110
112
|
radians: () => radians,
|
|
113
|
+
range: () => range,
|
|
111
114
|
reflect: () => reflect,
|
|
112
115
|
refract: () => refract,
|
|
113
116
|
reverseBits: () => reverseBits,
|
|
@@ -162,6 +165,7 @@ var std_exports = /* @__PURE__ */ __exportAll({
|
|
|
162
165
|
textureSampleBias: () => textureSampleBias,
|
|
163
166
|
textureSampleCompare: () => textureSampleCompare,
|
|
164
167
|
textureSampleCompareLevel: () => textureSampleCompareLevel,
|
|
168
|
+
textureSampleGrad: () => textureSampleGrad,
|
|
165
169
|
textureSampleLevel: () => textureSampleLevel,
|
|
166
170
|
textureStore: () => textureStore,
|
|
167
171
|
translate4: () => translate4,
|
|
@@ -172,6 +176,5 @@ var std_exports = /* @__PURE__ */ __exportAll({
|
|
|
172
176
|
unpack4x8unorm: () => unpack4x8unorm,
|
|
173
177
|
workgroupBarrier: () => workgroupBarrier
|
|
174
178
|
});
|
|
175
|
-
|
|
176
179
|
//#endregion
|
|
177
|
-
export { abs, acos, acosh, add, all, allEq, and, any, arrayLength, asin, asinh, atan, atan2, atanh, atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, 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, 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, textureSampleLevel, textureStore, translate4, translation4, transpose, trunc, unpack2x16float, unpack4x8unorm, workgroupBarrier };
|
|
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 };
|
package/std/matrix.d.ts
CHANGED
|
@@ -8,34 +8,34 @@ import { m4x4f, v3f } from "../data/wgslTypes.js";
|
|
|
8
8
|
* @param {v3f} vector - The vector by which to translate the matrix.
|
|
9
9
|
* @returns {m4x4f} The translated matrix.
|
|
10
10
|
*/
|
|
11
|
-
declare const translate4: DualFn
|
|
11
|
+
declare const translate4: DualFn;
|
|
12
12
|
/**
|
|
13
13
|
* Scales the given 4-by-4 matrix in each dimension by an amount given by the corresponding entry in the given vector.
|
|
14
14
|
* @param {m4x4f} matrix - The matrix to be modified.
|
|
15
15
|
* @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.
|
|
16
16
|
* @returns {m4x4f} The scaled matrix.
|
|
17
17
|
*/
|
|
18
|
-
declare const scale4: DualFn
|
|
18
|
+
declare const scale4: DualFn;
|
|
19
19
|
/**
|
|
20
20
|
* Rotates the given 4-by-4 matrix around the x-axis by the given angle.
|
|
21
21
|
* @param {m4x4f} matrix - The matrix to be modified.
|
|
22
22
|
* @param {number} angle - The angle by which to rotate (in radians).
|
|
23
23
|
* @returns {m4x4f} The rotated matrix.
|
|
24
24
|
*/
|
|
25
|
-
declare const rotateX4: DualFn
|
|
25
|
+
declare const rotateX4: DualFn;
|
|
26
26
|
/**
|
|
27
27
|
* Rotates the given 4-by-4 matrix around the y-axis by the given angle.
|
|
28
28
|
* @param {m4x4f} matrix - The matrix to be modified.
|
|
29
29
|
* @param {number} angle - The angle by which to rotate (in radians).
|
|
30
30
|
* @returns {m4x4f} The rotated matrix.
|
|
31
31
|
*/
|
|
32
|
-
declare const rotateY4: DualFn
|
|
32
|
+
declare const rotateY4: DualFn;
|
|
33
33
|
/**
|
|
34
34
|
* Rotates the given 4-by-4 matrix around the z-axis by the given angle.
|
|
35
35
|
* @param {m4x4f} matrix - The matrix to be modified.
|
|
36
36
|
* @param {number} angle - The angle by which to rotate (in radians).
|
|
37
37
|
* @returns {m4x4f} The rotated matrix.
|
|
38
38
|
*/
|
|
39
|
-
declare const rotateZ4: DualFn
|
|
39
|
+
declare const rotateZ4: DualFn;
|
|
40
40
|
//#endregion
|
|
41
41
|
export { rotateX4, rotateY4, rotateZ4, scale4, translate4 };
|
package/std/matrix.js
CHANGED
|
@@ -5,7 +5,6 @@ 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
|
-
|
|
9
8
|
//#region src/std/matrix.ts
|
|
10
9
|
const gpuTranslation4 = translation4[$gpuCallable].call.bind(translation4);
|
|
11
10
|
const gpuScaling4 = scaling4[$gpuCallable].call.bind(scaling4);
|
|
@@ -82,6 +81,5 @@ const rotateZ4 = dualImpl({
|
|
|
82
81
|
signature: rotateSignature,
|
|
83
82
|
codegenImpl: (ctx, [matrix, angle]) => stitch`(${gpuRotationZ4(ctx, [angle])} * ${matrix})`
|
|
84
83
|
});
|
|
85
|
-
|
|
86
84
|
//#endregion
|
|
87
|
-
export { rotateX4, rotateY4, rotateZ4, scale4, translate4 };
|
|
85
|
+
export { rotateX4, rotateY4, rotateZ4, scale4, translate4 };
|