typegpu 0.10.1 → 0.11.0-rc.1
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 +13 -0
- package/builtin.d.ts +50 -0
- package/builtin.js +35 -0
- package/common/fullScreenTriangle.d.ts +22 -0
- package/common/fullScreenTriangle.js +34 -0
- package/common/index.d.ts +4 -4
- package/common/index.js +8 -7
- package/common/writeSoA.d.ts +16 -0
- package/common/writeSoA.js +90 -0
- package/core/buffer/buffer.d.ts +79 -0
- package/core/buffer/buffer.js +246 -0
- package/core/buffer/bufferShorthand.d.ts +48 -0
- package/core/buffer/bufferShorthand.js +53 -0
- package/core/buffer/bufferUsage.d.ts +43 -0
- package/core/buffer/bufferUsage.js +165 -0
- package/core/constant/tgpuConstant.d.ts +29 -0
- package/core/constant/tgpuConstant.js +68 -0
- package/core/declare/tgpuDeclare.d.ts +18 -0
- package/core/declare/tgpuDeclare.js +39 -0
- package/core/function/autoIO.d.ts +38 -0
- package/core/function/autoIO.js +85 -0
- package/core/function/comptime.d.ts +39 -0
- package/core/function/comptime.js +49 -0
- package/core/function/createCallableSchema.js +40 -0
- package/core/function/dualImpl.js +52 -0
- package/core/function/entryInputRouter.js +39 -0
- package/core/function/extractArgs.js +204 -0
- package/core/function/fnCore.js +90 -0
- package/core/function/fnTypes.d.ts +40 -0
- package/core/function/ioSchema.d.ts +10 -0
- package/core/function/ioSchema.js +51 -0
- package/core/function/shelllessImpl.d.ts +28 -0
- package/core/function/shelllessImpl.js +21 -0
- package/core/function/templateUtils.js +12 -0
- package/core/function/tgpuComputeFn.d.ts +48 -0
- package/core/function/tgpuComputeFn.js +55 -0
- package/core/function/tgpuFn.d.ts +52 -0
- package/core/function/tgpuFn.js +168 -0
- package/core/function/tgpuFragmentFn.d.ts +72 -0
- package/core/function/tgpuFragmentFn.js +63 -0
- package/core/function/tgpuVertexFn.d.ts +59 -0
- package/core/function/tgpuVertexFn.js +59 -0
- package/core/pipeline/applyPipelineState.js +35 -0
- package/core/pipeline/computePipeline.d.ts +54 -0
- package/core/pipeline/computePipeline.js +227 -0
- package/core/pipeline/connectAttachmentToShader.js +24 -0
- package/core/pipeline/connectTargetsToShader.js +27 -0
- package/core/pipeline/limitsOverflow.js +12 -0
- package/core/pipeline/pipelineUtils.js +29 -0
- package/core/pipeline/renderPipeline.d.ts +284 -0
- package/core/pipeline/renderPipeline.js +489 -0
- package/core/pipeline/timeable.d.ts +20 -0
- package/core/pipeline/timeable.js +55 -0
- package/core/pipeline/typeGuards.js +27 -0
- package/core/querySet/querySet.d.ts +20 -0
- package/core/querySet/querySet.js +104 -0
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +59 -0
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +94 -0
- package/core/resolve/externals.d.ts +8 -0
- package/core/resolve/externals.js +56 -0
- package/core/resolve/namespace.d.ts +38 -0
- package/core/resolve/namespace.js +39 -0
- package/core/resolve/resolveData.js +144 -0
- package/core/resolve/stitch.js +23 -0
- package/core/resolve/tgpuResolve.d.ts +153 -0
- package/core/resolve/tgpuResolve.js +66 -0
- package/core/root/configurableImpl.js +17 -0
- package/core/root/init.d.ts +64 -0
- package/core/root/init.js +464 -0
- package/core/root/rootTypes.d.ts +642 -0
- package/core/sampler/sampler.d.ts +31 -0
- package/core/sampler/sampler.js +116 -0
- package/core/simulate/tgpuSimulate.d.ts +36 -0
- package/core/simulate/tgpuSimulate.js +74 -0
- package/core/slot/accessor.d.ts +9 -0
- package/core/slot/accessor.js +95 -0
- package/core/slot/internalSlots.js +5 -0
- package/core/slot/lazy.d.ts +6 -0
- package/core/slot/lazy.js +40 -0
- package/core/slot/slot.d.ts +6 -0
- package/core/slot/slot.js +39 -0
- package/core/slot/slotTypes.d.ts +92 -0
- package/core/slot/slotTypes.js +19 -0
- package/core/texture/externalTexture.d.ts +6 -0
- package/core/texture/externalTexture.js +47 -0
- package/core/texture/texture.d.ts +114 -0
- package/core/texture/texture.js +314 -0
- package/core/texture/textureFormats.d.ts +29 -0
- package/core/texture/textureFormats.js +97 -0
- package/core/texture/textureProps.d.ts +11 -0
- package/core/texture/textureUtils.js +222 -0
- package/core/texture/usageExtension.d.ts +21 -0
- package/core/texture/usageExtension.js +19 -0
- package/core/unroll/tgpuUnroll.d.ts +68 -0
- package/core/unroll/tgpuUnroll.js +94 -0
- package/core/valueProxyUtils.js +42 -0
- package/core/variable/tgpuVariable.d.ts +38 -0
- package/core/variable/tgpuVariable.js +99 -0
- package/core/vertexLayout/connectAttributesToShader.js +57 -0
- package/core/vertexLayout/vertexAttribute.d.ts +29 -0
- package/core/vertexLayout/vertexLayout.d.ts +19 -0
- package/core/vertexLayout/vertexLayout.js +103 -0
- package/data/alignIO.js +14 -0
- package/data/alignmentOf.d.ts +9 -0
- package/data/alignmentOf.js +86 -0
- package/data/array.d.ts +26 -0
- package/data/array.js +46 -0
- package/data/atomic.d.ts +15 -0
- package/data/atomic.js +24 -0
- package/data/attributes.d.ts +121 -0
- package/data/attributes.js +145 -0
- package/data/autoStruct.d.ts +1 -0
- package/data/autoStruct.js +81 -0
- package/data/compiledIO.js +228 -0
- package/data/dataIO.js +556 -0
- package/data/dataTypes.d.ts +115 -0
- package/data/dataTypes.js +100 -0
- package/data/deepEqual.d.ts +25 -0
- package/data/deepEqual.js +56 -0
- package/data/disarray.d.ts +32 -0
- package/data/disarray.js +50 -0
- package/data/getLongestContiguousPrefix.d.ts +9 -0
- package/data/getLongestContiguousPrefix.js +13 -0
- package/data/index.d.ts +26 -4
- package/data/index.js +36 -9
- package/data/instanceToSchema.d.ts +33 -0
- package/data/isContiguous.d.ts +9 -0
- package/data/isContiguous.js +13 -0
- package/data/matrix.d.ts +124 -0
- package/data/matrix.js +531 -0
- package/data/numberOps.js +23 -0
- package/data/numeric.d.ts +81 -0
- package/data/numeric.js +221 -0
- package/data/offsetUtils.d.ts +33 -0
- package/data/offsetUtils.js +165 -0
- package/data/offsets.js +34 -0
- package/data/partialIO.js +113 -0
- package/data/ptr.d.ts +11 -0
- package/data/ptr.js +44 -0
- package/data/ref.d.ts +34 -0
- package/data/ref.js +94 -0
- package/data/sampler.d.ts +107 -0
- package/data/sampler.js +24 -0
- package/data/schemaCallWrapper.js +30 -0
- package/data/schemaMemoryLayout.js +198 -0
- package/data/sizeOf.d.ts +9 -0
- package/data/sizeOf.js +13 -0
- package/data/snippet.d.ts +26 -0
- package/data/snippet.js +70 -0
- package/data/struct.d.ts +17 -0
- package/data/struct.js +44 -0
- package/data/texture.d.ts +292 -0
- package/{texture-BagDrrks.js → data/texture.js} +6 -5
- package/data/unstruct.d.ts +24 -0
- package/data/unstruct.js +41 -0
- package/data/vector.d.ts +191 -0
- package/data/vector.js +239 -0
- package/data/vectorImpl.js +515 -0
- package/data/vectorOps.js +681 -0
- package/data/vertexFormatData.d.ts +190 -0
- package/data/vertexFormatData.js +109 -0
- package/data/wgslTypes.d.ts +924 -0
- package/data/wgslTypes.js +222 -0
- package/errors.d.ts +44 -0
- package/errors.js +131 -0
- package/execMode.js +49 -0
- package/extension.d.ts +11 -0
- package/extension.js +16 -0
- package/getGPUValue.js +7 -0
- package/index.d.ts +42 -243
- package/index.js +21 -6320
- package/indexNamedExports.d.ts +40 -0
- package/mathUtils.js +12 -0
- package/memo.js +22 -0
- package/nameRegistry.d.ts +30 -0
- package/nameRegistry.js +447 -0
- package/package.js +4 -0
- package/package.json +26 -26
- package/resolutionCtx.d.ts +19 -0
- package/resolutionCtx.js +612 -0
- package/shared/env.js +12 -0
- package/shared/generators.js +13 -0
- package/shared/meta.d.ts +39 -0
- package/shared/meta.js +61 -0
- package/shared/repr.d.ts +138 -0
- package/shared/stringify.js +20 -0
- package/shared/symbols.d.ts +70 -0
- package/shared/symbols.js +48 -0
- package/shared/utilityTypes.d.ts +33 -0
- package/shared/utilityTypes.js +6 -0
- package/shared/vertexFormat.d.ts +70 -0
- package/shared/vertexFormat.js +63 -0
- package/std/array.d.ts +7 -0
- package/std/array.js +25 -0
- package/std/atomic.d.ts +19 -0
- package/std/atomic.js +111 -0
- package/std/bitcast.d.ts +10 -0
- package/std/bitcast.js +41 -0
- package/std/boolean.d.ts +141 -0
- package/std/boolean.js +299 -0
- package/std/derivative.d.ts +16 -0
- package/std/derivative.js +87 -0
- package/std/discard.d.ts +6 -0
- package/std/discard.js +14 -0
- package/std/extensions.d.ts +6 -0
- package/std/extensions.js +12 -0
- package/std/index.d.ts +17 -4
- package/std/index.js +21 -7
- package/std/matrix.d.ts +41 -0
- package/std/matrix.js +85 -0
- package/std/numeric.d.ts +200 -0
- package/std/numeric.js +845 -0
- package/std/operators.d.ts +56 -0
- package/std/operators.js +227 -0
- package/std/packing.d.ts +26 -0
- package/std/packing.js +84 -0
- package/std/range.d.ts +24 -0
- package/std/range.js +38 -0
- package/std/subgroup.d.ts +47 -0
- package/std/subgroup.js +218 -0
- package/std/texture.d.ts +117 -0
- package/std/texture.js +207 -0
- package/tgpu.js +42 -0
- package/tgpuBindGroupLayout.d.ts +161 -0
- package/tgpuBindGroupLayout.js +272 -0
- package/tgpuUnstable.d.ts +48 -0
- package/tgpuUnstable.js +64 -0
- package/tgsl/accessIndex.js +43 -0
- package/tgsl/accessProp.js +115 -0
- package/tgsl/consoleLog/deserializers.js +115 -0
- package/tgsl/consoleLog/logGenerator.js +84 -0
- package/tgsl/consoleLog/serializers.js +223 -0
- package/tgsl/consoleLog/types.d.ts +52 -0
- package/tgsl/consoleLog/types.js +11 -0
- package/tgsl/conversion.js +198 -0
- package/tgsl/forOfUtils.js +71 -0
- package/tgsl/generationHelpers.d.ts +37 -0
- package/tgsl/generationHelpers.js +67 -0
- package/tgsl/math.js +43 -0
- package/tgsl/shaderGenerator.d.ts +20 -0
- package/tgsl/shaderGenerator_members.d.ts +2 -0
- package/tgsl/shaderGenerator_members.js +6 -0
- package/tgsl/shellless.d.ts +11 -0
- package/tgsl/shellless.js +46 -0
- package/tgsl/wgslGenerator.d.ts +36 -0
- package/tgsl/wgslGenerator.js +639 -0
- package/types.d.ts +265 -0
- package/types.js +43 -0
- package/unwrapper.d.ts +27 -0
- package/wgslExtensions.d.ts +5 -0
- package/wgslExtensions.js +17 -0
- package/builtin-DdtWpk2t.js +0 -818
- package/builtin-DdtWpk2t.js.map +0 -1
- package/chunk-BYypO7fO.js +0 -18
- package/common/index.d.ts.map +0 -1
- package/common/index.js.map +0 -1
- package/data/index.d.ts.map +0 -1
- package/data/index.js.map +0 -1
- package/deepEqual-DQxK4vdp.js +0 -413
- package/deepEqual-DQxK4vdp.js.map +0 -1
- package/extensions-DIVuAfBM.js +0 -2032
- package/extensions-DIVuAfBM.js.map +0 -1
- package/fullScreenTriangle-CfFyQd_0.js +0 -543
- package/fullScreenTriangle-CfFyQd_0.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
- package/indexNamedExports-oL6tyaJ9.d.ts +0 -5697
- package/indexNamedExports-oL6tyaJ9.d.ts.map +0 -1
- package/operators-d-PMVTo7.js +0 -4158
- package/operators-d-PMVTo7.js.map +0 -1
- package/std/index.d.ts.map +0 -1
- package/std/index.js.map +0 -1
- package/texture-BagDrrks.js.map +0 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { stitch } from "../core/resolve/stitch.js";
|
|
2
|
+
import { dualImpl } from "../core/function/dualImpl.js";
|
|
3
|
+
//#region src/std/derivative.ts
|
|
4
|
+
const derivativeNormalError = "Derivative builtins are not allowed on the CPU";
|
|
5
|
+
const dpdx = dualImpl({
|
|
6
|
+
name: "dpdx",
|
|
7
|
+
normalImpl: derivativeNormalError,
|
|
8
|
+
signature: (value) => ({
|
|
9
|
+
argTypes: [value],
|
|
10
|
+
returnType: value
|
|
11
|
+
}),
|
|
12
|
+
codegenImpl: (_ctx, [value]) => stitch`dpdx(${value})`
|
|
13
|
+
});
|
|
14
|
+
const dpdxCoarse = dualImpl({
|
|
15
|
+
name: "dpdxCoarse",
|
|
16
|
+
normalImpl: derivativeNormalError,
|
|
17
|
+
signature: (value) => ({
|
|
18
|
+
argTypes: [value],
|
|
19
|
+
returnType: value
|
|
20
|
+
}),
|
|
21
|
+
codegenImpl: (_ctx, [value]) => stitch`dpdxCoarse(${value})`
|
|
22
|
+
});
|
|
23
|
+
const dpdxFine = dualImpl({
|
|
24
|
+
name: "dpdxFine",
|
|
25
|
+
normalImpl: derivativeNormalError,
|
|
26
|
+
signature: (value) => ({
|
|
27
|
+
argTypes: [value],
|
|
28
|
+
returnType: value
|
|
29
|
+
}),
|
|
30
|
+
codegenImpl: (_ctx, [value]) => stitch`dpdxFine(${value})`
|
|
31
|
+
});
|
|
32
|
+
const dpdy = dualImpl({
|
|
33
|
+
name: "dpdy",
|
|
34
|
+
normalImpl: derivativeNormalError,
|
|
35
|
+
signature: (value) => ({
|
|
36
|
+
argTypes: [value],
|
|
37
|
+
returnType: value
|
|
38
|
+
}),
|
|
39
|
+
codegenImpl: (_ctx, [value]) => stitch`dpdy(${value})`
|
|
40
|
+
});
|
|
41
|
+
const dpdyCoarse = dualImpl({
|
|
42
|
+
name: "dpdyCoarse",
|
|
43
|
+
normalImpl: derivativeNormalError,
|
|
44
|
+
signature: (value) => ({
|
|
45
|
+
argTypes: [value],
|
|
46
|
+
returnType: value
|
|
47
|
+
}),
|
|
48
|
+
codegenImpl: (_ctx, [value]) => stitch`dpdyCoarse(${value})`
|
|
49
|
+
});
|
|
50
|
+
const dpdyFine = dualImpl({
|
|
51
|
+
name: "dpdyFine",
|
|
52
|
+
normalImpl: derivativeNormalError,
|
|
53
|
+
signature: (value) => ({
|
|
54
|
+
argTypes: [value],
|
|
55
|
+
returnType: value
|
|
56
|
+
}),
|
|
57
|
+
codegenImpl: (_ctx, [value]) => stitch`dpdyFine(${value})`
|
|
58
|
+
});
|
|
59
|
+
const fwidth = dualImpl({
|
|
60
|
+
name: "fwidth",
|
|
61
|
+
normalImpl: derivativeNormalError,
|
|
62
|
+
signature: (value) => ({
|
|
63
|
+
argTypes: [value],
|
|
64
|
+
returnType: value
|
|
65
|
+
}),
|
|
66
|
+
codegenImpl: (_ctx, [value]) => stitch`fwidth(${value})`
|
|
67
|
+
});
|
|
68
|
+
const fwidthCoarse = dualImpl({
|
|
69
|
+
name: "fwidthCoarse",
|
|
70
|
+
normalImpl: derivativeNormalError,
|
|
71
|
+
signature: (value) => ({
|
|
72
|
+
argTypes: [value],
|
|
73
|
+
returnType: value
|
|
74
|
+
}),
|
|
75
|
+
codegenImpl: (_ctx, [value]) => stitch`fwidthCoarse(${value})`
|
|
76
|
+
});
|
|
77
|
+
const fwidthFine = dualImpl({
|
|
78
|
+
name: "fwidthFine",
|
|
79
|
+
normalImpl: derivativeNormalError,
|
|
80
|
+
signature: (value) => ({
|
|
81
|
+
argTypes: [value],
|
|
82
|
+
returnType: value
|
|
83
|
+
}),
|
|
84
|
+
codegenImpl: (_ctx, [value]) => stitch`fwidthFine(${value})`
|
|
85
|
+
});
|
|
86
|
+
//#endregion
|
|
87
|
+
export { dpdx, dpdxCoarse, dpdxFine, dpdy, dpdyCoarse, dpdyFine, fwidth, fwidthCoarse, fwidthFine };
|
package/std/discard.d.ts
ADDED
package/std/discard.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Void } from "../data/wgslTypes.js";
|
|
2
|
+
import { dualImpl } from "../core/function/dualImpl.js";
|
|
3
|
+
//#region src/std/discard.ts
|
|
4
|
+
const discard = dualImpl({
|
|
5
|
+
name: "discard",
|
|
6
|
+
normalImpl: "`discard` relies on GPU resources and cannot be executed outside of a draw call",
|
|
7
|
+
signature: {
|
|
8
|
+
argTypes: [],
|
|
9
|
+
returnType: Void
|
|
10
|
+
},
|
|
11
|
+
codegenImpl: () => "discard;"
|
|
12
|
+
});
|
|
13
|
+
//#endregion
|
|
14
|
+
export { discard };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getResolutionCtx } from "../execMode.js";
|
|
2
|
+
import { comptime } from "../core/function/comptime.js";
|
|
3
|
+
import { wgslExtensions } from "../wgslExtensions.js";
|
|
4
|
+
//#region src/std/extensions.ts
|
|
5
|
+
const extensionEnabled = comptime((extensionName) => {
|
|
6
|
+
const resolutionCtx = getResolutionCtx();
|
|
7
|
+
if (!resolutionCtx) throw new Error("Functions using `extensionEnabled` cannot be called directly. Either generate WGSL from them, or use tgpu['~unstable'].simulate(...)");
|
|
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}'`);
|
|
9
|
+
return (resolutionCtx.enableExtensions ?? []).includes(extensionName);
|
|
10
|
+
});
|
|
11
|
+
//#endregion
|
|
12
|
+
export { extensionEnabled };
|
package/std/index.d.ts
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { identity2, identity3, identity4, rotationX4, rotationY4, rotationZ4, scaling4, translation4 } from "../data/matrix.js";
|
|
2
|
+
import { discard } from "./discard.js";
|
|
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, bitShiftLeft, bitShiftRight, div, mod, mul, neg, sub } from "./operators.js";
|
|
5
|
+
import { rotateX4, rotateY4, rotateZ4, scale4, translate4 } from "./matrix.js";
|
|
6
|
+
import { all, allEq, and, any, eq, ge, gt, isCloseTo, le, lt, ne, not, or, select } from "./boolean.js";
|
|
7
|
+
import { atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, storageBarrier, textureBarrier, workgroupBarrier } from "./atomic.js";
|
|
8
|
+
import { dpdx, dpdxCoarse, dpdxFine, dpdy, dpdyCoarse, dpdyFine, fwidth, fwidthCoarse, fwidthFine } from "./derivative.js";
|
|
9
|
+
import { arrayLength } from "./array.js";
|
|
10
|
+
import { pack2x16float, pack4x8unorm, unpack2x16float, unpack4x8unorm } from "./packing.js";
|
|
11
|
+
import { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleGrad, textureSampleLevel, textureStore } from "./texture.js";
|
|
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
|
+
import { extensionEnabled } from "./extensions.js";
|
|
14
|
+
import { bitcastU32toF32, bitcastU32toI32 } from "./bitcast.js";
|
|
15
|
+
import { range } from "./range.js";
|
|
2
16
|
|
|
3
17
|
//#region src/std/index.d.ts
|
|
4
18
|
declare namespace index_d_exports {
|
|
5
|
-
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 };
|
|
6
20
|
}
|
|
7
21
|
//#endregion
|
|
8
|
-
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,
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
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,7 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { identity2, identity3, identity4, rotationX4, rotationY4, rotationZ4, scaling4, translation4 } from "../data/matrix.js";
|
|
3
|
+
import { add, bitShiftLeft, bitShiftRight, div, mod, mul, neg, sub } from "./operators.js";
|
|
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
|
+
import { arrayLength } from "./array.js";
|
|
6
|
+
import { range } from "./range.js";
|
|
7
|
+
import { bitcastU32toF32, bitcastU32toI32 } from "./bitcast.js";
|
|
8
|
+
import { pack2x16float, pack4x8unorm, unpack2x16float, unpack4x8unorm } from "./packing.js";
|
|
9
|
+
import { all, allEq, and, any, eq, ge, gt, isCloseTo, le, lt, ne, not, or, select } from "./boolean.js";
|
|
10
|
+
import { discard } from "./discard.js";
|
|
11
|
+
import { rotateX4, rotateY4, rotateZ4, scale4, translate4 } from "./matrix.js";
|
|
12
|
+
import { atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, storageBarrier, textureBarrier, workgroupBarrier } from "./atomic.js";
|
|
13
|
+
import { dpdx, dpdxCoarse, dpdxFine, dpdy, dpdyCoarse, dpdyFine, fwidth, fwidthCoarse, fwidthFine } from "./derivative.js";
|
|
14
|
+
import { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleGrad, textureSampleLevel, textureStore } from "./texture.js";
|
|
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
|
+
import { extensionEnabled } from "./extensions.js";
|
|
5
17
|
//#region src/std/index.ts
|
|
6
18
|
var std_exports = /* @__PURE__ */ __exportAll({
|
|
7
19
|
abs: () => abs,
|
|
@@ -27,6 +39,8 @@ var std_exports = /* @__PURE__ */ __exportAll({
|
|
|
27
39
|
atomicStore: () => atomicStore,
|
|
28
40
|
atomicSub: () => atomicSub,
|
|
29
41
|
atomicXor: () => atomicXor,
|
|
42
|
+
bitShiftLeft: () => bitShiftLeft,
|
|
43
|
+
bitShiftRight: () => bitShiftRight,
|
|
30
44
|
bitcastU32toF32: () => bitcastU32toF32,
|
|
31
45
|
bitcastU32toI32: () => bitcastU32toI32,
|
|
32
46
|
ceil: () => ceil,
|
|
@@ -96,6 +110,7 @@ var std_exports = /* @__PURE__ */ __exportAll({
|
|
|
96
110
|
pow: () => pow,
|
|
97
111
|
quantizeToF16: () => quantizeToF16,
|
|
98
112
|
radians: () => radians,
|
|
113
|
+
range: () => range,
|
|
99
114
|
reflect: () => reflect,
|
|
100
115
|
refract: () => refract,
|
|
101
116
|
reverseBits: () => reverseBits,
|
|
@@ -150,6 +165,7 @@ var std_exports = /* @__PURE__ */ __exportAll({
|
|
|
150
165
|
textureSampleBias: () => textureSampleBias,
|
|
151
166
|
textureSampleCompare: () => textureSampleCompare,
|
|
152
167
|
textureSampleCompareLevel: () => textureSampleCompareLevel,
|
|
168
|
+
textureSampleGrad: () => textureSampleGrad,
|
|
153
169
|
textureSampleLevel: () => textureSampleLevel,
|
|
154
170
|
textureStore: () => textureStore,
|
|
155
171
|
translate4: () => translate4,
|
|
@@ -160,7 +176,5 @@ var std_exports = /* @__PURE__ */ __exportAll({
|
|
|
160
176
|
unpack4x8unorm: () => unpack4x8unorm,
|
|
161
177
|
workgroupBarrier: () => workgroupBarrier
|
|
162
178
|
});
|
|
163
|
-
|
|
164
179
|
//#endregion
|
|
165
|
-
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,
|
|
166
|
-
//# sourceMappingURL=index.js.map
|
|
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
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DualFn } from "../types.js";
|
|
2
|
+
import { m4x4f, v3f } from "../data/wgslTypes.js";
|
|
3
|
+
|
|
4
|
+
//#region src/std/matrix.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Translates the given 4-by-4 matrix by the given vector.
|
|
7
|
+
* @param {m4x4f} matrix - The matrix to be modified.
|
|
8
|
+
* @param {v3f} vector - The vector by which to translate the matrix.
|
|
9
|
+
* @returns {m4x4f} The translated matrix.
|
|
10
|
+
*/
|
|
11
|
+
declare const translate4: DualFn;
|
|
12
|
+
/**
|
|
13
|
+
* Scales the given 4-by-4 matrix in each dimension by an amount given by the corresponding entry in the given vector.
|
|
14
|
+
* @param {m4x4f} matrix - The matrix to be modified.
|
|
15
|
+
* @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.
|
|
16
|
+
* @returns {m4x4f} The scaled matrix.
|
|
17
|
+
*/
|
|
18
|
+
declare const scale4: DualFn;
|
|
19
|
+
/**
|
|
20
|
+
* Rotates the given 4-by-4 matrix around the x-axis by the given angle.
|
|
21
|
+
* @param {m4x4f} matrix - The matrix to be modified.
|
|
22
|
+
* @param {number} angle - The angle by which to rotate (in radians).
|
|
23
|
+
* @returns {m4x4f} The rotated matrix.
|
|
24
|
+
*/
|
|
25
|
+
declare const rotateX4: DualFn;
|
|
26
|
+
/**
|
|
27
|
+
* Rotates the given 4-by-4 matrix around the y-axis by the given angle.
|
|
28
|
+
* @param {m4x4f} matrix - The matrix to be modified.
|
|
29
|
+
* @param {number} angle - The angle by which to rotate (in radians).
|
|
30
|
+
* @returns {m4x4f} The rotated matrix.
|
|
31
|
+
*/
|
|
32
|
+
declare const rotateY4: DualFn;
|
|
33
|
+
/**
|
|
34
|
+
* Rotates the given 4-by-4 matrix around the z-axis by the given angle.
|
|
35
|
+
* @param {m4x4f} matrix - The matrix to be modified.
|
|
36
|
+
* @param {number} angle - The angle by which to rotate (in radians).
|
|
37
|
+
* @returns {m4x4f} The rotated matrix.
|
|
38
|
+
*/
|
|
39
|
+
declare const rotateZ4: DualFn;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { rotateX4, rotateY4, rotateZ4, scale4, translate4 };
|
package/std/matrix.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { $gpuCallable } from "../shared/symbols.js";
|
|
2
|
+
import { stitch } from "../core/resolve/stitch.js";
|
|
3
|
+
import { f32 } from "../data/numeric.js";
|
|
4
|
+
import { vec3f } from "../data/vector.js";
|
|
5
|
+
import { dualImpl } from "../core/function/dualImpl.js";
|
|
6
|
+
import { mat4x4f, rotationX4, rotationY4, rotationZ4, scaling4, translation4 } from "../data/matrix.js";
|
|
7
|
+
import { mul } from "./operators.js";
|
|
8
|
+
//#region src/std/matrix.ts
|
|
9
|
+
const gpuTranslation4 = translation4[$gpuCallable].call.bind(translation4);
|
|
10
|
+
const gpuScaling4 = scaling4[$gpuCallable].call.bind(scaling4);
|
|
11
|
+
const gpuRotationX4 = rotationX4[$gpuCallable].call.bind(rotationX4);
|
|
12
|
+
const gpuRotationY4 = rotationY4[$gpuCallable].call.bind(rotationY4);
|
|
13
|
+
const gpuRotationZ4 = rotationZ4[$gpuCallable].call.bind(rotationZ4);
|
|
14
|
+
/**
|
|
15
|
+
* Translates the given 4-by-4 matrix by the given vector.
|
|
16
|
+
* @param {m4x4f} matrix - The matrix to be modified.
|
|
17
|
+
* @param {v3f} vector - The vector by which to translate the matrix.
|
|
18
|
+
* @returns {m4x4f} The translated matrix.
|
|
19
|
+
*/
|
|
20
|
+
const translate4 = dualImpl({
|
|
21
|
+
name: "translate4",
|
|
22
|
+
normalImpl: (matrix, vector) => mul(translation4(vector), matrix),
|
|
23
|
+
signature: {
|
|
24
|
+
argTypes: [mat4x4f, vec3f],
|
|
25
|
+
returnType: mat4x4f
|
|
26
|
+
},
|
|
27
|
+
codegenImpl: (ctx, [matrix, vector]) => stitch`(${gpuTranslation4(ctx, [vector])} * ${matrix})`
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Scales the given 4-by-4 matrix in each dimension by an amount given by the corresponding entry in the given vector.
|
|
31
|
+
* @param {m4x4f} matrix - The matrix to be modified.
|
|
32
|
+
* @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.
|
|
33
|
+
* @returns {m4x4f} The scaled matrix.
|
|
34
|
+
*/
|
|
35
|
+
const scale4 = dualImpl({
|
|
36
|
+
name: "scale4",
|
|
37
|
+
normalImpl: (matrix, vector) => mul(scaling4(vector), matrix),
|
|
38
|
+
signature: {
|
|
39
|
+
argTypes: [mat4x4f, vec3f],
|
|
40
|
+
returnType: mat4x4f
|
|
41
|
+
},
|
|
42
|
+
codegenImpl: (ctx, [matrix, vector]) => stitch`(${gpuScaling4(ctx, [vector])} * ${matrix})`
|
|
43
|
+
});
|
|
44
|
+
const rotateSignature = {
|
|
45
|
+
argTypes: [mat4x4f, f32],
|
|
46
|
+
returnType: mat4x4f
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Rotates the given 4-by-4 matrix around the x-axis by the given angle.
|
|
50
|
+
* @param {m4x4f} matrix - The matrix to be modified.
|
|
51
|
+
* @param {number} angle - The angle by which to rotate (in radians).
|
|
52
|
+
* @returns {m4x4f} The rotated matrix.
|
|
53
|
+
*/
|
|
54
|
+
const rotateX4 = dualImpl({
|
|
55
|
+
name: "rotateX4",
|
|
56
|
+
normalImpl: (matrix, angle) => mul(rotationX4(angle), matrix),
|
|
57
|
+
signature: rotateSignature,
|
|
58
|
+
codegenImpl: (ctx, [matrix, angle]) => stitch`(${gpuRotationX4(ctx, [angle])} * ${matrix})`
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Rotates the given 4-by-4 matrix around the y-axis by the given angle.
|
|
62
|
+
* @param {m4x4f} matrix - The matrix to be modified.
|
|
63
|
+
* @param {number} angle - The angle by which to rotate (in radians).
|
|
64
|
+
* @returns {m4x4f} The rotated matrix.
|
|
65
|
+
*/
|
|
66
|
+
const rotateY4 = dualImpl({
|
|
67
|
+
name: "rotateY4",
|
|
68
|
+
normalImpl: (matrix, angle) => mul(rotationY4(angle), matrix),
|
|
69
|
+
signature: rotateSignature,
|
|
70
|
+
codegenImpl: (ctx, [matrix, angle]) => stitch`(${gpuRotationY4(ctx, [angle])} * ${matrix})`
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* Rotates the given 4-by-4 matrix around the z-axis by the given angle.
|
|
74
|
+
* @param {m4x4f} matrix - The matrix to be modified.
|
|
75
|
+
* @param {number} angle - The angle by which to rotate (in radians).
|
|
76
|
+
* @returns {m4x4f} The rotated matrix.
|
|
77
|
+
*/
|
|
78
|
+
const rotateZ4 = dualImpl({
|
|
79
|
+
name: "rotateZ4",
|
|
80
|
+
normalImpl: (matrix, angle) => mul(rotationZ4(angle), matrix),
|
|
81
|
+
signature: rotateSignature,
|
|
82
|
+
codegenImpl: (ctx, [matrix, angle]) => stitch`(${gpuRotationZ4(ctx, [angle])} * ${matrix})`
|
|
83
|
+
});
|
|
84
|
+
//#endregion
|
|
85
|
+
export { rotateX4, rotateY4, rotateZ4, scale4, translate4 };
|
package/std/numeric.d.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { DualFn } from "../types.js";
|
|
2
|
+
import { AbstractFloat, AbstractInt, AnyFloat32VecInstance, AnyFloatVecInstance, AnyIntegerVecInstance, AnyMatInstance, AnyNumericVecInstance, AnySignedVecInstance, F16, F32, I32, Vec2f, Vec2h, Vec2i, Vec3f, Vec3h, Vec3i, Vec4f, Vec4h, Vec4i, WgslStruct, v2f, v2h, v2i, v3f, v3h, v3i, v4f, v4h, v4i } from "../data/wgslTypes.js";
|
|
3
|
+
import { Infer } from "../shared/repr.js";
|
|
4
|
+
|
|
5
|
+
//#region src/std/numeric.d.ts
|
|
6
|
+
type NumVec = AnyNumericVecInstance;
|
|
7
|
+
declare function cpuAbs(value: number): number;
|
|
8
|
+
declare function cpuAbs<T extends NumVec | number>(value: T): T;
|
|
9
|
+
declare const abs: DualFn;
|
|
10
|
+
declare function cpuAcos(value: number): number;
|
|
11
|
+
declare function cpuAcos<T extends AnyFloatVecInstance>(value: T): T;
|
|
12
|
+
declare const acos: DualFn;
|
|
13
|
+
declare function cpuAcosh(value: number): number;
|
|
14
|
+
declare function cpuAcosh<T extends AnyFloatVecInstance>(value: T): T;
|
|
15
|
+
declare const acosh: DualFn;
|
|
16
|
+
declare function cpuAsin(value: number): number;
|
|
17
|
+
declare function cpuAsin<T extends AnyFloatVecInstance>(value: T): T;
|
|
18
|
+
declare const asin: DualFn;
|
|
19
|
+
declare function cpuAsinh(value: number): number;
|
|
20
|
+
declare function cpuAsinh<T extends AnyFloatVecInstance>(value: T): T;
|
|
21
|
+
declare const asinh: DualFn;
|
|
22
|
+
declare function cpuAtan(value: number): number;
|
|
23
|
+
declare function cpuAtan<T extends AnyFloatVecInstance>(value: T): T;
|
|
24
|
+
declare const atan: DualFn;
|
|
25
|
+
declare function cpuAtanh(value: number): number;
|
|
26
|
+
declare function cpuAtanh<T extends AnyFloatVecInstance>(value: T): T;
|
|
27
|
+
declare const atanh: DualFn;
|
|
28
|
+
declare function cpuAtan2(y: number, x: number): number;
|
|
29
|
+
declare function cpuAtan2<T extends AnyFloatVecInstance>(y: T, x: T): T;
|
|
30
|
+
declare const atan2: DualFn;
|
|
31
|
+
declare function cpuCeil(value: number): number;
|
|
32
|
+
declare function cpuCeil<T extends AnyFloatVecInstance>(value: T): T;
|
|
33
|
+
declare const ceil: DualFn;
|
|
34
|
+
declare function cpuClamp(value: number, low: number, high: number): number;
|
|
35
|
+
declare function cpuClamp<T extends NumVec | number>(value: T, low: T, high: T): T;
|
|
36
|
+
declare const clamp: DualFn;
|
|
37
|
+
declare function cpuCos(value: number): number;
|
|
38
|
+
declare function cpuCos<T extends AnyFloatVecInstance>(value: T): T;
|
|
39
|
+
declare const cos: DualFn;
|
|
40
|
+
declare function cpuCosh(value: number): number;
|
|
41
|
+
declare function cpuCosh<T extends AnyFloatVecInstance>(value: T): T;
|
|
42
|
+
declare const cosh: DualFn;
|
|
43
|
+
declare function cpuCountLeadingZeros(value: number): number;
|
|
44
|
+
declare function cpuCountLeadingZeros<T extends AnyIntegerVecInstance>(value: T): T;
|
|
45
|
+
declare const countLeadingZeros: DualFn;
|
|
46
|
+
declare function cpuCountOneBits(value: number): number;
|
|
47
|
+
declare function cpuCountOneBits<T extends AnyIntegerVecInstance>(value: T): T;
|
|
48
|
+
declare const countOneBits: DualFn;
|
|
49
|
+
declare function cpuCountTrailingZeros(value: number): number;
|
|
50
|
+
declare function cpuCountTrailingZeros<T extends AnyIntegerVecInstance>(value: T): T;
|
|
51
|
+
declare const countTrailingZeros: DualFn;
|
|
52
|
+
declare const cross: DualFn;
|
|
53
|
+
declare function cpuDegrees(value: number): number;
|
|
54
|
+
declare function cpuDegrees<T extends AnyFloatVecInstance>(value: T): T;
|
|
55
|
+
declare const degrees: DualFn;
|
|
56
|
+
declare const determinant: DualFn;
|
|
57
|
+
declare function cpuDistance(a: number, b: number): number;
|
|
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;
|
|
63
|
+
declare function cpuExp(value: number): number;
|
|
64
|
+
declare function cpuExp<T extends AnyFloatVecInstance>(value: T): T;
|
|
65
|
+
declare const exp: DualFn;
|
|
66
|
+
declare function cpuExp2(value: number): number;
|
|
67
|
+
declare function cpuExp2<T extends AnyFloatVecInstance>(value: T): T;
|
|
68
|
+
declare const exp2: DualFn;
|
|
69
|
+
declare function cpuExtractBits(e: number, offset: number, count: number): number;
|
|
70
|
+
declare function cpuExtractBits<T extends AnyIntegerVecInstance>(e: T, offset: number, count: number): T;
|
|
71
|
+
declare const extractBits: DualFn;
|
|
72
|
+
declare const faceForward: DualFn;
|
|
73
|
+
declare function cpuFirstLeadingBit(value: number): number;
|
|
74
|
+
declare function cpuFirstLeadingBit<T extends AnyIntegerVecInstance>(value: T): T;
|
|
75
|
+
declare const firstLeadingBit: DualFn;
|
|
76
|
+
declare function cpuFirstTrailingBit(value: number): number;
|
|
77
|
+
declare function cpuFirstTrailingBit<T extends AnyIntegerVecInstance>(value: T): T;
|
|
78
|
+
declare const firstTrailingBit: DualFn;
|
|
79
|
+
declare function cpuFloor(value: number): number;
|
|
80
|
+
declare function cpuFloor<T extends AnyFloatVecInstance>(value: T): T;
|
|
81
|
+
declare const floor: DualFn;
|
|
82
|
+
declare function cpuFma(e1: number, e2: number, e3: number): number;
|
|
83
|
+
declare function cpuFma<T extends AnyFloatVecInstance>(e1: T, e2: T, e3: T): T;
|
|
84
|
+
declare const fma: DualFn;
|
|
85
|
+
declare function cpuFract(value: number): number;
|
|
86
|
+
declare function cpuFract<T extends AnyFloatVecInstance>(value: T): T;
|
|
87
|
+
declare const fract: DualFn;
|
|
88
|
+
declare const FrexpResults: {
|
|
89
|
+
readonly f32: WgslStruct;
|
|
90
|
+
readonly f16: WgslStruct;
|
|
91
|
+
readonly abstractFloat: WgslStruct;
|
|
92
|
+
readonly vec2f: WgslStruct;
|
|
93
|
+
readonly vec3f: WgslStruct;
|
|
94
|
+
readonly vec4f: WgslStruct;
|
|
95
|
+
readonly vec2h: WgslStruct;
|
|
96
|
+
readonly vec3h: WgslStruct;
|
|
97
|
+
readonly vec4h: WgslStruct;
|
|
98
|
+
};
|
|
99
|
+
type FrexpOverload = {
|
|
100
|
+
(value: number): Infer<(typeof FrexpResults)['f32']>;
|
|
101
|
+
<T extends AnyFloatVecInstance>(value: T): Infer<(typeof FrexpResults)[T['kind']]>;
|
|
102
|
+
};
|
|
103
|
+
declare const frexp: DualFn;
|
|
104
|
+
declare function cpuInsertBits(e: number, newbits: number, offset: number, count: number): number;
|
|
105
|
+
declare function cpuInsertBits<T extends AnyIntegerVecInstance>(e: T, newbits: T, offset: number, count: number): T;
|
|
106
|
+
declare const insertBits: DualFn;
|
|
107
|
+
declare function cpuInverseSqrt(value: number): number;
|
|
108
|
+
declare function cpuInverseSqrt<T extends AnyFloatVecInstance>(value: T): T;
|
|
109
|
+
declare const inverseSqrt: DualFn;
|
|
110
|
+
declare function cpuLdexp(e1: number, e2: number): number;
|
|
111
|
+
declare function cpuLdexp<T extends v2f | v2h>(e1: T, e2: v2i): T;
|
|
112
|
+
declare function cpuLdexp<T extends v3f | v3h>(e1: T, e2: v3i): T;
|
|
113
|
+
declare function cpuLdexp<T extends v4f | v4h>(e1: T, e2: v4i): T;
|
|
114
|
+
declare const ldexp: DualFn;
|
|
115
|
+
declare function cpuLength(value: number): number;
|
|
116
|
+
declare function cpuLength<T extends AnyFloatVecInstance>(value: T): number;
|
|
117
|
+
declare const length: DualFn;
|
|
118
|
+
declare function cpuLog(value: number): number;
|
|
119
|
+
declare function cpuLog<T extends AnyFloatVecInstance>(value: T): T;
|
|
120
|
+
declare const log: DualFn;
|
|
121
|
+
declare function cpuLog2(value: number): number;
|
|
122
|
+
declare function cpuLog2<T extends AnyFloatVecInstance>(value: T): T;
|
|
123
|
+
declare const log2: DualFn;
|
|
124
|
+
type VariadicOverload = {
|
|
125
|
+
(fst: number, ...rest: number[]): number;
|
|
126
|
+
<T extends NumVec>(fst: T, ...rest: T[]): T;
|
|
127
|
+
};
|
|
128
|
+
declare const max: DualFn;
|
|
129
|
+
declare const min: DualFn;
|
|
130
|
+
declare function cpuMix(e1: number, e2: number, e3: number): number;
|
|
131
|
+
declare function cpuMix<T extends AnyFloatVecInstance>(e1: T, e2: T, e3: number): T;
|
|
132
|
+
declare function cpuMix<T extends AnyFloatVecInstance>(e1: T, e2: T, e3: T): T;
|
|
133
|
+
declare const mix: DualFn;
|
|
134
|
+
declare const ModfResult: {
|
|
135
|
+
readonly f32: WgslStruct;
|
|
136
|
+
readonly f16: WgslStruct;
|
|
137
|
+
readonly abstractFloat: WgslStruct;
|
|
138
|
+
readonly vec2f: WgslStruct;
|
|
139
|
+
readonly vec3f: WgslStruct;
|
|
140
|
+
readonly vec4f: WgslStruct;
|
|
141
|
+
readonly vec2h: WgslStruct;
|
|
142
|
+
readonly vec3h: WgslStruct;
|
|
143
|
+
readonly vec4h: WgslStruct;
|
|
144
|
+
};
|
|
145
|
+
type ModfOverload = {
|
|
146
|
+
(value: number): Infer<(typeof ModfResult)['f32']>;
|
|
147
|
+
<T extends AnyFloatVecInstance>(value: T): Infer<(typeof ModfResult)[T['kind']]>;
|
|
148
|
+
};
|
|
149
|
+
declare const modf: ModfOverload;
|
|
150
|
+
declare const normalize: DualFn;
|
|
151
|
+
declare function powCpu(base: number, exponent: number): number;
|
|
152
|
+
declare function powCpu<T extends AnyFloatVecInstance>(base: T, exponent: T): T;
|
|
153
|
+
declare const pow: DualFn;
|
|
154
|
+
declare function cpuQuantizeToF16(value: number): number;
|
|
155
|
+
declare function cpuQuantizeToF16<T extends AnyFloat32VecInstance>(value: T): T;
|
|
156
|
+
declare const quantizeToF16: DualFn;
|
|
157
|
+
declare function cpuRadians(value: number): number;
|
|
158
|
+
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;
|
|
162
|
+
declare function cpuReverseBits(value: number): number;
|
|
163
|
+
declare function cpuReverseBits<T extends AnyIntegerVecInstance>(value: T): T;
|
|
164
|
+
declare const reverseBits: DualFn;
|
|
165
|
+
declare function cpuRound(value: number): number;
|
|
166
|
+
declare function cpuRound<T extends AnyFloatVecInstance>(value: T): T;
|
|
167
|
+
declare const round: DualFn;
|
|
168
|
+
declare function cpuSaturate(value: number): number;
|
|
169
|
+
declare function cpuSaturate<T extends AnyFloatVecInstance>(value: T): T;
|
|
170
|
+
declare const saturate: DualFn;
|
|
171
|
+
declare function cpuSign(e: number): number;
|
|
172
|
+
declare function cpuSign<T extends AnySignedVecInstance>(e: T): T;
|
|
173
|
+
declare const sign: DualFn;
|
|
174
|
+
declare function cpuSin(value: number): number;
|
|
175
|
+
declare function cpuSin<T extends AnyFloatVecInstance>(value: T): T;
|
|
176
|
+
declare const sin: DualFn;
|
|
177
|
+
declare function cpuSinh(value: number): number;
|
|
178
|
+
declare function cpuSinh<T extends AnyFloatVecInstance>(value: T): T;
|
|
179
|
+
declare const sinh: DualFn;
|
|
180
|
+
declare function cpuSmoothstep(edge0: number, edge1: number, x: number): number;
|
|
181
|
+
declare function cpuSmoothstep<T extends AnyFloatVecInstance>(edge0: T, edge1: T, x: T): T;
|
|
182
|
+
declare const smoothstep: DualFn;
|
|
183
|
+
declare function cpuSqrt(value: number): number;
|
|
184
|
+
declare function cpuSqrt<T extends AnyFloatVecInstance>(value: T): T;
|
|
185
|
+
declare const sqrt: DualFn;
|
|
186
|
+
declare function cpuStep(edge: number, x: number): number;
|
|
187
|
+
declare function cpuStep<T extends AnyFloatVecInstance | number>(edge: T, x: T): T;
|
|
188
|
+
declare const step: DualFn;
|
|
189
|
+
declare function cpuTan(value: number): number;
|
|
190
|
+
declare function cpuTan<T extends AnyFloatVecInstance>(value: T): T;
|
|
191
|
+
declare const tan: DualFn;
|
|
192
|
+
declare function cpuTanh(value: number): number;
|
|
193
|
+
declare function cpuTanh<T extends AnyFloatVecInstance>(value: T): T;
|
|
194
|
+
declare const tanh: DualFn;
|
|
195
|
+
declare const transpose: DualFn;
|
|
196
|
+
declare function cpuTrunc(value: number): number;
|
|
197
|
+
declare function cpuTrunc<T extends AnyFloatVecInstance>(value: T): T;
|
|
198
|
+
declare const trunc: DualFn;
|
|
199
|
+
//#endregion
|
|
200
|
+
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 };
|