@carbonenginejs/runtime-resource 0.12.2 → 0.14.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/README.md +21 -0
- package/dist/CjsResMan.js +393 -29
- package/dist/CjsResMan.js.map +1 -1
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js +165 -118
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js.map +1 -1
- package/dist/format/carbonEffect/buildCarbonEffectContainer.js +182 -0
- package/dist/format/carbonEffect/buildCarbonEffectContainer.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js +7 -113
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
- package/dist/format/carbonEffect/carbonEffectRecords.js +258 -66
- package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -1
- package/dist/format/carbonEffect/carbonEffectResourceTransform.js +197 -0
- package/dist/format/carbonEffect/carbonEffectResourceTransform.js.map +1 -0
- package/dist/format/effect/effectBodyInventory.js +146 -0
- package/dist/format/effect/effectBodyInventory.js.map +1 -0
- package/dist/format/effect/effectPermutationGraph.js +13 -13
- package/dist/format/effect/effectPermutationGraph.js.map +1 -1
- package/dist/format/index.js +4 -4
- package/dist/formats/black/CjsBlackFormat.js +19 -1
- package/dist/formats/black/CjsBlackFormat.js.map +1 -1
- package/dist/formats/bnk/CjsBnkFormat.js +28 -9
- package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
- package/dist/formats/bnk/core/busNodes.js +252 -0
- package/dist/formats/bnk/core/busNodes.js.map +1 -0
- package/dist/formats/bnk/core/effectNodes.js +147 -0
- package/dist/formats/bnk/core/effectNodes.js.map +1 -0
- package/dist/formats/bnk/core/eventAction.js +135 -24
- package/dist/formats/bnk/core/eventAction.js.map +1 -1
- package/dist/formats/bnk/core/globalSettings.js +215 -0
- package/dist/formats/bnk/core/globalSettings.js.map +1 -0
- package/dist/formats/bnk/core/helpers.js +37 -5
- package/dist/formats/bnk/core/helpers.js.map +1 -1
- package/dist/formats/bnk/core/musicNodes.js +43 -19
- package/dist/formats/bnk/core/musicNodes.js.map +1 -1
- package/dist/formats/bnk/core/nodeBase.js +28 -7
- package/dist/formats/bnk/core/nodeBase.js.map +1 -1
- package/dist/formats/dds/core/helpers.js +40 -1
- package/dist/formats/dds/core/helpers.js.map +1 -1
- package/dist/formats/dxbc/CjsDxbcFormat.js +45 -0
- package/dist/formats/dxbc/CjsDxbcFormat.js.map +1 -1
- package/dist/formats/dxbc/core/disassemble.js +240 -0
- package/dist/formats/dxbc/core/disassemble.js.map +1 -0
- package/dist/formats/gltf/CjsGltfFormat.js +1 -39
- package/dist/formats/gltf/CjsGltfFormat.js.map +1 -1
- package/dist/formats/gltf/core/helpers.js +1 -21
- package/dist/formats/gltf/core/helpers.js.map +1 -1
- package/dist/formats/hlsl/CjsHlslFormat.js +0 -21
- package/dist/formats/hlsl/CjsHlslFormat.js.map +1 -1
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +118 -49
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -1
- package/dist/formats/hlsl/core/detailMapFamily.js +128 -0
- package/dist/formats/hlsl/core/detailMapFamily.js.map +1 -0
- package/dist/formats/hlsl/core/localLightFamily.js +133 -0
- package/dist/formats/hlsl/core/localLightFamily.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +79 -73
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -1
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js +8 -1
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js.map +1 -1
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js +11 -691
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js.map +1 -1
- package/dist/formats/index.js +4 -2
- package/dist/formats/index.js.map +1 -1
- package/dist/formats/obj/CjsObjFormat.js +1 -22
- package/dist/formats/obj/CjsObjFormat.js.map +1 -1
- package/dist/formats/obj/core/helpers.js +1 -21
- package/dist/formats/obj/core/helpers.js.map +1 -1
- package/dist/formats/pickle/CjsPickleFormat.js +214 -0
- package/dist/formats/pickle/CjsPickleFormat.js.map +1 -0
- package/dist/formats/pickle/core/CjsPickleProtocol0Reader.js +551 -0
- package/dist/formats/pickle/core/CjsPickleProtocol0Reader.js.map +1 -0
- package/dist/formats/pickle/index.js +2 -0
- package/dist/formats/pickle/index.js.map +1 -0
- package/dist/formats/red/core/redGraph.js +11 -8
- package/dist/formats/red/core/redGraph.js.map +1 -1
- package/dist/formats/stl/CjsStlFormat.js +1 -46
- package/dist/formats/stl/CjsStlFormat.js.map +1 -1
- package/dist/formats/stl/core/helpers.js +1 -21
- package/dist/formats/stl/core/helpers.js.map +1 -1
- package/dist/formats/webgl/CjsWebglFormat.js +33 -55
- package/dist/formats/webgl/CjsWebglFormat.js.map +1 -1
- package/dist/formats/webgl/core/buildGlslEffectContainer.js +70 -0
- package/dist/formats/webgl/core/buildGlslEffectContainer.js.map +1 -0
- package/dist/formats/webgl/core/effectPackage.js +216 -108
- package/dist/formats/webgl/core/effectPackage.js.map +1 -1
- package/dist/formats/webgl/core/errors.js +1 -1
- package/dist/formats/webgl/core/errors.js.map +1 -1
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +166 -24
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
- package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js +63 -5
- package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js.map +1 -1
- package/dist/formats/webgl/core/glsl/packedLightFixups.js +98 -0
- package/dist/formats/webgl/core/glsl/packedLightFixups.js.map +1 -0
- package/dist/formats/webgl/core/glslBackendBlock.js +552 -0
- package/dist/formats/webgl/core/glslBackendBlock.js.map +1 -0
- package/dist/formats/webgl/core/glslBackendBodySet.js +243 -0
- package/dist/formats/webgl/core/glslBackendBodySet.js.map +1 -0
- package/dist/formats/webgl/core/{cewgCompleteness.js → glslEffectCompleteness.js} +12 -8
- package/dist/formats/webgl/core/glslEffectCompleteness.js.map +1 -0
- package/dist/formats/webgl/core/helpers.js +33 -172
- package/dist/formats/webgl/core/helpers.js.map +1 -1
- package/dist/formats/webgl/core/inspectGlslEffectContainer.js +122 -0
- package/dist/formats/webgl/core/inspectGlslEffectContainer.js.map +1 -0
- package/dist/formats/webgl/core/readGlslEffectContainer.js +249 -0
- package/dist/formats/webgl/core/readGlslEffectContainer.js.map +1 -0
- package/dist/formats/webgpu/CjsWebgpuFormat.js +15 -15
- package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +37 -145
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -1
- package/dist/formats/webgpu/core/{cewgpu/CewgpuContainer.js → carbonWebgpu/CarbonWebgpuContainer.js} +13 -27
- package/dist/formats/webgpu/core/carbonWebgpu/CarbonWebgpuContainer.js.map +1 -0
- package/dist/formats/webgpu/core/{cewgpu → carbonWebgpu}/containerViews.js +1 -1
- package/dist/formats/webgpu/core/carbonWebgpu/containerViews.js.map +1 -0
- package/dist/formats/webgpu/core/{cewgpu → carbonWebgpu}/validateContainer.js +4 -4
- package/dist/formats/webgpu/core/carbonWebgpu/validateContainer.js.map +1 -0
- package/dist/formats/webgpu/core/effectBackendBodySet.js +18 -18
- package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
- package/dist/formats/webgpu/core/errors.js +1 -1
- package/dist/formats/webgpu/core/errors.js.map +1 -1
- package/dist/formats/webgpu/core/helpers.js +22 -22
- package/dist/formats/webgpu/core/helpers.js.map +1 -1
- package/dist/formats/webgpu/core/packageEffect.js +11 -15
- package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
- package/dist/formats/webgpu/core/packageEffectSelection.js +1 -1
- package/dist/formats/webgpu/core/packageEffectSelection.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +23 -23
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +6 -6
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -1
- package/dist/formats/yaml/CjsYamlFormat.js +3 -3
- package/dist/formats/yaml/CjsYamlFormat.js.map +1 -1
- package/dist/formats/yaml/core/CjsYamlReader.js +4 -6
- package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -1
- package/dist/formats/yaml/core/helpers.js +27 -1
- package/dist/formats/yaml/core/helpers.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/resource/CjsLoadingObject.js +19 -0
- package/dist/resource/CjsLoadingObject.js.map +1 -0
- package/dist/resource/CjsResource.js +4 -0
- package/dist/resource/CjsResource.js.map +1 -1
- package/dist/resource/ResourceHandlerMode.js +14 -0
- package/dist/resource/ResourceHandlerMode.js.map +1 -0
- package/dist/resource/index.js +2 -0
- package/dist/resource/index.js.map +1 -1
- package/dist/resource/shader/Tr2EffectRes.js +118 -213
- package/dist/resource/shader/Tr2EffectRes.js.map +1 -1
- package/dist/resource/shader/Tr2Shader.js +37 -15
- package/dist/resource/shader/Tr2Shader.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectConstant.js +37 -29
- package/dist/resource/shader/reflection/Tr2EffectConstant.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectDescription.js +39 -34
- package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js +51 -30
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +45 -25
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectResource.js +51 -17
- package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js +219 -88
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js +28 -18
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2Pass.js +96 -39
- package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
- package/dist/resource/shader/reflection/carbonRecordFields.js +159 -0
- package/dist/resource/shader/reflection/carbonRecordFields.js.map +1 -0
- package/dist/resource/shader/reflection/shaderStage.js +22 -0
- package/dist/resource/shader/reflection/shaderStage.js.map +1 -0
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js +68 -10
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -1
- package/dist/worker/CjsResManMainThreadLoader.js +9 -7
- package/dist/worker/CjsResManMainThreadLoader.js.map +1 -1
- package/dist/worker/CjsResManWorker.js +5 -4
- package/dist/worker/CjsResManWorker.js.map +1 -1
- package/dist/worker/CjsResManWorkerLoader.js +9 -6
- package/dist/worker/CjsResManWorkerLoader.js.map +1 -1
- package/docs/README.md +2 -2
- package/docs/architecture.md +12 -3
- package/docs/concepts/resource-lifecycle.md +9 -8
- package/docs/concepts/shader-resource-model.md +14 -17
- package/docs/concepts/writing-an-engine-adapter.md +1 -1
- package/docs/formats/README.md +4 -2
- package/docs/formats/carbon-effect-container.md +127 -26
- package/docs/formats/dxbc/architecture.md +1 -1
- package/docs/formats/dxbc/reference/api.md +28 -0
- package/docs/formats/hlsl/README.md +3 -3
- package/docs/formats/hlsl/architecture.md +8 -9
- package/docs/formats/hlsl/guides/hydrating-json-output.md +3 -5
- package/docs/formats/hlsl/guides/reading-effects.md +5 -1
- package/docs/formats/hlsl/reference/advanced-analysis.md +20 -25
- package/docs/formats/hlsl/reference/api.md +0 -7
- package/docs/formats/hlsl/reference/json-graph.md +1 -4
- package/docs/formats/pickle.md +82 -0
- package/docs/formats/webgl/README.md +71 -13
- package/docs/formats/webgl/architecture.md +16 -17
- package/docs/formats/webgl/carbon-constant-layouts.md +3 -3
- package/docs/formats/webgl/decl-io.md +3 -3
- package/docs/formats/webgl/memory-structured.md +27 -8
- package/docs/formats/webgl/texture-sample.md +1 -1
- package/docs/formats/webgpu/README.md +3 -3
- package/docs/formats/webgpu/architecture.md +5 -6
- package/docs/formats/webgpu/formats/{cewgpu.md → carbon-webgpu.md} +10 -11
- package/docs/formats/webgpu/guides/effect-packaging.md +6 -8
- package/docs/formats/webgpu/reference/api.md +11 -12
- package/docs/formats/webgpu/reference/wgsl-compatibility.md +11 -8
- package/docs/formats/wwise.md +63 -2
- package/docs/reference/classes/core.md +10 -0
- package/docs/reference/classes/formats.md +40 -48
- package/docs/reference/classes/resources.md +2 -2
- package/docs/reference/queues.md +88 -4
- package/docs/reference/workers.md +7 -0
- package/package.json +61 -61
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js +0 -372
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js.map +0 -1
- package/dist/format/effect/effectReflectionPackage.js +0 -636
- package/dist/format/effect/effectReflectionPackage.js.map +0 -1
- package/dist/formats/hlsl/core/HlslReader.js +0 -16
- package/dist/formats/hlsl/core/HlslReader.js.map +0 -1
- package/dist/formats/hlsl/core/portableReflection.js +0 -848
- package/dist/formats/hlsl/core/portableReflection.js.map +0 -1
- package/dist/formats/hlsl/portable.js +0 -2
- package/dist/formats/hlsl/portable.js.map +0 -1
- package/dist/formats/webgl/core/cewg/CewgPackage.js +0 -340
- package/dist/formats/webgl/core/cewg/CewgPackage.js.map +0 -1
- package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js +0 -104
- package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js.map +0 -1
- package/dist/formats/webgl/core/cewg/binary.js +0 -19
- package/dist/formats/webgl/core/cewg/binary.js.map +0 -1
- package/dist/formats/webgl/core/cewgCompleteness.js.map +0 -1
- package/dist/formats/webgl/core/effectPackageValidation.js +0 -331
- package/dist/formats/webgl/core/effectPackageValidation.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/containerViews.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/validateContainer.js.map +0 -1
- package/dist/resource/shader/portable.js +0 -33
- package/dist/resource/shader/portable.js.map +0 -1
- package/docs/formats/hlsl/reference/portable-reflection.md +0 -141
- package/docs/formats/webgl/effect-reflection.md +0 -127
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { CjsCarbonEffectReader } from '../../../format/carbonEffect/CjsCarbonEffectReader.js';
|
|
2
|
+
import { readGlslBackendBlock } from './glslBackendBlock.js';
|
|
3
|
+
import { hlslShaderStageName } from '../../hlsl/core/tr2/HlslRenderContextEnum.js';
|
|
4
|
+
import { runtimeDescriptionFromCarbon } from '../../hlsl/core/carbonDescriptionToRuntime.js';
|
|
5
|
+
import { HlslEffectBindingManifest } from '../../hlsl/core/tr2/shader/HlslEffectBindingManifest.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Decodes a WebGL effect container into the stage/shader records the
|
|
9
|
+
* completeness rules consume.
|
|
10
|
+
*
|
|
11
|
+
* This exists so the rules run from container bytes alone. The alternative was
|
|
12
|
+
* to hand them the in-memory translation, which works inside `buildEffectPackage`
|
|
13
|
+
* and nowhere else — the validator reads a finished file and has no translation
|
|
14
|
+
* in scope. That would have cost the validator its completeness check while
|
|
15
|
+
* still requiring a decoder to produce the programs it compiles in a browser, so
|
|
16
|
+
* it was strictly more work for strictly less checking.
|
|
17
|
+
*
|
|
18
|
+
* The vocabulary is deliberately the one the rules already speak — `stages` with
|
|
19
|
+
* pass coordinates, `shaders` with source and a translation verdict. The rules
|
|
20
|
+
* are about the translation, not about how it was stored, so retargeting them
|
|
21
|
+
* meant changing where the records come from and nothing about what they mean.
|
|
22
|
+
*
|
|
23
|
+
* **What the wire cannot tell you.** `buildCarbonEffectContainer` stores a body
|
|
24
|
+
* the translator could not lower as its full pass tree with zero-length
|
|
25
|
+
* programs; the *reason* it failed stays in the in-memory build result and is
|
|
26
|
+
* never written. So a shader decoded from bytes reports `ok: false` with
|
|
27
|
+
* "no program was stored" and nothing more specific. That is the honest answer:
|
|
28
|
+
* a file on disk does not know why a translation failed months ago. Callers that
|
|
29
|
+
* do know — `buildEffectPackage`, at build time — keep their specific
|
|
30
|
+
* diagnostics by feeding the rules their own records instead.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/** The verdict a stage carrying no stored program gets. */
|
|
34
|
+
const NO_PROGRAM_REASON = "no program was stored";
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Derives the per-stage binding manifests for one body through the one
|
|
38
|
+
* manifest builder the source path uses.
|
|
39
|
+
*
|
|
40
|
+
* This replaces a hand-built reshape of the wire records into the manifest
|
|
41
|
+
* vocabulary. That copy had already diverged from the real manifest once —
|
|
42
|
+
* `isAutoregister` was silently dropped, making every resource look
|
|
43
|
+
* user-settable — which is the whole argument against a second producer: two
|
|
44
|
+
* hand-maintained spellings of one reflection drift, and the drift is exactly
|
|
45
|
+
* the kind of bug that draws, links and renders black without an error. The
|
|
46
|
+
* record tree now flows through `runtimeDescriptionFromCarbon` — the
|
|
47
|
+
* corpus-proven adapter the runtime read path uses — and
|
|
48
|
+
* `HlslEffectBindingManifest`, so the container read and the build-time
|
|
49
|
+
* package derive their manifests from the same code.
|
|
50
|
+
*
|
|
51
|
+
* No `bytecodeFor` is supplied: program text lives in the shader records this
|
|
52
|
+
* reader emits, so the manifest's `shaderBytecode` stays null rather than
|
|
53
|
+
* duplicating every program into the reflection.
|
|
54
|
+
*
|
|
55
|
+
* @param {object} description Decoded Carbon description record tree.
|
|
56
|
+
* @param {number} version Container data version.
|
|
57
|
+
* @param {string} source Source name for diagnostics.
|
|
58
|
+
* @returns {Map<string, object>} Manifest stage records keyed by
|
|
59
|
+
* `technique.passN.stageName`.
|
|
60
|
+
*/
|
|
61
|
+
function bodyManifestStages(description, version, source) {
|
|
62
|
+
const runtime = runtimeDescriptionFromCarbon(description, {
|
|
63
|
+
effectName: source,
|
|
64
|
+
version
|
|
65
|
+
});
|
|
66
|
+
const manifest = HlslEffectBindingManifest.fromEffectDescription(runtime).toJSON();
|
|
67
|
+
return new Map(manifest.stages.map(stage => [`${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`, stage]));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Decodes one pass's backend block, tolerating a pass that has none.
|
|
72
|
+
*
|
|
73
|
+
* @param {object} pass Decoded pass record.
|
|
74
|
+
* @param {string} passKey Enclosing pass key.
|
|
75
|
+
* @param {string} source Source name for error details.
|
|
76
|
+
* @returns {object} Per-stage backend data, keyed by stage name.
|
|
77
|
+
*/
|
|
78
|
+
function backendStages(pass, passKey, source) {
|
|
79
|
+
if (!pass.backendBlock?.size) return {
|
|
80
|
+
stages: {},
|
|
81
|
+
transforms: []
|
|
82
|
+
};
|
|
83
|
+
const block = readGlslBackendBlock(pass.backendBlock.bytes, {
|
|
84
|
+
layoutKey: passKey,
|
|
85
|
+
source
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
stages: block.stages ?? {},
|
|
89
|
+
transforms: block.transforms ?? []
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Decodes container bytes into stage and shader records.
|
|
95
|
+
*
|
|
96
|
+
* Bodies are decoded once each rather than once per permutation row: rows alias
|
|
97
|
+
* onto shared bodies, and a rule that saw the same body 4,096 times would report
|
|
98
|
+
* 4,096 identical incomplete passes.
|
|
99
|
+
*
|
|
100
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Container payload.
|
|
101
|
+
* @param {object} [values] Read values.
|
|
102
|
+
* @param {string} [values.source] Source name, for diagnostics.
|
|
103
|
+
* @returns {{stages:object[], shaders:object[], recordCount:number, bodyCount:number}}
|
|
104
|
+
* Stage graph in the completeness rules' vocabulary.
|
|
105
|
+
*/
|
|
106
|
+
function readGlslEffectContainer(input, values = {}) {
|
|
107
|
+
const source = values.source ?? "memory";
|
|
108
|
+
const reader = new CjsCarbonEffectReader(input, {
|
|
109
|
+
source
|
|
110
|
+
});
|
|
111
|
+
const stages = [];
|
|
112
|
+
const shaders = [];
|
|
113
|
+
const bodyKeyByOffset = new Map();
|
|
114
|
+
|
|
115
|
+
// Every permutation index that resolves to each body.
|
|
116
|
+
//
|
|
117
|
+
// This is the bridge a caller actually needs, and the only one that is
|
|
118
|
+
// sound. `bodyKey` here is this reader's own ordinal spelling; the
|
|
119
|
+
// permutation graph mints `body${N}` for the same body, and the two are not
|
|
120
|
+
// merely spelled differently — the graph dedupes by content (SHA-256 plus
|
|
121
|
+
// byte equality) while this reader dedupes by source-record offset. Those
|
|
122
|
+
// partitions coincide only because the container writer aliases
|
|
123
|
+
// byte-identical bodies onto one offset, which is a property of the writer
|
|
124
|
+
// rather than a contract.
|
|
125
|
+
//
|
|
126
|
+
// So a consumer must never map between the two by string surgery on either
|
|
127
|
+
// spelling, and must not assume the two ordinal sequences agree. It holds a
|
|
128
|
+
// permutation index; this gives it the body directly.
|
|
129
|
+
const permutationIndicesByOffset = new Map();
|
|
130
|
+
for (let index = 0; index < reader.records.length; index += 1) {
|
|
131
|
+
const {
|
|
132
|
+
offset
|
|
133
|
+
} = reader.records[index];
|
|
134
|
+
const seen = permutationIndicesByOffset.get(offset);
|
|
135
|
+
if (seen) seen.push(index);else permutationIndicesByOffset.set(offset, [index]);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Distinct program texts share one shader record, so `shaders` counts unique
|
|
139
|
+
// translations the way the chunk package's shader table did. Empty stages are
|
|
140
|
+
// deliberately *not* pooled: each keeps its own record so a report can name
|
|
141
|
+
// every pass that is missing a program rather than one shared "absent".
|
|
142
|
+
//
|
|
143
|
+
// The pool key is the program text *and* the backend reflection that came
|
|
144
|
+
// with it, not the text alone. A pooled record carries the bindings and
|
|
145
|
+
// stage inputs of whichever stage was seen first, and
|
|
146
|
+
// `validateShaderRuntimeContract` judges the emitted GLSL against them — so
|
|
147
|
+
// pooling on text alone would let two stages with identical source but
|
|
148
|
+
// different reflection be checked against the wrong metadata, silently. It
|
|
149
|
+
// is unlikely that identical GLSL ever carries different reflection, which
|
|
150
|
+
// is exactly why it would not be noticed.
|
|
151
|
+
const shaderKeyByIdentity = new Map();
|
|
152
|
+
for (let index = 0; index < reader.records.length; index += 1) {
|
|
153
|
+
const {
|
|
154
|
+
offset
|
|
155
|
+
} = reader.records[index];
|
|
156
|
+
if (bodyKeyByOffset.has(offset)) continue;
|
|
157
|
+
const bodyKey = `body_${bodyKeyByOffset.size}`;
|
|
158
|
+
bodyKeyByOffset.set(offset, bodyKey);
|
|
159
|
+
const description = reader.readDescription(index, {
|
|
160
|
+
backend: true
|
|
161
|
+
});
|
|
162
|
+
const manifestStages = bodyManifestStages(description, reader.version, source);
|
|
163
|
+
for (const technique of description.techniques) {
|
|
164
|
+
const techniqueName = technique.name.value;
|
|
165
|
+
for (const [passIndex, pass] of technique.passes.entries()) {
|
|
166
|
+
const passKey = `${techniqueName}.pass${passIndex}`;
|
|
167
|
+
const {
|
|
168
|
+
stages: backend,
|
|
169
|
+
transforms
|
|
170
|
+
} = backendStages(pass, passKey, source);
|
|
171
|
+
for (const stage of pass.stages) {
|
|
172
|
+
const name = hlslShaderStageName(stage.type);
|
|
173
|
+
const stageKey = `${bodyKey}.${passKey}.${name}`;
|
|
174
|
+
const stageBackend = backend[name] ?? {};
|
|
175
|
+
let shaderKey;
|
|
176
|
+
if (stage.shaderData?.size) {
|
|
177
|
+
const code = new TextDecoder().decode(stage.shaderData.bytes);
|
|
178
|
+
const identity = `${JSON.stringify([stageBackend.bindings ?? [], stageBackend.stageInputs ?? [], stageBackend.computeFragment ?? null])} ${code}`;
|
|
179
|
+
const pooled = shaderKeyByIdentity.get(identity);
|
|
180
|
+
if (pooled) {
|
|
181
|
+
shaderKey = pooled;
|
|
182
|
+
} else {
|
|
183
|
+
shaderKey = `shader_${shaderKeyByIdentity.size}`;
|
|
184
|
+
shaderKeyByIdentity.set(identity, shaderKey);
|
|
185
|
+
shaders.push({
|
|
186
|
+
key: shaderKey,
|
|
187
|
+
stageName: name,
|
|
188
|
+
source: code,
|
|
189
|
+
hlsl2webgl: {
|
|
190
|
+
ok: true
|
|
191
|
+
},
|
|
192
|
+
bindings: stageBackend.bindings ?? [],
|
|
193
|
+
stageInputs: stageBackend.stageInputs ?? [],
|
|
194
|
+
...(stageBackend.computeFragment ? {
|
|
195
|
+
computeFragment: stageBackend.computeFragment
|
|
196
|
+
} : {})
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
shaderKey = `${stageKey}.absent`;
|
|
201
|
+
shaders.push({
|
|
202
|
+
key: shaderKey,
|
|
203
|
+
stageName: name,
|
|
204
|
+
source: "",
|
|
205
|
+
hlsl2webgl: {
|
|
206
|
+
ok: false,
|
|
207
|
+
reason: NO_PROGRAM_REASON
|
|
208
|
+
},
|
|
209
|
+
bindings: stageBackend.bindings ?? [],
|
|
210
|
+
stageInputs: stageBackend.stageInputs ?? []
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
stages.push({
|
|
214
|
+
key: stageKey,
|
|
215
|
+
bodyKey,
|
|
216
|
+
techniqueName,
|
|
217
|
+
passIndex,
|
|
218
|
+
stageName: name,
|
|
219
|
+
stageType: stage.type,
|
|
220
|
+
shaderKey,
|
|
221
|
+
manifest: manifestStages.get(`${passKey}.${name}`) ?? null,
|
|
222
|
+
// The pass's transforms, so a rule can ask whether a
|
|
223
|
+
// description resource was merged away rather than lost.
|
|
224
|
+
transforms
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Ordered by first appearance, matching `bodyKey`'s ordinal.
|
|
232
|
+
const bodies = [];
|
|
233
|
+
for (const [offset, key] of bodyKeyByOffset) {
|
|
234
|
+
bodies.push({
|
|
235
|
+
key,
|
|
236
|
+
permutationIndices: Object.freeze(permutationIndicesByOffset.get(offset) ?? [])
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
stages,
|
|
241
|
+
shaders,
|
|
242
|
+
bodies,
|
|
243
|
+
recordCount: reader.records.length,
|
|
244
|
+
bodyCount: bodyKeyByOffset.size
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export { readGlslEffectContainer };
|
|
249
|
+
//# sourceMappingURL=readGlslEffectContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readGlslEffectContainer.js","sources":["../../../../../src/formats/webgl/core/readGlslEffectContainer.js"],"sourcesContent":["import { CjsCarbonEffectReader } from \"../../../format/carbonEffect/CjsCarbonEffectReader.js\";\r\nimport { readGlslBackendBlock } from \"./glslBackendBlock.js\";\r\nimport { hlslShaderStageName } from \"../../hlsl/core/tr2/HlslRenderContextEnum.js\";\r\nimport { runtimeDescriptionFromCarbon } from \"../../hlsl/core/carbonDescriptionToRuntime.js\";\r\nimport { HlslEffectBindingManifest } from \"../../hlsl/core/tr2/shader/HlslEffectBindingManifest.js\";\r\n\r\n/**\r\n * Decodes a WebGL effect container into the stage/shader records the\r\n * completeness rules consume.\r\n *\r\n * This exists so the rules run from container bytes alone. The alternative was\r\n * to hand them the in-memory translation, which works inside `buildEffectPackage`\r\n * and nowhere else — the validator reads a finished file and has no translation\r\n * in scope. That would have cost the validator its completeness check while\r\n * still requiring a decoder to produce the programs it compiles in a browser, so\r\n * it was strictly more work for strictly less checking.\r\n *\r\n * The vocabulary is deliberately the one the rules already speak — `stages` with\r\n * pass coordinates, `shaders` with source and a translation verdict. The rules\r\n * are about the translation, not about how it was stored, so retargeting them\r\n * meant changing where the records come from and nothing about what they mean.\r\n *\r\n * **What the wire cannot tell you.** `buildCarbonEffectContainer` stores a body\r\n * the translator could not lower as its full pass tree with zero-length\r\n * programs; the *reason* it failed stays in the in-memory build result and is\r\n * never written. So a shader decoded from bytes reports `ok: false` with\r\n * \"no program was stored\" and nothing more specific. That is the honest answer:\r\n * a file on disk does not know why a translation failed months ago. Callers that\r\n * do know — `buildEffectPackage`, at build time — keep their specific\r\n * diagnostics by feeding the rules their own records instead.\r\n */\r\n\r\n/** The verdict a stage carrying no stored program gets. */\r\nconst NO_PROGRAM_REASON = \"no program was stored\";\r\n\r\n/**\r\n * Derives the per-stage binding manifests for one body through the one\r\n * manifest builder the source path uses.\r\n *\r\n * This replaces a hand-built reshape of the wire records into the manifest\r\n * vocabulary. That copy had already diverged from the real manifest once —\r\n * `isAutoregister` was silently dropped, making every resource look\r\n * user-settable — which is the whole argument against a second producer: two\r\n * hand-maintained spellings of one reflection drift, and the drift is exactly\r\n * the kind of bug that draws, links and renders black without an error. The\r\n * record tree now flows through `runtimeDescriptionFromCarbon` — the\r\n * corpus-proven adapter the runtime read path uses — and\r\n * `HlslEffectBindingManifest`, so the container read and the build-time\r\n * package derive their manifests from the same code.\r\n *\r\n * No `bytecodeFor` is supplied: program text lives in the shader records this\r\n * reader emits, so the manifest's `shaderBytecode` stays null rather than\r\n * duplicating every program into the reflection.\r\n *\r\n * @param {object} description Decoded Carbon description record tree.\r\n * @param {number} version Container data version.\r\n * @param {string} source Source name for diagnostics.\r\n * @returns {Map<string, object>} Manifest stage records keyed by\r\n * `technique.passN.stageName`.\r\n */\r\nfunction bodyManifestStages(description, version, source)\r\n{\r\n const runtime = runtimeDescriptionFromCarbon(description, {\r\n effectName: source,\r\n version\r\n });\r\n const manifest = HlslEffectBindingManifest.fromEffectDescription(runtime).toJSON();\r\n return new Map(manifest.stages.map((stage) => [\r\n `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`,\r\n stage\r\n ]));\r\n}\r\n\r\n/**\r\n * Decodes one pass's backend block, tolerating a pass that has none.\r\n *\r\n * @param {object} pass Decoded pass record.\r\n * @param {string} passKey Enclosing pass key.\r\n * @param {string} source Source name for error details.\r\n * @returns {object} Per-stage backend data, keyed by stage name.\r\n */\r\nfunction backendStages(pass, passKey, source)\r\n{\r\n if (!pass.backendBlock?.size) return { stages: {}, transforms: [] };\r\n const block = readGlslBackendBlock(pass.backendBlock.bytes, { layoutKey: passKey, source });\r\n return { stages: block.stages ?? {}, transforms: block.transforms ?? [] };\r\n}\r\n\r\n/**\r\n * Decodes container bytes into stage and shader records.\r\n *\r\n * Bodies are decoded once each rather than once per permutation row: rows alias\r\n * onto shared bodies, and a rule that saw the same body 4,096 times would report\r\n * 4,096 identical incomplete passes.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Container payload.\r\n * @param {object} [values] Read values.\r\n * @param {string} [values.source] Source name, for diagnostics.\r\n * @returns {{stages:object[], shaders:object[], recordCount:number, bodyCount:number}}\r\n * Stage graph in the completeness rules' vocabulary.\r\n */\r\nexport function readGlslEffectContainer(input, values = {})\r\n{\r\n const source = values.source ?? \"memory\";\r\n const reader = new CjsCarbonEffectReader(input, { source });\r\n\r\n const stages = [];\r\n const shaders = [];\r\n const bodyKeyByOffset = new Map();\r\n\r\n // Every permutation index that resolves to each body.\r\n //\r\n // This is the bridge a caller actually needs, and the only one that is\r\n // sound. `bodyKey` here is this reader's own ordinal spelling; the\r\n // permutation graph mints `body${N}` for the same body, and the two are not\r\n // merely spelled differently — the graph dedupes by content (SHA-256 plus\r\n // byte equality) while this reader dedupes by source-record offset. Those\r\n // partitions coincide only because the container writer aliases\r\n // byte-identical bodies onto one offset, which is a property of the writer\r\n // rather than a contract.\r\n //\r\n // So a consumer must never map between the two by string surgery on either\r\n // spelling, and must not assume the two ordinal sequences agree. It holds a\r\n // permutation index; this gives it the body directly.\r\n const permutationIndicesByOffset = new Map();\r\n\r\n for (let index = 0; index < reader.records.length; index += 1)\r\n {\r\n const { offset } = reader.records[index];\r\n const seen = permutationIndicesByOffset.get(offset);\r\n if (seen) seen.push(index);\r\n else permutationIndicesByOffset.set(offset, [ index ]);\r\n }\r\n\r\n // Distinct program texts share one shader record, so `shaders` counts unique\r\n // translations the way the chunk package's shader table did. Empty stages are\r\n // deliberately *not* pooled: each keeps its own record so a report can name\r\n // every pass that is missing a program rather than one shared \"absent\".\r\n //\r\n // The pool key is the program text *and* the backend reflection that came\r\n // with it, not the text alone. A pooled record carries the bindings and\r\n // stage inputs of whichever stage was seen first, and\r\n // `validateShaderRuntimeContract` judges the emitted GLSL against them — so\r\n // pooling on text alone would let two stages with identical source but\r\n // different reflection be checked against the wrong metadata, silently. It\r\n // is unlikely that identical GLSL ever carries different reflection, which\r\n // is exactly why it would not be noticed.\r\n const shaderKeyByIdentity = new Map();\r\n\r\n for (let index = 0; index < reader.records.length; index += 1)\r\n {\r\n const { offset } = reader.records[index];\r\n if (bodyKeyByOffset.has(offset)) continue;\r\n\r\n const bodyKey = `body_${bodyKeyByOffset.size}`;\r\n bodyKeyByOffset.set(offset, bodyKey);\r\n\r\n const description = reader.readDescription(index, { backend: true });\r\n const manifestStages = bodyManifestStages(description, reader.version, source);\r\n\r\n for (const technique of description.techniques)\r\n {\r\n const techniqueName = technique.name.value;\r\n for (const [ passIndex, pass ] of technique.passes.entries())\r\n {\r\n const passKey = `${techniqueName}.pass${passIndex}`;\r\n const { stages: backend, transforms } = backendStages(\r\n pass,\r\n passKey,\r\n source\r\n );\r\n\r\n for (const stage of pass.stages)\r\n {\r\n const name = hlslShaderStageName(stage.type);\r\n const stageKey = `${bodyKey}.${passKey}.${name}`;\r\n const stageBackend = backend[name] ?? {};\r\n\r\n let shaderKey;\r\n if (stage.shaderData?.size)\r\n {\r\n const code = new TextDecoder().decode(stage.shaderData.bytes);\r\n const identity = `${JSON.stringify([\r\n stageBackend.bindings ?? [],\r\n stageBackend.stageInputs ?? [],\r\n stageBackend.computeFragment ?? null\r\n ])} ${code}`;\r\n const pooled = shaderKeyByIdentity.get(identity);\r\n if (pooled)\r\n {\r\n shaderKey = pooled;\r\n }\r\n else\r\n {\r\n shaderKey = `shader_${shaderKeyByIdentity.size}`;\r\n shaderKeyByIdentity.set(identity, shaderKey);\r\n shaders.push({\r\n key: shaderKey,\r\n stageName: name,\r\n source: code,\r\n hlsl2webgl: { ok: true },\r\n bindings: stageBackend.bindings ?? [],\r\n stageInputs: stageBackend.stageInputs ?? [],\r\n ...(stageBackend.computeFragment\r\n ? { computeFragment: stageBackend.computeFragment }\r\n : {})\r\n });\r\n }\r\n }\r\n else\r\n {\r\n shaderKey = `${stageKey}.absent`;\r\n shaders.push({\r\n key: shaderKey,\r\n stageName: name,\r\n source: \"\",\r\n hlsl2webgl: { ok: false, reason: NO_PROGRAM_REASON },\r\n bindings: stageBackend.bindings ?? [],\r\n stageInputs: stageBackend.stageInputs ?? []\r\n });\r\n }\r\n\r\n stages.push({\r\n key: stageKey,\r\n bodyKey,\r\n techniqueName,\r\n passIndex,\r\n stageName: name,\r\n stageType: stage.type,\r\n shaderKey,\r\n manifest: manifestStages.get(`${passKey}.${name}`) ?? null,\r\n // The pass's transforms, so a rule can ask whether a\r\n // description resource was merged away rather than lost.\r\n transforms\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Ordered by first appearance, matching `bodyKey`'s ordinal.\r\n const bodies = [];\r\n for (const [ offset, key ] of bodyKeyByOffset)\r\n {\r\n bodies.push({\r\n key,\r\n permutationIndices: Object.freeze(permutationIndicesByOffset.get(offset) ?? [])\r\n });\r\n }\r\n\r\n return {\r\n stages,\r\n shaders,\r\n bodies,\r\n recordCount: reader.records.length,\r\n bodyCount: bodyKeyByOffset.size\r\n };\r\n}\r\n\r\nexport default readGlslEffectContainer;\r\n"],"names":["NO_PROGRAM_REASON","bodyManifestStages","description","version","source","runtime","runtimeDescriptionFromCarbon","effectName","manifest","HlslEffectBindingManifest","fromEffectDescription","toJSON","Map","stages","map","stage","techniqueName","passIndex","stageName","backendStages","pass","passKey","backendBlock","size","transforms","block","readGlslBackendBlock","bytes","layoutKey","readGlslEffectContainer","input","values","reader","CjsCarbonEffectReader","shaders","bodyKeyByOffset","permutationIndicesByOffset","index","records","length","offset","seen","get","push","set","shaderKeyByIdentity","has","bodyKey","readDescription","backend","manifestStages","technique","techniques","name","value","passes","entries","hlslShaderStageName","type","stageKey","stageBackend","shaderKey","shaderData","code","TextDecoder","decode","identity","JSON","stringify","bindings","stageInputs","computeFragment","pooled","key","hlsl2webgl","ok","reason","stageType","bodies","permutationIndices","Object","freeze","recordCount","bodyCount"],"mappings":";;;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,MAAMA,iBAAiB,GAAG,uBAAuB;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,kBAAkBA,CAACC,WAAW,EAAEC,OAAO,EAAEC,MAAM,EACxD;AACI,EAAA,MAAMC,OAAO,GAAGC,4BAA4B,CAACJ,WAAW,EAAE;AACtDK,IAAAA,UAAU,EAAEH,MAAM;AAClBD,IAAAA;AACJ,GAAC,CAAC;EACF,MAAMK,QAAQ,GAAGC,yBAAyB,CAACC,qBAAqB,CAACL,OAAO,CAAC,CAACM,MAAM,EAAE;AAClF,EAAA,OAAO,IAAIC,GAAG,CAACJ,QAAQ,CAACK,MAAM,CAACC,GAAG,CAAEC,KAAK,IAAK,CAC1C,CAAA,EAAGA,KAAK,CAACC,aAAa,CAAA,KAAA,EAAQD,KAAK,CAACE,SAAS,CAAA,CAAA,EAAIF,KAAK,CAACG,SAAS,CAAA,CAAE,EAClEH,KAAK,CACR,CAAC,CAAC;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,aAAaA,CAACC,IAAI,EAAEC,OAAO,EAAEjB,MAAM,EAC5C;AACI,EAAA,IAAI,CAACgB,IAAI,CAACE,YAAY,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EACA,MAAMsD,MAAM,GAAG,EAAE;EACjB,KAAK,MAAM,CAAEtC,MAAM,EAAEiC,GAAG,CAAE,IAAItC,eAAe,EAC7C;IACI2C,MAAM,CAACnC,IAAI,CAAC;MACR8B,GAAG;AACHM,MAAAA,kBAAkB,EAAEC,MAAM,CAACC,MAAM,CAAC7C,0BAA0B,CAACM,GAAG,CAACF,MAAM,CAAC,IAAI,EAAE;AAClF,KAAC,CAAC;AACN,EAAA;EAEA,OAAO;IACH3B,MAAM;IACNqB,OAAO;IACP4C,MAAM;AACNI,IAAAA,WAAW,EAAElD,MAAM,CAACM,OAAO,CAACC,MAAM;IAClC4C,SAAS,EAAEhD,eAAe,CAACZ;GAC9B;AACL;;;;"}
|
|
@@ -5,12 +5,12 @@ import { buildWgslBindingPlan } from './core/wgsl/buildWgslBindingPlan.js';
|
|
|
5
5
|
import { buildWgslSet } from './core/wgsl/buildWgslSet.js';
|
|
6
6
|
import { buildEffectPackage } from './core/packageEffect.js';
|
|
7
7
|
import { FORMAT_WEBGPU_PACKAGE_VERSION } from './core/packageMetadata.js';
|
|
8
|
-
import { DEFAULT_VALUES, normalizeValues, validateClassKey, validateClass, readWithValues, inspectWithValues, analyzeEffectWithValues, toJsonValue,
|
|
8
|
+
import { DEFAULT_VALUES, normalizeValues, validateClassKey, validateClass, readWithValues, inspectWithValues, analyzeEffectWithValues, toJsonValue, isCarbonWebgpu, OUTPUT_JSON, OUTPUT_RAW, CARBON_WEBGPU_FORMAT, CARBON_WEBGPU_ANALYSIS_FORMAT } from './core/helpers.js';
|
|
9
9
|
|
|
10
10
|
const FORMAT_NAME = "CjsWebgpuFormat";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* CarbonEngineJS-facing format surface for `.
|
|
13
|
+
* CarbonEngineJS-facing format surface for `.carbonwebgpu` WebGPU packages, plus an
|
|
14
14
|
* offline effect-analysis helper built on the runtime-resource HLSL and DXBC
|
|
15
15
|
* format subpaths.
|
|
16
16
|
*
|
|
@@ -124,9 +124,9 @@ class CjsWebgpuFormat {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
|
-
* Read a
|
|
127
|
+
* Read a Carbon WebGPU package with this profile's values.
|
|
128
128
|
*
|
|
129
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input
|
|
129
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU package bytes.
|
|
130
130
|
* @param {object} [options] Per-call value overrides.
|
|
131
131
|
* @returns {object} Plain JSON data, or the raw package instance when emit is "raw".
|
|
132
132
|
*/
|
|
@@ -135,9 +135,9 @@ class CjsWebgpuFormat {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
|
-
* Inspect a
|
|
138
|
+
* Inspect a Carbon WebGPU package without building the full JSON shape.
|
|
139
139
|
*
|
|
140
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input
|
|
140
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU package bytes.
|
|
141
141
|
* @param {object} [options] Per-call value overrides.
|
|
142
142
|
* @returns {object} Plain summary data.
|
|
143
143
|
*/
|
|
@@ -158,7 +158,7 @@ class CjsWebgpuFormat {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
|
-
* Builds a
|
|
161
|
+
* Builds a Carbon WebGPU package with complete version-15 source reflection and
|
|
162
162
|
* selected-body WebGPU output from compiled Tr2 effect bytes.
|
|
163
163
|
*
|
|
164
164
|
* @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.
|
|
@@ -236,14 +236,14 @@ class CjsWebgpuFormat {
|
|
|
236
236
|
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate bytes.
|
|
237
237
|
* @returns {boolean} True when the payload has Carbon's version-15 shape.
|
|
238
238
|
*/
|
|
239
|
-
static
|
|
240
|
-
return
|
|
239
|
+
static isCarbonWebgpu(input) {
|
|
240
|
+
return isCarbonWebgpu(input);
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
/**
|
|
244
244
|
* Static one-shot read.
|
|
245
245
|
*
|
|
246
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input
|
|
246
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU package bytes.
|
|
247
247
|
* @param {object} [options] Format values.
|
|
248
248
|
* @returns {object} Plain JSON data, or the raw package instance when emit is "raw".
|
|
249
249
|
*/
|
|
@@ -254,7 +254,7 @@ class CjsWebgpuFormat {
|
|
|
254
254
|
/**
|
|
255
255
|
* Static one-shot inspection.
|
|
256
256
|
*
|
|
257
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input
|
|
257
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU package bytes.
|
|
258
258
|
* @param {object} [options] Format values.
|
|
259
259
|
* @returns {object} Plain summary data.
|
|
260
260
|
*/
|
|
@@ -274,7 +274,7 @@ class CjsWebgpuFormat {
|
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
/**
|
|
277
|
-
* Static selected-body
|
|
277
|
+
* Static selected-body Carbon WebGPU builder.
|
|
278
278
|
*
|
|
279
279
|
* @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.
|
|
280
280
|
* @param {object} [options] Source, body-mode, permutation, and stage-selection policy.
|
|
@@ -344,12 +344,12 @@ class CjsWebgpuFormat {
|
|
|
344
344
|
static CLASS_KEYS = CLASS_KEYS;
|
|
345
345
|
static type = Object.freeze(["shader"]);
|
|
346
346
|
static mediaTypes = Object.freeze(["shader"]);
|
|
347
|
-
static inputTypes = Object.freeze(["
|
|
347
|
+
static inputTypes = Object.freeze(["carbonwebgpu"]);
|
|
348
348
|
static outputTypes = Object.freeze([OUTPUT_JSON]);
|
|
349
349
|
static debugOutputTypes = Object.freeze([OUTPUT_RAW]);
|
|
350
350
|
static implementationStatus = "partial";
|
|
351
|
-
static format =
|
|
352
|
-
static analysisFormat =
|
|
351
|
+
static format = CARBON_WEBGPU_FORMAT;
|
|
352
|
+
static analysisFormat = CARBON_WEBGPU_ANALYSIS_FORMAT;
|
|
353
353
|
static packageVersion = FORMAT_WEBGPU_PACKAGE_VERSION;
|
|
354
354
|
}
|
|
355
355
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CjsWebgpuFormat.js","sources":["../../../../src/formats/webgpu/CjsWebgpuFormat.js"],"sourcesContent":["import { CLASS_KEYS } from \"./core/schema.js\";\nimport { lowerDxbcToIr } from \"./core/ir/lowerDxbcToIr.js\";\nimport { buildWgsl } from \"./core/wgsl/emitWgsl.js\";\nimport { buildWgslBindingPlan } from \"./core/wgsl/buildWgslBindingPlan.js\";\nimport { buildWgslSet } from \"./core/wgsl/buildWgslSet.js\";\nimport { buildEffectPackage } from \"./core/packageEffect.js\";\nimport { FORMAT_WEBGPU_PACKAGE_VERSION } from \"./core/packageMetadata.js\";\nimport {\n CEWGPU_ANALYSIS_FORMAT,\n CEWGPU_FORMAT,\n DEFAULT_VALUES,\n OUTPUT_JSON,\n OUTPUT_RAW,\n analyzeEffectWithValues,\n inspectWithValues,\n isCewgpu,\n normalizeValues,\n readWithValues,\n toJsonValue,\n validateClass,\n validateClassKey\n} from \"./core/helpers.js\";\n\nconst FORMAT_NAME = \"CjsWebgpuFormat\";\n\n/**\n * CarbonEngineJS-facing format surface for `.cewgpu` WebGPU packages, plus an\n * offline effect-analysis helper built on the runtime-resource HLSL and DXBC\n * format subpaths.\n *\n * The package owns read/build, normalized shader analysis, and the current\n * bounded DXBC-to-WGSL profiles. Broader shader-semantic coverage remains an\n * explicit qualification ladder.\n */\nexport class CjsWebgpuFormat\n{\n #emit = DEFAULT_VALUES.emit;\n #source = DEFAULT_VALUES.source;\n #decodeInstructions = DEFAULT_VALUES.decodeInstructions;\n #permutation = DEFAULT_VALUES.permutation;\n #schema = DEFAULT_VALUES.schema;\n #classes = {};\n\n /**\n * Create a reusable format profile.\n *\n * @param {object} [options] Default format values.\n */\n constructor(options = {})\n {\n this.SetValues(options);\n }\n\n /**\n * Set format values for this reusable profile.\n *\n * @param {object} [options] Values to merge into the profile.\n * @returns {CjsWebgpuFormat} This format profile.\n */\n SetValues(options = {})\n {\n const values = normalizeValues(this.GetValues(), options, CLASS_KEYS, FORMAT_NAME);\n this.#emit = values.emit;\n this.#source = values.source;\n this.#decodeInstructions = values.decodeInstructions;\n this.#permutation = values.permutation;\n this.#schema = values.schema;\n this.#classes = values.classes;\n return this;\n }\n\n /**\n * Get this profile's current values, optionally with per-call overrides.\n *\n * @param {object} [options] Optional values to merge into a copy.\n * @returns {object} A copy of the effective values.\n */\n GetValues(options = {})\n {\n return normalizeValues({\n emit: this.#emit,\n source: this.#source,\n decodeInstructions: this.#decodeInstructions,\n permutation: this.#permutation,\n schema: this.#schema,\n classes: this.#classes\n }, options, CLASS_KEYS, FORMAT_NAME);\n }\n\n /**\n * Set multiple node-class constructors for this profile.\n *\n * @param {object} [classes] Map of node class keys to constructors.\n * @returns {CjsWebgpuFormat} This format profile.\n */\n SetClasses(classes = {})\n {\n return this.SetValues({ classes });\n }\n\n /**\n * Set one node-class constructor for this profile.\n *\n * @param {string} type Node class key.\n * @param {Function|null|undefined} Class constructor to use, or nullish to delete.\n * @returns {CjsWebgpuFormat} This format profile.\n */\n SetClass(type, Class)\n {\n validateClassKey(CLASS_KEYS, type, FORMAT_NAME);\n if (Class === null || Class === undefined)\n {\n delete this.#classes[type];\n return this;\n }\n\n validateClass(CLASS_KEYS, type, Class, FORMAT_NAME);\n this.#classes = { ...this.#classes, [type]: Class };\n return this;\n }\n\n /**\n * Get a configured node-class constructor.\n *\n * @param {string} type Node class key.\n * @returns {Function|undefined} The registered constructor, if any.\n */\n GetClass(type)\n {\n validateClassKey(CLASS_KEYS, type, FORMAT_NAME);\n return this.#classes[type];\n }\n\n /**\n * Whether this format profile has a constructor registered for a node key.\n *\n * @param {string} type Node class key.\n * @returns {boolean} True when a constructor is registered.\n */\n HasClass(type)\n {\n return !!this.GetClass(type);\n }\n\n /**\n * Read a CEWGPU package with this profile's values.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU package bytes.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Plain JSON data, or the raw package instance when emit is \"raw\".\n */\n Read(input, options = {})\n {\n return readWithValues(input, this.GetValues(options));\n }\n\n /**\n * Inspect a CEWGPU package without building the full JSON shape.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU package bytes.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Plain summary data.\n */\n Inspect(input, options = {})\n {\n return inspectWithValues(input, this.GetValues(options));\n }\n\n /**\n * Analyzes one compiled effect payload into a normalized WebGPU-facing\n * document using the current profile's values.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect bytes.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Plain JSON-compatible analysis data.\n */\n AnalyzeEffect(input, options = {})\n {\n return analyzeEffectWithValues(input, this.GetValues(options));\n }\n\n /**\n * Builds a CEWGPU package with complete version-15 source reflection and\n * selected-body WebGPU output from compiled Tr2 effect bytes.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.\n * @param {object} [options] Source, body-mode, permutation, and stage-selection policy.\n * @returns {object} Package bytes plus inspection and provenance documents.\n */\n BuildEffect(input, options = {})\n {\n const values = this.GetValues();\n\n return buildEffectPackage(input, {\n source: values.source,\n permutation: values.permutation,\n ...options\n });\n }\n\n /**\n * Lowers DXBC bytes or decoded instructions into the front-end shader IR.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView|object} input DXBC input.\n * @param {object} [options] IR provenance options.\n * @returns {object} Frozen shader IR program.\n */\n BuildShaderIr(input, options = {})\n {\n return lowerDxbcToIr(input, options);\n }\n\n /**\n * Emits WGSL for the currently supported typed shader slice.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView|object} input DXBC or shader IR.\n * @param {object} [options] Source/provenance options.\n * @returns {object} Frozen WGSL shader descriptor.\n */\n BuildWgsl(input, options = {})\n {\n return buildWgsl(input, options);\n }\n\n /**\n * Assign one canonical numeric binding layout across shader stages in a pass.\n * Unshared D3D tuples remain stage-scoped unless shared explicitly.\n *\n * @param {object[]} programs Complete CJS shader IR stage set for one pass.\n * @param {object} [options] Pass-level binding policy.\n * @param {string[]} [options.sharedIdentities] Compatible D3D identities\n * confirmed to represent one resource across stages.\n * @returns {object} Frozen CJS_WGSL_BINDING_PLAN document.\n */\n BuildWgslBindingPlan(programs, options = {})\n {\n return buildWgslBindingPlan(programs, options);\n }\n\n /**\n * Assembles emitted shader descriptors into a portable WGSL set.\n *\n * @param {object[]} entries Canonically keyed emitted shader descriptors.\n * @returns {object} Frozen CJS_WGSL_SET document.\n */\n BuildWgslSet(entries)\n {\n return buildWgslSet(entries);\n }\n\n /**\n * Convert format output to JSON-compatible data.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n ToJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Static payload sniff. Static methods use camelCase by convention.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate bytes.\n * @returns {boolean} True when the payload has Carbon's version-15 shape.\n */\n static isCewgpu(input)\n {\n return isCewgpu(input);\n }\n\n /**\n * Static one-shot read.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU package bytes.\n * @param {object} [options] Format values.\n * @returns {object} Plain JSON data, or the raw package instance when emit is \"raw\".\n */\n static read(input, options = {})\n {\n return readWithValues(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME));\n }\n\n /**\n * Static one-shot inspection.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU package bytes.\n * @param {object} [options] Format values.\n * @returns {object} Plain summary data.\n */\n static inspect(input, options = {})\n {\n return inspectWithValues(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME));\n }\n\n /**\n * Static one-shot effect analysis.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect bytes.\n * @param {object} [options] Format values.\n * @returns {object} Plain JSON-compatible analysis data.\n */\n static analyzeEffect(input, options = {})\n {\n return analyzeEffectWithValues(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME));\n }\n\n /**\n * Static selected-body CEWGPU builder.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.\n * @param {object} [options] Source, body-mode, permutation, and stage-selection policy.\n * @returns {object} Package bytes plus inspection and provenance documents.\n */\n static buildEffect(input, options = {})\n {\n return buildEffectPackage(input, options);\n }\n\n /**\n * Static DXBC-to-front-end-IR helper.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView|object} input DXBC input.\n * @param {object} [options] IR provenance options.\n * @returns {object} Frozen shader IR program.\n */\n static buildShaderIr(input, options = {})\n {\n return lowerDxbcToIr(input, options);\n }\n\n /**\n * Static WGSL emission helper for the currently supported typed slice.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView|object} input DXBC or shader IR.\n * @param {object} [options] Source/provenance options.\n * @returns {object} Frozen WGSL shader descriptor.\n */\n static buildWgsl(input, options = {})\n {\n return buildWgsl(input, options);\n }\n\n /**\n * Static pass-global WGSL binding-plan helper. Unshared D3D tuples remain\n * stage-scoped unless listed in options.sharedIdentities.\n *\n * @param {object[]} programs Complete CJS shader IR stage set for one pass.\n * @param {object} [options] Pass-level binding policy.\n * @param {string[]} [options.sharedIdentities] Compatible D3D identities\n * confirmed to represent one resource across stages.\n * @returns {object} Frozen CJS_WGSL_BINDING_PLAN document.\n */\n static buildWgslBindingPlan(programs, options = {})\n {\n return buildWgslBindingPlan(programs, options);\n }\n\n /**\n * Static WGSL-set assembly helper.\n *\n * @param {object[]} entries Canonically keyed emitted shader descriptors.\n * @returns {object} Frozen CJS_WGSL_SET document.\n */\n static buildWgslSet(entries)\n {\n return buildWgslSet(entries);\n }\n\n /**\n * Static JSON-compatible conversion.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n static toJSON(value)\n {\n return toJsonValue(value);\n }\n\n static OUTPUT_JSON = OUTPUT_JSON;\n static OUTPUT_RAW = OUTPUT_RAW;\n static CLASS_KEYS = CLASS_KEYS;\n static type = Object.freeze([ \"shader\" ]);\n static mediaTypes = Object.freeze([ \"shader\" ]);\n static inputTypes = Object.freeze([ \"cewgpu\" ]);\n static outputTypes = Object.freeze([ OUTPUT_JSON ]);\n static debugOutputTypes = Object.freeze([ OUTPUT_RAW ]);\n static implementationStatus = \"partial\";\n static format = CEWGPU_FORMAT;\n static analysisFormat = CEWGPU_ANALYSIS_FORMAT;\n static packageVersion = FORMAT_WEBGPU_PACKAGE_VERSION;\n}\n\nexport default CjsWebgpuFormat;\n"],"names":["FORMAT_NAME","CjsWebgpuFormat","DEFAULT_VALUES","emit","source","decodeInstructions","permutation","schema","constructor","options","SetValues","values","normalizeValues","GetValues","CLASS_KEYS","classes","SetClasses","SetClass","type","Class","validateClassKey","undefined","validateClass","GetClass","HasClass","Read","input","readWithValues","Inspect","inspectWithValues","AnalyzeEffect","analyzeEffectWithValues","BuildEffect","buildEffectPackage","BuildShaderIr","lowerDxbcToIr","BuildWgsl","buildWgsl","BuildWgslBindingPlan","programs","buildWgslBindingPlan","BuildWgslSet","entries","buildWgslSet","ToJSON","value","toJsonValue","isCewgpu","read","inspect","analyzeEffect","buildEffect","buildShaderIr","toJSON","OUTPUT_JSON","OUTPUT_RAW","Object","freeze","mediaTypes","inputTypes","outputTypes","debugOutputTypes","implementationStatus","format","CEWGPU_FORMAT","analysisFormat","CEWGPU_ANALYSIS_FORMAT","packageVersion","FORMAT_WEBGPU_PACKAGE_VERSION"],"mappings":";;;;;;;;;AAuBA,MAAMA,WAAW,GAAG,iBAAiB;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AAC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,CAAC,CAAE,QAAQ,CAAE,CAAC;EAC/C,OAAOE,UAAU,GAAGH,MAAM,CAACC,MAAM,CAAC,CAAE,QAAQ,CAAE,CAAC;EAC/C,OAAOG,WAAW,GAAGJ,MAAM,CAACC,MAAM,CAAC,CAAEH,WAAW,CAAE,CAAC;EACnD,OAAOO,gBAAgB,GAAGL,MAAM,CAACC,MAAM,CAAC,CAAEF,UAAU,CAAE,CAAC;EACvD,OAAOO,oBAAoB,GAAG,SAAS;EACvC,OAAOC,MAAM,GAAGC,aAAa;EAC7B,OAAOC,cAAc,GAAGC,sBAAsB;EAC9C,OAAOC,cAAc,GAAGC,6BAA6B;AACzD;;;;"}
|
|
1
|
+
{"version":3,"file":"CjsWebgpuFormat.js","sources":["../../../../src/formats/webgpu/CjsWebgpuFormat.js"],"sourcesContent":["import { CLASS_KEYS } from \"./core/schema.js\";\nimport { lowerDxbcToIr } from \"./core/ir/lowerDxbcToIr.js\";\nimport { buildWgsl } from \"./core/wgsl/emitWgsl.js\";\nimport { buildWgslBindingPlan } from \"./core/wgsl/buildWgslBindingPlan.js\";\nimport { buildWgslSet } from \"./core/wgsl/buildWgslSet.js\";\nimport { buildEffectPackage } from \"./core/packageEffect.js\";\nimport { FORMAT_WEBGPU_PACKAGE_VERSION } from \"./core/packageMetadata.js\";\nimport {\n CARBON_WEBGPU_ANALYSIS_FORMAT,\n CARBON_WEBGPU_FORMAT,\n DEFAULT_VALUES,\n OUTPUT_JSON,\n OUTPUT_RAW,\n analyzeEffectWithValues,\n inspectWithValues,\n isCarbonWebgpu,\n normalizeValues,\n readWithValues,\n toJsonValue,\n validateClass,\n validateClassKey\n} from \"./core/helpers.js\";\n\nconst FORMAT_NAME = \"CjsWebgpuFormat\";\n\n/**\n * CarbonEngineJS-facing format surface for `.carbonwebgpu` WebGPU packages, plus an\n * offline effect-analysis helper built on the runtime-resource HLSL and DXBC\n * format subpaths.\n *\n * The package owns read/build, normalized shader analysis, and the current\n * bounded DXBC-to-WGSL profiles. Broader shader-semantic coverage remains an\n * explicit qualification ladder.\n */\nexport class CjsWebgpuFormat\n{\n #emit = DEFAULT_VALUES.emit;\n #source = DEFAULT_VALUES.source;\n #decodeInstructions = DEFAULT_VALUES.decodeInstructions;\n #permutation = DEFAULT_VALUES.permutation;\n #schema = DEFAULT_VALUES.schema;\n #classes = {};\n\n /**\n * Create a reusable format profile.\n *\n * @param {object} [options] Default format values.\n */\n constructor(options = {})\n {\n this.SetValues(options);\n }\n\n /**\n * Set format values for this reusable profile.\n *\n * @param {object} [options] Values to merge into the profile.\n * @returns {CjsWebgpuFormat} This format profile.\n */\n SetValues(options = {})\n {\n const values = normalizeValues(this.GetValues(), options, CLASS_KEYS, FORMAT_NAME);\n this.#emit = values.emit;\n this.#source = values.source;\n this.#decodeInstructions = values.decodeInstructions;\n this.#permutation = values.permutation;\n this.#schema = values.schema;\n this.#classes = values.classes;\n return this;\n }\n\n /**\n * Get this profile's current values, optionally with per-call overrides.\n *\n * @param {object} [options] Optional values to merge into a copy.\n * @returns {object} A copy of the effective values.\n */\n GetValues(options = {})\n {\n return normalizeValues({\n emit: this.#emit,\n source: this.#source,\n decodeInstructions: this.#decodeInstructions,\n permutation: this.#permutation,\n schema: this.#schema,\n classes: this.#classes\n }, options, CLASS_KEYS, FORMAT_NAME);\n }\n\n /**\n * Set multiple node-class constructors for this profile.\n *\n * @param {object} [classes] Map of node class keys to constructors.\n * @returns {CjsWebgpuFormat} This format profile.\n */\n SetClasses(classes = {})\n {\n return this.SetValues({ classes });\n }\n\n /**\n * Set one node-class constructor for this profile.\n *\n * @param {string} type Node class key.\n * @param {Function|null|undefined} Class constructor to use, or nullish to delete.\n * @returns {CjsWebgpuFormat} This format profile.\n */\n SetClass(type, Class)\n {\n validateClassKey(CLASS_KEYS, type, FORMAT_NAME);\n if (Class === null || Class === undefined)\n {\n delete this.#classes[type];\n return this;\n }\n\n validateClass(CLASS_KEYS, type, Class, FORMAT_NAME);\n this.#classes = { ...this.#classes, [type]: Class };\n return this;\n }\n\n /**\n * Get a configured node-class constructor.\n *\n * @param {string} type Node class key.\n * @returns {Function|undefined} The registered constructor, if any.\n */\n GetClass(type)\n {\n validateClassKey(CLASS_KEYS, type, FORMAT_NAME);\n return this.#classes[type];\n }\n\n /**\n * Whether this format profile has a constructor registered for a node key.\n *\n * @param {string} type Node class key.\n * @returns {boolean} True when a constructor is registered.\n */\n HasClass(type)\n {\n return !!this.GetClass(type);\n }\n\n /**\n * Read a Carbon WebGPU package with this profile's values.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU package bytes.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Plain JSON data, or the raw package instance when emit is \"raw\".\n */\n Read(input, options = {})\n {\n return readWithValues(input, this.GetValues(options));\n }\n\n /**\n * Inspect a Carbon WebGPU package without building the full JSON shape.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU package bytes.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Plain summary data.\n */\n Inspect(input, options = {})\n {\n return inspectWithValues(input, this.GetValues(options));\n }\n\n /**\n * Analyzes one compiled effect payload into a normalized WebGPU-facing\n * document using the current profile's values.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect bytes.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Plain JSON-compatible analysis data.\n */\n AnalyzeEffect(input, options = {})\n {\n return analyzeEffectWithValues(input, this.GetValues(options));\n }\n\n /**\n * Builds a Carbon WebGPU package with complete version-15 source reflection and\n * selected-body WebGPU output from compiled Tr2 effect bytes.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.\n * @param {object} [options] Source, body-mode, permutation, and stage-selection policy.\n * @returns {object} Package bytes plus inspection and provenance documents.\n */\n BuildEffect(input, options = {})\n {\n const values = this.GetValues();\n\n return buildEffectPackage(input, {\n source: values.source,\n permutation: values.permutation,\n ...options\n });\n }\n\n /**\n * Lowers DXBC bytes or decoded instructions into the front-end shader IR.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView|object} input DXBC input.\n * @param {object} [options] IR provenance options.\n * @returns {object} Frozen shader IR program.\n */\n BuildShaderIr(input, options = {})\n {\n return lowerDxbcToIr(input, options);\n }\n\n /**\n * Emits WGSL for the currently supported typed shader slice.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView|object} input DXBC or shader IR.\n * @param {object} [options] Source/provenance options.\n * @returns {object} Frozen WGSL shader descriptor.\n */\n BuildWgsl(input, options = {})\n {\n return buildWgsl(input, options);\n }\n\n /**\n * Assign one canonical numeric binding layout across shader stages in a pass.\n * Unshared D3D tuples remain stage-scoped unless shared explicitly.\n *\n * @param {object[]} programs Complete CJS shader IR stage set for one pass.\n * @param {object} [options] Pass-level binding policy.\n * @param {string[]} [options.sharedIdentities] Compatible D3D identities\n * confirmed to represent one resource across stages.\n * @returns {object} Frozen CJS_WGSL_BINDING_PLAN document.\n */\n BuildWgslBindingPlan(programs, options = {})\n {\n return buildWgslBindingPlan(programs, options);\n }\n\n /**\n * Assembles emitted shader descriptors into a portable WGSL set.\n *\n * @param {object[]} entries Canonically keyed emitted shader descriptors.\n * @returns {object} Frozen CJS_WGSL_SET document.\n */\n BuildWgslSet(entries)\n {\n return buildWgslSet(entries);\n }\n\n /**\n * Convert format output to JSON-compatible data.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n ToJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Static payload sniff. Static methods use camelCase by convention.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate bytes.\n * @returns {boolean} True when the payload has Carbon's version-15 shape.\n */\n static isCarbonWebgpu(input)\n {\n return isCarbonWebgpu(input);\n }\n\n /**\n * Static one-shot read.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU package bytes.\n * @param {object} [options] Format values.\n * @returns {object} Plain JSON data, or the raw package instance when emit is \"raw\".\n */\n static read(input, options = {})\n {\n return readWithValues(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME));\n }\n\n /**\n * Static one-shot inspection.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU package bytes.\n * @param {object} [options] Format values.\n * @returns {object} Plain summary data.\n */\n static inspect(input, options = {})\n {\n return inspectWithValues(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME));\n }\n\n /**\n * Static one-shot effect analysis.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect bytes.\n * @param {object} [options] Format values.\n * @returns {object} Plain JSON-compatible analysis data.\n */\n static analyzeEffect(input, options = {})\n {\n return analyzeEffectWithValues(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME));\n }\n\n /**\n * Static selected-body Carbon WebGPU builder.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.\n * @param {object} [options] Source, body-mode, permutation, and stage-selection policy.\n * @returns {object} Package bytes plus inspection and provenance documents.\n */\n static buildEffect(input, options = {})\n {\n return buildEffectPackage(input, options);\n }\n\n /**\n * Static DXBC-to-front-end-IR helper.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView|object} input DXBC input.\n * @param {object} [options] IR provenance options.\n * @returns {object} Frozen shader IR program.\n */\n static buildShaderIr(input, options = {})\n {\n return lowerDxbcToIr(input, options);\n }\n\n /**\n * Static WGSL emission helper for the currently supported typed slice.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView|object} input DXBC or shader IR.\n * @param {object} [options] Source/provenance options.\n * @returns {object} Frozen WGSL shader descriptor.\n */\n static buildWgsl(input, options = {})\n {\n return buildWgsl(input, options);\n }\n\n /**\n * Static pass-global WGSL binding-plan helper. Unshared D3D tuples remain\n * stage-scoped unless listed in options.sharedIdentities.\n *\n * @param {object[]} programs Complete CJS shader IR stage set for one pass.\n * @param {object} [options] Pass-level binding policy.\n * @param {string[]} [options.sharedIdentities] Compatible D3D identities\n * confirmed to represent one resource across stages.\n * @returns {object} Frozen CJS_WGSL_BINDING_PLAN document.\n */\n static buildWgslBindingPlan(programs, options = {})\n {\n return buildWgslBindingPlan(programs, options);\n }\n\n /**\n * Static WGSL-set assembly helper.\n *\n * @param {object[]} entries Canonically keyed emitted shader descriptors.\n * @returns {object} Frozen CJS_WGSL_SET document.\n */\n static buildWgslSet(entries)\n {\n return buildWgslSet(entries);\n }\n\n /**\n * Static JSON-compatible conversion.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n static toJSON(value)\n {\n return toJsonValue(value);\n }\n\n static OUTPUT_JSON = OUTPUT_JSON;\n static OUTPUT_RAW = OUTPUT_RAW;\n static CLASS_KEYS = CLASS_KEYS;\n static type = Object.freeze([ \"shader\" ]);\n static mediaTypes = Object.freeze([ \"shader\" ]);\n static inputTypes = Object.freeze([ \"carbonwebgpu\" ]);\n static outputTypes = Object.freeze([ OUTPUT_JSON ]);\n static debugOutputTypes = Object.freeze([ OUTPUT_RAW ]);\n static implementationStatus = \"partial\";\n static format = CARBON_WEBGPU_FORMAT;\n static analysisFormat = CARBON_WEBGPU_ANALYSIS_FORMAT;\n static packageVersion = FORMAT_WEBGPU_PACKAGE_VERSION;\n}\n\nexport default CjsWebgpuFormat;\n"],"names":["FORMAT_NAME","CjsWebgpuFormat","DEFAULT_VALUES","emit","source","decodeInstructions","permutation","schema","constructor","options","SetValues","values","normalizeValues","GetValues","CLASS_KEYS","classes","SetClasses","SetClass","type","Class","validateClassKey","undefined","validateClass","GetClass","HasClass","Read","input","readWithValues","Inspect","inspectWithValues","AnalyzeEffect","analyzeEffectWithValues","BuildEffect","buildEffectPackage","BuildShaderIr","lowerDxbcToIr","BuildWgsl","buildWgsl","BuildWgslBindingPlan","programs","buildWgslBindingPlan","BuildWgslSet","entries","buildWgslSet","ToJSON","value","toJsonValue","isCarbonWebgpu","read","inspect","analyzeEffect","buildEffect","buildShaderIr","toJSON","OUTPUT_JSON","OUTPUT_RAW","Object","freeze","mediaTypes","inputTypes","outputTypes","debugOutputTypes","implementationStatus","format","CARBON_WEBGPU_FORMAT","analysisFormat","CARBON_WEBGPU_ANALYSIS_FORMAT","packageVersion","FORMAT_WEBGPU_PACKAGE_VERSION"],"mappings":";;;;;;;;;AAuBA,MAAMA,WAAW,GAAG,iBAAiB;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,eAAe,CAC5B;AACI,EAAA,KAAK,GAAGC,cAAc,CAACC,IAAI;AAC3B,EAAA,OAAO,GAAGD,cAAc,CAACE,MAAM;AAC/B,EAAA,mBAAmB,GAAGF,cAAc,CAACG,kBAAkB;AACvD,EAAA,YAAY,GAAGH,cAAc,CAACI,WAAW;AACzC,EAAA,OAAO,GAAGJ,cAAc,CAACK,MAAM;EAC/B,QAAQ,GAAG,EAAE;;AAEb;AACJ;AACA;AACA;AACA;AACIC,EAAAA,WAAWA,CAACC,OAAO,GAAG,EAAE,EACxB;AACI,IAAA,IAAI,CAACC,SAAS,CAACD,OAAO,CAAC;AAC3B,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACA;AACIC,EAAAA,SAASA,CAACD,OAAO,GAAG,EAAE,EACtB;AACI,IAAA,MAAME,MAAM,GAAGC,eAAe,CAAC,IAAI,CAACC,SAAS,EAAE,EAAEJ,OAAO,EAAEK,UAAU,EAAEd,WAAW,CAAC;AAClF,IAAA,IAAI,CAAC,KAAK,GAAGW,MAAM,CAACR,IAAI;AACxB,IAAA,IAAI,CAAC,OAAO,GAAGQ,MAAM,CAACP,MAAM;AAC5B,IAAA,IAAI,CAAC,mBAAmB,GAAGO,MAAM,CAACN,kBAAkB;AACpD,IAAA,IAAI,CAAC,YAAY,GAAGM,MAAM,CAACL,WAAW;AACtC,IAAA,IAAI,CAAC,OAAO,GAAGK,MAAM,CAACJ,MAAM;AAC5B,IAAA,IAAI,CAAC,QAAQ,GAA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