typegpu 0.10.1 → 0.10.2
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/{chunk-BYypO7fO.js → _virtual/_rolldown/runtime.js} +1 -1
- package/builtin.d.ts +50 -0
- package/builtin.js +37 -0
- package/common/fullScreenTriangle.d.ts +26 -0
- package/common/fullScreenTriangle.js +36 -0
- package/common/index.d.ts +2 -3
- package/common/index.js +3 -4
- package/core/buffer/buffer.d.ts +74 -0
- package/core/buffer/buffer.js +197 -0
- package/core/buffer/bufferShorthand.d.ts +48 -0
- package/core/buffer/bufferShorthand.js +49 -0
- package/core/buffer/bufferUsage.d.ts +45 -0
- package/core/buffer/bufferUsage.js +163 -0
- package/core/constant/tgpuConstant.d.ts +28 -0
- package/core/constant/tgpuConstant.js +67 -0
- package/core/declare/tgpuDeclare.d.ts +18 -0
- package/core/declare/tgpuDeclare.js +40 -0
- package/core/function/autoIO.d.ts +37 -0
- package/core/function/autoIO.js +87 -0
- package/core/function/comptime.d.ts +39 -0
- package/core/function/comptime.js +51 -0
- package/core/function/createCallableSchema.js +42 -0
- package/core/function/dualImpl.js +54 -0
- package/core/function/extractArgs.js +204 -0
- package/core/function/fnCore.js +79 -0
- package/core/function/fnTypes.d.ts +34 -0
- package/core/function/ioSchema.d.ts +10 -0
- package/core/function/ioSchema.js +30 -0
- package/core/function/shelllessImpl.d.ts +28 -0
- package/core/function/shelllessImpl.js +23 -0
- package/core/function/templateUtils.js +13 -0
- package/core/function/tgpuComputeFn.d.ts +49 -0
- package/core/function/tgpuComputeFn.js +62 -0
- package/core/function/tgpuFn.d.ts +52 -0
- package/core/function/tgpuFn.js +170 -0
- package/core/function/tgpuFragmentFn.d.ts +68 -0
- package/core/function/tgpuFragmentFn.js +68 -0
- package/core/function/tgpuVertexFn.d.ts +55 -0
- package/core/function/tgpuVertexFn.js +65 -0
- package/core/pipeline/applyPipelineState.js +37 -0
- package/core/pipeline/computePipeline.d.ts +58 -0
- package/core/pipeline/computePipeline.js +226 -0
- package/core/pipeline/connectAttachmentToShader.js +26 -0
- package/core/pipeline/connectTargetsToShader.js +29 -0
- package/core/pipeline/limitsOverflow.js +13 -0
- package/core/pipeline/renderPipeline.d.ts +266 -0
- package/core/pipeline/renderPipeline.js +471 -0
- package/core/pipeline/timeable.d.ts +23 -0
- package/core/pipeline/timeable.js +61 -0
- package/core/pipeline/typeGuards.js +29 -0
- package/core/querySet/querySet.d.ts +22 -0
- package/core/querySet/querySet.js +103 -0
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +59 -0
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +96 -0
- package/core/resolve/externals.d.ts +10 -0
- package/core/resolve/externals.js +58 -0
- package/core/resolve/namespace.d.ts +38 -0
- package/core/resolve/namespace.js +41 -0
- package/core/resolve/resolveData.js +146 -0
- package/core/resolve/stitch.js +25 -0
- package/core/resolve/tgpuResolve.d.ts +151 -0
- package/core/resolve/tgpuResolve.js +68 -0
- package/core/root/configurableImpl.js +18 -0
- package/core/root/init.d.ts +69 -0
- package/core/root/init.js +457 -0
- package/core/root/rootTypes.d.ts +622 -0
- package/core/sampler/sampler.d.ts +35 -0
- package/core/sampler/sampler.js +116 -0
- package/core/simulate/tgpuSimulate.d.ts +36 -0
- package/core/simulate/tgpuSimulate.js +76 -0
- package/core/slot/accessor.d.ts +13 -0
- package/core/slot/accessor.js +97 -0
- package/core/slot/internalSlots.js +7 -0
- package/core/slot/lazy.d.ts +6 -0
- package/core/slot/lazy.js +42 -0
- package/core/slot/slot.d.ts +6 -0
- package/core/slot/slot.js +40 -0
- package/core/slot/slotTypes.d.ts +92 -0
- package/core/slot/slotTypes.js +21 -0
- package/core/texture/externalTexture.d.ts +12 -0
- package/core/texture/externalTexture.js +48 -0
- package/core/texture/texture.d.ts +118 -0
- package/core/texture/texture.js +312 -0
- package/core/texture/textureFormats.d.ts +29 -0
- package/core/texture/textureFormats.js +99 -0
- package/core/texture/textureProps.d.ts +11 -0
- package/core/texture/textureUtils.js +224 -0
- package/core/texture/usageExtension.d.ts +21 -0
- package/core/texture/usageExtension.js +21 -0
- package/core/unroll/tgpuUnroll.d.ts +13 -0
- package/core/unroll/tgpuUnroll.js +36 -0
- package/core/valueProxyUtils.js +44 -0
- package/core/variable/tgpuVariable.d.ts +38 -0
- package/core/variable/tgpuVariable.js +101 -0
- package/core/vertexLayout/connectAttributesToShader.js +59 -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 +15 -0
- package/data/alignmentOf.d.ts +10 -0
- package/data/alignmentOf.js +88 -0
- package/data/array.d.ts +28 -0
- package/data/array.js +48 -0
- package/data/atomic.d.ts +15 -0
- package/data/atomic.js +25 -0
- package/data/attributes.d.ts +121 -0
- package/data/attributes.js +145 -0
- package/data/autoStruct.d.ts +3 -0
- package/data/autoStruct.js +83 -0
- package/data/compiledIO.js +231 -0
- package/data/dataIO.js +549 -0
- package/data/dataTypes.d.ts +115 -0
- package/data/dataTypes.js +97 -0
- package/data/deepEqual.d.ts +25 -0
- package/data/deepEqual.js +58 -0
- package/data/disarray.d.ts +34 -0
- package/data/disarray.js +52 -0
- package/data/getLongestContiguousPrefix.d.ts +10 -0
- package/data/getLongestContiguousPrefix.js +15 -0
- package/data/index.d.ts +26 -4
- package/data/index.js +27 -7
- package/data/instanceToSchema.d.ts +33 -0
- package/data/isContiguous.d.ts +10 -0
- package/data/isContiguous.js +15 -0
- package/data/matrix.d.ts +126 -0
- package/data/matrix.js +517 -0
- package/data/numberOps.js +24 -0
- package/data/numeric.d.ts +81 -0
- package/data/numeric.js +234 -0
- package/data/offsetUtils.d.ts +33 -0
- package/data/offsetUtils.js +167 -0
- package/data/offsets.js +36 -0
- package/data/partialIO.js +68 -0
- package/data/ptr.d.ts +12 -0
- package/data/ptr.js +46 -0
- package/data/ref.d.ts +37 -0
- package/data/ref.js +96 -0
- package/data/sampler.d.ts +107 -0
- package/data/sampler.js +26 -0
- package/data/schemaCallWrapper.js +32 -0
- package/data/schemaMemoryLayout.js +200 -0
- package/data/sizeOf.d.ts +10 -0
- package/data/sizeOf.js +15 -0
- package/data/snippet.d.ts +26 -0
- package/data/snippet.js +61 -0
- package/data/struct.d.ts +17 -0
- package/data/struct.js +46 -0
- package/data/texture.d.ts +292 -0
- package/{texture-BagDrrks.js → data/texture.js} +6 -3
- package/data/unstruct.d.ts +24 -0
- package/data/unstruct.js +43 -0
- package/data/vector.d.ts +191 -0
- package/data/vector.js +247 -0
- package/data/vectorImpl.js +516 -0
- package/data/vectorOps.js +664 -0
- package/data/vertexFormatData.d.ts +190 -0
- package/data/vertexFormatData.js +110 -0
- package/data/wgslTypes.d.ts +896 -0
- package/data/wgslTypes.js +215 -0
- package/errors.d.ts +44 -0
- package/errors.js +128 -0
- package/execMode.js +51 -0
- package/extension.d.ts +11 -0
- package/extension.js +18 -0
- package/getGPUValue.js +9 -0
- package/index.d.ts +40 -243
- package/index.js +19 -6318
- package/indexNamedExports.d.ts +38 -0
- package/mathUtils.js +13 -0
- package/memo.js +22 -0
- package/nameRegistry.d.ts +30 -0
- package/nameRegistry.js +449 -0
- package/package.js +5 -0
- package/package.json +23 -23
- package/resolutionCtx.d.ts +29 -0
- package/resolutionCtx.js +546 -0
- package/shared/env.js +13 -0
- package/shared/generators.js +14 -0
- package/shared/meta.d.ts +39 -0
- package/shared/meta.js +63 -0
- package/shared/repr.d.ts +108 -0
- package/shared/stringify.js +22 -0
- package/shared/symbols.d.ts +61 -0
- package/shared/symbols.js +71 -0
- package/shared/utilityTypes.d.ts +29 -0
- package/shared/utilityTypes.js +7 -0
- package/shared/vertexFormat.d.ts +70 -0
- package/shared/vertexFormat.js +64 -0
- package/std/array.d.ts +7 -0
- package/std/array.js +27 -0
- package/std/atomic.d.ts +19 -0
- package/std/atomic.js +113 -0
- package/std/bitcast.d.ts +10 -0
- package/std/bitcast.js +43 -0
- package/std/boolean.d.ts +127 -0
- package/std/boolean.js +274 -0
- package/std/derivative.d.ts +16 -0
- package/std/derivative.js +89 -0
- package/std/discard.d.ts +6 -0
- package/std/discard.js +16 -0
- package/std/extensions.d.ts +8 -0
- package/std/extensions.js +14 -0
- package/std/index.d.ts +15 -3
- package/std/index.js +16 -5
- package/std/matrix.d.ts +41 -0
- package/std/matrix.js +87 -0
- package/std/numeric.d.ts +254 -0
- package/std/numeric.js +847 -0
- package/std/operators.d.ts +48 -0
- package/std/operators.js +153 -0
- package/std/packing.d.ts +26 -0
- package/std/packing.js +86 -0
- package/std/subgroup.d.ts +47 -0
- package/std/subgroup.js +220 -0
- package/std/texture.d.ts +108 -0
- package/std/texture.js +197 -0
- package/tgpu.js +44 -0
- package/tgpuBindGroupLayout.d.ts +161 -0
- package/tgpuBindGroupLayout.js +271 -0
- package/tgpuUnstable.d.ts +48 -0
- package/tgpuUnstable.js +66 -0
- package/tgsl/accessIndex.js +45 -0
- package/tgsl/accessProp.js +113 -0
- package/tgsl/consoleLog/deserializers.js +117 -0
- package/tgsl/consoleLog/logGenerator.js +86 -0
- package/tgsl/consoleLog/serializers.js +225 -0
- package/tgsl/consoleLog/types.d.ts +54 -0
- package/tgsl/consoleLog/types.js +12 -0
- package/tgsl/conversion.js +200 -0
- package/tgsl/forOfUtils.js +45 -0
- package/tgsl/generationHelpers.d.ts +37 -0
- package/tgsl/generationHelpers.js +67 -0
- package/tgsl/math.js +45 -0
- package/tgsl/shaderGenerator.d.ts +18 -0
- package/tgsl/shellless.d.ts +11 -0
- package/tgsl/shellless.js +53 -0
- package/tgsl/wgslGenerator.js +585 -0
- package/types.d.ts +255 -0
- package/types.js +43 -0
- package/unwrapper.d.ts +27 -0
- package/wgslExtensions.d.ts +5 -0
- package/wgslExtensions.js +18 -0
- package/builtin-DdtWpk2t.js +0 -818
- package/builtin-DdtWpk2t.js.map +0 -1
- 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,97 @@
|
|
|
1
|
+
import { $internal, isMarkedInternal } from "../shared/symbols.js";
|
|
2
|
+
import { setName } from "../shared/meta.js";
|
|
3
|
+
import { vertexFormats } from "../shared/vertexFormat.js";
|
|
4
|
+
import { isAlignAttrib, isDecorated, isLocationAttrib, isPtr, isSizeAttrib, isWgslData } from "./wgslTypes.js";
|
|
5
|
+
|
|
6
|
+
//#region src/data/dataTypes.ts
|
|
7
|
+
/**
|
|
8
|
+
* Runtime function to extract the inner data type from decorated types.
|
|
9
|
+
* If the data is not decorated, returns the data as-is.
|
|
10
|
+
*/
|
|
11
|
+
function undecorate(data) {
|
|
12
|
+
if (isDecorated(data) || isLooseDecorated(data)) return data.inner;
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function unptr(data) {
|
|
16
|
+
if (isPtr(data)) return data.inner;
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
const looseTypeLiterals = [
|
|
20
|
+
"unstruct",
|
|
21
|
+
"disarray",
|
|
22
|
+
"loose-decorated",
|
|
23
|
+
...vertexFormats
|
|
24
|
+
];
|
|
25
|
+
function isLooseData(data) {
|
|
26
|
+
return isMarkedInternal(data) && looseTypeLiterals.includes(data?.type);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Checks whether the passed in value is a disarray schema,
|
|
30
|
+
* as opposed to, e.g., a regular array schema.
|
|
31
|
+
*
|
|
32
|
+
* Array schemas can be used to describe uniform and storage buffers,
|
|
33
|
+
* whereas disarray schemas cannot. Disarrays are useful for
|
|
34
|
+
* defining vertex buffers instead.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* isDisarray(d.arrayOf(d.u32, 4)) // false
|
|
38
|
+
* isDisarray(d.disarrayOf(d.u32, 4)) // true
|
|
39
|
+
* isDisarray(d.vec3f) // false
|
|
40
|
+
*/
|
|
41
|
+
function isDisarray(schema) {
|
|
42
|
+
return isMarkedInternal(schema) && schema?.type === "disarray";
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Checks whether passed in value is a unstruct schema,
|
|
46
|
+
* as opposed to, e.g., a struct schema.
|
|
47
|
+
*
|
|
48
|
+
* Struct schemas can be used to describe uniform and storage buffers,
|
|
49
|
+
* whereas unstruct schemas cannot. Unstructs are useful for
|
|
50
|
+
* defining vertex buffers instead.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* isUnstruct(d.struct({ a: d.u32 })) // false
|
|
54
|
+
* isUnstruct(d.unstruct({ a: d.u32 })) // true
|
|
55
|
+
* isUnstruct(d.vec3f) // false
|
|
56
|
+
*/
|
|
57
|
+
function isUnstruct(schema) {
|
|
58
|
+
return isMarkedInternal(schema) && schema?.type === "unstruct";
|
|
59
|
+
}
|
|
60
|
+
function isLooseDecorated(value) {
|
|
61
|
+
return isMarkedInternal(value) && value?.type === "loose-decorated";
|
|
62
|
+
}
|
|
63
|
+
function getCustomAlignment(data) {
|
|
64
|
+
return data.attribs?.find(isAlignAttrib)?.params[0];
|
|
65
|
+
}
|
|
66
|
+
function getCustomSize(data) {
|
|
67
|
+
return data.attribs?.find(isSizeAttrib)?.params[0];
|
|
68
|
+
}
|
|
69
|
+
function getCustomLocation(data) {
|
|
70
|
+
return data.attribs?.find(isLocationAttrib)?.params[0];
|
|
71
|
+
}
|
|
72
|
+
function isData(value) {
|
|
73
|
+
return isWgslData(value) || isLooseData(value);
|
|
74
|
+
}
|
|
75
|
+
const UnknownData = Symbol("UNKNOWN");
|
|
76
|
+
var InfixDispatch = class {
|
|
77
|
+
constructor(name, lhs, operator) {
|
|
78
|
+
this.name = name;
|
|
79
|
+
this.lhs = lhs;
|
|
80
|
+
this.operator = operator;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var MatrixColumnsAccess = class {
|
|
84
|
+
constructor(matrix) {
|
|
85
|
+
this.matrix = matrix;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var ConsoleLog = class {
|
|
89
|
+
[$internal] = true;
|
|
90
|
+
constructor(op) {
|
|
91
|
+
this.op = op;
|
|
92
|
+
setName(this, "consoleLog");
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
export { ConsoleLog, InfixDispatch, MatrixColumnsAccess, UnknownData, getCustomAlignment, getCustomLocation, getCustomSize, isData, isDisarray, isLooseData, isLooseDecorated, isUnstruct, undecorate, unptr };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AnyData } from "./dataTypes.js";
|
|
2
|
+
|
|
3
|
+
//#region src/data/deepEqual.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Performs a deep comparison of two TypeGPU data schemas.
|
|
6
|
+
*
|
|
7
|
+
* @param a The first data schema to compare.
|
|
8
|
+
* @param b The second data schema to compare.
|
|
9
|
+
* @returns `true` if the schemas are deeply equal, `false` otherwise.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { vec3f, struct, deepEqual } from 'typegpu/data';
|
|
14
|
+
*
|
|
15
|
+
* const schema1 = struct({ a: vec3f });
|
|
16
|
+
* const schema2 = struct({ a: vec3f });
|
|
17
|
+
* const schema3 = struct({ b: vec3f });
|
|
18
|
+
*
|
|
19
|
+
* console.log(deepEqual(schema1, schema2)); // true
|
|
20
|
+
* console.log(deepEqual(schema1, schema3)); // false
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare function deepEqual(a: AnyData, b: AnyData): boolean;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { deepEqual };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isAtomic, isDecorated, isPtr, isWgslArray, isWgslStruct } from "./wgslTypes.js";
|
|
2
|
+
import { isDisarray, isLooseDecorated, isUnstruct } from "./dataTypes.js";
|
|
3
|
+
|
|
4
|
+
//#region src/data/deepEqual.ts
|
|
5
|
+
/**
|
|
6
|
+
* Performs a deep comparison of two TypeGPU data schemas.
|
|
7
|
+
*
|
|
8
|
+
* @param a The first data schema to compare.
|
|
9
|
+
* @param b The second data schema to compare.
|
|
10
|
+
* @returns `true` if the schemas are deeply equal, `false` otherwise.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { vec3f, struct, deepEqual } from 'typegpu/data';
|
|
15
|
+
*
|
|
16
|
+
* const schema1 = struct({ a: vec3f });
|
|
17
|
+
* const schema2 = struct({ a: vec3f });
|
|
18
|
+
* const schema3 = struct({ b: vec3f });
|
|
19
|
+
*
|
|
20
|
+
* console.log(deepEqual(schema1, schema2)); // true
|
|
21
|
+
* console.log(deepEqual(schema1, schema3)); // false
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function deepEqual(a, b) {
|
|
25
|
+
if (a === b) return true;
|
|
26
|
+
if (a.type !== b.type) return false;
|
|
27
|
+
if (isWgslStruct(a) && isWgslStruct(b) || isUnstruct(a) && isUnstruct(b)) {
|
|
28
|
+
const aProps = a.propTypes;
|
|
29
|
+
const bProps = b.propTypes;
|
|
30
|
+
const aKeys = Object.keys(aProps);
|
|
31
|
+
const bKeys = Object.keys(bProps);
|
|
32
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
33
|
+
for (let i = 0; i < aKeys.length; i++) {
|
|
34
|
+
const keyA = aKeys[i];
|
|
35
|
+
const keyB = bKeys[i];
|
|
36
|
+
if (keyA !== keyB || !keyA || !keyB || !deepEqual(aProps[keyA], bProps[keyB])) return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (isWgslArray(a) && isWgslArray(b) || isDisarray(a) && isDisarray(b)) return a.elementCount === b.elementCount && deepEqual(a.elementType, b.elementType);
|
|
41
|
+
if (isPtr(a) && isPtr(b)) return a.addressSpace === b.addressSpace && a.access === b.access && deepEqual(a.inner, b.inner);
|
|
42
|
+
if (isAtomic(a) && isAtomic(b)) return deepEqual(a.inner, b.inner);
|
|
43
|
+
if (isDecorated(a) && isDecorated(b) || isLooseDecorated(a) && isLooseDecorated(b)) {
|
|
44
|
+
if (!deepEqual(a.inner, b.inner)) return false;
|
|
45
|
+
if (a.attribs.length !== b.attribs.length) return false;
|
|
46
|
+
const getAttrKey = (attr) => {
|
|
47
|
+
const anyAttr = attr;
|
|
48
|
+
return `${anyAttr.type}(${(anyAttr.params ?? []).join(",")})`;
|
|
49
|
+
};
|
|
50
|
+
const attrsA = a.attribs.map(getAttrKey);
|
|
51
|
+
const attrsB = b.attribs.map(getAttrKey);
|
|
52
|
+
for (let i = 0; i < attrsA.length; i++) if (attrsA[i] !== attrsB[i]) return false;
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
export { deepEqual };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AnyData, Disarray } from "./dataTypes.js";
|
|
2
|
+
import { TgpuComptime } from "../core/function/comptime.js";
|
|
3
|
+
import "../indexNamedExports.js";
|
|
4
|
+
|
|
5
|
+
//#region src/data/disarray.d.ts
|
|
6
|
+
interface DisarrayConstructor {
|
|
7
|
+
<TElement extends AnyData>(elementType: TElement): (elementCount: number) => Disarray<TElement>;
|
|
8
|
+
<TElement extends AnyData>(elementType: TElement, elementCount: number): Disarray<TElement>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates an array schema that can be used to construct vertex buffers.
|
|
12
|
+
* Describes arrays with fixed-size length, storing elements of the same type.
|
|
13
|
+
*
|
|
14
|
+
* Elements in the schema are not aligned in respect to their `byteAlignment`,
|
|
15
|
+
* unless they are explicitly decorated with the custom align attribute
|
|
16
|
+
* via `d.align` function.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const disarray = d.disarrayOf(d.vec3f, 3); // packed array of vec3f
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const disarray = d.disarrayOf(d.align(16, d.vec3f), 3);
|
|
23
|
+
*
|
|
24
|
+
* If `elementCount` is not specified, a partially applied function is returned.
|
|
25
|
+
* @example
|
|
26
|
+
* const disarray = d.disarrayOf(d.vec3f);
|
|
27
|
+
* // ^? (n: number) => Disarray<d.Vec3f>
|
|
28
|
+
*
|
|
29
|
+
* @param elementType The type of elements in the array.
|
|
30
|
+
* @param elementCount The number of elements in the array.
|
|
31
|
+
*/
|
|
32
|
+
declare const disarrayOf: TgpuComptime<DisarrayConstructor>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { disarrayOf };
|
package/data/disarray.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { $internal } from "../shared/symbols.js";
|
|
2
|
+
import { schemaCallWrapper } from "./schemaCallWrapper.js";
|
|
3
|
+
import { comptime } from "../core/function/comptime.js";
|
|
4
|
+
|
|
5
|
+
//#region src/data/disarray.ts
|
|
6
|
+
/**
|
|
7
|
+
* Creates an array schema that can be used to construct vertex buffers.
|
|
8
|
+
* Describes arrays with fixed-size length, storing elements of the same type.
|
|
9
|
+
*
|
|
10
|
+
* Elements in the schema are not aligned in respect to their `byteAlignment`,
|
|
11
|
+
* unless they are explicitly decorated with the custom align attribute
|
|
12
|
+
* via `d.align` function.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const disarray = d.disarrayOf(d.vec3f, 3); // packed array of vec3f
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const disarray = d.disarrayOf(d.align(16, d.vec3f), 3);
|
|
19
|
+
*
|
|
20
|
+
* If `elementCount` is not specified, a partially applied function is returned.
|
|
21
|
+
* @example
|
|
22
|
+
* const disarray = d.disarrayOf(d.vec3f);
|
|
23
|
+
* // ^? (n: number) => Disarray<d.Vec3f>
|
|
24
|
+
*
|
|
25
|
+
* @param elementType The type of elements in the array.
|
|
26
|
+
* @param elementCount The number of elements in the array.
|
|
27
|
+
*/
|
|
28
|
+
const disarrayOf = comptime(((elementType, elementCount) => {
|
|
29
|
+
if (elementCount === void 0) return (count) => cpu_disarrayOf(elementType, count);
|
|
30
|
+
return cpu_disarrayOf(elementType, elementCount);
|
|
31
|
+
})).$name("disarrayOf");
|
|
32
|
+
function cpu_disarrayOf(elementType, elementCount) {
|
|
33
|
+
const disarraySchema = (elements) => {
|
|
34
|
+
if (elements && elements.length !== elementCount) throw new Error(`Disarray schema of ${elementCount} elements of type ${elementType.type} called with ${elements.length} argument(s).`);
|
|
35
|
+
return Array.from({ length: elementCount }, (_, i) => schemaCallWrapper(elementType, elements?.[i]));
|
|
36
|
+
};
|
|
37
|
+
Object.setPrototypeOf(disarraySchema, DisarrayImpl);
|
|
38
|
+
disarraySchema.elementType = elementType;
|
|
39
|
+
if (!Number.isInteger(elementCount) || elementCount < 0) throw new Error(`Cannot create disarray schema with invalid element count: ${elementCount}.`);
|
|
40
|
+
disarraySchema.elementCount = elementCount;
|
|
41
|
+
return disarraySchema;
|
|
42
|
+
}
|
|
43
|
+
const DisarrayImpl = {
|
|
44
|
+
[$internal]: true,
|
|
45
|
+
type: "disarray",
|
|
46
|
+
toString() {
|
|
47
|
+
return `disarrayOf(${this.elementType}, ${this.elementCount})`;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { disarrayOf };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./wgslTypes.js";
|
|
2
|
+
import { AnyData } from "./dataTypes.js";
|
|
3
|
+
|
|
4
|
+
//#region src/data/getLongestContiguousPrefix.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Returns the size (in bytes) of the longest contiguous memory prefix of data represented by the `schema`.
|
|
7
|
+
*/
|
|
8
|
+
declare function PUBLIC_getLongestContiguousPrefix(schema: AnyData): number;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { PUBLIC_getLongestContiguousPrefix };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getLayoutInfo } from "./schemaMemoryLayout.js";
|
|
2
|
+
|
|
3
|
+
//#region src/data/getLongestContiguousPrefix.ts
|
|
4
|
+
function getLongestContiguousPrefix(schema) {
|
|
5
|
+
return getLayoutInfo(schema, "longestContiguousPrefix");
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns the size (in bytes) of the longest contiguous memory prefix of data represented by the `schema`.
|
|
9
|
+
*/
|
|
10
|
+
function PUBLIC_getLongestContiguousPrefix(schema) {
|
|
11
|
+
return getLongestContiguousPrefix(schema);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { PUBLIC_getLongestContiguousPrefix, getLongestContiguousPrefix };
|
package/data/index.d.ts
CHANGED
|
@@ -1,9 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WgslComparisonSampler, WgslSampler, comparisonSampler, sampler } from "./sampler.js";
|
|
2
|
+
import { AnyBuiltin, BuiltinClipDistances, BuiltinFragDepth, BuiltinFrontFacing, BuiltinGlobalInvocationId, BuiltinInstanceIndex, BuiltinLocalInvocationId, BuiltinLocalInvocationIndex, BuiltinNumWorkgroups, BuiltinPosition, BuiltinSampleIndex, BuiltinSampleMask, BuiltinVertexIndex, BuiltinWorkgroupId, builtin } from "../builtin.js";
|
|
3
|
+
import { AnyAttribute, HasCustomLocation, IsBuiltin, align, interpolate, invariant, isBuiltin, location, size } from "./attributes.js";
|
|
4
|
+
import { memoryLayoutOf } from "./offsetUtils.js";
|
|
5
|
+
import { FormatToAcceptedData, FormatToWGSLType, PackedData, TgpuVertexFormatData, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, isPackedData, packedFormats, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra } from "./vertexFormatData.js";
|
|
6
|
+
import { _ref } from "./ref.js";
|
|
7
|
+
import { Align, AnyVecInstance, AnyWgslData, AnyWgslStruct, Atomic, BaseData, Bool, Builtin, Decorated, F16, F32, I32, Interpolate, Location, Mat2x2f, Mat3x3f, Mat4x4f, Ptr, Size, StorableData, U16, U32, Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u, Void, WgslArray, WgslStruct, atomicI32, atomicU32, isAlignAttrib, isAtomic, isBuiltinAttrib, isDecorated, isInterpolateAttrib, isLocationAttrib, isPtr, isSizeAttrib, isWgslArray, isWgslData, isWgslStruct, m2x2f, m3x3f, m4x4f, matBase, v2b, v2f, v2i, v2u, v3b, v3f, v3i, v3u, v4b, v4f, v4i, v4u, vecBase } from "./wgslTypes.js";
|
|
8
|
+
import { WgslExternalTexture, WgslStorageTexture, WgslStorageTexture1d, WgslStorageTexture2d, WgslStorageTexture2dArray, WgslStorageTexture3d, WgslStorageTextureProps, WgslTexture, WgslTexture1d, WgslTexture2d, WgslTexture2dArray, WgslTexture3d, WgslTextureCube, WgslTextureCubeArray, WgslTextureDepth2d, WgslTextureDepth2dArray, WgslTextureDepthCube, WgslTextureDepthCubeArray, WgslTextureDepthMultisampled2d, WgslTextureMultisampled2d, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d } from "./texture.js";
|
|
9
|
+
import { Infer, InferGPU, InferPartial } from "../shared/repr.js";
|
|
10
|
+
import { AnyData, AnyLooseData, Disarray, LooseDecorated, Unstruct, isData, isDisarray, isLooseData, isLooseDecorated, isUnstruct } from "./dataTypes.js";
|
|
11
|
+
import { bool, f16, f32, i32, u16, u32 } from "./numeric.js";
|
|
12
|
+
import { struct } from "./struct.js";
|
|
13
|
+
import { arrayOf } from "./array.js";
|
|
14
|
+
import { ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup } from "./ptr.js";
|
|
15
|
+
import { vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u } from "./vector.js";
|
|
16
|
+
import { disarrayOf } from "./disarray.js";
|
|
17
|
+
import { unstruct } from "./unstruct.js";
|
|
18
|
+
import { mat2x2f, mat3x3f, mat4x4f, matToArray } from "./matrix.js";
|
|
19
|
+
import { atomic } from "./atomic.js";
|
|
20
|
+
import { PUBLIC_sizeOf } from "./sizeOf.js";
|
|
21
|
+
import { PUBLIC_isContiguous } from "./isContiguous.js";
|
|
22
|
+
import { PUBLIC_getLongestContiguousPrefix } from "./getLongestContiguousPrefix.js";
|
|
23
|
+
import { PUBLIC_alignmentOf } from "./alignmentOf.js";
|
|
24
|
+
import { deepEqual } from "./deepEqual.js";
|
|
2
25
|
|
|
3
26
|
//#region src/data/index.d.ts
|
|
4
27
|
declare namespace index_d_exports {
|
|
5
|
-
export { Align, AnyAttribute, AnyBuiltin, AnyData, AnyLooseData, AnyVecInstance, AnyWgslData, AnyWgslStruct, Atomic, BaseData, BaseData as BaseWgslData, Bool, Builtin, BuiltinClipDistances, BuiltinFragDepth, BuiltinFrontFacing, BuiltinGlobalInvocationId, BuiltinInstanceIndex, BuiltinLocalInvocationId, BuiltinLocalInvocationIndex, BuiltinNumWorkgroups, BuiltinPosition, BuiltinSampleIndex, BuiltinSampleMask, BuiltinVertexIndex, BuiltinWorkgroupId, Decorated, Disarray, F16, F32, FormatToAcceptedData, FormatToWGSLType, HasCustomLocation, I32, Infer, InferGPU, InferPartial, Interpolate, IsBuiltin, Location, LooseDecorated, Mat2x2f, Mat3x3f, Mat4x4f, PackedData, Ptr, Size, StorableData, TgpuVertexFormatData, U16, U32, Unstruct, Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u, Void, WgslArray, WgslComparisonSampler, WgslExternalTexture, WgslSampler, WgslStorageTexture, WgslStorageTexture1d, WgslStorageTexture2d, WgslStorageTexture2dArray, WgslStorageTexture3d, WgslStorageTextureProps, WgslStruct, WgslTexture, WgslTexture1d, WgslTexture2d, WgslTexture2dArray, WgslTexture3d, WgslTextureCube, WgslTextureCubeArray, WgslTextureDepth2d, WgslTextureDepth2dArray, WgslTextureDepthCube, WgslTextureDepthCubeArray, WgslTextureDepthMultisampled2d, WgslTextureMultisampled2d, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, bool, builtin, comparisonSampler, deepEqual, disarrayOf, f16, f32, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, PUBLIC_getLongestContiguousPrefix as getLongestContiguousPrefix, i32, interpolate, invariant, isAlignAttrib, isAtomic, isBuiltin, isBuiltinAttrib, PUBLIC_isContiguous as isContiguous, isData, isDecorated, isDisarray, isInterpolateAttrib, isLocationAttrib, isLooseData, isLooseDecorated, isPackedData, isPtr, isSizeAttrib, isUnstruct, isWgslArray, isWgslData, isWgslStruct, location, m2x2f, m3x3f, m4x4f, mat2x2f, mat3x3f, mat4x4f, matBase, matToArray, memoryLayoutOf, packedFormats, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup, _ref as ref, sampler, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, size, PUBLIC_sizeOf as sizeOf, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, struct, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d, u16, u32, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra, unstruct, v2b, v2f, v2i, v2u, v3b, v3f, v3i, v3u, v4b, v4f, v4i, v4u, vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, vecBase };
|
|
28
|
+
export { Align, AnyAttribute, AnyBuiltin, AnyData, AnyLooseData, AnyVecInstance, AnyWgslData, AnyWgslStruct, Atomic, BaseData, BaseData as BaseWgslData, Bool, Builtin, BuiltinClipDistances, BuiltinFragDepth, BuiltinFrontFacing, BuiltinGlobalInvocationId, BuiltinInstanceIndex, BuiltinLocalInvocationId, BuiltinLocalInvocationIndex, BuiltinNumWorkgroups, BuiltinPosition, BuiltinSampleIndex, BuiltinSampleMask, BuiltinVertexIndex, BuiltinWorkgroupId, Decorated, Disarray, F16, F32, FormatToAcceptedData, FormatToWGSLType, HasCustomLocation, I32, Infer, InferGPU, InferPartial, Interpolate, IsBuiltin, Location, LooseDecorated, Mat2x2f, Mat3x3f, Mat4x4f, PackedData, Ptr, Size, StorableData, TgpuVertexFormatData, U16, U32, Unstruct, Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u, Void, WgslArray, WgslComparisonSampler, WgslExternalTexture, WgslSampler, WgslStorageTexture, WgslStorageTexture1d, WgslStorageTexture2d, WgslStorageTexture2dArray, WgslStorageTexture3d, WgslStorageTextureProps, WgslStruct, WgslTexture, WgslTexture1d, WgslTexture2d, WgslTexture2dArray, WgslTexture3d, WgslTextureCube, WgslTextureCubeArray, WgslTextureDepth2d, WgslTextureDepth2dArray, WgslTextureDepthCube, WgslTextureDepthCubeArray, WgslTextureDepthMultisampled2d, WgslTextureMultisampled2d, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, atomicI32, atomicU32, bool, builtin, comparisonSampler, deepEqual, disarrayOf, f16, f32, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, PUBLIC_getLongestContiguousPrefix as getLongestContiguousPrefix, i32, interpolate, invariant, isAlignAttrib, isAtomic, isBuiltin, isBuiltinAttrib, PUBLIC_isContiguous as isContiguous, isData, isDecorated, isDisarray, isInterpolateAttrib, isLocationAttrib, isLooseData, isLooseDecorated, isPackedData, isPtr, isSizeAttrib, isUnstruct, isWgslArray, isWgslData, isWgslStruct, location, m2x2f, m3x3f, m4x4f, mat2x2f, mat3x3f, mat4x4f, matBase, matToArray, memoryLayoutOf, packedFormats, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup, _ref as ref, sampler, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, size, PUBLIC_sizeOf as sizeOf, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, struct, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d, u16, u32, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra, unstruct, v2b, v2f, v2i, v2u, v3b, v3f, v3i, v3u, v4b, v4f, v4i, v4u, vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, vecBase };
|
|
6
29
|
}
|
|
7
30
|
//#endregion
|
|
8
|
-
export { type Align, type AnyAttribute, type AnyBuiltin, type AnyData, type AnyLooseData, type AnyVecInstance, type AnyWgslData, type AnyWgslStruct, type Atomic, type BaseData, type BaseData as BaseWgslData, type Bool, type Builtin, type BuiltinClipDistances, type BuiltinFragDepth, type BuiltinFrontFacing, type BuiltinGlobalInvocationId, type BuiltinInstanceIndex, type BuiltinLocalInvocationId, type BuiltinLocalInvocationIndex, type BuiltinNumWorkgroups, type BuiltinPosition, type BuiltinSampleIndex, type BuiltinSampleMask, type BuiltinVertexIndex, type BuiltinWorkgroupId, type Decorated, type Disarray, type F16, type F32, FormatToAcceptedData, FormatToWGSLType, type HasCustomLocation, type I32, type Infer, type InferGPU, type InferPartial, type Interpolate, type IsBuiltin, type Location, type LooseDecorated, type Mat2x2f, type Mat3x3f, type Mat4x4f, PackedData, type Ptr, type Size, type StorableData, TgpuVertexFormatData, type U16, type U32, type Unstruct, type Vec2b, type Vec2f, type Vec2h, type Vec2i, type Vec2u, type Vec3b, type Vec3f, type Vec3h, type Vec3i, type Vec3u, type Vec4b, type Vec4f, type Vec4h, type Vec4i, type Vec4u, Void, type WgslArray, type WgslComparisonSampler, type WgslExternalTexture, type WgslSampler, type WgslStorageTexture, type WgslStorageTexture1d, type WgslStorageTexture2d, type WgslStorageTexture2dArray, type WgslStorageTexture3d, type WgslStorageTextureProps, type WgslStruct, type WgslTexture, type WgslTexture1d, type WgslTexture2d, type WgslTexture2dArray, type WgslTexture3d, type WgslTextureCube, type WgslTextureCubeArray, type WgslTextureDepth2d, type WgslTextureDepth2dArray, type WgslTextureDepthCube, type WgslTextureDepthCubeArray, type WgslTextureDepthMultisampled2d, type WgslTextureMultisampled2d, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, bool, builtin, comparisonSampler, deepEqual, disarrayOf, f16, f32, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, PUBLIC_getLongestContiguousPrefix as getLongestContiguousPrefix, i32, interpolate, invariant, isAlignAttrib, isAtomic, isBuiltin, isBuiltinAttrib, PUBLIC_isContiguous as isContiguous, isData, isDecorated, isDisarray, isInterpolateAttrib, isLocationAttrib, isLooseData, isLooseDecorated, isPackedData, isPtr, isSizeAttrib, isUnstruct, isWgslArray, isWgslData, isWgslStruct, location, type m2x2f, type m3x3f, type m4x4f, mat2x2f, mat3x3f, mat4x4f, type matBase, matToArray, memoryLayoutOf, packedFormats, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup, _ref as ref, sampler, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, size, PUBLIC_sizeOf as sizeOf, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, struct,
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
31
|
+
export { type Align, type AnyAttribute, type AnyBuiltin, type AnyData, type AnyLooseData, type AnyVecInstance, type AnyWgslData, type AnyWgslStruct, type Atomic, type BaseData, type BaseData as BaseWgslData, type Bool, type Builtin, type BuiltinClipDistances, type BuiltinFragDepth, type BuiltinFrontFacing, type BuiltinGlobalInvocationId, type BuiltinInstanceIndex, type BuiltinLocalInvocationId, type BuiltinLocalInvocationIndex, type BuiltinNumWorkgroups, type BuiltinPosition, type BuiltinSampleIndex, type BuiltinSampleMask, type BuiltinVertexIndex, type BuiltinWorkgroupId, type Decorated, type Disarray, type F16, type F32, FormatToAcceptedData, FormatToWGSLType, type HasCustomLocation, type I32, type Infer, type InferGPU, type InferPartial, type Interpolate, type IsBuiltin, type Location, type LooseDecorated, type Mat2x2f, type Mat3x3f, type Mat4x4f, PackedData, type Ptr, type Size, type StorableData, TgpuVertexFormatData, type U16, type U32, type Unstruct, type Vec2b, type Vec2f, type Vec2h, type Vec2i, type Vec2u, type Vec3b, type Vec3f, type Vec3h, type Vec3i, type Vec3u, type Vec4b, type Vec4f, type Vec4h, type Vec4i, type Vec4u, Void, type WgslArray, type WgslComparisonSampler, type WgslExternalTexture, type WgslSampler, type WgslStorageTexture, type WgslStorageTexture1d, type WgslStorageTexture2d, type WgslStorageTexture2dArray, type WgslStorageTexture3d, type WgslStorageTextureProps, type WgslStruct, type WgslTexture, type WgslTexture1d, type WgslTexture2d, type WgslTexture2dArray, type WgslTexture3d, type WgslTextureCube, type WgslTextureCubeArray, type WgslTextureDepth2d, type WgslTextureDepth2dArray, type WgslTextureDepthCube, type WgslTextureDepthCubeArray, type WgslTextureDepthMultisampled2d, type WgslTextureMultisampled2d, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, type atomicI32, type atomicU32, bool, builtin, comparisonSampler, deepEqual, disarrayOf, f16, f32, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, PUBLIC_getLongestContiguousPrefix as getLongestContiguousPrefix, i32, index_d_exports, interpolate, invariant, isAlignAttrib, isAtomic, isBuiltin, isBuiltinAttrib, PUBLIC_isContiguous as isContiguous, isData, isDecorated, isDisarray, isInterpolateAttrib, isLocationAttrib, isLooseData, isLooseDecorated, isPackedData, isPtr, isSizeAttrib, isUnstruct, isWgslArray, isWgslData, isWgslStruct, location, type m2x2f, type m3x3f, type m4x4f, mat2x2f, mat3x3f, mat4x4f, type matBase, matToArray, memoryLayoutOf, packedFormats, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup, _ref as ref, sampler, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, size, PUBLIC_sizeOf as sizeOf, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, struct, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d, u16, u32, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra, unstruct, type v2b, type v2f, type v2i, type v2u, type v3b, type v3f, type v3i, type v3u, type v4b, type v4f, type v4i, type v4u, vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, type vecBase };
|
package/data/index.js
CHANGED
|
@@ -1,8 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { Void, isAlignAttrib, isAtomic, isBuiltinAttrib, isDecorated, isInterpolateAttrib, isLocationAttrib, isPtr, isSizeAttrib, isWgslArray, isWgslData, isWgslStruct } from "./wgslTypes.js";
|
|
3
|
+
import { isData, isDisarray, isLooseData, isLooseDecorated, isUnstruct } from "./dataTypes.js";
|
|
4
|
+
import { ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup } from "./ptr.js";
|
|
5
|
+
import { _ref } from "./ref.js";
|
|
6
|
+
import { bool, f16, f32, i32, u16, u32 } from "./numeric.js";
|
|
7
|
+
import { VecBase } from "./vectorImpl.js";
|
|
8
|
+
import { vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u } from "./vector.js";
|
|
9
|
+
import { float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, isPackedData, packedFormats, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra } from "./vertexFormatData.js";
|
|
10
|
+
import { PUBLIC_alignmentOf } from "./alignmentOf.js";
|
|
11
|
+
import { PUBLIC_sizeOf } from "./sizeOf.js";
|
|
12
|
+
import { align, interpolate, invariant, isBuiltin, location, size } from "./attributes.js";
|
|
13
|
+
import { struct } from "./struct.js";
|
|
14
|
+
import { MatBase, mat2x2f, mat3x3f, mat4x4f, matToArray } from "./matrix.js";
|
|
15
|
+
import { infixOperators } from "../tgsl/accessProp.js";
|
|
16
|
+
import { comparisonSampler, sampler } from "./sampler.js";
|
|
17
|
+
import { texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d } from "./texture.js";
|
|
18
|
+
import { arrayOf } from "./array.js";
|
|
19
|
+
import { atomic } from "./atomic.js";
|
|
20
|
+
import { builtin } from "../builtin.js";
|
|
21
|
+
import { PUBLIC_isContiguous } from "./isContiguous.js";
|
|
22
|
+
import { PUBLIC_getLongestContiguousPrefix } from "./getLongestContiguousPrefix.js";
|
|
23
|
+
import { memoryLayoutOf } from "./offsetUtils.js";
|
|
24
|
+
import { disarrayOf } from "./disarray.js";
|
|
25
|
+
import { unstruct } from "./unstruct.js";
|
|
26
|
+
import { deepEqual } from "./deepEqual.js";
|
|
6
27
|
import { Operator } from "tsover-runtime";
|
|
7
28
|
|
|
8
29
|
//#region src/data/index.ts
|
|
@@ -161,5 +182,4 @@ assignInfixOperator(MatBase, "sub", Operator.minus);
|
|
|
161
182
|
assignInfixOperator(MatBase, "mul", Operator.star);
|
|
162
183
|
|
|
163
184
|
//#endregion
|
|
164
|
-
export { Void, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, bool, builtin, comparisonSampler, deepEqual, disarrayOf, f16, f32, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, PUBLIC_getLongestContiguousPrefix as getLongestContiguousPrefix, i32, interpolate, invariant, isAlignAttrib, isAtomic, isBuiltin, isBuiltinAttrib, PUBLIC_isContiguous as isContiguous, isData, isDecorated, isDisarray, isInterpolateAttrib, isLocationAttrib, isLooseData, isLooseDecorated, isPackedData, isPtr, isSizeAttrib, isUnstruct, isWgslArray, isWgslData, isWgslStruct, location, mat2x2f, mat3x3f, mat4x4f, matToArray, memoryLayoutOf, packedFormats, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup, _ref as ref, sampler, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, size, PUBLIC_sizeOf as sizeOf, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, struct,
|
|
165
|
-
//# sourceMappingURL=index.js.map
|
|
185
|
+
export { Void, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, bool, builtin, comparisonSampler, data_exports, deepEqual, disarrayOf, f16, f32, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, PUBLIC_getLongestContiguousPrefix as getLongestContiguousPrefix, i32, interpolate, invariant, isAlignAttrib, isAtomic, isBuiltin, isBuiltinAttrib, PUBLIC_isContiguous as isContiguous, isData, isDecorated, isDisarray, isInterpolateAttrib, isLocationAttrib, isLooseData, isLooseDecorated, isPackedData, isPtr, isSizeAttrib, isUnstruct, isWgslArray, isWgslData, isWgslStruct, location, mat2x2f, mat3x3f, mat4x4f, matToArray, memoryLayoutOf, packedFormats, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup, _ref as ref, sampler, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, size, PUBLIC_sizeOf as sizeOf, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, struct, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d, u16, u32, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra, unstruct, vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { $internal } from "../shared/symbols.js";
|
|
2
|
+
import { Bool, F16, F32, I32, Mat2x2f, Mat3x3f, Mat4x4f, U16, U32, Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u, Void } from "./wgslTypes.js";
|
|
3
|
+
|
|
4
|
+
//#region src/data/instanceToSchema.d.ts
|
|
5
|
+
type KindToSchemaMap = {
|
|
6
|
+
vec2f: Vec2f;
|
|
7
|
+
vec3f: Vec3f;
|
|
8
|
+
vec4f: Vec4f;
|
|
9
|
+
vec2h: Vec2h;
|
|
10
|
+
vec3h: Vec3h;
|
|
11
|
+
vec4h: Vec4h;
|
|
12
|
+
vec2i: Vec2i;
|
|
13
|
+
vec3i: Vec3i;
|
|
14
|
+
vec4i: Vec4i;
|
|
15
|
+
vec2u: Vec2u;
|
|
16
|
+
vec3u: Vec3u;
|
|
17
|
+
vec4u: Vec4u;
|
|
18
|
+
'vec2<bool>': Vec2b;
|
|
19
|
+
'vec3<bool>': Vec3b;
|
|
20
|
+
'vec4<bool>': Vec4b;
|
|
21
|
+
mat2x2f: Mat2x2f;
|
|
22
|
+
mat3x3f: Mat3x3f;
|
|
23
|
+
mat4x4f: Mat4x4f;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Inverse operation to d.Infer<T>
|
|
27
|
+
*/
|
|
28
|
+
type InstanceToSchema<T> = T extends number ? U32 | U16 | I32 | F32 | F16 : T extends boolean ? Bool : T extends undefined ? Void : T extends {
|
|
29
|
+
readonly [$internal]: unknown;
|
|
30
|
+
readonly kind: infer TKind extends keyof KindToSchemaMap;
|
|
31
|
+
} ? KindToSchemaMap[TKind] : T;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { InstanceToSchema };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./wgslTypes.js";
|
|
2
|
+
import { AnyData } from "./dataTypes.js";
|
|
3
|
+
|
|
4
|
+
//#region src/data/isContiguous.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Returns `true` if data represented by the `schema` doesn't have padding.
|
|
7
|
+
*/
|
|
8
|
+
declare function PUBLIC_isContiguous(schema: AnyData): boolean;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { PUBLIC_isContiguous };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getLayoutInfo } from "./schemaMemoryLayout.js";
|
|
2
|
+
|
|
3
|
+
//#region src/data/isContiguous.ts
|
|
4
|
+
function isContiguous(schema) {
|
|
5
|
+
return getLayoutInfo(schema, "isContiguous");
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns `true` if data represented by the `schema` doesn't have padding.
|
|
9
|
+
*/
|
|
10
|
+
function PUBLIC_isContiguous(schema) {
|
|
11
|
+
return isContiguous(schema);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { PUBLIC_isContiguous, isContiguous };
|
package/data/matrix.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { DualFn } from "../types.js";
|
|
2
|
+
import { Mat2x2f, Mat3x3f, Mat4x4f, m2x2f, m3x3f, m4x4f, v3f } from "./wgslTypes.js";
|
|
3
|
+
import { TgpuComptime } from "../core/function/comptime.js";
|
|
4
|
+
import "../indexNamedExports.js";
|
|
5
|
+
|
|
6
|
+
//#region src/data/matrix.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Returns a 2-by-2 identity matrix.
|
|
9
|
+
* @returns {m2x2f} The result matrix.
|
|
10
|
+
*/
|
|
11
|
+
declare const identity2: TgpuComptime<() => m2x2f>;
|
|
12
|
+
/**
|
|
13
|
+
* Returns a 3-by-3 identity matrix.
|
|
14
|
+
* @returns {m3x3f} The result matrix.
|
|
15
|
+
*/
|
|
16
|
+
declare const identity3: TgpuComptime<() => m3x3f>;
|
|
17
|
+
/**
|
|
18
|
+
* Returns a 4-by-4 identity matrix.
|
|
19
|
+
* @returns {m4x4f} The result matrix.
|
|
20
|
+
*/
|
|
21
|
+
declare const identity4: TgpuComptime<() => m4x4f>;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a 4-by-4 matrix which translates by the given vector v.
|
|
24
|
+
* @param {v3f} vector - The vector by which to translate.
|
|
25
|
+
* @returns {m4x4f} The translation matrix.
|
|
26
|
+
*/
|
|
27
|
+
declare const translation4: DualFn<(vector: v3f) => m4x4f>;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a 4-by-4 matrix which scales in each dimension by an amount given by the corresponding entry in the given vector.
|
|
30
|
+
* @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.
|
|
31
|
+
* @returns {m4x4f} The scaling matrix.
|
|
32
|
+
*/
|
|
33
|
+
declare const scaling4: DualFn<(vector: v3f) => m4x4f>;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a 4-by-4 matrix which rotates around the x-axis by the given angle.
|
|
36
|
+
* @param {number} angle - The angle by which to rotate (in radians).
|
|
37
|
+
* @returns {m4x4f} The rotation matrix.
|
|
38
|
+
*/
|
|
39
|
+
declare const rotationX4: DualFn<(a: number) => m4x4f>;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a 4-by-4 matrix which rotates around the y-axis by the given angle.
|
|
42
|
+
* @param {number} angle - The angle by which to rotate (in radians).
|
|
43
|
+
* @returns {m4x4f} The rotation matrix.
|
|
44
|
+
*/
|
|
45
|
+
declare const rotationY4: DualFn<(a: number) => m4x4f>;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a 4-by-4 matrix which rotates around the z-axis by the given angle.
|
|
48
|
+
* @param {number} angle - The angle by which to rotate (in radians).
|
|
49
|
+
* @returns {m4x4f} The rotation matrix.
|
|
50
|
+
*/
|
|
51
|
+
declare const rotationZ4: DualFn<(a: number) => m4x4f>;
|
|
52
|
+
/**
|
|
53
|
+
* Schema representing mat2x2f - a matrix with 2 rows and 2 columns, with elements of type f32.
|
|
54
|
+
* Also a constructor function for this matrix type.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* const zero2x2 = mat2x2f(); // filled with zeros
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* const mat = mat2x2f(0, 1, 2, 3);
|
|
61
|
+
* mat.columns[0] // vec2f(0, 1)
|
|
62
|
+
* mat.columns[1] // vec2f(2, 3)
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* const mat = mat2x2f(
|
|
66
|
+
* vec2f(0, 1), // column 0
|
|
67
|
+
* vec2f(1, 2), // column 1
|
|
68
|
+
* );
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* const buffer = root.createBuffer(d.mat2x2f, d.mat2x2f(0, 1, 2, 3)); // buffer holding a d.mat2x2f value, with an initial value of ((0, 1), (2, 3))
|
|
72
|
+
*/
|
|
73
|
+
declare const mat2x2f: Mat2x2f;
|
|
74
|
+
/**
|
|
75
|
+
* Schema representing mat3x3f - a matrix with 3 rows and 3 columns, with elements of type f32.
|
|
76
|
+
* Also a constructor function for this matrix type.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* const zero3x3 = mat3x3f(); // filled with zeros
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* const mat = mat3x3f(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
|
83
|
+
* mat.columns[0] // vec3f(0, 1, 2)
|
|
84
|
+
* mat.columns[1] // vec3f(3, 4, 5)
|
|
85
|
+
* mat.columns[2] // vec3f(6, 7, 8)
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* const mat = mat3x3f(
|
|
89
|
+
* vec3f(0, 1, 2), // column 0
|
|
90
|
+
* vec3f(2, 3, 4), // column 1
|
|
91
|
+
* vec3f(5, 6, 7), // column 2
|
|
92
|
+
* );
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* const buffer = root.createBuffer(d.mat3x3f, d.mat3x3f()); // buffer holding a d.mat3x3f value, with an initial value of mat3x3f filled with zeros
|
|
96
|
+
*/
|
|
97
|
+
declare const mat3x3f: Mat3x3f;
|
|
98
|
+
/**
|
|
99
|
+
* Schema representing mat4x4f - a matrix with 4 rows and 4 columns, with elements of type f32.
|
|
100
|
+
* Also a constructor function for this matrix type.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* const zero4x4 = mat4x4f(); // filled with zeros
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* const mat = mat4x4f(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
|
|
107
|
+
* mat.columns[0] // vec4f(0, 1, 2, 3)
|
|
108
|
+
* mat.columns[1] // vec4f(4, 5, 6, 7)
|
|
109
|
+
* mat.columns[2] // vec4f(8, 9, 10, 11)
|
|
110
|
+
* mat.columns[3] // vec4f(12, 13, 14, 15)
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* const mat = mat4x4f(
|
|
114
|
+
* vec4f(0, 1, 2, 3), // column 0
|
|
115
|
+
* vec4f(4, 5, 6, 7), // column 1
|
|
116
|
+
* vec4f(8, 9, 10, 11), // column 2
|
|
117
|
+
* vec4f(12, 13, 14, 15), // column 3
|
|
118
|
+
* );
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* const buffer = root.createBuffer(d.mat4x4f, d.mat4x4f()); // buffer holding a d.mat4x4f value, with an initial value of mat4x4f filled with zeros
|
|
122
|
+
*/
|
|
123
|
+
declare const mat4x4f: Mat4x4f;
|
|
124
|
+
declare function matToArray(mat: m2x2f | m3x3f | m4x4f): number[];
|
|
125
|
+
//#endregion
|
|
126
|
+
export { identity2, identity3, identity4, mat2x2f, mat3x3f, mat4x4f, matToArray, rotationX4, rotationY4, rotationZ4, scaling4, translation4 };
|