@carbonenginejs/runtime-resource 0.17.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/carbonEffect/backendEngineId.js +1 -3
- package/dist/format/carbonEffect/backendEngineId.js.map +1 -1
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js +2 -1
- 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/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/webgl/core/effectPackage.js +2 -3
- package/dist/formats/webgl/core/effectPackage.js.map +1 -1
- package/dist/formats/webgl/core/glslBackendBlock.js +6 -5
- 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/webgpu/CjsWebgpuFormat.js +161 -163
- package/dist/formats/webgpu/CjsWebgpuFormat.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/docs/formats/webgpu/formats/carbon-webgpu.md +11 -4
- package/docs/formats/webgpu/reference/api.md +7 -6
- package/package.json +2 -2
|
@@ -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,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;AACV,KAAC,CAAC,CAAC,CACFE,IAAI,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAKC,WAAW,CAACF,IAAI,CAACP,SAAS,EAAEQ,KAAK,CAACR,SAAS,CAAC;AAC3E,GAAC,CAAC;AACN;AAEA,SAASU,wBAAwBA,CAACC,iBAAiB,EACnD;AACI,EAAA,MAAMC,aAAa,GAAG,IAAIC,GAAG,EAAE;EAE/B,KAAK,MAAMC,SAAS,IAAIH,iBAAiB,EAAEI,UAAU,IAAI,EAAE,EAC3D;AACI,IAAA,KAAK,IAAIC,SAAS,GAAG,CAAC,EAAEA,SAAS,GAAGF,SAAS,CAACG,MAAM,CAACC,MAAM,EAAEF,SAAS,EAAE,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AC,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":";;;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,EAAEf,KAAK,CAAC7D,gBAAgB;AACtD6E,MAAAA,MAAM,EAAE,YAAY;AACpBJ,MAAAA,KAAK,EAAE,IAAI;MACXO,SAAS,EAAEC,UAAU,CAACjG,MAAM;AAC5BD,MAAAA,MAAM,EAAE2F,MAAM,CAACC,MAAM,CAACM,UAAU;AACpC,KAAC,CAAC,CAAC;AACX,EAAA;AAEA,EAAA,MAAMY,eAAe,GAAGvC,MAAM,CAACwC,MAAM,CAAErC,IAAI,IAAKA,IAAI,CAACoB,MAAM,KAAK,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;;;;"}
|
|
@@ -8,7 +8,6 @@ import { lowerDxbcToIr } from './ir/lowerDxbcToIr.js';
|
|
|
8
8
|
import { normalizeEffectPermutation, validateResolvedPermutation } from './packageEffectSelection.js';
|
|
9
9
|
|
|
10
10
|
const OUTPUT_JSON = "json";
|
|
11
|
-
const OUTPUT_RAW = "raw";
|
|
12
11
|
const CARBON_WEBGPU_FORMAT = "CARBON_WEBGPU";
|
|
13
12
|
const CARBON_WEBGPU_ANALYSIS_FORMAT = "CARBON_WEBGPU_ANALYSIS";
|
|
14
13
|
const CARBON_WEBGPU_ANALYSIS_VERSION = 1;
|
|
@@ -21,13 +20,27 @@ const DEFAULT_VALUES = Object.freeze({
|
|
|
21
20
|
classes: Object.freeze({})
|
|
22
21
|
});
|
|
23
22
|
const OPTION_KEYS = new Set(["emit", "source", "decodeInstructions", "permutation", "schema", "classes"]);
|
|
23
|
+
// One emit, as WebGL has. `Read` returns the container-backed document and that
|
|
24
|
+
// document is complete: the analysis, WGSL, metadata and permutation views the
|
|
25
|
+
// caller selects among, plus `backendBodySet`, which is every translated body
|
|
26
|
+
// joined to its shared translation units.
|
|
27
|
+
//
|
|
28
|
+
// A second `raw` emit used to hand back the live `CarbonWebgpuContainer` because
|
|
29
|
+
// the chunk package's JSON could not express the body set. It became the only way
|
|
30
|
+
// to reach a body, so `engine-webgpu` duck-typed the container instead of reading
|
|
31
|
+
// the document - and when the chunk package was replaced, the engine kept asking
|
|
32
|
+
// for a shape the producer had stopped emitting. Both halves then failed, in
|
|
33
|
+
// different directions, for weeks: the default emit built pipelines but resolved
|
|
34
|
+
// no bodies, and the raw emit resolved bodies but built no pipelines.
|
|
35
|
+
//
|
|
36
|
+
// Neither is reachable now. The container stays internal to this module.
|
|
37
|
+
const VALID_EMITS = new Set([OUTPUT_JSON]);
|
|
24
38
|
function hasOwn(value, key) {
|
|
25
39
|
return Object.prototype.hasOwnProperty.call(value, key);
|
|
26
40
|
}
|
|
27
41
|
function normalizeEmit(emit, readerName) {
|
|
28
|
-
if (emit === undefined || emit
|
|
29
|
-
|
|
30
|
-
throw new TypeError(`${readerName}: emit must be "${OUTPUT_JSON}" or "${OUTPUT_RAW}", got ${JSON.stringify(emit)}`);
|
|
42
|
+
if (emit === undefined || VALID_EMITS.has(emit)) return OUTPUT_JSON;
|
|
43
|
+
throw new TypeError(`${readerName}: emit must be "${OUTPUT_JSON}", got ${JSON.stringify(emit)}`);
|
|
31
44
|
}
|
|
32
45
|
function assertKnownOptions(options, readerName) {
|
|
33
46
|
for (const key of Object.keys(options)) {
|
|
@@ -52,12 +65,12 @@ function cloneValues(values) {
|
|
|
52
65
|
};
|
|
53
66
|
}
|
|
54
67
|
|
|
55
|
-
/**
|
|
56
|
-
* Rejects class override keys outside a format reader's supported class set.
|
|
57
|
-
*
|
|
58
|
-
* @param {string[]} classKeys Supported class override keys.
|
|
59
|
-
* @param {string} key Candidate override key.
|
|
60
|
-
* @param {string} readerName Reader name used in diagnostics.
|
|
68
|
+
/**
|
|
69
|
+
* Rejects class override keys outside a format reader's supported class set.
|
|
70
|
+
*
|
|
71
|
+
* @param {string[]} classKeys Supported class override keys.
|
|
72
|
+
* @param {string} key Candidate override key.
|
|
73
|
+
* @param {string} readerName Reader name used in diagnostics.
|
|
61
74
|
*/
|
|
62
75
|
function validateClassKey(classKeys, key, readerName) {
|
|
63
76
|
if (!classKeys.includes(key)) {
|
|
@@ -65,13 +78,13 @@ function validateClassKey(classKeys, key, readerName) {
|
|
|
65
78
|
}
|
|
66
79
|
}
|
|
67
80
|
|
|
68
|
-
/**
|
|
69
|
-
* Validates one constructor supplied through a format reader class override.
|
|
70
|
-
*
|
|
71
|
-
* @param {string[]} classKeys Supported class override keys.
|
|
72
|
-
* @param {string} type Candidate override key.
|
|
73
|
-
* @param {Function} Class Candidate constructor.
|
|
74
|
-
* @param {string} readerName Reader name used in diagnostics.
|
|
81
|
+
/**
|
|
82
|
+
* Validates one constructor supplied through a format reader class override.
|
|
83
|
+
*
|
|
84
|
+
* @param {string[]} classKeys Supported class override keys.
|
|
85
|
+
* @param {string} type Candidate override key.
|
|
86
|
+
* @param {Function} Class Candidate constructor.
|
|
87
|
+
* @param {string} readerName Reader name used in diagnostics.
|
|
75
88
|
*/
|
|
76
89
|
function validateClass(classKeys, type, Class, readerName) {
|
|
77
90
|
validateClassKey(classKeys, type, readerName);
|
|
@@ -93,14 +106,14 @@ function mergeClasses(values, classes, classKeys, readerName) {
|
|
|
93
106
|
values.classes = next;
|
|
94
107
|
}
|
|
95
108
|
|
|
96
|
-
/**
|
|
97
|
-
* Merge format values over a base set and validate them.
|
|
98
|
-
*
|
|
99
|
-
* @param {object} base Current values.
|
|
100
|
-
* @param {object} [options] Values to merge in.
|
|
101
|
-
* @param {string[]} classKeys Valid class keys.
|
|
102
|
-
* @param {string} readerName Reader name used in error messages.
|
|
103
|
-
* @returns {object} A validated copy of the merged values.
|
|
109
|
+
/**
|
|
110
|
+
* Merge format values over a base set and validate them.
|
|
111
|
+
*
|
|
112
|
+
* @param {object} base Current values.
|
|
113
|
+
* @param {object} [options] Values to merge in.
|
|
114
|
+
* @param {string[]} classKeys Valid class keys.
|
|
115
|
+
* @param {string} readerName Reader name used in error messages.
|
|
116
|
+
* @returns {object} A validated copy of the merged values.
|
|
104
117
|
*/
|
|
105
118
|
function normalizeValues(base, options = {}, classKeys = [], readerName = "CjsWebgpuFormat") {
|
|
106
119
|
if (!options || typeof options !== "object") {
|
|
@@ -117,11 +130,11 @@ function normalizeValues(base, options = {}, classKeys = [], readerName = "CjsWe
|
|
|
117
130
|
return values;
|
|
118
131
|
}
|
|
119
132
|
|
|
120
|
-
/**
|
|
121
|
-
* Normalize caller input into a Uint8Array of package bytes.
|
|
122
|
-
*
|
|
123
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.
|
|
124
|
-
* @returns {Uint8Array} The payload bytes.
|
|
133
|
+
/**
|
|
134
|
+
* Normalize caller input into a Uint8Array of package bytes.
|
|
135
|
+
*
|
|
136
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.
|
|
137
|
+
* @returns {Uint8Array} The payload bytes.
|
|
125
138
|
*/
|
|
126
139
|
function toBytes(input) {
|
|
127
140
|
if (input instanceof Uint8Array) return input;
|
|
@@ -130,17 +143,17 @@ function toBytes(input) {
|
|
|
130
143
|
throw new TypeError("CjsWebgpuFormat: input must be Carbon WebGPU package bytes (Uint8Array, Buffer, DataView or ArrayBuffer)");
|
|
131
144
|
}
|
|
132
145
|
|
|
133
|
-
/**
|
|
134
|
-
* Reports whether a payload has the Carbon v15 container shape.
|
|
135
|
-
*
|
|
136
|
-
* This is a **shape** check, not an identity check. Our containers are stock
|
|
137
|
-
* Carbon v15 files, so nothing in the bytes separates one from a shipped
|
|
138
|
-
* `effect.dx11` file -- and nothing should. Identity comes from the resource
|
|
139
|
-
* path the file was resolved through, exactly as it does for Carbon, whose own
|
|
140
|
-
* three backend trees are byte-format-identical with no language field anywhere.
|
|
141
|
-
*
|
|
142
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.
|
|
143
|
-
* @returns {boolean} True when the payload opens on Carbon's v15 version dword.
|
|
146
|
+
/**
|
|
147
|
+
* Reports whether a payload has the Carbon v15 container shape.
|
|
148
|
+
*
|
|
149
|
+
* This is a **shape** check, not an identity check. Our containers are stock
|
|
150
|
+
* Carbon v15 files, so nothing in the bytes separates one from a shipped
|
|
151
|
+
* `effect.dx11` file -- and nothing should. Identity comes from the resource
|
|
152
|
+
* path the file was resolved through, exactly as it does for Carbon, whose own
|
|
153
|
+
* three backend trees are byte-format-identical with no language field anywhere.
|
|
154
|
+
*
|
|
155
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.
|
|
156
|
+
* @returns {boolean} True when the payload opens on Carbon's v15 version dword.
|
|
144
157
|
*/
|
|
145
158
|
function isCarbonWebgpu(input) {
|
|
146
159
|
try {
|
|
@@ -150,12 +163,12 @@ function isCarbonWebgpu(input) {
|
|
|
150
163
|
}
|
|
151
164
|
}
|
|
152
165
|
|
|
153
|
-
/**
|
|
154
|
-
* The shared read path used by the instance Read/Inspect and static one-shots.
|
|
155
|
-
*
|
|
156
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.
|
|
157
|
-
* @param {object} values Normalized format values.
|
|
158
|
-
* @returns {CarbonWebgpuContainer} The loaded container.
|
|
166
|
+
/**
|
|
167
|
+
* The shared read path used by the instance Read/Inspect and static one-shots.
|
|
168
|
+
*
|
|
169
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.
|
|
170
|
+
* @param {object} values Normalized format values.
|
|
171
|
+
* @returns {CarbonWebgpuContainer} The loaded container.
|
|
159
172
|
*/
|
|
160
173
|
function readRaw(input, values) {
|
|
161
174
|
const bytes = toBytes(input);
|
|
@@ -183,20 +196,20 @@ function readRaw(input, values) {
|
|
|
183
196
|
return container;
|
|
184
197
|
}
|
|
185
198
|
|
|
186
|
-
/**
|
|
187
|
-
* Converts a loaded container to the documented plain JSON shape.
|
|
188
|
-
*
|
|
189
|
-
* `analysis` and `wgsl` are **derived views**, not stored documents. The chunk
|
|
190
|
-
* package kept them beside the reflection they were computed from and carried
|
|
191
|
-
* digests to detect the two disagreeing; there is now one document, so there is
|
|
192
|
-
* nothing left to disagree and no digest to carry.
|
|
193
|
-
*
|
|
194
|
-
* `chunks` is gone. It described a container that no longer exists, and a record
|
|
195
|
-
* layout has no chunk table to translate it into.
|
|
196
|
-
*
|
|
197
|
-
* @param {CarbonWebgpuContainer} container Loaded container.
|
|
198
|
-
* @param {object} [options] View options.
|
|
199
|
-
* @returns {object} Plain JSON data.
|
|
199
|
+
/**
|
|
200
|
+
* Converts a loaded container to the documented plain JSON shape.
|
|
201
|
+
*
|
|
202
|
+
* `analysis` and `wgsl` are **derived views**, not stored documents. The chunk
|
|
203
|
+
* package kept them beside the reflection they were computed from and carried
|
|
204
|
+
* digests to detect the two disagreeing; there is now one document, so there is
|
|
205
|
+
* nothing left to disagree and no digest to carry.
|
|
206
|
+
*
|
|
207
|
+
* `chunks` is gone. It described a container that no longer exists, and a record
|
|
208
|
+
* layout has no chunk table to translate it into.
|
|
209
|
+
*
|
|
210
|
+
* @param {CarbonWebgpuContainer} container Loaded container.
|
|
211
|
+
* @param {object} [options] View options.
|
|
212
|
+
* @returns {object} Plain JSON data.
|
|
200
213
|
*/
|
|
201
214
|
function packageToJson(container, options = {}) {
|
|
202
215
|
const source = options.source || container.sourcePath || "memory";
|
|
@@ -229,27 +242,26 @@ function packageToJson(container, options = {}) {
|
|
|
229
242
|
});
|
|
230
243
|
}
|
|
231
244
|
|
|
232
|
-
/**
|
|
233
|
-
* Shared read entry
|
|
234
|
-
*
|
|
235
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.
|
|
236
|
-
* @param {object} values Normalized format values.
|
|
237
|
-
* @returns {
|
|
245
|
+
/**
|
|
246
|
+
* Shared read entry.
|
|
247
|
+
*
|
|
248
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.
|
|
249
|
+
* @param {object} values Normalized format values.
|
|
250
|
+
* @returns {object} Plain JSON data.
|
|
238
251
|
*/
|
|
239
252
|
function readWithValues(input, values) {
|
|
240
|
-
|
|
241
|
-
return values.emit === OUTPUT_RAW ? container : packageToJson(container, {
|
|
253
|
+
return packageToJson(readRaw(input, values), {
|
|
242
254
|
source: values.source
|
|
243
255
|
});
|
|
244
256
|
}
|
|
245
257
|
|
|
246
|
-
/**
|
|
247
|
-
* Compact inspection: Carbon version and compiler bytes, body counts, and the
|
|
248
|
-
* resolved analysis/WGSL counts without building the full JSON package shape.
|
|
249
|
-
*
|
|
250
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.
|
|
251
|
-
* @param {object} values Normalized format values.
|
|
252
|
-
* @returns {object} Plain summary data.
|
|
258
|
+
/**
|
|
259
|
+
* Compact inspection: Carbon version and compiler bytes, body counts, and the
|
|
260
|
+
* resolved analysis/WGSL counts without building the full JSON package shape.
|
|
261
|
+
*
|
|
262
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.
|
|
263
|
+
* @param {object} values Normalized format values.
|
|
264
|
+
* @returns {object} Plain summary data.
|
|
253
265
|
*/
|
|
254
266
|
function inspectWithValues(input, values) {
|
|
255
267
|
const container = readRaw(input, values);
|
|
@@ -351,15 +363,15 @@ function analyzeStage(stage, options) {
|
|
|
351
363
|
return out;
|
|
352
364
|
}
|
|
353
365
|
|
|
354
|
-
/**
|
|
355
|
-
* Builds the normalized WebGPU analysis document from a resolved effect.
|
|
356
|
-
*
|
|
357
|
-
* @param {object} resolved Raw resolved-effect context from `readEffectAnalysis`.
|
|
358
|
-
* @param {object} [options] Analysis options.
|
|
359
|
-
* @param {string} [options.source] Source label for diagnostics.
|
|
360
|
-
* @param {boolean} [options.decodeBytecode] Whether stage bytecode is inspected.
|
|
361
|
-
* @param {boolean} [options.decodeInstructions] Whether DXBC instructions are decoded.
|
|
362
|
-
* @returns {object} Plain JSON-compatible analysis data.
|
|
366
|
+
/**
|
|
367
|
+
* Builds the normalized WebGPU analysis document from a resolved effect.
|
|
368
|
+
*
|
|
369
|
+
* @param {object} resolved Raw resolved-effect context from `readEffectAnalysis`.
|
|
370
|
+
* @param {object} [options] Analysis options.
|
|
371
|
+
* @param {string} [options.source] Source label for diagnostics.
|
|
372
|
+
* @param {boolean} [options.decodeBytecode] Whether stage bytecode is inspected.
|
|
373
|
+
* @param {boolean} [options.decodeInstructions] Whether DXBC instructions are decoded.
|
|
374
|
+
* @returns {object} Plain JSON-compatible analysis data.
|
|
363
375
|
*/
|
|
364
376
|
function buildEffectAnalysis(resolved, options = {}) {
|
|
365
377
|
const source = options.source || resolved.effectRes?.sourcePath || "memory";
|
|
@@ -390,14 +402,14 @@ function buildEffectAnalysis(resolved, options = {}) {
|
|
|
390
402
|
});
|
|
391
403
|
}
|
|
392
404
|
|
|
393
|
-
/**
|
|
394
|
-
* Analyzes one compiled effect payload into a normalized WebGPU-facing
|
|
395
|
-
* document: selected permutation, Carbon binding manifest, and per-stage DXBC
|
|
396
|
-
* decode.
|
|
397
|
-
*
|
|
398
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.
|
|
399
|
-
* @param {object} values Normalized format values.
|
|
400
|
-
* @returns {object} Plain JSON-compatible analysis data.
|
|
405
|
+
/**
|
|
406
|
+
* Analyzes one compiled effect payload into a normalized WebGPU-facing
|
|
407
|
+
* document: selected permutation, Carbon binding manifest, and per-stage DXBC
|
|
408
|
+
* decode.
|
|
409
|
+
*
|
|
410
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.
|
|
411
|
+
* @param {object} values Normalized format values.
|
|
412
|
+
* @returns {object} Plain JSON-compatible analysis data.
|
|
401
413
|
*/
|
|
402
414
|
function analyzeEffectWithValues(input, values) {
|
|
403
415
|
const permutation = normalizeEffectPermutation(values.permutation);
|
|
@@ -412,11 +424,11 @@ function analyzeEffectWithValues(input, values) {
|
|
|
412
424
|
});
|
|
413
425
|
}
|
|
414
426
|
|
|
415
|
-
/**
|
|
416
|
-
* Deep-convert a value to plain JSON-compatible data.
|
|
417
|
-
*
|
|
418
|
-
* @param {any} value Value to convert.
|
|
419
|
-
* @returns {any} Plain data.
|
|
427
|
+
/**
|
|
428
|
+
* Deep-convert a value to plain JSON-compatible data.
|
|
429
|
+
*
|
|
430
|
+
* @param {any} value Value to convert.
|
|
431
|
+
* @returns {any} Plain data.
|
|
420
432
|
*/
|
|
421
433
|
function toJsonValue(value) {
|
|
422
434
|
if (value === null || value === undefined) return value ?? null;
|
|
@@ -439,5 +451,5 @@ function toJsonValue(value) {
|
|
|
439
451
|
return null;
|
|
440
452
|
}
|
|
441
453
|
|
|
442
|
-
export { CARBON_WEBGPU_ANALYSIS_FORMAT, CARBON_WEBGPU_ANALYSIS_VERSION, CARBON_WEBGPU_FORMAT, DEFAULT_VALUES, OUTPUT_JSON,
|
|
454
|
+
export { CARBON_WEBGPU_ANALYSIS_FORMAT, CARBON_WEBGPU_ANALYSIS_VERSION, CARBON_WEBGPU_FORMAT, DEFAULT_VALUES, OUTPUT_JSON, WebgpuReadError, analyzeEffectWithValues, buildEffectAnalysis, inspectWithValues, isCarbonWebgpu, normalizeValues, packageToJson, readRaw, readWithValues, toBytes, toJsonValue, validateClass, validateClassKey };
|
|
443
455
|
//# sourceMappingURL=helpers.js.map
|