@carbonenginejs/runtime-resource 0.17.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js +16 -4
  2. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -1
  3. package/dist/format/carbonEffect/backendEngineId.js +1 -3
  4. package/dist/format/carbonEffect/backendEngineId.js.map +1 -1
  5. package/dist/format/carbonEffect/buildCarbonEffectContainer.js +11 -1
  6. package/dist/format/carbonEffect/buildCarbonEffectContainer.js.map +1 -1
  7. package/dist/format/carbonEffect/carbonEffectBackendBlock.js +38 -1
  8. package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
  9. package/dist/format/carbonEffect/carbonEffectRecords.js +45 -1
  10. package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -1
  11. package/dist/format/carbonEffect/carbonEffectResourceTransform.js +120 -60
  12. package/dist/format/carbonEffect/carbonEffectResourceTransform.js.map +1 -1
  13. package/dist/format/effect/effectPermutationGraph.js +46 -29
  14. package/dist/format/effect/effectPermutationGraph.js.map +1 -1
  15. package/dist/format/index.js +1 -1
  16. package/dist/formats/dds/core/helpers.js +35 -6
  17. package/dist/formats/dds/core/helpers.js.map +1 -1
  18. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +53 -1
  19. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -1
  20. package/dist/formats/hlsl/core/detailMapFamily.js +1 -1
  21. package/dist/formats/hlsl/core/detailMapFamily.js.map +1 -1
  22. package/dist/formats/hlsl/core/localLightFamily.js +1 -1
  23. package/dist/formats/hlsl/core/localLightFamily.js.map +1 -1
  24. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js +10 -1
  25. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js.map +1 -1
  26. package/dist/formats/index.js +3 -0
  27. package/dist/formats/index.js.map +1 -1
  28. package/dist/formats/schemabound/CjsSchemaBoundFormat.js +236 -0
  29. package/dist/formats/schemabound/CjsSchemaBoundFormat.js.map +1 -0
  30. package/dist/formats/schemabound/core/schemaBoundErrors.js +9 -0
  31. package/dist/formats/schemabound/core/schemaBoundErrors.js.map +1 -0
  32. package/dist/formats/schemabound/core/schemaBoundValues.js +307 -0
  33. package/dist/formats/schemabound/core/schemaBoundValues.js.map +1 -0
  34. package/dist/formats/schemabound/index.js +2 -0
  35. package/dist/formats/schemabound/index.js.map +1 -0
  36. package/dist/formats/sqlite/CjsSqliteFormat.js +244 -0
  37. package/dist/formats/sqlite/CjsSqliteFormat.js.map +1 -0
  38. package/dist/formats/sqlite/core/sqlitePages.js +159 -0
  39. package/dist/formats/sqlite/core/sqlitePages.js.map +1 -0
  40. package/dist/formats/sqlite/core/sqliteRecords.js +174 -0
  41. package/dist/formats/sqlite/core/sqliteRecords.js.map +1 -0
  42. package/dist/formats/sqlite/core/sqliteSchema.js +100 -0
  43. package/dist/formats/sqlite/core/sqliteSchema.js.map +1 -0
  44. package/dist/formats/sqlite/index.js +2 -0
  45. package/dist/formats/sqlite/index.js.map +1 -0
  46. package/dist/formats/static/CjsStaticFormat.js +220 -0
  47. package/dist/formats/static/CjsStaticFormat.js.map +1 -0
  48. package/dist/formats/static/index.js +2 -0
  49. package/dist/formats/static/index.js.map +1 -0
  50. package/dist/formats/webgl/core/buildGlslEffectContainer.js +3 -1
  51. package/dist/formats/webgl/core/buildGlslEffectContainer.js.map +1 -1
  52. package/dist/formats/webgl/core/effectPackage.js +13 -5
  53. package/dist/formats/webgl/core/effectPackage.js.map +1 -1
  54. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +10 -2
  55. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
  56. package/dist/formats/webgl/core/glslBackendBlock.js +6 -5
  57. package/dist/formats/webgl/core/glslBackendBlock.js.map +1 -1
  58. package/dist/formats/webgl/core/glslBackendBodySet.js +0 -1
  59. package/dist/formats/webgl/core/glslBackendBodySet.js.map +1 -1
  60. package/dist/formats/webgpu/CjsWebgpuFormat.js +161 -163
  61. package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
  62. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +3 -1
  63. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -1
  64. package/dist/formats/webgpu/core/carbonWebgpu/containerViews.js +179 -131
  65. package/dist/formats/webgpu/core/carbonWebgpu/containerViews.js.map +1 -1
  66. package/dist/formats/webgpu/core/effectBackendBodySet.js +2 -3
  67. package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
  68. package/dist/formats/webgpu/core/helpers.js +111 -99
  69. package/dist/formats/webgpu/core/helpers.js.map +1 -1
  70. package/dist/formats/webgpu/core/packageEffect.js +44 -33
  71. package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
  72. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +9 -1
  73. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
  74. package/dist/resource/shader/reflection/Tr2EffectStageInput.js +14 -0
  75. package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
  76. package/docs/concepts/shader-resource-model.md +34 -1
  77. package/docs/formats/README.md +21 -0
  78. package/docs/formats/carbon-effect-container.md +54 -27
  79. package/docs/formats/schemabound.md +112 -0
  80. package/docs/formats/static.md +119 -0
  81. package/docs/formats/webgl/README.md +5 -3
  82. package/docs/formats/webgpu/README.md +2 -2
  83. package/docs/formats/webgpu/architecture.md +2 -2
  84. package/docs/formats/webgpu/formats/carbon-webgpu.md +24 -6
  85. package/docs/formats/webgpu/guides/effect-packaging.md +1 -2
  86. package/docs/formats/webgpu/reference/api.md +7 -6
  87. package/docs/formats/webgpu/reference/wgsl-compatibility.md +2 -2
  88. package/docs/reference/classes/formats.md +33 -0
  89. package/package.json +5 -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,CAAE,CAAC;AAG3G,SAASC,MAAMA,CAACC,KAAK,EAAEC,GAAG,EAC1B;EACI,OAAOZ,MAAM,CAACa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,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,MAAM,CAAC;AACxCC,EAAAA,IAAI,EAAEP,WAAW;AACjBQ,EAAAA,MAAM,EAAE,QAAQ;AAChBC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AW,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,28 +6,33 @@ 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
+ import { resolveWriteVersion } from '../../../format/carbonEffect/carbonEffectRecords.js';
13
14
  import { isParticleClearEffectCandidate, preflightParticleClearEffectProfile, particleClearEffectProofFor } from './wgsl/lowerParticleClearComputePrograms.js';
14
15
  import { normalizeEffectPermutation, validateResolvedPermutation, selectEffectStages, buildWgslSelectionMetadata } from './packageEffectSelection.js';
15
16
 
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.
17
+ /**
18
+ * Build one structurally valid Carbon WebGPU package from compiled Tr2 effect bytes.
19
+ *
20
+ * The version-15 build result retains every unique body's portable source
21
+ * reflection as in-memory evidence while the emitted Carbon wire stores WGSL
22
+ * or empty program slots plus representable non-program fields. Filesystem
23
+ * concerns remain in callers.
24
+ *
25
+ * @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.
26
+ * @param {object} [options] Source, body-mode, permutation, and stage-selection policy.
27
+ * @returns {object} Package bytes plus inspection and provenance documents.
27
28
  */
28
29
  function buildEffectPackage(input, options = {}) {
29
30
  const mode = normalizeMode(options.mode, options.allPermutations);
30
31
  const source = normalizeSource(options.source);
32
+ // Resolved once, up front, so an unwritable request fails before any
33
+ // translation work is done rather than at the final assembly step. The
34
+ // reported value is what was actually emitted, never the constant.
35
+ const containerVersion = resolveWriteVersion(options.version);
31
36
  const outputPath = normalizeOptionalString(options.outputPath, "Effect outputPath");
32
37
  const sourceIdentity = normalizeSourceIdentity(options.sourceIdentity, source, input);
33
38
  const permutation = normalizeEffectPermutation(options.permutation);
@@ -142,13 +147,18 @@ function buildEffectPackage(input, options = {}) {
142
147
  sourcePath: source,
143
148
  outputPath,
144
149
  sourceIdentity,
150
+ // The Carbon container version these bytes ARE, stated rather than
151
+ // implied. The writer emits 15 and only 15, while the reader accepts
152
+ // 8..15, so a consumer cannot infer what it was handed from what we can
153
+ // read - and a v15 reader elsewhere (ccpwgl's Tw2Shader, Carbon itself)
154
+ // needs to know this file is one it can parse before it tries.
155
+ containerVersion,
145
156
  targetBackend: WEBGPU_BACKEND_NAME,
146
157
  backendPackage: FORMAT_WEBGPU_PACKAGE_NAME,
147
158
  backendPackageVersion: FORMAT_WEBGPU_PACKAGE_VERSION,
148
159
  translator: DXBC_WGSL_TRANSLATOR_NAME,
149
160
  translatorVersion: DXBC_WGSL_TRANSLATOR_VERSION,
150
161
  permutationGraph: Object.freeze({
151
- chunk: EFFECT_PERMUTATION_GRAPH_CHUNK,
152
162
  format: EFFECT_PERMUTATION_GRAPH_FORMAT,
153
163
  formatVersion: EFFECT_PERMUTATION_GRAPH_VERSION,
154
164
  sha256: sha256Utf8(`${JSON.stringify(permutationGraph)}\n`),
@@ -161,7 +171,6 @@ function buildEffectPackage(input, options = {}) {
161
171
  } : {}),
162
172
  ...(backendBodySet ? {
163
173
  backendBodySet: Object.freeze({
164
- chunk: EFFECT_BACKEND_BODY_SET_CHUNK,
165
174
  format: EFFECT_BACKEND_BODY_SET_FORMAT,
166
175
  formatVersion: EFFECT_BACKEND_BODY_SET_VERSION,
167
176
  sha256: sha256Utf8(`${JSON.stringify(backendBodySet)}\n`),
@@ -179,6 +188,7 @@ function buildEffectPackage(input, options = {}) {
179
188
  };
180
189
  const metadata = {
181
190
  effectName: analysis.effectName,
191
+ containerVersion,
182
192
  sourcePath: source,
183
193
  bodyMode: mode,
184
194
  bodyIndex: analysis.bodyIndex,
@@ -198,7 +208,8 @@ function buildEffectPackage(input, options = {}) {
198
208
  // hashes as build evidence; they are not records in the emitted container.
199
209
  const emittedBodySet = backendBodySet ?? selectedModeBodySet(permutationGraph, wgsl, analysis.bodyIndex);
200
210
  const container = buildCarbonEffectContainer(resolved.effectRes, permutationGraph, emittedBodySet, {
201
- compilerVersion: resolved.effectRes.m_compilerVersionBytes
211
+ compilerVersion: resolved.effectRes.m_compilerVersionBytes,
212
+ version: containerVersion
202
213
  });
203
214
  const bytes = container.bytes;
204
215
  const inspection = inspectWithValues(bytes, {
@@ -234,23 +245,23 @@ function buildEffectPackage(input, options = {}) {
234
245
  });
235
246
  }
236
247
 
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.
248
+ /**
249
+ * Wraps a selected-mode translation as the body set the container emitter takes.
250
+ *
251
+ * `mode: "all"` builds a real body set covering every unique body. `mode:
252
+ * "selected"` translates exactly one, and the container still carries every
253
+ * permutation — that asymmetry is the format working as intended rather than a
254
+ * gap. When the container emitter rebuilds an untranslated body, it retains
255
+ * representable non-program description fields and writes zero-length program
256
+ * slots.
257
+ *
258
+ * So this does not translate anything. It reshapes the one translation already
259
+ * performed into the body-set contract, and marks every other body unsupported.
260
+ *
261
+ * @param {object} permutationGraph Validated permutation graph.
262
+ * @param {object} wgsl Emitted WGSL set for the selected body.
263
+ * @param {number} bodyIndex Selected permutation index.
264
+ * @returns {object} Body set covering one translated body.
254
265
  */
255
266
  function selectedModeBodySet(permutationGraph, wgsl, bodyIndex) {
256
267
  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,OAAO,GAAG,EAAE,EACtD;EACI,MAAMC,IAAI,GAAGC,aAAa,CAACF,OAAO,CAACC,IAAI,EAAED,OAAO,CAACG,eAAe,CAAC;AACj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hE,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 { resolveWriteVersion } from \"../../../format/carbonEffect/carbonEffectRecords.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 // Resolved once, up front, so an unwritable request fails before any\r\n // translation work is done rather than at the final assembly step. The\r\n // reported value is what was actually emitted, never the constant.\r\n const containerVersion = resolveWriteVersion(options.version);\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 // The Carbon container version these bytes ARE, stated rather than\r\n // implied. The writer emits 15 and only 15, while the reader accepts\r\n // 8..15, so a consumer cannot infer what it was handed from what we can\r\n // read - and a v15 reader elsewhere (ccpwgl's Tw2Shader, Carbon itself)\r\n // needs to know this file is one it can parse before it tries.\r\n containerVersion,\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 containerVersion,\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 {\r\n compilerVersion: resolved.effectRes.m_compilerVersionBytes,\r\n version: containerVersion\r\n }\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","containerVersion","resolveWriteVersion","version","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":";;;;;;;;;;;;;;;;AAwCA;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;AAC9C;AACA;AACA;AACA,EAAA,MAAME,gBAAgB,GAAGC,mBAAmB,CAACP,OAAO,CAACQ,OAAO,CAAC;EAC7D,MAAMC,UAAU,GAAGC,uBAAuB,CAACV,OAAO,CAACS,UAAU,EAAE,mBAAmB,CAAC;EACnF,MAAME,cAAc,GAAGC,uBAAuB,CAC1CZ,OAAO,CAACW,cAAc,EACtBP,MAAM,EACNL,KACJ,CAAC;AACD,EAAA,MAAMc,WAAW,GAAGC,0BAA0B,CAACd,OAAO,CAACa,WAAW,CAAC;AACnE,EAAA,MAAME,SAAS,GAAGC,kBAAkB,CAAChB,OAAO,CAACe,SAAS,CAA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B,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;;;;"}
@@ -25,12 +25,20 @@ function normalizeInput(input, transformId, index) {
25
25
  const layer = input?.layer;
26
26
  const identity = input?.identity;
27
27
  const scoped = input?.scopeIdentity;
28
- if (typeof parameter !== "string" || !parameter || !Number.isInteger(layer) || layer !== index || typeof identity !== "string" || !RESOURCE_IDENTITY.test(identity) || scoped !== `${identity}@fragment`) {
28
+ const registers = typeof identity === "string" ? RESOURCE_IDENTITY.exec(identity) : null;
29
+ if (typeof parameter !== "string" || !parameter || !Number.isInteger(layer) || layer !== index || !registers || scoped !== `${identity}@fragment`) {
29
30
  throw new Error(`WGSL resource transform ${transformId} has an invalid input at layer ${index}`);
30
31
  }
32
+ // The register pair is parsed back out of the identity rather than copied
33
+ // from the caller, so it cannot contradict the identity it composes. It has
34
+ // to be carried: the container stores the pair and rebuilds the identity
35
+ // from it on read, so dropping it here wrote zeroes and every layer of every
36
+ // merged detail map came back as `sampled-resource:0:0`.
31
37
  return {
32
38
  parameter,
33
39
  layer,
40
+ registerSpace: Number(registers[1]),
41
+ registerIndex: Number(registers[2]),
34
42
  identity,
35
43
  scopeIdentity: scoped
36
44
  };