@carbonenginejs/runtime-resource 0.12.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/dist/CjsResMan.js +4 -4
  2. package/dist/CjsResMan.js.map +1 -1
  3. package/dist/_virtual/_rollupPluginBabelHelpers.js +1 -4
  4. package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
  5. package/dist/format/CjsByteReader.js +310 -0
  6. package/dist/format/CjsByteReader.js.map +1 -0
  7. package/dist/format/CjsByteWriter.js +242 -0
  8. package/dist/format/CjsByteWriter.js.map +1 -0
  9. package/dist/format/CjsFormatError.js +41 -0
  10. package/dist/format/CjsFormatError.js.map +1 -0
  11. package/dist/format/CjsStringTable.js +268 -0
  12. package/dist/format/CjsStringTable.js.map +1 -0
  13. package/dist/format/carbonEffect/CjsCarbonEffectReader.js +361 -0
  14. package/dist/format/carbonEffect/CjsCarbonEffectReader.js.map +1 -0
  15. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js +373 -0
  16. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -0
  17. package/dist/format/carbonEffect/carbonDescriptionFromPortable.js +372 -0
  18. package/dist/format/carbonEffect/carbonDescriptionFromPortable.js.map +1 -0
  19. package/dist/format/carbonEffect/carbonEffectBackendBlock.js +427 -0
  20. package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -0
  21. package/dist/format/carbonEffect/carbonEffectRecords.js +955 -0
  22. package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -0
  23. package/dist/format/compareUtf8.js +36 -0
  24. package/dist/format/compareUtf8.js.map +1 -0
  25. package/dist/format/index.js +11 -0
  26. package/dist/format/index.js.map +1 -0
  27. package/dist/formats/bnk/CjsBnkFormat.js +10 -4
  28. package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
  29. package/dist/formats/bnk/core/eventAction.js +305 -0
  30. package/dist/formats/bnk/core/eventAction.js.map +1 -0
  31. package/dist/formats/bnk/core/helpers.js +11 -2
  32. package/dist/formats/bnk/core/helpers.js.map +1 -1
  33. package/dist/formats/bnk/core/nodeBase.js +532 -0
  34. package/dist/formats/bnk/core/nodeBase.js.map +1 -0
  35. package/dist/formats/bnk/core/sfxNodes.js +252 -152
  36. package/dist/formats/bnk/core/sfxNodes.js.map +1 -1
  37. package/dist/formats/hlsl/core/HlslReader.js +7 -257
  38. package/dist/formats/hlsl/core/HlslReader.js.map +1 -1
  39. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +781 -0
  40. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -0
  41. package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +21 -1
  42. package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -1
  43. package/dist/formats/index.js +1 -1
  44. package/dist/formats/webgl/core/cewg/CewgPackage.js +2 -1
  45. package/dist/formats/webgl/core/cewg/CewgPackage.js.map +1 -1
  46. package/dist/formats/webgl/core/cewg/binary.js +11 -93
  47. package/dist/formats/webgl/core/cewg/binary.js.map +1 -1
  48. package/dist/formats/webgl/core/effectPackage.js +1 -1
  49. package/dist/formats/webgpu/CjsWebgpuFormat.js +4 -23
  50. package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
  51. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +197 -0
  52. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -0
  53. package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js +368 -0
  54. package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js.map +1 -0
  55. package/dist/formats/webgpu/core/cewgpu/containerViews.js +355 -0
  56. package/dist/formats/webgpu/core/cewgpu/containerViews.js.map +1 -0
  57. package/dist/formats/webgpu/core/cewgpu/validateContainer.js +90 -0
  58. package/dist/formats/webgpu/core/cewgpu/validateContainer.js.map +1 -0
  59. package/dist/formats/webgpu/core/effectBackendBodySet.js +21 -20
  60. package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
  61. package/dist/formats/webgpu/core/helpers.js +87 -92
  62. package/dist/formats/webgpu/core/helpers.js.map +1 -1
  63. package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +14 -13
  64. package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js.map +1 -1
  65. package/dist/formats/webgpu/core/ir/inferValueTypes.js +10 -8
  66. package/dist/formats/webgpu/core/ir/inferValueTypes.js.map +1 -1
  67. package/dist/formats/webgpu/core/packageEffect.js +94 -9
  68. package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
  69. package/dist/formats/webgpu/core/packageMetadata.js +10 -1
  70. package/dist/formats/webgpu/core/packageMetadata.js.map +1 -1
  71. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +17 -15
  72. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
  73. package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +13 -12
  74. package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js.map +1 -1
  75. package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +9 -8
  76. package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -1
  77. package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +23 -22
  78. package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js.map +1 -1
  79. package/dist/formats/webgpu/core/wgsl/selectionPlans.js +46 -44
  80. package/dist/formats/webgpu/core/wgsl/selectionPlans.js.map +1 -1
  81. package/dist/resource/CjsResource.js +700 -684
  82. package/dist/resource/CjsResource.js.map +1 -1
  83. package/dist/resource/Tr2LightProfileRes.js +18 -27
  84. package/dist/resource/Tr2LightProfileRes.js.map +1 -1
  85. package/dist/resource/audio/CjsAudioBufferRes.js +2 -2
  86. package/dist/resource/audio/CjsAudioBufferRes.js.map +1 -1
  87. package/dist/resource/audio/CjsAudioRes.js +2 -2
  88. package/dist/resource/audio/CjsAudioRes.js.map +1 -1
  89. package/dist/resource/geometry/TriGeometryRes.js +605 -586
  90. package/dist/resource/geometry/TriGeometryRes.js.map +1 -1
  91. package/dist/resource/geometry/granny/Tr2GrannyStateRes.js +21 -30
  92. package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -1
  93. package/dist/resource/geometry/granny/TriGrannyRes.js +21 -30
  94. package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -1
  95. package/dist/resource/shader/Tr2EffectRes.js +9 -7
  96. package/dist/resource/shader/Tr2EffectRes.js.map +1 -1
  97. package/dist/resource/shader/Tr2MaterialArea.js +5 -3
  98. package/dist/resource/shader/Tr2MaterialArea.js.map +1 -1
  99. package/dist/resource/shader/Tr2MaterialMesh.js +4 -2
  100. package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -1
  101. package/dist/resource/shader/Tr2MaterialRes.js +5 -3
  102. package/dist/resource/shader/Tr2MaterialRes.js.map +1 -1
  103. package/dist/resource/shader/Tr2Shader.js +26 -21
  104. package/dist/resource/shader/Tr2Shader.js.map +1 -1
  105. package/dist/resource/shader/Tr2ShaderPermutation.js +8 -6
  106. package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -1
  107. package/dist/resource/shader/reflection/Tr2EffectDefine.js +5 -3
  108. package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -1
  109. package/dist/resource/shader/reflection/Tr2EffectDescription.js +5 -3
  110. package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -1
  111. package/dist/resource/shader/reflection/Tr2EffectLibrary.js +17 -15
  112. package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -1
  113. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +11 -9
  114. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
  115. package/dist/resource/shader/reflection/Tr2EffectResource.js +8 -6
  116. package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
  117. package/dist/resource/shader/reflection/Tr2EffectStageInput.js +15 -13
  118. package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
  119. package/dist/resource/shader/reflection/Tr2EffectTechnique.js +7 -5
  120. package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -1
  121. package/dist/resource/shader/reflection/Tr2Pass.js +11 -9
  122. package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
  123. package/dist/resource/shader/sampler/Tr2SamplerSetup.js +8 -6
  124. package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -1
  125. package/dist/resource/texture/CjsTextureArrayRes.js +400 -411
  126. package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -1
  127. package/dist/resource/texture/Tr2ImageRes.js +99 -95
  128. package/dist/resource/texture/Tr2ImageRes.js.map +1 -1
  129. package/dist/resource/texture/TriTextureRes.js +312 -273
  130. package/dist/resource/texture/TriTextureRes.js.map +1 -1
  131. package/docs/README.md +13 -1
  132. package/docs/architecture.md +3 -3
  133. package/docs/concepts/resource-lifecycle.md +9 -2
  134. package/docs/concepts/shader-resource-model.md +114 -0
  135. package/docs/concepts/writing-an-engine-adapter.md +115 -0
  136. package/docs/formats/README.md +24 -1
  137. package/docs/formats/carbon-effect-container.md +452 -0
  138. package/docs/formats/dxbc/reference/classes/README.md +5 -72
  139. package/docs/formats/hlsl/reference/api.md +5 -4
  140. package/docs/formats/hlsl/reference/classes/README.md +6 -11
  141. package/docs/formats/provenance.md +23 -13
  142. package/docs/formats/webgl/reference/classes/README.md +5 -92
  143. package/docs/formats/webgpu/README.md +19 -16
  144. package/docs/formats/webgpu/architecture.md +15 -12
  145. package/docs/formats/webgpu/formats/cewgpu.md +175 -438
  146. package/docs/formats/webgpu/guides/effect-packaging.md +132 -140
  147. package/docs/formats/webgpu/reference/api.md +131 -131
  148. package/docs/formats/webgpu/reference/classes/README.md +5 -62
  149. package/docs/formats/webgpu/reference/wgsl-compatibility.md +146 -45
  150. package/docs/formats/wwise.md +34 -8
  151. package/docs/reference/classes/core.md +80 -0
  152. package/docs/reference/classes/formats.md +18 -28
  153. package/docs/reference/events.md +25 -0
  154. package/docs/reference/motherlode-cache.md +22 -8
  155. package/docs/reference/workers.md +5 -5
  156. package/docs/roadmap.md +61 -41
  157. package/package.json +2 -1
  158. package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js +0 -415
  159. package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js.map +0 -1
  160. package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js +0 -100
  161. package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js.map +0 -1
  162. package/dist/formats/webgpu/core/cewgpu/binary.js +0 -93
  163. package/dist/formats/webgpu/core/cewgpu/binary.js.map +0 -1
  164. package/dist/formats/webgpu/core/cewgpu/tags.js +0 -17
  165. package/dist/formats/webgpu/core/cewgpu/tags.js.map +0 -1
  166. package/dist/formats/webgpu/core/effectPackageValidation.js +0 -1078
  167. package/dist/formats/webgpu/core/effectPackageValidation.js.map +0 -1
  168. package/docs/formats/hlsl/reference/classes/carbon-compatibility.md +0 -66
  169. package/docs/formats/hlsl/reference/classes/public-api.md +0 -26
  170. package/docs/formats/hlsl/reference/classes/tr2-effect-model.md +0 -150
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CjsCarbonEffectReader.js","sources":["../../../../src/format/carbonEffect/CjsCarbonEffectReader.js"],"sourcesContent":["// Source: trinity/trinity/Resources/Tr2EffectRes.cpp (DoLoad, GetShader)\n// Source: trinity/shadercompiler/ShaderCompiler.cpp:746-845 (file assembly)\n\nimport { CjsByteReader } from \"../CjsByteReader.js\";\nimport { CjsFormatReadError } from \"../CjsFormatError.js\";\nimport { CARBON_EFFECT_DATA_VERSION, readEffectDescription } from \"./carbonEffectRecords.js\";\n\n/** Byte count of the ASCII-hex MD5 source hash in the v15 header. */\nexport const CARBON_EFFECT_SOURCE_HASH_BYTES = 32;\n\n/** Byte count of one offset-table row: `{u32 index, u32 offset, u32 size}`. */\nexport const CARBON_EFFECT_RECORD_BYTES = 12;\n\n/**\n * Plain byte cursor over one description blob, carrying the Carbon effect error\n * class and message.\n *\n * Separate from the container reader because the container reader parses its\n * header in the constructor; a body needs a cursor, not a second header parse.\n */\nexport class CjsCarbonEffectBodyReader extends CjsByteReader\n{\n static ReadError = CjsFormatReadError;\n\n static endOfDataMessage = \"Unexpected end of Carbon effect data\";\n}\n\n/**\n * Reader for Carbon's compiled-effect container at version 15.\n *\n * The header is (`ShaderCompiler.cpp:822-831`):\n *\n * ```\n * u32 version = 15\n * u8[4] shaderCompilerVersion <- four bytes, not a u32\n * char[32] sourceHash <- ASCII hex MD5 of the HLSL inputs\n * u32 stringTableSize | arena\n * u8 permutationCount | permutation records\n * u32 recordCount | recordCount x { u32 index, u32 offset, u32 size }\n * description blobs\n * ```\n *\n * Only version 15 is accepted. Carbon's own reader takes 2..15\n * (`Tr2EffectRes.cpp:209`) but marks the v13/v14 field-order boundaries\n * unverified, and every file in the shipped dx11/dx12 corpus is v15, so a\n * lower version here means something unexpected rather than something old.\n */\nexport class CjsCarbonEffectReader extends CjsCarbonEffectBodyReader\n{\n /** Cursor class used for description blobs. */\n static BodyReader = CjsCarbonEffectBodyReader;\n\n /**\n * Reads the container header, arena, permutation axes and offset table.\n *\n * @param {ArrayBuffer|ArrayBufferView|Uint8Array} bytes Container bytes.\n * @param {object} [options] Read options.\n * @param {string} [options.source] Source name used in error details.\n * @param {boolean} [options.permissive] Accept a sparse or misordered offset\n * table instead of rejecting it. For forensic inspection of a file already\n * known to be malformed; never for a load path.\n */\n constructor(bytes, options = {})\n {\n super(bytes, options);\n\n this.version = this.readUint32();\n if (this.version !== CARBON_EFFECT_DATA_VERSION)\n {\n throw this._error(\n `Unsupported Carbon effect version ${this.version}; expected ${CARBON_EFFECT_DATA_VERSION}`,\n { version: this.version }\n );\n }\n\n this.compilerVersion = Array.from(this.readRaw(4));\n this.sourceHash = Uint8Array.from(this.readRaw(CARBON_EFFECT_SOURCE_HASH_BYTES));\n\n this.stringTableSize = this.readUint32();\n if (this.offset + this.stringTableSize > this.bytes.length)\n {\n throw this._error(\"Invalid Carbon effect string-table size\", {\n stringTableSize: this.stringTableSize,\n byteLength: this.bytes.length\n });\n }\n this.stringTableBytes = this.bytes.subarray(this.offset, this.offset + this.stringTableSize);\n this.skip(this.stringTableSize);\n this.setStringTable(this.stringTableBytes, this.stringTableSize);\n\n this.permutations = this.#readPermutations();\n this.records = this.#readRecords();\n this.headerEnd = this.offset;\n this.diagnostics = this.#inspect();\n\n if (!options.permissive)\n {\n this.requireDensePermutationTable();\n }\n }\n\n /**\n * Returns the product of the permutation axes' option counts — the number of\n * offset-table rows a fully populated file has.\n *\n * @returns {number} Permutation count.\n */\n get permutationProduct()\n {\n let product = 1;\n for (const permutation of this.permutations)\n {\n product *= permutation.options.length;\n }\n return product;\n }\n\n /**\n * Throws unless the offset table is dense and positionally indexed.\n *\n * Carbon indexes `m_offsets` positionally and never reads the stored `index`\n * field (`Tr2EffectRes.cpp:121-126`), so a sparse or misordered table does\n * not fail — it silently returns the wrong shader body. Carbon gets density\n * incidentally, from `g_compiledEffects` being a `std::map` densely keyed by\n * `AddPermutationsToWorkQueue`, and promises it nowhere.\n *\n * Measured across the whole shipped corpus at build 3444265 — 4833 files and\n * 78,498 rows across `effect.dx11`, `effect.dx12` and `effect.metal` — both\n * conditions hold in every file, so this runs by default.\n *\n * `--ignore-permutations` does make CCP's compiler emit only key 0 while\n * declaring every axis, so a sparse file is producible. That argues for an\n * escape hatch, not for permissiveness: because Carbon indexes positionally,\n * accepting such a file returns the wrong permutation's shader silently, which\n * is exactly the failure class this container port exists to close.\n * `{ permissive: true }` is the opt-in, for inspecting a file already known to\n * be malformed.\n */\n requireDensePermutationTable()\n {\n if (!this.diagnostics.dense)\n {\n throw this._error(\"Carbon effect offset table is sparse\", {\n recordCount: this.records.length,\n permutationProduct: this.permutationProduct\n });\n }\n if (!this.diagnostics.indicesMatchPosition)\n {\n throw this._error(\"Carbon effect offset table is not positionally indexed\", {\n firstMismatch: this.diagnostics.firstIndexMismatch\n });\n }\n }\n\n /**\n * Reads and parses one permutation's description blob.\n *\n * `backend` is **optional**, and omitting it is the interesting case. A\n * Carbon file ends each pass at the render states; ours adds one eight-byte\n * block reference. Nothing in the header distinguishes the two, and we\n * deliberately do not add anything — no envelope, no version of our own,\n * because CCP owns the version space and a container that announces itself\n * is an invention nothing requires.\n *\n * Instead the blob describes itself, using a rule the format already has.\n * Every sized record must parse to exactly its declared end (Rule 1), and a\n * body's declared size is in the offset table. So the wrong interpretation\n * either throws or leaves the cursor somewhere other than the end, and one\n * retry settles it.\n *\n * Pass `backend` explicitly when the caller knows — the loader does, because\n * backend selection is by resource path, mirroring Carbon's\n * `effect.dx11`/`effect.dx12`/`effect.metal`. Auto-detection is for bytes\n * that arrive without that context: tooling, caches, inspection.\n *\n * @param {number} index Permutation index, positional in the offset table.\n * @param {object} [options] Read options.\n * @param {boolean} [options.backend] Expect our optional per-pass trailing\n * block. Omit to detect it from the blob's declared end.\n * @returns {object} Description record tree.\n */\n readDescription(index, options = {})\n {\n const record = this.records[index];\n if (!record)\n {\n throw this._error(`No Carbon effect body at permutation index ${index}`, {\n index,\n recordCount: this.records.length\n });\n }\n\n if (options.backend !== undefined)\n {\n return this.#readDescriptionAs(record, options.backend === true);\n }\n\n // Plain Carbon first: it is the larger population, and it is the reading\n // that must stay cheap.\n try\n {\n return this.#readDescriptionAs(record, false);\n }\n catch (withoutBlocks)\n {\n try\n {\n return this.#readDescriptionAs(record, true);\n }\n catch\n {\n // Report the plain-Carbon failure. If neither reading works the\n // blob is malformed, and the Carbon diagnosis is the useful one;\n // the backend attempt's error would describe a misparse of bytes\n // that were never a backend block.\n throw withoutBlocks;\n }\n }\n }\n\n /**\n * Parses one body under an exact backend-block assumption.\n *\n * @param {object} record Offset-table row.\n * @param {boolean} backend Whether to expect the per-pass block.\n * @returns {object} Description record tree.\n */\n #readDescriptionAs(record, backend)\n {\n const reader = new this.constructor.BodyReader(this.bytes, {\n source: this.source,\n offset: record.offset,\n end: record.offset + record.size,\n stringTable: this.stringTableBytes,\n stringTableSize: this.stringTableSize\n });\n return readEffectDescription(reader, { backend });\n }\n\n /**\n * Returns the raw description-blob bytes for one permutation.\n *\n * @param {number} index Permutation index, positional in the offset table.\n * @returns {Uint8Array} View over the body bytes.\n */\n bodyBytes(index)\n {\n const record = this.records[index];\n if (!record)\n {\n throw this._error(`No Carbon effect body at permutation index ${index}`, { index });\n }\n return this.bytes.subarray(record.offset, record.offset + record.size);\n }\n\n /**\n * Reads the permutation axis records (`ShaderCompiler.cpp:769-795`,\n * `Tr2EffectRes.cpp:263-292`).\n *\n * @returns {object[]} Permutation axes with arena references retained.\n */\n #readPermutations()\n {\n const permutations = [];\n const count = this.readUint8();\n for (let index = 0; index < count; index += 1)\n {\n const nameOffset = this.readUint32();\n const name = this.readStringAt(nameOffset);\n const defaultOption = this.readUint8();\n const descriptionOffset = this.readUint32();\n const description = this.readStringAt(descriptionOffset);\n const type = this.readUint8();\n\n const options = [];\n const optionCount = this.readUint8();\n for (let optionIndex = 0; optionIndex < optionCount; optionIndex += 1)\n {\n const offset = this.readUint32();\n options.push({ offset, value: this.readStringAt(offset) });\n }\n\n permutations.push({\n name: { offset: nameOffset, value: name },\n defaultOption,\n description: { offset: descriptionOffset, value: description },\n type,\n options\n });\n }\n return permutations;\n }\n\n /**\n * Reads the offset table (`ShaderCompiler.cpp:800-820`,\n * `Tr2EffectRes.cpp:294-311`).\n *\n * @returns {object[]} Offset-table rows.\n */\n #readRecords()\n {\n const count = this.readUint32();\n if (count === 0)\n {\n throw this._error(\"Carbon effect contains no compiled bodies\");\n }\n if (this.offset + count * CARBON_EFFECT_RECORD_BYTES > this.bytes.length)\n {\n throw this._error(\"Carbon effect offset table runs past the end of the file\", {\n recordCount: count,\n byteLength: this.bytes.length\n });\n }\n\n const records = [];\n for (let index = 0; index < count; index += 1)\n {\n records.push({\n index: this.readUint32(),\n offset: this.readUint32(),\n size: this.readUint32()\n });\n }\n return records;\n }\n\n /**\n * Validates every row's byte range and collects the structural diagnostics\n * Carbon relies on without stating.\n *\n * @returns {object} Structural diagnostics.\n */\n #inspect()\n {\n const headerEnd = this.headerEnd;\n const byteLength = this.bytes.length;\n let firstIndexMismatch = null;\n const uniqueOffsets = new Set();\n\n for (let index = 0; index < this.records.length; index += 1)\n {\n const record = this.records[index];\n if (record.index !== index && firstIndexMismatch === null)\n {\n firstIndexMismatch = { position: index, storedIndex: record.index };\n }\n const end = record.offset + record.size;\n if (record.offset < headerEnd || end > byteLength || record.size === 0)\n {\n throw this._error(`Carbon effect body record ${index} is out of range`, {\n position: index,\n offset: record.offset,\n size: record.size,\n headerEnd,\n byteLength\n });\n }\n uniqueOffsets.add(record.offset);\n }\n\n // The body region must begin exactly where the header ends. Carbon computes\n // its first body offset as `4 + 4 + 32 + headerSize + stringTable.GetSize()`\n // (`ShaderCompiler.cpp:801`), so a gap or an overlap means our reconstruction\n // of that arithmetic disagrees with the writer's — which would silently\n // misread every body rather than fail. Carbon's own reader does not check\n // this; measured across 4833 shipped files, every one starts its body region\n // flush against the header with no slack.\n const firstBody = Math.min(...this.records.map((record) => record.offset));\n if (firstBody !== headerEnd)\n {\n throw this._error(\"Carbon effect body region does not start where the header ends\", {\n firstBody,\n headerEnd,\n slack: firstBody - headerEnd\n });\n }\n\n return {\n recordCount: this.records.length,\n permutationProduct: this.permutationProduct,\n dense: this.records.length === this.permutationProduct,\n indicesMatchPosition: firstIndexMismatch === null,\n firstIndexMismatch,\n uniqueBodyCount: uniqueOffsets.size,\n aliasedRowCount: this.records.length - uniqueOffsets.size\n };\n }\n}\n\nexport default CjsCarbonEffectReader;\n"],"names":["CARBON_EFFECT_SOURCE_HASH_BYTES","CARBON_EFFECT_RECORD_BYTES","CjsCarbonEffectBodyReader","CjsByteReader","ReadError","CjsFormatReadError","endOfDataMessage","CjsCarbonEffectReader","BodyReader","constructor","bytes","options","version","readUint32","CARBON_EFFECT_DATA_VERSION","_error","compilerVersion","Array","from","readRaw","sourceHash","Uint8Array","stringTableSize","offset","length","byteLength","stringTableBytes","subarray","skip","setStringTable","permutations","records","headerEnd","diagnostics","permissive","requireDensePermutationTable","permutationProduct","product","permutation","dense","recordCount","indicesMatchPosition","firstMismatch","firstIndexMismatch","readDescription","index","record","backend","undefined","withoutBlocks","#readDescriptionAs","reader","source","end","size","stringTable","readEffectDescription","bodyBytes","#readPermutations","count","readUint8","nameOffset","name","readStringAt","defaultOption","descriptionOffset","description","type","optionCount","optionIndex","push","value","#readRecords","#inspect","uniqueOffsets","Set","position","storedIndex","add","firstBody","Math","min","map","slack","uniqueBodyCount","aliasedRowCount"],"mappings":";;;;AAAA;AACA;;;AAMA;AACO,MAAMA,+BAA+B,GAAG;;AAE/C;AACO,MAAMC,0BAA0B,GAAG;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,yBAAyB,SAASC,aAAa,CAC5D;EACI,OAAOC,SAAS,GAAGC,kBAAkB;EAErC,OAAOC,gBAAgB,GAAG,sCAAsC;AACpE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,qBAAqB,SAASL,yBAAyB,CACpE;AACI;EACA,OAAOM,UAAU,GAAGN,yBAAyB;;AAE7C;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACIO,EAAAA,WAAWA,CAACC,KAAK,EAAEC,OAAO,GAAG,EAAE,EAC/B;AACI,IAAA,KAAK,CAACD,KAAK,EAAEC,OAAO,CAAC;AAErB,IAAA,IAAI,CAACC,OAAO,GAAG,IAAI,CAACC,UAAU,EAAE;AAChC,IAAA,IAAI,IAAI,CAACD,OAAO,KAAKE,0BAA0B,EAC/C;MACI,MAAM,IAAI,CAACC,MAAM,CACb,CAAA,kCAAA,EAAqC,IAAI,CAACH,OAAO,CAAA,WAAA,EAAcE,0BAA0B,CAAA,CAAE,EAC3F;QAAEF,OAAO,EAAE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wD,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,GAAG,IAAI,CAAClD,OAAO,CAACmD,GAAG,CAAEpC,MAAM,IAAKA,MAAM,CAACvB,MAAM,CAAC,CAAC;IAC1E,IAAIwD,SAAS,KAAK/C,SAAS,EAC3B;AACI,MAAA,MAAM,IAAI,CAACjB,MAAM,CAAC,gEAAgE,EAAE;QAChFgE,SAAS;QACT/C,SAAS;QACTmD,KAAK,EAAEJ,SAAS,GAAG/C;AACvB,OAAC,CAAC;AACN,IAAA;IAEA,OAAO;AACHQ,MAAAA,WAAW,EAAE,IAAI,CAACT,OAAO,CAACP,MAAM;MAChCY,kBAAkB,EAAE,IAAI,CAACA,kBAAkB;MAC3CG,KAAK,EAAE,IAAI,CAACR,OAAO,CAACP,MAAM,KAAK,IAAI,CAACY,kBAAkB;MACtDK,oBAAoB,EAAEE,kBAAkB,KAAK,IAAI;MACjDA,kBAAkB;MAClByC,eAAe,EAAEV,aAAa,CAACpB,IAAI;MACnC+B,eAAe,EAAE,IAAI,CAACtD,OAAO,CAACP,MAAM,GAAGkD,aAAa,CAACpB;KACxD;AACL,EAAA;AACJ;;;;"}
@@ -0,0 +1,373 @@
1
+ import { CjsByteWriter } from '../CjsByteWriter.js';
2
+ import { CjsStringTable } from '../CjsStringTable.js';
3
+ import { CjsFormatWriteError } from '../CjsFormatError.js';
4
+ import { writeEffectDescription, collectArena, internArena, CARBON_EFFECT_DATA_VERSION } from './carbonEffectRecords.js';
5
+ import { CARBON_EFFECT_SOURCE_HASH_BYTES } from './CjsCarbonEffectReader.js';
6
+ export { CARBON_EFFECT_RECORD_BYTES } from './CjsCarbonEffectReader.js';
7
+
8
+ // Source: trinity/shadercompiler/ShaderCompiler.cpp:717-845 (alias dedupe, file assembly)
9
+
10
+ const textEncoder = new TextEncoder();
11
+
12
+ /**
13
+ * Byte count of one permutation record's fixed part: `u32 name`,
14
+ * `u8 defaultOption`, `u32 description`, `u8 type`, `u8 optionCount`
15
+ * (`ShaderCompiler.cpp:757-761`).
16
+ */
17
+ const PERMUTATION_FIXED_BYTES = 11;
18
+
19
+ /**
20
+ * FNV-1a over every byte, used to bucket body-dedupe candidates.
21
+ *
22
+ * @param {Uint8Array} bytes Byte run to hash.
23
+ * @returns {number} 32-bit hash.
24
+ */
25
+ function hashBytes(bytes) {
26
+ let hash = 0x811c9dc5;
27
+ for (let index = 0; index < bytes.length; index += 1) {
28
+ hash ^= bytes[index];
29
+ hash = Math.imul(hash, 0x01000193);
30
+ }
31
+ return hash >>> 0;
32
+ }
33
+
34
+ /**
35
+ * Reports whether two byte runs are identical.
36
+ *
37
+ * @param {Uint8Array} a First byte run.
38
+ * @param {Uint8Array} b Second byte run.
39
+ * @returns {boolean} True when the runs match exactly.
40
+ */
41
+ function bytesEqual(a, b) {
42
+ if (a.length !== b.length) return false;
43
+ for (let index = 0; index < a.length; index += 1) {
44
+ if (a[index] !== b[index]) return false;
45
+ }
46
+ return true;
47
+ }
48
+
49
+ /**
50
+ * Normalises a source hash to the 32 ASCII bytes the header slot holds.
51
+ *
52
+ * @param {string|ArrayBufferView|Uint8Array} value 32 hex characters or 32 bytes.
53
+ * @returns {Uint8Array} Exactly 32 bytes.
54
+ */
55
+ function normalizeSourceHash(value) {
56
+ const bytes = typeof value === "string" ? textEncoder.encode(value) : value instanceof Uint8Array ? value : new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
57
+ if (bytes.length !== CARBON_EFFECT_SOURCE_HASH_BYTES) {
58
+ throw new CjsFormatWriteError(`Source hash must be exactly ${CARBON_EFFECT_SOURCE_HASH_BYTES} bytes`, {
59
+ byteLength: bytes.length
60
+ });
61
+ }
62
+ return bytes;
63
+ }
64
+
65
+ /**
66
+ * Normalises a compiler version to the four bytes the header slot holds.
67
+ *
68
+ * The slot is `uint8_t[4]` — `{major, minor, patch, tweak}` from
69
+ * `ShaderCompilerConfig.h.in:5`, of which Carbon's rebuild check compares only
70
+ * the first three (`ModifiedTime.cpp:77`). Carbon's own runtime skips the field
71
+ * entirely (`Tr2EffectRes.cpp:246-249`).
72
+ *
73
+ * @param {number[]|ArrayBufferView|Uint8Array} value Four version components.
74
+ * @returns {Uint8Array} Exactly 4 bytes.
75
+ */
76
+ function normalizeCompilerVersion(value) {
77
+ const bytes = Array.isArray(value) ? Uint8Array.from(value, part => Number(part) & 0xff) : value instanceof Uint8Array ? value : new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
78
+ if (bytes.length !== 4) {
79
+ throw new CjsFormatWriteError("Compiler version must be exactly 4 bytes", {
80
+ byteLength: bytes.length
81
+ });
82
+ }
83
+ return bytes;
84
+ }
85
+
86
+ /**
87
+ * Assembles a Carbon compiled-effect container from fully resolved parts.
88
+ *
89
+ * This is the low-level primitive: every arena reference in `permutationRows`
90
+ * is already a byte offset and every body is already serialised, so the
91
+ * function reproduces exactly Carbon's header order, alias dedupe and
92
+ * body-offset arithmetic and nothing else. Re-emitting a file through this
93
+ * function with its own arena and body bytes must reproduce it byte for byte.
94
+ *
95
+ * Body-offset base is `4 + 4 + 32 + headerSize + stringTable.GetSize()`
96
+ * (`ShaderCompiler.cpp:801`), where `headerSize` is the byte size of the
97
+ * permutation block plus the offset table (`:765`) and `GetSize()` includes the
98
+ * arena's own `u32` length prefix (`StringTable.cpp:82-85`).
99
+ *
100
+ * @param {object} parts Resolved container parts.
101
+ * @param {number[]|Uint8Array} parts.compilerVersion Four version bytes.
102
+ * @param {string|Uint8Array} parts.sourceHash 32 ASCII hash bytes.
103
+ * @param {Uint8Array} parts.stringTableBytes Arena payload, without its prefix.
104
+ * @param {object[]} parts.permutationRows Permutation axes with resolved offsets.
105
+ * @param {Array<{index:number, bytes:Uint8Array}>} parts.bodies Serialised bodies.
106
+ * @returns {Uint8Array} Container bytes.
107
+ */
108
+ function writeCarbonEffectFile(parts) {
109
+ const compilerVersion = normalizeCompilerVersion(parts.compilerVersion ?? [0, 0, 0, 0]);
110
+ const sourceHash = normalizeSourceHash(parts.sourceHash ?? "0".repeat(CARBON_EFFECT_SOURCE_HASH_BYTES));
111
+ const stringTableBytes = parts.stringTableBytes ?? new Uint8Array(0);
112
+ const permutationRows = parts.permutationRows ?? [];
113
+ const bodies = parts.bodies ?? [];
114
+ if (bodies.length === 0) {
115
+ throw new CjsFormatWriteError("A Carbon effect container needs at least one body");
116
+ }
117
+ if (permutationRows.length > 0xff) {
118
+ throw new CjsFormatWriteError("Permutation axis count does not fit in a u8", {
119
+ count: permutationRows.length
120
+ });
121
+ }
122
+ const ordered = bodies.slice().sort((a, b) => a.index - b.index);
123
+ for (let position = 0; position < ordered.length; position += 1) {
124
+ if (ordered[position].index !== position) {
125
+ throw new CjsFormatWriteError("Carbon effect bodies must be dense and start at index 0; the reader indexes the offset table positionally", {
126
+ position,
127
+ index: ordered[position].index
128
+ });
129
+ }
130
+ }
131
+ let permutationBytes = 1;
132
+ for (const row of permutationRows) {
133
+ if (row.options.length > 0xff) {
134
+ throw new CjsFormatWriteError("Permutation option count does not fit in a u8", {
135
+ name: row.name,
136
+ count: row.options.length
137
+ });
138
+ }
139
+ permutationBytes += PERMUTATION_FIXED_BYTES + row.options.length * 4;
140
+ }
141
+ const headerSize = (ordered.length * 3 + 1) * 4 + permutationBytes;
142
+ const base = 4 + 4 + CARBON_EFFECT_SOURCE_HASH_BYTES + headerSize + (stringTableBytes.length + 4);
143
+
144
+ // Carbon compares packed bodies pairwise and points a duplicate's row at the
145
+ // surviving twin, so the offset table stays dense while the file stores each
146
+ // distinct body once (`ShaderCompiler.cpp:717-744`, `:804-820`). Keying the
147
+ // first occurrence by content reaches the same rows in one pass.
148
+ const byContent = new Map();
149
+ const records = [];
150
+ const uniqueBodies = [];
151
+ let cursor = base;
152
+ for (const body of ordered) {
153
+ const key = hashBytes(body.bytes);
154
+ const candidates = byContent.get(key);
155
+ const existing = candidates?.find(candidate => bytesEqual(candidate.bytes, body.bytes));
156
+ if (existing) {
157
+ records.push({
158
+ index: body.index,
159
+ offset: existing.offset,
160
+ size: existing.size
161
+ });
162
+ continue;
163
+ }
164
+ const record = {
165
+ index: body.index,
166
+ offset: cursor,
167
+ size: body.bytes.length
168
+ };
169
+ if (candidates) candidates.push({
170
+ bytes: body.bytes,
171
+ ...record
172
+ });else byContent.set(key, [{
173
+ bytes: body.bytes,
174
+ ...record
175
+ }]);
176
+ records.push(record);
177
+ uniqueBodies.push(body.bytes);
178
+ cursor += body.bytes.length;
179
+ }
180
+ const writer = new CjsByteWriter(cursor);
181
+ writer.u32(CARBON_EFFECT_DATA_VERSION);
182
+ writer.bytes(compilerVersion);
183
+ writer.bytes(sourceHash);
184
+ writer.u32(stringTableBytes.length);
185
+ if (stringTableBytes.length > 0) writer.bytes(stringTableBytes);
186
+ writer.u8(permutationRows.length);
187
+ for (const row of permutationRows) {
188
+ writer.u32(row.nameOffset);
189
+ writer.u8(row.defaultOption);
190
+ writer.u32(row.descriptionOffset);
191
+ writer.u8(row.type);
192
+ writer.u8(row.options.length);
193
+ for (const optionOffset of row.options) {
194
+ writer.u32(optionOffset);
195
+ }
196
+ }
197
+ writer.u32(records.length);
198
+ for (const record of records) {
199
+ writer.u32(record.index);
200
+ writer.u32(record.offset);
201
+ writer.u32(record.size);
202
+ }
203
+ if (writer.length !== base) {
204
+ throw new CjsFormatWriteError("Carbon effect header size arithmetic disagrees with the bytes written", {
205
+ written: writer.length,
206
+ expected: base,
207
+ headerSize,
208
+ permutationBytes
209
+ });
210
+ }
211
+ for (const bytes of uniqueBodies) {
212
+ writer.bytes(bytes);
213
+ }
214
+ return writer.toBytes();
215
+ }
216
+
217
+ /**
218
+ * Builder for a Carbon compiled-effect container.
219
+ *
220
+ * Interning and emission are two passes over the same records, in that order,
221
+ * because an arena offset is only stable once every entry is present: adding
222
+ * after an offset has been handed out would shift every offset already written.
223
+ * `collectArena` runs the first pass and `internArena` the second, and because
224
+ * both drive the same `writeEffectDescription` walk they cannot fall out of
225
+ * step with each other.
226
+ */
227
+ class CjsCarbonEffectWriter {
228
+ #table;
229
+ #permutations = [];
230
+ #bodies = [];
231
+ #compilerVersion;
232
+ #sourceHash;
233
+ #backend;
234
+
235
+ /**
236
+ * Creates an empty container builder.
237
+ *
238
+ * @param {object} [options] Builder options.
239
+ * @param {number[]|Uint8Array} [options.compilerVersion] Four version bytes.
240
+ * @param {string|Uint8Array} [options.sourceHash] 32 ASCII hash bytes.
241
+ * @param {CjsStringTable} [options.stringTable] Arena to intern into.
242
+ * @param {boolean} [options.backend] Emit the optional trailing block per pass.
243
+ */
244
+ constructor(options = {}) {
245
+ this.#table = options.stringTable ?? new CjsStringTable();
246
+ this.#compilerVersion = options.compilerVersion ?? [0, 0, 0, 0];
247
+ this.#sourceHash = options.sourceHash ?? "0".repeat(CARBON_EFFECT_SOURCE_HASH_BYTES);
248
+ this.#backend = options.backend === true;
249
+ }
250
+
251
+ /**
252
+ * Returns the arena this builder interns into.
253
+ *
254
+ * @returns {CjsStringTable} String table.
255
+ */
256
+ get stringTable() {
257
+ return this.#table;
258
+ }
259
+
260
+ /**
261
+ * Adds a permutation axis.
262
+ *
263
+ * @param {object} axis Axis description.
264
+ * @param {string} axis.name Axis name.
265
+ * @param {number} [axis.defaultOption] Index of the default option.
266
+ * @param {string} [axis.description] Axis description text.
267
+ * @param {number} [axis.type] Axis type byte.
268
+ * @param {string[]} axis.options Option names.
269
+ * @returns {CjsCarbonEffectWriter} This builder.
270
+ */
271
+ addPermutation(axis) {
272
+ this.#permutations.push({
273
+ name: String(axis.name ?? ""),
274
+ defaultOption: axis.defaultOption ?? 0,
275
+ description: String(axis.description ?? ""),
276
+ type: axis.type ?? 0,
277
+ options: (axis.options ?? []).map(option => String(option))
278
+ });
279
+ return this;
280
+ }
281
+
282
+ /**
283
+ * Adds one permutation's description record tree.
284
+ *
285
+ * @param {number} index Permutation index.
286
+ * @param {object} description Description record tree.
287
+ * @returns {CjsCarbonEffectWriter} This builder.
288
+ */
289
+ addBody(index, description) {
290
+ this.#bodies.push({
291
+ index,
292
+ description,
293
+ bytes: null
294
+ });
295
+ return this;
296
+ }
297
+
298
+ /**
299
+ * Adds one permutation's already-serialised description bytes.
300
+ *
301
+ * Used when re-emitting a file whose arena is being reused verbatim: the
302
+ * bytes already carry resolved offsets into that arena, so they must not be
303
+ * re-interned.
304
+ *
305
+ * @param {number} index Permutation index.
306
+ * @param {Uint8Array} bytes Serialised description blob.
307
+ * @returns {CjsCarbonEffectWriter} This builder.
308
+ */
309
+ addRawBody(index, bytes) {
310
+ this.#bodies.push({
311
+ index,
312
+ description: null,
313
+ bytes: Uint8Array.from(bytes)
314
+ });
315
+ return this;
316
+ }
317
+
318
+ /**
319
+ * Interns, serialises and assembles the container.
320
+ *
321
+ * @returns {Uint8Array} Container bytes.
322
+ */
323
+ toBytes() {
324
+ for (const axis of this.#permutations) {
325
+ axis.nameRef = this.#table.addString(axis.name);
326
+ axis.descriptionRef = this.#table.addString(axis.description);
327
+ axis.optionRefs = axis.options.map(option => this.#table.addString(option));
328
+ }
329
+ for (const body of this.#bodies) {
330
+ if (body.description) {
331
+ writeEffectDescription(new CjsByteWriter(), body.description, {
332
+ arena: collectArena(this.#table),
333
+ backend: this.#backend
334
+ });
335
+ }
336
+ }
337
+ this.#table.finish();
338
+ const arena = internArena(this.#table);
339
+ const bodies = this.#bodies.map(body => {
340
+ if (body.bytes) return {
341
+ index: body.index,
342
+ bytes: body.bytes
343
+ };
344
+ const writer = new CjsByteWriter();
345
+ writeEffectDescription(writer, body.description, {
346
+ arena,
347
+ backend: this.#backend
348
+ });
349
+ return {
350
+ index: body.index,
351
+ bytes: writer.toBytes()
352
+ };
353
+ });
354
+ const permutationRows = this.#permutations.map(axis => ({
355
+ name: axis.name,
356
+ nameOffset: this.#table.offsetOf(axis.nameRef),
357
+ defaultOption: axis.defaultOption,
358
+ descriptionOffset: this.#table.offsetOf(axis.descriptionRef),
359
+ type: axis.type,
360
+ options: axis.optionRefs.map(reference => this.#table.offsetOf(reference))
361
+ }));
362
+ return writeCarbonEffectFile({
363
+ compilerVersion: this.#compilerVersion,
364
+ sourceHash: this.#sourceHash,
365
+ stringTableBytes: this.#table.toBytes(),
366
+ permutationRows,
367
+ bodies
368
+ });
369
+ }
370
+ }
371
+
372
+ export { CARBON_EFFECT_SOURCE_HASH_BYTES, CjsCarbonEffectWriter, writeCarbonEffectFile };
373
+ //# sourceMappingURL=CjsCarbonEffectWriter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CjsCarbonEffectWriter.js","sources":["../../../../src/format/carbonEffect/CjsCarbonEffectWriter.js"],"sourcesContent":["// Source: trinity/shadercompiler/ShaderCompiler.cpp:717-845 (alias dedupe, file assembly)\n\nimport { CjsByteWriter } from \"../CjsByteWriter.js\";\nimport { CjsStringTable } from \"../CjsStringTable.js\";\nimport { CjsFormatWriteError } from \"../CjsFormatError.js\";\nimport {\n CARBON_EFFECT_DATA_VERSION,\n collectArena,\n internArena,\n writeEffectDescription\n} from \"./carbonEffectRecords.js\";\nimport { CARBON_EFFECT_RECORD_BYTES, CARBON_EFFECT_SOURCE_HASH_BYTES } from \"./CjsCarbonEffectReader.js\";\n\nconst textEncoder = new TextEncoder();\n\n/**\n * Byte count of one permutation record's fixed part: `u32 name`,\n * `u8 defaultOption`, `u32 description`, `u8 type`, `u8 optionCount`\n * (`ShaderCompiler.cpp:757-761`).\n */\nconst PERMUTATION_FIXED_BYTES = 11;\n\n/**\n * FNV-1a over every byte, used to bucket body-dedupe candidates.\n *\n * @param {Uint8Array} bytes Byte run to hash.\n * @returns {number} 32-bit hash.\n */\nfunction hashBytes(bytes)\n{\n let hash = 0x811c9dc5;\n for (let index = 0; index < bytes.length; index += 1)\n {\n hash ^= bytes[index];\n hash = Math.imul(hash, 0x01000193);\n }\n return hash >>> 0;\n}\n\n/**\n * Reports whether two byte runs are identical.\n *\n * @param {Uint8Array} a First byte run.\n * @param {Uint8Array} b Second byte run.\n * @returns {boolean} True when the runs match exactly.\n */\nfunction bytesEqual(a, b)\n{\n if (a.length !== b.length) return false;\n for (let index = 0; index < a.length; index += 1)\n {\n if (a[index] !== b[index]) return false;\n }\n return true;\n}\n\n/**\n * Normalises a source hash to the 32 ASCII bytes the header slot holds.\n *\n * @param {string|ArrayBufferView|Uint8Array} value 32 hex characters or 32 bytes.\n * @returns {Uint8Array} Exactly 32 bytes.\n */\nfunction normalizeSourceHash(value)\n{\n const bytes = typeof value === \"string\"\n ? textEncoder.encode(value)\n : (value instanceof Uint8Array\n ? value\n : new Uint8Array(value.buffer, value.byteOffset, value.byteLength));\n if (bytes.length !== CARBON_EFFECT_SOURCE_HASH_BYTES)\n {\n throw new CjsFormatWriteError(\n `Source hash must be exactly ${CARBON_EFFECT_SOURCE_HASH_BYTES} bytes`,\n { byteLength: bytes.length }\n );\n }\n return bytes;\n}\n\n/**\n * Normalises a compiler version to the four bytes the header slot holds.\n *\n * The slot is `uint8_t[4]` — `{major, minor, patch, tweak}` from\n * `ShaderCompilerConfig.h.in:5`, of which Carbon's rebuild check compares only\n * the first three (`ModifiedTime.cpp:77`). Carbon's own runtime skips the field\n * entirely (`Tr2EffectRes.cpp:246-249`).\n *\n * @param {number[]|ArrayBufferView|Uint8Array} value Four version components.\n * @returns {Uint8Array} Exactly 4 bytes.\n */\nfunction normalizeCompilerVersion(value)\n{\n const bytes = Array.isArray(value)\n ? Uint8Array.from(value, (part) => Number(part) & 0xff)\n : (value instanceof Uint8Array\n ? value\n : new Uint8Array(value.buffer, value.byteOffset, value.byteLength));\n if (bytes.length !== 4)\n {\n throw new CjsFormatWriteError(\"Compiler version must be exactly 4 bytes\", {\n byteLength: bytes.length\n });\n }\n return bytes;\n}\n\n/**\n * Assembles a Carbon compiled-effect container from fully resolved parts.\n *\n * This is the low-level primitive: every arena reference in `permutationRows`\n * is already a byte offset and every body is already serialised, so the\n * function reproduces exactly Carbon's header order, alias dedupe and\n * body-offset arithmetic and nothing else. Re-emitting a file through this\n * function with its own arena and body bytes must reproduce it byte for byte.\n *\n * Body-offset base is `4 + 4 + 32 + headerSize + stringTable.GetSize()`\n * (`ShaderCompiler.cpp:801`), where `headerSize` is the byte size of the\n * permutation block plus the offset table (`:765`) and `GetSize()` includes the\n * arena's own `u32` length prefix (`StringTable.cpp:82-85`).\n *\n * @param {object} parts Resolved container parts.\n * @param {number[]|Uint8Array} parts.compilerVersion Four version bytes.\n * @param {string|Uint8Array} parts.sourceHash 32 ASCII hash bytes.\n * @param {Uint8Array} parts.stringTableBytes Arena payload, without its prefix.\n * @param {object[]} parts.permutationRows Permutation axes with resolved offsets.\n * @param {Array<{index:number, bytes:Uint8Array}>} parts.bodies Serialised bodies.\n * @returns {Uint8Array} Container bytes.\n */\nexport function writeCarbonEffectFile(parts)\n{\n const compilerVersion = normalizeCompilerVersion(parts.compilerVersion ?? [ 0, 0, 0, 0 ]);\n const sourceHash = normalizeSourceHash(parts.sourceHash ?? \"0\".repeat(CARBON_EFFECT_SOURCE_HASH_BYTES));\n const stringTableBytes = parts.stringTableBytes ?? new Uint8Array(0);\n const permutationRows = parts.permutationRows ?? [];\n const bodies = parts.bodies ?? [];\n\n if (bodies.length === 0)\n {\n throw new CjsFormatWriteError(\"A Carbon effect container needs at least one body\");\n }\n if (permutationRows.length > 0xff)\n {\n throw new CjsFormatWriteError(\"Permutation axis count does not fit in a u8\", {\n count: permutationRows.length\n });\n }\n\n const ordered = bodies.slice().sort((a, b) => a.index - b.index);\n for (let position = 0; position < ordered.length; position += 1)\n {\n if (ordered[position].index !== position)\n {\n throw new CjsFormatWriteError(\n \"Carbon effect bodies must be dense and start at index 0; the reader indexes the offset table positionally\",\n { position, index: ordered[position].index }\n );\n }\n }\n\n let permutationBytes = 1;\n for (const row of permutationRows)\n {\n if (row.options.length > 0xff)\n {\n throw new CjsFormatWriteError(\"Permutation option count does not fit in a u8\", {\n name: row.name,\n count: row.options.length\n });\n }\n permutationBytes += PERMUTATION_FIXED_BYTES + row.options.length * 4;\n }\n\n const headerSize = (ordered.length * 3 + 1) * 4 + permutationBytes;\n const base = 4 + 4 + CARBON_EFFECT_SOURCE_HASH_BYTES + headerSize + (stringTableBytes.length + 4);\n\n // Carbon compares packed bodies pairwise and points a duplicate's row at the\n // surviving twin, so the offset table stays dense while the file stores each\n // distinct body once (`ShaderCompiler.cpp:717-744`, `:804-820`). Keying the\n // first occurrence by content reaches the same rows in one pass.\n const byContent = new Map();\n const records = [];\n const uniqueBodies = [];\n let cursor = base;\n for (const body of ordered)\n {\n const key = hashBytes(body.bytes);\n const candidates = byContent.get(key);\n const existing = candidates?.find((candidate) => bytesEqual(candidate.bytes, body.bytes));\n if (existing)\n {\n records.push({ index: body.index, offset: existing.offset, size: existing.size });\n continue;\n }\n const record = { index: body.index, offset: cursor, size: body.bytes.length };\n if (candidates) candidates.push({ bytes: body.bytes, ...record });\n else byContent.set(key, [ { bytes: body.bytes, ...record } ]);\n records.push(record);\n uniqueBodies.push(body.bytes);\n cursor += body.bytes.length;\n }\n\n const writer = new CjsByteWriter(cursor);\n writer.u32(CARBON_EFFECT_DATA_VERSION);\n writer.bytes(compilerVersion);\n writer.bytes(sourceHash);\n\n writer.u32(stringTableBytes.length);\n if (stringTableBytes.length > 0) writer.bytes(stringTableBytes);\n\n writer.u8(permutationRows.length);\n for (const row of permutationRows)\n {\n writer.u32(row.nameOffset);\n writer.u8(row.defaultOption);\n writer.u32(row.descriptionOffset);\n writer.u8(row.type);\n writer.u8(row.options.length);\n for (const optionOffset of row.options)\n {\n writer.u32(optionOffset);\n }\n }\n\n writer.u32(records.length);\n for (const record of records)\n {\n writer.u32(record.index);\n writer.u32(record.offset);\n writer.u32(record.size);\n }\n\n if (writer.length !== base)\n {\n throw new CjsFormatWriteError(\"Carbon effect header size arithmetic disagrees with the bytes written\", {\n written: writer.length,\n expected: base,\n headerSize,\n permutationBytes\n });\n }\n\n for (const bytes of uniqueBodies)\n {\n writer.bytes(bytes);\n }\n\n return writer.toBytes();\n}\n\n/**\n * Builder for a Carbon compiled-effect container.\n *\n * Interning and emission are two passes over the same records, in that order,\n * because an arena offset is only stable once every entry is present: adding\n * after an offset has been handed out would shift every offset already written.\n * `collectArena` runs the first pass and `internArena` the second, and because\n * both drive the same `writeEffectDescription` walk they cannot fall out of\n * step with each other.\n */\nexport class CjsCarbonEffectWriter\n{\n #table;\n #permutations = [];\n #bodies = [];\n #compilerVersion;\n #sourceHash;\n #backend;\n\n /**\n * Creates an empty container builder.\n *\n * @param {object} [options] Builder options.\n * @param {number[]|Uint8Array} [options.compilerVersion] Four version bytes.\n * @param {string|Uint8Array} [options.sourceHash] 32 ASCII hash bytes.\n * @param {CjsStringTable} [options.stringTable] Arena to intern into.\n * @param {boolean} [options.backend] Emit the optional trailing block per pass.\n */\n constructor(options = {})\n {\n this.#table = options.stringTable ?? new CjsStringTable();\n this.#compilerVersion = options.compilerVersion ?? [ 0, 0, 0, 0 ];\n this.#sourceHash = options.sourceHash ?? \"0\".repeat(CARBON_EFFECT_SOURCE_HASH_BYTES);\n this.#backend = options.backend === true;\n }\n\n /**\n * Returns the arena this builder interns into.\n *\n * @returns {CjsStringTable} String table.\n */\n get stringTable()\n {\n return this.#table;\n }\n\n /**\n * Adds a permutation axis.\n *\n * @param {object} axis Axis description.\n * @param {string} axis.name Axis name.\n * @param {number} [axis.defaultOption] Index of the default option.\n * @param {string} [axis.description] Axis description text.\n * @param {number} [axis.type] Axis type byte.\n * @param {string[]} axis.options Option names.\n * @returns {CjsCarbonEffectWriter} This builder.\n */\n addPermutation(axis)\n {\n this.#permutations.push({\n name: String(axis.name ?? \"\"),\n defaultOption: axis.defaultOption ?? 0,\n description: String(axis.description ?? \"\"),\n type: axis.type ?? 0,\n options: (axis.options ?? []).map((option) => String(option))\n });\n return this;\n }\n\n /**\n * Adds one permutation's description record tree.\n *\n * @param {number} index Permutation index.\n * @param {object} description Description record tree.\n * @returns {CjsCarbonEffectWriter} This builder.\n */\n addBody(index, description)\n {\n this.#bodies.push({ index, description, bytes: null });\n return this;\n }\n\n /**\n * Adds one permutation's already-serialised description bytes.\n *\n * Used when re-emitting a file whose arena is being reused verbatim: the\n * bytes already carry resolved offsets into that arena, so they must not be\n * re-interned.\n *\n * @param {number} index Permutation index.\n * @param {Uint8Array} bytes Serialised description blob.\n * @returns {CjsCarbonEffectWriter} This builder.\n */\n addRawBody(index, bytes)\n {\n this.#bodies.push({ index, description: null, bytes: Uint8Array.from(bytes) });\n return this;\n }\n\n /**\n * Interns, serialises and assembles the container.\n *\n * @returns {Uint8Array} Container bytes.\n */\n toBytes()\n {\n for (const axis of this.#permutations)\n {\n axis.nameRef = this.#table.addString(axis.name);\n axis.descriptionRef = this.#table.addString(axis.description);\n axis.optionRefs = axis.options.map((option) => this.#table.addString(option));\n }\n for (const body of this.#bodies)\n {\n if (body.description)\n {\n writeEffectDescription(new CjsByteWriter(), body.description, {\n arena: collectArena(this.#table),\n backend: this.#backend\n });\n }\n }\n\n this.#table.finish();\n\n const arena = internArena(this.#table);\n const bodies = this.#bodies.map((body) =>\n {\n if (body.bytes) return { index: body.index, bytes: body.bytes };\n const writer = new CjsByteWriter();\n writeEffectDescription(writer, body.description, { arena, backend: this.#backend });\n return { index: body.index, bytes: writer.toBytes() };\n });\n\n const permutationRows = this.#permutations.map((axis) => ({\n name: axis.name,\n nameOffset: this.#table.offsetOf(axis.nameRef),\n defaultOption: axis.defaultOption,\n descriptionOffset: this.#table.offsetOf(axis.descriptionRef),\n type: axis.type,\n options: axis.optionRefs.map((reference) => this.#table.offsetOf(reference))\n }));\n\n return writeCarbonEffectFile({\n compilerVersion: this.#compilerVersion,\n sourceHash: this.#sourceHash,\n stringTableBytes: this.#table.toBytes(),\n permutationRows,\n bodies\n });\n }\n}\n\nexport { CARBON_EFFECT_RECORD_BYTES, CARBON_EFFECT_SOURCE_HASH_BYTES };\nexport default CjsCarbonEffectWriter;\n"],"names":["textEncoder","TextEncoder","PERMUTATION_FIXED_BYTES","hashBytes","bytes","hash","index","length","Math","imul","bytesEqual","a","b","normalizeSourceHash","value","encode","Uint8Array","buffer","byteOffset","byteLength","CARBON_EFFECT_SOURCE_HASH_BYTES","CjsFormatWriteError","normalizeCompilerVersion","Array","isArray","from","part","Number","writeCarbonEffectFile","parts","compilerVersion","sourceHash","repeat","stringTableBytes","permutationRows","bodies","count","ordered","slice","sort","position","permutationBytes","row","options","name","headerSize","base","byContent","Map","records","uniqueBodies","cursor","body","key","candidates","get","existing","find","candidate","push","offset","size","record","set","writer","CjsByteWriter","u32","CARBON_EFFECT_DATA_VERSION","u8","nameOffset","defaultOption","descriptionOffset","type","optionOffset","written","expected","toBytes","CjsCarbonEffectWriter","constructor","stringTable","CjsStringTable","backend","addPermutation","axis","String","description","map","option","addBody","addRawBody","nameRef","addString","descriptionRef","optionRefs","writeEffectDescription","arena","collectArena","finish","internArena","offsetOf","reference"],"mappings":";;;;;;;AAAA;;AAaA,MAAMA,WAAW,GAAG,IAAIC,WAAW,EAAE;;AAErC;AACA;AACA;AACA;AACA;AACA,MAAMC,uBAAuB,GAAG,EAAE;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,SAASA,CAACC,KAAK,EACxB;EACI,IAAIC,IAAI,GAAG,UAAU;AACrB,EAAA,KAAK,IAAIC,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGF,KAAK,CAACG,MAAM,EAAED,KAAK,IAAI,CAAC,EACpD;AACID,IAAAA,IAAI,IAAID,KAAK,CAACE,KAAK,CAAC;IACpBD,IAAI,GAAGG,IAAI,CAACC,IAAI,CAACJ,IAAI,EAAE,UAAU,CAAC;AACtC,EAAA;EACA,OAAOA,IAAI,KAAK,CAAC;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASK,UAAUA,CAACC,CAAC,EAAEC,CAAC,EACxB;EACI,IAAID,CAAC,CAACJ,MAAM,KAAKK,CAAC,CAACL,MAAM,EAAE,OAAO,KAAK;AACvC,EAAA,KAAK,IAAID,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGK,CAAC,CAACJ,MAAM,EAAED,KAAK,IAAI,CAAC,EAChD;IACI,IAAIK,CAAC,CAACL,KAAK,CAAC,KAAKM,CAAC,CAACN,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