@carbonenginejs/runtime-resource 0.16.0 → 0.18.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 +98 -0
- package/dist/format/carbonEffect/backendEngineId.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js +24 -23
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
- package/dist/format/carbonEffect/carbonEffectResourceTransform.js +1 -1
- package/dist/format/carbonEffect/carbonEffectResourceTransform.js.map +1 -1
- package/dist/format/effect/effectPermutationGraph.js +46 -29
- package/dist/format/effect/effectPermutationGraph.js.map +1 -1
- package/dist/format/index.js +1 -1
- package/dist/formats/hlsl/core/detailMapFamily.js +1 -1
- package/dist/formats/hlsl/core/detailMapFamily.js.map +1 -1
- package/dist/formats/hlsl/core/localLightFamily.js +1 -1
- package/dist/formats/hlsl/core/localLightFamily.js.map +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 +143 -56
- 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 +74 -30
- package/dist/formats/webgl/core/glslBackendBlock.js.map +1 -1
- package/dist/formats/webgl/core/glslBackendBodySet.js +0 -1
- package/dist/formats/webgl/core/glslBackendBodySet.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/CjsWebgpuFormat.js +161 -163
- package/dist/formats/webgpu/CjsWebgpuFormat.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/webgpu/core/effectBackendBodySet.js +21 -22
- package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
- package/dist/formats/webgpu/core/helpers.js +111 -99
- package/dist/formats/webgpu/core/helpers.js.map +1 -1
- package/dist/formats/webgpu/core/packageEffect.js +30 -32
- package/dist/formats/webgpu/core/packageEffect.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/Tr2EffectStageInput.js +102 -60
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
- package/docs/concepts/format-type-resolution.md +79 -0
- package/docs/formats/README.md +11 -0
- package/docs/formats/webgpu/formats/carbon-webgpu.md +11 -4
- package/docs/formats/webgpu/reference/api.md +7 -6
- package/docs/formats/wwise.md +25 -0
- package/docs/roadmap.md +19 -0
- package/package.json +2 -2
|
@@ -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,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ACC,MAAM,CAAC;AACjBiE,MAAAA,MAAM,EAAE,eAAe;AACvB;AACA;AACA;MACAzC,gBAAgB,EAAE,IAAI,CAACA,gBAAgB;MACvCD,UAAU,EAAE,IAAI,CAACA,UAAU;AAC3B0F,MAAAA,eAAe,EAAElH,MAAM,CAACC,MAAM,CAAC,CAAE,GAAG,IAAI,CAACyB,MAAM,CAACwF,eAAe,CAAE,CAAC;MAClEC,UAAU,EAAEvH,WAAW,CAACwG,MAAM,CAAC,IAAI,CAAC1E,MAAM,CAACyF,UAAU,CAAC;AACtDnD,MAAAA,gBAAgB,EAAE,IAAI,CAACtC,MAAM,CAACiB,OAAO,CAAC1B,MAAM;MAC5CmG,eAAe,EAAE7D,QAAQ,CAACF,IAAI;AAC9BgE,MAAAA,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;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A;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACI,IAAIiC,cAAcA,GAClB;IACI,OAAOC,oBAAoB,CAAC,IAAI,CAAC;AACrC,EAAA;;AAEA;AACJ;AACA;AACA;AACA;EACI,IAAIC,IAAIA,GACR;AACI,IAAA,MAAM9D,QAAQ,GAAG,IAAI,CAACJ,eAAe;IACrC,OAAOnD,MAAM,CAACC,MAAM,CAAC;AACjBiE,MAAAA,MAAM,EAAE,eAAe;AACvB;AACA;AACA;MACAzC,gBAAgB,EAAE,IAAI,CAACA,gBAAgB;MACvCD,UAAU,EAAE,IAAI,CAACA,UAAU;AAC3B8F,MAAAA,eAAe,EAAEtH,MAAM,CAACC,MAAM,CAAC,CAAE,GAAG,IAAI,CAACyB,MAAM,CAAC4F,eAAe,CAAE,CAAC;MAClEC,UAAU,EAAE3H,WAAW,CAACwG,MAAM,CAAC,IAAI,CAAC1E,MAAM,CAAC6F,UAAU,CAAC;AACtDvD,MAAAA,gBAAgB,EAAE,IAAI,CAACtC,MAAM,CAACiB,OAAO,CAAC1B,MAAM;MAC5CuG,eAAe,EAAEjE,QAAQ,CAACF,IAAI;AAC9BoE,MAAAA,SAAS,EAAE,IAAI,CAAC/F,MAAM,CAAC2C,YAAY,CAACpD;AACxC,KAAC,CAAC;AACN,EAAA;AACJ;;;;"}
|
|
@@ -12,17 +12,16 @@ import { selectEffectStages } from './packageEffectSelection.js';
|
|
|
12
12
|
import { compareUtf8 } from '../../../format/compareUtf8.js';
|
|
13
13
|
import { isParticleClearEffectCandidate, preflightParticleClearEffectProfile, particleClearEffectProofFor } from './wgsl/lowerParticleClearComputePrograms.js';
|
|
14
14
|
|
|
15
|
-
const EFFECT_BACKEND_BODY_SET_CHUNK = "WGSB";
|
|
16
15
|
const EFFECT_BACKEND_BODY_SET_FORMAT = "CJS_WGSL_BODY_SET";
|
|
17
16
|
const EFFECT_BACKEND_BODY_SET_VERSION = 1;
|
|
18
17
|
|
|
19
|
-
/**
|
|
20
|
-
* One translation unit is exactly one pass of one body: the binding plan, the
|
|
21
|
-
* resource-transform plan, and every stage's emitted WGSL are derived together.
|
|
22
|
-
* Bodies that share an identical pass signature therefore share one unit.
|
|
23
|
-
*
|
|
24
|
-
* @param {object} pass Pass entry carrying its ordered stage records.
|
|
25
|
-
* @returns {string} Stable signature for the pass translation unit.
|
|
18
|
+
/**
|
|
19
|
+
* One translation unit is exactly one pass of one body: the binding plan, the
|
|
20
|
+
* resource-transform plan, and every stage's emitted WGSL are derived together.
|
|
21
|
+
* Bodies that share an identical pass signature therefore share one unit.
|
|
22
|
+
*
|
|
23
|
+
* @param {object} pass Pass entry carrying its ordered stage records.
|
|
24
|
+
* @returns {string} Stable signature for the pass translation unit.
|
|
26
25
|
*/
|
|
27
26
|
function passUnitSignature(pass) {
|
|
28
27
|
return JSON.stringify({
|
|
@@ -157,19 +156,19 @@ function translatePassUnit(pass, programForKey, source, bindingPolicy) {
|
|
|
157
156
|
})));
|
|
158
157
|
}
|
|
159
158
|
|
|
160
|
-
/**
|
|
161
|
-
* Translate every unique source body into backend programs, layouts, and
|
|
162
|
-
* resource transforms, sharing one translation unit between bodies whose pass
|
|
163
|
-
* is byte-for-byte identical.
|
|
164
|
-
*
|
|
165
|
-
* A body that cannot be lowered is retained as an explicitly unsupported
|
|
166
|
-
* in-memory record carrying its reason. Portable source reflection is built
|
|
167
|
-
* separately from the same effect; this body-set document does not store it.
|
|
168
|
-
*
|
|
169
|
-
* @param {object} effectRes Loaded version-15 `Tr2EffectRes`.
|
|
170
|
-
* @param {object} permutationGraph Validated `PGRF` document.
|
|
171
|
-
* @param {object} [options] Source label, stage selection, and binding policy.
|
|
172
|
-
* @returns {object} Frozen `CJS_WGSL_BODY_SET` document.
|
|
159
|
+
/**
|
|
160
|
+
* Translate every unique source body into backend programs, layouts, and
|
|
161
|
+
* resource transforms, sharing one translation unit between bodies whose pass
|
|
162
|
+
* is byte-for-byte identical.
|
|
163
|
+
*
|
|
164
|
+
* A body that cannot be lowered is retained as an explicitly unsupported
|
|
165
|
+
* in-memory record carrying its reason. Portable source reflection is built
|
|
166
|
+
* separately from the same effect; this body-set document does not store it.
|
|
167
|
+
*
|
|
168
|
+
* @param {object} effectRes Loaded version-15 `Tr2EffectRes`.
|
|
169
|
+
* @param {object} permutationGraph Validated `PGRF` document.
|
|
170
|
+
* @param {object} [options] Source label, stage selection, and binding policy.
|
|
171
|
+
* @returns {object} Frozen `CJS_WGSL_BODY_SET` document.
|
|
173
172
|
*/
|
|
174
173
|
function buildEffectBackendBodySet(effectRes, permutationGraph, options = {}) {
|
|
175
174
|
const source = options.source || "memory";
|
|
@@ -302,5 +301,5 @@ function buildEffectBackendBodySet(effectRes, permutationGraph, options = {}) {
|
|
|
302
301
|
});
|
|
303
302
|
}
|
|
304
303
|
|
|
305
|
-
export {
|
|
304
|
+
export { EFFECT_BACKEND_BODY_SET_FORMAT, EFFECT_BACKEND_BODY_SET_VERSION, buildEffectBackendBodySet };
|
|
306
305
|
//# sourceMappingURL=effectBackendBodySet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effectBackendBodySet.js","sources":["../../../../../src/formats/webgpu/core/effectBackendBodySet.js"],"sourcesContent":["import { HlslEffectBindingManifest } from \"../../hlsl/core/tr2/shader/HlslEffectBindingManifest.js\";\nimport { enumerateUniqueEffectBodies } from \"../../../format/effect/effectBodyInventory.js\";\nimport { buildEffectAnalysis } from \"./helpers.js\";\nimport { normalizeBytecodeBytes } from \"./effectAnalysis.js\";\nimport { lowerDxbcToIr } from \"./ir/lowerDxbcToIr.js\";\nimport { buildWgslBindingPlan } from \"./wgsl/buildWgslBindingPlan.js\";\nimport { buildWgsl } from \"./wgsl/emitWgsl.js\";\nimport { buildWgslSet } from \"./wgsl/buildWgslSet.js\";\nimport { buildResourceTransformPlan } from \"./wgsl/buildResourceTransformPlan.js\";\nimport { sha256Bytes, sha256Utf8 } from \"../../../format/effect/sha256.js\";\nimport { selectEffectStages } from \"./packageEffectSelection.js\";\nimport { compareUtf8 } from \"../../../format/compareUtf8.js\";\nimport {\n isParticleClearEffectCandidate,\n particleClearEffectProofFor,\n preflightParticleClearEffectProfile\n} from \"./wgsl/lowerParticleClearComputePrograms.js\";\n\nexport const EFFECT_BACKEND_BODY_SET_CHUNK = \"WGSB\";\nexport const EFFECT_BACKEND_BODY_SET_FORMAT = \"CJS_WGSL_BODY_SET\";\nexport const EFFECT_BACKEND_BODY_SET_VERSION = 1;\n\n/**\n * One translation unit is exactly one pass of one body: the binding plan, the\n * resource-transform plan, and every stage's emitted WGSL are derived together.\n * Bodies that share an identical pass signature therefore share one unit.\n *\n * @param {object} pass Pass entry carrying its ordered stage records.\n * @returns {string} Stable signature for the pass translation unit.\n */\nfunction passUnitSignature(pass)\n{\n return JSON.stringify({\n passKey: pass.passKey,\n stages: pass.stages\n .map((stage) => ({\n stageName: stage.stageName,\n bytecode: stage.bytecodeDigest,\n semanticBindings: stage.semanticBindings,\n // An effect profile changes emission, so two otherwise identical\n // passes must not share one unit when their proofs differ.\n effectProfileProof: stage.effectProfileProof\n ? sha256Utf8(JSON.stringify(stage.effectProfileProof))\n : null\n }))\n .sort((left, right) => compareUtf8(left.stageName, right.stageName))\n });\n}\n\nfunction collectBodyStageBytecode(effectDescription)\n{\n const bytecodeByKey = new Map();\n\n for (const technique of effectDescription?.techniques ?? [])\n {\n for (let passIndex = 0; passIndex < technique.passes.length; passIndex++)\n {\n const stageInputs = technique.passes[passIndex].stageInputs;\n\n for (let stageType = 0; stageType < stageInputs.length; stageType++)\n {\n const stage = stageInputs[stageType];\n if (!stage?.m_exists) continue;\n\n const stageName = stage.cjsShaderBytecode?.stageName;\n const value = stage.cjsShaderBytecode?.bytes;\n if (!stageName || value === undefined || value === null) continue;\n\n const key = `${technique.name}.pass${passIndex}.${stageName}`;\n const bytes = normalizeBytecodeBytes(value, `${key} stage bytecode`);\n\n if (!bytes?.length)\n {\n throw new TypeError(`${key} stage bytecode must be a non-empty byte view`);\n }\n\n bytecodeByKey.set(key, {\n techniqueName: technique.name,\n passIndex,\n stageType,\n stageName,\n bytes\n });\n }\n }\n }\n\n return bytecodeByKey;\n}\n\nfunction resolveBody(effectRes, permutationIndex, source)\n{\n const shader = effectRes.GetShaderByIndex(permutationIndex);\n\n if (!shader)\n {\n throw new Error(\n `Effect body at permutation ${permutationIndex} could not be decoded`\n );\n }\n\n const effectDescription = shader.GetEffectDescription();\n\n if (!effectDescription)\n {\n throw new Error(\n `Effect body at permutation ${permutationIndex} has no effect description`\n );\n }\n\n const resolved = {\n effectRes,\n shader,\n selection: { bodyIndex: permutationIndex, selectedOptions: [] },\n effectDescription,\n bindingManifest: HlslEffectBindingManifest.fromEffectDescription(effectDescription),\n stageBytecodeByKey: collectBodyStageBytecode(effectDescription)\n };\n\n return {\n resolved,\n analysis: buildEffectAnalysis(resolved, {\n source,\n decodeBytecode: false,\n decodeInstructions: false\n })\n };\n}\n\nfunction buildPassEntries(analysis, resolved, selection, effectProfileContext)\n{\n const selectedStages = selectEffectStages(analysis.stages, selection);\n const passes = new Map();\n\n for (const stage of selectedStages)\n {\n const passKey = `${stage.techniqueName}.pass${stage.passIndex}`;\n\n if (!passes.has(passKey))\n {\n passes.set(passKey, { passKey, stages: [] });\n }\n\n const bytecode = resolved.stageBytecodeByKey.get(stage.key)?.bytes;\n\n if (!bytecode?.length)\n {\n throw new Error(`${stage.key} has no shader bytecode`);\n }\n\n passes.get(passKey).stages.push({\n key: stage.key,\n stageName: stage.stageName,\n bytecodeKey: stage.key,\n bytecodeDigest: sha256Bytes(bytecode),\n semanticBindings: analysis.stages.find((candidate) =>\n candidate.techniqueName === stage.techniqueName\n && candidate.passIndex === stage.passIndex\n && candidate.stageName === stage.stageName)?.bindings || [],\n effectProfileProof: particleClearEffectProofFor(\n effectProfileContext,\n stage.key\n )\n });\n }\n\n return Array.from(passes.values());\n}\n\nfunction translatePassUnit(pass, programForKey, source, bindingPolicy)\n{\n const irEntries = pass.stages.map((stage) => ({\n key: stage.key,\n ir: programForKey(stage.bytecodeKey),\n semanticBindings: stage.semanticBindings,\n effectProfileProof: stage.effectProfileProof\n }));\n const resourceTransformPlan = buildResourceTransformPlan(\n irEntries.map((entry) => ({\n ir: entry.ir,\n semanticBindings: entry.semanticBindings\n })),\n { layoutKey: pass.passKey }\n );\n const proof = irEntries.find((entry) => entry.effectProfileProof)\n ?.effectProfileProof ?? null;\n const plan = buildWgslBindingPlan(\n irEntries.map((entry) => entry.ir),\n {\n ...(bindingPolicy ?? {}),\n ...(proof ? { effectProfileProof: proof } : {}),\n ...(resourceTransformPlan ? { resourceTransformPlan } : {})\n }\n );\n\n return buildWgslSet(irEntries.map((entry) => ({\n key: entry.key,\n shader: buildWgsl(entry.ir, {\n bindingPlan: plan,\n ...(resourceTransformPlan ? { resourceTransformPlan } : {}),\n ...(entry.effectProfileProof\n ? { effectProfileProof: entry.effectProfileProof }\n : {})\n })\n })));\n}\n\n/**\n * Translate every unique source body into backend programs, layouts, and\n * resource transforms, sharing one translation unit between bodies whose pass\n * is byte-for-byte identical.\n *\n * A body that cannot be lowered is retained as an explicitly unsupported\n * in-memory record carrying its reason. Portable source reflection is built\n * separately from the same effect; this body-set document does not store it.\n *\n * @param {object} effectRes Loaded version-15 `Tr2EffectRes`.\n * @param {object} permutationGraph Validated `PGRF` document.\n * @param {object} [options] Source label, stage selection, and binding policy.\n * @returns {object} Frozen `CJS_WGSL_BODY_SET` document.\n */\nexport function buildEffectBackendBodySet(effectRes, permutationGraph, options = {})\n{\n const source = options.source || \"memory\";\n const selection = options.selection ?? null;\n const bindingPolicy = options.bindingPolicy ?? null;\n const groups = enumerateUniqueEffectBodies(effectRes);\n\n if (groups.length !== permutationGraph.bodies.length)\n {\n throw new Error(\n \"Effect backend body set requires one unique body per permutation-graph body\"\n );\n }\n\n const unitsBySignature = new Map();\n const graphBodiesByKey = new Map(permutationGraph.bodies.map((body) => [ body.key, body ]));\n const passUnits = [];\n const bodies = [];\n const seenBodyKeys = new Set();\n\n for (const group of groups)\n {\n const variant = permutationGraph.variants[group.permutationIndex];\n const graphBody = variant ? graphBodiesByKey.get(variant.bodyKey) : null;\n\n if (!graphBody)\n {\n throw new Error(\n `Effect backend body ${group.permutationIndex} does not reconcile with its permutation graph record`\n );\n }\n\n if (seenBodyKeys.has(graphBody.key))\n {\n throw new Error(\n `Effect backend body ${graphBody.key} was enumerated more than once`\n );\n }\n\n seenBodyKeys.add(graphBody.key);\n\n let resolvedBody = null;\n let passes = null;\n let programForKey = null;\n\n try\n {\n resolvedBody = resolveBody(effectRes, group.permutationIndex, source);\n\n // One IR cache per body, so a stage shared by two passes lowers once\n // and the effect-profile preflight can seed it exactly as the\n // selected-body path does.\n const programsByKey = new Map();\n programForKey = (key) =>\n {\n if (programsByKey.has(key)) return programsByKey.get(key);\n\n const bytecode = resolvedBody.resolved.stageBytecodeByKey.get(key)?.bytes;\n\n if (!bytecode?.length)\n {\n throw new Error(`${key} has no shader bytecode`);\n }\n\n const program = lowerDxbcToIr(bytecode, { source: `${source}#${key}` });\n programsByKey.set(key, program);\n return program;\n };\n\n let effectProfileContext = null;\n\n if (isParticleClearEffectCandidate(resolvedBody.resolved.effectDescription))\n {\n programForKey(\"Main.pass0.compute\");\n programForKey(\"Main.pass1.compute\");\n effectProfileContext = preflightParticleClearEffectProfile(\n resolvedBody.resolved.effectDescription,\n programsByKey\n );\n }\n\n passes = buildPassEntries(\n resolvedBody.analysis,\n resolvedBody.resolved,\n selection,\n effectProfileContext\n );\n }\n catch (error)\n {\n // Stage selection and profile preflight fail closed per body: an\n // unsupported stage kind in one body must not fail the package.\n bodies.push(Object.freeze({\n bodyKey: graphBody.key,\n representativePermutationIndex: group.permutationIndex,\n status: \"unsupported\",\n error: String(error?.message ?? error),\n passCount: 0,\n passes: Object.freeze([])\n }));\n continue;\n }\n\n const bodyPasses = [];\n let failure = null;\n\n for (const pass of passes)\n {\n const signature = passUnitSignature(pass);\n let unit = unitsBySignature.get(signature);\n\n if (!unit)\n {\n let wgsl = null;\n\n try\n {\n wgsl = translatePassUnit(\n pass,\n programForKey,\n source,\n bindingPolicy\n );\n }\n catch (error)\n {\n failure = String(error?.message ?? error);\n break;\n }\n\n unit = {\n key: `unit${passUnits.length}`,\n sha256: sha256Utf8(`${JSON.stringify(wgsl)}\\n`),\n wgslSetVersion: wgsl.formatVersion,\n shaders: wgsl.shaders,\n layouts: wgsl.layouts,\n ...(wgsl.resourceTransforms\n ? { resourceTransforms: wgsl.resourceTransforms }\n : {})\n };\n unitsBySignature.set(signature, unit);\n passUnits.push(unit);\n }\n\n bodyPasses.push(Object.freeze({ passKey: pass.passKey, unitKey: unit.key }));\n }\n\n bodies.push(Object.freeze(failure\n ? {\n bodyKey: graphBody.key,\n representativePermutationIndex: group.permutationIndex,\n status: \"unsupported\",\n error: failure,\n passCount: 0,\n passes: Object.freeze([])\n }\n : {\n bodyKey: graphBody.key,\n representativePermutationIndex: group.permutationIndex,\n status: \"translated\",\n error: null,\n passCount: bodyPasses.length,\n passes: Object.freeze(bodyPasses)\n }));\n }\n\n const translatedCount = bodies.filter((body) => body.status === \"translated\").length;\n\n if (!translatedCount)\n {\n throw new Error(\n \"Effect backend body set requires at least one translated body\"\n );\n }\n\n return Object.freeze({\n format: EFFECT_BACKEND_BODY_SET_FORMAT,\n formatVersion: EFFECT_BACKEND_BODY_SET_VERSION,\n coverage: Object.freeze({\n bodies: translatedCount === bodies.length ? \"all-unique\" : \"partial\",\n programs: \"complete-for-translated\"\n }),\n bodyCount: bodies.length,\n translatedBodyCount: translatedCount,\n passUnitCount: passUnits.length,\n passUnits: Object.freeze(passUnits.map((unit) => Object.freeze(unit))),\n bodies: Object.freeze(bodies)\n });\n}\n"],"names":["EFFECT_BACKEND_BODY_SET_CHUNK","EFFECT_BACKEND_BODY_SET_FORMAT","EFFECT_BACKEND_BODY_SET_VERSION","passUnitSignature","pass","JSON","stringify","passKey","stages","map","stage","stageName","bytecode","bytecodeDigest","semanticBindings","effectProfileProof","sha256Utf8","sort","left","right","compareUtf8","collectBodyStageBytecode","effectDescription","bytecodeByKey","Map","technique","techniques","passIndex","passes","length","stageInputs","stageType","m_exists","cjsShaderBytecode","value","bytes","undefined","key","name","normalizeBytecodeBytes","TypeError","set","techniqueName","resolveBody","effectRes","permutationIndex","source","shader","GetShaderByIndex","Error","GetEffectDescription","resolved","selection","bodyIndex","selectedOptions","bindingManifest","HlslEffectBindingManifest","fromEffectDescription","stageBytecodeByKey","analysis","buildEffectAnalysis","decodeBytecode","decodeInstructions","buildPassEntries","effectProfileContext","selectedStages","selectEffectStages","has","get","push","bytecodeKey","sha256Bytes","find","candidate","bindings","particleClearEffectProofFor","Array","from","values","translatePassUnit","programForKey","bindingPolicy","irEntries","ir","resourceTransformPlan","buildResourceTransformPlan","entry","layoutKey","proof","plan","buildWgslBindingPlan","buildWgslSet","buildWgsl","bindingPlan","buildEffectBackendBodySet","permutationGraph","options","groups","enumerateUniqueEffectBodies","bodies","unitsBySignature","graphBodiesByKey","body","passUnits","seenBodyKeys","Set","group","variant","variants","graphBody","bodyKey","add","resolvedBody","programsByKey","program","lowerDxbcToIr","isParticleClearEffectCandidate","preflightParticleClearEffectProfile","error","Object","freeze","representativePermutationIndex","status","String","message","passCount","bodyPasses","failure","signature","unit","wgsl","sha256","wgslSetVersion","formatVersion","shaders","layouts","resourceTransforms","unitKey","translatedCount","filter","format","coverage","programs","bodyCount","translatedBodyCount","passUnitCount"],"mappings":";;;;;;;;;;;;;;AAkBO,MAAMA,6BAA6B,GAAG;AACtC,MAAMC,8BAA8B,GAAG;AACvC,MAAMC,+BAA+B,GAAG;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,iBAAiBA,CAACC,IAAI,EAC/B;EACI,OAAOC,IAAI,CAACC,SAAS,CAAC;IAClBC,OAAO,EAAEH,IAAI,CAACG,OAAO;IACrBC,MAAM,EAAEJ,IAAI,CAACI,MAAM,CACdC,GAAG,CAAEC,KAAK,KAAM;MACbC,SAAS,EAAED,KAAK,CAACC,SA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,YAAY,CAAC,CAAC7F,MAAM;EAEpF,IAAI,CAAC6G,eAAe,EACpB;AACI,IAAA,MAAM,IAAIzF,KAAK,CACX,+DACJ,CAAC;AACL,EAAA;EAEA,OAAOsE,MAAM,CAACC,MAAM,CAAC;AACjBoB,IAAAA,MAAM,EAAE3I,8BAA8B;AACtCoI,IAAAA,aAAa,EAAEnI,+BAA+B;AAC9C2I,IAAAA,QAAQ,EAAEtB,MAAM,CAACC,MAAM,CAAC;MACpBrB,MAAM,EAAEuC,eAAe,KAAKvC,MAAM,CAACtE,MAAM,GAAG,YAAY,GAAG,SAAS;AACpEiH,MAAAA,QAAQ,EAAE;AACd,KAAC,CAAC;IACFC,SAAS,EAAE5C,MAAM,CAACtE,MAAM;AACxBmH,IAAAA,mBAAmB,EAAEN,eAAe;IACpCO,aAAa,EAAE1C,SAAS,CAAC1E,MAAM;AAC/B0E,IAAAA,SAAS,EAAEgB,MAAM,CAACC,MAAM,CAACjB,SAAS,CAAC9F,GAAG,CAAEwH,IAAI,IAAKV,MAAM,CAACC,MAAM,CAACS,IAAI,CAAC,CAAC,CAAC;AACtE9B,IAAAA,MAAM,EAAEoB,MAAM,CAACC,MAAM,CAACrB,MAAM;AAChC,GAAC,CAAC;AACN;;;;"}
|
|
1
|
+
{"version":3,"file":"effectBackendBodySet.js","sources":["../../../../../src/formats/webgpu/core/effectBackendBodySet.js"],"sourcesContent":["import { HlslEffectBindingManifest } from \"../../hlsl/core/tr2/shader/HlslEffectBindingManifest.js\";\r\nimport { enumerateUniqueEffectBodies } from \"../../../format/effect/effectBodyInventory.js\";\r\nimport { buildEffectAnalysis } from \"./helpers.js\";\r\nimport { normalizeBytecodeBytes } from \"./effectAnalysis.js\";\r\nimport { lowerDxbcToIr } from \"./ir/lowerDxbcToIr.js\";\r\nimport { buildWgslBindingPlan } from \"./wgsl/buildWgslBindingPlan.js\";\r\nimport { buildWgsl } from \"./wgsl/emitWgsl.js\";\r\nimport { buildWgslSet } from \"./wgsl/buildWgslSet.js\";\r\nimport { buildResourceTransformPlan } from \"./wgsl/buildResourceTransformPlan.js\";\r\nimport { sha256Bytes, sha256Utf8 } from \"../../../format/effect/sha256.js\";\r\nimport { selectEffectStages } from \"./packageEffectSelection.js\";\r\nimport { compareUtf8 } from \"../../../format/compareUtf8.js\";\r\nimport {\r\n isParticleClearEffectCandidate,\r\n particleClearEffectProofFor,\r\n preflightParticleClearEffectProfile\r\n} from \"./wgsl/lowerParticleClearComputePrograms.js\";\r\n\r\nexport const EFFECT_BACKEND_BODY_SET_FORMAT = \"CJS_WGSL_BODY_SET\";\r\nexport const EFFECT_BACKEND_BODY_SET_VERSION = 1;\r\n\r\n/**\r\n * One translation unit is exactly one pass of one body: the binding plan, the\r\n * resource-transform plan, and every stage's emitted WGSL are derived together.\r\n * Bodies that share an identical pass signature therefore share one unit.\r\n *\r\n * @param {object} pass Pass entry carrying its ordered stage records.\r\n * @returns {string} Stable signature for the pass translation unit.\r\n */\r\nfunction passUnitSignature(pass)\r\n{\r\n return JSON.stringify({\r\n passKey: pass.passKey,\r\n stages: pass.stages\r\n .map((stage) => ({\r\n stageName: stage.stageName,\r\n bytecode: stage.bytecodeDigest,\r\n semanticBindings: stage.semanticBindings,\r\n // An effect profile changes emission, so two otherwise identical\r\n // passes must not share one unit when their proofs differ.\r\n effectProfileProof: stage.effectProfileProof\r\n ? sha256Utf8(JSON.stringify(stage.effectProfileProof))\r\n : null\r\n }))\r\n .sort((left, right) => compareUtf8(left.stageName, right.stageName))\r\n });\r\n}\r\n\r\nfunction collectBodyStageBytecode(effectDescription)\r\n{\r\n const bytecodeByKey = new Map();\r\n\r\n for (const technique of effectDescription?.techniques ?? [])\r\n {\r\n for (let passIndex = 0; passIndex < technique.passes.length; passIndex++)\r\n {\r\n const stageInputs = technique.passes[passIndex].stageInputs;\r\n\r\n for (let stageType = 0; stageType < stageInputs.length; stageType++)\r\n {\r\n const stage = stageInputs[stageType];\r\n if (!stage?.m_exists) continue;\r\n\r\n const stageName = stage.cjsShaderBytecode?.stageName;\r\n const value = stage.cjsShaderBytecode?.bytes;\r\n if (!stageName || value === undefined || value === null) continue;\r\n\r\n const key = `${technique.name}.pass${passIndex}.${stageName}`;\r\n const bytes = normalizeBytecodeBytes(value, `${key} stage bytecode`);\r\n\r\n if (!bytes?.length)\r\n {\r\n throw new TypeError(`${key} stage bytecode must be a non-empty byte view`);\r\n }\r\n\r\n bytecodeByKey.set(key, {\r\n techniqueName: technique.name,\r\n passIndex,\r\n stageType,\r\n stageName,\r\n bytes\r\n });\r\n }\r\n }\r\n }\r\n\r\n return bytecodeByKey;\r\n}\r\n\r\nfunction resolveBody(effectRes, permutationIndex, source)\r\n{\r\n const shader = effectRes.GetShaderByIndex(permutationIndex);\r\n\r\n if (!shader)\r\n {\r\n throw new Error(\r\n `Effect body at permutation ${permutationIndex} could not be decoded`\r\n );\r\n }\r\n\r\n const effectDescription = shader.GetEffectDescription();\r\n\r\n if (!effectDescription)\r\n {\r\n throw new Error(\r\n `Effect body at permutation ${permutationIndex} has no effect description`\r\n );\r\n }\r\n\r\n const resolved = {\r\n effectRes,\r\n shader,\r\n selection: { bodyIndex: permutationIndex, selectedOptions: [] },\r\n effectDescription,\r\n bindingManifest: HlslEffectBindingManifest.fromEffectDescription(effectDescription),\r\n stageBytecodeByKey: collectBodyStageBytecode(effectDescription)\r\n };\r\n\r\n return {\r\n resolved,\r\n analysis: buildEffectAnalysis(resolved, {\r\n source,\r\n decodeBytecode: false,\r\n decodeInstructions: false\r\n })\r\n };\r\n}\r\n\r\nfunction buildPassEntries(analysis, resolved, selection, effectProfileContext)\r\n{\r\n const selectedStages = selectEffectStages(analysis.stages, selection);\r\n const passes = new Map();\r\n\r\n for (const stage of selectedStages)\r\n {\r\n const passKey = `${stage.techniqueName}.pass${stage.passIndex}`;\r\n\r\n if (!passes.has(passKey))\r\n {\r\n passes.set(passKey, { passKey, stages: [] });\r\n }\r\n\r\n const bytecode = resolved.stageBytecodeByKey.get(stage.key)?.bytes;\r\n\r\n if (!bytecode?.length)\r\n {\r\n throw new Error(`${stage.key} has no shader bytecode`);\r\n }\r\n\r\n passes.get(passKey).stages.push({\r\n key: stage.key,\r\n stageName: stage.stageName,\r\n bytecodeKey: stage.key,\r\n bytecodeDigest: sha256Bytes(bytecode),\r\n semanticBindings: analysis.stages.find((candidate) =>\r\n candidate.techniqueName === stage.techniqueName\r\n && candidate.passIndex === stage.passIndex\r\n && candidate.stageName === stage.stageName)?.bindings || [],\r\n effectProfileProof: particleClearEffectProofFor(\r\n effectProfileContext,\r\n stage.key\r\n )\r\n });\r\n }\r\n\r\n return Array.from(passes.values());\r\n}\r\n\r\nfunction translatePassUnit(pass, programForKey, source, bindingPolicy)\r\n{\r\n const irEntries = pass.stages.map((stage) => ({\r\n key: stage.key,\r\n ir: programForKey(stage.bytecodeKey),\r\n semanticBindings: stage.semanticBindings,\r\n effectProfileProof: stage.effectProfileProof\r\n }));\r\n const resourceTransformPlan = buildResourceTransformPlan(\r\n irEntries.map((entry) => ({\r\n ir: entry.ir,\r\n semanticBindings: entry.semanticBindings\r\n })),\r\n { layoutKey: pass.passKey }\r\n );\r\n const proof = irEntries.find((entry) => entry.effectProfileProof)\r\n ?.effectProfileProof ?? null;\r\n const plan = buildWgslBindingPlan(\r\n irEntries.map((entry) => entry.ir),\r\n {\r\n ...(bindingPolicy ?? {}),\r\n ...(proof ? { effectProfileProof: proof } : {}),\r\n ...(resourceTransformPlan ? { resourceTransformPlan } : {})\r\n }\r\n );\r\n\r\n return buildWgslSet(irEntries.map((entry) => ({\r\n key: entry.key,\r\n shader: buildWgsl(entry.ir, {\r\n bindingPlan: plan,\r\n ...(resourceTransformPlan ? { resourceTransformPlan } : {}),\r\n ...(entry.effectProfileProof\r\n ? { effectProfileProof: entry.effectProfileProof }\r\n : {})\r\n })\r\n })));\r\n}\r\n\r\n/**\r\n * Translate every unique source body into backend programs, layouts, and\r\n * resource transforms, sharing one translation unit between bodies whose pass\r\n * is byte-for-byte identical.\r\n *\r\n * A body that cannot be lowered is retained as an explicitly unsupported\r\n * in-memory record carrying its reason. Portable source reflection is built\r\n * separately from the same effect; this body-set document does not store it.\r\n *\r\n * @param {object} effectRes Loaded version-15 `Tr2EffectRes`.\r\n * @param {object} permutationGraph Validated `PGRF` document.\r\n * @param {object} [options] Source label, stage selection, and binding policy.\r\n * @returns {object} Frozen `CJS_WGSL_BODY_SET` document.\r\n */\r\nexport function buildEffectBackendBodySet(effectRes, permutationGraph, options = {})\r\n{\r\n const source = options.source || \"memory\";\r\n const selection = options.selection ?? null;\r\n const bindingPolicy = options.bindingPolicy ?? null;\r\n const groups = enumerateUniqueEffectBodies(effectRes);\r\n\r\n if (groups.length !== permutationGraph.bodies.length)\r\n {\r\n throw new Error(\r\n \"Effect backend body set requires one unique body per permutation-graph body\"\r\n );\r\n }\r\n\r\n const unitsBySignature = new Map();\r\n const graphBodiesByKey = new Map(permutationGraph.bodies.map((body) => [ body.key, body ]));\r\n const passUnits = [];\r\n const bodies = [];\r\n const seenBodyKeys = new Set();\r\n\r\n for (const group of groups)\r\n {\r\n const variant = permutationGraph.variants[group.permutationIndex];\r\n const graphBody = variant ? graphBodiesByKey.get(variant.bodyKey) : null;\r\n\r\n if (!graphBody)\r\n {\r\n throw new Error(\r\n `Effect backend body ${group.permutationIndex} does not reconcile with its permutation graph record`\r\n );\r\n }\r\n\r\n if (seenBodyKeys.has(graphBody.key))\r\n {\r\n throw new Error(\r\n `Effect backend body ${graphBody.key} was enumerated more than once`\r\n );\r\n }\r\n\r\n seenBodyKeys.add(graphBody.key);\r\n\r\n let resolvedBody = null;\r\n let passes = null;\r\n let programForKey = null;\r\n\r\n try\r\n {\r\n resolvedBody = resolveBody(effectRes, group.permutationIndex, source);\r\n\r\n // One IR cache per body, so a stage shared by two passes lowers once\r\n // and the effect-profile preflight can seed it exactly as the\r\n // selected-body path does.\r\n const programsByKey = new Map();\r\n programForKey = (key) =>\r\n {\r\n if (programsByKey.has(key)) return programsByKey.get(key);\r\n\r\n const bytecode = resolvedBody.resolved.stageBytecodeByKey.get(key)?.bytes;\r\n\r\n if (!bytecode?.length)\r\n {\r\n throw new Error(`${key} has no shader bytecode`);\r\n }\r\n\r\n const program = lowerDxbcToIr(bytecode, { source: `${source}#${key}` });\r\n programsByKey.set(key, program);\r\n return program;\r\n };\r\n\r\n let effectProfileContext = null;\r\n\r\n if (isParticleClearEffectCandidate(resolvedBody.resolved.effectDescription))\r\n {\r\n programForKey(\"Main.pass0.compute\");\r\n programForKey(\"Main.pass1.compute\");\r\n effectProfileContext = preflightParticleClearEffectProfile(\r\n resolvedBody.resolved.effectDescription,\r\n programsByKey\r\n );\r\n }\r\n\r\n passes = buildPassEntries(\r\n resolvedBody.analysis,\r\n resolvedBody.resolved,\r\n selection,\r\n effectProfileContext\r\n );\r\n }\r\n catch (error)\r\n {\r\n // Stage selection and profile preflight fail closed per body: an\r\n // unsupported stage kind in one body must not fail the package.\r\n bodies.push(Object.freeze({\r\n bodyKey: graphBody.key,\r\n representativePermutationIndex: group.permutationIndex,\r\n status: \"unsupported\",\r\n error: String(error?.message ?? error),\r\n passCount: 0,\r\n passes: Object.freeze([])\r\n }));\r\n continue;\r\n }\r\n\r\n const bodyPasses = [];\r\n let failure = null;\r\n\r\n for (const pass of passes)\r\n {\r\n const signature = passUnitSignature(pass);\r\n let unit = unitsBySignature.get(signature);\r\n\r\n if (!unit)\r\n {\r\n let wgsl = null;\r\n\r\n try\r\n {\r\n wgsl = translatePassUnit(\r\n pass,\r\n programForKey,\r\n source,\r\n bindingPolicy\r\n );\r\n }\r\n catch (error)\r\n {\r\n failure = String(error?.message ?? error);\r\n break;\r\n }\r\n\r\n unit = {\r\n key: `unit${passUnits.length}`,\r\n sha256: sha256Utf8(`${JSON.stringify(wgsl)}\\n`),\r\n wgslSetVersion: wgsl.formatVersion,\r\n shaders: wgsl.shaders,\r\n layouts: wgsl.layouts,\r\n ...(wgsl.resourceTransforms\r\n ? { resourceTransforms: wgsl.resourceTransforms }\r\n : {})\r\n };\r\n unitsBySignature.set(signature, unit);\r\n passUnits.push(unit);\r\n }\r\n\r\n bodyPasses.push(Object.freeze({ passKey: pass.passKey, unitKey: unit.key }));\r\n }\r\n\r\n bodies.push(Object.freeze(failure\r\n ? {\r\n bodyKey: graphBody.key,\r\n representativePermutationIndex: group.permutationIndex,\r\n status: \"unsupported\",\r\n error: failure,\r\n passCount: 0,\r\n passes: Object.freeze([])\r\n }\r\n : {\r\n bodyKey: graphBody.key,\r\n representativePermutationIndex: group.permutationIndex,\r\n status: \"translated\",\r\n error: null,\r\n passCount: bodyPasses.length,\r\n passes: Object.freeze(bodyPasses)\r\n }));\r\n }\r\n\r\n const translatedCount = bodies.filter((body) => body.status === \"translated\").length;\r\n\r\n if (!translatedCount)\r\n {\r\n throw new Error(\r\n \"Effect backend body set requires at least one translated body\"\r\n );\r\n }\r\n\r\n return Object.freeze({\r\n format: EFFECT_BACKEND_BODY_SET_FORMAT,\r\n formatVersion: EFFECT_BACKEND_BODY_SET_VERSION,\r\n coverage: Object.freeze({\r\n bodies: translatedCount === bodies.length ? \"all-unique\" : \"partial\",\r\n programs: \"complete-for-translated\"\r\n }),\r\n bodyCount: bodies.length,\r\n translatedBodyCount: translatedCount,\r\n passUnitCount: passUnits.length,\r\n passUnits: Object.freeze(passUnits.map((unit) => Object.freeze(unit))),\r\n bodies: Object.freeze(bodies)\r\n });\r\n}\r\n"],"names":["EFFECT_BACKEND_BODY_SET_FORMAT","EFFECT_BACKEND_BODY_SET_VERSION","passUnitSignature","pass","JSON","stringify","passKey","stages","map","stage","stageName","bytecode","bytecodeDigest","semanticBindings","effectProfileProof","sha256Utf8","sort","left","right","compareUtf8","collectBodyStageBytecode","effectDescription","bytecodeByKey","Map","technique","techniques","passIndex","passes","length","stageInputs","stageType","m_exists","cjsShaderBytecode","value","bytes","undefined","key","name","normalizeBytecodeBytes","TypeError","set","techniqueName","resolveBody","effectRes","permutationIndex","source","shader","GetShaderByIndex","Error","GetEffectDescription","resolved","selection","bodyIndex","selectedOptions","bindingManifest","HlslEffectBindingManifest","fromEffectDescription","stageBytecodeByKey","analysis","buildEffectAnalysis","decodeBytecode","decodeInstructions","buildPassEntries","effectProfileContext","selectedStages","selectEffectStages","has","get","push","bytecodeKey","sha256Bytes","find","candidate","bindings","particleClearEffectProofFor","Array","from","values","translatePassUnit","programForKey","bindingPolicy","irEntries","ir","resourceTransformPlan","buildResourceTransformPlan","entry","layoutKey","proof","plan","buildWgslBindingPlan","buildWgslSet","buildWgsl","bindingPlan","buildEffectBackendBodySet","permutationGraph","options","groups","enumerateUniqueEffectBodies","bodies","unitsBySignature","graphBodiesByKey","body","passUnits","seenBodyKeys","Set","group","variant","variants","graphBody","bodyKey","add","resolvedBody","programsByKey","program","lowerDxbcToIr","isParticleClearEffectCandidate","preflightParticleClearEffectProfile","error","Object","freeze","representativePermutationIndex","status","String","message","passCount","bodyPasses","failure","signature","unit","wgsl","sha256","wgslSetVersion","formatVersion","shaders","layouts","resourceTransforms","unitKey","translatedCount","filter","format","coverage","programs","bodyCount","translatedBodyCount","passUnitCount"],"mappings":";;;;;;;;;;;;;;AAkBO,MAAMA,8BAA8B,GAAG;AACvC,MAAMC,+BAA+B,GAAG;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,iBAAiBA,CAACC,IAAI,EAC/B;EACI,OAAOC,IAAI,CAACC,SAAS,CAAC;IAClBC,OAAO,EAAEH,IAAI,CAACG,OAAO;IACrBC,MAAM,EAAEJ,IAAI,CAACI,MAAM,CACdC,GAAG,CAAEC,KAAK,KAAM;MACbC,SAAS,EAAED,KAAK,CAACC,SAAS;MAC1BC,QAAQ,EAAEF,KAAK,CAACG,cAAc;MAC9BC,gBAAgB,EAAEJ,KAAK,CAACI,gBAAgB;AACxC;AACA;AACAC,MAAAA,kBAAkB,EAAEL,KAAK,CAACK,kBAAkB,GACtCC,UAAU,CAACX,IAAI,CAACC,SAAS,CAACI,KAAK,CAACK,kBAAkB,CAAC,CAAC,GACpD;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