@carbonenginejs/runtime-resource 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CjsResMan.js +4 -4
- package/dist/CjsResMan.js.map +1 -1
- package/dist/_virtual/_rollupPluginBabelHelpers.js +1 -4
- package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/dist/format/CjsByteReader.js +310 -0
- package/dist/format/CjsByteReader.js.map +1 -0
- package/dist/format/CjsByteWriter.js +242 -0
- package/dist/format/CjsByteWriter.js.map +1 -0
- package/dist/format/CjsFormatError.js +41 -0
- package/dist/format/CjsFormatError.js.map +1 -0
- package/dist/format/CjsStringTable.js +268 -0
- package/dist/format/CjsStringTable.js.map +1 -0
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js +361 -0
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js.map +1 -0
- package/dist/format/carbonEffect/CjsCarbonEffectWriter.js +373 -0
- package/dist/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -0
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js +372 -0
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js +427 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectRecords.js +955 -0
- package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -0
- package/dist/format/compareUtf8.js +36 -0
- package/dist/format/compareUtf8.js.map +1 -0
- package/dist/format/index.js +11 -0
- package/dist/format/index.js.map +1 -0
- package/dist/formats/bnk/CjsBnkFormat.js +10 -4
- package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
- package/dist/formats/bnk/core/eventAction.js +305 -0
- package/dist/formats/bnk/core/eventAction.js.map +1 -0
- package/dist/formats/bnk/core/helpers.js +11 -2
- package/dist/formats/bnk/core/helpers.js.map +1 -1
- package/dist/formats/bnk/core/nodeBase.js +532 -0
- package/dist/formats/bnk/core/nodeBase.js.map +1 -0
- package/dist/formats/bnk/core/sfxNodes.js +252 -152
- package/dist/formats/bnk/core/sfxNodes.js.map +1 -1
- package/dist/formats/hlsl/core/HlslReader.js +7 -257
- package/dist/formats/hlsl/core/HlslReader.js.map +1 -1
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +781 -0
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +21 -1
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -1
- package/dist/formats/index.js +1 -1
- package/dist/formats/webgl/core/cewg/CewgPackage.js +2 -1
- package/dist/formats/webgl/core/cewg/CewgPackage.js.map +1 -1
- package/dist/formats/webgl/core/cewg/binary.js +11 -93
- package/dist/formats/webgl/core/cewg/binary.js.map +1 -1
- package/dist/formats/webgl/core/effectPackage.js +1 -1
- package/dist/formats/webgpu/CjsWebgpuFormat.js +4 -23
- package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +197 -0
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js +368 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/containerViews.js +355 -0
- package/dist/formats/webgpu/core/cewgpu/containerViews.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/validateContainer.js +90 -0
- package/dist/formats/webgpu/core/cewgpu/validateContainer.js.map +1 -0
- package/dist/formats/webgpu/core/effectBackendBodySet.js +21 -20
- package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
- package/dist/formats/webgpu/core/helpers.js +87 -92
- package/dist/formats/webgpu/core/helpers.js.map +1 -1
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +14 -13
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js.map +1 -1
- package/dist/formats/webgpu/core/ir/inferValueTypes.js +10 -8
- package/dist/formats/webgpu/core/ir/inferValueTypes.js.map +1 -1
- package/dist/formats/webgpu/core/packageEffect.js +94 -9
- package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
- package/dist/formats/webgpu/core/packageMetadata.js +10 -1
- package/dist/formats/webgpu/core/packageMetadata.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +17 -15
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +13 -12
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +9 -8
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +23 -22
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js +46 -44
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js.map +1 -1
- package/dist/resource/CjsResource.js +700 -684
- package/dist/resource/CjsResource.js.map +1 -1
- package/dist/resource/Tr2LightProfileRes.js +18 -27
- package/dist/resource/Tr2LightProfileRes.js.map +1 -1
- package/dist/resource/audio/CjsAudioBufferRes.js +2 -2
- package/dist/resource/audio/CjsAudioBufferRes.js.map +1 -1
- package/dist/resource/audio/CjsAudioRes.js +2 -2
- package/dist/resource/audio/CjsAudioRes.js.map +1 -1
- package/dist/resource/geometry/TriGeometryRes.js +605 -586
- package/dist/resource/geometry/TriGeometryRes.js.map +1 -1
- package/dist/resource/geometry/granny/Tr2GrannyStateRes.js +21 -30
- package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -1
- package/dist/resource/geometry/granny/TriGrannyRes.js +21 -30
- package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -1
- package/dist/resource/shader/Tr2EffectRes.js +9 -7
- package/dist/resource/shader/Tr2EffectRes.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialArea.js +5 -3
- package/dist/resource/shader/Tr2MaterialArea.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialMesh.js +4 -2
- package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialRes.js +5 -3
- package/dist/resource/shader/Tr2MaterialRes.js.map +1 -1
- package/dist/resource/shader/Tr2Shader.js +26 -21
- package/dist/resource/shader/Tr2Shader.js.map +1 -1
- package/dist/resource/shader/Tr2ShaderPermutation.js +8 -6
- package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectDefine.js +5 -3
- package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectDescription.js +5 -3
- package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js +17 -15
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +11 -9
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectResource.js +8 -6
- package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js +15 -13
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js +7 -5
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2Pass.js +11 -9
- package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js +8 -6
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -1
- package/dist/resource/texture/CjsTextureArrayRes.js +400 -411
- package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -1
- package/dist/resource/texture/Tr2ImageRes.js +99 -95
- package/dist/resource/texture/Tr2ImageRes.js.map +1 -1
- package/dist/resource/texture/TriTextureRes.js +312 -273
- package/dist/resource/texture/TriTextureRes.js.map +1 -1
- package/docs/README.md +13 -1
- package/docs/architecture.md +3 -3
- package/docs/concepts/resource-lifecycle.md +9 -2
- package/docs/concepts/shader-resource-model.md +114 -0
- package/docs/concepts/writing-an-engine-adapter.md +115 -0
- package/docs/formats/README.md +24 -1
- package/docs/formats/carbon-effect-container.md +452 -0
- package/docs/formats/dxbc/reference/classes/README.md +5 -72
- package/docs/formats/hlsl/reference/api.md +5 -4
- package/docs/formats/hlsl/reference/classes/README.md +6 -11
- package/docs/formats/provenance.md +23 -13
- package/docs/formats/webgl/reference/classes/README.md +5 -92
- package/docs/formats/webgpu/README.md +19 -16
- package/docs/formats/webgpu/architecture.md +15 -12
- package/docs/formats/webgpu/formats/cewgpu.md +175 -438
- package/docs/formats/webgpu/guides/effect-packaging.md +132 -140
- package/docs/formats/webgpu/reference/api.md +131 -131
- package/docs/formats/webgpu/reference/classes/README.md +5 -62
- package/docs/formats/webgpu/reference/wgsl-compatibility.md +146 -45
- package/docs/formats/wwise.md +34 -8
- package/docs/reference/classes/core.md +80 -0
- package/docs/reference/classes/formats.md +18 -28
- package/docs/reference/events.md +25 -0
- package/docs/reference/motherlode-cache.md +22 -8
- package/docs/reference/workers.md +5 -5
- package/docs/roadmap.md +61 -41
- package/package.json +2 -1
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js +0 -415
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js +0 -100
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/binary.js +0 -93
- package/dist/formats/webgpu/core/cewgpu/binary.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/tags.js +0 -17
- package/dist/formats/webgpu/core/cewgpu/tags.js.map +0 -1
- package/dist/formats/webgpu/core/effectPackageValidation.js +0 -1078
- package/dist/formats/webgpu/core/effectPackageValidation.js.map +0 -1
- package/docs/formats/hlsl/reference/classes/carbon-compatibility.md +0 -66
- package/docs/formats/hlsl/reference/classes/public-api.md +0 -26
- package/docs/formats/hlsl/reference/classes/tr2-effect-model.md +0 -150
|
@@ -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 \"../../hlsl/portable.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 {\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) => left.stageName.localeCompare(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 * record. Its complete source reflection stays in `RFLX`, so a partial backend\n * never removes source truth.\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","localeCompare","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":";;;;;;;;;;;;;AAiBO,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,KAAKD,IAAI,CAACP,SAAS,CAACS,aAAa,CAACD,KAAK,CAACR,SAAS,CAAC;AAC5E,GA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EiH,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 \"../../hlsl/portable.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_CHUNK = \"WGSB\";\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\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 *\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_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,iB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AAS,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,15 +1,14 @@
|
|
|
1
1
|
import { CjsDxbcFormat } from '../../dxbc/CjsDxbcFormat.js';
|
|
2
2
|
import { readEffectAnalysis, normalizeBytecodeBytes } from './effectAnalysis.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { looksLikeCewgpuContainer, CewgpuContainer } from './cewgpu/CewgpuContainer.js';
|
|
4
|
+
import { validateEffectContainer } from './cewgpu/validateContainer.js';
|
|
5
|
+
import { resolvedPermutationIndex, deriveAnalysis, deriveWgsl, deriveBackendBodySet, deriveMetadata, deriveInfo } from './cewgpu/containerViews.js';
|
|
6
6
|
import { WebgpuReadError } from './errors.js';
|
|
7
7
|
import { lowerDxbcToIr } from './ir/lowerDxbcToIr.js';
|
|
8
8
|
import { normalizeEffectPermutation, validateResolvedPermutation } from './packageEffectSelection.js';
|
|
9
9
|
|
|
10
10
|
const OUTPUT_JSON = "json";
|
|
11
11
|
const OUTPUT_RAW = "raw";
|
|
12
|
-
const CEWGPU_MAGIC = "CWGP";
|
|
13
12
|
const CEWGPU_FORMAT = "CEWGPU";
|
|
14
13
|
const CEWGPU_ANALYSIS_FORMAT = "CEWGPU_ANALYSIS";
|
|
15
14
|
const CEWGPU_ANALYSIS_VERSION = 1;
|
|
@@ -132,15 +131,20 @@ function toBytes(input) {
|
|
|
132
131
|
}
|
|
133
132
|
|
|
134
133
|
/**
|
|
135
|
-
*
|
|
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.
|
|
136
141
|
*
|
|
137
142
|
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.
|
|
138
|
-
* @returns {boolean} True when the payload
|
|
143
|
+
* @returns {boolean} True when the payload opens on Carbon's v15 version dword.
|
|
139
144
|
*/
|
|
140
145
|
function isCewgpu(input) {
|
|
141
146
|
try {
|
|
142
|
-
|
|
143
|
-
return bytes.length >= CEWGPU_MAGIC.length && CEWGPU_MAGIC.split("").every((char, index) => bytes[index] === char.charCodeAt(0));
|
|
147
|
+
return looksLikeCewgpuContainer(toBytes(input));
|
|
144
148
|
} catch {
|
|
145
149
|
return false;
|
|
146
150
|
}
|
|
@@ -149,136 +153,127 @@ function isCewgpu(input) {
|
|
|
149
153
|
/**
|
|
150
154
|
* The shared read path used by the instance Read/Inspect and static one-shots.
|
|
151
155
|
*
|
|
152
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU
|
|
156
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU container payload.
|
|
153
157
|
* @param {object} values Normalized format values.
|
|
154
|
-
* @returns {
|
|
158
|
+
* @returns {CewgpuContainer} The loaded container.
|
|
155
159
|
*/
|
|
156
160
|
function readRaw(input, values) {
|
|
157
161
|
const bytes = toBytes(input);
|
|
158
|
-
const
|
|
159
|
-
const ok =
|
|
162
|
+
const container = new CewgpuContainer();
|
|
163
|
+
const ok = container.Read(bytes, {
|
|
160
164
|
sourcePath: values.source
|
|
161
165
|
});
|
|
162
166
|
if (!ok) {
|
|
163
|
-
throw new WebgpuReadError(
|
|
167
|
+
throw new WebgpuReadError(container.readError ? container.readError.message : "Failed to read CEWGPU container", {
|
|
164
168
|
source: values.source,
|
|
165
|
-
cause:
|
|
169
|
+
cause: container.readError || null
|
|
166
170
|
});
|
|
167
171
|
}
|
|
168
172
|
try {
|
|
169
|
-
|
|
173
|
+
validateEffectContainer(container, {
|
|
174
|
+
source: values.source
|
|
175
|
+
});
|
|
170
176
|
} catch (error) {
|
|
177
|
+
if (error instanceof WebgpuReadError) throw error;
|
|
171
178
|
throw new WebgpuReadError(error.message, {
|
|
172
179
|
source: values.source,
|
|
173
180
|
cause: error
|
|
174
181
|
});
|
|
175
182
|
}
|
|
176
|
-
return
|
|
177
|
-
}
|
|
178
|
-
function analysisStages(pkg) {
|
|
179
|
-
const analysisJson = pkg.analysisJson;
|
|
180
|
-
return Array.isArray(analysisJson?.stages) ? analysisJson.stages : [];
|
|
181
|
-
}
|
|
182
|
-
function wgslShaders(pkg) {
|
|
183
|
-
const wgslJson = pkg.wgslJson;
|
|
184
|
-
return Array.isArray(wgslJson?.shaders) ? wgslJson.shaders : [];
|
|
185
|
-
}
|
|
186
|
-
function wgslLayouts(pkg) {
|
|
187
|
-
const wgslJson = pkg.wgslJson;
|
|
188
|
-
return Array.isArray(wgslJson?.layouts) ? wgslJson.layouts : [];
|
|
183
|
+
return container;
|
|
189
184
|
}
|
|
190
185
|
|
|
191
186
|
/**
|
|
192
|
-
* Converts a loaded
|
|
187
|
+
* Converts a loaded container to the documented plain JSON shape.
|
|
193
188
|
*
|
|
194
|
-
*
|
|
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 {CewgpuContainer} container Loaded container.
|
|
198
|
+
* @param {object} [options] View options.
|
|
195
199
|
* @returns {object} Plain JSON data.
|
|
196
200
|
*/
|
|
197
|
-
function packageToJson(
|
|
201
|
+
function packageToJson(container, options = {}) {
|
|
202
|
+
const source = options.source || container.sourcePath || "memory";
|
|
203
|
+
const permutationIndex = options.permutationIndex ?? resolvedPermutationIndex(container);
|
|
204
|
+
const analysis = deriveAnalysis(container, {
|
|
205
|
+
source,
|
|
206
|
+
permutationIndex
|
|
207
|
+
});
|
|
208
|
+
const wgsl = deriveWgsl(container, {
|
|
209
|
+
permutationIndex
|
|
210
|
+
});
|
|
198
211
|
return toJsonValue({
|
|
199
212
|
format: CEWGPU_FORMAT,
|
|
200
|
-
version:
|
|
201
|
-
sourcePath:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
analysis: pkg.analysisJson !== null ? pkg.analysisJson : pkg.analysis,
|
|
217
|
-
wgsl: pkg.wgslJson !== null ? pkg.wgslJson : pkg.wgsl,
|
|
218
|
-
stages: analysisStages(pkg),
|
|
219
|
-
shaders: wgslShaders(pkg),
|
|
220
|
-
layouts: wgslLayouts(pkg)
|
|
213
|
+
version: container.carbon.version,
|
|
214
|
+
sourcePath: source,
|
|
215
|
+
info: deriveInfo(container, {
|
|
216
|
+
source
|
|
217
|
+
}),
|
|
218
|
+
metadata: deriveMetadata(container, {
|
|
219
|
+
source,
|
|
220
|
+
permutationIndex
|
|
221
|
+
}),
|
|
222
|
+
permutationGraph: container.permutationGraph,
|
|
223
|
+
analysis,
|
|
224
|
+
wgsl,
|
|
225
|
+
backendBodySet: deriveBackendBodySet(container),
|
|
226
|
+
stages: analysis.stages ?? [],
|
|
227
|
+
shaders: wgsl.shaders ?? [],
|
|
228
|
+
layouts: wgsl.layouts ?? []
|
|
221
229
|
});
|
|
222
230
|
}
|
|
223
231
|
|
|
224
232
|
/**
|
|
225
233
|
* Shared read entry honouring the emit mode.
|
|
226
234
|
*
|
|
227
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU
|
|
235
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU container payload.
|
|
228
236
|
* @param {object} values Normalized format values.
|
|
229
|
-
* @returns {
|
|
237
|
+
* @returns {CewgpuContainer|object} Raw container or plain JSON data.
|
|
230
238
|
*/
|
|
231
239
|
function readWithValues(input, values) {
|
|
232
|
-
const
|
|
233
|
-
return values.emit === OUTPUT_RAW ?
|
|
240
|
+
const container = readRaw(input, values);
|
|
241
|
+
return values.emit === OUTPUT_RAW ? container : packageToJson(container, {
|
|
242
|
+
source: values.source
|
|
243
|
+
});
|
|
234
244
|
}
|
|
235
245
|
|
|
236
246
|
/**
|
|
237
|
-
*
|
|
238
|
-
* WGSL
|
|
247
|
+
* Compact inspection: Carbon version and compiler bytes, body counts, and the
|
|
248
|
+
* resolved analysis/WGSL counts without building the full JSON package shape.
|
|
239
249
|
*
|
|
240
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU
|
|
250
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU container payload.
|
|
241
251
|
* @param {object} values Normalized format values.
|
|
242
252
|
* @returns {object} Plain summary data.
|
|
243
253
|
*/
|
|
244
254
|
function inspectWithValues(input, values) {
|
|
245
|
-
const
|
|
246
|
-
const
|
|
247
|
-
const
|
|
255
|
+
const container = readRaw(input, values);
|
|
256
|
+
const graph = container.permutationGraph;
|
|
257
|
+
const permutationIndex = resolvedPermutationIndex(container);
|
|
258
|
+
const analysis = deriveAnalysis(container, {
|
|
259
|
+
source: values.source,
|
|
260
|
+
permutationIndex
|
|
261
|
+
});
|
|
262
|
+
const wgsl = deriveWgsl(container, {
|
|
263
|
+
permutationIndex
|
|
264
|
+
});
|
|
248
265
|
return {
|
|
249
266
|
source: values.source,
|
|
250
267
|
isCewgpu: true,
|
|
251
|
-
version:
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
size,
|
|
259
|
-
offset
|
|
260
|
-
})),
|
|
261
|
-
permutationCount: permutationGraph?.variants?.length ?? 0,
|
|
262
|
-
uniqueBodyCount: permutationGraph?.bodies?.length ?? 0,
|
|
263
|
-
reflectionBodyCount: info?.effectReflection?.bodyCount ?? 0,
|
|
264
|
-
reflectionSourceProgramCount: info?.effectReflection?.sourceProgramCount ?? 0,
|
|
265
|
-
reflectionBlobCount: info?.effectReflection?.blobCount ?? 0,
|
|
266
|
-
reflectionBlobByteLength: info?.effectReflection?.blobByteLength ?? 0,
|
|
267
|
-
stageCount: analysisStages(pkg).length,
|
|
268
|
-
shaderCount: wgslShaders(pkg).length,
|
|
269
|
-
layoutCount: wgslLayouts(pkg).length
|
|
268
|
+
version: container.carbon.version,
|
|
269
|
+
compilerVersion: [...container.carbon.compilerVersion],
|
|
270
|
+
permutationCount: graph.variants.length,
|
|
271
|
+
uniqueBodyCount: graph.bodies.length,
|
|
272
|
+
stageCount: analysis.stages.length,
|
|
273
|
+
shaderCount: wgsl.shaders.length,
|
|
274
|
+
layoutCount: wgsl.layouts.length
|
|
270
275
|
};
|
|
271
276
|
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Assembles a CEWGPU package from ordered chunk payloads.
|
|
275
|
-
*
|
|
276
|
-
* @param {Array<[string, string|object|Uint8Array|ArrayBuffer|ArrayBufferView]>} chunks Ordered package chunks.
|
|
277
|
-
* @returns {Uint8Array} Package bytes.
|
|
278
|
-
*/
|
|
279
|
-
function buildPackage(chunks) {
|
|
280
|
-
return CewgpuPackageBuilder.build(chunks);
|
|
281
|
-
}
|
|
282
277
|
function dxbcSource(source, key) {
|
|
283
278
|
return source ? `${source}#${key}` : key;
|
|
284
279
|
}
|
|
@@ -444,5 +439,5 @@ function toJsonValue(value) {
|
|
|
444
439
|
return null;
|
|
445
440
|
}
|
|
446
441
|
|
|
447
|
-
export { CEWGPU_ANALYSIS_FORMAT, CEWGPU_ANALYSIS_VERSION, CEWGPU_FORMAT,
|
|
442
|
+
export { CEWGPU_ANALYSIS_FORMAT, CEWGPU_ANALYSIS_VERSION, CEWGPU_FORMAT, DEFAULT_VALUES, OUTPUT_JSON, OUTPUT_RAW, WebgpuReadError, analyzeEffectWithValues, buildEffectAnalysis, inspectWithValues, isCewgpu, normalizeValues, packageToJson, readRaw, readWithValues, toBytes, toJsonValue, validateClass, validateClassKey };
|
|
448
443
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../../../src/formats/webgpu/core/helpers.js"],"sourcesContent":["import CjsDxbcFormat from \"../../dxbc/index.js\";\nimport { normalizeBytecodeBytes, readEffectAnalysis } from \"./effectAnalysis.js\";\n\nimport { CewgpuPackage } from \"./cewgpu/CewgpuPackage.js\";\nimport { CewgpuPackageBuilder } from \"./cewgpu/CewgpuPackageBuilder.js\";\nimport { validateEffectPackageEnvelope } from \"./effectPackageValidation.js\";\nimport { WebgpuReadError } from \"./errors.js\";\nimport { lowerDxbcToIr } from \"./ir/lowerDxbcToIr.js\";\nimport {\n normalizeEffectPermutation,\n validateResolvedPermutation\n} from \"./packageEffectSelection.js\";\n\nexport const OUTPUT_JSON = \"json\";\nexport const OUTPUT_RAW = \"raw\";\nexport const CEWGPU_MAGIC = \"CWGP\";\nexport const CEWGPU_FORMAT = \"CEWGPU\";\nexport const CEWGPU_ANALYSIS_FORMAT = \"CEWGPU_ANALYSIS\";\nexport const CEWGPU_ANALYSIS_VERSION = 1;\n\nexport const DEFAULT_VALUES = Object.freeze({\n emit: OUTPUT_JSON,\n source: \"memory\",\n decodeInstructions: true,\n permutation: null,\n schema: null,\n classes: Object.freeze({})\n});\n\nconst OPTION_KEYS = new Set([ \"emit\", \"source\", \"decodeInstructions\", \"permutation\", \"schema\", \"classes\" ]);\nconst VALID_EMITS = new Set([ OUTPUT_JSON, OUTPUT_RAW ]);\n\nfunction hasOwn(value, key)\n{\n return Object.prototype.hasOwnProperty.call(value, key);\n}\n\nfunction normalizeEmit(emit, readerName)\n{\n if (emit === undefined || emit === OUTPUT_JSON) return OUTPUT_JSON;\n if (emit === OUTPUT_RAW) return OUTPUT_RAW;\n throw new TypeError(`${readerName}: emit must be \"${OUTPUT_JSON}\" or \"${OUTPUT_RAW}\", got ${JSON.stringify(emit)}`);\n}\n\nfunction assertKnownOptions(options, readerName)\n{\n for (const key of Object.keys(options))\n {\n if (!OPTION_KEYS.has(key))\n {\n throw new TypeError(`${readerName}: unknown option ${JSON.stringify(key)}`);\n }\n }\n}\n\nfunction classMap(values)\n{\n return values && values.classes ? values.classes : {};\n}\n\nfunction cloneValues(values)\n{\n return {\n emit: values.emit,\n source: values.source ?? DEFAULT_VALUES.source,\n decodeInstructions: values.decodeInstructions ?? DEFAULT_VALUES.decodeInstructions,\n permutation: values.permutation ?? null,\n schema: values.schema ?? null,\n classes: { ...classMap(values) }\n };\n}\n\n/**\n * Rejects class override keys outside a format reader's supported class set.\n *\n * @param {string[]} classKeys Supported class override keys.\n * @param {string} key Candidate override key.\n * @param {string} readerName Reader name used in diagnostics.\n */\nexport function validateClassKey(classKeys, key, readerName)\n{\n if (!classKeys.includes(key))\n {\n throw new Error(`${readerName} unknown class type \"${String(key)}\"`);\n }\n}\n\n/**\n * Validates one constructor supplied through a format reader class override.\n *\n * @param {string[]} classKeys Supported class override keys.\n * @param {string} type Candidate override key.\n * @param {Function} Class Candidate constructor.\n * @param {string} readerName Reader name used in diagnostics.\n */\nexport function validateClass(classKeys, type, Class, readerName)\n{\n validateClassKey(classKeys, type, readerName);\n if (typeof Class !== \"function\")\n {\n throw new TypeError(`${readerName} class \"${type}\" must be a constructor`);\n }\n}\n\nfunction mergeClasses(values, classes, classKeys, readerName)\n{\n if (!classes || typeof classes !== \"object\")\n {\n throw new TypeError(`${readerName} classes option must be an object`);\n }\n\n const next = { ...values.classes };\n for (const [ type, Class ] of Object.entries(classes))\n {\n validateClass(classKeys, type, Class, readerName);\n next[type] = Class;\n }\n values.classes = next;\n}\n\n/**\n * Merge format values over a base set and validate them.\n *\n * @param {object} base Current values.\n * @param {object} [options] Values to merge in.\n * @param {string[]} classKeys Valid class keys.\n * @param {string} readerName Reader name used in error messages.\n * @returns {object} A validated copy of the merged values.\n */\nexport function normalizeValues(base, options = {}, classKeys = [], readerName = \"CjsWebgpuFormat\")\n{\n if (!options || typeof options !== \"object\")\n {\n throw new TypeError(`${readerName} options must be an object`);\n }\n\n assertKnownOptions(options, readerName);\n\n const values = cloneValues(base);\n if (hasOwn(options, \"emit\")) values.emit = normalizeEmit(options.emit, readerName);\n if (hasOwn(options, \"source\")) values.source = typeof options.source === \"string\" && options.source ? options.source : DEFAULT_VALUES.source;\n if (hasOwn(options, \"decodeInstructions\")) values.decodeInstructions = !!options.decodeInstructions;\n if (hasOwn(options, \"permutation\")) values.permutation = options.permutation ?? null;\n if (hasOwn(options, \"schema\")) values.schema = options.schema ?? null;\n if (hasOwn(options, \"classes\")) mergeClasses(values, options.classes, classKeys, readerName);\n return values;\n}\n\n/**\n * Normalize caller input into a Uint8Array of package bytes.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.\n * @returns {Uint8Array} The payload bytes.\n */\nexport function toBytes(input)\n{\n if (input instanceof Uint8Array) return input;\n if (typeof ArrayBuffer !== \"undefined\" && input instanceof ArrayBuffer) return new Uint8Array(input);\n if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n throw new TypeError(\"CjsWebgpuFormat: input must be CEWGPU package bytes (Uint8Array, Buffer, DataView or ArrayBuffer)\");\n}\n\n/**\n * Sniffs whether a payload starts with the CEWGPU container magic.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.\n * @returns {boolean} True when the payload looks like a CEWGPU package.\n */\nexport function isCewgpu(input)\n{\n try\n {\n const bytes = toBytes(input);\n return bytes.length >= CEWGPU_MAGIC.length\n && CEWGPU_MAGIC.split(\"\").every((char, index) => bytes[index] === char.charCodeAt(0));\n }\n catch\n {\n return false;\n }\n}\n\n/**\n * The shared read path used by the instance Read/Inspect and static one-shots.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU package payload.\n * @param {object} values Normalized format values.\n * @returns {CewgpuPackage} The loaded package.\n */\nexport function readRaw(input, values)\n{\n const bytes = toBytes(input);\n const pkg = new CewgpuPackage();\n const ok = pkg.Read(bytes, { sourcePath: values.source });\n\n if (!ok)\n {\n throw new WebgpuReadError(\n pkg.readError ? pkg.readError.message : \"Failed to read CEWGPU package\",\n {\n source: values.source,\n cause: pkg.readError || null\n }\n );\n }\n\n try\n {\n validateEffectPackageEnvelope(pkg);\n }\n catch (error)\n {\n throw new WebgpuReadError(error.message, {\n source: values.source,\n cause: error\n });\n }\n\n return pkg;\n}\n\nfunction analysisStages(pkg)\n{\n const analysisJson = pkg.analysisJson;\n return Array.isArray(analysisJson?.stages) ? analysisJson.stages : [];\n}\n\nfunction wgslShaders(pkg)\n{\n const wgslJson = pkg.wgslJson;\n return Array.isArray(wgslJson?.shaders) ? wgslJson.shaders : [];\n}\n\nfunction wgslLayouts(pkg)\n{\n const wgslJson = pkg.wgslJson;\n return Array.isArray(wgslJson?.layouts) ? wgslJson.layouts : [];\n}\n\n/**\n * Converts a loaded package to the documented plain JSON shape.\n *\n * @param {CewgpuPackage} pkg Loaded package.\n * @returns {object} Plain JSON data.\n */\nexport function packageToJson(pkg)\n{\n return toJsonValue({\n format: CEWGPU_FORMAT,\n version: pkg.version,\n sourcePath: pkg.sourcePath,\n chunks: pkg.chunks.map(({ tag, size, offset }) => ({ tag, size, offset })),\n info: pkg.info,\n metadata: pkg.metadata,\n permutationGraph: pkg.permutationGraph,\n reflection: pkg.reflection,\n reflectionBlobByteLength: pkg.reflectionBlobBytes?.byteLength ?? 0,\n analysis: pkg.analysisJson !== null ? pkg.analysisJson : pkg.analysis,\n wgsl: pkg.wgslJson !== null ? pkg.wgslJson : pkg.wgsl,\n stages: analysisStages(pkg),\n shaders: wgslShaders(pkg),\n layouts: wgslLayouts(pkg)\n });\n}\n\n/**\n * Shared read entry honouring the emit mode.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU package payload.\n * @param {object} values Normalized format values.\n * @returns {CewgpuPackage|object} Raw package or plain JSON package data.\n */\nexport function readWithValues(input, values)\n{\n const pkg = readRaw(input, values);\n return values.emit === OUTPUT_RAW ? pkg : packageToJson(pkg);\n}\n\n/**\n * Cheap inspection: version, chunk tags/sizes, analysis-stage counts, and\n * WGSL shader counts without building the full JSON package shape.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU package payload.\n * @param {object} values Normalized format values.\n * @returns {object} Plain summary data.\n */\nexport function inspectWithValues(input, values)\n{\n const pkg = readRaw(input, values);\n const info = pkg.info;\n const permutationGraph = pkg.permutationGraph;\n return {\n source: values.source,\n isCewgpu: true,\n version: pkg.version,\n chunks: pkg.chunks.map(({ tag, size, offset }) => ({ tag, size, offset })),\n permutationCount: permutationGraph?.variants?.length ?? 0,\n uniqueBodyCount: permutationGraph?.bodies?.length ?? 0,\n reflectionBodyCount: info?.effectReflection?.bodyCount ?? 0,\n reflectionSourceProgramCount:\n info?.effectReflection?.sourceProgramCount ?? 0,\n reflectionBlobCount: info?.effectReflection?.blobCount ?? 0,\n reflectionBlobByteLength:\n info?.effectReflection?.blobByteLength ?? 0,\n stageCount: analysisStages(pkg).length,\n shaderCount: wgslShaders(pkg).length,\n layoutCount: wgslLayouts(pkg).length\n };\n}\n\n/**\n * Assembles a CEWGPU package from ordered chunk payloads.\n *\n * @param {Array<[string, string|object|Uint8Array|ArrayBuffer|ArrayBufferView]>} chunks Ordered package chunks.\n * @returns {Uint8Array} Package bytes.\n */\nexport function buildPackage(chunks)\n{\n return CewgpuPackageBuilder.build(chunks);\n}\n\nfunction dxbcSource(source, key)\n{\n return source ? `${source}#${key}` : key;\n}\n\nfunction resolvedStageBytecode(stage, key, bytecodeByKey)\n{\n if (!Number.isInteger(stage.stageType)\n || !Number.isInteger(stage.passIndex)\n || typeof stage.techniqueName !== \"string\"\n || !stage.techniqueName\n || typeof stage.stageName !== \"string\"\n || !stage.stageName)\n {\n throw new Error(`${key} manifest stage identity is invalid`);\n }\n\n const innerStageType = stage.shaderBytecode?.stageType;\n if (innerStageType !== undefined && !Number.isInteger(innerStageType))\n {\n throw new Error(`${key} manifest stage bytecode type is invalid`);\n }\n\n let raw = bytecodeByKey?.get(key);\n if (!raw && bytecodeByKey instanceof Map)\n {\n raw = Array.from(bytecodeByKey.values()).find((entry) =>\n entry.techniqueName === stage.techniqueName\n && entry.passIndex === stage.passIndex\n && entry.stageType === stage.stageType\n );\n }\n if (!raw) return stage.shaderBytecode?.bytes;\n\n if (!Number.isInteger(raw.stageType)\n || stage.stageType !== raw.stageType\n || (innerStageType !== undefined && innerStageType !== raw.stageType)\n || stage.stageName !== raw.stageName\n || (stage.shaderBytecode?.stageName !== undefined\n && stage.shaderBytecode.stageName !== raw.stageName))\n {\n throw new Error(`${key} manifest and raw stage metadata disagree`);\n }\n\n if (stage.shaderBytecode?.bytes !== undefined)\n {\n const manifestBytes = normalizeBytecodeBytes(\n stage.shaderBytecode.bytes,\n `${key} manifest stage bytecode`\n );\n if (!manifestBytes\n || manifestBytes.length !== raw.bytes.length\n || manifestBytes.some((value, index) => value !== raw.bytes[index]))\n {\n throw new Error(`${key} manifest and raw stage bytecode disagree`);\n }\n }\n\n return raw.bytes;\n}\n\nfunction analyzeStage(stage, options)\n{\n const key = `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`;\n const shaderBytecode = stage.shaderBytecode && typeof stage.shaderBytecode === \"object\"\n ? { ...stage.shaderBytecode }\n : stage.shaderBytecode;\n if (shaderBytecode && typeof shaderBytecode === \"object\")\n {\n delete shaderBytecode.bytes;\n }\n const out = {\n ...stage,\n shaderBytecode,\n key,\n dxbc: null,\n dxbcError: null,\n ir: null,\n irError: null\n };\n\n if (options.decodeBytecode === false)\n {\n return out;\n }\n\n const bytecodeBytes = normalizeBytecodeBytes(\n options.bytecodeBytes ?? stage.shaderBytecode?.bytes,\n `${key} stage bytecode`\n );\n if (!bytecodeBytes?.length)\n {\n return out;\n }\n\n try\n {\n out.dxbc = CjsDxbcFormat.read(bytecodeBytes, {\n source: dxbcSource(options.source, key),\n decodeInstructions: options.decodeInstructions\n });\n if (options.decodeInstructions && Array.isArray(out.dxbc.instructions))\n {\n try\n {\n out.ir = lowerDxbcToIr(out.dxbc, { source: dxbcSource(options.source, key) });\n }\n catch (error)\n {\n out.irError = {\n name: error.name,\n message: error.message\n };\n }\n }\n }\n catch (error)\n {\n out.dxbcError = {\n name: error.name,\n message: error.message\n };\n }\n\n return out;\n}\n\n/**\n * Builds the normalized WebGPU analysis document from a resolved effect.\n *\n * @param {object} resolved Raw resolved-effect context from `readEffectAnalysis`.\n * @param {object} [options] Analysis options.\n * @param {string} [options.source] Source label for diagnostics.\n * @param {boolean} [options.decodeBytecode] Whether stage bytecode is inspected.\n * @param {boolean} [options.decodeInstructions] Whether DXBC instructions are decoded.\n * @returns {object} Plain JSON-compatible analysis data.\n */\nexport function buildEffectAnalysis(resolved, options = {})\n{\n const source = options.source || resolved.effectRes?.sourcePath || \"memory\";\n const decodeBytecode = options.decodeBytecode !== undefined ? !!options.decodeBytecode : true;\n const decodeInstructions = options.decodeInstructions !== undefined ? !!options.decodeInstructions : true;\n const manifest = resolved.bindingManifest?.toJSON?.() ?? null;\n const bytecodeByKey = resolved.stageBytecodeByKey instanceof Map\n ? resolved.stageBytecodeByKey\n : null;\n const stages = (manifest?.stages || []).map((stage) =>\n {\n const key = `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`;\n\n return analyzeStage(stage, {\n source,\n decodeBytecode,\n decodeInstructions,\n bytecodeBytes: resolvedStageBytecode(stage, key, bytecodeByKey)\n });\n });\n\n return toJsonValue({\n format: CEWGPU_ANALYSIS_FORMAT,\n formatVersion: CEWGPU_ANALYSIS_VERSION,\n source,\n effectVersion: resolved.effectDescription?.version ?? manifest?.version ?? resolved.effectRes?.m_version ?? null,\n compilerVersion: resolved.effectRes?.m_compilerVersion ?? null,\n effectName: manifest?.effectName || resolved.effectDescription?.effectName || null,\n bodyIndex: resolved.selection?.bodyIndex ?? 0,\n selectedOptions: resolved.selection?.selectedOptions ?? [],\n passes: manifest?.passes || [],\n stages\n });\n}\n\n/**\n * Analyzes one compiled effect payload into a normalized WebGPU-facing\n * document: selected permutation, Carbon binding manifest, and per-stage DXBC\n * decode.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.\n * @param {object} values Normalized format values.\n * @returns {object} Plain JSON-compatible analysis data.\n */\nexport function analyzeEffectWithValues(input, values)\n{\n const permutation = normalizeEffectPermutation(values.permutation);\n const resolved = readEffectAnalysis(input, {\n source: values.source,\n permutation\n });\n validateResolvedPermutation(\n permutation,\n resolved.selection?.selectedOptions ?? []\n );\n\n return buildEffectAnalysis(resolved, {\n source: values.source,\n decodeInstructions: values.decodeInstructions\n });\n}\n\n/**\n * Deep-convert a value to plain JSON-compatible data.\n *\n * @param {any} value Value to convert.\n * @returns {any} Plain data.\n */\nexport function toJsonValue(value)\n{\n if (value === null || value === undefined) return value ?? null;\n if (typeof value === \"number\" || typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"bigint\") return value.toString();\n if (ArrayBuffer.isView(value)) return Array.from(value);\n if (Array.isArray(value)) return value.map(toJsonValue);\n if (value instanceof Map)\n {\n const out = {};\n for (const [ key, entry ] of value) out[key] = toJsonValue(entry);\n return out;\n }\n if (value instanceof Set) return Array.from(value, toJsonValue);\n if (typeof value === \"object\")\n {\n if (typeof value.toJSON === \"function\") return toJsonValue(value.toJSON());\n const out = {};\n for (const key of Object.keys(value)) out[key] = toJsonValue(value[key]);\n return out;\n }\n return null;\n}\n\nexport { WebgpuReadError };\n"],"names":["OUTPUT_JSON","OUTPUT_RAW","CEWGPU_MAGIC","CEWGPU_FORMAT","CEWGPU_ANALYSIS_FORMAT","CEWGPU_ANALYSIS_VERSION","DEFAULT_VALUES","Object","freeze","emit","source","decodeInstructions","permutation","schema","classes","OPTION_KEYS","Set","hasOwn","value","key","prototype","hasOwnProperty","call","normalizeEmit","readerName","undefined","TypeError","JSON","stringify","assertKnownOptions","options","keys","has","classMap","values","cloneValues","validateClassKey","classKeys","includes","Error","String","validateClass","type","Class","mergeClasses","next","entries","normalizeValues","base","toBytes","input","Uint8Array","ArrayBuffer","isView","buffer","byteOffset","byteLength","isCewgpu","bytes","length","split","every","char","index","charCodeAt","readRaw","pkg","CewgpuPackage","ok","Read","sourcePath","WebgpuReadError","readError","message","cause","validateEffectPackageEnvelope","error","analysisStages","analysisJson","Array","isArray","stages","wgslShaders","wgslJson","shaders","wgslLayouts","layouts","packageToJson","toJsonValue","format","version","chunks","map","tag","size","offset","info","metadata","permutationGraph","reflection","reflectionBlobByteLength","reflectionBlobBytes","analysis","wgsl","readWithValues","inspectWithValues","permutationCount","variants","uniqueBodyCount","bodies","reflectionBodyCount","effectReflection","bodyCount","reflectionSourceProgramCount","sourceProgramCount","reflectionBlobCount","blobCount","blobByteLength","stageCount","shaderCount","layoutCount","buildPackage","CewgpuPackageBuilder","build","dxbcSource","resolvedStageBytecode","stage","bytecodeByKey","Number","isInteger","stageType","passIndex","techniqueName","stageName","innerStageType","shaderBytecode","raw","get","Map","from","find","entry","manifestBytes","normalizeBytecodeBytes","some","analyzeStage","out","dxbc","dxbcError","ir","irError","decodeBytecode","bytecodeBytes","CjsDxbcFormat","read","instructions","lowerDxbcToIr","name","buildEffectAnalysis","resolved","effectRes","manifest","bindingManifest","toJSON","stageBytecodeByKey","formatVersion","effectVersion","effectDescription","m_version","compilerVersion","m_compilerVersion","effectName","bodyIndex","selection","selectedOptions","passes","analyzeEffectWithValues","normalizeEffectPermutation","readEffectAnalysis","validateResolvedPermutation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AAW,CAAC;AAC/D,EAAA,IAAI,OAAOtE,KAAK,KAAK,QAAQ,EAC7B;AACI,IAAA,IAAI,OAAOA,KAAK,CAACiJ,MAAM,KAAK,UAAU,EAAE,OAAO3E,WAAW,CAACtE,KAAK,CAACiJ,MAAM,EAAE,CAAC;IAC1E,MAAMjB,GAAG,GAAG,EAAE;IACd,KAAK,MAAM/H,GAAG,IAAIZ,MAAM,CAACwB,IAAI,CAACb,KAAK,CAAC,EAAEgI,GAAG,CAAC/H,GAAG,CAAC,GAAGqE,WAAW,CAACtE,KAAK,CAACC,GAAG,CAAC,CAAC;AACxE,IAAA,OAAO+H,GAAG;AACd,EAAA;AACA,EAAA,OAAO,IAAI;AACf;;;;"}
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../../../src/formats/webgpu/core/helpers.js"],"sourcesContent":["import CjsDxbcFormat from \"../../dxbc/index.js\";\nimport { normalizeBytecodeBytes, readEffectAnalysis } from \"./effectAnalysis.js\";\n\nimport { CewgpuContainer, looksLikeCewgpuContainer } from \"./cewgpu/CewgpuContainer.js\";\nimport { validateEffectContainer } from \"./cewgpu/validateContainer.js\";\nimport {\n deriveAnalysis,\n deriveBackendBodySet,\n deriveInfo,\n deriveMetadata,\n deriveWgsl,\n resolvedPermutationIndex\n} from \"./cewgpu/containerViews.js\";\nimport { WebgpuReadError } from \"./errors.js\";\nimport { lowerDxbcToIr } from \"./ir/lowerDxbcToIr.js\";\nimport {\n normalizeEffectPermutation,\n validateResolvedPermutation\n} from \"./packageEffectSelection.js\";\n\nexport const OUTPUT_JSON = \"json\";\nexport const OUTPUT_RAW = \"raw\";\nexport const CEWGPU_FORMAT = \"CEWGPU\";\nexport const CEWGPU_ANALYSIS_FORMAT = \"CEWGPU_ANALYSIS\";\nexport const CEWGPU_ANALYSIS_VERSION = 1;\n\nexport const DEFAULT_VALUES = Object.freeze({\n emit: OUTPUT_JSON,\n source: \"memory\",\n decodeInstructions: true,\n permutation: null,\n schema: null,\n classes: Object.freeze({})\n});\n\nconst OPTION_KEYS = new Set([ \"emit\", \"source\", \"decodeInstructions\", \"permutation\", \"schema\", \"classes\" ]);\nconst VALID_EMITS = new Set([ OUTPUT_JSON, OUTPUT_RAW ]);\n\nfunction hasOwn(value, key)\n{\n return Object.prototype.hasOwnProperty.call(value, key);\n}\n\nfunction normalizeEmit(emit, readerName)\n{\n if (emit === undefined || emit === OUTPUT_JSON) return OUTPUT_JSON;\n if (emit === OUTPUT_RAW) return OUTPUT_RAW;\n throw new TypeError(`${readerName}: emit must be \"${OUTPUT_JSON}\" or \"${OUTPUT_RAW}\", got ${JSON.stringify(emit)}`);\n}\n\nfunction assertKnownOptions(options, readerName)\n{\n for (const key of Object.keys(options))\n {\n if (!OPTION_KEYS.has(key))\n {\n throw new TypeError(`${readerName}: unknown option ${JSON.stringify(key)}`);\n }\n }\n}\n\nfunction classMap(values)\n{\n return values && values.classes ? values.classes : {};\n}\n\nfunction cloneValues(values)\n{\n return {\n emit: values.emit,\n source: values.source ?? DEFAULT_VALUES.source,\n decodeInstructions: values.decodeInstructions ?? DEFAULT_VALUES.decodeInstructions,\n permutation: values.permutation ?? null,\n schema: values.schema ?? null,\n classes: { ...classMap(values) }\n };\n}\n\n/**\n * Rejects class override keys outside a format reader's supported class set.\n *\n * @param {string[]} classKeys Supported class override keys.\n * @param {string} key Candidate override key.\n * @param {string} readerName Reader name used in diagnostics.\n */\nexport function validateClassKey(classKeys, key, readerName)\n{\n if (!classKeys.includes(key))\n {\n throw new Error(`${readerName} unknown class type \"${String(key)}\"`);\n }\n}\n\n/**\n * Validates one constructor supplied through a format reader class override.\n *\n * @param {string[]} classKeys Supported class override keys.\n * @param {string} type Candidate override key.\n * @param {Function} Class Candidate constructor.\n * @param {string} readerName Reader name used in diagnostics.\n */\nexport function validateClass(classKeys, type, Class, readerName)\n{\n validateClassKey(classKeys, type, readerName);\n if (typeof Class !== \"function\")\n {\n throw new TypeError(`${readerName} class \"${type}\" must be a constructor`);\n }\n}\n\nfunction mergeClasses(values, classes, classKeys, readerName)\n{\n if (!classes || typeof classes !== \"object\")\n {\n throw new TypeError(`${readerName} classes option must be an object`);\n }\n\n const next = { ...values.classes };\n for (const [ type, Class ] of Object.entries(classes))\n {\n validateClass(classKeys, type, Class, readerName);\n next[type] = Class;\n }\n values.classes = next;\n}\n\n/**\n * Merge format values over a base set and validate them.\n *\n * @param {object} base Current values.\n * @param {object} [options] Values to merge in.\n * @param {string[]} classKeys Valid class keys.\n * @param {string} readerName Reader name used in error messages.\n * @returns {object} A validated copy of the merged values.\n */\nexport function normalizeValues(base, options = {}, classKeys = [], readerName = \"CjsWebgpuFormat\")\n{\n if (!options || typeof options !== \"object\")\n {\n throw new TypeError(`${readerName} options must be an object`);\n }\n\n assertKnownOptions(options, readerName);\n\n const values = cloneValues(base);\n if (hasOwn(options, \"emit\")) values.emit = normalizeEmit(options.emit, readerName);\n if (hasOwn(options, \"source\")) values.source = typeof options.source === \"string\" && options.source ? options.source : DEFAULT_VALUES.source;\n if (hasOwn(options, \"decodeInstructions\")) values.decodeInstructions = !!options.decodeInstructions;\n if (hasOwn(options, \"permutation\")) values.permutation = options.permutation ?? null;\n if (hasOwn(options, \"schema\")) values.schema = options.schema ?? null;\n if (hasOwn(options, \"classes\")) mergeClasses(values, options.classes, classKeys, readerName);\n return values;\n}\n\n/**\n * Normalize caller input into a Uint8Array of package bytes.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.\n * @returns {Uint8Array} The payload bytes.\n */\nexport function toBytes(input)\n{\n if (input instanceof Uint8Array) return input;\n if (typeof ArrayBuffer !== \"undefined\" && input instanceof ArrayBuffer) return new Uint8Array(input);\n if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n throw new TypeError(\"CjsWebgpuFormat: input must be CEWGPU package bytes (Uint8Array, Buffer, DataView or ArrayBuffer)\");\n}\n\n/**\n * Reports whether a payload has the Carbon v15 container shape.\n *\n * This is a **shape** check, not an identity check. Our containers are stock\n * Carbon v15 files, so nothing in the bytes separates one from a shipped\n * `effect.dx11` file -- and nothing should. Identity comes from the resource\n * path the file was resolved through, exactly as it does for Carbon, whose own\n * three backend trees are byte-format-identical with no language field anywhere.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.\n * @returns {boolean} True when the payload opens on Carbon's v15 version dword.\n */\nexport function isCewgpu(input)\n{\n try\n {\n return looksLikeCewgpuContainer(toBytes(input));\n }\n catch\n {\n return false;\n }\n}\n\n/**\n * The shared read path used by the instance Read/Inspect and static one-shots.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU container payload.\n * @param {object} values Normalized format values.\n * @returns {CewgpuContainer} The loaded container.\n */\nexport function readRaw(input, values)\n{\n const bytes = toBytes(input);\n const container = new CewgpuContainer();\n const ok = container.Read(bytes, { sourcePath: values.source });\n\n if (!ok)\n {\n throw new WebgpuReadError(\n container.readError ? container.readError.message : \"Failed to read CEWGPU container\",\n {\n source: values.source,\n cause: container.readError || null\n }\n );\n }\n\n try\n {\n validateEffectContainer(container, { source: values.source });\n }\n catch (error)\n {\n if (error instanceof WebgpuReadError) throw error;\n throw new WebgpuReadError(error.message, {\n source: values.source,\n cause: error\n });\n }\n\n return container;\n}\n\n/**\n * Converts a loaded container to the documented plain JSON shape.\n *\n * `analysis` and `wgsl` are **derived views**, not stored documents. The chunk\n * package kept them beside the reflection they were computed from and carried\n * digests to detect the two disagreeing; there is now one document, so there is\n * nothing left to disagree and no digest to carry.\n *\n * `chunks` is gone. It described a container that no longer exists, and a record\n * layout has no chunk table to translate it into.\n *\n * @param {CewgpuContainer} container Loaded container.\n * @param {object} [options] View options.\n * @returns {object} Plain JSON data.\n */\nexport function packageToJson(container, options = {})\n{\n const source = options.source || container.sourcePath || \"memory\";\n const permutationIndex = options.permutationIndex ?? resolvedPermutationIndex(container);\n const analysis = deriveAnalysis(container, { source, permutationIndex });\n const wgsl = deriveWgsl(container, { permutationIndex });\n\n return toJsonValue({\n format: CEWGPU_FORMAT,\n version: container.carbon.version,\n sourcePath: source,\n info: deriveInfo(container, { source }),\n metadata: deriveMetadata(container, { source, permutationIndex }),\n permutationGraph: container.permutationGraph,\n analysis,\n wgsl,\n backendBodySet: deriveBackendBodySet(container),\n stages: analysis.stages ?? [],\n shaders: wgsl.shaders ?? [],\n layouts: wgsl.layouts ?? []\n });\n}\n\n/**\n * Shared read entry honouring the emit mode.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU container payload.\n * @param {object} values Normalized format values.\n * @returns {CewgpuContainer|object} Raw container or plain JSON data.\n */\nexport function readWithValues(input, values)\n{\n const container = readRaw(input, values);\n return values.emit === OUTPUT_RAW\n ? container\n : packageToJson(container, { source: values.source });\n}\n\n/**\n * Compact inspection: Carbon version and compiler bytes, body counts, and the\n * resolved analysis/WGSL counts without building the full JSON package shape.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU container payload.\n * @param {object} values Normalized format values.\n * @returns {object} Plain summary data.\n */\nexport function inspectWithValues(input, values)\n{\n const container = readRaw(input, values);\n const graph = container.permutationGraph;\n const permutationIndex = resolvedPermutationIndex(container);\n const analysis = deriveAnalysis(container, { source: values.source, permutationIndex });\n const wgsl = deriveWgsl(container, { permutationIndex });\n\n return {\n source: values.source,\n isCewgpu: true,\n version: container.carbon.version,\n compilerVersion: [ ...container.carbon.compilerVersion ],\n permutationCount: graph.variants.length,\n uniqueBodyCount: graph.bodies.length,\n stageCount: analysis.stages.length,\n shaderCount: wgsl.shaders.length,\n layoutCount: wgsl.layouts.length\n };\n}\n\nfunction dxbcSource(source, key)\n{\n return source ? `${source}#${key}` : key;\n}\n\nfunction resolvedStageBytecode(stage, key, bytecodeByKey)\n{\n if (!Number.isInteger(stage.stageType)\n || !Number.isInteger(stage.passIndex)\n || typeof stage.techniqueName !== \"string\"\n || !stage.techniqueName\n || typeof stage.stageName !== \"string\"\n || !stage.stageName)\n {\n throw new Error(`${key} manifest stage identity is invalid`);\n }\n\n const innerStageType = stage.shaderBytecode?.stageType;\n if (innerStageType !== undefined && !Number.isInteger(innerStageType))\n {\n throw new Error(`${key} manifest stage bytecode type is invalid`);\n }\n\n let raw = bytecodeByKey?.get(key);\n if (!raw && bytecodeByKey instanceof Map)\n {\n raw = Array.from(bytecodeByKey.values()).find((entry) =>\n entry.techniqueName === stage.techniqueName\n && entry.passIndex === stage.passIndex\n && entry.stageType === stage.stageType\n );\n }\n if (!raw) return stage.shaderBytecode?.bytes;\n\n if (!Number.isInteger(raw.stageType)\n || stage.stageType !== raw.stageType\n || (innerStageType !== undefined && innerStageType !== raw.stageType)\n || stage.stageName !== raw.stageName\n || (stage.shaderBytecode?.stageName !== undefined\n && stage.shaderBytecode.stageName !== raw.stageName))\n {\n throw new Error(`${key} manifest and raw stage metadata disagree`);\n }\n\n if (stage.shaderBytecode?.bytes !== undefined)\n {\n const manifestBytes = normalizeBytecodeBytes(\n stage.shaderBytecode.bytes,\n `${key} manifest stage bytecode`\n );\n if (!manifestBytes\n || manifestBytes.length !== raw.bytes.length\n || manifestBytes.some((value, index) => value !== raw.bytes[index]))\n {\n throw new Error(`${key} manifest and raw stage bytecode disagree`);\n }\n }\n\n return raw.bytes;\n}\n\nfunction analyzeStage(stage, options)\n{\n const key = `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`;\n const shaderBytecode = stage.shaderBytecode && typeof stage.shaderBytecode === \"object\"\n ? { ...stage.shaderBytecode }\n : stage.shaderBytecode;\n if (shaderBytecode && typeof shaderBytecode === \"object\")\n {\n delete shaderBytecode.bytes;\n }\n const out = {\n ...stage,\n shaderBytecode,\n key,\n dxbc: null,\n dxbcError: null,\n ir: null,\n irError: null\n };\n\n if (options.decodeBytecode === false)\n {\n return out;\n }\n\n const bytecodeBytes = normalizeBytecodeBytes(\n options.bytecodeBytes ?? stage.shaderBytecode?.bytes,\n `${key} stage bytecode`\n );\n if (!bytecodeBytes?.length)\n {\n return out;\n }\n\n try\n {\n out.dxbc = CjsDxbcFormat.read(bytecodeBytes, {\n source: dxbcSource(options.source, key),\n decodeInstructions: options.decodeInstructions\n });\n if (options.decodeInstructions && Array.isArray(out.dxbc.instructions))\n {\n try\n {\n out.ir = lowerDxbcToIr(out.dxbc, { source: dxbcSource(options.source, key) });\n }\n catch (error)\n {\n out.irError = {\n name: error.name,\n message: error.message\n };\n }\n }\n }\n catch (error)\n {\n out.dxbcError = {\n name: error.name,\n message: error.message\n };\n }\n\n return out;\n}\n\n/**\n * Builds the normalized WebGPU analysis document from a resolved effect.\n *\n * @param {object} resolved Raw resolved-effect context from `readEffectAnalysis`.\n * @param {object} [options] Analysis options.\n * @param {string} [options.source] Source label for diagnostics.\n * @param {boolean} [options.decodeBytecode] Whether stage bytecode is inspected.\n * @param {boolean} [options.decodeInstructions] Whether DXBC instructions are decoded.\n * @returns {object} Plain JSON-compatible analysis data.\n */\nexport function buildEffectAnalysis(resolved, options = {})\n{\n const source = options.source || resolved.effectRes?.sourcePath || \"memory\";\n const decodeBytecode = options.decodeBytecode !== undefined ? !!options.decodeBytecode : true;\n const decodeInstructions = options.decodeInstructions !== undefined ? !!options.decodeInstructions : true;\n const manifest = resolved.bindingManifest?.toJSON?.() ?? null;\n const bytecodeByKey = resolved.stageBytecodeByKey instanceof Map\n ? resolved.stageBytecodeByKey\n : null;\n const stages = (manifest?.stages || []).map((stage) =>\n {\n const key = `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`;\n\n return analyzeStage(stage, {\n source,\n decodeBytecode,\n decodeInstructions,\n bytecodeBytes: resolvedStageBytecode(stage, key, bytecodeByKey)\n });\n });\n\n return toJsonValue({\n format: CEWGPU_ANALYSIS_FORMAT,\n formatVersion: CEWGPU_ANALYSIS_VERSION,\n source,\n effectVersion: resolved.effectDescription?.version ?? manifest?.version ?? resolved.effectRes?.m_version ?? null,\n compilerVersion: resolved.effectRes?.m_compilerVersion ?? null,\n effectName: manifest?.effectName || resolved.effectDescription?.effectName || null,\n bodyIndex: resolved.selection?.bodyIndex ?? 0,\n selectedOptions: resolved.selection?.selectedOptions ?? [],\n passes: manifest?.passes || [],\n stages\n });\n}\n\n/**\n * Analyzes one compiled effect payload into a normalized WebGPU-facing\n * document: selected permutation, Carbon binding manifest, and per-stage DXBC\n * decode.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.\n * @param {object} values Normalized format values.\n * @returns {object} Plain JSON-compatible analysis data.\n */\nexport function analyzeEffectWithValues(input, values)\n{\n const permutation = normalizeEffectPermutation(values.permutation);\n const resolved = readEffectAnalysis(input, {\n source: values.source,\n permutation\n });\n validateResolvedPermutation(\n permutation,\n resolved.selection?.selectedOptions ?? []\n );\n\n return buildEffectAnalysis(resolved, {\n source: values.source,\n decodeInstructions: values.decodeInstructions\n });\n}\n\n/**\n * Deep-convert a value to plain JSON-compatible data.\n *\n * @param {any} value Value to convert.\n * @returns {any} Plain data.\n */\nexport function toJsonValue(value)\n{\n if (value === null || value === undefined) return value ?? null;\n if (typeof value === \"number\" || typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"bigint\") return value.toString();\n if (ArrayBuffer.isView(value)) return Array.from(value);\n if (Array.isArray(value)) return value.map(toJsonValue);\n if (value instanceof Map)\n {\n const out = {};\n for (const [ key, entry ] of value) out[key] = toJsonValue(entry);\n return out;\n }\n if (value instanceof Set) return Array.from(value, toJsonValue);\n if (typeof value === \"object\")\n {\n if (typeof value.toJSON === \"function\") return toJsonValue(value.toJSON());\n const out = {};\n for (const key of Object.keys(value)) out[key] = toJsonValue(value[key]);\n return out;\n }\n return null;\n}\n\nexport { WebgpuReadError };\n"],"names":["OUTPUT_JSON","OUTPUT_RAW","CEWGPU_FORMAT","CEWGPU_ANALYSIS_FORMAT","CEWGPU_ANALYSIS_VERSION","DEFAULT_VALUES","Object","freeze","emit","source","decodeInstructions","permutation","schema","classes","OPTION_KEYS","Set","hasOwn","value","key","prototype","hasOwnProperty","call","normalizeEmit","readerName","undefined","TypeError","JSON","stringify","assertKnownOptions","options","keys","has","classMap","values","cloneValues","validateClassKey","classKeys","includes","Error","String","validateClass","type","Class","mergeClasses","next","entries","normalizeValues","base","toBytes","input","Uint8Array","ArrayBuffer","isView","buffer","byteOffset","byteLength","isCewgpu","looksLikeCewgpuContainer","readRaw","bytes","container","CewgpuContainer","ok","Read","sourcePath","WebgpuReadError","readError","message","cause","validateEffectContainer","error","packageToJson","permutationIndex","resolvedPermutationIndex","analysis","deriveAnalysis","wgsl","deriveWgsl","toJsonValue","format","version","carbon","info","deriveInfo","metadata","deriveMetadata","permutationGraph","backendBodySet","deriveBackendBodySet","stages","shaders","layouts","readWithValues","inspectWithValues","graph","compilerVersion","permutationCount","variants","length","uniqueBodyCount","bodies","stageCount","shaderCount","layoutCount","dxbcSource","resolvedStageBytecode","stage","bytecodeByKey","Number","isInteger","stageType","passIndex","techniqueName","stageName","innerStageType","shaderBytecode","raw","get","Map","Array","from","find","entry","manifestBytes","normalizeBytecodeBytes","some","index","analyzeStage","out","dxbc","dxbcError","ir","irError","decodeBytecode","bytecodeBytes","CjsDxbcFormat","read","isArray","instructions","lowerDxbcToIr","name","buildEffectAnalysis","resolved","effectRes","manifest","bindingManifest","toJSON","stageBytecodeByKey","map","formatVersion","effectVersion","effectDescription","m_version","m_compilerVersion","effectName","bodyIndex","selection","selectedOptions","passes","analyzeEffectWithValues","normalizeEffectPermutation","readEffectAnalysis","validateResolvedPermutation","toString"],"mappings":";;;;;;;;;AAoBO,MAAMA,WAAW,GAAG;AACpB,MAAMC,UAAU,GAAG;AACnB,MAAMC,aAAa,GAAG;AACtB,MAAMC,sBAAsB,GAAG;AAC/B,MAAMC,uBAAuB,GAAG;MAE1BC,cAAc,GAAGC,MAAM,CAACC,MAAM,CAAC;AACxCC,EAAAA,IAAI,EAAER,WAAW;AACjBS,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,kBAAkB,EAAE,IAAI;AACxBC,EAAAA,WAAW,EAAE,IAAI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