@carbonenginejs/runtime-resource 0.11.1 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CjsResMan.js +4 -4
- package/dist/CjsResMan.js.map +1 -1
- package/dist/_virtual/_rollupPluginBabelHelpers.js +1 -4
- package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/dist/format/CjsByteReader.js +310 -0
- package/dist/format/CjsByteReader.js.map +1 -0
- package/dist/format/CjsByteWriter.js +242 -0
- package/dist/format/CjsByteWriter.js.map +1 -0
- package/dist/format/CjsFormatError.js +41 -0
- package/dist/format/CjsFormatError.js.map +1 -0
- package/dist/format/CjsStringTable.js +268 -0
- package/dist/format/CjsStringTable.js.map +1 -0
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js +361 -0
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js.map +1 -0
- package/dist/format/carbonEffect/CjsCarbonEffectWriter.js +373 -0
- package/dist/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -0
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js +372 -0
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js +427 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectRecords.js +955 -0
- package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -0
- package/dist/format/compareUtf8.js +36 -0
- package/dist/format/compareUtf8.js.map +1 -0
- package/dist/format/index.js +11 -0
- package/dist/format/index.js.map +1 -0
- package/dist/formats/bnk/CjsBnkFormat.js +18 -2
- package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
- package/dist/formats/bnk/core/eventAction.js +305 -0
- package/dist/formats/bnk/core/eventAction.js.map +1 -0
- package/dist/formats/bnk/core/graph.js +3 -6
- package/dist/formats/bnk/core/graph.js.map +1 -1
- package/dist/formats/bnk/core/helpers.js +62 -11
- package/dist/formats/bnk/core/helpers.js.map +1 -1
- package/dist/formats/bnk/core/nodeBase.js +532 -0
- package/dist/formats/bnk/core/nodeBase.js.map +1 -0
- package/dist/formats/bnk/core/sfxNodes.js +632 -0
- package/dist/formats/bnk/core/sfxNodes.js.map +1 -0
- package/dist/formats/bnk/core/soundbanksInfo.js +59 -51
- package/dist/formats/bnk/core/soundbanksInfo.js.map +1 -1
- package/dist/formats/gr2/CjsGr2Format.js +256 -13
- package/dist/formats/gr2/CjsGr2Format.js.map +1 -1
- package/dist/formats/gr2/core/helpers.js +15 -15
- package/dist/formats/gr2/core/helpers.js.map +1 -1
- package/dist/formats/gr2/core/json.js +1 -1
- package/dist/formats/gr2/core/json.js.map +1 -1
- package/dist/formats/gr2/core/targets.js +1 -1
- package/dist/formats/gr2/core/targets.js.map +1 -1
- package/dist/formats/gr2/index.js +0 -1
- package/dist/formats/gr2/index.js.map +1 -1
- package/dist/formats/hlsl/core/HlslReader.js +7 -257
- package/dist/formats/hlsl/core/HlslReader.js.map +1 -1
- package/dist/formats/hlsl/core/analysis.js +1 -1
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +781 -0
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +21 -1
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -1
- package/dist/formats/hlsl/index.js +1 -0
- package/dist/formats/hlsl/index.js.map +1 -1
- package/dist/formats/index.js +3 -6
- package/dist/formats/index.js.map +1 -1
- package/dist/formats/webgl/core/cewg/CewgPackage.js +2 -1
- package/dist/formats/webgl/core/cewg/CewgPackage.js.map +1 -1
- package/dist/formats/webgl/core/cewg/binary.js +11 -93
- package/dist/formats/webgl/core/cewg/binary.js.map +1 -1
- package/dist/formats/webgl/core/effectPackage.js +4 -1
- package/dist/formats/webgl/core/effectPackage.js.map +1 -1
- package/dist/formats/webgl/core/errors.js +3 -3
- package/dist/formats/webgl/core/errors.js.map +1 -1
- package/dist/formats/webgpu/CjsWebgpuFormat.js +4 -23
- package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +197 -0
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js +368 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/containerViews.js +355 -0
- package/dist/formats/webgpu/core/cewgpu/containerViews.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/validateContainer.js +90 -0
- package/dist/formats/webgpu/core/cewgpu/validateContainer.js.map +1 -0
- package/dist/formats/webgpu/core/effectBackendBodySet.js +21 -20
- package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
- package/dist/formats/webgpu/core/helpers.js +87 -92
- package/dist/formats/webgpu/core/helpers.js.map +1 -1
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +14 -13
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js.map +1 -1
- package/dist/formats/webgpu/core/ir/inferValueTypes.js +10 -8
- package/dist/formats/webgpu/core/ir/inferValueTypes.js.map +1 -1
- package/dist/formats/webgpu/core/packageEffect.js +94 -9
- package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
- package/dist/formats/webgpu/core/packageMetadata.js +10 -1
- package/dist/formats/webgpu/core/packageMetadata.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +17 -15
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +13 -12
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +9 -8
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +23 -22
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js +46 -44
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js.map +1 -1
- package/dist/resource/CjsResource.js +700 -684
- package/dist/resource/CjsResource.js.map +1 -1
- package/dist/resource/Tr2LightProfileRes.js +18 -27
- package/dist/resource/Tr2LightProfileRes.js.map +1 -1
- package/dist/resource/audio/CjsAudioBufferRes.js +2 -2
- package/dist/resource/audio/CjsAudioBufferRes.js.map +1 -1
- package/dist/resource/audio/CjsAudioRes.js +2 -2
- package/dist/resource/audio/CjsAudioRes.js.map +1 -1
- package/dist/resource/geometry/TriGeometryRes.js +605 -586
- package/dist/resource/geometry/TriGeometryRes.js.map +1 -1
- package/dist/resource/geometry/granny/Tr2GrannyStateRes.js +21 -30
- package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -1
- package/dist/resource/geometry/granny/TriGrannyRes.js +21 -30
- package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -1
- package/dist/resource/shader/Tr2EffectRes.js +9 -7
- package/dist/resource/shader/Tr2EffectRes.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialArea.js +5 -3
- package/dist/resource/shader/Tr2MaterialArea.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialMesh.js +4 -2
- package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialRes.js +5 -3
- package/dist/resource/shader/Tr2MaterialRes.js.map +1 -1
- package/dist/resource/shader/Tr2Shader.js +26 -21
- package/dist/resource/shader/Tr2Shader.js.map +1 -1
- package/dist/resource/shader/Tr2ShaderPermutation.js +8 -6
- package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectDefine.js +5 -3
- package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectDescription.js +5 -3
- package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js +17 -15
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +11 -9
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectResource.js +8 -6
- package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js +15 -13
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js +7 -5
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2Pass.js +11 -9
- package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js +8 -6
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -1
- package/dist/resource/texture/CjsTextureArrayRes.js +400 -411
- package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -1
- package/dist/resource/texture/Tr2ImageRes.js +99 -95
- package/dist/resource/texture/Tr2ImageRes.js.map +1 -1
- package/dist/resource/texture/TriTextureRes.js +312 -273
- package/dist/resource/texture/TriTextureRes.js.map +1 -1
- package/docs/README.md +13 -1
- package/docs/architecture.md +3 -3
- package/docs/concepts/resource-lifecycle.md +9 -2
- package/docs/concepts/shader-resource-model.md +114 -0
- package/docs/concepts/writing-an-engine-adapter.md +115 -0
- package/docs/formats/README.md +24 -1
- package/docs/formats/carbon-effect-container.md +452 -0
- package/docs/formats/dxbc/README.md +68 -0
- package/docs/formats/dxbc/architecture.md +80 -0
- package/docs/formats/dxbc/reference/api.md +77 -0
- package/docs/formats/dxbc/reference/classes/README.md +9 -0
- package/docs/formats/dxbc/reference/decoded-output.md +122 -0
- package/docs/formats/gr2.md +3 -4
- package/docs/formats/hlsl/README.md +54 -0
- package/docs/formats/hlsl/architecture.md +67 -0
- package/docs/formats/hlsl/guides/hydrating-json-output.md +62 -0
- package/docs/formats/hlsl/guides/reading-effects.md +64 -0
- package/docs/formats/hlsl/reference/advanced-analysis.md +66 -0
- package/docs/formats/hlsl/reference/api.md +98 -0
- package/docs/formats/hlsl/reference/classes/README.md +11 -0
- package/docs/formats/hlsl/reference/json-graph.md +100 -0
- package/docs/formats/hlsl/reference/portable-reflection.md +141 -0
- package/docs/formats/provenance.md +32 -17
- package/docs/formats/webgl/README.md +57 -0
- package/docs/formats/webgl/architecture.md +70 -0
- package/docs/formats/webgl/carbon-constant-layouts.md +326 -0
- package/docs/formats/webgl/decl-io.md +1234 -0
- package/docs/formats/webgl/effect-reflection.md +127 -0
- package/docs/formats/webgl/memory-structured.md +871 -0
- package/docs/formats/webgl/reference/classes/README.md +9 -0
- package/docs/formats/webgl/texture-sample.md +964 -0
- package/docs/formats/webgpu/README.md +84 -0
- package/docs/formats/webgpu/architecture.md +96 -0
- package/docs/formats/webgpu/formats/cewgpu.md +216 -0
- package/docs/formats/webgpu/guides/effect-packaging.md +191 -0
- package/docs/formats/webgpu/reference/api.md +197 -0
- package/docs/formats/webgpu/reference/classes/README.md +9 -0
- package/docs/formats/webgpu/reference/wgsl-compatibility.md +1543 -0
- package/docs/formats/wwise.md +45 -4
- package/docs/reference/classes/core.md +80 -0
- package/docs/reference/classes/formats.md +24 -34
- package/docs/reference/events.md +25 -0
- package/docs/reference/motherlode-cache.md +22 -8
- package/docs/reference/workers.md +5 -5
- package/docs/roadmap.md +61 -41
- package/format-notices/bnk/NOTICE +5 -4
- package/format-notices/webgl/NOTICE +1 -1
- package/package.json +2 -1
- package/dist/formats/gr2/core/CjsFormatGr2.js +0 -273
- package/dist/formats/gr2/core/CjsFormatGr2.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js +0 -415
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js +0 -100
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/binary.js +0 -93
- package/dist/formats/webgpu/core/cewgpu/binary.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/tags.js +0 -17
- package/dist/formats/webgpu/core/cewgpu/tags.js.map +0 -1
- package/dist/formats/webgpu/core/effectPackageValidation.js +0 -1078
- package/dist/formats/webgpu/core/effectPackageValidation.js.map +0 -1
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import '../../../format/compareUtf8.js';
|
|
2
|
+
import { writeBackendBlock } from '../../../format/carbonEffect/carbonEffectBackendBlock.js';
|
|
3
|
+
import { carbonDescriptionFromPortable } from '../../../format/carbonEffect/carbonDescriptionFromPortable.js';
|
|
4
|
+
import '../../../format/CjsByteReader.js';
|
|
5
|
+
import { CjsCarbonEffectWriter } from '../../../format/carbonEffect/CjsCarbonEffectWriter.js';
|
|
6
|
+
import { buildEffectBodyReflection } from '../../hlsl/core/portableReflection.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Assembles the WebGPU effect container: Carbon's v15 record layout carrying
|
|
10
|
+
* WGSL where a shipped file carries DXBC.
|
|
11
|
+
*
|
|
12
|
+
* The Carbon record layout is shared across backends. CEWGPU replaces stage
|
|
13
|
+
* program bytes with WGSL or an empty slot and adds one optional trailing block
|
|
14
|
+
* per pass. The portable-to-Carbon mapping retains representable non-program
|
|
15
|
+
* fields; non-dynamic sampler names are unrecoverable and stage order is
|
|
16
|
+
* canonicalized.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* There is no envelope, no magic and no version of our own. That is deliberate.
|
|
21
|
+
*
|
|
22
|
+
* A twelve-byte prefix (`magic | containerVersion | payloadKind`) was carried
|
|
23
|
+
* here and has been removed, along with a proposed "v16" for this variant.
|
|
24
|
+
* Neither survived the only question worth asking of an addition: what breaks
|
|
25
|
+
* without it?
|
|
26
|
+
*
|
|
27
|
+
* - `payloadKind` is redundant with the directory the file came from. CEWGPU
|
|
28
|
+
* identity belongs to the `effect.webgpu/` resource path; `.cewg` remains a
|
|
29
|
+
* separate CEWG chunk format.
|
|
30
|
+
* - The magic only distinguished our file from a Carbon one, which the same
|
|
31
|
+
* directory already answers, and which the file *name* answers too.
|
|
32
|
+
* - A version of our own would have claimed a number CCP owns, in the one field
|
|
33
|
+
* whose job is telling a reader how to parse. A real v16 from them would then
|
|
34
|
+
* collide with ours.
|
|
35
|
+
*
|
|
36
|
+
* What remains is a bare Carbon v15 record file. `CewgpuContainer` reads it and
|
|
37
|
+
* the shared record reader detects the per-pass block from the description's
|
|
38
|
+
* declared end. Direct `Tr2EffectRes` hydration remains an adapter boundary:
|
|
39
|
+
* a Carbon description tree is not the portable reflection envelope consumed
|
|
40
|
+
* by `Tr2Shader.fromPortable`.
|
|
41
|
+
*
|
|
42
|
+
* The one addition that does survive the question is the block itself: WebGPU
|
|
43
|
+
* bind-group layouts come from the lowered IR and are not derivable from Carbon
|
|
44
|
+
* reflection, so without it there is no binding topology and no pipeline.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The entry-point name every WGSL lowerer emits.
|
|
49
|
+
*
|
|
50
|
+
* Carbon's `StageInput` has no entry-point field, so the container can only omit
|
|
51
|
+
* one if it is a constant of our emitter rather than data. It is: all thirteen
|
|
52
|
+
* `lower*Program` modules write `entryPoint: "main"` literally. Measured constant
|
|
53
|
+
* across 626 shaders in seven effects — but measurement only shows it holds
|
|
54
|
+
* today, so the substitution asserts it. A future lowerer that picks a different
|
|
55
|
+
* name fails the build instead of silently emitting a container whose programs
|
|
56
|
+
* cannot be found.
|
|
57
|
+
*/
|
|
58
|
+
const WGSL_ENTRY_POINT = "main";
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Builds the per-pass backend block for one pass of one translated body.
|
|
62
|
+
*
|
|
63
|
+
* @param {object} unit Pass translation unit.
|
|
64
|
+
* @param {string} passKey Enclosing pass key.
|
|
65
|
+
* @returns {Uint8Array|null} Block bytes, or null when the pass has no layout.
|
|
66
|
+
*/
|
|
67
|
+
function backendBlockFor(unit, passKey) {
|
|
68
|
+
const layout = unit.layouts.find(entry => entry.key === passKey);
|
|
69
|
+
if (!layout) return null;
|
|
70
|
+
return writeBackendBlock({
|
|
71
|
+
bindGroups: layout.bindGroups,
|
|
72
|
+
transforms: (unit.resourceTransforms ?? []).filter(transform => transform.layoutKey === passKey)
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Maps one body's translated passes by pass key.
|
|
78
|
+
*
|
|
79
|
+
* @param {object} body Backend body-set record.
|
|
80
|
+
* @param {Map<string, object>} unitsByKey Units indexed by key.
|
|
81
|
+
* @returns {Map<string, object>} Units indexed by pass key.
|
|
82
|
+
*/
|
|
83
|
+
function unitsByPassKey(body, unitsByKey) {
|
|
84
|
+
const result = new Map();
|
|
85
|
+
for (const pass of body.passes ?? []) {
|
|
86
|
+
result.set(pass.passKey, unitsByKey.get(pass.unitKey));
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Builds one body's Carbon description record tree with WGSL substituted in.
|
|
93
|
+
*
|
|
94
|
+
* A body the translator could not lower retains its representable non-program
|
|
95
|
+
* description fields and carries zero-length programs. Emitting empty
|
|
96
|
+
* `shaderData` says exactly what the wire knows: no backend program was stored.
|
|
97
|
+
* Full portable source reflection remains in the in-memory build result, not
|
|
98
|
+
* in this emitted body.
|
|
99
|
+
*
|
|
100
|
+
* @param {object} effectRes Loaded version-15 `Tr2EffectRes`.
|
|
101
|
+
* @param {number} permutationIndex Representative permutation for this body.
|
|
102
|
+
* @param {Map<string, object>|null} passUnits Units by pass key, or null when unsupported.
|
|
103
|
+
* @returns {object} Description record tree.
|
|
104
|
+
*/
|
|
105
|
+
function describeBody(effectRes, permutationIndex, passUnits) {
|
|
106
|
+
const reflection = buildEffectBodyReflection(effectRes, permutationIndex);
|
|
107
|
+
if (!passUnits) {
|
|
108
|
+
return carbonDescriptionFromPortable(reflection, {
|
|
109
|
+
programFor: () => ({
|
|
110
|
+
bytes: new Uint8Array(0),
|
|
111
|
+
size: 0
|
|
112
|
+
})
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return carbonDescriptionFromPortable(reflection, {
|
|
116
|
+
programFor: (stage, context) => {
|
|
117
|
+
const unit = passUnits.get(context.passKey);
|
|
118
|
+
const shader = unit?.shaders.find(entry => entry.key === `${context.passKey}.${stage.stageName}`);
|
|
119
|
+
if (!shader) return {
|
|
120
|
+
bytes: new Uint8Array(0),
|
|
121
|
+
size: 0
|
|
122
|
+
};
|
|
123
|
+
if (shader.entryPoint !== WGSL_ENTRY_POINT) {
|
|
124
|
+
throw new Error(`WGSL shader ${shader.key} has entry point "${shader.entryPoint}"; ` + `the container omits the name because every lowerer emits "${WGSL_ENTRY_POINT}"`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// `sourceMap` is deliberately dropped. Its offsets index DXBC bytes,
|
|
128
|
+
// which this container does not carry, so it is a translator
|
|
129
|
+
// diagnostic rather than payload. It was separately measured to
|
|
130
|
+
// suppress no sharing, so keeping it would buy nothing either.
|
|
131
|
+
const bytes = new TextEncoder().encode(shader.code);
|
|
132
|
+
return {
|
|
133
|
+
bytes,
|
|
134
|
+
size: bytes.byteLength
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
backendBlockFor: context => {
|
|
138
|
+
const unit = passUnits.get(context.passKey);
|
|
139
|
+
return unit ? backendBlockFor(unit, context.passKey) : null;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Builds the complete WebGPU effect container.
|
|
146
|
+
*
|
|
147
|
+
* @param {object} effectRes Loaded version-15 `Tr2EffectRes`.
|
|
148
|
+
* @param {object} permutationGraph Validated `PGRF` document.
|
|
149
|
+
* @param {object} backendBodySet Translated backend bodies.
|
|
150
|
+
* @param {object} [options] Container options.
|
|
151
|
+
* @param {number[]|Uint8Array} [options.compilerVersion] Four version bytes.
|
|
152
|
+
* @param {string} [options.sourceHash] 32 ASCII hash characters.
|
|
153
|
+
* @returns {{bytes:Uint8Array, bodyCount:number, distinctBodyCount:number}} Container and its body accounting.
|
|
154
|
+
*/
|
|
155
|
+
function buildCarbonEffectContainer(effectRes, permutationGraph, backendBodySet, options = {}) {
|
|
156
|
+
const unitsByKey = new Map(backendBodySet.passUnits.map(unit => [unit.key, unit]));
|
|
157
|
+
const bodyByKey = new Map(backendBodySet.bodies.map(body => [body.bodyKey, body]));
|
|
158
|
+
const writer = new CjsCarbonEffectWriter({
|
|
159
|
+
backend: true,
|
|
160
|
+
compilerVersion: options.compilerVersion ?? effectRes.m_compilerVersionBytes ?? [0, 0, 0, 0],
|
|
161
|
+
...(options.sourceHash ? {
|
|
162
|
+
sourceHash: options.sourceHash
|
|
163
|
+
} : {})
|
|
164
|
+
});
|
|
165
|
+
for (const axis of permutationGraph.axes) {
|
|
166
|
+
writer.addPermutation({
|
|
167
|
+
name: axis.name,
|
|
168
|
+
defaultOption: axis.defaultOption,
|
|
169
|
+
description: axis.description,
|
|
170
|
+
type: axis.type,
|
|
171
|
+
options: axis.options
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Build one emitted description per source body key and reuse it for each
|
|
176
|
+
// matching permutation. The writer may dedupe additional descriptions when
|
|
177
|
+
// their emitted bytes become identical after source programs are replaced;
|
|
178
|
+
// the offset table remains dense.
|
|
179
|
+
const describedByBodyKey = new Map();
|
|
180
|
+
for (const [permutationIndex, variant] of permutationGraph.variants.entries()) {
|
|
181
|
+
let description = describedByBodyKey.get(variant.bodyKey);
|
|
182
|
+
if (!description) {
|
|
183
|
+
const body = bodyByKey.get(variant.bodyKey);
|
|
184
|
+
description = describeBody(effectRes, body?.representativePermutationIndex ?? permutationIndex, body?.status === "translated" ? unitsByPassKey(body, unitsByKey) : null);
|
|
185
|
+
describedByBodyKey.set(variant.bodyKey, description);
|
|
186
|
+
}
|
|
187
|
+
writer.addBody(permutationIndex, description);
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
bytes: writer.toBytes(),
|
|
191
|
+
permutationCount: permutationGraph.variants.length,
|
|
192
|
+
bodyCount: describedByBodyKey.size
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export { WGSL_ENTRY_POINT, buildCarbonEffectContainer };
|
|
197
|
+
//# sourceMappingURL=buildCarbonEffectContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildCarbonEffectContainer.js","sources":["../../../../../src/formats/webgpu/core/buildCarbonEffectContainer.js"],"sourcesContent":["import {\n CjsCarbonEffectWriter,\n carbonDescriptionFromPortable,\n writeBackendBlock\n} from \"../../../format/carbonEffect/index.js\";\nimport { buildEffectBodyReflection } from \"../../hlsl/core/portableReflection.js\";\n\n/**\n * Assembles the WebGPU effect container: Carbon's v15 record layout carrying\n * WGSL where a shipped file carries DXBC.\n *\n * The Carbon record layout is shared across backends. CEWGPU replaces stage\n * program bytes with WGSL or an empty slot and adds one optional trailing block\n * per pass. The portable-to-Carbon mapping retains representable non-program\n * fields; non-dynamic sampler names are unrecoverable and stage order is\n * canonicalized.\n */\n\n/**\n * There is no envelope, no magic and no version of our own. That is deliberate.\n *\n * A twelve-byte prefix (`magic | containerVersion | payloadKind`) was carried\n * here and has been removed, along with a proposed \"v16\" for this variant.\n * Neither survived the only question worth asking of an addition: what breaks\n * without it?\n *\n * - `payloadKind` is redundant with the directory the file came from. CEWGPU\n * identity belongs to the `effect.webgpu/` resource path; `.cewg` remains a\n * separate CEWG chunk format.\n * - The magic only distinguished our file from a Carbon one, which the same\n * directory already answers, and which the file *name* answers too.\n * - A version of our own would have claimed a number CCP owns, in the one field\n * whose job is telling a reader how to parse. A real v16 from them would then\n * collide with ours.\n *\n * What remains is a bare Carbon v15 record file. `CewgpuContainer` reads it and\n * the shared record reader detects the per-pass block from the description's\n * declared end. Direct `Tr2EffectRes` hydration remains an adapter boundary:\n * a Carbon description tree is not the portable reflection envelope consumed\n * by `Tr2Shader.fromPortable`.\n *\n * The one addition that does survive the question is the block itself: WebGPU\n * bind-group layouts come from the lowered IR and are not derivable from Carbon\n * reflection, so without it there is no binding topology and no pipeline.\n */\n\n/**\n * The entry-point name every WGSL lowerer emits.\n *\n * Carbon's `StageInput` has no entry-point field, so the container can only omit\n * one if it is a constant of our emitter rather than data. It is: all thirteen\n * `lower*Program` modules write `entryPoint: \"main\"` literally. Measured constant\n * across 626 shaders in seven effects — but measurement only shows it holds\n * today, so the substitution asserts it. A future lowerer that picks a different\n * name fails the build instead of silently emitting a container whose programs\n * cannot be found.\n */\nexport const WGSL_ENTRY_POINT = \"main\";\n\n/**\n * Builds the per-pass backend block for one pass of one translated body.\n *\n * @param {object} unit Pass translation unit.\n * @param {string} passKey Enclosing pass key.\n * @returns {Uint8Array|null} Block bytes, or null when the pass has no layout.\n */\nfunction backendBlockFor(unit, passKey)\n{\n const layout = unit.layouts.find((entry) => entry.key === passKey);\n if (!layout) return null;\n\n return writeBackendBlock({\n bindGroups: layout.bindGroups,\n transforms: (unit.resourceTransforms ?? [])\n .filter((transform) => transform.layoutKey === passKey)\n });\n}\n\n/**\n * Maps one body's translated passes by pass key.\n *\n * @param {object} body Backend body-set record.\n * @param {Map<string, object>} unitsByKey Units indexed by key.\n * @returns {Map<string, object>} Units indexed by pass key.\n */\nfunction unitsByPassKey(body, unitsByKey)\n{\n const result = new Map();\n for (const pass of body.passes ?? [])\n {\n result.set(pass.passKey, unitsByKey.get(pass.unitKey));\n }\n return result;\n}\n\n/**\n * Builds one body's Carbon description record tree with WGSL substituted in.\n *\n * A body the translator could not lower retains its representable non-program\n * description fields and carries zero-length programs. Emitting empty\n * `shaderData` says exactly what the wire knows: no backend program was stored.\n * Full portable source reflection remains in the in-memory build result, not\n * in this emitted body.\n *\n * @param {object} effectRes Loaded version-15 `Tr2EffectRes`.\n * @param {number} permutationIndex Representative permutation for this body.\n * @param {Map<string, object>|null} passUnits Units by pass key, or null when unsupported.\n * @returns {object} Description record tree.\n */\nfunction describeBody(effectRes, permutationIndex, passUnits)\n{\n const reflection = buildEffectBodyReflection(effectRes, permutationIndex);\n\n if (!passUnits)\n {\n return carbonDescriptionFromPortable(reflection, {\n programFor: () => ({ bytes: new Uint8Array(0), size: 0 })\n });\n }\n\n return carbonDescriptionFromPortable(reflection, {\n programFor: (stage, context) =>\n {\n const unit = passUnits.get(context.passKey);\n const shader = unit?.shaders.find(\n (entry) => entry.key === `${context.passKey}.${stage.stageName}`\n );\n\n if (!shader) return { bytes: new Uint8Array(0), size: 0 };\n\n if (shader.entryPoint !== WGSL_ENTRY_POINT)\n {\n throw new Error(\n `WGSL shader ${shader.key} has entry point \"${shader.entryPoint}\"; `\n + `the container omits the name because every lowerer emits \"${WGSL_ENTRY_POINT}\"`\n );\n }\n\n // `sourceMap` is deliberately dropped. Its offsets index DXBC bytes,\n // which this container does not carry, so it is a translator\n // diagnostic rather than payload. It was separately measured to\n // suppress no sharing, so keeping it would buy nothing either.\n const bytes = new TextEncoder().encode(shader.code);\n return { bytes, size: bytes.byteLength };\n },\n backendBlockFor: (context) =>\n {\n const unit = passUnits.get(context.passKey);\n return unit ? backendBlockFor(unit, context.passKey) : null;\n }\n });\n}\n\n/**\n * Builds the complete WebGPU effect container.\n *\n * @param {object} effectRes Loaded version-15 `Tr2EffectRes`.\n * @param {object} permutationGraph Validated `PGRF` document.\n * @param {object} backendBodySet Translated backend bodies.\n * @param {object} [options] Container options.\n * @param {number[]|Uint8Array} [options.compilerVersion] Four version bytes.\n * @param {string} [options.sourceHash] 32 ASCII hash characters.\n * @returns {{bytes:Uint8Array, bodyCount:number, distinctBodyCount:number}} Container and its body accounting.\n */\nexport function buildCarbonEffectContainer(\n effectRes,\n permutationGraph,\n backendBodySet,\n options = {}\n)\n{\n const unitsByKey = new Map(backendBodySet.passUnits.map((unit) => [ unit.key, unit ]));\n const bodyByKey = new Map(backendBodySet.bodies.map((body) => [ body.bodyKey, body ]));\n const writer = new CjsCarbonEffectWriter({\n backend: true,\n compilerVersion: options.compilerVersion ?? effectRes.m_compilerVersionBytes ?? [ 0, 0, 0, 0 ],\n ...(options.sourceHash ? { sourceHash: options.sourceHash } : {})\n });\n\n for (const axis of permutationGraph.axes)\n {\n writer.addPermutation({\n name: axis.name,\n defaultOption: axis.defaultOption,\n description: axis.description,\n type: axis.type,\n options: axis.options\n });\n }\n\n // Build one emitted description per source body key and reuse it for each\n // matching permutation. The writer may dedupe additional descriptions when\n // their emitted bytes become identical after source programs are replaced;\n // the offset table remains dense.\n const describedByBodyKey = new Map();\n\n for (const [ permutationIndex, variant ] of permutationGraph.variants.entries())\n {\n let description = describedByBodyKey.get(variant.bodyKey);\n\n if (!description)\n {\n const body = bodyByKey.get(variant.bodyKey);\n description = describeBody(\n effectRes,\n body?.representativePermutationIndex ?? permutationIndex,\n body?.status === \"translated\" ? unitsByPassKey(body, unitsByKey) : null\n );\n describedByBodyKey.set(variant.bodyKey, description);\n }\n\n writer.addBody(permutationIndex, description);\n }\n\n return {\n bytes: writer.toBytes(),\n permutationCount: permutationGraph.variants.length,\n bodyCount: describedByBodyKey.size\n };\n}\n\nexport default buildCarbonEffectContainer;\n"],"names":["WGSL_ENTRY_POINT","backendBlockFor","unit","passKey","layout","layouts","find","entry","key","writeBackendBlock","bindGroups","transforms","resourceTransforms","filter","transform","layoutKey","unitsByPassKey","body","unitsByKey","result","Map","pass","passes","set","get","unitKey","describeBody","effectRes","permutationIndex","passUnits","reflection","buildEffectBodyReflection","carbonDescriptionFromPortable","programFor","bytes","Uint8Array","size","stage","context","shader","shaders","stageName","entryPoint","Error","TextEncoder","encode","code","byteLength","buildCarbonEffectContainer","permutationGraph","backendBodySet","options","map","bodyByKey","bodies","bodyKey","writer","CjsCarbonEffectWriter","backend","compilerVersion","m_compilerVersionBytes","sourceHash","axis","axes","addPermutation","name","defaultOption","description","type","describedByBodyKey","variant","variants","entries","representativePermutationIndex","status","addBody","toBytes","permutationCount","length","bodyCount"],"mappings":";;;;;;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;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;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,GAAG;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAACC,IAAI,EAAEC,OAAO,EACtC;AACI,EAAA,MAAMC,MAAM,GAAGF,IAAI,CAACG,OAAO,CAACC,IAAI,CAAEC,KAAK,IAAKA,KAAK,CAACC,GAAG,KAAKL,OAAO,CAAC;AAClE,EAAA,IAAI,CAACC,MAAM,EAAE,OAAO,IAAI;AAExB,EAAA,OAAOK,iBAAiB,CAAC;IACrBC,UAAU,EAAEN,MAAM,CAACM,UAAU;AAC7BC,IAAAA,UAAU,EAAE,CAACT,IAAI,CAACU,kBAAkB,IAAI,EAAE,EACrCC,MAAM,CAAEC,SAAS,IAAKA,SAAS,CAACC,SAAS,KAAKZ,OAAO;AAC9D,GAAC,CAAC;AACN;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASa,cAAcA,CAACC,IAAI,EAAEC,UAAU,EACxC;AACI,EAAA,MAAMC,MAAM,GAAG,IAAIC,GAAG,EAAE;EACxB,KAAK,MAAMC,IAAI,IAAIJ,IAAI,CAACK,MAAM,IAAI,EAAE,EACpC;AACIH,IAAAA,MAAM,CAACI,GAAG,CAACF,IAAI,CAAClB,OAA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O,MAAM;IAClDC,SAAS,EAAEV,kBAAkB,CAACjC;GACjC;AACL;;;;"}
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import '../../../../format/compareUtf8.js';
|
|
2
|
+
import { readBackendBlock } from '../../../../format/carbonEffect/carbonEffectBackendBlock.js';
|
|
3
|
+
import { CjsCarbonEffectReader } from '../../../../format/carbonEffect/CjsCarbonEffectReader.js';
|
|
4
|
+
import '../../../../format/carbonEffect/CjsCarbonEffectWriter.js';
|
|
5
|
+
import { WGSL_ENTRY_POINT } from '../buildCarbonEffectContainer.js';
|
|
6
|
+
import { sha256Bytes } from '../../../../format/effect/sha256.js';
|
|
7
|
+
import { deriveBackendBodySet } from './containerViews.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Reader for the WebGPU effect container.
|
|
11
|
+
*
|
|
12
|
+
* The chunk package stored the permutation graph, the source reflection, the
|
|
13
|
+
* translated body set and the emitted WGSL as four documents that had to be kept
|
|
14
|
+
* consistent with each other, and carried digests to detect when they were not.
|
|
15
|
+
* Under the record layout there is one document. The permutation graph is the
|
|
16
|
+
* header's own permutation records and offset table, the reflection is the
|
|
17
|
+
* description tree, and a translated pass is that tree's `shaderData` plus its
|
|
18
|
+
* trailing block. So the accessors below are **views**, not stored copies, and
|
|
19
|
+
* the class of bug the digests guarded against cannot occur: there is nothing
|
|
20
|
+
* left to disagree.
|
|
21
|
+
*
|
|
22
|
+
* Keys the chunk format stored explicitly are derived here instead:
|
|
23
|
+
*
|
|
24
|
+
* - a body key is its position among distinct offset-table entries, which is
|
|
25
|
+
* exactly what Carbon's alias dedupe produces;
|
|
26
|
+
* - a pass's technique name, pass index and stage name come from its position in
|
|
27
|
+
* the record tree, which is why cross-technique passes share on the wire;
|
|
28
|
+
* - the WGSL entry point is a constant of the emitter, asserted on write.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
const textDecoder = new TextDecoder("utf-8", {
|
|
32
|
+
fatal: false
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
/** WGSL stage names by Carbon stage type, for the stage types WebGPU supports. */
|
|
36
|
+
const WEBGPU_STAGE_NAME = Object.freeze({
|
|
37
|
+
0: "vertex",
|
|
38
|
+
1: "pixel",
|
|
39
|
+
2: "compute"
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/** WebGPU pipeline stage for a WGSL stage name. */
|
|
43
|
+
const WEBGPU_STAGE = Object.freeze({
|
|
44
|
+
vertex: "vertex",
|
|
45
|
+
pixel: "fragment",
|
|
46
|
+
compute: "compute"
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Reports whether bytes look like a Carbon v15 effect container.
|
|
51
|
+
*
|
|
52
|
+
* This is a **shape** check, not an identity check, and the distinction is the
|
|
53
|
+
* point: our containers are stock Carbon v15 files, so nothing in the bytes
|
|
54
|
+
* separates ours from a shipped `effect.dx11` file. Identity comes from where
|
|
55
|
+
* the file was resolved — `effect.webgpu/` versus `effect.dx11/` — exactly as it
|
|
56
|
+
* does for Carbon, whose three backend trees are also byte-format-identical.
|
|
57
|
+
*
|
|
58
|
+
* Use this to reject something that is not a v15 container at all. Do not use it
|
|
59
|
+
* to decide what a payload is.
|
|
60
|
+
*
|
|
61
|
+
* @param {Uint8Array} bytes Candidate bytes.
|
|
62
|
+
* @returns {boolean} True when the first dword is Carbon's v15 version.
|
|
63
|
+
*/
|
|
64
|
+
function looksLikeCewgpuContainer(bytes) {
|
|
65
|
+
if (!bytes || bytes.length < 4) return false;
|
|
66
|
+
return bytes[0] === 15 && bytes[1] === 0 && bytes[2] === 0 && bytes[3] === 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Decomposes a permutation index into per-axis option indices.
|
|
71
|
+
*
|
|
72
|
+
* The inverse of Carbon's own selection arithmetic: it accumulates
|
|
73
|
+
* `value * multiplier` over the axes in declaration order, multiplying the
|
|
74
|
+
* running radix by each axis's option count.
|
|
75
|
+
*
|
|
76
|
+
* @param {object[]} axes Permutation axis records.
|
|
77
|
+
* @param {number} permutationIndex Permutation index.
|
|
78
|
+
* @returns {number[]} Option index per axis.
|
|
79
|
+
*/
|
|
80
|
+
function optionIndicesFor(axes, permutationIndex) {
|
|
81
|
+
let remaining = permutationIndex;
|
|
82
|
+
return axes.map(axis => {
|
|
83
|
+
const radix = axis.options.length || 1;
|
|
84
|
+
const value = remaining % radix;
|
|
85
|
+
remaining = Math.floor(remaining / radix);
|
|
86
|
+
return value;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Reader over one WebGPU effect container.
|
|
92
|
+
*/
|
|
93
|
+
class CewgpuContainer {
|
|
94
|
+
/**
|
|
95
|
+
* Creates an empty container reader.
|
|
96
|
+
*/
|
|
97
|
+
constructor() {
|
|
98
|
+
this.readError = null;
|
|
99
|
+
this.sourcePath = "";
|
|
100
|
+
this.containerVersion = 0;
|
|
101
|
+
this.bytes = null;
|
|
102
|
+
this.carbon = null;
|
|
103
|
+
this._descriptions = new Map();
|
|
104
|
+
this._bodyKeyByOffset = null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Reads a container from bytes.
|
|
109
|
+
*
|
|
110
|
+
* @param {ArrayBuffer|ArrayBufferView|Uint8Array} source Container bytes.
|
|
111
|
+
* @param {object} [options] Read options.
|
|
112
|
+
* @param {string} [options.sourcePath] Source path for diagnostics.
|
|
113
|
+
* @returns {boolean} True when the container was decoded.
|
|
114
|
+
*/
|
|
115
|
+
Read(source, options = {}) {
|
|
116
|
+
this.readError = null;
|
|
117
|
+
this.sourcePath = options.sourcePath || "";
|
|
118
|
+
this._descriptions = new Map();
|
|
119
|
+
this._bodyKeyByOffset = null;
|
|
120
|
+
try {
|
|
121
|
+
const bytes = source instanceof Uint8Array ? source : source instanceof ArrayBuffer ? new Uint8Array(source) : new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
122
|
+
this.bytes = bytes;
|
|
123
|
+
this.carbon = new CjsCarbonEffectReader(bytes, {
|
|
124
|
+
source: this.sourcePath || "CEWGPU"
|
|
125
|
+
});
|
|
126
|
+
this.containerVersion = this.carbon.version;
|
|
127
|
+
return true;
|
|
128
|
+
} catch (error) {
|
|
129
|
+
this.readError = error;
|
|
130
|
+
this.carbon = null;
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Reports whether the container decoded.
|
|
137
|
+
*
|
|
138
|
+
* @returns {boolean} True when readable.
|
|
139
|
+
*/
|
|
140
|
+
IsGood() {
|
|
141
|
+
return this.carbon !== null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Reads one permutation's description, memoised by stored body.
|
|
146
|
+
*
|
|
147
|
+
* Aliased permutations share one stored blob, so they share one parse.
|
|
148
|
+
*
|
|
149
|
+
* @param {number} permutationIndex Permutation index.
|
|
150
|
+
* @returns {object} Description record tree.
|
|
151
|
+
*/
|
|
152
|
+
GetDescription(permutationIndex) {
|
|
153
|
+
const record = this.carbon.records[permutationIndex];
|
|
154
|
+
if (!record) {
|
|
155
|
+
throw new Error(`CEWGPU container has no body at permutation ${permutationIndex}`);
|
|
156
|
+
}
|
|
157
|
+
if (!this._descriptions.has(record.offset)) {
|
|
158
|
+
this._descriptions.set(record.offset, this.carbon.readDescription(permutationIndex, {
|
|
159
|
+
backend: true
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
return this._descriptions.get(record.offset);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Maps each distinct stored body to a stable key, in offset-table order.
|
|
167
|
+
*
|
|
168
|
+
* @returns {Map<number, string>} Body key by stored offset.
|
|
169
|
+
*/
|
|
170
|
+
get bodyKeyByOffset() {
|
|
171
|
+
if (!this._bodyKeyByOffset) {
|
|
172
|
+
const keys = new Map();
|
|
173
|
+
for (const record of this.carbon.records) {
|
|
174
|
+
if (!keys.has(record.offset)) keys.set(record.offset, `body${keys.size}`);
|
|
175
|
+
}
|
|
176
|
+
this._bodyKeyByOffset = keys;
|
|
177
|
+
}
|
|
178
|
+
return this._bodyKeyByOffset;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Derives the permutation graph the chunk package used to store.
|
|
183
|
+
*
|
|
184
|
+
* @returns {object} Permutation graph view.
|
|
185
|
+
*/
|
|
186
|
+
get permutationGraph() {
|
|
187
|
+
const bodyKeys = this.bodyKeyByOffset;
|
|
188
|
+
const bodies = [];
|
|
189
|
+
for (const [offset, key] of bodyKeys) {
|
|
190
|
+
const record = this.carbon.records.find(entry => entry.offset === offset);
|
|
191
|
+
bodies.push(Object.freeze({
|
|
192
|
+
key,
|
|
193
|
+
offset,
|
|
194
|
+
byteLength: record.size,
|
|
195
|
+
// Hashed from the stored description blob. The chunk graph
|
|
196
|
+
// carried a digest per body; here it is a function of the bytes
|
|
197
|
+
// it identifies, so it cannot disagree with them. It is also what
|
|
198
|
+
// Tr2EffectRes uses to prove bodies are distinct -- aliased rows
|
|
199
|
+
// share one blob and therefore one digest, which is exactly the
|
|
200
|
+
// identity the offset table already expresses.
|
|
201
|
+
sha256: sha256Bytes(this.bytes.subarray(offset, offset + record.size)),
|
|
202
|
+
permutationCount: this.carbon.records.filter(entry => entry.offset === offset).length
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
return Object.freeze({
|
|
206
|
+
// The envelope the chunk `PGRF` document carried. Not provenance:
|
|
207
|
+
// `Tr2EffectRes.SetPayload` validates it before accepting a payload
|
|
208
|
+
// at all, so a graph without it is refused outright.
|
|
209
|
+
format: "CJS_EFFECT_PERMUTATION_GRAPH",
|
|
210
|
+
formatVersion: 1,
|
|
211
|
+
// Fixed by construction rather than recorded. A container always
|
|
212
|
+
// carries every permutation, the offset table gives body identity
|
|
213
|
+
// only, and source reflection is not a separate document.
|
|
214
|
+
coverage: Object.freeze({
|
|
215
|
+
permutations: "complete",
|
|
216
|
+
bodies: "identity-only",
|
|
217
|
+
reflection: "absent"
|
|
218
|
+
}),
|
|
219
|
+
axes: Object.freeze(this.carbon.permutations.map((axis, index) => Object.freeze({
|
|
220
|
+
index,
|
|
221
|
+
name: axis.name.value,
|
|
222
|
+
defaultOption: axis.defaultOption,
|
|
223
|
+
description: axis.description.value,
|
|
224
|
+
type: axis.type,
|
|
225
|
+
options: Object.freeze(axis.options.map(option => option.value))
|
|
226
|
+
}))),
|
|
227
|
+
variants: Object.freeze(this.carbon.records.map((record, permutationIndex) => Object.freeze({
|
|
228
|
+
permutationIndex,
|
|
229
|
+
bodyKey: bodyKeys.get(record.offset),
|
|
230
|
+
// Mixed-radix decomposition of the index over the axes, which
|
|
231
|
+
// is the inverse of the sum Carbon's GetShader() builds when
|
|
232
|
+
// it walks options in declaration order.
|
|
233
|
+
optionIndices: Object.freeze(optionIndicesFor(this.carbon.permutations, permutationIndex)),
|
|
234
|
+
// The offset-table row itself. Aliased permutations share a
|
|
235
|
+
// stored record, so the consumer can prove that two
|
|
236
|
+
// permutations resolve to the same emitted bytes.
|
|
237
|
+
sourceRecord: Object.freeze({
|
|
238
|
+
offset: record.offset,
|
|
239
|
+
byteLength: record.size
|
|
240
|
+
})
|
|
241
|
+
}))),
|
|
242
|
+
bodies: Object.freeze(bodies)
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Resolves the translated backend passes for one permutation.
|
|
248
|
+
*
|
|
249
|
+
* A body whose stages carry no program is reported unsupported, which is
|
|
250
|
+
* what a zero-length `shaderData` means: the reflection is known, the
|
|
251
|
+
* program is not.
|
|
252
|
+
*
|
|
253
|
+
* @param {number} [permutationIndex] Permutation index.
|
|
254
|
+
* @returns {object|null} Resolved backend body.
|
|
255
|
+
*/
|
|
256
|
+
GetBackendBodyPrograms(permutationIndex = 0) {
|
|
257
|
+
if (!this.IsGood()) return null;
|
|
258
|
+
const record = this.carbon.records[permutationIndex];
|
|
259
|
+
if (!record) return null;
|
|
260
|
+
const description = this.GetDescription(permutationIndex);
|
|
261
|
+
const bodyKey = this.bodyKeyByOffset.get(record.offset);
|
|
262
|
+
const passes = [];
|
|
263
|
+
let translated = false;
|
|
264
|
+
for (const technique of description.techniques) {
|
|
265
|
+
for (const [passIndex, pass] of technique.passes.entries()) {
|
|
266
|
+
const passKey = `${technique.name.value}.pass${passIndex}`;
|
|
267
|
+
const shaders = [];
|
|
268
|
+
for (const stage of pass.stages) {
|
|
269
|
+
const stageName = WEBGPU_STAGE_NAME[stage.type];
|
|
270
|
+
if (!stageName || stage.shaderData.size === 0) continue;
|
|
271
|
+
translated = true;
|
|
272
|
+
shaders.push(Object.freeze({
|
|
273
|
+
key: `${passKey}.${stageName}`,
|
|
274
|
+
techniqueName: technique.name.value,
|
|
275
|
+
passIndex,
|
|
276
|
+
stageName,
|
|
277
|
+
stage: WEBGPU_STAGE[stageName],
|
|
278
|
+
stageType: stage.type,
|
|
279
|
+
entryPoint: WGSL_ENTRY_POINT,
|
|
280
|
+
code: textDecoder.decode(stage.shaderData.bytes),
|
|
281
|
+
...(stageName === "compute" ? {
|
|
282
|
+
threadGroupSize: [...stage.threadGroupSize]
|
|
283
|
+
} : {})
|
|
284
|
+
}));
|
|
285
|
+
}
|
|
286
|
+
if (!shaders.length) continue;
|
|
287
|
+
const block = pass.backendBlock && pass.backendBlock.size !== 0 ? readBackendBlock(pass.backendBlock.bytes, {
|
|
288
|
+
layoutKey: passKey,
|
|
289
|
+
source: this.sourcePath || "CEWGPU"
|
|
290
|
+
}) : null;
|
|
291
|
+
passes.push(Object.freeze({
|
|
292
|
+
passKey,
|
|
293
|
+
shaders: Object.freeze(shaders),
|
|
294
|
+
layouts: Object.freeze(block ? [Object.freeze({
|
|
295
|
+
key: passKey,
|
|
296
|
+
techniqueName: technique.name.value,
|
|
297
|
+
passIndex,
|
|
298
|
+
bindGroups: block.bindGroups
|
|
299
|
+
})] : []),
|
|
300
|
+
...(block?.transforms?.length ? {
|
|
301
|
+
resourceTransforms: Object.freeze(block.transforms)
|
|
302
|
+
} : {})
|
|
303
|
+
}));
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return Object.freeze({
|
|
307
|
+
permutationIndex,
|
|
308
|
+
bodyKey,
|
|
309
|
+
status: translated ? "translated" : "unsupported",
|
|
310
|
+
error: translated ? null : "body carries no translated programs",
|
|
311
|
+
passes: Object.freeze(passes)
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Derives the body-set view, for consumers holding the raw container.
|
|
317
|
+
*
|
|
318
|
+
* `packageToJson` exposes the same document. A consumer taking the raw emit
|
|
319
|
+
* reads it here instead, which is why this is a getter on the container
|
|
320
|
+
* rather than only a field in the JSON projection.
|
|
321
|
+
*
|
|
322
|
+
* @returns {object} Body-set document.
|
|
323
|
+
*/
|
|
324
|
+
get backendBodySet() {
|
|
325
|
+
return deriveBackendBodySet(this);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Returns the Carbon description currently exposed through the legacy
|
|
330
|
+
* portable-reflection accessor.
|
|
331
|
+
*
|
|
332
|
+
* This is not a `CJS_EFFECT_BODY_REFLECTION` envelope. Direct
|
|
333
|
+
* `Tr2EffectRes` hydration requires an adapter and remains an open
|
|
334
|
+
* integration boundary.
|
|
335
|
+
*
|
|
336
|
+
* @param {number} [permutationIndex] Permutation index.
|
|
337
|
+
* @returns {object|null} Raw Carbon description record tree.
|
|
338
|
+
*/
|
|
339
|
+
GetPortableEffectReflection(permutationIndex = 0) {
|
|
340
|
+
if (!this.IsGood()) return null;
|
|
341
|
+
return this.GetDescription(permutationIndex);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Summarises the container without materialising every body.
|
|
346
|
+
*
|
|
347
|
+
* @returns {object} Container summary.
|
|
348
|
+
*/
|
|
349
|
+
get info() {
|
|
350
|
+
const bodyKeys = this.bodyKeyByOffset;
|
|
351
|
+
return Object.freeze({
|
|
352
|
+
format: "CEWGPU",
|
|
353
|
+
// Carbon's own version dword, always 15. There is no container
|
|
354
|
+
// version of ours: see buildCarbonEffectContainer for why nothing
|
|
355
|
+
// announces the payload, and why identity comes from the path.
|
|
356
|
+
containerVersion: this.containerVersion,
|
|
357
|
+
sourcePath: this.sourcePath,
|
|
358
|
+
compilerVersion: Object.freeze([...this.carbon.compilerVersion]),
|
|
359
|
+
sourceHash: textDecoder.decode(this.carbon.sourceHash),
|
|
360
|
+
permutationCount: this.carbon.records.length,
|
|
361
|
+
uniqueBodyCount: bodyKeys.size,
|
|
362
|
+
axisCount: this.carbon.permutations.length
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export { CewgpuContainer, looksLikeCewgpuContainer };
|
|
368
|
+
//# sourceMappingURL=CewgpuContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CewgpuContainer.js","sources":["../../../../../../src/formats/webgpu/core/cewgpu/CewgpuContainer.js"],"sourcesContent":["import {\n CjsCarbonEffectReader,\n readBackendBlock\n} from \"../../../../format/carbonEffect/index.js\";\nimport { WGSL_ENTRY_POINT } from \"../buildCarbonEffectContainer.js\";\nimport { sha256Bytes } from \"../../../../format/effect/sha256.js\";\nimport { deriveBackendBodySet } from \"./containerViews.js\";\n\n/**\n * Reader for the WebGPU effect container.\n *\n * The chunk package stored the permutation graph, the source reflection, the\n * translated body set and the emitted WGSL as four documents that had to be kept\n * consistent with each other, and carried digests to detect when they were not.\n * Under the record layout there is one document. The permutation graph is the\n * header's own permutation records and offset table, the reflection is the\n * description tree, and a translated pass is that tree's `shaderData` plus its\n * trailing block. So the accessors below are **views**, not stored copies, and\n * the class of bug the digests guarded against cannot occur: there is nothing\n * left to disagree.\n *\n * Keys the chunk format stored explicitly are derived here instead:\n *\n * - a body key is its position among distinct offset-table entries, which is\n * exactly what Carbon's alias dedupe produces;\n * - a pass's technique name, pass index and stage name come from its position in\n * the record tree, which is why cross-technique passes share on the wire;\n * - the WGSL entry point is a constant of the emitter, asserted on write.\n */\n\nconst textDecoder = new TextDecoder(\"utf-8\", { fatal: false });\n\n/** WGSL stage names by Carbon stage type, for the stage types WebGPU supports. */\nconst WEBGPU_STAGE_NAME = Object.freeze({ 0: \"vertex\", 1: \"pixel\", 2: \"compute\" });\n\n/** WebGPU pipeline stage for a WGSL stage name. */\nconst WEBGPU_STAGE = Object.freeze({ vertex: \"vertex\", pixel: \"fragment\", compute: \"compute\" });\n\n/**\n * Reports whether bytes look like a Carbon v15 effect container.\n *\n * This is a **shape** check, not an identity check, and the distinction is the\n * point: our containers are stock Carbon v15 files, so nothing in the bytes\n * separates ours from a shipped `effect.dx11` file. Identity comes from where\n * the file was resolved — `effect.webgpu/` versus `effect.dx11/` — exactly as it\n * does for Carbon, whose three backend trees are also byte-format-identical.\n *\n * Use this to reject something that is not a v15 container at all. Do not use it\n * to decide what a payload is.\n *\n * @param {Uint8Array} bytes Candidate bytes.\n * @returns {boolean} True when the first dword is Carbon's v15 version.\n */\nexport function looksLikeCewgpuContainer(bytes)\n{\n if (!bytes || bytes.length < 4) return false;\n return bytes[0] === 15 && bytes[1] === 0 && bytes[2] === 0 && bytes[3] === 0;\n}\n\n/**\n * Decomposes a permutation index into per-axis option indices.\n *\n * The inverse of Carbon's own selection arithmetic: it accumulates\n * `value * multiplier` over the axes in declaration order, multiplying the\n * running radix by each axis's option count.\n *\n * @param {object[]} axes Permutation axis records.\n * @param {number} permutationIndex Permutation index.\n * @returns {number[]} Option index per axis.\n */\nfunction optionIndicesFor(axes, permutationIndex)\n{\n let remaining = permutationIndex;\n return axes.map((axis) =>\n {\n const radix = axis.options.length || 1;\n const value = remaining % radix;\n remaining = Math.floor(remaining / radix);\n return value;\n });\n}\n\n/**\n * Reader over one WebGPU effect container.\n */\nexport class CewgpuContainer\n{\n /**\n * Creates an empty container reader.\n */\n constructor()\n {\n this.readError = null;\n this.sourcePath = \"\";\n this.containerVersion = 0;\n this.bytes = null;\n this.carbon = null;\n this._descriptions = new Map();\n this._bodyKeyByOffset = null;\n }\n\n /**\n * Reads a container from bytes.\n *\n * @param {ArrayBuffer|ArrayBufferView|Uint8Array} source Container bytes.\n * @param {object} [options] Read options.\n * @param {string} [options.sourcePath] Source path for diagnostics.\n * @returns {boolean} True when the container was decoded.\n */\n Read(source, options = {})\n {\n this.readError = null;\n this.sourcePath = options.sourcePath || \"\";\n this._descriptions = new Map();\n this._bodyKeyByOffset = null;\n\n try\n {\n const bytes = source instanceof Uint8Array\n ? source\n : (source instanceof ArrayBuffer\n ? new Uint8Array(source)\n : new Uint8Array(source.buffer, source.byteOffset, source.byteLength));\n\n this.bytes = bytes;\n this.carbon = new CjsCarbonEffectReader(bytes, {\n source: this.sourcePath || \"CEWGPU\"\n });\n this.containerVersion = this.carbon.version;\n return true;\n }\n catch (error)\n {\n this.readError = error;\n this.carbon = null;\n return false;\n }\n }\n\n /**\n * Reports whether the container decoded.\n *\n * @returns {boolean} True when readable.\n */\n IsGood()\n {\n return this.carbon !== null;\n }\n\n /**\n * Reads one permutation's description, memoised by stored body.\n *\n * Aliased permutations share one stored blob, so they share one parse.\n *\n * @param {number} permutationIndex Permutation index.\n * @returns {object} Description record tree.\n */\n GetDescription(permutationIndex)\n {\n const record = this.carbon.records[permutationIndex];\n if (!record)\n {\n throw new Error(`CEWGPU container has no body at permutation ${permutationIndex}`);\n }\n if (!this._descriptions.has(record.offset))\n {\n this._descriptions.set(\n record.offset,\n this.carbon.readDescription(permutationIndex, { backend: true })\n );\n }\n return this._descriptions.get(record.offset);\n }\n\n /**\n * Maps each distinct stored body to a stable key, in offset-table order.\n *\n * @returns {Map<number, string>} Body key by stored offset.\n */\n get bodyKeyByOffset()\n {\n if (!this._bodyKeyByOffset)\n {\n const keys = new Map();\n for (const record of this.carbon.records)\n {\n if (!keys.has(record.offset)) keys.set(record.offset, `body${keys.size}`);\n }\n this._bodyKeyByOffset = keys;\n }\n return this._bodyKeyByOffset;\n }\n\n /**\n * Derives the permutation graph the chunk package used to store.\n *\n * @returns {object} Permutation graph view.\n */\n get permutationGraph()\n {\n const bodyKeys = this.bodyKeyByOffset;\n const bodies = [];\n\n for (const [ offset, key ] of bodyKeys)\n {\n const record = this.carbon.records.find((entry) => entry.offset === offset);\n bodies.push(Object.freeze({\n key,\n offset,\n byteLength: record.size,\n // Hashed from the stored description blob. The chunk graph\n // carried a digest per body; here it is a function of the bytes\n // it identifies, so it cannot disagree with them. It is also what\n // Tr2EffectRes uses to prove bodies are distinct -- aliased rows\n // share one blob and therefore one digest, which is exactly the\n // identity the offset table already expresses.\n sha256: sha256Bytes(this.bytes.subarray(offset, offset + record.size)),\n permutationCount: this.carbon.records\n .filter((entry) => entry.offset === offset).length\n }));\n }\n\n return Object.freeze({\n // The envelope the chunk `PGRF` document carried. Not provenance:\n // `Tr2EffectRes.SetPayload` validates it before accepting a payload\n // at all, so a graph without it is refused outright.\n format: \"CJS_EFFECT_PERMUTATION_GRAPH\",\n formatVersion: 1,\n // Fixed by construction rather than recorded. A container always\n // carries every permutation, the offset table gives body identity\n // only, and source reflection is not a separate document.\n coverage: Object.freeze({\n permutations: \"complete\",\n bodies: \"identity-only\",\n reflection: \"absent\"\n }),\n axes: Object.freeze(this.carbon.permutations.map((axis, index) => Object.freeze({\n index,\n name: axis.name.value,\n defaultOption: axis.defaultOption,\n description: axis.description.value,\n type: axis.type,\n options: Object.freeze(axis.options.map((option) => option.value))\n }))),\n variants: Object.freeze(this.carbon.records.map((record, permutationIndex) =>\n Object.freeze({\n permutationIndex,\n bodyKey: bodyKeys.get(record.offset),\n // Mixed-radix decomposition of the index over the axes, which\n // is the inverse of the sum Carbon's GetShader() builds when\n // it walks options in declaration order.\n optionIndices: Object.freeze(\n optionIndicesFor(this.carbon.permutations, permutationIndex)\n ),\n // The offset-table row itself. Aliased permutations share a\n // stored record, so the consumer can prove that two\n // permutations resolve to the same emitted bytes.\n sourceRecord: Object.freeze({\n offset: record.offset,\n byteLength: record.size\n })\n }))),\n bodies: Object.freeze(bodies)\n });\n }\n\n /**\n * Resolves the translated backend passes for one permutation.\n *\n * A body whose stages carry no program is reported unsupported, which is\n * what a zero-length `shaderData` means: the reflection is known, the\n * program is not.\n *\n * @param {number} [permutationIndex] Permutation index.\n * @returns {object|null} Resolved backend body.\n */\n GetBackendBodyPrograms(permutationIndex = 0)\n {\n if (!this.IsGood()) return null;\n\n const record = this.carbon.records[permutationIndex];\n if (!record) return null;\n\n const description = this.GetDescription(permutationIndex);\n const bodyKey = this.bodyKeyByOffset.get(record.offset);\n const passes = [];\n let translated = false;\n\n for (const technique of description.techniques)\n {\n for (const [ passIndex, pass ] of technique.passes.entries())\n {\n const passKey = `${technique.name.value}.pass${passIndex}`;\n const shaders = [];\n\n for (const stage of pass.stages)\n {\n const stageName = WEBGPU_STAGE_NAME[stage.type];\n if (!stageName || stage.shaderData.size === 0) continue;\n translated = true;\n shaders.push(Object.freeze({\n key: `${passKey}.${stageName}`,\n techniqueName: technique.name.value,\n passIndex,\n stageName,\n stage: WEBGPU_STAGE[stageName],\n stageType: stage.type,\n entryPoint: WGSL_ENTRY_POINT,\n code: textDecoder.decode(stage.shaderData.bytes),\n ...(stageName === \"compute\"\n ? { threadGroupSize: [ ...stage.threadGroupSize ] }\n : {})\n }));\n }\n\n if (!shaders.length) continue;\n\n const block = pass.backendBlock && pass.backendBlock.size !== 0\n ? readBackendBlock(pass.backendBlock.bytes, {\n layoutKey: passKey,\n source: this.sourcePath || \"CEWGPU\"\n })\n : null;\n\n passes.push(Object.freeze({\n passKey,\n shaders: Object.freeze(shaders),\n layouts: Object.freeze(block\n ? [ Object.freeze({\n key: passKey,\n techniqueName: technique.name.value,\n passIndex,\n bindGroups: block.bindGroups\n }) ]\n : []),\n ...(block?.transforms?.length\n ? { resourceTransforms: Object.freeze(block.transforms) }\n : {})\n }));\n }\n }\n\n return Object.freeze({\n permutationIndex,\n bodyKey,\n status: translated ? \"translated\" : \"unsupported\",\n error: translated ? null : \"body carries no translated programs\",\n passes: Object.freeze(passes)\n });\n }\n\n /**\n * Derives the body-set view, for consumers holding the raw container.\n *\n * `packageToJson` exposes the same document. A consumer taking the raw emit\n * reads it here instead, which is why this is a getter on the container\n * rather than only a field in the JSON projection.\n *\n * @returns {object} Body-set document.\n */\n get backendBodySet()\n {\n return deriveBackendBodySet(this);\n }\n\n /**\n * Returns the Carbon description currently exposed through the legacy\n * portable-reflection accessor.\n *\n * This is not a `CJS_EFFECT_BODY_REFLECTION` envelope. Direct\n * `Tr2EffectRes` hydration requires an adapter and remains an open\n * integration boundary.\n *\n * @param {number} [permutationIndex] Permutation index.\n * @returns {object|null} Raw Carbon description record tree.\n */\n GetPortableEffectReflection(permutationIndex = 0)\n {\n if (!this.IsGood()) return null;\n return this.GetDescription(permutationIndex);\n }\n\n /**\n * Summarises the container without materialising every body.\n *\n * @returns {object} Container summary.\n */\n get info()\n {\n const bodyKeys = this.bodyKeyByOffset;\n return Object.freeze({\n format: \"CEWGPU\",\n // Carbon's own version dword, always 15. There is no container\n // version of ours: see buildCarbonEffectContainer for why nothing\n // announces the payload, and why identity comes from the path.\n containerVersion: this.containerVersion,\n sourcePath: this.sourcePath,\n compilerVersion: Object.freeze([ ...this.carbon.compilerVersion ]),\n sourceHash: textDecoder.decode(this.carbon.sourceHash),\n permutationCount: this.carbon.records.length,\n uniqueBodyCount: bodyKeys.size,\n axisCount: this.carbon.permutations.length\n });\n }\n}\n\nexport default CewgpuContainer;\n"],"names":["textDecoder","TextDecoder","fatal","WEBGPU_STAGE_NAME","Object","freeze","WEBGPU_STAGE","vertex","pixel","compute","looksLikeCewgpuContainer","bytes","length","optionIndicesFor","axes","permutationIndex","remaining","map","axis","radix","options","value","Math","floor","CewgpuContainer","constructor","readError","sourcePath","containerVersion","carbon","_descriptions","Map","_bodyKeyByOffset","Read","source","Uint8Array","ArrayBuffer","buffer","byteOffset","byteLength","CjsCarbonEffectReader","version","error","IsGood","GetDescription","record","records","Error","has","offset","set","readDescription","backend","get","bodyKeyByOffset","keys","size","permutationGraph","bodyKeys","bodies","key","find","entry","push","sha256","sha256Bytes","subarray","permutationCount","filter","format","formatVersion","coverage","permutations","reflection","index","name","defaultOption","description","type","option","variants","bodyKey","optionIndices","sourceRecord","GetBackendBodyPrograms","passes","translated","technique","techniques","passIndex","pass","entries","passKey","shaders","stage","stages","stageName","shaderData","techniqueName","stageType","entryPoint","WGSL_ENTRY_POINT","code","decode","threadGroupSize","block","backendBlock","readBackendBlock","layoutKey","layouts","bindGroups","transforms","resourceTransforms","status","backendBodySet","deriveBackendBodySet","GetPortableEffectReflection","info","compilerVersion","sourceHash","uniqueBodyCount","axisCount"],"mappings":";;;;;;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,WAAW,GAAG,IAAIC,WAAW,CAAC,OAAO,EAAE;AAAEC,EAAAA,KAAK,EAAE;AAAM,CAAC,CAAC;;AAE9D;AACA,MAAMC,iBAAiB,GAAGC,MAAM,CAACC,MAAM,CAAC;AAAE,EAAA,CAAC,EAAE,QAAQ;AAAE,EAAA,CAAC,EAAE,OAAO;AAAE,EAAA,CAAC,EAAE;AAAU,CAAC,CAAC;;AAElF;AACA,MAAMC,YAAY,GAAGF,MAAM,CAACC,MAAM,CAAC;AAAEE,EAAAA,MAAM,EAAE,QAAQ;AAAEC,EAAAA,KAAK,EAAE,UAAU;AAAEC,EAAAA,OAAO,EAAE;AAAU,CAAC,CAAC;;AAE/F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,wBAAwBA,CAACC,KAAK,EAC9C;EACI,IAAI,CAACA,KAAK,IAAIA,KAAK,CAACC,MAAM,GAAG,CAAC,EAAE,OAAO,KAAK;EAC5C,OAAOD,KAAK,C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