@carbonenginejs/runtime-resource 0.15.0 → 0.17.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/dist/format/CjsFormat.js +84 -83
- package/dist/format/CjsFormat.js.map +1 -1
- package/dist/format/CjsResourceProbe.js +87 -86
- package/dist/format/CjsResourceProbe.js.map +1 -1
- package/dist/format/carbonEffect/backendEngineId.js +100 -0
- package/dist/format/carbonEffect/backendEngineId.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js +23 -23
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
- package/dist/format/index.js +1 -1
- package/dist/formats/png/core/helpers.js +27 -8
- package/dist/formats/png/core/helpers.js.map +1 -1
- package/dist/formats/webgl/core/effectPackage.js +141 -53
- package/dist/formats/webgl/core/effectPackage.js.map +1 -1
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +799 -456
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
- package/dist/formats/webgl/core/glslBackendBlock.js +70 -27
- package/dist/formats/webgl/core/glslBackendBlock.js.map +1 -1
- package/dist/formats/webgl/core/helpers.js +53 -53
- package/dist/formats/webgl/core/helpers.js.map +1 -1
- package/dist/formats/webgl/core/readGlslEffectContainer.js +82 -67
- package/dist/formats/webgl/core/readGlslEffectContainer.js.map +1 -1
- package/dist/formats/webgpu/core/carbonWebgpu/CarbonWebgpuContainer.js +10 -1
- package/dist/formats/webgpu/core/carbonWebgpu/CarbonWebgpuContainer.js.map +1 -1
- package/dist/formats/wem/CjsWemFormat.js +121 -121
- package/dist/formats/wem/CjsWemFormat.js.map +1 -1
- package/dist/formats/wem/core/resolve.js +8 -8
- package/dist/formats/wem/core/resolve.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +2 -2
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectResource.js +2 -2
- package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js +102 -60
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepCompress.js +2 -2
- package/dist/resource/texture/Tr2TexturePipelineStepCompress.js.map +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepPack.js +2 -2
- package/dist/resource/texture/Tr2TexturePipelineStepPack.js.map +1 -1
- package/docs/concepts/format-type-resolution.md +79 -0
- package/docs/formats/README.md +11 -0
- package/docs/formats/wwise.md +25 -0
- package/docs/roadmap.md +19 -0
- package/package.json +61 -61
|
@@ -1,62 +1,63 @@
|
|
|
1
1
|
import { CjsCarbonEffectReader } from '../../../format/carbonEffect/CjsCarbonEffectReader.js';
|
|
2
2
|
import { readGlslBackendBlock } from './glslBackendBlock.js';
|
|
3
|
+
import { peekBackendEngineId, CARBON_BACKEND_ENGINE_ID } from '../../../format/carbonEffect/backendEngineId.js';
|
|
3
4
|
import { hlslShaderStageName } from '../../hlsl/core/tr2/HlslRenderContextEnum.js';
|
|
4
5
|
import { runtimeDescriptionFromCarbon } from '../../hlsl/core/carbonDescriptionToRuntime.js';
|
|
5
6
|
import { HlslEffectBindingManifest } from '../../hlsl/core/tr2/shader/HlslEffectBindingManifest.js';
|
|
6
7
|
|
|
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.
|
|
8
|
+
/**
|
|
9
|
+
* Decodes a WebGL effect container into the stage/shader records the
|
|
10
|
+
* completeness rules consume.
|
|
11
|
+
*
|
|
12
|
+
* This exists so the rules run from container bytes alone. The alternative was
|
|
13
|
+
* to hand them the in-memory translation, which works inside `buildEffectPackage`
|
|
14
|
+
* and nowhere else — the validator reads a finished file and has no translation
|
|
15
|
+
* in scope. That would have cost the validator its completeness check while
|
|
16
|
+
* still requiring a decoder to produce the programs it compiles in a browser, so
|
|
17
|
+
* it was strictly more work for strictly less checking.
|
|
18
|
+
*
|
|
19
|
+
* The vocabulary is deliberately the one the rules already speak — `stages` with
|
|
20
|
+
* pass coordinates, `shaders` with source and a translation verdict. The rules
|
|
21
|
+
* are about the translation, not about how it was stored, so retargeting them
|
|
22
|
+
* meant changing where the records come from and nothing about what they mean.
|
|
23
|
+
*
|
|
24
|
+
* **What the wire cannot tell you.** `buildCarbonEffectContainer` stores a body
|
|
25
|
+
* the translator could not lower as its full pass tree with zero-length
|
|
26
|
+
* programs; the *reason* it failed stays in the in-memory build result and is
|
|
27
|
+
* never written. So a shader decoded from bytes reports `ok: false` with
|
|
28
|
+
* "no program was stored" and nothing more specific. That is the honest answer:
|
|
29
|
+
* a file on disk does not know why a translation failed months ago. Callers that
|
|
30
|
+
* do know — `buildEffectPackage`, at build time — keep their specific
|
|
31
|
+
* diagnostics by feeding the rules their own records instead.
|
|
31
32
|
*/
|
|
32
33
|
|
|
33
34
|
/** The verdict a stage carrying no stored program gets. */
|
|
34
35
|
const NO_PROGRAM_REASON = "no program was stored";
|
|
35
36
|
|
|
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`.
|
|
37
|
+
/**
|
|
38
|
+
* Derives the per-stage binding manifests for one body through the one
|
|
39
|
+
* manifest builder the source path uses.
|
|
40
|
+
*
|
|
41
|
+
* This replaces a hand-built reshape of the wire records into the manifest
|
|
42
|
+
* vocabulary. That copy had already diverged from the real manifest once —
|
|
43
|
+
* `isAutoregister` was silently dropped, making every resource look
|
|
44
|
+
* user-settable — which is the whole argument against a second producer: two
|
|
45
|
+
* hand-maintained spellings of one reflection drift, and the drift is exactly
|
|
46
|
+
* the kind of bug that draws, links and renders black without an error. The
|
|
47
|
+
* record tree now flows through `runtimeDescriptionFromCarbon` — the
|
|
48
|
+
* corpus-proven adapter the runtime read path uses — and
|
|
49
|
+
* `HlslEffectBindingManifest`, so the container read and the build-time
|
|
50
|
+
* package derive their manifests from the same code.
|
|
51
|
+
*
|
|
52
|
+
* No `bytecodeFor` is supplied: program text lives in the shader records this
|
|
53
|
+
* reader emits, so the manifest's `shaderBytecode` stays null rather than
|
|
54
|
+
* duplicating every program into the reflection.
|
|
55
|
+
*
|
|
56
|
+
* @param {object} description Decoded Carbon description record tree.
|
|
57
|
+
* @param {number} version Container data version.
|
|
58
|
+
* @param {string} source Source name for diagnostics.
|
|
59
|
+
* @returns {Map<string, object>} Manifest stage records keyed by
|
|
60
|
+
* `technique.passN.stageName`.
|
|
60
61
|
*/
|
|
61
62
|
function bodyManifestStages(description, version, source) {
|
|
62
63
|
const runtime = runtimeDescriptionFromCarbon(description, {
|
|
@@ -67,19 +68,33 @@ function bodyManifestStages(description, version, source) {
|
|
|
67
68
|
return new Map(manifest.stages.map(stage => [`${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`, stage]));
|
|
68
69
|
}
|
|
69
70
|
|
|
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.
|
|
71
|
+
/**
|
|
72
|
+
* Decodes one pass's backend block, tolerating a pass that has none.
|
|
73
|
+
*
|
|
74
|
+
* @param {object} pass Decoded pass record.
|
|
75
|
+
* @param {string} passKey Enclosing pass key.
|
|
76
|
+
* @param {string} source Source name for error details.
|
|
77
|
+
* @returns {object} Per-stage backend data, keyed by stage name.
|
|
77
78
|
*/
|
|
78
79
|
function backendStages(pass, passKey, source) {
|
|
79
80
|
if (!pass.backendBlock?.size) return {
|
|
80
81
|
stages: {},
|
|
81
82
|
transforms: []
|
|
82
83
|
};
|
|
84
|
+
|
|
85
|
+
// A block belonging to another backend is not an error here. The container
|
|
86
|
+
// is Carbon-shaped whatever it targets, and loading it must not depend on
|
|
87
|
+
// being able to use its programs - a dx11 container loads and simply cannot
|
|
88
|
+
// be executed by this library. Report no backend data and let prepare fail
|
|
89
|
+
// where the backend actually matters.
|
|
90
|
+
const engineId = peekBackendEngineId(pass.backendBlock.bytes);
|
|
91
|
+
if (engineId !== CARBON_BACKEND_ENGINE_ID.webgl2) {
|
|
92
|
+
return {
|
|
93
|
+
stages: {},
|
|
94
|
+
transforms: [],
|
|
95
|
+
foreignEngineId: engineId
|
|
96
|
+
};
|
|
97
|
+
}
|
|
83
98
|
const block = readGlslBackendBlock(pass.backendBlock.bytes, {
|
|
84
99
|
layoutKey: passKey,
|
|
85
100
|
source
|
|
@@ -90,18 +105,18 @@ function backendStages(pass, passKey, source) {
|
|
|
90
105
|
};
|
|
91
106
|
}
|
|
92
107
|
|
|
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.
|
|
108
|
+
/**
|
|
109
|
+
* Decodes container bytes into stage and shader records.
|
|
110
|
+
*
|
|
111
|
+
* Bodies are decoded once each rather than once per permutation row: rows alias
|
|
112
|
+
* onto shared bodies, and a rule that saw the same body 4,096 times would report
|
|
113
|
+
* 4,096 identical incomplete passes.
|
|
114
|
+
*
|
|
115
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Container payload.
|
|
116
|
+
* @param {object} [values] Read values.
|
|
117
|
+
* @param {string} [values.source] Source name, for diagnostics.
|
|
118
|
+
* @returns {{stages:object[], shaders:object[], recordCount:number, bodyCount:number}}
|
|
119
|
+
* Stage graph in the completeness rules' vocabulary.
|
|
105
120
|
*/
|
|
106
121
|
function readGlslEffectContainer(input, values = {}) {
|
|
107
122
|
const source = values.source ?? "memory";
|
|
@@ -1 +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,IA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,YAAAA;AACJ,WAAC,CAAC;AACN,QAAA;AACJ,MAAA;AACJ,IAAA;AACJ,EAAA;;AAEA;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;;;;"}
|
|
1
|
+
{"version":3,"file":"readGlslEffectContainer.js","sources":["../../../../../src/formats/webgl/core/readGlslEffectContainer.js"],"sourcesContent":["import { CjsCarbonEffectReader } from \"../../../format/carbonEffect/CjsCarbonEffectReader.js\";\nimport { readGlslBackendBlock } from \"./glslBackendBlock.js\";\nimport {\n CARBON_BACKEND_ENGINE_ID,\n peekBackendEngineId\n} from \"../../../format/carbonEffect/backendEngineId.js\";\nimport { hlslShaderStageName } from \"../../hlsl/core/tr2/HlslRenderContextEnum.js\";\nimport { runtimeDescriptionFromCarbon } from \"../../hlsl/core/carbonDescriptionToRuntime.js\";\nimport { HlslEffectBindingManifest } from \"../../hlsl/core/tr2/shader/HlslEffectBindingManifest.js\";\n\n/**\n * Decodes a WebGL effect container into the stage/shader records the\n * completeness rules consume.\n *\n * This exists so the rules run from container bytes alone. The alternative was\n * to hand them the in-memory translation, which works inside `buildEffectPackage`\n * and nowhere else — the validator reads a finished file and has no translation\n * in scope. That would have cost the validator its completeness check while\n * still requiring a decoder to produce the programs it compiles in a browser, so\n * it was strictly more work for strictly less checking.\n *\n * The vocabulary is deliberately the one the rules already speak — `stages` with\n * pass coordinates, `shaders` with source and a translation verdict. The rules\n * are about the translation, not about how it was stored, so retargeting them\n * meant changing where the records come from and nothing about what they mean.\n *\n * **What the wire cannot tell you.** `buildCarbonEffectContainer` stores a body\n * the translator could not lower as its full pass tree with zero-length\n * programs; the *reason* it failed stays in the in-memory build result and is\n * never written. So a shader decoded from bytes reports `ok: false` with\n * \"no program was stored\" and nothing more specific. That is the honest answer:\n * a file on disk does not know why a translation failed months ago. Callers that\n * do know — `buildEffectPackage`, at build time — keep their specific\n * diagnostics by feeding the rules their own records instead.\n */\n\n/** The verdict a stage carrying no stored program gets. */\nconst NO_PROGRAM_REASON = \"no program was stored\";\n\n/**\n * Derives the per-stage binding manifests for one body through the one\n * manifest builder the source path uses.\n *\n * This replaces a hand-built reshape of the wire records into the manifest\n * vocabulary. That copy had already diverged from the real manifest once —\n * `isAutoregister` was silently dropped, making every resource look\n * user-settable — which is the whole argument against a second producer: two\n * hand-maintained spellings of one reflection drift, and the drift is exactly\n * the kind of bug that draws, links and renders black without an error. The\n * record tree now flows through `runtimeDescriptionFromCarbon` — the\n * corpus-proven adapter the runtime read path uses — and\n * `HlslEffectBindingManifest`, so the container read and the build-time\n * package derive their manifests from the same code.\n *\n * No `bytecodeFor` is supplied: program text lives in the shader records this\n * reader emits, so the manifest's `shaderBytecode` stays null rather than\n * duplicating every program into the reflection.\n *\n * @param {object} description Decoded Carbon description record tree.\n * @param {number} version Container data version.\n * @param {string} source Source name for diagnostics.\n * @returns {Map<string, object>} Manifest stage records keyed by\n * `technique.passN.stageName`.\n */\nfunction bodyManifestStages(description, version, source)\n{\n const runtime = runtimeDescriptionFromCarbon(description, {\n effectName: source,\n version\n });\n const manifest = HlslEffectBindingManifest.fromEffectDescription(runtime).toJSON();\n return new Map(manifest.stages.map((stage) => [\n `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`,\n stage\n ]));\n}\n\n/**\n * Decodes one pass's backend block, tolerating a pass that has none.\n *\n * @param {object} pass Decoded pass record.\n * @param {string} passKey Enclosing pass key.\n * @param {string} source Source name for error details.\n * @returns {object} Per-stage backend data, keyed by stage name.\n */\nfunction backendStages(pass, passKey, source)\n{\n if (!pass.backendBlock?.size) return { stages: {}, transforms: [] };\n\n // A block belonging to another backend is not an error here. The container\n // is Carbon-shaped whatever it targets, and loading it must not depend on\n // being able to use its programs - a dx11 container loads and simply cannot\n // be executed by this library. Report no backend data and let prepare fail\n // where the backend actually matters.\n const engineId = peekBackendEngineId(pass.backendBlock.bytes);\n if (engineId !== CARBON_BACKEND_ENGINE_ID.webgl2)\n {\n return { stages: {}, transforms: [], foreignEngineId: engineId };\n }\n\n const block = readGlslBackendBlock(pass.backendBlock.bytes, { layoutKey: passKey, source });\n return { stages: block.stages ?? {}, transforms: block.transforms ?? [] };\n}\n\n/**\n * Decodes container bytes into stage and shader records.\n *\n * Bodies are decoded once each rather than once per permutation row: rows alias\n * onto shared bodies, and a rule that saw the same body 4,096 times would report\n * 4,096 identical incomplete passes.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Container payload.\n * @param {object} [values] Read values.\n * @param {string} [values.source] Source name, for diagnostics.\n * @returns {{stages:object[], shaders:object[], recordCount:number, bodyCount:number}}\n * Stage graph in the completeness rules' vocabulary.\n */\nexport function readGlslEffectContainer(input, values = {})\n{\n const source = values.source ?? \"memory\";\n const reader = new CjsCarbonEffectReader(input, { source });\n\n const stages = [];\n const shaders = [];\n const bodyKeyByOffset = new Map();\n\n // Every permutation index that resolves to each body.\n //\n // This is the bridge a caller actually needs, and the only one that is\n // sound. `bodyKey` here is this reader's own ordinal spelling; the\n // permutation graph mints `body${N}` for the same body, and the two are not\n // merely spelled differently — the graph dedupes by content (SHA-256 plus\n // byte equality) while this reader dedupes by source-record offset. Those\n // partitions coincide only because the container writer aliases\n // byte-identical bodies onto one offset, which is a property of the writer\n // rather than a contract.\n //\n // So a consumer must never map between the two by string surgery on either\n // spelling, and must not assume the two ordinal sequences agree. It holds a\n // permutation index; this gives it the body directly.\n const permutationIndicesByOffset = new Map();\n\n for (let index = 0; index < reader.records.length; index += 1)\n {\n const { offset } = reader.records[index];\n const seen = permutationIndicesByOffset.get(offset);\n if (seen) seen.push(index);\n else permutationIndicesByOffset.set(offset, [ index ]);\n }\n\n // Distinct program texts share one shader record, so `shaders` counts unique\n // translations the way the chunk package's shader table did. Empty stages are\n // deliberately *not* pooled: each keeps its own record so a report can name\n // every pass that is missing a program rather than one shared \"absent\".\n //\n // The pool key is the program text *and* the backend reflection that came\n // with it, not the text alone. A pooled record carries the bindings and\n // stage inputs of whichever stage was seen first, and\n // `validateShaderRuntimeContract` judges the emitted GLSL against them — so\n // pooling on text alone would let two stages with identical source but\n // different reflection be checked against the wrong metadata, silently. It\n // is unlikely that identical GLSL ever carries different reflection, which\n // is exactly why it would not be noticed.\n const shaderKeyByIdentity = new Map();\n\n for (let index = 0; index < reader.records.length; index += 1)\n {\n const { offset } = reader.records[index];\n if (bodyKeyByOffset.has(offset)) continue;\n\n const bodyKey = `body_${bodyKeyByOffset.size}`;\n bodyKeyByOffset.set(offset, bodyKey);\n\n const description = reader.readDescription(index, { backend: true });\n const manifestStages = bodyManifestStages(description, reader.version, source);\n\n for (const technique of description.techniques)\n {\n const techniqueName = technique.name.value;\n for (const [ passIndex, pass ] of technique.passes.entries())\n {\n const passKey = `${techniqueName}.pass${passIndex}`;\n const { stages: backend, transforms } = backendStages(\n pass,\n passKey,\n source\n );\n\n for (const stage of pass.stages)\n {\n const name = hlslShaderStageName(stage.type);\n const stageKey = `${bodyKey}.${passKey}.${name}`;\n const stageBackend = backend[name] ?? {};\n\n let shaderKey;\n if (stage.shaderData?.size)\n {\n const code = new TextDecoder().decode(stage.shaderData.bytes);\n const identity = `${JSON.stringify([\n stageBackend.bindings ?? [],\n stageBackend.stageInputs ?? [],\n stageBackend.computeFragment ?? null\n ])} ${code}`;\n const pooled = shaderKeyByIdentity.get(identity);\n if (pooled)\n {\n shaderKey = pooled;\n }\n else\n {\n shaderKey = `shader_${shaderKeyByIdentity.size}`;\n shaderKeyByIdentity.set(identity, shaderKey);\n shaders.push({\n key: shaderKey,\n stageName: name,\n source: code,\n hlsl2webgl: { ok: true },\n bindings: stageBackend.bindings ?? [],\n stageInputs: stageBackend.stageInputs ?? [],\n ...(stageBackend.computeFragment\n ? { computeFragment: stageBackend.computeFragment }\n : {})\n });\n }\n }\n else\n {\n shaderKey = `${stageKey}.absent`;\n shaders.push({\n key: shaderKey,\n stageName: name,\n source: \"\",\n hlsl2webgl: { ok: false, reason: NO_PROGRAM_REASON },\n bindings: stageBackend.bindings ?? [],\n stageInputs: stageBackend.stageInputs ?? []\n });\n }\n\n stages.push({\n key: stageKey,\n bodyKey,\n techniqueName,\n passIndex,\n stageName: name,\n stageType: stage.type,\n shaderKey,\n manifest: manifestStages.get(`${passKey}.${name}`) ?? null,\n // The pass's transforms, so a rule can ask whether a\n // description resource was merged away rather than lost.\n transforms\n });\n }\n }\n }\n }\n\n // Ordered by first appearance, matching `bodyKey`'s ordinal.\n const bodies = [];\n for (const [ offset, key ] of bodyKeyByOffset)\n {\n bodies.push({\n key,\n permutationIndices: Object.freeze(permutationIndicesByOffset.get(offset) ?? [])\n });\n }\n\n return {\n stages,\n shaders,\n bodies,\n recordCount: reader.records.length,\n bodyCount: bodyKeyByOffset.size\n };\n}\n\nexport default readGlslEffectContainer;\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","engineId","peekBackendEngineId","bytes","CARBON_BACKEND_ENGINE_ID","webgl2","foreignEngineId","block","readGlslBackendBlock","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":";;;;;;;AAUA;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,EAAEC,IAAI,EAAE,OAAO;IAAEV,MAAM,EAAE,EAAE;AAAEW,IAAAA,UAAU,EAAE;GAAI;;AAEnE;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,CAAC,CAAA,EAAG1B,OAAO,CAAA,CAAA,EAAIqC,IAAI,CAAA,CAAE,CAAC,IAAI,IAAI;AAC1D;AACA;AACAlC,YAAAA;AACJ,WAAC,CAAC;AACN,QAAA;AACJ,MAAA;AACJ,IAAA;AACJ,EAAA;;AAEA;EACA,MAAM2D,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;IACHhC,MAAM;IACN0B,OAAO;IACP4C,MAAM;AACNI,IAAAA,WAAW,EAAElD,MAAM,CAACM,OAAO,CAACC,MAAM;IAClC4C,SAAS,EAAEhD,eAAe,CAACjB;GAC9B;AACL;;;;"}
|
|
@@ -4,6 +4,7 @@ import { looksLikeCarbonEffectContainer, CjsCarbonEffectReader } from '../../../
|
|
|
4
4
|
import '../../../../format/carbonEffect/CjsCarbonEffectWriter.js';
|
|
5
5
|
import { WGSL_ENTRY_POINT } from '../buildCarbonEffectContainer.js';
|
|
6
6
|
import { sha256Bytes } from '../../../../format/effect/sha256.js';
|
|
7
|
+
import { peekBackendEngineId, CARBON_BACKEND_ENGINE_ID } from '../../../../format/carbonEffect/backendEngineId.js';
|
|
7
8
|
import { deriveBackendBodySet } from './containerViews.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -286,7 +287,15 @@ class CarbonWebgpuContainer {
|
|
|
286
287
|
}));
|
|
287
288
|
}
|
|
288
289
|
if (!shaders.length) continue;
|
|
289
|
-
|
|
290
|
+
|
|
291
|
+
// A block belonging to another backend reads as absent, not as a
|
|
292
|
+
// failure. The container is Carbon-shaped whatever it targets, so
|
|
293
|
+
// loading must not depend on being able to use its programs - a
|
|
294
|
+
// dx11 container carries no block at all and still loads, and a
|
|
295
|
+
// WebGL2 block met here means "not for this engine". Prepare is
|
|
296
|
+
// where the backend actually matters.
|
|
297
|
+
const blockBytes = pass.backendBlock && pass.backendBlock.size !== 0 ? pass.backendBlock.bytes : null;
|
|
298
|
+
const block = blockBytes && peekBackendEngineId(blockBytes) === CARBON_BACKEND_ENGINE_ID.webgpu ? readBackendBlock(blockBytes, {
|
|
290
299
|
layoutKey: passKey,
|
|
291
300
|
source: this.sourcePath || "CARBON_WEBGPU"
|
|
292
301
|
}) : null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarbonWebgpuContainer.js","sources":["../../../../../../src/formats/webgpu/core/carbonWebgpu/CarbonWebgpuContainer.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 {\n looksLikeCarbonEffectContainer\n} from \"../../../../format/carbonEffect/CjsCarbonEffectReader.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 looksLikeCarbonWebgpuContainer(bytes)\n{\n // Delegates rather than repeating the version dword. WebGL needs the same\n // check, and a second hand-written copy of one constant is a second chance\n // to disagree with it.\n return looksLikeCarbonEffectContainer(bytes);\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 CarbonWebgpuContainer\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 || \"CARBON_WEBGPU\"\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(`Carbon WebGPU 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 || \"CARBON_WEBGPU\"\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 * 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: \"CARBON_WEBGPU\",\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 CarbonWebgpuContainer;\n"],"names":["textDecoder","TextDecoder","fatal","WEBGPU_STAGE_NAME","Object","freeze","WEBGPU_STAGE","vertex","pixel","compute","looksLikeCarbonWebgpuContainer","bytes","looksLikeCarbonEffectContainer","optionIndicesFor","axes","permutationIndex","remaining","map","axis","radix","options","length","value","Math","floor","CarbonWebgpuContainer","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","info","compilerVersion","sourceHash","uniqueBodyCount","axisCount"],"mappings":";;;;;;;;AAWA;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,8BAA8BA,CAACC,KAAK,EACpD;AACI;AACA;AACA;EACA,OAAOC,8BAA8B,CAACD,KAAK,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,gBAAgBA,CAACC,IAAI,EAAEC,gBAAgB,EAChD;EACI,IAAIC,SAAS,GAAGD,gBAAgB;AAChC,EAAA,OAAOD,IAAI,CAACG,GAAG,CAAEC,IAAI,IACrB;IACI,MAAMC,KAAK,GAAGD,IAAI,CAACE,OAAO,CAACC,MAAM,IAAI,CAAC;AACtC,IAAA,MAAMC,KAAK,GAAGN,SAAS,GAAGG,KAAK;IAC/BH,SAAS,GAAGO,IAAI,CAACC,KAAK,CAACR,SAAS,GAAGG,KAAK,CAAC;AACzC,IAAA,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AAAA,SAAS,EAAE,IAAI,CAAC3F,MAAM,CAAC2C,YAAY,CAACpD;AACxC,KAAC,CAAC;AACN,EAAA;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"CarbonWebgpuContainer.js","sources":["../../../../../../src/formats/webgpu/core/carbonWebgpu/CarbonWebgpuContainer.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 {\n CARBON_BACKEND_ENGINE_ID,\n peekBackendEngineId\n} from \"../../../../format/carbonEffect/backendEngineId.js\";\nimport {\n looksLikeCarbonEffectContainer\n} from \"../../../../format/carbonEffect/CjsCarbonEffectReader.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 looksLikeCarbonWebgpuContainer(bytes)\n{\n // Delegates rather than repeating the version dword. WebGL needs the same\n // check, and a second hand-written copy of one constant is a second chance\n // to disagree with it.\n return looksLikeCarbonEffectContainer(bytes);\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 CarbonWebgpuContainer\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 || \"CARBON_WEBGPU\"\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(`Carbon WebGPU 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 // A block belonging to another backend reads as absent, not as a\n // failure. The container is Carbon-shaped whatever it targets, so\n // loading must not depend on being able to use its programs - a\n // dx11 container carries no block at all and still loads, and a\n // WebGL2 block met here means \"not for this engine\". Prepare is\n // where the backend actually matters.\n const blockBytes = pass.backendBlock && pass.backendBlock.size !== 0\n ? pass.backendBlock.bytes\n : null;\n const block = blockBytes\n && peekBackendEngineId(blockBytes) === CARBON_BACKEND_ENGINE_ID.webgpu\n ? readBackendBlock(blockBytes, {\n layoutKey: passKey,\n source: this.sourcePath || \"CARBON_WEBGPU\"\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 * 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: \"CARBON_WEBGPU\",\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 CarbonWebgpuContainer;\n"],"names":["textDecoder","TextDecoder","fatal","WEBGPU_STAGE_NAME","Object","freeze","WEBGPU_STAGE","vertex","pixel","compute","looksLikeCarbonWebgpuContainer","bytes","looksLikeCarbonEffectContainer","optionIndicesFor","axes","permutationIndex","remaining","map","axis","radix","options","length","value","Math","floor","CarbonWebgpuContainer","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","blockBytes","backendBlock","block","peekBackendEngineId","CARBON_BACKEND_ENGINE_ID","webgpu","readBackendBlock","layoutKey","layouts","bindGroups","transforms","resourceTransforms","status","backendBodySet","deriveBackendBodySet","info","compilerVersion","sourceHash","uniqueBodyCount","axisCount"],"mappings":";;;;;;;;;AAeA;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,8BAA8BA,CAACC,KAAK,EACpD;AACI;AACA;AACA;EACA,OAAOC,8BAA8B,CAACD,KAAK,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,gBAAgBA,CAACC,IAAI,EAAEC,gBAAgB,EAChD;EACI,IAAIC,SAAS,GAAGD,gBAAgB;AAChC,EAAA,OAAOD,IAAI,CAACG,GAAG,CAAEC,IAAI,IACrB;IACI,MAAMC,KAAK,GAAGD,IAAI,CAACE,OAAO,CAACC,MAAM,IAAI,CAAC;AACtC,IAAA,MAAMC,KAAK,GAAGN,SAAS,GAAGG,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