typegpu 0.11.9 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builtin.d.ts +51 -53
- package/builtin.js +30 -34
- package/common/fullScreenTriangle.d.ts +2 -10
- package/common/fullScreenTriangle.js +20 -28
- package/common/index.d.ts +2 -9
- package/common/index.js +3 -12
- package/common/writeSoA.d.ts +11 -12
- package/common/writeSoA.js +88 -76
- package/core/buffer/buffer.d.ts +79 -62
- package/core/buffer/buffer.js +279 -205
- package/core/buffer/bufferBinding.d.ts +71 -0
- package/core/buffer/bufferBinding.js +154 -0
- package/core/buffer/bufferUsage.d.ts +14 -45
- package/core/buffer/bufferUsage.js +1 -171
- package/core/buffer/laidOutBuffer.d.ts +25 -0
- package/core/buffer/laidOutBuffer.js +55 -0
- package/core/commandEncoder/attachments.d.ts +125 -0
- package/core/commandEncoder/attachments.js +29 -0
- package/core/commandEncoder/commandEncoder.d.ts +53 -0
- package/core/commandEncoder/commandEncoder.js +56 -0
- package/core/commandEncoder/computePass.d.ts +58 -0
- package/core/commandEncoder/computePass.js +63 -0
- package/core/commandEncoder/renderPass.d.ts +121 -0
- package/core/commandEncoder/renderPass.js +196 -0
- package/core/constant/tgpuConstant.d.ts +26 -26
- package/core/constant/tgpuConstant.js +76 -65
- package/core/declare/tgpuDeclare.d.ts +3 -6
- package/core/declare/tgpuDeclare.js +36 -36
- package/core/function/autoIO.d.ts +61 -33
- package/core/function/autoIO.js +68 -73
- package/core/function/comptime.d.ts +11 -13
- package/core/function/comptime.js +60 -52
- package/core/function/createCallableSchema.d.ts +16 -0
- package/core/function/createCallableSchema.js +50 -40
- package/core/function/dualImpl.d.ts +44 -0
- package/core/function/dualImpl.js +71 -50
- package/core/function/entryInputRouter.d.ts +26 -0
- package/core/function/entryInputRouter.js +31 -33
- package/core/function/extractArgs.d.ts +38 -0
- package/core/function/extractArgs.js +202 -200
- package/core/function/fnCore.d.ts +44 -5
- package/core/function/fnCore.js +148 -93
- package/core/function/fnTypes.d.ts +31 -29
- package/core/function/fnTypes.js +1 -0
- package/core/function/ioSchema.d.ts +12 -10
- package/core/function/ioSchema.js +65 -47
- package/core/function/shelllessImpl.d.ts +9 -12
- package/core/function/shelllessImpl.js +17 -22
- package/core/function/templateUtils.d.ts +2 -0
- package/core/function/templateUtils.js +9 -8
- package/core/function/tgpuComputeFn.d.ts +26 -28
- package/core/function/tgpuComputeFn.js +47 -48
- package/core/function/tgpuFn.d.ts +34 -37
- package/core/function/tgpuFn.js +179 -153
- package/core/function/tgpuFragmentFn.d.ts +52 -53
- package/core/function/tgpuFragmentFn.js +63 -56
- package/core/function/tgpuVertexFn.d.ts +36 -39
- package/core/function/tgpuVertexFn.js +56 -53
- package/core/pipeline/computePipeline.d.ts +141 -53
- package/core/pipeline/computePipeline.js +291 -225
- package/core/pipeline/connectAttachmentToShader.d.ts +4 -0
- package/core/pipeline/connectAttachmentToShader.js +25 -22
- package/core/pipeline/connectTargetsToShader.d.ts +3 -0
- package/core/pipeline/connectTargetsToShader.js +29 -27
- package/core/pipeline/drawState.d.ts +52 -0
- package/core/pipeline/drawState.js +225 -0
- package/core/pipeline/limitsOverflow.d.ts +2 -0
- package/core/pipeline/limitsOverflow.js +13 -10
- package/core/pipeline/performanceTracker.d.ts +14 -0
- package/core/pipeline/performanceTracker.js +34 -0
- package/core/pipeline/pipelineUtils.d.ts +18 -0
- package/core/pipeline/pipelineUtils.js +54 -25
- package/core/pipeline/priors.d.ts +1 -0
- package/core/pipeline/priors.js +12 -0
- package/core/pipeline/renderPipeline.d.ts +246 -261
- package/core/pipeline/renderPipeline.js +487 -480
- package/core/pipeline/timeable.d.ts +28 -18
- package/core/pipeline/timeable.js +90 -52
- package/core/pipeline/typeGuards.d.ts +17 -0
- package/core/pipeline/typeGuards.js +52 -22
- package/core/querySet/querySet.d.ts +26 -21
- package/core/querySet/querySet.js +127 -103
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +13 -18
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +89 -90
- package/core/resolve/externals.d.ts +25 -8
- package/core/resolve/externals.js +78 -54
- package/core/resolve/namespace.d.ts +22 -25
- package/core/resolve/namespace.js +16 -21
- package/core/resolve/resolvableString.d.ts +7 -0
- package/core/resolve/resolvableString.js +13 -0
- package/core/resolve/resolveData.d.ts +10 -0
- package/core/resolve/resolveData.js +162 -121
- package/core/resolve/stitch.d.ts +8 -0
- package/core/resolve/stitch.js +23 -21
- package/core/resolve/tgpuResolve.d.ts +55 -53
- package/core/resolve/tgpuResolve.js +106 -53
- package/core/root/configurableImpl.d.ts +10 -0
- package/core/root/configurableImpl.js +17 -19
- package/core/root/init.d.ts +76 -38
- package/core/root/init.js +346 -455
- package/core/root/rootTypes.d.ts +461 -636
- package/core/root/rootTypes.js +1 -0
- package/core/sampler/sampler.d.ts +50 -31
- package/core/sampler/sampler.js +120 -113
- package/core/simulate/tgpuSimulate.d.ts +9 -12
- package/core/simulate/tgpuSimulate.js +68 -71
- package/core/slot/accessor.d.ts +36 -13
- package/core/slot/accessor.js +138 -91
- package/core/slot/internalSlots.d.ts +2 -0
- package/core/slot/internalSlots.js +1 -6
- package/core/slot/lazy.d.ts +2 -6
- package/core/slot/lazy.js +71 -39
- package/core/slot/slot.d.ts +2 -6
- package/core/slot/slot.js +45 -38
- package/core/slot/slotTypes.d.ts +78 -80
- package/core/slot/slotTypes.js +11 -16
- package/core/texture/externalTexture.d.ts +20 -11
- package/core/texture/externalTexture.js +46 -46
- package/core/texture/texture.d.ts +152 -97
- package/core/texture/texture.js +407 -314
- package/core/texture/textureFormats.d.ts +42 -23
- package/core/texture/textureFormats.js +104 -75
- package/core/texture/textureProps.d.ts +7 -10
- package/core/texture/textureProps.js +1 -0
- package/core/texture/textureUtils.d.ts +8 -0
- package/core/texture/textureUtils.js +185 -179
- package/core/texture/usageExtension.d.ts +21 -18
- package/core/texture/usageExtension.js +13 -17
- package/core/unroll/tgpuUnroll.d.ts +20 -19
- package/core/unroll/tgpuUnroll.js +82 -91
- package/core/valueProxyUtils.d.ts +3 -0
- package/core/valueProxyUtils.js +52 -41
- package/core/variable/tgpuVariable.d.ts +26 -27
- package/core/variable/tgpuVariable.js +93 -96
- package/core/vertexLayout/connectAttributesToShader.d.ts +9 -0
- package/core/vertexLayout/connectAttributesToShader.js +61 -56
- package/core/vertexLayout/vertexAttribute.d.ts +21 -17
- package/core/vertexLayout/vertexAttribute.js +1 -0
- package/core/vertexLayout/vertexLayout.d.ts +24 -18
- package/core/vertexLayout/vertexLayout.js +130 -99
- package/core/whitespaces.d.ts +2 -0
- package/core/whitespaces.js +16 -0
- package/data/alignIO.d.ts +7 -0
- package/data/alignIO.js +13 -13
- package/data/alignmentOf.d.ts +5 -8
- package/data/alignmentOf.js +90 -75
- package/data/array.d.ts +6 -9
- package/data/array.js +48 -40
- package/data/atomic.d.ts +2 -7
- package/data/atomic.js +26 -23
- package/data/attributes.d.ts +19 -21
- package/data/attributes.js +192 -132
- package/data/autoStruct.d.ts +36 -3
- package/data/autoStruct.js +84 -81
- package/data/compiledIO.d.ts +5 -0
- package/data/compiledIO.js +231 -215
- package/data/dataIO.d.ts +13 -11
- package/data/dataIO.js +643 -589
- package/data/dataTypes.d.ts +83 -65
- package/data/dataTypes.js +66 -68
- package/data/deepEqual.d.ts +2 -7
- package/data/deepEqual.js +80 -55
- package/data/disarray.d.ts +6 -10
- package/data/disarray.js +52 -46
- package/data/float16Conversion.d.ts +4 -0
- package/data/float16Conversion.js +7 -0
- package/data/getLongestContiguousPrefix.d.ts +4 -8
- package/data/getLongestContiguousPrefix.js +6 -11
- package/data/index.d.ts +30 -31
- package/data/index.js +39 -172
- package/data/instanceToSchema.d.ts +24 -27
- package/data/instanceToSchema.js +1 -0
- package/data/isContiguous.d.ts +4 -8
- package/data/isContiguous.js +6 -11
- package/data/matrix.d.ts +21 -21
- package/data/matrix.js +513 -505
- package/data/numberOps.d.ts +6 -0
- package/data/numberOps.js +26 -20
- package/data/numeric.d.ts +21 -12
- package/data/numeric.js +287 -197
- package/data/offsetUtils.d.ts +9 -13
- package/data/offsetUtils.js +204 -144
- package/data/offsets.d.ts +8 -0
- package/data/offsets.js +33 -33
- package/data/partialIO.d.ts +13 -8
- package/data/partialIO.js +124 -113
- package/data/ptr.d.ts +12 -12
- package/data/ptr.js +42 -44
- package/data/ref.d.ts +40 -27
- package/data/ref.js +125 -95
- package/data/sampler.d.ts +99 -101
- package/data/sampler.js +17 -21
- package/data/schemaCallWrapper.d.ts +19 -0
- package/data/schemaCallWrapper.js +31 -26
- package/data/schemaMemoryLayout.d.ts +8 -0
- package/data/schemaMemoryLayout.js +213 -185
- package/data/sizeOf.d.ts +4 -8
- package/data/sizeOf.js +6 -11
- package/data/snippet.d.ts +96 -20
- package/data/snippet.js +75 -86
- package/data/struct.d.ts +4 -7
- package/data/struct.js +51 -39
- package/data/texture.d.ts +253 -250
- package/data/texture.js +238 -200
- package/data/unstruct.d.ts +2 -7
- package/data/unstruct.js +43 -37
- package/data/vector.d.ts +33 -21
- package/data/vector.js +234 -221
- package/data/vectorImpl.d.ts +231 -0
- package/data/vectorImpl.js +563 -515
- package/data/vectorOps.d.ts +63 -0
- package/data/vectorOps.js +642 -630
- package/data/vertexFormatData.d.ts +181 -184
- package/data/vertexFormatData.js +104 -106
- package/data/wgslTypes.d.ts +665 -600
- package/data/wgslTypes.js +220 -198
- package/errors.d.ts +50 -24
- package/errors.js +146 -126
- package/execMode.d.ts +16 -0
- package/execMode.js +47 -40
- package/extension.d.ts +13 -8
- package/extension.js +10 -16
- package/getGPUValue.d.ts +1 -0
- package/getGPUValue.js +2 -7
- package/index.d.ts +28 -68
- package/index.js +8 -28
- package/indexNamedExports.d.ts +69 -42
- package/indexNamedExports.js +25 -0
- package/internal.d.ts +16 -0
- package/internal.js +12 -0
- package/mathUtils.d.ts +5 -0
- package/mathUtils.js +7 -11
- package/memo.d.ts +11 -0
- package/memo.js +20 -22
- package/minify.d.ts +5 -0
- package/minify.js +93 -0
- package/nameUtils.d.ts +29 -0
- package/nameUtils.js +427 -394
- package/package.json +5 -1
- package/resolutionCtx.d.ts +162 -22
- package/resolutionCtx.js +911 -629
- package/serial/registry.d.ts +15 -0
- package/serial/registry.js +106 -0
- package/serial/restore.d.ts +49 -0
- package/serial/restore.js +68 -0
- package/serial/schema.d.ts +58 -0
- package/serial/schema.js +209 -0
- package/serial/types.d.ts +5 -0
- package/serial/types.js +1 -0
- package/shared/env.d.ts +9 -0
- package/shared/env.js +9 -12
- package/shared/generators.d.ts +4 -0
- package/shared/generators.js +10 -12
- package/shared/meta.d.ts +29 -14
- package/shared/meta.js +71 -55
- package/shared/normalizeMetadata.d.ts +32 -27
- package/shared/normalizeMetadata.js +23 -36
- package/shared/repr.d.ts +73 -55
- package/shared/repr.js +1 -0
- package/shared/soul.d.ts +17 -0
- package/shared/soul.js +1 -0
- package/shared/stringify.d.ts +2 -0
- package/shared/stringify.js +29 -20
- package/shared/symbols.d.ts +26 -20
- package/shared/symbols.js +79 -79
- package/shared/tseynit.d.ts +2 -0
- package/shared/tseynit.js +160 -75
- package/shared/utilityTypes.d.ts +30 -14
- package/shared/utilityTypes.js +2 -6
- package/shared/vertexFormat.d.ts +41 -43
- package/shared/vertexFormat.js +59 -62
- package/std/array.d.ts +2 -7
- package/std/array.js +18 -23
- package/std/atomic.d.ts +14 -18
- package/std/atomic.js +96 -95
- package/std/bitcast.d.ts +193 -10
- package/std/bitcast.js +309 -39
- package/std/boolean.d.ts +19 -33
- package/std/boolean.js +296 -288
- package/std/copy.d.ts +2 -7
- package/std/copy.js +27 -24
- package/std/derivative.d.ts +11 -15
- package/std/derivative.js +56 -79
- package/std/discard.d.ts +1 -6
- package/std/discard.js +7 -14
- package/std/environment.d.ts +19 -14
- package/std/environment.js +71 -51
- package/std/extensions.d.ts +2 -8
- package/std/extensions.js +10 -11
- package/std/index.d.ts +20 -24
- package/std/index.js +32 -187
- package/std/matrix.d.ts +6 -12
- package/std/matrix.js +60 -69
- package/std/numeric.d.ts +143 -146
- package/std/numeric.js +858 -749
- package/std/operators.d.ts +19 -27
- package/std/operators.js +227 -193
- package/std/packing.d.ts +5 -11
- package/std/packing.js +67 -75
- package/std/range.d.ts +6 -11
- package/std/range.js +48 -36
- package/std/subgroup.d.ts +33 -37
- package/std/subgroup.js +180 -217
- package/std/texture.d.ts +70 -38
- package/std/texture.js +176 -172
- package/taskQueue.d.ts +6 -0
- package/taskQueue.js +30 -0
- package/tgpu.d.ts +16 -0
- package/tgpu.js +17 -44
- package/tgpuBindGroupLayout.d.ts +132 -152
- package/tgpuBindGroupLayout.js +346 -268
- package/tgpuLogger.d.ts +34 -0
- package/tgpuLogger.js +63 -0
- package/tgpuUnstable.d.ts +16 -22
- package/tgpuUnstable.js +13 -35
- package/tgsl/accessIndex.d.ts +2 -0
- package/tgsl/accessIndex.js +76 -33
- package/tgsl/accessProp.d.ts +2 -0
- package/tgsl/accessProp.js +142 -101
- package/tgsl/accessStructProp.d.ts +5 -0
- package/tgsl/accessStructProp.js +13 -15
- package/tgsl/consoleLog/deserializers.d.ts +13 -0
- package/tgsl/consoleLog/deserializers.js +119 -103
- package/tgsl/consoleLog/logGenerator.d.ts +21 -0
- package/tgsl/consoleLog/logGenerator.js +85 -80
- package/tgsl/consoleLog/serializers.d.ts +21 -0
- package/tgsl/consoleLog/serializers.js +119 -100
- package/tgsl/consoleLog/types.d.ts +40 -39
- package/tgsl/consoleLog/types.js +1 -0
- package/tgsl/conversion.d.ts +33 -0
- package/tgsl/conversion.js +271 -216
- package/tgsl/forOfUtils.d.ts +15 -0
- package/tgsl/forOfUtils.js +85 -70
- package/tgsl/generationHelpers.d.ts +22 -39
- package/tgsl/generationHelpers.js +85 -58
- package/tgsl/infixDispatch.d.ts +70 -0
- package/tgsl/infixDispatch.js +48 -46
- package/tgsl/jsPolyfills.d.ts +16 -19
- package/tgsl/jsPolyfills.js +44 -42
- package/tgsl/makeDereferenceable.d.ts +48 -0
- package/tgsl/makeDereferenceable.js +86 -0
- package/tgsl/makeResolvable.d.ts +22 -0
- package/tgsl/makeResolvable.js +33 -0
- package/tgsl/shaderGenerator.d.ts +77 -17
- package/tgsl/shaderGenerator.js +1 -0
- package/tgsl/shellless.d.ts +6 -9
- package/tgsl/shellless.js +73 -43
- package/tgsl/wgslGenerator.d.ts +66 -59
- package/tgsl/wgslGenerator.js +1344 -760
- package/types.d.ts +287 -222
- package/types.js +61 -44
- package/unwrapper.d.ts +31 -26
- package/unwrapper.js +1 -0
- package/wgslExtensions.d.ts +3 -5
- package/wgslExtensions.js +12 -16
- package/_virtual/rolldown_runtime.js +0 -13
- package/core/buffer/bufferShorthand.d.ts +0 -50
- package/core/buffer/bufferShorthand.js +0 -55
- package/core/pipeline/applyPipelineState.js +0 -37
- package/package.js +0 -5
- package/tgsl/shaderGenerator_members.d.ts +0 -33
- package/tgsl/shaderGenerator_members.js +0 -12
package/tgpuLogger.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
declare const warningTypes: readonly ["deprecated", "suspicious", "fallback", "precision-loss", "implicit-conversion", "webgpu-feature-missing", "webgpu-limits-exceeded", "locations-mismatched", "log-limit-exceeded", "external-omitted"];
|
|
2
|
+
type WarningType = (typeof warningTypes)[number];
|
|
3
|
+
interface Logger {
|
|
4
|
+
warn(type: WarningType, ...args: unknown[]): void;
|
|
5
|
+
warnOnce(type: WarningType, key: object, tag: string, ...args: unknown[]): void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Use this object to globally disable TypeGPU warnings.
|
|
9
|
+
* All warnings are better addressed than silenced, only use this when absolutely necessary.
|
|
10
|
+
*
|
|
11
|
+
* By default, lesser warnings are already silenced in production environment.
|
|
12
|
+
*/
|
|
13
|
+
interface Warn {
|
|
14
|
+
/**
|
|
15
|
+
* Globally disables one kind of warnings.
|
|
16
|
+
* Do not use unless absolutely necessary.
|
|
17
|
+
*/
|
|
18
|
+
disable(type: WarningType): void;
|
|
19
|
+
/**
|
|
20
|
+
* Restores the initial state.
|
|
21
|
+
*/
|
|
22
|
+
reset(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare class TgpuLogger implements Logger, Warn {
|
|
25
|
+
#private;
|
|
26
|
+
constructor(prod: boolean);
|
|
27
|
+
disable(type: WarningType): void;
|
|
28
|
+
reset(): void;
|
|
29
|
+
warn(type: WarningType, ...args: unknown[]): void;
|
|
30
|
+
warnOnce(type: WarningType, key: object, tag: string, ...args: unknown[]): void;
|
|
31
|
+
}
|
|
32
|
+
export declare const logger: Logger;
|
|
33
|
+
export declare const warn: Warn;
|
|
34
|
+
export {};
|
package/tgpuLogger.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { DEV, TEST } from "./shared/env.js";
|
|
2
|
+
const warningTypes = [
|
|
3
|
+
'deprecated',
|
|
4
|
+
'suspicious',
|
|
5
|
+
'fallback',
|
|
6
|
+
'precision-loss',
|
|
7
|
+
'implicit-conversion',
|
|
8
|
+
'webgpu-feature-missing',
|
|
9
|
+
'webgpu-limits-exceeded',
|
|
10
|
+
'locations-mismatched',
|
|
11
|
+
'log-limit-exceeded',
|
|
12
|
+
'external-omitted',
|
|
13
|
+
];
|
|
14
|
+
export class TgpuLogger {
|
|
15
|
+
#initialEnabledWarnings;
|
|
16
|
+
#enabledWarnings;
|
|
17
|
+
#warned = new WeakMap();
|
|
18
|
+
constructor(prod) {
|
|
19
|
+
if (prod) {
|
|
20
|
+
this.#initialEnabledWarnings = [
|
|
21
|
+
'webgpu-feature-missing',
|
|
22
|
+
'webgpu-limits-exceeded',
|
|
23
|
+
'locations-mismatched',
|
|
24
|
+
'log-limit-exceeded',
|
|
25
|
+
'external-omitted',
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
this.#initialEnabledWarnings = warningTypes;
|
|
30
|
+
}
|
|
31
|
+
this.#enabledWarnings = new Set(this.#initialEnabledWarnings);
|
|
32
|
+
}
|
|
33
|
+
disable(type) {
|
|
34
|
+
this.#enabledWarnings.delete(type);
|
|
35
|
+
}
|
|
36
|
+
reset() {
|
|
37
|
+
this.#enabledWarnings = new Set(this.#initialEnabledWarnings);
|
|
38
|
+
}
|
|
39
|
+
warn(type, ...args) {
|
|
40
|
+
if (this.#enabledWarnings.has(type)) {
|
|
41
|
+
console.warn(`⚠️ [${type}] `, ...args);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
warnOnce(type, key, tag, ...args) {
|
|
45
|
+
if (!this.#enabledWarnings.has(type)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
let warnings = this.#warned.get(key);
|
|
49
|
+
if (!warnings) {
|
|
50
|
+
warnings = new Set();
|
|
51
|
+
this.#warned.set(key, warnings);
|
|
52
|
+
}
|
|
53
|
+
const warningId = `${type}:${tag}`;
|
|
54
|
+
if (warnings.has(warningId)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
warnings.add(warningId);
|
|
58
|
+
this.warn(type, ...args);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const tgpuLogger = new TgpuLogger(!(DEV || TEST));
|
|
62
|
+
export const logger = tgpuLogger;
|
|
63
|
+
export const warn = tgpuLogger;
|
package/tgpuUnstable.d.ts
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { lazy } from
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
//#region src/tgpuUnstable.d.ts
|
|
18
|
-
declare namespace tgpuUnstable_d_exports {
|
|
19
|
-
export { _accessor as accessor, _comptime as comptime, _computeFn as computeFn, _constant as const, declare, _lazy as derived, _fn as fn, _fragmentFn as fragmentFn, _mutableAccessor as mutableAccessor, namespace, _privateVar as privateVar, rawCodeSnippet, simulate, _slot as slot, _vertexFn as vertexFn, _vertexLayout as vertexLayout, _workgroupVar as workgroupVar };
|
|
20
|
-
}
|
|
1
|
+
export { declare } from './core/declare/tgpuDeclare.ts';
|
|
2
|
+
export { rawCodeSnippet } from './core/rawCodeSnippet/tgpuRawCodeSnippet.ts';
|
|
3
|
+
export { namespace } from './core/resolve/namespace.ts';
|
|
4
|
+
export { simulate } from './core/simulate/tgpuSimulate.ts';
|
|
5
|
+
import { constant } from './core/constant/tgpuConstant.ts';
|
|
6
|
+
import { comptime } from './core/function/comptime.ts';
|
|
7
|
+
import { computeFn } from './core/function/tgpuComputeFn.ts';
|
|
8
|
+
import { fn } from './core/function/tgpuFn.ts';
|
|
9
|
+
import { fragmentFn } from './core/function/tgpuFragmentFn.ts';
|
|
10
|
+
import { vertexFn } from './core/function/tgpuVertexFn.ts';
|
|
11
|
+
import { accessor, mutableAccessor } from './core/slot/accessor.ts';
|
|
12
|
+
import { lazy } from './core/slot/lazy.ts';
|
|
13
|
+
import { slot } from './core/slot/slot.ts';
|
|
14
|
+
import { privateVar, workgroupVar } from './core/variable/tgpuVariable.ts';
|
|
15
|
+
import { vertexLayout } from './core/vertexLayout/vertexLayout.ts';
|
|
21
16
|
/** @deprecated This feature is now stable, use tgpu.const. */
|
|
22
17
|
declare const _constant: typeof constant;
|
|
23
18
|
/** @deprecated This feature is now stable, use tgpu.comptime. */
|
|
@@ -44,5 +39,4 @@ declare const _privateVar: typeof privateVar;
|
|
|
44
39
|
declare const _workgroupVar: typeof workgroupVar;
|
|
45
40
|
/** @deprecated This feature is now stable, use tgpu.vertexLayout. */
|
|
46
41
|
declare const _vertexLayout: typeof vertexLayout;
|
|
47
|
-
|
|
48
|
-
export { tgpuUnstable_d_exports };
|
|
42
|
+
export { _accessor as accessor, _comptime as comptime, _computeFn as computeFn, _constant as const, _fn as fn, _fragmentFn as fragmentFn, _lazy as derived, _mutableAccessor as mutableAccessor, _privateVar as privateVar, _slot as slot, _vertexFn as vertexFn, _vertexLayout as vertexLayout, _workgroupVar as workgroupVar, };
|
package/tgpuUnstable.js
CHANGED
|
@@ -1,40 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// NOTE: This is a barrel file, internal files should not import things from this file
|
|
2
|
+
export { declare } from "./core/declare/tgpuDeclare.js";
|
|
3
|
+
export { rawCodeSnippet } from "./core/rawCodeSnippet/tgpuRawCodeSnippet.js";
|
|
4
|
+
export { namespace } from "./core/resolve/namespace.js";
|
|
5
|
+
export { simulate } from "./core/simulate/tgpuSimulate.js";
|
|
6
|
+
// DEPRECATED
|
|
3
7
|
import { constant } from "./core/constant/tgpuConstant.js";
|
|
8
|
+
import { comptime } from "./core/function/comptime.js";
|
|
9
|
+
import { computeFn } from "./core/function/tgpuComputeFn.js";
|
|
4
10
|
import { fn } from "./core/function/tgpuFn.js";
|
|
11
|
+
import { fragmentFn } from "./core/function/tgpuFragmentFn.js";
|
|
12
|
+
import { vertexFn } from "./core/function/tgpuVertexFn.js";
|
|
13
|
+
import { accessor, mutableAccessor } from "./core/slot/accessor.js";
|
|
14
|
+
import { lazy } from "./core/slot/lazy.js";
|
|
5
15
|
import { slot } from "./core/slot/slot.js";
|
|
6
16
|
import { privateVar, workgroupVar } from "./core/variable/tgpuVariable.js";
|
|
7
|
-
import { namespace } from "./core/resolve/namespace.js";
|
|
8
|
-
import { computeFn } from "./core/function/tgpuComputeFn.js";
|
|
9
17
|
import { vertexLayout } from "./core/vertexLayout/vertexLayout.js";
|
|
10
|
-
import { lazy } from "./core/slot/lazy.js";
|
|
11
|
-
import { accessor, mutableAccessor } from "./core/slot/accessor.js";
|
|
12
|
-
import { fragmentFn } from "./core/function/tgpuFragmentFn.js";
|
|
13
|
-
import { vertexFn } from "./core/function/tgpuVertexFn.js";
|
|
14
|
-
import { declare } from "./core/declare/tgpuDeclare.js";
|
|
15
|
-
import { rawCodeSnippet } from "./core/rawCodeSnippet/tgpuRawCodeSnippet.js";
|
|
16
|
-
import { simulate } from "./core/simulate/tgpuSimulate.js";
|
|
17
|
-
|
|
18
|
-
//#region src/tgpuUnstable.ts
|
|
19
|
-
var tgpuUnstable_exports = /* @__PURE__ */ __export({
|
|
20
|
-
accessor: () => _accessor,
|
|
21
|
-
comptime: () => _comptime,
|
|
22
|
-
computeFn: () => _computeFn,
|
|
23
|
-
const: () => _constant,
|
|
24
|
-
declare: () => declare,
|
|
25
|
-
derived: () => _lazy,
|
|
26
|
-
fn: () => _fn,
|
|
27
|
-
fragmentFn: () => _fragmentFn,
|
|
28
|
-
mutableAccessor: () => _mutableAccessor,
|
|
29
|
-
namespace: () => namespace,
|
|
30
|
-
privateVar: () => _privateVar,
|
|
31
|
-
rawCodeSnippet: () => rawCodeSnippet,
|
|
32
|
-
simulate: () => simulate,
|
|
33
|
-
slot: () => _slot,
|
|
34
|
-
vertexFn: () => _vertexFn,
|
|
35
|
-
vertexLayout: () => _vertexLayout,
|
|
36
|
-
workgroupVar: () => _workgroupVar
|
|
37
|
-
});
|
|
38
18
|
/** @deprecated This feature is now stable, use tgpu.const. */
|
|
39
19
|
const _constant = constant;
|
|
40
20
|
/** @deprecated This feature is now stable, use tgpu.comptime. */
|
|
@@ -61,6 +41,4 @@ const _privateVar = privateVar;
|
|
|
61
41
|
const _workgroupVar = workgroupVar;
|
|
62
42
|
/** @deprecated This feature is now stable, use tgpu.vertexLayout. */
|
|
63
43
|
const _vertexLayout = vertexLayout;
|
|
64
|
-
|
|
65
|
-
//#endregion
|
|
66
|
-
export { tgpuUnstable_exports };
|
|
44
|
+
export { _accessor as accessor, _comptime as comptime, _computeFn as computeFn, _constant as const, _fn as fn, _fragmentFn as fragmentFn, _lazy as derived, _mutableAccessor as mutableAccessor, _privateVar as privateVar, _slot as slot, _vertexFn as vertexFn, _vertexLayout as vertexLayout, _workgroupVar as workgroupVar, };
|
package/tgsl/accessIndex.js
CHANGED
|
@@ -1,40 +1,83 @@
|
|
|
1
|
-
import { isPtr, isVec, isWgslArray, isWgslStruct } from "../data/wgslTypes.js";
|
|
2
|
-
import { MatrixColumnsAccess, isDisarray } from "../data/dataTypes.js";
|
|
3
|
-
import { snip } from "../data/snippet.js";
|
|
4
|
-
import { isKnownAtComptime } from "../types.js";
|
|
5
1
|
import { stitch } from "../core/resolve/stitch.js";
|
|
2
|
+
import { isDisarray, MatrixColumnsAccess } from "../data/dataTypes.js";
|
|
6
3
|
import { derefSnippet } from "../data/ref.js";
|
|
7
|
-
import {
|
|
4
|
+
import { snip } from "../data/snippet.js";
|
|
8
5
|
import { vec2f, vec3f, vec4f } from "../data/vector.js";
|
|
6
|
+
import { isPtr, isVec, isWgslArray, isWgslStruct } from "../data/wgslTypes.js";
|
|
7
|
+
import { isKnownAtComptime } from "../types.js";
|
|
9
8
|
import { accessProp } from "./accessProp.js";
|
|
10
|
-
|
|
11
|
-
//#region src/tgsl/accessIndex.ts
|
|
9
|
+
import { ArrayExpression, coerceToSnippet } from "./generationHelpers.js";
|
|
12
10
|
const indexableTypeToResult = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
mat2x2f: vec2f,
|
|
12
|
+
mat3x3f: vec3f,
|
|
13
|
+
mat4x4f: vec4f,
|
|
16
14
|
};
|
|
17
|
-
function accessIndex(target, indexArg) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
export function accessIndex(target, indexArg) {
|
|
16
|
+
const index = typeof indexArg === 'number' ? coerceToSnippet(indexArg) : indexArg;
|
|
17
|
+
// array
|
|
18
|
+
if (isWgslArray(target.dataType) || isDisarray(target.dataType)) {
|
|
19
|
+
const elementType = target.dataType.elementType;
|
|
20
|
+
let origin;
|
|
21
|
+
if (target.origin === 'constant-immutable-def') {
|
|
22
|
+
// Constant refs stay const unless the element/index forces runtime materialization
|
|
23
|
+
origin =
|
|
24
|
+
index.origin === 'constant' || index.origin === 'constant-immutable-def'
|
|
25
|
+
? 'constant-immutable-def'
|
|
26
|
+
: 'runtime-immutable-def';
|
|
27
|
+
}
|
|
28
|
+
else if (target.origin === 'constant') {
|
|
29
|
+
// Ephemeral constants indexed with constants stay constant, otherwise they become runtime-known
|
|
30
|
+
origin =
|
|
31
|
+
index.origin === 'constant' || index.origin === 'constant-immutable-def'
|
|
32
|
+
? 'constant'
|
|
33
|
+
: 'runtime';
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// Fallthrough
|
|
37
|
+
origin = target.origin;
|
|
38
|
+
}
|
|
39
|
+
if (target.value instanceof ArrayExpression && isKnownAtComptime(index)) {
|
|
40
|
+
return target.value.elements[index.value];
|
|
41
|
+
}
|
|
42
|
+
return snip(isKnownAtComptime(target) && isKnownAtComptime(index)
|
|
43
|
+
? // oxlint-disable-next-line typescript/no-explicit-any -- it's fine, it's there
|
|
44
|
+
target.value[index.value]
|
|
45
|
+
: stitch `${target}[${index}]`, elementType,
|
|
46
|
+
/* origin */ origin, target.possibleSideEffects || index.possibleSideEffects);
|
|
47
|
+
}
|
|
48
|
+
// vector
|
|
49
|
+
if (isVec(target.dataType)) {
|
|
50
|
+
return snip(isKnownAtComptime(target) && isKnownAtComptime(index)
|
|
51
|
+
? // oxlint-disable-next-line typescript/no-explicit-any -- it's fine, it's there
|
|
52
|
+
target.value[index.value]
|
|
53
|
+
: stitch `${target}[${index}]`, target.dataType.primitive,
|
|
54
|
+
/* origin */ target.origin, target.possibleSideEffects || index.possibleSideEffects);
|
|
55
|
+
}
|
|
56
|
+
if (isPtr(target.dataType)) {
|
|
57
|
+
// Sometimes values that are typed as pointers aren't instances of `d.ref`, so we
|
|
58
|
+
// allow indexing as if it wasn't a pointer.
|
|
59
|
+
return accessIndex(derefSnippet(target), index);
|
|
60
|
+
}
|
|
61
|
+
// matrix.columns
|
|
62
|
+
if (target.value instanceof MatrixColumnsAccess) {
|
|
63
|
+
const propType = indexableTypeToResult[target.value.matrix.dataType.type];
|
|
64
|
+
return snip(stitch `${target.value.matrix}[${index}]`, propType,
|
|
65
|
+
/* origin */ target.origin, target.possibleSideEffects || index.possibleSideEffects);
|
|
66
|
+
}
|
|
67
|
+
// matrix
|
|
68
|
+
if (target.dataType.type in indexableTypeToResult) {
|
|
69
|
+
throw new Error("The only way of accessing matrix elements in TypeGPU functions is through the 'columns' property.");
|
|
70
|
+
}
|
|
71
|
+
if (isKnownAtComptime(target) && isKnownAtComptime(index)) {
|
|
72
|
+
// No idea what the type is, so we act on the snippet's value and try to guess
|
|
73
|
+
return coerceToSnippet(
|
|
74
|
+
// oxlint-disable-next-line typescript/no-explicit-any -- we're inspecting the value, and it could be any value
|
|
75
|
+
target.value[index.value]);
|
|
76
|
+
}
|
|
77
|
+
if (isWgslStruct(target.dataType) &&
|
|
78
|
+
isKnownAtComptime(index) &&
|
|
79
|
+
typeof index.value === 'string') {
|
|
80
|
+
return accessProp(target, index.value);
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
37
83
|
}
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
export { accessIndex };
|
package/tgsl/accessProp.js
CHANGED
|
@@ -1,110 +1,151 @@
|
|
|
1
|
-
import { isMat, isPtr, isVec, isWgslArray, isWgslStruct } from "../data/wgslTypes.js";
|
|
2
|
-
import { getName, isNamable, setName } from "../shared/meta.js";
|
|
3
|
-
import { MatrixColumnsAccess, UnknownData, isUnstruct } from "../data/dataTypes.js";
|
|
4
|
-
import { isSnippet, snip } from "../data/snippet.js";
|
|
5
|
-
import { isKnownAtComptime } from "../types.js";
|
|
6
1
|
import { stitch } from "../core/resolve/stitch.js";
|
|
7
|
-
import { derefSnippet } from "../data/ref.js";
|
|
8
|
-
import { accessStructProp } from "./accessStructProp.js";
|
|
9
|
-
import { bool, f16, f32, i32, u32 } from "../data/numeric.js";
|
|
10
|
-
import { coerceToSnippet, numericLiteralToSnippet } from "./generationHelpers.js";
|
|
11
|
-
import { vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u } from "../data/vector.js";
|
|
12
2
|
import { AutoStruct } from "../data/autoStruct.js";
|
|
13
3
|
import { EntryInputRouter } from "../core/function/entryInputRouter.js";
|
|
4
|
+
import { isUnstruct, MatrixColumnsAccess, UnknownData } from "../data/dataTypes.js";
|
|
5
|
+
import { bool, f16, f32, i32, u32 } from "../data/numeric.js";
|
|
6
|
+
import { derefSnippet } from "../data/ref.js";
|
|
7
|
+
import { isSnippet, snip } from "../data/snippet.js";
|
|
8
|
+
import { vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, } from "../data/vector.js";
|
|
9
|
+
import { isMat, isPtr, isVec, isWgslArray, isWgslStruct, } from "../data/wgslTypes.js";
|
|
10
|
+
import { isKnownAtComptime } from "../types.js";
|
|
11
|
+
import { coerceToSnippet, numericLiteralToSnippet } from "./generationHelpers.js";
|
|
14
12
|
import { InfixDispatch, infixOperators } from "./infixDispatch.js";
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
import { accessStructProp } from "./accessStructProp.js";
|
|
14
|
+
import { getName, isNamable, setName } from "../shared/meta.js";
|
|
17
15
|
const infixKinds = [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
16
|
+
'vec2f',
|
|
17
|
+
'vec3f',
|
|
18
|
+
'vec4f',
|
|
19
|
+
'vec2h',
|
|
20
|
+
'vec3h',
|
|
21
|
+
'vec4h',
|
|
22
|
+
'vec2i',
|
|
23
|
+
'vec3i',
|
|
24
|
+
'vec4i',
|
|
25
|
+
'vec2u',
|
|
26
|
+
'vec3u',
|
|
27
|
+
'vec4u',
|
|
28
|
+
'mat2x2f',
|
|
29
|
+
'mat3x3f',
|
|
30
|
+
'mat4x4f',
|
|
33
31
|
];
|
|
34
32
|
const swizzleLenToType = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
33
|
+
f: {
|
|
34
|
+
1: f32,
|
|
35
|
+
2: vec2f,
|
|
36
|
+
3: vec3f,
|
|
37
|
+
4: vec4f,
|
|
38
|
+
},
|
|
39
|
+
h: {
|
|
40
|
+
1: f16,
|
|
41
|
+
2: vec2h,
|
|
42
|
+
3: vec3h,
|
|
43
|
+
4: vec4h,
|
|
44
|
+
},
|
|
45
|
+
i: {
|
|
46
|
+
1: i32,
|
|
47
|
+
2: vec2i,
|
|
48
|
+
3: vec3i,
|
|
49
|
+
4: vec4i,
|
|
50
|
+
},
|
|
51
|
+
u: {
|
|
52
|
+
1: u32,
|
|
53
|
+
2: vec2u,
|
|
54
|
+
3: vec3u,
|
|
55
|
+
4: vec4u,
|
|
56
|
+
},
|
|
57
|
+
b: {
|
|
58
|
+
1: bool,
|
|
59
|
+
2: vec2b,
|
|
60
|
+
3: vec3b,
|
|
61
|
+
4: vec4b,
|
|
62
|
+
},
|
|
65
63
|
};
|
|
66
|
-
function accessProp(target, propName) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
64
|
+
export function accessProp(target, propName) {
|
|
65
|
+
if (infixKinds.includes(target.dataType.type) && propName in infixOperators) {
|
|
66
|
+
const operator = infixOperators[propName];
|
|
67
|
+
return snip(new InfixDispatch(target, operator), UnknownData,
|
|
68
|
+
/* origin */ target.origin, target.possibleSideEffects);
|
|
69
|
+
}
|
|
70
|
+
if (isWgslArray(target.dataType) && propName === 'length') {
|
|
71
|
+
if (target.dataType.elementCount === 0) {
|
|
72
|
+
// Dynamically-sized array
|
|
73
|
+
return snip(stitch `arrayLength(&${target})`, u32,
|
|
74
|
+
/* origin */ 'runtime', target.possibleSideEffects);
|
|
75
|
+
}
|
|
76
|
+
return numericLiteralToSnippet(target.dataType.elementCount);
|
|
77
|
+
}
|
|
78
|
+
if (isMat(target.dataType) && propName === 'columns') {
|
|
79
|
+
return snip(new MatrixColumnsAccess(target), UnknownData,
|
|
80
|
+
/* origin */ target.origin, target.possibleSideEffects);
|
|
81
|
+
}
|
|
82
|
+
if (isWgslStruct(target.dataType) || isUnstruct(target.dataType)) {
|
|
83
|
+
return accessStructProp(target, propName);
|
|
84
|
+
}
|
|
85
|
+
if (target.dataType instanceof AutoStruct) {
|
|
86
|
+
const result = target.dataType.accessProp(propName);
|
|
87
|
+
if (!result) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
return snip(stitch `${target}.${result.prop}`, result.type, 'argument', target.possibleSideEffects);
|
|
91
|
+
}
|
|
92
|
+
if (target.dataType instanceof EntryInputRouter) {
|
|
93
|
+
const result = target.dataType.accessProp(propName);
|
|
94
|
+
if (isSnippet(result)) {
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
if (result) {
|
|
98
|
+
return accessProp(result.target, result.prop);
|
|
99
|
+
}
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
if (isPtr(target.dataType)) {
|
|
103
|
+
const derefed = derefSnippet(target);
|
|
104
|
+
if (propName === '$') {
|
|
105
|
+
// Dereference pointer
|
|
106
|
+
return derefed;
|
|
107
|
+
}
|
|
108
|
+
// Sometimes values that are typed as pointers aren't instances of `d.ref`, so we
|
|
109
|
+
// allow access to member props as if it wasn't a pointer.
|
|
110
|
+
return accessProp(derefed, propName);
|
|
111
|
+
}
|
|
112
|
+
if (isVec(target.dataType)) {
|
|
113
|
+
// Example: d.vec3f().kind === 'vec3f'
|
|
114
|
+
if (propName === 'kind') {
|
|
115
|
+
// The snippet has no side-effects
|
|
116
|
+
return snip(target.dataType.type, UnknownData, 'constant', /* possibleSideEffects */ false);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const propLength = propName.length;
|
|
120
|
+
if (isVec(target.dataType) &&
|
|
121
|
+
propLength >= 1 &&
|
|
122
|
+
propLength <= 4 &&
|
|
123
|
+
/^[xyzw]+$|^[rgba]+$/.test(propName)) {
|
|
124
|
+
const swizzleTypeChar = target.dataType.type.includes('bool')
|
|
125
|
+
? 'b'
|
|
126
|
+
: target.dataType.type[4];
|
|
127
|
+
const swizzleType = swizzleLenToType[swizzleTypeChar][propLength];
|
|
128
|
+
if (!swizzleType) {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
return snip(isKnownAtComptime(target)
|
|
132
|
+
? // oxlint-disable-next-line typescript/no-explicit-any -- it's fine, the prop is there
|
|
133
|
+
target.value[propName]
|
|
134
|
+
: stitch `${target}.${propName}`, swizzleType,
|
|
135
|
+
// Swizzling creates new vectors (unless they're on the lhs of an assignment, but that's not yet supported in WGSL)
|
|
136
|
+
/* origin */ propLength === 1
|
|
137
|
+
? target.origin
|
|
138
|
+
: target.origin === 'constant' || target.origin === 'constant-immutable-def'
|
|
139
|
+
? 'constant'
|
|
140
|
+
: 'runtime', target.possibleSideEffects);
|
|
141
|
+
}
|
|
142
|
+
if (isKnownAtComptime(target) || target.dataType === UnknownData) {
|
|
143
|
+
// oxlint-disable-next-line typescript/no-explicit-any -- we either know exactly what it is, or have no idea at all
|
|
144
|
+
const prop = target.value[propName];
|
|
145
|
+
if (isNamable(prop) && getName(prop) === undefined) {
|
|
146
|
+
setName(prop, propName);
|
|
147
|
+
}
|
|
148
|
+
return coerceToSnippet(prop);
|
|
149
|
+
}
|
|
150
|
+
return undefined;
|
|
107
151
|
}
|
|
108
|
-
|
|
109
|
-
//#endregion
|
|
110
|
-
export { accessProp };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Snippet } from '../data/snippet.ts';
|
|
2
|
+
/**
|
|
3
|
+
* This function is separate from `accessProp` to avoid a circular dependency.
|
|
4
|
+
*/
|
|
5
|
+
export declare function accessStructProp(target: Snippet, propName: string): import("../internal.ts").ResolvedSnippet | undefined;
|
package/tgsl/accessStructProp.js
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stitch } from "../core/resolve/stitch.js";
|
|
2
2
|
import { isUnstruct, undecorate } from "../data/dataTypes.js";
|
|
3
3
|
import { snip } from "../data/snippet.js";
|
|
4
|
+
import { isWgslStruct } from "../data/wgslTypes.js";
|
|
4
5
|
import { invariant } from "../errors.js";
|
|
5
|
-
import { stitch } from "../core/resolve/stitch.js";
|
|
6
|
-
|
|
7
|
-
//#region src/tgsl/accessStructProp.ts
|
|
8
6
|
/**
|
|
9
|
-
* This function is separate from `accessProp` to avoid a circular dependency.
|
|
10
|
-
*/
|
|
11
|
-
function accessStructProp(target, propName) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
* This function is separate from `accessProp` to avoid a circular dependency.
|
|
8
|
+
*/
|
|
9
|
+
export function accessStructProp(target, propName) {
|
|
10
|
+
invariant(isWgslStruct(target.dataType) || isUnstruct(target.dataType), 'Expected snippet type to be struct/unstruct.');
|
|
11
|
+
let propType = target.dataType.propTypes[propName];
|
|
12
|
+
if (!propType) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
propType = undecorate(propType);
|
|
16
|
+
return snip(stitch `${target}.${propName}`, propType,
|
|
17
|
+
/* origin */ target.origin, target.possibleSideEffects);
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { accessStructProp };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type AnyWgslData } from '../../data/wgslTypes.ts';
|
|
2
|
+
import type { LogResources } from './types.ts';
|
|
3
|
+
export declare function deserializeAndStringify(serializedData: Uint32Array, argTypes: (AnyWgslData | string)[]): string[];
|
|
4
|
+
/**
|
|
5
|
+
* Reads and deserializes log data from GPU buffers, logging results to the console.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* - Log entries with IDs equal to 0 are filtered out.
|
|
9
|
+
* - Console messages are prepended with options.messagePrefix styled with purple background and white text.
|
|
10
|
+
* - A warning is displayed if the log count exceeds the limit passed in options.
|
|
11
|
+
* - After processing, the index buffer and the data buffer are cleared.
|
|
12
|
+
*/
|
|
13
|
+
export declare function logDataFromGPU(resources: LogResources): void;
|