@carbonenginejs/runtime-resource 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/format/carbonEffect/backendEngineId.js +1 -3
  2. package/dist/format/carbonEffect/backendEngineId.js.map +1 -1
  3. package/dist/format/carbonEffect/carbonEffectBackendBlock.js +2 -1
  4. package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
  5. package/dist/format/carbonEffect/carbonEffectResourceTransform.js +1 -1
  6. package/dist/format/carbonEffect/carbonEffectResourceTransform.js.map +1 -1
  7. package/dist/format/effect/effectPermutationGraph.js +46 -29
  8. package/dist/format/effect/effectPermutationGraph.js.map +1 -1
  9. package/dist/formats/hlsl/core/detailMapFamily.js +1 -1
  10. package/dist/formats/hlsl/core/detailMapFamily.js.map +1 -1
  11. package/dist/formats/hlsl/core/localLightFamily.js +1 -1
  12. package/dist/formats/hlsl/core/localLightFamily.js.map +1 -1
  13. package/dist/formats/webgl/core/effectPackage.js +2 -3
  14. package/dist/formats/webgl/core/effectPackage.js.map +1 -1
  15. package/dist/formats/webgl/core/glslBackendBlock.js +6 -5
  16. package/dist/formats/webgl/core/glslBackendBlock.js.map +1 -1
  17. package/dist/formats/webgl/core/glslBackendBodySet.js +0 -1
  18. package/dist/formats/webgl/core/glslBackendBodySet.js.map +1 -1
  19. package/dist/formats/webgpu/CjsWebgpuFormat.js +161 -163
  20. package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
  21. package/dist/formats/webgpu/core/effectBackendBodySet.js +21 -22
  22. package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
  23. package/dist/formats/webgpu/core/helpers.js +111 -99
  24. package/dist/formats/webgpu/core/helpers.js.map +1 -1
  25. package/dist/formats/webgpu/core/packageEffect.js +30 -32
  26. package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
  27. package/docs/formats/webgpu/formats/carbon-webgpu.md +11 -4
  28. package/docs/formats/webgpu/reference/api.md +7 -6
  29. package/package.json +2 -2
@@ -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 { CarbonWebgpuContainer, looksLikeCarbonWebgpuContainer } from \"./carbonWebgpu/CarbonWebgpuContainer.js\";\nimport { validateEffectContainer } from \"./carbonWebgpu/validateContainer.js\";\nimport {\n deriveAnalysis,\n deriveBackendBodySet,\n deriveInfo,\n deriveMetadata,\n deriveWgsl,\n resolvedPermutationIndex\n} from \"./carbonWebgpu/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 CARBON_WEBGPU_FORMAT = \"CARBON_WEBGPU\";\nexport const CARBON_WEBGPU_ANALYSIS_FORMAT = \"CARBON_WEBGPU_ANALYSIS\";\nexport const CARBON_WEBGPU_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 Carbon WebGPU 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 isCarbonWebgpu(input)\n{\n try\n {\n return looksLikeCarbonWebgpuContainer(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 Carbon WebGPU container payload.\n * @param {object} values Normalized format values.\n * @returns {CarbonWebgpuContainer} The loaded container.\n */\nexport function readRaw(input, values)\n{\n const bytes = toBytes(input);\n const container = new CarbonWebgpuContainer();\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 Carbon WebGPU 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 {CarbonWebgpuContainer} 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: CARBON_WEBGPU_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 Carbon WebGPU container payload.\n * @param {object} values Normalized format values.\n * @returns {CarbonWebgpuContainer|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 Carbon WebGPU 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 isCarbonWebgpu: 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: CARBON_WEBGPU_ANALYSIS_FORMAT,\n formatVersion: CARBON_WEBGPU_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","CARBON_WEBGPU_FORMAT","CARBON_WEBGPU_ANALYSIS_FORMAT","CARBON_WEBGPU_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","isCarbonWebgpu","looksLikeCarbonWebgpuContainer","readRaw","bytes","container","CarbonWebgpuContainer","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,oBAAoB,GAAG;AAC7B,MAAMC,6BAA6B,GAAG;AACtC,MAAMC,8BAA8B,GAAG;MAEjCC,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;AACjBC,EAAAA,MAAM,EAAE,IAAI;AACZC,EAAAA,OAAO,EAAEP,MAAM,CAACC,MAAM,CAAC,EAAE;AAC7B,CAAC;AAED,MAAMO,WAAW,GAAG,IAAIC,GAAG,CAAC,CAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,CAA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,CAAC9G,GAAG,CAAC,GAAG4D,WAAW,CAAC7D,KAAK,CAACC,GAAG,CAAC,CAAC;AACxE,IAAA,OAAO8G,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\";\r\nimport { normalizeBytecodeBytes, readEffectAnalysis } from \"./effectAnalysis.js\";\r\n\r\nimport { CarbonWebgpuContainer, looksLikeCarbonWebgpuContainer } from \"./carbonWebgpu/CarbonWebgpuContainer.js\";\r\nimport { validateEffectContainer } from \"./carbonWebgpu/validateContainer.js\";\r\nimport {\r\n deriveAnalysis,\r\n deriveBackendBodySet,\r\n deriveInfo,\r\n deriveMetadata,\r\n deriveWgsl,\r\n resolvedPermutationIndex\r\n} from \"./carbonWebgpu/containerViews.js\";\r\nimport { WebgpuReadError } from \"./errors.js\";\r\nimport { lowerDxbcToIr } from \"./ir/lowerDxbcToIr.js\";\r\nimport {\r\n normalizeEffectPermutation,\r\n validateResolvedPermutation\r\n} from \"./packageEffectSelection.js\";\r\n\r\nexport const OUTPUT_JSON = \"json\";\r\nexport const CARBON_WEBGPU_FORMAT = \"CARBON_WEBGPU\";\r\nexport const CARBON_WEBGPU_ANALYSIS_FORMAT = \"CARBON_WEBGPU_ANALYSIS\";\r\nexport const CARBON_WEBGPU_ANALYSIS_VERSION = 1;\r\n\r\nexport const DEFAULT_VALUES = Object.freeze({\r\n emit: OUTPUT_JSON,\r\n source: \"memory\",\r\n decodeInstructions: true,\r\n permutation: null,\r\n schema: null,\r\n classes: Object.freeze({})\r\n});\r\n\r\nconst OPTION_KEYS = new Set([ \"emit\", \"source\", \"decodeInstructions\", \"permutation\", \"schema\", \"classes\" ]);\r\n// One emit, as WebGL has. `Read` returns the container-backed document and that\r\n// document is complete: the analysis, WGSL, metadata and permutation views the\r\n// caller selects among, plus `backendBodySet`, which is every translated body\r\n// joined to its shared translation units.\r\n//\r\n// A second `raw` emit used to hand back the live `CarbonWebgpuContainer` because\r\n// the chunk package's JSON could not express the body set. It became the only way\r\n// to reach a body, so `engine-webgpu` duck-typed the container instead of reading\r\n// the document - and when the chunk package was replaced, the engine kept asking\r\n// for a shape the producer had stopped emitting. Both halves then failed, in\r\n// different directions, for weeks: the default emit built pipelines but resolved\r\n// no bodies, and the raw emit resolved bodies but built no pipelines.\r\n//\r\n// Neither is reachable now. The container stays internal to this module.\r\nconst VALID_EMITS = new Set([ OUTPUT_JSON ]);\r\n\r\nfunction hasOwn(value, key)\r\n{\r\n return Object.prototype.hasOwnProperty.call(value, key);\r\n}\r\n\r\nfunction normalizeEmit(emit, readerName)\r\n{\r\n if (emit === undefined || VALID_EMITS.has(emit)) return OUTPUT_JSON;\r\n throw new TypeError(`${readerName}: emit must be \"${OUTPUT_JSON}\", got ${JSON.stringify(emit)}`);\r\n}\r\n\r\nfunction assertKnownOptions(options, readerName)\r\n{\r\n for (const key of Object.keys(options))\r\n {\r\n if (!OPTION_KEYS.has(key))\r\n {\r\n throw new TypeError(`${readerName}: unknown option ${JSON.stringify(key)}`);\r\n }\r\n }\r\n}\r\n\r\nfunction classMap(values)\r\n{\r\n return values && values.classes ? values.classes : {};\r\n}\r\n\r\nfunction cloneValues(values)\r\n{\r\n return {\r\n emit: values.emit,\r\n source: values.source ?? DEFAULT_VALUES.source,\r\n decodeInstructions: values.decodeInstructions ?? DEFAULT_VALUES.decodeInstructions,\r\n permutation: values.permutation ?? null,\r\n schema: values.schema ?? null,\r\n classes: { ...classMap(values) }\r\n };\r\n}\r\n\r\n/**\r\n * Rejects class override keys outside a format reader's supported class set.\r\n *\r\n * @param {string[]} classKeys Supported class override keys.\r\n * @param {string} key Candidate override key.\r\n * @param {string} readerName Reader name used in diagnostics.\r\n */\r\nexport function validateClassKey(classKeys, key, readerName)\r\n{\r\n if (!classKeys.includes(key))\r\n {\r\n throw new Error(`${readerName} unknown class type \"${String(key)}\"`);\r\n }\r\n}\r\n\r\n/**\r\n * Validates one constructor supplied through a format reader class override.\r\n *\r\n * @param {string[]} classKeys Supported class override keys.\r\n * @param {string} type Candidate override key.\r\n * @param {Function} Class Candidate constructor.\r\n * @param {string} readerName Reader name used in diagnostics.\r\n */\r\nexport function validateClass(classKeys, type, Class, readerName)\r\n{\r\n validateClassKey(classKeys, type, readerName);\r\n if (typeof Class !== \"function\")\r\n {\r\n throw new TypeError(`${readerName} class \"${type}\" must be a constructor`);\r\n }\r\n}\r\n\r\nfunction mergeClasses(values, classes, classKeys, readerName)\r\n{\r\n if (!classes || typeof classes !== \"object\")\r\n {\r\n throw new TypeError(`${readerName} classes option must be an object`);\r\n }\r\n\r\n const next = { ...values.classes };\r\n for (const [ type, Class ] of Object.entries(classes))\r\n {\r\n validateClass(classKeys, type, Class, readerName);\r\n next[type] = Class;\r\n }\r\n values.classes = next;\r\n}\r\n\r\n/**\r\n * Merge format values over a base set and validate them.\r\n *\r\n * @param {object} base Current values.\r\n * @param {object} [options] Values to merge in.\r\n * @param {string[]} classKeys Valid class keys.\r\n * @param {string} readerName Reader name used in error messages.\r\n * @returns {object} A validated copy of the merged values.\r\n */\r\nexport function normalizeValues(base, options = {}, classKeys = [], readerName = \"CjsWebgpuFormat\")\r\n{\r\n if (!options || typeof options !== \"object\")\r\n {\r\n throw new TypeError(`${readerName} options must be an object`);\r\n }\r\n\r\n assertKnownOptions(options, readerName);\r\n\r\n const values = cloneValues(base);\r\n if (hasOwn(options, \"emit\")) values.emit = normalizeEmit(options.emit, readerName);\r\n if (hasOwn(options, \"source\")) values.source = typeof options.source === \"string\" && options.source ? options.source : DEFAULT_VALUES.source;\r\n if (hasOwn(options, \"decodeInstructions\")) values.decodeInstructions = !!options.decodeInstructions;\r\n if (hasOwn(options, \"permutation\")) values.permutation = options.permutation ?? null;\r\n if (hasOwn(options, \"schema\")) values.schema = options.schema ?? null;\r\n if (hasOwn(options, \"classes\")) mergeClasses(values, options.classes, classKeys, readerName);\r\n return values;\r\n}\r\n\r\n/**\r\n * Normalize caller input into a Uint8Array of package bytes.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.\r\n * @returns {Uint8Array} The payload bytes.\r\n */\r\nexport function toBytes(input)\r\n{\r\n if (input instanceof Uint8Array) return input;\r\n if (typeof ArrayBuffer !== \"undefined\" && input instanceof ArrayBuffer) return new Uint8Array(input);\r\n if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\r\n throw new TypeError(\"CjsWebgpuFormat: input must be Carbon WebGPU package bytes (Uint8Array, Buffer, DataView or ArrayBuffer)\");\r\n}\r\n\r\n/**\r\n * Reports whether a payload has the Carbon v15 container shape.\r\n *\r\n * This is a **shape** check, not an identity check. Our containers are stock\r\n * Carbon v15 files, so nothing in the bytes separates one from a shipped\r\n * `effect.dx11` file -- and nothing should. Identity comes from the resource\r\n * path the file was resolved through, exactly as it does for Carbon, whose own\r\n * three backend trees are byte-format-identical with no language field anywhere.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.\r\n * @returns {boolean} True when the payload opens on Carbon's v15 version dword.\r\n */\r\nexport function isCarbonWebgpu(input)\r\n{\r\n try\r\n {\r\n return looksLikeCarbonWebgpuContainer(toBytes(input));\r\n }\r\n catch\r\n {\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * The shared read path used by the instance Read/Inspect and static one-shots.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.\r\n * @param {object} values Normalized format values.\r\n * @returns {CarbonWebgpuContainer} The loaded container.\r\n */\r\nexport function readRaw(input, values)\r\n{\r\n const bytes = toBytes(input);\r\n const container = new CarbonWebgpuContainer();\r\n const ok = container.Read(bytes, { sourcePath: values.source });\r\n\r\n if (!ok)\r\n {\r\n throw new WebgpuReadError(\r\n container.readError ? container.readError.message : \"Failed to read Carbon WebGPU container\",\r\n {\r\n source: values.source,\r\n cause: container.readError || null\r\n }\r\n );\r\n }\r\n\r\n try\r\n {\r\n validateEffectContainer(container, { source: values.source });\r\n }\r\n catch (error)\r\n {\r\n if (error instanceof WebgpuReadError) throw error;\r\n throw new WebgpuReadError(error.message, {\r\n source: values.source,\r\n cause: error\r\n });\r\n }\r\n\r\n return container;\r\n}\r\n\r\n/**\r\n * Converts a loaded container to the documented plain JSON shape.\r\n *\r\n * `analysis` and `wgsl` are **derived views**, not stored documents. The chunk\r\n * package kept them beside the reflection they were computed from and carried\r\n * digests to detect the two disagreeing; there is now one document, so there is\r\n * nothing left to disagree and no digest to carry.\r\n *\r\n * `chunks` is gone. It described a container that no longer exists, and a record\r\n * layout has no chunk table to translate it into.\r\n *\r\n * @param {CarbonWebgpuContainer} container Loaded container.\r\n * @param {object} [options] View options.\r\n * @returns {object} Plain JSON data.\r\n */\r\nexport function packageToJson(container, options = {})\r\n{\r\n const source = options.source || container.sourcePath || \"memory\";\r\n const permutationIndex = options.permutationIndex ?? resolvedPermutationIndex(container);\r\n const analysis = deriveAnalysis(container, { source, permutationIndex });\r\n const wgsl = deriveWgsl(container, { permutationIndex });\r\n\r\n return toJsonValue({\r\n format: CARBON_WEBGPU_FORMAT,\r\n version: container.carbon.version,\r\n sourcePath: source,\r\n info: deriveInfo(container, { source }),\r\n metadata: deriveMetadata(container, { source, permutationIndex }),\r\n permutationGraph: container.permutationGraph,\r\n analysis,\r\n wgsl,\r\n backendBodySet: deriveBackendBodySet(container),\r\n stages: analysis.stages ?? [],\r\n shaders: wgsl.shaders ?? [],\r\n layouts: wgsl.layouts ?? []\r\n });\r\n}\r\n\r\n/**\r\n * Shared read entry.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.\r\n * @param {object} values Normalized format values.\r\n * @returns {object} Plain JSON data.\r\n */\r\nexport function readWithValues(input, values)\r\n{\r\n return packageToJson(readRaw(input, values), { source: values.source });\r\n}\r\n\r\n/**\r\n * Compact inspection: Carbon version and compiler bytes, body counts, and the\r\n * resolved analysis/WGSL counts without building the full JSON package shape.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.\r\n * @param {object} values Normalized format values.\r\n * @returns {object} Plain summary data.\r\n */\r\nexport function inspectWithValues(input, values)\r\n{\r\n const container = readRaw(input, values);\r\n const graph = container.permutationGraph;\r\n const permutationIndex = resolvedPermutationIndex(container);\r\n const analysis = deriveAnalysis(container, { source: values.source, permutationIndex });\r\n const wgsl = deriveWgsl(container, { permutationIndex });\r\n\r\n return {\r\n source: values.source,\r\n isCarbonWebgpu: true,\r\n version: container.carbon.version,\r\n compilerVersion: [ ...container.carbon.compilerVersion ],\r\n permutationCount: graph.variants.length,\r\n uniqueBodyCount: graph.bodies.length,\r\n stageCount: analysis.stages.length,\r\n shaderCount: wgsl.shaders.length,\r\n layoutCount: wgsl.layouts.length\r\n };\r\n}\r\n\r\nfunction dxbcSource(source, key)\r\n{\r\n return source ? `${source}#${key}` : key;\r\n}\r\n\r\nfunction resolvedStageBytecode(stage, key, bytecodeByKey)\r\n{\r\n if (!Number.isInteger(stage.stageType)\r\n || !Number.isInteger(stage.passIndex)\r\n || typeof stage.techniqueName !== \"string\"\r\n || !stage.techniqueName\r\n || typeof stage.stageName !== \"string\"\r\n || !stage.stageName)\r\n {\r\n throw new Error(`${key} manifest stage identity is invalid`);\r\n }\r\n\r\n const innerStageType = stage.shaderBytecode?.stageType;\r\n if (innerStageType !== undefined && !Number.isInteger(innerStageType))\r\n {\r\n throw new Error(`${key} manifest stage bytecode type is invalid`);\r\n }\r\n\r\n let raw = bytecodeByKey?.get(key);\r\n if (!raw && bytecodeByKey instanceof Map)\r\n {\r\n raw = Array.from(bytecodeByKey.values()).find((entry) =>\r\n entry.techniqueName === stage.techniqueName\r\n && entry.passIndex === stage.passIndex\r\n && entry.stageType === stage.stageType\r\n );\r\n }\r\n if (!raw) return stage.shaderBytecode?.bytes;\r\n\r\n if (!Number.isInteger(raw.stageType)\r\n || stage.stageType !== raw.stageType\r\n || (innerStageType !== undefined && innerStageType !== raw.stageType)\r\n || stage.stageName !== raw.stageName\r\n || (stage.shaderBytecode?.stageName !== undefined\r\n && stage.shaderBytecode.stageName !== raw.stageName))\r\n {\r\n throw new Error(`${key} manifest and raw stage metadata disagree`);\r\n }\r\n\r\n if (stage.shaderBytecode?.bytes !== undefined)\r\n {\r\n const manifestBytes = normalizeBytecodeBytes(\r\n stage.shaderBytecode.bytes,\r\n `${key} manifest stage bytecode`\r\n );\r\n if (!manifestBytes\r\n || manifestBytes.length !== raw.bytes.length\r\n || manifestBytes.some((value, index) => value !== raw.bytes[index]))\r\n {\r\n throw new Error(`${key} manifest and raw stage bytecode disagree`);\r\n }\r\n }\r\n\r\n return raw.bytes;\r\n}\r\n\r\nfunction analyzeStage(stage, options)\r\n{\r\n const key = `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`;\r\n const shaderBytecode = stage.shaderBytecode && typeof stage.shaderBytecode === \"object\"\r\n ? { ...stage.shaderBytecode }\r\n : stage.shaderBytecode;\r\n if (shaderBytecode && typeof shaderBytecode === \"object\")\r\n {\r\n delete shaderBytecode.bytes;\r\n }\r\n const out = {\r\n ...stage,\r\n shaderBytecode,\r\n key,\r\n dxbc: null,\r\n dxbcError: null,\r\n ir: null,\r\n irError: null\r\n };\r\n\r\n if (options.decodeBytecode === false)\r\n {\r\n return out;\r\n }\r\n\r\n const bytecodeBytes = normalizeBytecodeBytes(\r\n options.bytecodeBytes ?? stage.shaderBytecode?.bytes,\r\n `${key} stage bytecode`\r\n );\r\n if (!bytecodeBytes?.length)\r\n {\r\n return out;\r\n }\r\n\r\n try\r\n {\r\n out.dxbc = CjsDxbcFormat.read(bytecodeBytes, {\r\n source: dxbcSource(options.source, key),\r\n decodeInstructions: options.decodeInstructions\r\n });\r\n if (options.decodeInstructions && Array.isArray(out.dxbc.instructions))\r\n {\r\n try\r\n {\r\n out.ir = lowerDxbcToIr(out.dxbc, { source: dxbcSource(options.source, key) });\r\n }\r\n catch (error)\r\n {\r\n out.irError = {\r\n name: error.name,\r\n message: error.message\r\n };\r\n }\r\n }\r\n }\r\n catch (error)\r\n {\r\n out.dxbcError = {\r\n name: error.name,\r\n message: error.message\r\n };\r\n }\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Builds the normalized WebGPU analysis document from a resolved effect.\r\n *\r\n * @param {object} resolved Raw resolved-effect context from `readEffectAnalysis`.\r\n * @param {object} [options] Analysis options.\r\n * @param {string} [options.source] Source label for diagnostics.\r\n * @param {boolean} [options.decodeBytecode] Whether stage bytecode is inspected.\r\n * @param {boolean} [options.decodeInstructions] Whether DXBC instructions are decoded.\r\n * @returns {object} Plain JSON-compatible analysis data.\r\n */\r\nexport function buildEffectAnalysis(resolved, options = {})\r\n{\r\n const source = options.source || resolved.effectRes?.sourcePath || \"memory\";\r\n const decodeBytecode = options.decodeBytecode !== undefined ? !!options.decodeBytecode : true;\r\n const decodeInstructions = options.decodeInstructions !== undefined ? !!options.decodeInstructions : true;\r\n const manifest = resolved.bindingManifest?.toJSON?.() ?? null;\r\n const bytecodeByKey = resolved.stageBytecodeByKey instanceof Map\r\n ? resolved.stageBytecodeByKey\r\n : null;\r\n const stages = (manifest?.stages || []).map((stage) =>\r\n {\r\n const key = `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`;\r\n\r\n return analyzeStage(stage, {\r\n source,\r\n decodeBytecode,\r\n decodeInstructions,\r\n bytecodeBytes: resolvedStageBytecode(stage, key, bytecodeByKey)\r\n });\r\n });\r\n\r\n return toJsonValue({\r\n format: CARBON_WEBGPU_ANALYSIS_FORMAT,\r\n formatVersion: CARBON_WEBGPU_ANALYSIS_VERSION,\r\n source,\r\n effectVersion: resolved.effectDescription?.version ?? manifest?.version ?? resolved.effectRes?.m_version ?? null,\r\n compilerVersion: resolved.effectRes?.m_compilerVersion ?? null,\r\n effectName: manifest?.effectName || resolved.effectDescription?.effectName || null,\r\n bodyIndex: resolved.selection?.bodyIndex ?? 0,\r\n selectedOptions: resolved.selection?.selectedOptions ?? [],\r\n passes: manifest?.passes || [],\r\n stages\r\n });\r\n}\r\n\r\n/**\r\n * Analyzes one compiled effect payload into a normalized WebGPU-facing\r\n * document: selected permutation, Carbon binding manifest, and per-stage DXBC\r\n * decode.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.\r\n * @param {object} values Normalized format values.\r\n * @returns {object} Plain JSON-compatible analysis data.\r\n */\r\nexport function analyzeEffectWithValues(input, values)\r\n{\r\n const permutation = normalizeEffectPermutation(values.permutation);\r\n const resolved = readEffectAnalysis(input, {\r\n source: values.source,\r\n permutation\r\n });\r\n validateResolvedPermutation(\r\n permutation,\r\n resolved.selection?.selectedOptions ?? []\r\n );\r\n\r\n return buildEffectAnalysis(resolved, {\r\n source: values.source,\r\n decodeInstructions: values.decodeInstructions\r\n });\r\n}\r\n\r\n/**\r\n * Deep-convert a value to plain JSON-compatible data.\r\n *\r\n * @param {any} value Value to convert.\r\n * @returns {any} Plain data.\r\n */\r\nexport function toJsonValue(value)\r\n{\r\n if (value === null || value === undefined) return value ?? null;\r\n if (typeof value === \"number\" || typeof value === \"string\" || typeof value === \"boolean\") return value;\r\n if (typeof value === \"bigint\") return value.toString();\r\n if (ArrayBuffer.isView(value)) return Array.from(value);\r\n if (Array.isArray(value)) return value.map(toJsonValue);\r\n if (value instanceof Map)\r\n {\r\n const out = {};\r\n for (const [ key, entry ] of value) out[key] = toJsonValue(entry);\r\n return out;\r\n }\r\n if (value instanceof Set) return Array.from(value, toJsonValue);\r\n if (typeof value === \"object\")\r\n {\r\n if (typeof value.toJSON === \"function\") return toJsonValue(value.toJSON());\r\n const out = {};\r\n for (const key of Object.keys(value)) out[key] = toJsonValue(value[key]);\r\n return out;\r\n }\r\n return null;\r\n}\r\n\r\nexport { WebgpuReadError };\r\n"],"names":["OUTPUT_JSON","CARBON_WEBGPU_FORMAT","CARBON_WEBGPU_ANALYSIS_FORMAT","CARBON_WEBGPU_ANALYSIS_VERSION","DEFAULT_VALUES","Object","freeze","emit","source","decodeInstructions","permutation","schema","classes","OPTION_KEYS","Set","VALID_EMITS","hasOwn","value","key","prototype","hasOwnProperty","call","normalizeEmit","readerName","undefined","has","TypeError","JSON","stringify","assertKnownOptions","options","keys","classMap","values","cloneValues","validateClassKey","classKeys","includes","Error","String","validateClass","type","Class","mergeClasses","next","entries","normalizeValues","base","toBytes","input","Uint8Array","ArrayBuffer","isView","buffer","byteOffset","byteLength","isCarbonWebgpu","looksLikeCarbonWebgpuContainer","readRaw","bytes","container","CarbonWebgpuContainer","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,oBAAoB,GAAG;AAC7B,MAAMC,6BAA6B,GAAG;AACtC,MAAMC,8BAA8B,GAAG;MAEjCC,cAAc,GAAGC,MAAM,CAACC,M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,IAAI/G,KAAK,YAAYH,GAAG,EAAE,OAAOyG,KAAK,CAACC,IAAI,CAACvG,KAAK,EAAE6D,WAAW,CAAC;AAC/D,EAAA,IAAI,OAAO7D,KAAK,KAAK,QAAQ,EAC7B;AACI,IAAA,IAAI,OAAOA,KAAK,CAACiI,MAAM,KAAK,UAAU,EAAE,OAAOpE,WAAW,CAAC7D,KAAK,CAACiI,MAAM,EAAE,CAAC;IAC1E,MAAMlB,GAAG,GAAG,EAAE;IACd,KAAK,MAAM9G,GAAG,IAAIb,MAAM,CAAC0B,IAAI,CAACd,KAAK,CAAC,EAAE+G,GAAG,CAAC9G,GAAG,CAAC,GAAG4D,WAAW,CAAC7D,KAAK,CAACC,GAAG,CAAC,CAAC;AACxE,IAAA,OAAO8G,GAAG;AACd,EAAA;AACA,EAAA,OAAO,IAAI;AACf;;;;"}
@@ -6,24 +6,24 @@ import { buildWgslBindingPlan } from './wgsl/buildWgslBindingPlan.js';
6
6
  import { buildWgsl } from './wgsl/emitWgsl.js';
7
7
  import { buildWgslSet } from './wgsl/buildWgslSet.js';
8
8
  import { buildResourceTransformPlan } from './wgsl/buildResourceTransformPlan.js';
9
- import { buildEffectPermutationGraph, EFFECT_PERMUTATION_GRAPH_VERSION, EFFECT_PERMUTATION_GRAPH_FORMAT, EFFECT_PERMUTATION_GRAPH_CHUNK } from '../../../format/effect/effectPermutationGraph.js';
10
- import { buildEffectBackendBodySet, EFFECT_BACKEND_BODY_SET_VERSION, EFFECT_BACKEND_BODY_SET_FORMAT, EFFECT_BACKEND_BODY_SET_CHUNK } from './effectBackendBodySet.js';
9
+ import { buildEffectPermutationGraph, EFFECT_PERMUTATION_GRAPH_VERSION, EFFECT_PERMUTATION_GRAPH_FORMAT } from '../../../format/effect/effectPermutationGraph.js';
10
+ import { buildEffectBackendBodySet, EFFECT_BACKEND_BODY_SET_VERSION, EFFECT_BACKEND_BODY_SET_FORMAT } from './effectBackendBodySet.js';
11
11
  import { DXBC_WGSL_TRANSLATOR_VERSION, DXBC_WGSL_TRANSLATOR_NAME, FORMAT_WEBGPU_PACKAGE_VERSION, FORMAT_WEBGPU_PACKAGE_NAME, WEBGPU_BACKEND_NAME, EFFECT_INFO_VERSION } from './packageMetadata.js';
12
12
  import { sha256Utf8, sha256Bytes } from '../../../format/effect/sha256.js';
13
13
  import { isParticleClearEffectCandidate, preflightParticleClearEffectProfile, particleClearEffectProofFor } from './wgsl/lowerParticleClearComputePrograms.js';
14
14
  import { normalizeEffectPermutation, validateResolvedPermutation, selectEffectStages, buildWgslSelectionMetadata } from './packageEffectSelection.js';
15
15
 
16
- /**
17
- * Build one structurally valid Carbon WebGPU package from compiled Tr2 effect bytes.
18
- *
19
- * The version-15 build result retains every unique body's portable source
20
- * reflection as in-memory evidence while the emitted Carbon wire stores WGSL
21
- * or empty program slots plus representable non-program fields. Filesystem
22
- * concerns remain in callers.
23
- *
24
- * @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.
25
- * @param {object} [options] Source, body-mode, permutation, and stage-selection policy.
26
- * @returns {object} Package bytes plus inspection and provenance documents.
16
+ /**
17
+ * Build one structurally valid Carbon WebGPU package from compiled Tr2 effect bytes.
18
+ *
19
+ * The version-15 build result retains every unique body's portable source
20
+ * reflection as in-memory evidence while the emitted Carbon wire stores WGSL
21
+ * or empty program slots plus representable non-program fields. Filesystem
22
+ * concerns remain in callers.
23
+ *
24
+ * @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.
25
+ * @param {object} [options] Source, body-mode, permutation, and stage-selection policy.
26
+ * @returns {object} Package bytes plus inspection and provenance documents.
27
27
  */
28
28
  function buildEffectPackage(input, options = {}) {
29
29
  const mode = normalizeMode(options.mode, options.allPermutations);
@@ -148,7 +148,6 @@ function buildEffectPackage(input, options = {}) {
148
148
  translator: DXBC_WGSL_TRANSLATOR_NAME,
149
149
  translatorVersion: DXBC_WGSL_TRANSLATOR_VERSION,
150
150
  permutationGraph: Object.freeze({
151
- chunk: EFFECT_PERMUTATION_GRAPH_CHUNK,
152
151
  format: EFFECT_PERMUTATION_GRAPH_FORMAT,
153
152
  formatVersion: EFFECT_PERMUTATION_GRAPH_VERSION,
154
153
  sha256: sha256Utf8(`${JSON.stringify(permutationGraph)}\n`),
@@ -161,7 +160,6 @@ function buildEffectPackage(input, options = {}) {
161
160
  } : {}),
162
161
  ...(backendBodySet ? {
163
162
  backendBodySet: Object.freeze({
164
- chunk: EFFECT_BACKEND_BODY_SET_CHUNK,
165
163
  format: EFFECT_BACKEND_BODY_SET_FORMAT,
166
164
  formatVersion: EFFECT_BACKEND_BODY_SET_VERSION,
167
165
  sha256: sha256Utf8(`${JSON.stringify(backendBodySet)}\n`),
@@ -234,23 +232,23 @@ function buildEffectPackage(input, options = {}) {
234
232
  });
235
233
  }
236
234
 
237
- /**
238
- * Wraps a selected-mode translation as the body set the container emitter takes.
239
- *
240
- * `mode: "all"` builds a real body set covering every unique body. `mode:
241
- * "selected"` translates exactly one, and the container still carries every
242
- * permutation — that asymmetry is the format working as intended rather than a
243
- * gap. When the container emitter rebuilds an untranslated body, it retains
244
- * representable non-program description fields and writes zero-length program
245
- * slots.
246
- *
247
- * So this does not translate anything. It reshapes the one translation already
248
- * performed into the body-set contract, and marks every other body unsupported.
249
- *
250
- * @param {object} permutationGraph Validated permutation graph.
251
- * @param {object} wgsl Emitted WGSL set for the selected body.
252
- * @param {number} bodyIndex Selected permutation index.
253
- * @returns {object} Body set covering one translated body.
235
+ /**
236
+ * Wraps a selected-mode translation as the body set the container emitter takes.
237
+ *
238
+ * `mode: "all"` builds a real body set covering every unique body. `mode:
239
+ * "selected"` translates exactly one, and the container still carries every
240
+ * permutation — that asymmetry is the format working as intended rather than a
241
+ * gap. When the container emitter rebuilds an untranslated body, it retains
242
+ * representable non-program description fields and writes zero-length program
243
+ * slots.
244
+ *
245
+ * So this does not translate anything. It reshapes the one translation already
246
+ * performed into the body-set contract, and marks every other body unsupported.
247
+ *
248
+ * @param {object} permutationGraph Validated permutation graph.
249
+ * @param {object} wgsl Emitted WGSL set for the selected body.
250
+ * @param {number} bodyIndex Selected permutation index.
251
+ * @returns {object} Body set covering one translated body.
254
252
  */
255
253
  function selectedModeBodySet(permutationGraph, wgsl, bodyIndex) {
256
254
  const selectedBodyKey = permutationGraph.variants.find(variant => variant.permutationIndex === bodyIndex)?.bodyKey ?? permutationGraph.variants[0]?.bodyKey ?? null;
@@ -1 +1 @@
1
- {"version":3,"file":"packageEffect.js","sources":["../../../../../src/formats/webgpu/core/packageEffect.js"],"sourcesContent":["import { readEffectAnalysis } from \"./effectAnalysis.js\";\nimport { buildEffectAnalysis, inspectWithValues } from \"./helpers.js\";\nimport { buildCarbonEffectContainer } from \"./buildCarbonEffectContainer.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 {\n buildEffectPermutationGraph,\n EFFECT_PERMUTATION_GRAPH_CHUNK,\n EFFECT_PERMUTATION_GRAPH_FORMAT,\n EFFECT_PERMUTATION_GRAPH_VERSION\n} from \"../../../format/effect/effectPermutationGraph.js\";\nimport {\n buildEffectBackendBodySet,\n EFFECT_BACKEND_BODY_SET_CHUNK,\n EFFECT_BACKEND_BODY_SET_FORMAT,\n EFFECT_BACKEND_BODY_SET_VERSION\n} from \"./effectBackendBodySet.js\";\nimport {\n DXBC_WGSL_TRANSLATOR_NAME,\n DXBC_WGSL_TRANSLATOR_VERSION,\n EFFECT_INFO_VERSION,\n FORMAT_WEBGPU_PACKAGE_NAME,\n FORMAT_WEBGPU_PACKAGE_VERSION,\n WEBGPU_BACKEND_NAME\n} from \"./packageMetadata.js\";\nimport { sha256Bytes, sha256Utf8 } from \"../../../format/effect/sha256.js\";\nimport {\n isParticleClearEffectCandidate,\n particleClearEffectProofFor,\n preflightParticleClearEffectProfile\n} from \"./wgsl/lowerParticleClearComputePrograms.js\";\nimport {\n buildWgslSelectionMetadata,\n normalizeEffectPermutation,\n selectEffectStages,\n validateResolvedPermutation\n} from \"./packageEffectSelection.js\";\n\n/**\n * Build one structurally valid Carbon WebGPU package from compiled Tr2 effect bytes.\n *\n * The version-15 build result retains every unique body's portable source\n * reflection as in-memory evidence while the emitted Carbon wire stores WGSL\n * or empty program slots plus representable non-program fields. Filesystem\n * concerns remain in callers.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.\n * @param {object} [options] Source, body-mode, permutation, and stage-selection policy.\n * @returns {object} Package bytes plus inspection and provenance documents.\n */\nexport function buildEffectPackage(input, options = {})\n{\n const mode = normalizeMode(options.mode, options.allPermutations);\n const source = normalizeSource(options.source);\n const outputPath = normalizeOptionalString(options.outputPath, \"Effect outputPath\");\n const sourceIdentity = normalizeSourceIdentity(\n options.sourceIdentity,\n source,\n input\n );\n const permutation = normalizeEffectPermutation(options.permutation);\n const selection = normalizeSelection(options.selection);\n const resolved = readEffectAnalysis(input, { source, permutation });\n\n // One INFO version means one contract, and that contract requires complete\n // source reflection, which only version-15 input can supply.\n if (resolved.effectRes?.m_version !== 15)\n {\n throw new Error(\n \"Effect package requires a version-15 compiled effect, got version \"\n + (resolved.effectRes?.m_version ?? \"unknown\")\n );\n }\n\n validateResolvedPermutation(permutation, resolved.selection?.selectedOptions ?? []);\n\n const analysis = buildEffectAnalysis(resolved, {\n source,\n decodeBytecode: false,\n decodeInstructions: false\n });\n const bytecodeByKey = resolved.stageBytecodeByKey;\n const selectedStages = selectEffectStages(analysis.stages, selection);\n const programsByKey = new Map();\n const programForKey = (key) =>\n {\n if (programsByKey.has(key)) return programsByKey.get(key);\n const bytecode = bytecodeByKey.get(key)?.bytes;\n\n if (!bytecode?.length)\n {\n throw new Error(`${key} has no shader bytecode`);\n }\n const program = lowerDxbcToIr(\n bytecode,\n { source: `${source}#${key}` }\n );\n programsByKey.set(key, program);\n return program;\n };\n let effectProfileContext = null;\n if (isParticleClearEffectCandidate(resolved.effectDescription))\n {\n programForKey(\"Main.pass0.compute\");\n programForKey(\"Main.pass1.compute\");\n effectProfileContext = preflightParticleClearEffectProfile(\n resolved.effectDescription,\n programsByKey\n );\n }\n const irEntries = selectedStages.map((stage) => ({\n key: stage.key,\n passKey: `${stage.techniqueName}.pass${stage.passIndex}`,\n ir: programForKey(stage.key),\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 const programsByPass = new Map();\n\n for (const entry of irEntries)\n {\n if (!programsByPass.has(entry.passKey))\n {\n programsByPass.set(entry.passKey, []);\n }\n\n programsByPass.get(entry.passKey).push(entry);\n }\n\n const resourceTransformPlans = new Map(Array.from(programsByPass, ([ key, entries ]) => [\n key,\n buildResourceTransformPlan(\n entries.map((entry) => ({\n ir: entry.ir,\n semanticBindings: entry.semanticBindings\n })),\n { layoutKey: key }\n )\n ]));\n const plans = new Map(Array.from(programsByPass, ([ key, entries ]) =>\n {\n const proof = entries.find((entry) => entry.effectProfileProof)\n ?.effectProfileProof ?? null;\n const resourceTransformPlan = resourceTransformPlans.get(key);\n return [\n key,\n buildWgslBindingPlan(\n entries.map((entry) => entry.ir),\n {\n ...(options.bindingPolicy ?? {}),\n ...(proof ? { effectProfileProof: proof } : {}),\n ...(resourceTransformPlan ? { resourceTransformPlan } : {})\n }\n )\n ];\n }));\n const shaderEntries = irEntries.map((entry) => ({\n key: entry.key,\n shader: buildWgsl(entry.ir, {\n bindingPlan: plans.get(entry.passKey),\n ...(resourceTransformPlans.get(entry.passKey)\n ? { resourceTransformPlan: resourceTransformPlans.get(entry.passKey) }\n : {}),\n ...(entry.effectProfileProof\n ? { effectProfileProof: entry.effectProfileProof }\n : {})\n })\n }));\n const wgsl = buildWgslSet(shaderEntries);\n const wgslSelection = buildWgslSelectionMetadata(selection, selectedStages);\n const permutationGraph = buildEffectPermutationGraph(resolved.effectRes);\n // The source is complete when it is a version-15 container. This used to be\n // read off a built reflection document, which made the document look load\n // bearing when it was only ever a consequence of the same version check.\n const sourceComplete = resolved.effectRes.m_version === 15;\n if (mode === \"all\" && !sourceComplete)\n {\n throw new Error(\n \"Effect package mode all requires a complete version-15 source\"\n );\n }\n\n const backendBodySet = mode === \"all\"\n ? buildEffectBackendBodySet(resolved.effectRes, permutationGraph, {\n source,\n selection,\n bindingPolicy: options.bindingPolicy\n })\n : null;\n const completeness = Object.freeze({\n packageValid: true,\n sourceComplete,\n backendComplete: false,\n runtimeComplete: false\n });\n const info = {\n format: \"CARBON_WEBGPU\",\n formatVersion: EFFECT_INFO_VERSION,\n packageKind: \"tr2-effect-webgpu\",\n sourcePath: source,\n outputPath,\n sourceIdentity,\n targetBackend: WEBGPU_BACKEND_NAME,\n backendPackage: FORMAT_WEBGPU_PACKAGE_NAME,\n backendPackageVersion: FORMAT_WEBGPU_PACKAGE_VERSION,\n translator: DXBC_WGSL_TRANSLATOR_NAME,\n translatorVersion: DXBC_WGSL_TRANSLATOR_VERSION,\n permutationGraph: Object.freeze({\n chunk: EFFECT_PERMUTATION_GRAPH_CHUNK,\n format: EFFECT_PERMUTATION_GRAPH_FORMAT,\n formatVersion: EFFECT_PERMUTATION_GRAPH_VERSION,\n sha256: sha256Utf8(`${JSON.stringify(permutationGraph)}\\n`),\n permutationCount: permutationGraph.variants.length,\n uniqueBodyCount: permutationGraph.bodies.length\n }),\n ...(sourceComplete\n ? {\n sourceBodyCoverage: \"all-unique\",\n backendBodyCoverage: backendBodySet\n ? backendBodySet.coverage.bodies\n : \"selected\"\n }\n : {}),\n ...(backendBodySet\n ? {\n backendBodySet: Object.freeze({\n chunk: EFFECT_BACKEND_BODY_SET_CHUNK,\n format: EFFECT_BACKEND_BODY_SET_FORMAT,\n formatVersion: EFFECT_BACKEND_BODY_SET_VERSION,\n sha256: sha256Utf8(`${JSON.stringify(backendBodySet)}\\n`),\n bodyCount: backendBodySet.bodyCount,\n translatedBodyCount: backendBodySet.translatedBodyCount,\n passUnitCount: backendBodySet.passUnitCount\n })\n }\n : {}),\n bodyMode: mode,\n completeness,\n stageCount: analysis.stages.length,\n selectedStageCount: selectedStages.length,\n shaderCount: wgsl.shaders.length,\n layoutCount: wgsl.layouts.length\n };\n const metadata = {\n effectName: analysis.effectName,\n sourcePath: source,\n bodyMode: mode,\n bodyIndex: analysis.bodyIndex,\n selectedOptions: analysis.selectedOptions,\n ...(wgslSelection ? { wgslSelection } : {})\n };\n // The switchover. Former stored chunks are now compatibility views over the\n // Carbon records: the permutation graph comes from the header and offset\n // table, and a translated pass comes from shaderData plus its trailing\n // block. The description tree retains only representable non-program\n // reflection; full portable source reflection remains in the rich\n // in-memory return value below.\n //\n // The wire no longer stores cross-chunk digests. The rich return value keeps\n // hashes as build evidence; they are not records in the emitted container.\n const emittedBodySet = backendBodySet\n ?? selectedModeBodySet(permutationGraph, wgsl, analysis.bodyIndex);\n const container = buildCarbonEffectContainer(\n resolved.effectRes,\n permutationGraph,\n emittedBodySet,\n { compilerVersion: resolved.effectRes.m_compilerVersionBytes }\n );\n const bytes = container.bytes;\n const inspection = inspectWithValues(bytes, {\n source,\n emit: \"json\"\n });\n const qualification = Object.freeze({\n ok: true,\n level: \"structural\",\n validator: \"carbon-webgpu-structural\",\n mode,\n ...completeness,\n selectedStageCount: selectedStages.length,\n shaderCount: wgsl.shaders.length,\n layoutCount: wgsl.layouts.length,\n ...(backendBodySet\n ? {\n backendBodyCount: backendBodySet.bodyCount,\n backendTranslatedBodyCount: backendBodySet.translatedBodyCount,\n backendPassUnitCount: backendBodySet.passUnitCount\n }\n : {}),\n nativeComparison: false\n });\n\n return Object.freeze({\n bytes,\n info: Object.freeze(info),\n metadata: Object.freeze(metadata),\n permutationGraph,\n analysis,\n wgsl,\n backendBodySet,\n inspection: Object.freeze(inspection),\n qualification\n });\n}\n\n/**\n * Wraps a selected-mode translation as the body set the container emitter takes.\n *\n * `mode: \"all\"` builds a real body set covering every unique body. `mode:\n * \"selected\"` translates exactly one, and the container still carries every\n * permutation — that asymmetry is the format working as intended rather than a\n * gap. When the container emitter rebuilds an untranslated body, it retains\n * representable non-program description fields and writes zero-length program\n * slots.\n *\n * So this does not translate anything. It reshapes the one translation already\n * performed into the body-set contract, and marks every other body unsupported.\n *\n * @param {object} permutationGraph Validated permutation graph.\n * @param {object} wgsl Emitted WGSL set for the selected body.\n * @param {number} bodyIndex Selected permutation index.\n * @returns {object} Body set covering one translated body.\n */\nfunction selectedModeBodySet(permutationGraph, wgsl, bodyIndex)\n{\n const selectedBodyKey = permutationGraph.variants\n .find((variant) => variant.permutationIndex === bodyIndex)?.bodyKey\n ?? permutationGraph.variants[0]?.bodyKey\n ?? null;\n\n const shadersByPass = new Map();\n for (const shader of wgsl.shaders)\n {\n const passKey = `${shader.techniqueName}.pass${shader.passIndex}`;\n if (!shadersByPass.has(passKey)) shadersByPass.set(passKey, []);\n shadersByPass.get(passKey).push(shader);\n }\n\n const passUnits = [];\n const passes = [];\n for (const [ passKey, shaders ] of shadersByPass)\n {\n const transforms = (wgsl.resourceTransforms ?? [])\n .filter((transform) => transform.layoutKey === passKey);\n const unit = {\n key: `unit${passUnits.length}`,\n wgslSetVersion: wgsl.formatVersion,\n shaders,\n layouts: wgsl.layouts.filter((layout) => layout.key === passKey),\n ...(transforms.length ? { resourceTransforms: transforms } : {})\n };\n passUnits.push(unit);\n passes.push({ passKey, unitKey: unit.key });\n }\n\n const bodies = permutationGraph.bodies.map((body) => (body.key === selectedBodyKey\n ? {\n bodyKey: body.key,\n representativePermutationIndex: bodyIndex,\n status: \"translated\",\n error: null,\n passCount: passes.length,\n passes\n }\n : {\n bodyKey: body.key,\n representativePermutationIndex: permutationGraph.variants\n .find((variant) => variant.bodyKey === body.key)?.permutationIndex ?? 0,\n status: \"unsupported\",\n error: \"not translated in selected mode\",\n passCount: 0,\n passes: []\n }));\n\n return {\n bodyCount: bodies.length,\n translatedBodyCount: 1,\n passUnitCount: passUnits.length,\n passUnits,\n bodies\n };\n}\n\nfunction normalizeMode(value, allPermutations)\n{\n if (allPermutations !== undefined && typeof allPermutations !== \"boolean\")\n {\n throw new TypeError(\"Effect allPermutations compatibility option must be boolean\");\n }\n\n const mode = String(allPermutations === true ? \"all\" : value ?? \"selected\").trim();\n\n if (mode !== \"selected\" && mode !== \"all\")\n {\n throw new Error(\n `Effect package mode ${mode || \"<empty>\"} is not supported; `\n + \"supported modes are selected and all\"\n );\n }\n\n return mode;\n}\n\nfunction normalizeSource(value)\n{\n const source = String(value ?? \"memory\").trim();\n\n return source || \"memory\";\n}\n\nfunction normalizeOptionalString(value, name)\n{\n if (value === undefined || value === null)\n {\n return null;\n }\n\n const result = String(value).trim();\n\n if (!result)\n {\n throw new TypeError(`${name} must be a non-empty string or null`);\n }\n\n return result;\n}\n\nfunction normalizeSelection(value)\n{\n if (value === undefined || value === null)\n {\n return null;\n }\n\n if (!value || typeof value !== \"object\" || Array.isArray(value))\n {\n throw new TypeError(\"Effect stage selection must be an object\");\n }\n\n const techniqueName = String(value.techniqueName ?? \"\").trim();\n const passIndex = value.passIndex ?? null;\n const stageNames = value.stageNames ?? [];\n\n if (!techniqueName)\n {\n throw new TypeError(\"Effect stage selection requires techniqueName\");\n }\n\n if (passIndex !== null && (!Number.isSafeInteger(passIndex) || passIndex < 0))\n {\n throw new TypeError(\"Effect stage selection passIndex must be a non-negative integer or null\");\n }\n\n if (!Array.isArray(stageNames)\n || stageNames.some((stageName) => ![ \"vertex\", \"pixel\", \"compute\" ].includes(stageName)))\n {\n throw new TypeError(\"Effect stage selection supports only vertex, pixel, and compute stageNames\");\n }\n\n if (stageNames.length && passIndex === null)\n {\n throw new TypeError(\"Effect stageNames require an exact passIndex\");\n }\n\n return Object.freeze({\n techniqueName,\n passIndex,\n stageNames: Object.freeze([ ...new Set(stageNames) ])\n });\n}\n\nfunction normalizeSourceIdentity(value, source, input)\n{\n if (value !== undefined && value !== null\n && (!value || typeof value !== \"object\" || Array.isArray(value)))\n {\n throw new TypeError(\"Effect sourceIdentity must be an object\");\n }\n\n const bytes = input instanceof Uint8Array\n ? input\n : input instanceof ArrayBuffer\n ? new Uint8Array(input)\n : ArrayBuffer.isView(input)\n ? new Uint8Array(input.buffer, input.byteOffset, input.byteLength)\n : null;\n\n if (!bytes)\n {\n throw new TypeError(\"Effect input must be Uint8Array, ArrayBuffer, or ArrayBufferView bytes\");\n }\n\n const sha256 = sha256Bytes(bytes);\n if (value?.sha256 !== undefined && value?.sha256 !== null\n && value.sha256 !== sha256)\n {\n throw new Error(\n \"Effect sourceIdentity.sha256 does not match the exact effect input bytes\"\n );\n }\n\n return Object.freeze({\n logicalPath: value?.logicalPath ?? source,\n game: value?.game ?? null,\n client: value?.client ?? null,\n build: value?.build === undefined || value?.build === null ? null : String(value.build),\n byteLength: bytes.byteLength,\n md5: value?.md5 ?? null,\n sha256\n });\n}\n"],"names":["buildEffectPackage","input","options","mode","normalizeMode","allPermutations","source","normalizeSource","outputPath","normalizeOptionalString","sourceIdentity","normalizeSourceIdentity","permutation","normalizeEffectPermutation","selection","normalizeSelection","resolved","readEffectAnalysis","effectRes","m_version","Error","validateResolvedPermutation","selectedOptions","analysis","buildEffectAnalysis","decodeBytecode","decodeInstructions","bytecodeByKey","stageBytecodeByKey","selectedStages","selectEffectStages","stages","programsByKey","Map","programForKey","key","has","get","bytecode","bytes","length","program","lowerDxbcToIr","set","effectProfileContext","isParticleClearEffectCandidate","effectDescription","preflightParticleClearEffectProfile","irEntries","map","stage","passKey","techniqueName","passIndex","ir","semanticBindings","find","candidate","stageName","bindings","effectProfileProof","particleClearEffectProofFor","programsByPass","entry","push","resourceTransformPlans","Array","from","entries","buildResourceTransformPlan","layoutKey","plans","proof","resourceTransformPlan","buildWgslBindingPlan","bindingPolicy","shaderEntries","shader","buildWgsl","bindingPlan","wgsl","buildWgslSet","wgslSelection","buildWgslSelectionMetadata","permutationGraph","buildEffectPermutationGraph","sourceComplete","backendBodySet","buildEffectBackendBodySet","completeness","Object","freeze","packageValid","backendComplete","runtimeComplete","info","format","formatVersion","EFFECT_INFO_VERSION","packageKind","sourcePath","targetBackend","WEBGPU_BACKEND_NAME","backendPackage","FORMAT_WEBGPU_PACKAGE_NAME","backendPackageVersion","FORMAT_WEBGPU_PACKAGE_VERSION","translator","DXBC_WGSL_TRANSLATOR_NAME","translatorVersion","DXBC_WGSL_TRANSLATOR_VERSION","chunk","EFFECT_PERMUTATION_GRAPH_CHUNK","EFFECT_PERMUTATION_GRAPH_FORMAT","EFFECT_PERMUTATION_GRAPH_VERSION","sha256","sha256Utf8","JSON","stringify","permutationCount","variants","uniqueBodyCount","bodies","sourceBodyCoverage","backendBodyCoverage","coverage","EFFECT_BACKEND_BODY_SET_CHUNK","EFFECT_BACKEND_BODY_SET_FORMAT","EFFECT_BACKEND_BODY_SET_VERSION","bodyCount","translatedBodyCount","passUnitCount","bodyMode","stageCount","selectedStageCount","shaderCount","shaders","layoutCount","layouts","metadata","effectName","bodyIndex","emittedBodySet","selectedModeBodySet","container","buildCarbonEffectContainer","compilerVersion","m_compilerVersionBytes","inspection","inspectWithValues","emit","qualification","ok","level","validator","backendBodyCount","backendTranslatedBodyCount","backendPassUnitCount","nativeComparison","selectedBodyKey","variant","permutationIndex","bodyKey","shadersByPass","passUnits","passes","transforms","resourceTransforms","filter","transform","unit","wgslSetVersion","layout","unitKey","body","representativePermutationIndex","status","error","passCount","value","undefined","TypeError","String","trim","name","result","isArray","stageNames","Number","isSafeInteger","some","includes","Set","Uint8Array","ArrayBuffer","isView","buffer","byteOffset","byteLength","sha256Bytes","logicalPath","game","client","build","md5"],"mappings":";;;;;;;;;;;;;;;AAyCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAkBA,CAACC,KAAK,EAAEC,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wE,CAAC;AACjG,EAAA;AAEA,EAAA,MAAMlE,MAAM,GAAGoF,WAAW,CAAChK,KAAK,CAAC;AACjC,EAAA,IAAI4I,KAAK,EAAEhE,MAAM,KAAKiE,SAAS,IAAID,KAAK,EAAEhE,MAAM,KAAK,IAAI,IAClDgE,KAAK,CAAChE,MAAM,KAAKA,MAAM,EAC9B;AACI,IAAA,MAAM,IAAI/F,KAAK,CACX,0EACJ,CAAC;AACL,EAAA;EAEA,OAAOsE,MAAM,CAACC,MAAM,CAAC;AACjB6G,IAAAA,WAAW,EAAErB,KAAK,EAAEqB,WAAW,IAAIlM,MAAM;AACzCmM,IAAAA,IAAI,EAAEtB,KAAK,EAAEsB,IAAI,IAAI,IAAI;AACzBC,IAAAA,MAAM,EAAEvB,KAAK,EAAEuB,MAAM,IAAI,IAAI;IAC7BC,KAAK,EAAExB,KAAK,EAAEwB,KAAK,KAAKvB,SAAS,IAAID,KAAK,EAAEwB,KAAK,KAAK,IAAI,GAAG,IAAI,GAAGrB,MAAM,CAACH,KAAK,CAACwB,KAAK,CAAC;IACvFL,UAAU,EAAE/J,KAAK,CAAC+J,UAAU;AAC5BM,IAAAA,GAAG,EAAEzB,KAAK,EAAEyB,GAAG,IAAI,IAAI;AACvBzF,IAAAA;AACJ,GAAC,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"packageEffect.js","sources":["../../../../../src/formats/webgpu/core/packageEffect.js"],"sourcesContent":["import { readEffectAnalysis } from \"./effectAnalysis.js\";\r\nimport { buildEffectAnalysis, inspectWithValues } from \"./helpers.js\";\r\nimport { buildCarbonEffectContainer } from \"./buildCarbonEffectContainer.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 {\r\n buildEffectPermutationGraph,\r\n EFFECT_PERMUTATION_GRAPH_FORMAT,\r\n EFFECT_PERMUTATION_GRAPH_VERSION\r\n} from \"../../../format/effect/effectPermutationGraph.js\";\r\nimport {\r\n buildEffectBackendBodySet,\r\n EFFECT_BACKEND_BODY_SET_FORMAT,\r\n EFFECT_BACKEND_BODY_SET_VERSION\r\n} from \"./effectBackendBodySet.js\";\r\nimport {\r\n DXBC_WGSL_TRANSLATOR_NAME,\r\n DXBC_WGSL_TRANSLATOR_VERSION,\r\n EFFECT_INFO_VERSION,\r\n FORMAT_WEBGPU_PACKAGE_NAME,\r\n FORMAT_WEBGPU_PACKAGE_VERSION,\r\n WEBGPU_BACKEND_NAME\r\n} from \"./packageMetadata.js\";\r\nimport { sha256Bytes, sha256Utf8 } from \"../../../format/effect/sha256.js\";\r\nimport {\r\n isParticleClearEffectCandidate,\r\n particleClearEffectProofFor,\r\n preflightParticleClearEffectProfile\r\n} from \"./wgsl/lowerParticleClearComputePrograms.js\";\r\nimport {\r\n buildWgslSelectionMetadata,\r\n normalizeEffectPermutation,\r\n selectEffectStages,\r\n validateResolvedPermutation\r\n} from \"./packageEffectSelection.js\";\r\n\r\n/**\r\n * Build one structurally valid Carbon WebGPU package from compiled Tr2 effect bytes.\r\n *\r\n * The version-15 build result retains every unique body's portable source\r\n * reflection as in-memory evidence while the emitted Carbon wire stores WGSL\r\n * or empty program slots plus representable non-program fields. Filesystem\r\n * concerns remain in callers.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.\r\n * @param {object} [options] Source, body-mode, permutation, and stage-selection policy.\r\n * @returns {object} Package bytes plus inspection and provenance documents.\r\n */\r\nexport function buildEffectPackage(input, options = {})\r\n{\r\n const mode = normalizeMode(options.mode, options.allPermutations);\r\n const source = normalizeSource(options.source);\r\n const outputPath = normalizeOptionalString(options.outputPath, \"Effect outputPath\");\r\n const sourceIdentity = normalizeSourceIdentity(\r\n options.sourceIdentity,\r\n source,\r\n input\r\n );\r\n const permutation = normalizeEffectPermutation(options.permutation);\r\n const selection = normalizeSelection(options.selection);\r\n const resolved = readEffectAnalysis(input, { source, permutation });\r\n\r\n // One INFO version means one contract, and that contract requires complete\r\n // source reflection, which only version-15 input can supply.\r\n if (resolved.effectRes?.m_version !== 15)\r\n {\r\n throw new Error(\r\n \"Effect package requires a version-15 compiled effect, got version \"\r\n + (resolved.effectRes?.m_version ?? \"unknown\")\r\n );\r\n }\r\n\r\n validateResolvedPermutation(permutation, resolved.selection?.selectedOptions ?? []);\r\n\r\n const analysis = buildEffectAnalysis(resolved, {\r\n source,\r\n decodeBytecode: false,\r\n decodeInstructions: false\r\n });\r\n const bytecodeByKey = resolved.stageBytecodeByKey;\r\n const selectedStages = selectEffectStages(analysis.stages, selection);\r\n const programsByKey = new Map();\r\n const programForKey = (key) =>\r\n {\r\n if (programsByKey.has(key)) return programsByKey.get(key);\r\n const bytecode = bytecodeByKey.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 const program = lowerDxbcToIr(\r\n bytecode,\r\n { source: `${source}#${key}` }\r\n );\r\n programsByKey.set(key, program);\r\n return program;\r\n };\r\n let effectProfileContext = null;\r\n if (isParticleClearEffectCandidate(resolved.effectDescription))\r\n {\r\n programForKey(\"Main.pass0.compute\");\r\n programForKey(\"Main.pass1.compute\");\r\n effectProfileContext = preflightParticleClearEffectProfile(\r\n resolved.effectDescription,\r\n programsByKey\r\n );\r\n }\r\n const irEntries = selectedStages.map((stage) => ({\r\n key: stage.key,\r\n passKey: `${stage.techniqueName}.pass${stage.passIndex}`,\r\n ir: programForKey(stage.key),\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 const programsByPass = new Map();\r\n\r\n for (const entry of irEntries)\r\n {\r\n if (!programsByPass.has(entry.passKey))\r\n {\r\n programsByPass.set(entry.passKey, []);\r\n }\r\n\r\n programsByPass.get(entry.passKey).push(entry);\r\n }\r\n\r\n const resourceTransformPlans = new Map(Array.from(programsByPass, ([ key, entries ]) => [\r\n key,\r\n buildResourceTransformPlan(\r\n entries.map((entry) => ({\r\n ir: entry.ir,\r\n semanticBindings: entry.semanticBindings\r\n })),\r\n { layoutKey: key }\r\n )\r\n ]));\r\n const plans = new Map(Array.from(programsByPass, ([ key, entries ]) =>\r\n {\r\n const proof = entries.find((entry) => entry.effectProfileProof)\r\n ?.effectProfileProof ?? null;\r\n const resourceTransformPlan = resourceTransformPlans.get(key);\r\n return [\r\n key,\r\n buildWgslBindingPlan(\r\n entries.map((entry) => entry.ir),\r\n {\r\n ...(options.bindingPolicy ?? {}),\r\n ...(proof ? { effectProfileProof: proof } : {}),\r\n ...(resourceTransformPlan ? { resourceTransformPlan } : {})\r\n }\r\n )\r\n ];\r\n }));\r\n const shaderEntries = irEntries.map((entry) => ({\r\n key: entry.key,\r\n shader: buildWgsl(entry.ir, {\r\n bindingPlan: plans.get(entry.passKey),\r\n ...(resourceTransformPlans.get(entry.passKey)\r\n ? { resourceTransformPlan: resourceTransformPlans.get(entry.passKey) }\r\n : {}),\r\n ...(entry.effectProfileProof\r\n ? { effectProfileProof: entry.effectProfileProof }\r\n : {})\r\n })\r\n }));\r\n const wgsl = buildWgslSet(shaderEntries);\r\n const wgslSelection = buildWgslSelectionMetadata(selection, selectedStages);\r\n const permutationGraph = buildEffectPermutationGraph(resolved.effectRes);\r\n // The source is complete when it is a version-15 container. This used to be\r\n // read off a built reflection document, which made the document look load\r\n // bearing when it was only ever a consequence of the same version check.\r\n const sourceComplete = resolved.effectRes.m_version === 15;\r\n if (mode === \"all\" && !sourceComplete)\r\n {\r\n throw new Error(\r\n \"Effect package mode all requires a complete version-15 source\"\r\n );\r\n }\r\n\r\n const backendBodySet = mode === \"all\"\r\n ? buildEffectBackendBodySet(resolved.effectRes, permutationGraph, {\r\n source,\r\n selection,\r\n bindingPolicy: options.bindingPolicy\r\n })\r\n : null;\r\n const completeness = Object.freeze({\r\n packageValid: true,\r\n sourceComplete,\r\n backendComplete: false,\r\n runtimeComplete: false\r\n });\r\n const info = {\r\n format: \"CARBON_WEBGPU\",\r\n formatVersion: EFFECT_INFO_VERSION,\r\n packageKind: \"tr2-effect-webgpu\",\r\n sourcePath: source,\r\n outputPath,\r\n sourceIdentity,\r\n targetBackend: WEBGPU_BACKEND_NAME,\r\n backendPackage: FORMAT_WEBGPU_PACKAGE_NAME,\r\n backendPackageVersion: FORMAT_WEBGPU_PACKAGE_VERSION,\r\n translator: DXBC_WGSL_TRANSLATOR_NAME,\r\n translatorVersion: DXBC_WGSL_TRANSLATOR_VERSION,\r\n permutationGraph: Object.freeze({\r\n format: EFFECT_PERMUTATION_GRAPH_FORMAT,\r\n formatVersion: EFFECT_PERMUTATION_GRAPH_VERSION,\r\n sha256: sha256Utf8(`${JSON.stringify(permutationGraph)}\\n`),\r\n permutationCount: permutationGraph.variants.length,\r\n uniqueBodyCount: permutationGraph.bodies.length\r\n }),\r\n ...(sourceComplete\r\n ? {\r\n sourceBodyCoverage: \"all-unique\",\r\n backendBodyCoverage: backendBodySet\r\n ? backendBodySet.coverage.bodies\r\n : \"selected\"\r\n }\r\n : {}),\r\n ...(backendBodySet\r\n ? {\r\n backendBodySet: Object.freeze({\r\n format: EFFECT_BACKEND_BODY_SET_FORMAT,\r\n formatVersion: EFFECT_BACKEND_BODY_SET_VERSION,\r\n sha256: sha256Utf8(`${JSON.stringify(backendBodySet)}\\n`),\r\n bodyCount: backendBodySet.bodyCount,\r\n translatedBodyCount: backendBodySet.translatedBodyCount,\r\n passUnitCount: backendBodySet.passUnitCount\r\n })\r\n }\r\n : {}),\r\n bodyMode: mode,\r\n completeness,\r\n stageCount: analysis.stages.length,\r\n selectedStageCount: selectedStages.length,\r\n shaderCount: wgsl.shaders.length,\r\n layoutCount: wgsl.layouts.length\r\n };\r\n const metadata = {\r\n effectName: analysis.effectName,\r\n sourcePath: source,\r\n bodyMode: mode,\r\n bodyIndex: analysis.bodyIndex,\r\n selectedOptions: analysis.selectedOptions,\r\n ...(wgslSelection ? { wgslSelection } : {})\r\n };\r\n // The switchover. Former stored chunks are now compatibility views over the\r\n // Carbon records: the permutation graph comes from the header and offset\r\n // table, and a translated pass comes from shaderData plus its trailing\r\n // block. The description tree retains only representable non-program\r\n // reflection; full portable source reflection remains in the rich\r\n // in-memory return value below.\r\n //\r\n // The wire no longer stores cross-chunk digests. The rich return value keeps\r\n // hashes as build evidence; they are not records in the emitted container.\r\n const emittedBodySet = backendBodySet\r\n ?? selectedModeBodySet(permutationGraph, wgsl, analysis.bodyIndex);\r\n const container = buildCarbonEffectContainer(\r\n resolved.effectRes,\r\n permutationGraph,\r\n emittedBodySet,\r\n { compilerVersion: resolved.effectRes.m_compilerVersionBytes }\r\n );\r\n const bytes = container.bytes;\r\n const inspection = inspectWithValues(bytes, {\r\n source,\r\n emit: \"json\"\r\n });\r\n const qualification = Object.freeze({\r\n ok: true,\r\n level: \"structural\",\r\n validator: \"carbon-webgpu-structural\",\r\n mode,\r\n ...completeness,\r\n selectedStageCount: selectedStages.length,\r\n shaderCount: wgsl.shaders.length,\r\n layoutCount: wgsl.layouts.length,\r\n ...(backendBodySet\r\n ? {\r\n backendBodyCount: backendBodySet.bodyCount,\r\n backendTranslatedBodyCount: backendBodySet.translatedBodyCount,\r\n backendPassUnitCount: backendBodySet.passUnitCount\r\n }\r\n : {}),\r\n nativeComparison: false\r\n });\r\n\r\n return Object.freeze({\r\n bytes,\r\n info: Object.freeze(info),\r\n metadata: Object.freeze(metadata),\r\n permutationGraph,\r\n analysis,\r\n wgsl,\r\n backendBodySet,\r\n inspection: Object.freeze(inspection),\r\n qualification\r\n });\r\n}\r\n\r\n/**\r\n * Wraps a selected-mode translation as the body set the container emitter takes.\r\n *\r\n * `mode: \"all\"` builds a real body set covering every unique body. `mode:\r\n * \"selected\"` translates exactly one, and the container still carries every\r\n * permutation — that asymmetry is the format working as intended rather than a\r\n * gap. When the container emitter rebuilds an untranslated body, it retains\r\n * representable non-program description fields and writes zero-length program\r\n * slots.\r\n *\r\n * So this does not translate anything. It reshapes the one translation already\r\n * performed into the body-set contract, and marks every other body unsupported.\r\n *\r\n * @param {object} permutationGraph Validated permutation graph.\r\n * @param {object} wgsl Emitted WGSL set for the selected body.\r\n * @param {number} bodyIndex Selected permutation index.\r\n * @returns {object} Body set covering one translated body.\r\n */\r\nfunction selectedModeBodySet(permutationGraph, wgsl, bodyIndex)\r\n{\r\n const selectedBodyKey = permutationGraph.variants\r\n .find((variant) => variant.permutationIndex === bodyIndex)?.bodyKey\r\n ?? permutationGraph.variants[0]?.bodyKey\r\n ?? null;\r\n\r\n const shadersByPass = new Map();\r\n for (const shader of wgsl.shaders)\r\n {\r\n const passKey = `${shader.techniqueName}.pass${shader.passIndex}`;\r\n if (!shadersByPass.has(passKey)) shadersByPass.set(passKey, []);\r\n shadersByPass.get(passKey).push(shader);\r\n }\r\n\r\n const passUnits = [];\r\n const passes = [];\r\n for (const [ passKey, shaders ] of shadersByPass)\r\n {\r\n const transforms = (wgsl.resourceTransforms ?? [])\r\n .filter((transform) => transform.layoutKey === passKey);\r\n const unit = {\r\n key: `unit${passUnits.length}`,\r\n wgslSetVersion: wgsl.formatVersion,\r\n shaders,\r\n layouts: wgsl.layouts.filter((layout) => layout.key === passKey),\r\n ...(transforms.length ? { resourceTransforms: transforms } : {})\r\n };\r\n passUnits.push(unit);\r\n passes.push({ passKey, unitKey: unit.key });\r\n }\r\n\r\n const bodies = permutationGraph.bodies.map((body) => (body.key === selectedBodyKey\r\n ? {\r\n bodyKey: body.key,\r\n representativePermutationIndex: bodyIndex,\r\n status: \"translated\",\r\n error: null,\r\n passCount: passes.length,\r\n passes\r\n }\r\n : {\r\n bodyKey: body.key,\r\n representativePermutationIndex: permutationGraph.variants\r\n .find((variant) => variant.bodyKey === body.key)?.permutationIndex ?? 0,\r\n status: \"unsupported\",\r\n error: \"not translated in selected mode\",\r\n passCount: 0,\r\n passes: []\r\n }));\r\n\r\n return {\r\n bodyCount: bodies.length,\r\n translatedBodyCount: 1,\r\n passUnitCount: passUnits.length,\r\n passUnits,\r\n bodies\r\n };\r\n}\r\n\r\nfunction normalizeMode(value, allPermutations)\r\n{\r\n if (allPermutations !== undefined && typeof allPermutations !== \"boolean\")\r\n {\r\n throw new TypeError(\"Effect allPermutations compatibility option must be boolean\");\r\n }\r\n\r\n const mode = String(allPermutations === true ? \"all\" : value ?? \"selected\").trim();\r\n\r\n if (mode !== \"selected\" && mode !== \"all\")\r\n {\r\n throw new Error(\r\n `Effect package mode ${mode || \"<empty>\"} is not supported; `\r\n + \"supported modes are selected and all\"\r\n );\r\n }\r\n\r\n return mode;\r\n}\r\n\r\nfunction normalizeSource(value)\r\n{\r\n const source = String(value ?? \"memory\").trim();\r\n\r\n return source || \"memory\";\r\n}\r\n\r\nfunction normalizeOptionalString(value, name)\r\n{\r\n if (value === undefined || value === null)\r\n {\r\n return null;\r\n }\r\n\r\n const result = String(value).trim();\r\n\r\n if (!result)\r\n {\r\n throw new TypeError(`${name} must be a non-empty string or null`);\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction normalizeSelection(value)\r\n{\r\n if (value === undefined || value === null)\r\n {\r\n return null;\r\n }\r\n\r\n if (!value || typeof value !== \"object\" || Array.isArray(value))\r\n {\r\n throw new TypeError(\"Effect stage selection must be an object\");\r\n }\r\n\r\n const techniqueName = String(value.techniqueName ?? \"\").trim();\r\n const passIndex = value.passIndex ?? null;\r\n const stageNames = value.stageNames ?? [];\r\n\r\n if (!techniqueName)\r\n {\r\n throw new TypeError(\"Effect stage selection requires techniqueName\");\r\n }\r\n\r\n if (passIndex !== null && (!Number.isSafeInteger(passIndex) || passIndex < 0))\r\n {\r\n throw new TypeError(\"Effect stage selection passIndex must be a non-negative integer or null\");\r\n }\r\n\r\n if (!Array.isArray(stageNames)\r\n || stageNames.some((stageName) => ![ \"vertex\", \"pixel\", \"compute\" ].includes(stageName)))\r\n {\r\n throw new TypeError(\"Effect stage selection supports only vertex, pixel, and compute stageNames\");\r\n }\r\n\r\n if (stageNames.length && passIndex === null)\r\n {\r\n throw new TypeError(\"Effect stageNames require an exact passIndex\");\r\n }\r\n\r\n return Object.freeze({\r\n techniqueName,\r\n passIndex,\r\n stageNames: Object.freeze([ ...new Set(stageNames) ])\r\n });\r\n}\r\n\r\nfunction normalizeSourceIdentity(value, source, input)\r\n{\r\n if (value !== undefined && value !== null\r\n && (!value || typeof value !== \"object\" || Array.isArray(value)))\r\n {\r\n throw new TypeError(\"Effect sourceIdentity must be an object\");\r\n }\r\n\r\n const bytes = input instanceof Uint8Array\r\n ? input\r\n : input instanceof ArrayBuffer\r\n ? new Uint8Array(input)\r\n : ArrayBuffer.isView(input)\r\n ? new Uint8Array(input.buffer, input.byteOffset, input.byteLength)\r\n : null;\r\n\r\n if (!bytes)\r\n {\r\n throw new TypeError(\"Effect input must be Uint8Array, ArrayBuffer, or ArrayBufferView bytes\");\r\n }\r\n\r\n const sha256 = sha256Bytes(bytes);\r\n if (value?.sha256 !== undefined && value?.sha256 !== null\r\n && value.sha256 !== sha256)\r\n {\r\n throw new Error(\r\n \"Effect sourceIdentity.sha256 does not match the exact effect input bytes\"\r\n );\r\n }\r\n\r\n return Object.freeze({\r\n logicalPath: value?.logicalPath ?? source,\r\n game: value?.game ?? null,\r\n client: value?.client ?? null,\r\n build: value?.build === undefined || value?.build === null ? null : String(value.build),\r\n byteLength: bytes.byteLength,\r\n md5: value?.md5 ?? null,\r\n sha256\r\n });\r\n}\r\n"],"names":["buildEffectPackage","input","options","mode","normalizeMode","allPermutations","source","normalizeSource","outputPath","normalizeOptionalString","sourceIdentity","normalizeSourceIdentity","permutation","normalizeEffectPermutation","selection","normalizeSelection","resolved","readEffectAnalysis","effectRes","m_version","Error","validateResolvedPermutation","selectedOptions","analysis","buildEffectAnalysis","decodeBytecode","decodeInstructions","bytecodeByKey","stageBytecodeByKey","selectedStages","selectEffectStages","stages","programsByKey","Map","programForKey","key","has","get","bytecode","bytes","length","program","lowerDxbcToIr","set","effectProfileContext","isParticleClearEffectCandidate","effectDescription","preflightParticleClearEffectProfile","irEntries","map","stage","passKey","techniqueName","passIndex","ir","semanticBindings","find","candidate","stageName","bindings","effectProfileProof","particleClearEffectProofFor","programsByPass","entry","push","resourceTransformPlans","Array","from","entries","buildResourceTransformPlan","layoutKey","plans","proof","resourceTransformPlan","buildWgslBindingPlan","bindingPolicy","shaderEntries","shader","buildWgsl","bindingPlan","wgsl","buildWgslSet","wgslSelection","buildWgslSelectionMetadata","permutationGraph","buildEffectPermutationGraph","sourceComplete","backendBodySet","buildEffectBackendBodySet","completeness","Object","freeze","packageValid","backendComplete","runtimeComplete","info","format","formatVersion","EFFECT_INFO_VERSION","packageKind","sourcePath","targetBackend","WEBGPU_BACKEND_NAME","backendPackage","FORMAT_WEBGPU_PACKAGE_NAME","backendPackageVersion","FORMAT_WEBGPU_PACKAGE_VERSION","translator","DXBC_WGSL_TRANSLATOR_NAME","translatorVersion","DXBC_WGSL_TRANSLATOR_VERSION","EFFECT_PERMUTATION_GRAPH_FORMAT","EFFECT_PERMUTATION_GRAPH_VERSION","sha256","sha256Utf8","JSON","stringify","permutationCount","variants","uniqueBodyCount","bodies","sourceBodyCoverage","backendBodyCoverage","coverage","EFFECT_BACKEND_BODY_SET_FORMAT","EFFECT_BACKEND_BODY_SET_VERSION","bodyCount","translatedBodyCount","passUnitCount","bodyMode","stageCount","selectedStageCount","shaderCount","shaders","layoutCount","layouts","metadata","effectName","bodyIndex","emittedBodySet","selectedModeBodySet","container","buildCarbonEffectContainer","compilerVersion","m_compilerVersionBytes","inspection","inspectWithValues","emit","qualification","ok","level","validator","backendBodyCount","backendTranslatedBodyCount","backendPassUnitCount","nativeComparison","selectedBodyKey","variant","permutationIndex","bodyKey","shadersByPass","passUnits","passes","transforms","resourceTransforms","filter","transform","unit","wgslSetVersion","layout","unitKey","body","representativePermutationIndex","status","error","passCount","value","undefined","TypeError","String","trim","name","result","isArray","stageNames","Number","isSafeInteger","some","includes","Set","Uint8Array","ArrayBuffer","isView","buffer","byteOffset","byteLength","sha256Bytes","logicalPath","game","client","build","md5"],"mappings":";;;;;;;;;;;;;;;AAuCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAkBA,CAACC,KAAK,EAAEC,OAAO,GAAG,EAAE,EACtD;EACI,MAAMC,IAAI,GAAGC,aAAa,CAACF,OAAO,CAACC,IAAI,EAAED,OAAO,CAACG,eAAe,CAAC;AACjE,EAAA,MAAMC,MAAM,GAAGC,eAAe,CAACL,OAAO,CAACI,MAAM,CAAC;EAC9C,MAAME,UAAU,GAAGC,uBAAuB,CAACP,OAAO,CAACM,UAAU,EAAE,mBAAmB,CAAC;EACnF,MAAME,cAAc,GAAGC,uBAAuB,CAC1CT,OAAO,CAACQ,cAAc,EACtBJ,MAAM,EACNL,KACJ,CAAC;AACD,EAAA,MAAMW,WAAW,GAAGC,0BAA0B,CAACX,OAAO,CAACU,WAAW,CAAC;AACnE,EAAA,MAAME,SAAS,GAAGC,kBAAkB,CAACb,OAAO,CAACY,SAAS,CAAC;AACvD,EAAA,MAAME,QAAQ,GAAGC,kBAAkB,CAAChB,KAAK,EAAE;IAAEK,MAAM;AAAEM,IAAAA;AAAY,GAAC,CAAC;;AAEnE;AACA;AACA,EAAA,IAAII,QAAQ,CAACE,SAAS,EAAEC,SAAS,KAAK,EAAE,EACxC;AACI,IAAA,MAAM,IAAIC,KAAK,CACX,oEAAoE,IACjEJ,QAAQ,CAACE,SAAS,EAAEC,SAAS,IAAI,SAAS,CACjD,CAAC;AACL,EAAA;EAEAE,2BAA2B,CAACT,WAAW,EAAEI,QAAQ,CAACF,SAAS,EAAEQ,eAAe,IAAI,EAAE,CA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AAC7L,KAAK,CAAC,GACrB8L,WAAW,CAACC,MAAM,CAAC/L,KAAK,CAAC,GACrB,IAAI6L,UAAU,CAAC7L,KAAK,CAACgM,MAAM,EAAEhM,KAAK,CAACiM,UAAU,EAAEjM,KAAK,CAACkM,UAAU,CAAC,GAChE,IAAI;EAElB,IAAI,CAAC5J,KAAK,EACV;AACI,IAAA,MAAM,IAAI2I,SAAS,CAAC,wEAAwE,CAAC;AACjG,EAAA;AAEA,EAAA,MAAMjE,MAAM,GAAGmF,WAAW,CAAC7J,KAAK,CAAC;AACjC,EAAA,IAAIyI,KAAK,EAAE/D,MAAM,KAAKgE,SAAS,IAAID,KAAK,EAAE/D,MAAM,KAAK,IAAI,IAClD+D,KAAK,CAAC/D,MAAM,KAAKA,MAAM,EAC9B;AACI,IAAA,MAAM,IAAI7F,KAAK,CACX,0EACJ,CAAC;AACL,EAAA;EAEA,OAAOsE,MAAM,CAACC,MAAM,CAAC;AACjB0G,IAAAA,WAAW,EAAErB,KAAK,EAAEqB,WAAW,IAAI/L,MAAM;AACzCgM,IAAAA,IAAI,EAAEtB,KAAK,EAAEsB,IAAI,IAAI,IAAI;AACzBC,IAAAA,MAAM,EAAEvB,KAAK,EAAEuB,MAAM,IAAI,IAAI;IAC7BC,KAAK,EAAExB,KAAK,EAAEwB,KAAK,KAAKvB,SAAS,IAAID,KAAK,EAAEwB,KAAK,KAAK,IAAI,GAAG,IAAI,GAAGrB,MAAM,CAACH,KAAK,CAACwB,KAAK,CAAC;IACvFL,UAAU,EAAE5J,KAAK,CAAC4J,UAAU;AAC5BM,IAAAA,GAAG,EAAEzB,KAAK,EAAEyB,GAAG,IAAI,IAAI;AACvBxF,IAAAA;AACJ,GAAC,CAAC;AACN;;;;"}
@@ -63,10 +63,17 @@ Equivalent read surfaces are derived from the one Carbon record tree:
63
63
  | `WGSL` | Program text and layouts read from stage records and backend blocks |
64
64
  | `WGSB` | A body-set view derived across distinct stored bodies |
65
65
 
66
- `Read(..., { emit: "json" })` returns these compatibility views as plain data.
67
- They are not independent stored documents and carry no cross-document digests.
68
- `Read(..., { emit: "raw" })` returns the internal `CarbonWebgpuContainer` reader.
69
- There is no `chunks` array and no generic `Build(chunks)` API.
66
+ `Read` returns these derived views as plain data. They are not independent stored
67
+ documents and carry no cross-document digests. There is no `chunks` array and no
68
+ generic `Build(chunks)` API.
69
+
70
+ There is exactly one emit, as there is for WebGL, and the document it returns is
71
+ complete: alongside the views above it carries `permutationGraph` and
72
+ `backendBodySet`, the latter being every translated body joined to its shared
73
+ translation units. A second `raw` emit used to hand back the internal
74
+ `CarbonWebgpuContainer` because the former chunk package could not express the
75
+ body set in JSON. It is removed. The container is internal, and consumers read
76
+ the document rather than binding to a reader object.
70
77
 
71
78
  ## Building
72
79
 
@@ -75,7 +75,7 @@ Callers establish identity through the resource path that supplied the bytes.
75
75
 
76
76
  | Option | Meaning |
77
77
  | --- | --- |
78
- | `emit` | `"json"` by default or `"raw"` for the internal container reader. |
78
+ | `emit` | `"json"`, the only accepted value. Any other value is a `TypeError`. |
79
79
  | `source` | Caller-owned diagnostic label; it is never opened. |
80
80
  | `decodeInstructions` | Includes decoded instruction and IR detail during analysis. |
81
81
  | `permutation` | Exact `NAME=VALUE` assertions for `AnalyzeEffect` and `BuildEffect`; ignored by current `Read` and `Inspect`. |
@@ -85,8 +85,9 @@ Callers establish identity through the resource path that supplied the bytes.
85
85
  Class registrations are validated and stored for forward compatibility.
86
86
  Current JSON reads return plain data rather than hydrated package classes.
87
87
 
88
- Raw output is an internal reader over the same bytes. It is not a second wire
89
- format and should not be persisted.
88
+ There is one emit. The document it returns carries every view a consumer needs,
89
+ including `permutationGraph` and the complete `backendBodySet`, so there is no
90
+ second read mode to choose and no reader object to hold.
90
91
 
91
92
  ## Read result
92
93
 
@@ -174,9 +175,9 @@ coalescing uses version 3 and carries an explicit transform recipe.
174
175
 
175
176
  ## Static metadata
176
177
 
177
- The class exposes `OUTPUT_JSON`, `OUTPUT_RAW`, `CLASS_KEYS`, `type`,
178
- `mediaTypes`, `inputTypes`, `outputTypes`, `debugOutputTypes`,
179
- `implementationStatus`, `format`, `analysisFormat`, and `packageVersion`.
178
+ The class exposes `OUTPUT_JSON`, `CLASS_KEYS`, `type`, `mediaTypes`,
179
+ `inputTypes`, `outputTypes`, `implementationStatus`, `format`, `analysisFormat`,
180
+ and `packageVersion`. There is no `OUTPUT_RAW` and no `debugOutputTypes`.
180
181
 
181
182
  ## Errors
182
183
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carbonenginejs/runtime-resource",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "CarbonEngineJS resource lifecycle, cache, source, and object loading contracts.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -52,7 +52,7 @@
52
52
  "node": ">=18"
53
53
  },
54
54
  "dependencies": {
55
- "@carbonenginejs/runtime-utils": "^0.1.5",
55
+ "@carbonenginejs/runtime-utils": "^0.1.6",
56
56
  "meshoptimizer": "^1.2.0",
57
57
  "yaml": "^2.4.0"
58
58
  },