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,38 @@
|
|
|
1
|
+
import { INTERNAL_GlobalExt } from "./shared/meta.js";
|
|
2
|
+
import { Storage, StorageFlag, isUsableAsStorage } from "./extension.js";
|
|
3
|
+
import { TgpuQuerySet } from "./core/querySet/querySet.js";
|
|
4
|
+
import { TgpuBufferMutable, TgpuBufferReadonly, TgpuBufferUniform, isUsableAsUniform } from "./core/buffer/bufferUsage.js";
|
|
5
|
+
import { TgpuMutable, TgpuReadonly, TgpuUniform, isBufferShorthand } from "./core/buffer/bufferShorthand.js";
|
|
6
|
+
import { TgpuComputeFn, TgpuComputeFnShell, isTgpuComputeFn } from "./core/function/tgpuComputeFn.js";
|
|
7
|
+
import { TgpuVar, VariableScope, isVariable } from "./core/variable/tgpuVariable.js";
|
|
8
|
+
import { Eventual, TgpuAccessor, TgpuLazy, TgpuMutableAccessor, TgpuSlot, isAccessor, isLazy, isMutableAccessor, isSlot } from "./core/slot/slotTypes.js";
|
|
9
|
+
import { TgpuComputePipeline } from "./core/pipeline/computePipeline.js";
|
|
10
|
+
import { AutoFragmentIn, AutoFragmentOut, AutoVertexIn, AutoVertexOut } from "./core/function/autoIO.js";
|
|
11
|
+
import { TgpuFragmentFn, TgpuFragmentFnShell, isTgpuFragmentFn } from "./core/function/tgpuFragmentFn.js";
|
|
12
|
+
import { TgpuVertexFn, TgpuVertexFnShell, isTgpuVertexFn } from "./core/function/tgpuVertexFn.js";
|
|
13
|
+
import { TextureProps } from "./core/texture/textureProps.js";
|
|
14
|
+
import { RenderFlag, SampledFlag, isUsableAsRender, isUsableAsSampled } from "./core/texture/usageExtension.js";
|
|
15
|
+
import { TgpuVertexLayout } from "./core/vertexLayout/vertexLayout.js";
|
|
16
|
+
import { ColorAttachment, TgpuPrimitiveState, TgpuRenderPipeline } from "./core/pipeline/renderPipeline.js";
|
|
17
|
+
import { TgpuComparisonSampler, TgpuFixedComparisonSampler, TgpuFixedSampler, TgpuSampler, isComparisonSampler, isSampler } from "./core/sampler/sampler.js";
|
|
18
|
+
import { BindLayoutEntry, ExtractBindGroupInputFromLayout, LayoutEntryToInput, TgpuBindGroup, TgpuBindGroupLayout, TgpuLayoutComparisonSampler, TgpuLayoutEntry, TgpuLayoutExternalTexture, TgpuLayoutSampler, TgpuLayoutStorage, TgpuLayoutTexture, TgpuLayoutUniform } from "./tgpuBindGroupLayout.js";
|
|
19
|
+
import { Configurable, TgpuGuardedComputePipeline, TgpuRoot, ValidateBufferSchema, ValidateStorageSchema, ValidateUniformSchema, WithBinding, WithCompute, WithFragment, WithVertex, Withable } from "./core/root/rootTypes.js";
|
|
20
|
+
import { IndexFlag, TgpuBuffer, Uniform, UniformFlag, ValidUsagesFor, Vertex, VertexFlag, isBuffer, isUsableAsVertex } from "./core/buffer/buffer.js";
|
|
21
|
+
import { TgpuDeclare } from "./core/declare/tgpuDeclare.js";
|
|
22
|
+
import { TgpuFn, TgpuFnShell, TgpuGenericFn, isTgpuFn } from "./core/function/tgpuFn.js";
|
|
23
|
+
import { TgpuTexture, TgpuTextureView, isTexture } from "./core/texture/texture.js";
|
|
24
|
+
import { TgpuConst } from "./core/constant/tgpuConstant.js";
|
|
25
|
+
import { TgpuComptime } from "./core/function/comptime.js";
|
|
26
|
+
import { Namespace } from "./core/resolve/namespace.js";
|
|
27
|
+
import { InitFromDeviceOptions, InitOptions } from "./core/root/init.js";
|
|
28
|
+
import { RawCodeSnippetOrigin, TgpuRawCodeSnippet } from "./core/rawCodeSnippet/tgpuRawCodeSnippet.js";
|
|
29
|
+
import { index_d_exports } from "./data/index.js";
|
|
30
|
+
import { index_d_exports as index_d_exports$1 } from "./std/index.js";
|
|
31
|
+
import { index_d_exports as index_d_exports$2 } from "./common/index.js";
|
|
32
|
+
import { MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError } from "./errors.js";
|
|
33
|
+
|
|
34
|
+
//#region src/indexNamedExports.d.ts
|
|
35
|
+
/** @deprecated Use TgpuRenderPipeline.Descriptor */
|
|
36
|
+
type TgpuRenderPipelineDescriptor = TgpuRenderPipeline.Descriptor;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { TgpuRenderPipelineDescriptor };
|
package/mathUtils.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/mathUtils.ts
|
|
2
|
+
/**
|
|
3
|
+
* @param value
|
|
4
|
+
* @param modulo has to be power of 2
|
|
5
|
+
*/
|
|
6
|
+
const roundUp = (value, modulo) => {
|
|
7
|
+
const bitMask = modulo - 1;
|
|
8
|
+
const invBitMask = ~bitMask;
|
|
9
|
+
return (value & bitMask) === 0 ? value : (value & invBitMask) + modulo;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { roundUp };
|
package/memo.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/memo.ts
|
|
2
|
+
/**
|
|
3
|
+
* Caches results of the function passed in as
|
|
4
|
+
* the argument to the constructor.
|
|
5
|
+
*
|
|
6
|
+
* If the key can be garbage collected, it will be.
|
|
7
|
+
*/
|
|
8
|
+
var WeakMemo = class {
|
|
9
|
+
_map = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
constructor(_make) {
|
|
11
|
+
this._make = _make;
|
|
12
|
+
}
|
|
13
|
+
getOrMake(key, ...args) {
|
|
14
|
+
if (this._map.has(key)) return this._map.get(key);
|
|
15
|
+
const value = this._make(key, ...args);
|
|
16
|
+
this._map.set(key, value);
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { WeakMemo };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/nameRegistry.d.ts
|
|
2
|
+
interface NameRegistry {
|
|
3
|
+
/**
|
|
4
|
+
* Creates a valid WGSL identifier, each guaranteed to be unique
|
|
5
|
+
* in the lifetime of a single resolution process
|
|
6
|
+
* (excluding non-global identifiers from popped scopes).
|
|
7
|
+
* Should append "_" to primer, followed by some id.
|
|
8
|
+
* @param primer Used in the generation process, makes the identifier more recognizable.
|
|
9
|
+
* @param global Whether the name should be registered in the global scope (true), or in the current function scope (false)
|
|
10
|
+
*/
|
|
11
|
+
makeUnique(primer: string | undefined, global: boolean): string;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a valid WGSL identifier.
|
|
14
|
+
* Renames identifiers that are WGSL reserved words.
|
|
15
|
+
* @param primer Used in the generation process.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* makeValid("notAKeyword"); // "notAKeyword"
|
|
19
|
+
* makeValid("struct"); // makeUnique("struct")
|
|
20
|
+
* makeValid("struct_1"); // makeUnique("struct_1") (to avoid potential name collisions)
|
|
21
|
+
* makeValid("_"); // ERROR (too difficult to make valid to care)
|
|
22
|
+
*/
|
|
23
|
+
makeValid(primer: string): string;
|
|
24
|
+
pushFunctionScope(): void;
|
|
25
|
+
popFunctionScope(): void;
|
|
26
|
+
pushBlockScope(): void;
|
|
27
|
+
popBlockScope(): void;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { NameRegistry };
|
package/nameRegistry.js
ADDED
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
import { invariant } from "./errors.js";
|
|
2
|
+
|
|
3
|
+
//#region src/nameRegistry.ts
|
|
4
|
+
const bannedTokens = new Set([
|
|
5
|
+
"alias",
|
|
6
|
+
"break",
|
|
7
|
+
"case",
|
|
8
|
+
"const",
|
|
9
|
+
"const_assert",
|
|
10
|
+
"continue",
|
|
11
|
+
"continuing",
|
|
12
|
+
"default",
|
|
13
|
+
"diagnostic",
|
|
14
|
+
"discard",
|
|
15
|
+
"else",
|
|
16
|
+
"enable",
|
|
17
|
+
"false",
|
|
18
|
+
"fn",
|
|
19
|
+
"for",
|
|
20
|
+
"if",
|
|
21
|
+
"let",
|
|
22
|
+
"loop",
|
|
23
|
+
"override",
|
|
24
|
+
"requires",
|
|
25
|
+
"return",
|
|
26
|
+
"struct",
|
|
27
|
+
"switch",
|
|
28
|
+
"true",
|
|
29
|
+
"var",
|
|
30
|
+
"while",
|
|
31
|
+
"NULL",
|
|
32
|
+
"Self",
|
|
33
|
+
"abstract",
|
|
34
|
+
"active",
|
|
35
|
+
"alignas",
|
|
36
|
+
"alignof",
|
|
37
|
+
"as",
|
|
38
|
+
"asm",
|
|
39
|
+
"asm_fragment",
|
|
40
|
+
"async",
|
|
41
|
+
"attribute",
|
|
42
|
+
"auto",
|
|
43
|
+
"await",
|
|
44
|
+
"become",
|
|
45
|
+
"cast",
|
|
46
|
+
"catch",
|
|
47
|
+
"class",
|
|
48
|
+
"co_await",
|
|
49
|
+
"co_return",
|
|
50
|
+
"co_yield",
|
|
51
|
+
"coherent",
|
|
52
|
+
"column_major",
|
|
53
|
+
"common",
|
|
54
|
+
"compile",
|
|
55
|
+
"compile_fragment",
|
|
56
|
+
"concept",
|
|
57
|
+
"const_cast",
|
|
58
|
+
"consteval",
|
|
59
|
+
"constexpr",
|
|
60
|
+
"constinit",
|
|
61
|
+
"crate",
|
|
62
|
+
"debugger",
|
|
63
|
+
"decltype",
|
|
64
|
+
"delete",
|
|
65
|
+
"demote",
|
|
66
|
+
"demote_to_helper",
|
|
67
|
+
"do",
|
|
68
|
+
"dynamic_cast",
|
|
69
|
+
"enum",
|
|
70
|
+
"explicit",
|
|
71
|
+
"export",
|
|
72
|
+
"extends",
|
|
73
|
+
"extern",
|
|
74
|
+
"external",
|
|
75
|
+
"fallthrough",
|
|
76
|
+
"filter",
|
|
77
|
+
"final",
|
|
78
|
+
"finally",
|
|
79
|
+
"friend",
|
|
80
|
+
"from",
|
|
81
|
+
"fxgroup",
|
|
82
|
+
"get",
|
|
83
|
+
"goto",
|
|
84
|
+
"groupshared",
|
|
85
|
+
"highp",
|
|
86
|
+
"impl",
|
|
87
|
+
"implements",
|
|
88
|
+
"import",
|
|
89
|
+
"inline",
|
|
90
|
+
"instanceof",
|
|
91
|
+
"interface",
|
|
92
|
+
"layout",
|
|
93
|
+
"lowp",
|
|
94
|
+
"macro",
|
|
95
|
+
"macro_rules",
|
|
96
|
+
"match",
|
|
97
|
+
"mediump",
|
|
98
|
+
"meta",
|
|
99
|
+
"mod",
|
|
100
|
+
"module",
|
|
101
|
+
"move",
|
|
102
|
+
"mut",
|
|
103
|
+
"mutable",
|
|
104
|
+
"namespace",
|
|
105
|
+
"new",
|
|
106
|
+
"nil",
|
|
107
|
+
"noexcept",
|
|
108
|
+
"noinline",
|
|
109
|
+
"nointerpolation",
|
|
110
|
+
"non_coherent",
|
|
111
|
+
"noncoherent",
|
|
112
|
+
"noperspective",
|
|
113
|
+
"null",
|
|
114
|
+
"nullptr",
|
|
115
|
+
"of",
|
|
116
|
+
"operator",
|
|
117
|
+
"package",
|
|
118
|
+
"packoffset",
|
|
119
|
+
"partition",
|
|
120
|
+
"pass",
|
|
121
|
+
"patch",
|
|
122
|
+
"pixelfragment",
|
|
123
|
+
"precise",
|
|
124
|
+
"precision",
|
|
125
|
+
"premerge",
|
|
126
|
+
"priv",
|
|
127
|
+
"protected",
|
|
128
|
+
"pub",
|
|
129
|
+
"public",
|
|
130
|
+
"readonly",
|
|
131
|
+
"ref",
|
|
132
|
+
"regardless",
|
|
133
|
+
"register",
|
|
134
|
+
"reinterpret_cast",
|
|
135
|
+
"require",
|
|
136
|
+
"resource",
|
|
137
|
+
"restrict",
|
|
138
|
+
"self",
|
|
139
|
+
"set",
|
|
140
|
+
"shared",
|
|
141
|
+
"sizeof",
|
|
142
|
+
"smooth",
|
|
143
|
+
"snorm",
|
|
144
|
+
"static",
|
|
145
|
+
"static_assert",
|
|
146
|
+
"static_cast",
|
|
147
|
+
"std",
|
|
148
|
+
"subroutine",
|
|
149
|
+
"super",
|
|
150
|
+
"target",
|
|
151
|
+
"template",
|
|
152
|
+
"this",
|
|
153
|
+
"thread_local",
|
|
154
|
+
"throw",
|
|
155
|
+
"trait",
|
|
156
|
+
"try",
|
|
157
|
+
"type",
|
|
158
|
+
"typedef",
|
|
159
|
+
"typeid",
|
|
160
|
+
"typename",
|
|
161
|
+
"typeof",
|
|
162
|
+
"union",
|
|
163
|
+
"unless",
|
|
164
|
+
"unorm",
|
|
165
|
+
"unsafe",
|
|
166
|
+
"unsized",
|
|
167
|
+
"use",
|
|
168
|
+
"using",
|
|
169
|
+
"varying",
|
|
170
|
+
"virtual",
|
|
171
|
+
"volatile",
|
|
172
|
+
"wgsl",
|
|
173
|
+
"where",
|
|
174
|
+
"with",
|
|
175
|
+
"writeonly",
|
|
176
|
+
"yield",
|
|
177
|
+
"sampler",
|
|
178
|
+
"uniform",
|
|
179
|
+
"storage"
|
|
180
|
+
]);
|
|
181
|
+
const builtins = new Set([
|
|
182
|
+
"array",
|
|
183
|
+
"bool",
|
|
184
|
+
"f16",
|
|
185
|
+
"f32",
|
|
186
|
+
"i32",
|
|
187
|
+
"u32",
|
|
188
|
+
"mat2x2",
|
|
189
|
+
"mat2x3",
|
|
190
|
+
"mat2x4",
|
|
191
|
+
"mat3x2",
|
|
192
|
+
"mat3x3",
|
|
193
|
+
"mat3x4",
|
|
194
|
+
"mat4x2",
|
|
195
|
+
"mat4x3",
|
|
196
|
+
"mat4x4",
|
|
197
|
+
"vec2",
|
|
198
|
+
"vec3",
|
|
199
|
+
"vec4",
|
|
200
|
+
"bitcast",
|
|
201
|
+
"all",
|
|
202
|
+
"any",
|
|
203
|
+
"select",
|
|
204
|
+
"arrayLength",
|
|
205
|
+
"abs",
|
|
206
|
+
"acos",
|
|
207
|
+
"acosh",
|
|
208
|
+
"asin",
|
|
209
|
+
"asinh",
|
|
210
|
+
"atan",
|
|
211
|
+
"atanh",
|
|
212
|
+
"atan2",
|
|
213
|
+
"ceil",
|
|
214
|
+
"clamp",
|
|
215
|
+
"cos",
|
|
216
|
+
"cosh",
|
|
217
|
+
"countLeadingZeros",
|
|
218
|
+
"countOneBits",
|
|
219
|
+
"countTrailingZeros",
|
|
220
|
+
"cross",
|
|
221
|
+
"degrees",
|
|
222
|
+
"determinant",
|
|
223
|
+
"distance",
|
|
224
|
+
"dot",
|
|
225
|
+
"dot4U8Packed",
|
|
226
|
+
"dot4I8Packed",
|
|
227
|
+
"exp",
|
|
228
|
+
"exp2",
|
|
229
|
+
"extractBits",
|
|
230
|
+
"faceForward",
|
|
231
|
+
"firstLeadingBit",
|
|
232
|
+
"firstTrailingBit",
|
|
233
|
+
"floor",
|
|
234
|
+
"fma",
|
|
235
|
+
"fract",
|
|
236
|
+
"frexp",
|
|
237
|
+
"insertBits",
|
|
238
|
+
"inverseSqrt",
|
|
239
|
+
"ldexp",
|
|
240
|
+
"length",
|
|
241
|
+
"log",
|
|
242
|
+
"log2",
|
|
243
|
+
"max",
|
|
244
|
+
"min",
|
|
245
|
+
"mix",
|
|
246
|
+
"modf",
|
|
247
|
+
"normalize",
|
|
248
|
+
"pow",
|
|
249
|
+
"quantizeToF16",
|
|
250
|
+
"radians",
|
|
251
|
+
"reflect",
|
|
252
|
+
"refract",
|
|
253
|
+
"reverseBits",
|
|
254
|
+
"round",
|
|
255
|
+
"saturate",
|
|
256
|
+
"sign",
|
|
257
|
+
"sin",
|
|
258
|
+
"sinh",
|
|
259
|
+
"smoothstep",
|
|
260
|
+
"sqrt",
|
|
261
|
+
"step",
|
|
262
|
+
"tan",
|
|
263
|
+
"tanh",
|
|
264
|
+
"transpose",
|
|
265
|
+
"trunc",
|
|
266
|
+
"dpdx",
|
|
267
|
+
"dpdxCoarse",
|
|
268
|
+
"dpdxFine",
|
|
269
|
+
"dpdy",
|
|
270
|
+
"dpdyCoarse",
|
|
271
|
+
"dpdyFine",
|
|
272
|
+
"fwidth",
|
|
273
|
+
"fwidthCoarse",
|
|
274
|
+
"fwidthFine",
|
|
275
|
+
"textureDimensions",
|
|
276
|
+
"textureGather",
|
|
277
|
+
"textureGatherCompare",
|
|
278
|
+
"textureLoad",
|
|
279
|
+
"textureNumLayers",
|
|
280
|
+
"textureNumLevels",
|
|
281
|
+
"textureNumSamples",
|
|
282
|
+
"textureSample",
|
|
283
|
+
"textureSampleBias",
|
|
284
|
+
"textureSampleCompare",
|
|
285
|
+
"textureSampleCompareLevel",
|
|
286
|
+
"textureSampleGrad",
|
|
287
|
+
"textureSampleLevel",
|
|
288
|
+
"textureSampleBaseClampToEdge",
|
|
289
|
+
"textureStore",
|
|
290
|
+
"atomicLoad",
|
|
291
|
+
"atomicStore",
|
|
292
|
+
"atomicAdd",
|
|
293
|
+
"atomicSub",
|
|
294
|
+
"atomicMax",
|
|
295
|
+
"atomicMin",
|
|
296
|
+
"atomicAnd",
|
|
297
|
+
"atomicOr",
|
|
298
|
+
"atomicXor",
|
|
299
|
+
"atomicExchange",
|
|
300
|
+
"atomicCompareExchangeWeak",
|
|
301
|
+
"pack4x8snorm",
|
|
302
|
+
"pack4x8unorm",
|
|
303
|
+
"pack4xI8",
|
|
304
|
+
"pack4xU8",
|
|
305
|
+
"pack4xI8Clamp",
|
|
306
|
+
"pack4xU8Clamp",
|
|
307
|
+
"pack2x16snorm",
|
|
308
|
+
"pack2x16unorm",
|
|
309
|
+
"pack2x16float",
|
|
310
|
+
"unpack4x8snorm",
|
|
311
|
+
"unpack4x8unorm",
|
|
312
|
+
"unpack4xI8",
|
|
313
|
+
"unpack4xU8",
|
|
314
|
+
"unpack2x16snorm",
|
|
315
|
+
"unpack2x16unorm",
|
|
316
|
+
"unpack2x16float",
|
|
317
|
+
"storageBarrier",
|
|
318
|
+
"textureBarrier",
|
|
319
|
+
"workgroupBarrier",
|
|
320
|
+
"workgroupUniformLoad",
|
|
321
|
+
"subgroupAdd",
|
|
322
|
+
"subgroupExclusiveAdd",
|
|
323
|
+
"subgroupInclusiveAdd",
|
|
324
|
+
"subgroupAll",
|
|
325
|
+
"subgroupAnd",
|
|
326
|
+
"subgroupAny",
|
|
327
|
+
"subgroupBallot",
|
|
328
|
+
"subgroupBroadcast",
|
|
329
|
+
"subgroupBroadcastFirst",
|
|
330
|
+
"subgroupElect",
|
|
331
|
+
"subgroupMax",
|
|
332
|
+
"subgroupMin",
|
|
333
|
+
"subgroupMul",
|
|
334
|
+
"subgroupExclusiveMul",
|
|
335
|
+
"subgroupInclusiveMul",
|
|
336
|
+
"subgroupOr",
|
|
337
|
+
"subgroupShuffle",
|
|
338
|
+
"subgroupShuffleDown",
|
|
339
|
+
"subgroupShuffleUp",
|
|
340
|
+
"subgroupShuffleXor",
|
|
341
|
+
"subgroupXor",
|
|
342
|
+
"quadBroadcast",
|
|
343
|
+
"quadSwapDiagonal",
|
|
344
|
+
"quadSwapX",
|
|
345
|
+
"quadSwapY"
|
|
346
|
+
]);
|
|
347
|
+
function sanitizePrimer(primer) {
|
|
348
|
+
if (primer) return primer.replaceAll(/\s/g, "_").replaceAll(/[^\w\d]/g, "");
|
|
349
|
+
return "item";
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* A function for checking whether an identifier needs renaming.
|
|
353
|
+
* Throws if provided with an invalid identifier that cannot be easily renamed.
|
|
354
|
+
* @example
|
|
355
|
+
* isValidIdentifier("ident"); // true
|
|
356
|
+
* isValidIdentifier("struct"); // false
|
|
357
|
+
* isValidIdentifier("struct_1"); // false
|
|
358
|
+
* isValidIdentifier("_"); // ERROR
|
|
359
|
+
* isValidIdentifier("my variable"); // ERROR
|
|
360
|
+
*/
|
|
361
|
+
function isValidIdentifier(ident) {
|
|
362
|
+
if (ident === "_" || ident.startsWith("__") || /\s/.test(ident)) throw new Error(`Invalid identifier '${ident}'. Choose an identifier without whitespaces or leading underscores.`);
|
|
363
|
+
const prefix = ident.split("_")[0];
|
|
364
|
+
return !bannedTokens.has(prefix) && !builtins.has(prefix);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Same as `isValidIdentifier`, except does not check for builtin clashes.
|
|
368
|
+
*/
|
|
369
|
+
function isValidProp(ident) {
|
|
370
|
+
if (ident === "_" || ident.startsWith("__") || /\s/.test(ident)) throw new Error(`Invalid identifier '${ident}'. Choose an identifier without whitespaces or leading underscores.`);
|
|
371
|
+
const prefix = ident.split("_")[0];
|
|
372
|
+
return !bannedTokens.has(prefix);
|
|
373
|
+
}
|
|
374
|
+
var NameRegistryImpl = class {
|
|
375
|
+
#usedNames;
|
|
376
|
+
#scopeStack;
|
|
377
|
+
constructor() {
|
|
378
|
+
this.#usedNames = new Set([...bannedTokens, ...builtins]);
|
|
379
|
+
this.#scopeStack = [];
|
|
380
|
+
}
|
|
381
|
+
get #usedBlockScopeNames() {
|
|
382
|
+
return this.#scopeStack[this.#scopeStack.length - 1]?.usedBlockScopeNames;
|
|
383
|
+
}
|
|
384
|
+
makeUnique(primer, global) {
|
|
385
|
+
const sanitizedPrimer = sanitizePrimer(primer);
|
|
386
|
+
const name = this.getUniqueVariant(sanitizedPrimer);
|
|
387
|
+
if (global) this.#usedNames.add(name);
|
|
388
|
+
else this.#usedBlockScopeNames?.add(name);
|
|
389
|
+
return name;
|
|
390
|
+
}
|
|
391
|
+
#isUsedInBlocksBefore(name) {
|
|
392
|
+
const functionScopeIndex = this.#scopeStack.findLastIndex((scope) => scope.type === "functionScope");
|
|
393
|
+
return this.#scopeStack.slice(functionScopeIndex + 1).some((scope) => scope.usedBlockScopeNames.has(name));
|
|
394
|
+
}
|
|
395
|
+
makeValid(primer) {
|
|
396
|
+
if (isValidIdentifier(primer) && !this.#usedNames.has(primer) && !this.#isUsedInBlocksBefore(primer)) {
|
|
397
|
+
this.#usedBlockScopeNames?.add(primer);
|
|
398
|
+
return primer;
|
|
399
|
+
}
|
|
400
|
+
return this.makeUnique(primer, false);
|
|
401
|
+
}
|
|
402
|
+
isUsed(name) {
|
|
403
|
+
return this.#usedNames.has(name) || this.#isUsedInBlocksBefore(name);
|
|
404
|
+
}
|
|
405
|
+
pushFunctionScope() {
|
|
406
|
+
this.#scopeStack.push({ type: "functionScope" });
|
|
407
|
+
this.#scopeStack.push({
|
|
408
|
+
type: "blockScope",
|
|
409
|
+
usedBlockScopeNames: /* @__PURE__ */ new Set()
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
popFunctionScope() {
|
|
413
|
+
const functionScopeIndex = this.#scopeStack.findLastIndex((scope) => scope.type === "functionScope");
|
|
414
|
+
if (functionScopeIndex === -1) throw new Error("Tried to pop function scope when no scope was present.");
|
|
415
|
+
this.#scopeStack.splice(functionScopeIndex);
|
|
416
|
+
}
|
|
417
|
+
pushBlockScope() {
|
|
418
|
+
this.#scopeStack.push({
|
|
419
|
+
type: "blockScope",
|
|
420
|
+
usedBlockScopeNames: /* @__PURE__ */ new Set()
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
popBlockScope() {
|
|
424
|
+
invariant(this.#scopeStack[this.#scopeStack.length - 1]?.type === "blockScope", "Tried to pop block scope, but it is not present");
|
|
425
|
+
this.#scopeStack.pop();
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
var RandomNameRegistry = class extends NameRegistryImpl {
|
|
429
|
+
#lastUniqueId = 0;
|
|
430
|
+
getUniqueVariant(base) {
|
|
431
|
+
let name = `${base}_${this.#lastUniqueId++}`;
|
|
432
|
+
while (this.isUsed(name)) name = `${base}_${this.#lastUniqueId++}`;
|
|
433
|
+
return name;
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
var StrictNameRegistry = class extends NameRegistryImpl {
|
|
437
|
+
getUniqueVariant(base) {
|
|
438
|
+
let index = 0;
|
|
439
|
+
let name = base;
|
|
440
|
+
while (this.isUsed(name)) {
|
|
441
|
+
index++;
|
|
442
|
+
name = `${base}_${index}`;
|
|
443
|
+
}
|
|
444
|
+
return name;
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
//#endregion
|
|
449
|
+
export { RandomNameRegistry, StrictNameRegistry, isValidProp };
|
package/package.js
ADDED
package/package.json
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typegpu",
|
|
3
|
+
"version": "0.10.2",
|
|
3
4
|
"private": false,
|
|
4
|
-
"version": "0.10.1",
|
|
5
5
|
"description": "A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"compute",
|
|
8
|
+
"gpgpu",
|
|
9
|
+
"shader",
|
|
10
|
+
"shaders",
|
|
11
|
+
"typescript",
|
|
12
|
+
"webgpu",
|
|
13
|
+
"wgpu",
|
|
14
|
+
"wgsl"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://typegpu.com",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/software-mansion/TypeGPU/issues"
|
|
19
|
+
},
|
|
6
20
|
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/software-mansion/TypeGPU.git"
|
|
24
|
+
},
|
|
7
25
|
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
8
27
|
"exports": {
|
|
9
28
|
"./package.json": "./package.json",
|
|
10
29
|
".": {
|
|
@@ -24,33 +43,14 @@
|
|
|
24
43
|
"default": "./common/index.js"
|
|
25
44
|
}
|
|
26
45
|
},
|
|
27
|
-
"sideEffects": false,
|
|
28
|
-
"engines": {
|
|
29
|
-
"node": ">=12.20.0"
|
|
30
|
-
},
|
|
31
|
-
"repository": {
|
|
32
|
-
"type": "git",
|
|
33
|
-
"url": "git+https://github.com/software-mansion/TypeGPU.git"
|
|
34
|
-
},
|
|
35
|
-
"keywords": [
|
|
36
|
-
"webgpu",
|
|
37
|
-
"wgpu",
|
|
38
|
-
"wgsl",
|
|
39
|
-
"typescript",
|
|
40
|
-
"compute",
|
|
41
|
-
"shader",
|
|
42
|
-
"shaders",
|
|
43
|
-
"gpgpu"
|
|
44
|
-
],
|
|
45
|
-
"bugs": {
|
|
46
|
-
"url": "https://github.com/software-mansion/TypeGPU/issues"
|
|
47
|
-
},
|
|
48
|
-
"homepage": "https://typegpu.com",
|
|
49
46
|
"dependencies": {
|
|
50
47
|
"tinyest": "~0.3.0",
|
|
51
48
|
"tsover-runtime": "^0.0.5",
|
|
52
49
|
"typed-binary": "^4.3.1"
|
|
53
50
|
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=12.20.0"
|
|
53
|
+
},
|
|
54
54
|
"main": "./index.js",
|
|
55
55
|
"types": "./index.d.ts",
|
|
56
56
|
"peerDependencies": {},
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import "./data/snippet.js";
|
|
2
|
+
import "./tgsl/shellless.js";
|
|
3
|
+
import { LogResources } from "./tgsl/consoleLog/types.js";
|
|
4
|
+
import "./core/slot/slotTypes.js";
|
|
5
|
+
import { TgpuBindGroup, TgpuBindGroupLayout } from "./tgpuBindGroupLayout.js";
|
|
6
|
+
import "./tgsl/shaderGenerator.js";
|
|
7
|
+
import "./core/root/rootTypes.js";
|
|
8
|
+
import "./types.js";
|
|
9
|
+
import "./data/wgslTypes.js";
|
|
10
|
+
import "./data/dataTypes.js";
|
|
11
|
+
import "./core/resolve/namespace.js";
|
|
12
|
+
|
|
13
|
+
//#region src/resolutionCtx.d.ts
|
|
14
|
+
/**
|
|
15
|
+
* The results of a WGSL resolution.
|
|
16
|
+
*
|
|
17
|
+
* @param code - The resolved code.
|
|
18
|
+
* @param usedBindGroupLayouts - List of used `tgpu.bindGroupLayout`s.
|
|
19
|
+
* @param catchall - Automatically constructed bind group for buffer usages and buffer shorthands, preceded by its index.
|
|
20
|
+
* @param logResources - Buffers and information about used console.logs needed to decode the raw data.
|
|
21
|
+
*/
|
|
22
|
+
interface ResolutionResult {
|
|
23
|
+
code: string;
|
|
24
|
+
usedBindGroupLayouts: TgpuBindGroupLayout[];
|
|
25
|
+
catchall: [number, TgpuBindGroup] | undefined;
|
|
26
|
+
logResources: LogResources | undefined;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { ResolutionResult };
|