@carbonenginejs/runtime-resource 0.11.1 → 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 (211) 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 +18 -2
  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/graph.js +3 -6
  32. package/dist/formats/bnk/core/graph.js.map +1 -1
  33. package/dist/formats/bnk/core/helpers.js +62 -11
  34. package/dist/formats/bnk/core/helpers.js.map +1 -1
  35. package/dist/formats/bnk/core/nodeBase.js +532 -0
  36. package/dist/formats/bnk/core/nodeBase.js.map +1 -0
  37. package/dist/formats/bnk/core/sfxNodes.js +632 -0
  38. package/dist/formats/bnk/core/sfxNodes.js.map +1 -0
  39. package/dist/formats/bnk/core/soundbanksInfo.js +59 -51
  40. package/dist/formats/bnk/core/soundbanksInfo.js.map +1 -1
  41. package/dist/formats/gr2/CjsGr2Format.js +256 -13
  42. package/dist/formats/gr2/CjsGr2Format.js.map +1 -1
  43. package/dist/formats/gr2/core/helpers.js +15 -15
  44. package/dist/formats/gr2/core/helpers.js.map +1 -1
  45. package/dist/formats/gr2/core/json.js +1 -1
  46. package/dist/formats/gr2/core/json.js.map +1 -1
  47. package/dist/formats/gr2/core/targets.js +1 -1
  48. package/dist/formats/gr2/core/targets.js.map +1 -1
  49. package/dist/formats/gr2/index.js +0 -1
  50. package/dist/formats/gr2/index.js.map +1 -1
  51. package/dist/formats/hlsl/core/HlslReader.js +7 -257
  52. package/dist/formats/hlsl/core/HlslReader.js.map +1 -1
  53. package/dist/formats/hlsl/core/analysis.js +1 -1
  54. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +781 -0
  55. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -0
  56. package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +21 -1
  57. package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -1
  58. package/dist/formats/hlsl/index.js +1 -0
  59. package/dist/formats/hlsl/index.js.map +1 -1
  60. package/dist/formats/index.js +3 -6
  61. package/dist/formats/index.js.map +1 -1
  62. package/dist/formats/webgl/core/cewg/CewgPackage.js +2 -1
  63. package/dist/formats/webgl/core/cewg/CewgPackage.js.map +1 -1
  64. package/dist/formats/webgl/core/cewg/binary.js +11 -93
  65. package/dist/formats/webgl/core/cewg/binary.js.map +1 -1
  66. package/dist/formats/webgl/core/effectPackage.js +4 -1
  67. package/dist/formats/webgl/core/effectPackage.js.map +1 -1
  68. package/dist/formats/webgl/core/errors.js +3 -3
  69. package/dist/formats/webgl/core/errors.js.map +1 -1
  70. package/dist/formats/webgpu/CjsWebgpuFormat.js +4 -23
  71. package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
  72. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +197 -0
  73. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -0
  74. package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js +368 -0
  75. package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js.map +1 -0
  76. package/dist/formats/webgpu/core/cewgpu/containerViews.js +355 -0
  77. package/dist/formats/webgpu/core/cewgpu/containerViews.js.map +1 -0
  78. package/dist/formats/webgpu/core/cewgpu/validateContainer.js +90 -0
  79. package/dist/formats/webgpu/core/cewgpu/validateContainer.js.map +1 -0
  80. package/dist/formats/webgpu/core/effectBackendBodySet.js +21 -20
  81. package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
  82. package/dist/formats/webgpu/core/helpers.js +87 -92
  83. package/dist/formats/webgpu/core/helpers.js.map +1 -1
  84. package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +14 -13
  85. package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js.map +1 -1
  86. package/dist/formats/webgpu/core/ir/inferValueTypes.js +10 -8
  87. package/dist/formats/webgpu/core/ir/inferValueTypes.js.map +1 -1
  88. package/dist/formats/webgpu/core/packageEffect.js +94 -9
  89. package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
  90. package/dist/formats/webgpu/core/packageMetadata.js +10 -1
  91. package/dist/formats/webgpu/core/packageMetadata.js.map +1 -1
  92. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +17 -15
  93. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
  94. package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +13 -12
  95. package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js.map +1 -1
  96. package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +9 -8
  97. package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -1
  98. package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +23 -22
  99. package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js.map +1 -1
  100. package/dist/formats/webgpu/core/wgsl/selectionPlans.js +46 -44
  101. package/dist/formats/webgpu/core/wgsl/selectionPlans.js.map +1 -1
  102. package/dist/resource/CjsResource.js +700 -684
  103. package/dist/resource/CjsResource.js.map +1 -1
  104. package/dist/resource/Tr2LightProfileRes.js +18 -27
  105. package/dist/resource/Tr2LightProfileRes.js.map +1 -1
  106. package/dist/resource/audio/CjsAudioBufferRes.js +2 -2
  107. package/dist/resource/audio/CjsAudioBufferRes.js.map +1 -1
  108. package/dist/resource/audio/CjsAudioRes.js +2 -2
  109. package/dist/resource/audio/CjsAudioRes.js.map +1 -1
  110. package/dist/resource/geometry/TriGeometryRes.js +605 -586
  111. package/dist/resource/geometry/TriGeometryRes.js.map +1 -1
  112. package/dist/resource/geometry/granny/Tr2GrannyStateRes.js +21 -30
  113. package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -1
  114. package/dist/resource/geometry/granny/TriGrannyRes.js +21 -30
  115. package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -1
  116. package/dist/resource/shader/Tr2EffectRes.js +9 -7
  117. package/dist/resource/shader/Tr2EffectRes.js.map +1 -1
  118. package/dist/resource/shader/Tr2MaterialArea.js +5 -3
  119. package/dist/resource/shader/Tr2MaterialArea.js.map +1 -1
  120. package/dist/resource/shader/Tr2MaterialMesh.js +4 -2
  121. package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -1
  122. package/dist/resource/shader/Tr2MaterialRes.js +5 -3
  123. package/dist/resource/shader/Tr2MaterialRes.js.map +1 -1
  124. package/dist/resource/shader/Tr2Shader.js +26 -21
  125. package/dist/resource/shader/Tr2Shader.js.map +1 -1
  126. package/dist/resource/shader/Tr2ShaderPermutation.js +8 -6
  127. package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -1
  128. package/dist/resource/shader/reflection/Tr2EffectDefine.js +5 -3
  129. package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -1
  130. package/dist/resource/shader/reflection/Tr2EffectDescription.js +5 -3
  131. package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -1
  132. package/dist/resource/shader/reflection/Tr2EffectLibrary.js +17 -15
  133. package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -1
  134. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +11 -9
  135. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
  136. package/dist/resource/shader/reflection/Tr2EffectResource.js +8 -6
  137. package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
  138. package/dist/resource/shader/reflection/Tr2EffectStageInput.js +15 -13
  139. package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
  140. package/dist/resource/shader/reflection/Tr2EffectTechnique.js +7 -5
  141. package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -1
  142. package/dist/resource/shader/reflection/Tr2Pass.js +11 -9
  143. package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
  144. package/dist/resource/shader/sampler/Tr2SamplerSetup.js +8 -6
  145. package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -1
  146. package/dist/resource/texture/CjsTextureArrayRes.js +400 -411
  147. package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -1
  148. package/dist/resource/texture/Tr2ImageRes.js +99 -95
  149. package/dist/resource/texture/Tr2ImageRes.js.map +1 -1
  150. package/dist/resource/texture/TriTextureRes.js +312 -273
  151. package/dist/resource/texture/TriTextureRes.js.map +1 -1
  152. package/docs/README.md +13 -1
  153. package/docs/architecture.md +3 -3
  154. package/docs/concepts/resource-lifecycle.md +9 -2
  155. package/docs/concepts/shader-resource-model.md +114 -0
  156. package/docs/concepts/writing-an-engine-adapter.md +115 -0
  157. package/docs/formats/README.md +24 -1
  158. package/docs/formats/carbon-effect-container.md +452 -0
  159. package/docs/formats/dxbc/README.md +68 -0
  160. package/docs/formats/dxbc/architecture.md +80 -0
  161. package/docs/formats/dxbc/reference/api.md +77 -0
  162. package/docs/formats/dxbc/reference/classes/README.md +9 -0
  163. package/docs/formats/dxbc/reference/decoded-output.md +122 -0
  164. package/docs/formats/gr2.md +3 -4
  165. package/docs/formats/hlsl/README.md +54 -0
  166. package/docs/formats/hlsl/architecture.md +67 -0
  167. package/docs/formats/hlsl/guides/hydrating-json-output.md +62 -0
  168. package/docs/formats/hlsl/guides/reading-effects.md +64 -0
  169. package/docs/formats/hlsl/reference/advanced-analysis.md +66 -0
  170. package/docs/formats/hlsl/reference/api.md +98 -0
  171. package/docs/formats/hlsl/reference/classes/README.md +11 -0
  172. package/docs/formats/hlsl/reference/json-graph.md +100 -0
  173. package/docs/formats/hlsl/reference/portable-reflection.md +141 -0
  174. package/docs/formats/provenance.md +32 -17
  175. package/docs/formats/webgl/README.md +57 -0
  176. package/docs/formats/webgl/architecture.md +70 -0
  177. package/docs/formats/webgl/carbon-constant-layouts.md +326 -0
  178. package/docs/formats/webgl/decl-io.md +1234 -0
  179. package/docs/formats/webgl/effect-reflection.md +127 -0
  180. package/docs/formats/webgl/memory-structured.md +871 -0
  181. package/docs/formats/webgl/reference/classes/README.md +9 -0
  182. package/docs/formats/webgl/texture-sample.md +964 -0
  183. package/docs/formats/webgpu/README.md +84 -0
  184. package/docs/formats/webgpu/architecture.md +96 -0
  185. package/docs/formats/webgpu/formats/cewgpu.md +216 -0
  186. package/docs/formats/webgpu/guides/effect-packaging.md +191 -0
  187. package/docs/formats/webgpu/reference/api.md +197 -0
  188. package/docs/formats/webgpu/reference/classes/README.md +9 -0
  189. package/docs/formats/webgpu/reference/wgsl-compatibility.md +1543 -0
  190. package/docs/formats/wwise.md +45 -4
  191. package/docs/reference/classes/core.md +80 -0
  192. package/docs/reference/classes/formats.md +24 -34
  193. package/docs/reference/events.md +25 -0
  194. package/docs/reference/motherlode-cache.md +22 -8
  195. package/docs/reference/workers.md +5 -5
  196. package/docs/roadmap.md +61 -41
  197. package/format-notices/bnk/NOTICE +5 -4
  198. package/format-notices/webgl/NOTICE +1 -1
  199. package/package.json +2 -1
  200. package/dist/formats/gr2/core/CjsFormatGr2.js +0 -273
  201. package/dist/formats/gr2/core/CjsFormatGr2.js.map +0 -1
  202. package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js +0 -415
  203. package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js.map +0 -1
  204. package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js +0 -100
  205. package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js.map +0 -1
  206. package/dist/formats/webgpu/core/cewgpu/binary.js +0 -93
  207. package/dist/formats/webgpu/core/cewgpu/binary.js.map +0 -1
  208. package/dist/formats/webgpu/core/cewgpu/tags.js +0 -17
  209. package/dist/formats/webgpu/core/cewgpu/tags.js.map +0 -1
  210. package/dist/formats/webgpu/core/effectPackageValidation.js +0 -1078
  211. package/dist/formats/webgpu/core/effectPackageValidation.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"lowerComputeProgram.js","sources":["../../../../../../src/formats/webgpu/core/wgsl/lowerComputeProgram.js"],"sourcesContent":["import { requireRefactoringAllowed } from \"./precisionControls.js\";\nimport {\n validateExactComputeEnvelope,\n validateReturnTypeMirror,\n validateSm50ResourceExtensions\n} from \"./validateExactComputeIr.js\";\nimport { validateFixedHandleBinding, validateFixedHandleOperand } from \"./validateHandleOperand.js\";\nimport {\n isSkinVerticesComputeProfile,\n lowerSkinVerticesComputeProgram\n} from \"./lowerSkinVerticesComputeProgram.js\";\nimport {\n isCreateHistogramsComputeProfile,\n lowerCreateHistogramsComputeProgram\n} from \"./lowerCreateHistogramsComputeProgram.js\";\nimport {\n isMergeHistogramsComputeProfile,\n lowerMergeHistogramsComputeProgram\n} from \"./lowerMergeHistogramsComputeProgram.js\";\nimport {\n isParticleClearInitializeCandidate,\n isParticleClearResetCandidate,\n lowerParticleClearInitializeComputeProgram,\n lowerParticleClearResetComputeProgram\n} from \"./lowerParticleClearComputePrograms.js\";\nimport {\n isParticleEmitComputeCandidate,\n lowerParticleEmitComputeProgram\n} from \"./lowerParticleEmitComputeProgram.js\";\nimport {\n isSortStepComputeProfile,\n lowerSortStepComputeProgram\n} from \"./lowerSortStepComputeProgram.js\";\nimport {\n isSortComputeProfile,\n lowerSortComputeProgram\n} from \"./lowerSortComputeProgram.js\";\nimport {\n isSortInnerComputeProfile,\n lowerSortInnerComputeProgram\n} from \"./lowerSortInnerComputeProgram.js\";\n\nconst COMPONENTS = Object.freeze([ \"x\", \"y\", \"z\", \"w\" ]);\nconst DECLARATION_OPCODES = Object.freeze([\n \"dcl_global_flags\",\n \"dcl_resource\",\n \"dcl_unordered_access_view_typed\",\n \"dcl_temps\",\n \"dcl_thread_group\"\n]);\nconst ARITHMETIC_RULES = Object.freeze({\n imul: Object.freeze({\n rule: \"signed-integer\",\n resultType: \"int32\",\n destinationOperand: 1,\n sourceOperands: Object.freeze([ 2, 3 ]),\n sourceType: \"int32\",\n operator: \"*\"\n }),\n umax: Object.freeze({\n rule: \"unsigned-integer\",\n resultType: \"uint32\",\n destinationOperand: 0,\n sourceOperands: Object.freeze([ 1, 2 ]),\n sourceType: \"uint32\",\n functionName: \"max\"\n }),\n iadd: Object.freeze({\n rule: \"signed-integer\",\n resultType: \"int32\",\n destinationOperand: 0,\n sourceOperands: Object.freeze([ 1, 2 ]),\n sourceType: \"int32\",\n operator: \"+\"\n }),\n ushr: Object.freeze({\n rule: \"unsigned-integer\",\n resultType: \"uint32\",\n destinationOperand: 0,\n sourceOperands: Object.freeze([ 1, 2 ]),\n sourceType: \"uint32\",\n operator: \">>\"\n })\n});\nconst SUPPORTED_OPCODES = new Set([\n \"ld\", ...Object.keys(ARITHMETIC_RULES), \"store_uav_typed\", \"ret\"\n]);\nconst KIND_ORDER = Object.freeze({ \"sampled-resource\": 0, \"storage-resource\": 1 });\nconst KIND_PREFIX = Object.freeze({ \"sampled-resource\": \"t\", \"storage-resource\": \"u\" });\n\nfunction deepFreeze(value)\n{\n if (!value || typeof value !== \"object\" || Object.isFrozen(value)) return value;\n for (const entry of Object.values(value)) deepFreeze(entry);\n return Object.freeze(value);\n}\n\nfunction scalarTypeName(type)\n{\n return ({ int32: \"i32\", uint32: \"u32\", bitpattern32: \"u32\" })[type] || null;\n}\n\nfunction canonicalRef(ref)\n{\n return `${ref?.valueId || \"\"}.${ref?.component || \"\"}`;\n}\n\nfunction sameRef(left, right)\n{\n return canonicalRef(left) === canonicalRef(right);\n}\n\nfunction registerKey(operand)\n{\n return `${operand.typeName}[${operand.registerIndex}]`;\n}\n\nfunction validateCommonOperand(operand, instruction, operandIndex)\n{\n if (!operand\n || (operand.modifierName ?? \"none\") !== \"none\"\n || (operand.minPrecisionName ?? \"default\") !== \"default\"\n || operand.nonUniform === true)\n {\n throw new Error(`WGSL compute instruction ${instruction.index} requires an unmodified, uniform, default-precision operand ${operandIndex}`);\n }\n}\n\nfunction validateFixedRegisterOperand(operand, instruction, operandIndex, typeName)\n{\n validateCommonOperand(operand, instruction, operandIndex);\n const index = operand.indices?.[0];\n if (operand.typeName !== typeName\n || !Number.isInteger(operand.registerIndex) || operand.registerIndex < 0\n || operand.indices?.length !== 1\n || index?.relative\n || index?.values?.length !== 1\n || index.values[0] !== operand.registerIndex)\n {\n throw new Error(`WGSL compute instruction ${instruction.index} operand ${operandIndex} has an invalid fixed ${typeName} identity`);\n }\n return operand;\n}\n\nfunction validateDestinationOperand(operand, instruction, operandIndex)\n{\n validateFixedRegisterOperand(operand, instruction, operandIndex, \"temp\");\n if (operand.registerIndex !== 0\n || operand.componentCount !== 4\n || !COMPONENTS.includes(operand.mask)\n || operand.swizzle || operand.selected)\n {\n throw new Error(`WGSL compute instruction ${instruction.index} operand ${operandIndex} requires one canonical temp[0] destination lane`);\n }\n return operand.mask;\n}\n\nfunction validateScalarTempSource(operand, instruction, operandIndex)\n{\n validateFixedRegisterOperand(operand, instruction, operandIndex, \"temp\");\n if (operand.registerIndex !== 0\n || operand.componentCount !== 4\n || !COMPONENTS.includes(operand.selected)\n || operand.mask || operand.swizzle)\n {\n throw new Error(`WGSL compute instruction ${instruction.index} operand ${operandIndex} requires one selected temp[0] source lane`);\n }\n return operand.selected;\n}\n\nfunction immediateBits(operand, instruction, operandIndex, replicated)\n{\n validateCommonOperand(operand, instruction, operandIndex);\n const values = operand.immediateValues || [];\n if (operand.typeName !== \"immediate32\"\n || operand.registerIndex !== null\n || operand.indices?.length\n || operand.mask || operand.swizzle || operand.selected\n || ![ 1, 4 ].includes(operand.componentCount)\n || values.length !== operand.componentCount\n || values.some((value) => !Number.isInteger(value?.uint32)))\n {\n throw new Error(`WGSL compute instruction ${instruction.index} operand ${operandIndex} requires canonical immediate32 data`);\n }\n const bits = values.map((value) => value.uint32 >>> 0);\n if (replicated && (bits.length !== 4 || bits.some((value) => value !== bits[0])))\n {\n throw new Error(`WGSL compute instruction ${instruction.index} operand ${operandIndex} requires four replicated immediate lanes`);\n }\n if (!replicated && bits.length !== 1)\n {\n throw new Error(`WGSL compute instruction ${instruction.index} operand ${operandIndex} requires one immediate lane`);\n }\n return bits[0];\n}\n\nfunction immediateCode(bits, type)\n{\n const literal = `0x${(bits >>> 0).toString(16).padStart(8, \"0\")}u`;\n return type === \"int32\" ? `bitcast<i32>(${literal})` : literal;\n}\n\nfunction validateValueRef(program, ref, expectedRegister, expectedComponent)\n{\n const value = program.values.find((entry) => entry.id === ref?.valueId);\n if (!value\n || value.register !== expectedRegister\n || ref.component !== expectedComponent\n || !value.writeMask.includes(expectedComponent))\n {\n throw new Error(`WGSL compute register dataflow references an incompatible ${expectedRegister}.${expectedComponent} value`);\n }\n if (value.origin === \"undefined-register\")\n {\n throw new Error(`WGSL compute reads undefined ${expectedRegister}.${expectedComponent}`);\n }\n return value;\n}\n\nfunction validateRead(program, instruction, operandIndex, operand, components, state, expectedReads)\n{\n const register = registerKey(operand);\n const matches = instruction.dataflow.reads.filter((entry) =>\n entry.kind === \"register-read\" && entry.operandIndex === operandIndex);\n if (matches.length !== 1)\n {\n throw new Error(`WGSL compute instruction ${instruction.index} has inconsistent read metadata for operand ${operandIndex}`);\n }\n const read = matches[0];\n if (read.register !== register\n || read.components?.length !== components.length\n || read.refs?.length !== components.length\n || components.some((component, index) =>\n read.components[index] !== component\n || !sameRef(read.refs[index], state.get(`${register}.${component}`))))\n {\n throw new Error(`WGSL compute instruction ${instruction.index} has stale or mismatched SSA reads for operand ${operandIndex}`);\n }\n components.forEach((component, index) =>\n validateValueRef(program, read.refs[index], register, component));\n expectedReads.add(read);\n return read;\n}\n\nfunction validateNoUnexpectedReads(instruction, expectedReads)\n{\n if (instruction.dataflow.reads.length !== expectedReads.size\n || instruction.dataflow.reads.some((read) => !expectedReads.has(read)))\n {\n throw new Error(`WGSL compute instruction ${instruction.index} has unexpected register or index reads`);\n }\n}\n\nfunction validateWrite(program, instruction, operandIndex, operand, state, writtenValueIds)\n{\n const writes = instruction.dataflow.writes;\n if (writes.length !== 1 || writes[0].operandIndex !== operandIndex)\n {\n throw new Error(`WGSL compute instruction ${instruction.index} requires one destination write at operand ${operandIndex}`);\n }\n const write = writes[0];\n const register = registerKey(operand);\n const component = operand.mask;\n const value = program.values.find((entry) => entry.id === write.valueId);\n if (write.register !== register || write.mask !== component\n || !value || value.origin !== \"instruction-write\"\n || value.instructionIndex !== instruction.index\n || value.register !== register || value.writeMask !== component\n || writtenValueIds.has(value.id))\n {\n throw new Error(`WGSL compute instruction ${instruction.index} has inconsistent destination SSA metadata`);\n }\n const previousComponents = COMPONENTS.filter((entry) => entry !== component);\n if (!write.previous\n || Object.keys(write.previous).sort().join(\"\") !== previousComponents.slice().sort().join(\"\")\n || previousComponents.some((entry) =>\n !sameRef(write.previous[entry], state.get(`${register}.${entry}`)))\n || Object.keys(write.result || {}).sort().join(\"\") !== COMPONENTS.slice().sort().join(\"\")\n || !sameRef(write.result[component], { valueId: value.id, component })\n || previousComponents.some((entry) =>\n !sameRef(write.result[entry], state.get(`${register}.${entry}`))))\n {\n throw new Error(`WGSL compute instruction ${instruction.index} has inconsistent previous/result SSA lanes`);\n }\n writtenValueIds.add(value.id);\n state.set(`${register}.${component}`, { valueId: value.id, component });\n return { write, value };\n}\n\nfunction valueStorageType(value, component)\n{\n const type = value?.componentTypes?.[component];\n if (!scalarTypeName(type))\n {\n throw new Error(`WGSL compute value ${value?.id || \"<missing>\"}.${component} has an unresolved type`);\n }\n return type;\n}\n\nfunction reinterpretCode(code, fromType, toType)\n{\n const from = scalarTypeName(fromType);\n const to = scalarTypeName(toType);\n if (!from || !to)\n {\n throw new Error(`WGSL compute cannot reinterpret ${fromType} to ${toType}`);\n }\n return from === to ? code : `bitcast<${to}>(${code})`;\n}\n\nfunction readCode(program, instruction, operandIndex, expectedType, state, expectedReads)\n{\n const operand = instruction.operands[operandIndex];\n if (operand?.typeName === \"immediate32\")\n {\n return immediateCode(immediateBits(operand, instruction, operandIndex, false), expectedType);\n }\n const component = validateScalarTempSource(operand, instruction, operandIndex);\n const read = validateRead(program, instruction, operandIndex, operand, [ component ], state, expectedReads);\n const value = validateValueRef(program, read.refs[0], read.register, component);\n return reinterpretCode(value.id, valueStorageType(value, component), expectedType);\n}\n\nfunction replicatedStoreCode(program, instruction, operandIndex, state, expectedReads)\n{\n const operand = instruction.operands[operandIndex];\n if (operand?.typeName === \"immediate32\")\n {\n return immediateCode(immediateBits(operand, instruction, operandIndex, true), \"uint32\");\n }\n validateFixedRegisterOperand(operand, instruction, operandIndex, \"temp\");\n if (operand.registerIndex !== 0\n || operand.componentCount !== 4 || operand.mask || operand.selected\n || operand.swizzle?.length !== 4\n || Array.from(operand.swizzle).some((component) => component !== operand.swizzle[0]))\n {\n throw new Error(`WGSL compute store instruction ${instruction.index} requires four replicated source lanes from temp[0]`);\n }\n const component = operand.swizzle[0];\n if (!COMPONENTS.includes(component))\n {\n throw new Error(`WGSL compute store instruction ${instruction.index} selects an invalid source lane`);\n }\n const components = Array(4).fill(component);\n const read = validateRead(program, instruction, operandIndex, operand, components, state, expectedReads);\n const value = validateValueRef(program, read.refs[0], read.register, component);\n return reinterpretCode(value.id, valueStorageType(value, component), \"uint32\");\n}\n\nfunction expectedOperandTypes(instruction)\n{\n if (instruction.opcodeName === \"ld\")\n {\n return [\n [ \"destination\", \"int32\" ],\n [ \"source\", \"uint32\" ],\n [ \"source\", \"unknown\" ]\n ];\n }\n const arithmetic = ARITHMETIC_RULES[instruction.opcodeName];\n if (arithmetic)\n {\n return instruction.operands.map((_, operandIndex) => [\n operandIndex === arithmetic.destinationOperand ? \"destination\" : \"source\",\n operandIndex === arithmetic.destinationOperand || arithmetic.sourceOperands.includes(operandIndex)\n ? arithmetic.resultType\n : \"unknown\"\n ]);\n }\n if (instruction.opcodeName === \"store_uav_typed\")\n {\n return [\n [ \"source\", \"unknown\" ],\n [ \"source\", \"uint32\" ],\n [ \"source\", \"uint32\" ]\n ];\n }\n return [];\n}\n\nfunction expectedRule(instruction)\n{\n if (instruction.opcodeName === \"ld\") return [ \"texture-load\", \"int32\" ];\n const arithmetic = ARITHMETIC_RULES[instruction.opcodeName];\n if (arithmetic) return [ arithmetic.rule, arithmetic.resultType ];\n if (instruction.opcodeName === \"store_uav_typed\") return [ \"typed-uav-store\", \"unknown\" ];\n return [ \"untyped\", \"unknown\" ];\n}\n\nfunction bitcastKey(entry)\n{\n if (entry.kind === \"read-bitcast\")\n {\n return [\n entry.kind, entry.operandIndex, entry.componentIndex, entry.valueId,\n entry.component, entry.from, entry.to\n ].join(\":\");\n }\n if (entry.kind === \"result-bitcast\")\n {\n return [\n entry.kind, entry.operandIndex, entry.valueId, entry.component,\n entry.from, entry.to\n ].join(\":\");\n }\n return [\n entry.kind, entry.operandIndex, entry.component, entry.from, entry.to,\n entry.uint32 >>> 0\n ].join(\":\");\n}\n\nfunction validateTypeInfo(program, instruction)\n{\n const [ rule, resultType ] = expectedRule(instruction);\n const operandTypes = expectedOperandTypes(instruction);\n const typeInfo = instruction.typeInfo;\n if (typeInfo?.kind !== \"instruction-types\"\n || typeInfo.rule !== rule\n || typeInfo.resultType !== resultType\n || typeInfo.conversion !== null\n || typeInfo.conditionProjection !== null\n || typeInfo.operandTypes?.length !== operandTypes.length\n || operandTypes.some(([ role, expectedType ], operandIndex) =>\n {\n const actual = typeInfo.operandTypes[operandIndex];\n return actual?.operandIndex !== operandIndex\n || actual.role !== role\n || actual.expectedType !== expectedType\n || actual.modifier !== \"none\"\n || actual.minPrecision !== \"default\";\n }))\n {\n throw new Error(`WGSL compute instruction ${instruction.index} has inconsistent type metadata`);\n }\n\n const required = [];\n for (const read of instruction.dataflow.reads)\n {\n if (read.kind !== \"register-read\")\n {\n throw new Error(`WGSL compute instruction ${instruction.index} has unsupported index-read type metadata`);\n }\n const expected = operandTypes[read.operandIndex]?.[1];\n if (!expected || expected === \"unknown\") continue;\n read.refs.forEach((ref, componentIndex) =>\n {\n const value = program.values.find((entry) => entry.id === ref.valueId);\n const storage = valueStorageType(value, ref.component);\n if (storage !== expected)\n {\n required.push({\n kind: \"read-bitcast\",\n operandIndex: read.operandIndex,\n componentIndex,\n valueId: ref.valueId,\n component: ref.component,\n from: storage,\n to: expected\n });\n }\n });\n }\n if (resultType !== \"unknown\")\n {\n for (const write of instruction.dataflow.writes)\n {\n for (const component of write.mask)\n {\n const value = program.values.find((entry) => entry.id === write.valueId);\n const storage = valueStorageType(value, component);\n if (storage !== resultType)\n {\n required.push({\n kind: \"result-bitcast\",\n operandIndex: write.operandIndex,\n valueId: write.valueId,\n component,\n from: resultType,\n to: storage\n });\n }\n }\n }\n }\n operandTypes.forEach(([, expectedType ], operandIndex) =>\n {\n const operand = instruction.operands[operandIndex];\n if (operand?.typeName !== \"immediate32\" || expectedType !== \"int32\") return;\n operand.immediateValues.forEach((value, componentIndex) =>\n {\n required.push({\n kind: \"immediate-bitcast\",\n operandIndex,\n component: COMPONENTS[componentIndex],\n from: \"uint32\",\n to: \"int32\",\n uint32: value.uint32 >>> 0\n });\n });\n });\n const requiredKeys = required.map(bitcastKey).sort();\n const actualKeys = (typeInfo.bitcasts || []).map(bitcastKey).sort();\n if (new Set(actualKeys).size !== actualKeys.length\n || requiredKeys.length !== actualKeys.length\n || requiredKeys.some((entry, index) => entry !== actualKeys[index]))\n {\n throw new Error(`WGSL compute instruction ${instruction.index} has inconsistent bitcast metadata`);\n }\n}\n\nfunction bindingRegister(binding)\n{\n return binding.range?.lowerBound ?? binding.registerIndex;\n}\n\nfunction bindingSpace(binding)\n{\n return binding.range?.registerSpace ?? 0;\n}\n\nfunction bindingIdentity(binding)\n{\n return `${binding.resourceKind}:${bindingSpace(binding)}:${bindingRegister(binding)}`;\n}\n\nfunction validateBindingRange(binding)\n{\n const registerIndex = binding.registerIndex;\n const range = binding.range;\n if (!Number.isInteger(registerIndex) || registerIndex < 0\n || range?.bindingModel !== \"sm5.0-register\"\n || range.rangeId !== null\n || range.lowerBound !== registerIndex\n || range.upperBound !== registerIndex\n || range.unbounded !== false\n || range.registerCount !== 1\n || range.registerSpace !== 0)\n {\n throw new Error(`WGSL compute binding ${binding.id || \"<unknown>\"} requires one fixed SM5.0 register`);\n }\n}\n\nfunction validateBindingDeclaration(program, binding, opcodeName, operandType, returnType)\n{\n const declarations = program.declarations.filter((entry) =>\n entry.dxbcOffset === binding.declarationOffset);\n if (declarations.length !== 1 || declarations[0].opcodeName !== opcodeName)\n {\n throw new Error(`WGSL compute binding ${binding.id} has inconsistent declaration identity`);\n }\n const declaration = declarations[0];\n const data = declaration.data;\n const operand = declaration.operands?.[0];\n validateReturnTypeMirror(\n binding.returnType,\n `WGSL compute binding ${binding.id}`);\n validateReturnTypeMirror(\n data?.returnType,\n `WGSL compute declaration at DXBC offset ${declaration.dxbcOffset}`);\n validateBindingRange(binding);\n if (binding.operandType !== operandType\n || binding.resourceDimension !== \"buffer\"\n || binding.structureStride !== null\n || binding.accessPattern !== null\n || binding.returnType?.returnTypeNames?.length !== 4\n || binding.returnType.returnTypeNames.some((entry) => entry !== returnType)\n || data?.registerIndex !== binding.registerIndex\n || data.resourceDimensionName !== \"buffer\"\n || (opcodeName === \"dcl_resource\" && data.sampleCount !== 0)\n || (opcodeName === \"dcl_unordered_access_view_typed\"\n && data.globallyCoherent !== false)\n || data.returnType?.returnTypeNames?.length !== 4\n || data.returnType.returnTypeNames.some((entry) => entry !== returnType)\n || declaration.operands?.length !== 1)\n {\n throw new Error(`WGSL compute binding ${binding.id} has an unsupported typed-buffer declaration`);\n }\n validateFixedRegisterOperand(\n operand,\n { index: `declaration@${declaration.dxbcOffset}` },\n 0,\n operandType);\n if (operand.componentCount !== 0 || operand.mask || operand.swizzle || operand.selected)\n {\n throw new Error(`WGSL compute binding ${binding.id} declaration has a malformed handle operand`);\n }\n}\n\nfunction portableBinding(binding)\n{\n return {\n identity: binding.identity,\n resourceKind: binding.resourceKind,\n generatedSymbol: binding.generatedSymbol,\n registerSpace: binding.registerSpace,\n registerIndex: binding.registerIndex,\n type: binding.type,\n buffer: binding.buffer\n };\n}\n\nfunction applyBindingPlan(bindings, bindingPlan)\n{\n if (bindingPlan === null || bindingPlan === undefined) return bindings;\n if (bindingPlan?.format !== \"CJS_WGSL_BINDING_PLAN\"\n || bindingPlan.formatVersion !== 2\n || !Array.isArray(bindingPlan.bindings)\n || bindingPlan.bindings.length !== bindings.length)\n {\n throw new TypeError(\"WGSL compute binding plan must provide exact version 2 compute coverage\");\n }\n const planned = new Map();\n const slots = new Set();\n for (const entry of bindingPlan.bindings)\n {\n const identity = `${entry.resourceKind}:${entry.registerSpace}:${entry.registerIndex}`;\n const slot = `${entry.group}:${entry.binding}`;\n if (entry.identity !== identity\n || entry.scopeIdentity !== `${identity}@compute`\n || entry.stages?.length !== 1 || entry.stages[0] !== \"compute\"\n || !Number.isInteger(entry.group) || entry.group < 0\n || !Number.isInteger(entry.binding) || entry.binding < 0\n || planned.has(identity) || slots.has(slot))\n {\n throw new Error(`WGSL compute binding plan contains an invalid entry ${entry.identity || identity}`);\n }\n planned.set(identity, entry);\n slots.add(slot);\n }\n return bindings.map((binding) =>\n {\n const entry = planned.get(binding.identity);\n if (!entry\n || JSON.stringify(portableBinding(binding)) !== JSON.stringify({\n identity: entry.identity,\n resourceKind: entry.resourceKind,\n generatedSymbol: entry.generatedSymbol,\n registerSpace: entry.registerSpace,\n registerIndex: entry.registerIndex,\n type: entry.type,\n buffer: entry.buffer\n }))\n {\n throw new Error(`WGSL compute binding plan layout for ${binding.identity} does not match the shader declaration`);\n }\n return { ...binding, scopeIdentity: entry.scopeIdentity, group: entry.group, binding: entry.binding };\n });\n}\n\n/**\n * Lowers the two scalar typed-buffer bindings used by the first compute slice.\n *\n * @param {object} program Frozen CJS shader IR.\n * @param {object|null} [bindingPlan] Optional exact compute-only binding plan.\n * @returns {object[]} Frozen WebGPU binding records.\n */\nexport function lowerComputeBindingLayout(program, bindingPlan = null)\n{\n if (program?.format !== \"CJS_SHADER_IR\" || program.formatVersion !== 1)\n {\n throw new TypeError(\"WGSL compute binding lowering expects CJS_SHADER_IR version 1 input\");\n }\n const bindings = Array.from(program.bindings || []).sort((left, right) =>\n bindingSpace(left) - bindingSpace(right)\n || (KIND_ORDER[left.resourceKind] ?? 99) - (KIND_ORDER[right.resourceKind] ?? 99)\n || bindingRegister(left) - bindingRegister(right)\n || left.declarationOffset - right.declarationOffset);\n if (bindings.length !== 2\n || bindings.filter((entry) => entry.resourceKind === \"sampled-resource\").length !== 1\n || bindings.filter((entry) => entry.resourceKind === \"storage-resource\").length !== 1)\n {\n throw new Error(\"WGSL compute body slice requires exactly one typed SRV and one typed UAV\");\n }\n const identities = new Set();\n const lowered = bindings.map((binding, bindingIndex) =>\n {\n const identity = bindingIdentity(binding);\n if (identities.has(identity))\n {\n throw new Error(`WGSL compute binding layout contains duplicate ${identity}`);\n }\n identities.add(identity);\n const sampled = binding.resourceKind === \"sampled-resource\";\n validateBindingDeclaration(\n program,\n binding,\n sampled ? \"dcl_resource\" : \"dcl_unordered_access_view_typed\",\n sampled ? \"resource\" : \"uav\",\n sampled ? \"sint\" : \"uint\");\n const registerIndex = bindingRegister(binding);\n const registerSpace = bindingSpace(binding);\n return {\n kind: \"wgsl-binding\",\n id: binding.id,\n identity,\n scopeIdentity: `${identity}@compute`,\n resourceKind: binding.resourceKind,\n generatedSymbol: `${KIND_PREFIX[binding.resourceKind]}${registerIndex}`,\n registerSpace,\n registerIndex,\n rangeId: null,\n group: 0,\n binding: bindingIndex,\n visibility: \"compute\",\n declarationOffset: binding.declarationOffset,\n declaration: sampled ? \"var<storage, read>\" : \"var<storage, read_write>\",\n type: sampled ? \"array<i32>\" : \"array<atomic<u32>>\",\n buffer: {\n type: sampled ? \"read-only-storage\" : \"storage\",\n hasDynamicOffset: false,\n minBindingSize: 4\n }\n };\n });\n return deepFreeze(applyBindingPlan(lowered, bindingPlan));\n}\n\nfunction bindingForOperand(bindings, resourceKind, operand, instruction, operandIndex)\n{\n validateFixedHandleOperand(instruction, operandIndex, operand.typeName, \"compute\");\n const matches = bindings.filter((entry) =>\n entry.resourceKind === resourceKind\n && entry.registerIndex === operand.registerIndex\n && entry.registerSpace === 0);\n if (matches.length !== 1)\n {\n throw new Error(`WGSL compute instruction ${instruction.index} has an unresolved ${resourceKind} binding`);\n }\n return validateFixedHandleBinding(operand, matches[0], \"compute\");\n}\n\nfunction validateProgramShape(program)\n{\n if (program?.format !== \"CJS_SHADER_IR\" || program.formatVersion !== 1)\n {\n throw new TypeError(\"WGSL compute lowering expects CJS_SHADER_IR version 1 input\");\n }\n if (program.stage !== \"compute\") throw new Error(`WGSL compute lowering cannot lower ${program.stage}`);\n if (program.shaderModel?.major !== 5 || program.shaderModel.minor !== 0)\n {\n throw new Error(\"WGSL compute body slice currently supports only SM5.0\");\n }\n if ((program.signatures?.input || []).length\n || (program.signatures?.output || []).length\n || (program.signatures?.patch || []).length\n || program.immediateConstantBuffer\n || program.constTables)\n {\n throw new Error(\"WGSL compute body slice does not support signatures or constant tables\");\n }\n if (program.declarations?.length !== DECLARATION_OPCODES.length\n || DECLARATION_OPCODES.some((opcodeName, index) =>\n program.declarations[index]?.opcodeName !== opcodeName))\n {\n throw new Error(\"WGSL compute declaration shape is not supported; the bounded body slice requires canonical global/SRV/UAV/temp/thread-group declarations\");\n }\n const temp = program.declarations[3];\n const group = program.declarations[4];\n if (temp.data?.tempCount !== 1\n || group.data?.threadGroupX !== 1\n || group.data?.threadGroupY !== 1\n || group.data?.threadGroupZ !== 1)\n {\n throw new Error(\"WGSL compute body slice requires one temporary and dcl_thread_group 1,1,1\");\n }\n requireRefactoringAllowed(program, \"compute\");\n if (!Array.isArray(program.instructions) || program.instructions.length < 2\n || program.instructions.at(-1)?.opcodeName !== \"ret\"\n || program.instructions.slice(0, -1).some((instruction) => instruction.opcodeName === \"ret\")\n || program.instructions.some((instruction) => !SUPPORTED_OPCODES.has(instruction.opcodeName))\n || program.instructions.some((instruction, index) =>\n instruction.index !== index\n || (index > 0 && instruction.dxbcOffset <= program.instructions[index - 1].dxbcOffset)))\n {\n throw new Error(\"WGSL compute body slice requires one straight-line supported instruction sequence ending in ret\");\n }\n const block = program.blocks?.[0];\n if (program.blocks?.length !== 1\n || block.id !== \"block0\" || block.index !== 0\n || block.startInstruction !== 0\n || block.endInstruction !== program.instructions.length - 1\n || block.terminator !== \"ret\"\n || block.reachable === false\n || block.successors?.length || block.predecessors?.length\n || block.mergeSite !== null\n || block.inputValueIds?.length\n || block.instructionIndices?.length !== program.instructions.length\n || block.instructionIndices.some((value, index) => value !== index))\n {\n throw new Error(\"WGSL compute body slice requires one canonical reachable return block\");\n }\n}\n\nfunction validateInstructionEnvelope(instruction)\n{\n const isReturn = instruction.opcodeName === \"ret\";\n if (instruction.controlKind !== (isReturn ? \"termination\" : null)\n || instruction.testBoolean !== null\n || instruction.saturate\n || instruction.preciseMask !== \"\"\n || (instruction.opcodeName !== \"ld\" && instruction.extensions?.length))\n {\n throw new Error(`WGSL compute instruction ${instruction.index} has unsupported control, modifier, or extension metadata`);\n }\n for (let operandIndex = 0; operandIndex < instruction.operands.length; operandIndex += 1)\n {\n validateCommonOperand(instruction.operands[operandIndex], instruction, operandIndex);\n }\n}\n\nfunction validateLoadExtensions(instruction)\n{\n const extensions = instruction.extensions || [];\n validateSm50ResourceExtensions(extensions, {\n resourceDimension: 1,\n resourceDimensionName: \"buffer\",\n structureStride: 0,\n resourceReturnTypes: [ 3, 3, 3, 3 ]\n }, `WGSL compute load instruction ${instruction.index}`);\n}\n\nfunction validateNullHighDestination(instruction)\n{\n const operand = instruction.operands[0];\n validateCommonOperand(operand, instruction, 0);\n if (operand.typeName !== \"null\"\n || operand.componentCount !== 0\n || operand.registerIndex !== null\n || operand.indices?.length\n || operand.mask || operand.swizzle || operand.selected\n || operand.immediateValues?.length)\n {\n throw new Error(`WGSL compute imul instruction ${instruction.index} requires a null high destination`);\n }\n}\n\nfunction seedRegisterState(program)\n{\n const state = new Map();\n const valueIds = new Set();\n for (const value of program.values || [])\n {\n if (valueIds.has(value.id))\n {\n throw new Error(`WGSL compute program contains duplicate value ${value.id}`);\n }\n valueIds.add(value.id);\n if (![ \"undefined-register\", \"instruction-write\" ].includes(value.origin)\n || value.register !== \"temp[0]\"\n || value.writeMask.length !== 1\n || !COMPONENTS.includes(value.writeMask)\n || Object.keys(value.componentTypes || {}).length !== 1\n || (value.origin === \"instruction-write\"\n ? !scalarTypeName(value.componentTypes[value.writeMask])\n : value.componentTypes[value.writeMask] !== \"unknown\"))\n {\n throw new Error(`WGSL compute value ${value.id} is outside the bounded temp[0] scalar slice`);\n }\n if (value.origin === \"undefined-register\")\n {\n if (value.instructionIndex !== null || value.blockId !== null || value.previous !== null)\n {\n throw new Error(`WGSL compute undefined value ${value.id} has inconsistent origin metadata`);\n }\n const key = `${value.register}.${value.writeMask}`;\n if (state.has(key))\n {\n throw new Error(`WGSL compute program contains duplicate undefined ${key}`);\n }\n state.set(key, { valueId: value.id, component: value.writeMask });\n }\n else if (value.blockId !== \"block0\")\n {\n throw new Error(`WGSL compute instruction value ${value.id} belongs to an unexpected block`);\n }\n }\n return state;\n}\n\nfunction validateBlockOutput(program, state)\n{\n const outputs = program.blocks[0].outputValues || [];\n const expected = Array.from(state, ([ key, ref ]) =>\n {\n const split = key.lastIndexOf(\".\");\n return { register: key.slice(0, split), component: key.slice(split + 1), ref };\n }).sort((left, right) =>\n left.register.localeCompare(right.register) || left.component.localeCompare(right.component));\n const actual = outputs.slice().sort((left, right) =>\n left.register.localeCompare(right.register) || left.component.localeCompare(right.component));\n if (actual.length !== expected.length\n || expected.some((entry, index) =>\n actual[index]?.register !== entry.register\n || actual[index]?.component !== entry.component\n || !sameRef(actual[index]?.ref, entry.ref)))\n {\n throw new Error(\"WGSL compute block output does not match the final scalar register state\");\n }\n}\n\n/**\n * Lowers the bounded setdrawparameters/setsortargs compute slice into typed SSA.\n *\n * @param {object} program Frozen CJS shader IR.\n * @param {object} [options] Optional exact compute-only binding plan.\n * @returns {object} Frozen typed compute program.\n */\nfunction lowerScalarWordComputeProgram(program, options = {})\n{\n validateProgramShape(program);\n const bindings = lowerComputeBindingLayout(program, options.bindingPlan ?? null);\n const state = seedRegisterState(program);\n const writtenValueIds = new Set();\n const statements = [];\n\n for (const instruction of program.instructions)\n {\n validateInstructionEnvelope(instruction);\n validateTypeInfo(program, instruction);\n const expectedReads = new Set();\n\n if (instruction.opcodeName === \"ret\")\n {\n if (instruction.operands.length || instruction.dataflow.reads.length || instruction.dataflow.writes.length)\n {\n throw new Error(`WGSL compute return instruction ${instruction.index} must be operand-free`);\n }\n statements.push({\n kind: \"return\",\n instructionIndex: instruction.index,\n dxbcOffset: instruction.dxbcOffset\n });\n continue;\n }\n\n if (instruction.opcodeName === \"ld\")\n {\n if (instruction.operands.length !== 3)\n {\n throw new Error(`WGSL compute load instruction ${instruction.index} requires three operands`);\n }\n validateLoadExtensions(instruction);\n const destination = instruction.operands[0];\n validateDestinationOperand(destination, instruction, 0);\n if (destination.mask !== \"x\")\n {\n throw new Error(`WGSL compute load instruction ${instruction.index} scalar-word profile requires the x destination lane`);\n }\n const address = immediateCode(\n immediateBits(instruction.operands[1], instruction, 1, true),\n \"uint32\");\n const resource = validateFixedRegisterOperand(\n instruction.operands[2], instruction, 2, \"resource\");\n if (resource.componentCount !== 4 || resource.swizzle !== \"xyzw\"\n || resource.mask || resource.selected)\n {\n throw new Error(`WGSL compute load instruction ${instruction.index} requires a canonical xyzw resource selection`);\n }\n const binding = bindingForOperand(\n bindings, \"sampled-resource\", resource, instruction, 2);\n const { write, value } = validateWrite(\n program, instruction, 0, destination, state, writtenValueIds);\n validateNoUnexpectedReads(instruction, expectedReads);\n const length = `arrayLength(&${binding.generatedSymbol})`;\n const intrinsic = `select(0i, ${binding.generatedSymbol}[min(${address}, ${length} - 1u)], ${address} < ${length})`;\n const storage = valueStorageType(value, write.mask);\n statements.push({\n kind: \"let\",\n instructionIndex: instruction.index,\n dxbcOffset: instruction.dxbcOffset,\n name: value.id,\n type: scalarTypeName(storage),\n expression: {\n code: reinterpretCode(intrinsic, \"int32\", storage),\n type: scalarTypeName(storage)\n }\n });\n continue;\n }\n\n const arithmetic = ARITHMETIC_RULES[instruction.opcodeName];\n if (arithmetic)\n {\n if (instruction.operands.length !== (instruction.opcodeName === \"imul\" ? 4 : 3))\n {\n throw new Error(`WGSL compute ${instruction.opcodeName} instruction ${instruction.index} has an unsupported operand count`);\n }\n if (instruction.opcodeName === \"imul\") validateNullHighDestination(instruction);\n const destination = instruction.operands[arithmetic.destinationOperand];\n validateDestinationOperand(destination, instruction, arithmetic.destinationOperand);\n const sources = arithmetic.sourceOperands.map((operandIndex) =>\n readCode(program, instruction, operandIndex, arithmetic.sourceType, state, expectedReads));\n validateNoUnexpectedReads(instruction, expectedReads);\n const intrinsic = arithmetic.functionName\n ? `${arithmetic.functionName}(${sources.join(\", \")})`\n : `(${sources[0]} ${arithmetic.operator} ${sources[1]})`;\n const { write, value } = validateWrite(\n program, instruction, arithmetic.destinationOperand,\n destination, state, writtenValueIds);\n const storage = valueStorageType(value, write.mask);\n statements.push({\n kind: \"let\",\n instructionIndex: instruction.index,\n dxbcOffset: instruction.dxbcOffset,\n name: value.id,\n type: scalarTypeName(storage),\n expression: {\n code: reinterpretCode(intrinsic, arithmetic.resultType, storage),\n type: scalarTypeName(storage)\n }\n });\n continue;\n }\n\n if (instruction.opcodeName === \"store_uav_typed\")\n {\n if (instruction.operands.length !== 3 || instruction.dataflow.writes.length)\n {\n throw new Error(`WGSL compute store instruction ${instruction.index} requires three source operands`);\n }\n const uav = validateFixedRegisterOperand(\n instruction.operands[0], instruction, 0, \"uav\");\n if (uav.componentCount !== 4 || uav.mask !== \"xyzw\"\n || uav.swizzle || uav.selected)\n {\n throw new Error(`WGSL compute store instruction ${instruction.index} requires a full xyzw UAV mask`);\n }\n const binding = bindingForOperand(\n bindings, \"storage-resource\", uav, instruction, 0);\n const address = immediateCode(\n immediateBits(instruction.operands[1], instruction, 1, true),\n \"uint32\");\n const value = replicatedStoreCode(\n program, instruction, 2, state, expectedReads);\n validateNoUnexpectedReads(instruction, expectedReads);\n statements.push({\n kind: \"if\",\n instructionIndex: instruction.index,\n dxbcOffset: instruction.dxbcOffset,\n condition: {\n code: `${address} < arrayLength(&${binding.generatedSymbol})`,\n type: \"bool\"\n },\n statements: [ {\n kind: \"call\",\n instructionIndex: instruction.index,\n dxbcOffset: instruction.dxbcOffset,\n expression: {\n code: `atomicStore(&${binding.generatedSymbol}[${address}], ${value})`,\n type: \"void\"\n }\n } ]\n });\n }\n }\n\n if (writtenValueIds.size !== program.values.filter((value) =>\n value.origin === \"instruction-write\").length)\n {\n throw new Error(\"WGSL compute program contains an unowned instruction-write value\");\n }\n validateBlockOutput(program, state);\n return deepFreeze({\n kind: \"typed-shader-program\",\n format: \"CJS_TYPED_SHADER\",\n formatVersion: 1,\n source: program.source,\n stage: \"compute\",\n entryPoint: \"main\",\n threadGroupSize: [ 1, 1, 1 ],\n bindings,\n statements\n });\n}\n\n/**\n * Routes one compute program to an exact declaration-shaped lowering profile.\n * Once a profile is selected its validation errors are final; malformed input\n * never falls through to a broader profile.\n *\n * @param {object} program Frozen CJS shader IR.\n * @param {object} [options] Optional exact compute-only binding plan.\n * @returns {object} Frozen typed compute program.\n */\nexport function lowerComputeProgram(program, options = {})\n{\n validateExactComputeEnvelope(program, \"WGSL compute\");\n if (isParticleClearResetCandidate(program))\n {\n return lowerParticleClearResetComputeProgram(program, options);\n }\n if (isParticleClearInitializeCandidate(program))\n {\n return lowerParticleClearInitializeComputeProgram(program, options);\n }\n if (isParticleEmitComputeCandidate(program))\n {\n return lowerParticleEmitComputeProgram(program, options);\n }\n if (isCreateHistogramsComputeProfile(program))\n {\n return lowerCreateHistogramsComputeProgram(program, options);\n }\n if (isMergeHistogramsComputeProfile(program))\n {\n return lowerMergeHistogramsComputeProgram(program, options);\n }\n if (isSortComputeProfile(program))\n {\n return lowerSortComputeProgram(program, options);\n }\n if (isSortInnerComputeProfile(program))\n {\n return lowerSortInnerComputeProgram(program, options);\n }\n if (isSortStepComputeProfile(program))\n {\n return lowerSortStepComputeProgram(program, options);\n }\n if (isSkinVerticesComputeProfile(program))\n {\n return lowerSkinVerticesComputeProgram(program, options);\n }\n return lowerScalarWordComputeProgram(program, options);\n}\n"],"names":["COMPONENTS","Object","freeze","DECLARATION_OPCODES","ARITHMETIC_RULES","imul","rule","resultType","destinationOperand","sourceOperands","sourceType","operator","umax","functionName","iadd","ushr","SUPPORTED_OPCODES","Set","keys","KIND_ORDER","KIND_PREFIX","deepFreeze","value","isFrozen","entry","values","scalarTypeName","type","int32","uint32","bitpattern32","canonicalRef","ref","valueId","component","sameRef","left","right","registerKey","operand","typeName","registerIndex","validateCommonOperand","instruction","operandIndex","modifierName","minPrecisionName","nonUniform","Error","index","validateFixedRegisterOperand","indices","Number","isInteger","length","relative","validateDestinationOperand","componentCount","includes","mask","swizzle","selected","validateScalarTempSource","immediateBits","replicated","immediateValues","some","bits","map","immediateCode","literal","toString","padStart","validateValueRef","program","expectedRegister","expectedComponent","find","id","register","writeMask","origin","validateRead","components","state","expectedReads","matches","dataflow","reads","filter","kind","read","refs","get","forEach","add","validateNoUnexpectedReads","size","has","validateWrite","writtenValueIds","writes","write","instructionIndex","previousComponents","previous","sort","join","slice","result","set","valueStorageType","componentTypes","reinterpretCode","code","fromType","toType","from","to","readCode","expectedType","operands","replicatedStoreCode","Array","fill","expectedOperandTypes","opcodeName","arithmetic","_","expectedRule","bitcastKey","componentIndex","validateTypeInfo","operandTypes","typeInfo","conversion","conditionProjection","role","actual","modifier","minPrecision","required","expected","storage","push","requiredKeys","actualKeys","bitcasts","bindingRegister","binding","range","lowerBound","bindingSpace","registerSpace","bindingIdentity","resourceKind","validateBindingRange","bindingModel","rangeId","upperBound","unbounded","registerCount","validateBindingDeclaration","operandType","returnType","declarations","dxbcOffset","declarationOffset","declaration","data","validateReturnTypeMirror","resourceDimension","structureStride","accessPattern","returnTypeNames","resourceDimensionName","sampleCount","globallyCoherent","portableBinding","identity","generatedSymbol","buffer","applyBindingPlan","bindings","bindingPlan","undefined","format","formatVersion","isArray","TypeError","planned","Map","slots","slot","group","scopeIdentity","stages","JSON","stringify","lowerComputeBindingLayout","identities","lowered","bindingIndex","sampled","visibility","hasDynamicOffset","minBindingSize","bindingForOperand","validateFixedHandleOperand","validateFixedHandleBinding","validateProgramShape","stage","shaderModel","major","minor","signatures","input","output","patch","immediateConstantBuffer","constTables","temp","tempCount","threadGroupX","threadGroupY","threadGroupZ","requireRefactoringAllowed","instructions","at","block","blocks","startInstruction","endInstruction","terminator","reachable","successors","predecessors","mergeSite","inputValueIds","instructionIndices","validateInstructionEnvelope","isReturn","controlKind","testBoolean","saturate","preciseMask","extensions","validateLoadExtensions","validateSm50ResourceExtensions","resourceReturnTypes","validateNullHighDestination","seedRegisterState","valueIds","blockId","key","validateBlockOutput","outputs","outputValues","split","lastIndexOf","localeCompare","lowerScalarWordComputeProgram","options","statements","destination","address","resource","intrinsic","name","expression","sources","uav","condition","source","entryPoint","threadGroupSize","lowerComputeProgram","validateExactComputeEnvelope","isParticleClearResetCandidate","lowerParticleClearResetComputeProgram","isParticleClearInitializeCandidate","lowerParticleClearInitializeComputeProgram","isParticleEmitComputeCandidate","lowerParticleEmitComputeProgram","isCreateHistogramsComputeProfile","lowerCreateHistogramsComputeProgram","isMergeHistogramsComputeProfile","lowerMergeHistogramsComputeProgram","isSortComputeProfile","lowerSortComputeProgram","isSortInnerComputeProfile","lowerSortInnerComputeProgram","isSortStepComputeProfile","lowerSortStepComputeProgram","isSkinVerticesComputeProfile","lowerSkinVerticesComputeProgram"],"mappings":";;;;;;;;;;;;AA0CA,MAAMA,UAAU,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE,CAAC;AACxD,MAAMC,mBAAmB,GAAGF,MAAM,CAACC,MAAM,CAAC,CACtC,kBAAkB,EAClB,cAAc,EACd,iCAAiC,EACjC,WAAW,EACX,kBAAkB,CACrB,CAAC;AACF,MAAME,gBAAgB,GAAGH,MAAM,CAACC,MAAM,CAAC;AACnCG,EAAAA,IAAI,EAAEJ,MAAM,CAACC,MAAM,CAAC;AAChBI,IAAAA,IAAI,EAAE,gBAAgB;AACtBC,IAAAA,UAAU,EAAE,OAAO;AACnBC,IAAAA,kBAAkB,EAAE,CAAC;IACrBC,cAAc,EAAER,MAAM,CAACC,MAAM,CAAC,CAAE,CAAC,EAAE,CAAC,CAAE,CAAC;AACvCQ,IAAAA,UAAU,EAAE,OAAO;AACnBC,IAAAA,QAAQ,EAAE;AACd,GAAC,CAAC;AACFC,EAAAA,IAAI,EAAEX,MAAM,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OuN,uBAAuB,CAACvN,OAAO,EAAE4L,OAAO,CAAC;AACpD,EAAA;AACA,EAAA,IAAI4B,yBAAyB,CAACxN,OAAO,CAAC,EACtC;AACI,IAAA,OAAOyN,4BAA4B,CAACzN,OAAO,EAAE4L,OAAO,CAAC;AACzD,EAAA;AACA,EAAA,IAAI8B,wBAAwB,CAAC1N,OAAO,CAAC,EACrC;AACI,IAAA,OAAO2N,2BAA2B,CAAC3N,OAAO,EAAE4L,OAAO,CAAC;AACxD,EAAA;AACA,EAAA,IAAIgC,4BAA4B,CAAC5N,OAAO,CAAC,EACzC;AACI,IAAA,OAAO6N,+BAA+B,CAAC7N,OAAO,EAAE4L,OAAO,CAAC;AAC5D,EAAA;AACA,EAAA,OAAOD,6BAA6B,CAAC3L,OAAO,EAAE4L,OAAO,CAAC;AAC1D;;;;"}
1
+ {"version":3,"file":"lowerComputeProgram.js","sources":["../../../../../../src/formats/webgpu/core/wgsl/lowerComputeProgram.js"],"sourcesContent":["import { requireRefactoringAllowed } from \"./precisionControls.js\";\r\nimport {\r\n validateExactComputeEnvelope,\r\n validateReturnTypeMirror,\r\n validateSm50ResourceExtensions\r\n} from \"./validateExactComputeIr.js\";\r\nimport { validateFixedHandleBinding, validateFixedHandleOperand } from \"./validateHandleOperand.js\";\r\nimport { compareUtf8 } from \"../../../../format/compareUtf8.js\";\r\nimport {\r\n isSkinVerticesComputeProfile,\r\n lowerSkinVerticesComputeProgram\r\n} from \"./lowerSkinVerticesComputeProgram.js\";\r\nimport {\r\n isCreateHistogramsComputeProfile,\r\n lowerCreateHistogramsComputeProgram\r\n} from \"./lowerCreateHistogramsComputeProgram.js\";\r\nimport {\r\n isMergeHistogramsComputeProfile,\r\n lowerMergeHistogramsComputeProgram\r\n} from \"./lowerMergeHistogramsComputeProgram.js\";\r\nimport {\r\n isParticleClearInitializeCandidate,\r\n isParticleClearResetCandidate,\r\n lowerParticleClearInitializeComputeProgram,\r\n lowerParticleClearResetComputeProgram\r\n} from \"./lowerParticleClearComputePrograms.js\";\r\nimport {\r\n isParticleEmitComputeCandidate,\r\n lowerParticleEmitComputeProgram\r\n} from \"./lowerParticleEmitComputeProgram.js\";\r\nimport {\r\n isSortStepComputeProfile,\r\n lowerSortStepComputeProgram\r\n} from \"./lowerSortStepComputeProgram.js\";\r\nimport {\r\n isSortComputeProfile,\r\n lowerSortComputeProgram\r\n} from \"./lowerSortComputeProgram.js\";\r\nimport {\r\n isSortInnerComputeProfile,\r\n lowerSortInnerComputeProgram\r\n} from \"./lowerSortInnerComputeProgram.js\";\r\n\r\nconst COMPONENTS = Object.freeze([ \"x\", \"y\", \"z\", \"w\" ]);\r\nconst DECLARATION_OPCODES = Object.freeze([\r\n \"dcl_global_flags\",\r\n \"dcl_resource\",\r\n \"dcl_unordered_access_view_typed\",\r\n \"dcl_temps\",\r\n \"dcl_thread_group\"\r\n]);\r\nconst ARITHMETIC_RULES = Object.freeze({\r\n imul: Object.freeze({\r\n rule: \"signed-integer\",\r\n resultType: \"int32\",\r\n destinationOperand: 1,\r\n sourceOperands: Object.freeze([ 2, 3 ]),\r\n sourceType: \"int32\",\r\n operator: \"*\"\r\n }),\r\n umax: Object.freeze({\r\n rule: \"unsigned-integer\",\r\n resultType: \"uint32\",\r\n destinationOperand: 0,\r\n sourceOperands: Object.freeze([ 1, 2 ]),\r\n sourceType: \"uint32\",\r\n functionName: \"max\"\r\n }),\r\n iadd: Object.freeze({\r\n rule: \"signed-integer\",\r\n resultType: \"int32\",\r\n destinationOperand: 0,\r\n sourceOperands: Object.freeze([ 1, 2 ]),\r\n sourceType: \"int32\",\r\n operator: \"+\"\r\n }),\r\n ushr: Object.freeze({\r\n rule: \"unsigned-integer\",\r\n resultType: \"uint32\",\r\n destinationOperand: 0,\r\n sourceOperands: Object.freeze([ 1, 2 ]),\r\n sourceType: \"uint32\",\r\n operator: \">>\"\r\n })\r\n});\r\nconst SUPPORTED_OPCODES = new Set([\r\n \"ld\", ...Object.keys(ARITHMETIC_RULES), \"store_uav_typed\", \"ret\"\r\n]);\r\nconst KIND_ORDER = Object.freeze({ \"sampled-resource\": 0, \"storage-resource\": 1 });\r\nconst KIND_PREFIX = Object.freeze({ \"sampled-resource\": \"t\", \"storage-resource\": \"u\" });\r\n\r\nfunction deepFreeze(value)\r\n{\r\n if (!value || typeof value !== \"object\" || Object.isFrozen(value)) return value;\r\n for (const entry of Object.values(value)) deepFreeze(entry);\r\n return Object.freeze(value);\r\n}\r\n\r\nfunction scalarTypeName(type)\r\n{\r\n return ({ int32: \"i32\", uint32: \"u32\", bitpattern32: \"u32\" })[type] || null;\r\n}\r\n\r\nfunction canonicalRef(ref)\r\n{\r\n return `${ref?.valueId || \"\"}.${ref?.component || \"\"}`;\r\n}\r\n\r\nfunction sameRef(left, right)\r\n{\r\n return canonicalRef(left) === canonicalRef(right);\r\n}\r\n\r\nfunction registerKey(operand)\r\n{\r\n return `${operand.typeName}[${operand.registerIndex}]`;\r\n}\r\n\r\nfunction validateCommonOperand(operand, instruction, operandIndex)\r\n{\r\n if (!operand\r\n || (operand.modifierName ?? \"none\") !== \"none\"\r\n || (operand.minPrecisionName ?? \"default\") !== \"default\"\r\n || operand.nonUniform === true)\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} requires an unmodified, uniform, default-precision operand ${operandIndex}`);\r\n }\r\n}\r\n\r\nfunction validateFixedRegisterOperand(operand, instruction, operandIndex, typeName)\r\n{\r\n validateCommonOperand(operand, instruction, operandIndex);\r\n const index = operand.indices?.[0];\r\n if (operand.typeName !== typeName\r\n || !Number.isInteger(operand.registerIndex) || operand.registerIndex < 0\r\n || operand.indices?.length !== 1\r\n || index?.relative\r\n || index?.values?.length !== 1\r\n || index.values[0] !== operand.registerIndex)\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} operand ${operandIndex} has an invalid fixed ${typeName} identity`);\r\n }\r\n return operand;\r\n}\r\n\r\nfunction validateDestinationOperand(operand, instruction, operandIndex)\r\n{\r\n validateFixedRegisterOperand(operand, instruction, operandIndex, \"temp\");\r\n if (operand.registerIndex !== 0\r\n || operand.componentCount !== 4\r\n || !COMPONENTS.includes(operand.mask)\r\n || operand.swizzle || operand.selected)\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} operand ${operandIndex} requires one canonical temp[0] destination lane`);\r\n }\r\n return operand.mask;\r\n}\r\n\r\nfunction validateScalarTempSource(operand, instruction, operandIndex)\r\n{\r\n validateFixedRegisterOperand(operand, instruction, operandIndex, \"temp\");\r\n if (operand.registerIndex !== 0\r\n || operand.componentCount !== 4\r\n || !COMPONENTS.includes(operand.selected)\r\n || operand.mask || operand.swizzle)\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} operand ${operandIndex} requires one selected temp[0] source lane`);\r\n }\r\n return operand.selected;\r\n}\r\n\r\nfunction immediateBits(operand, instruction, operandIndex, replicated)\r\n{\r\n validateCommonOperand(operand, instruction, operandIndex);\r\n const values = operand.immediateValues || [];\r\n if (operand.typeName !== \"immediate32\"\r\n || operand.registerIndex !== null\r\n || operand.indices?.length\r\n || operand.mask || operand.swizzle || operand.selected\r\n || ![ 1, 4 ].includes(operand.componentCount)\r\n || values.length !== operand.componentCount\r\n || values.some((value) => !Number.isInteger(value?.uint32)))\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} operand ${operandIndex} requires canonical immediate32 data`);\r\n }\r\n const bits = values.map((value) => value.uint32 >>> 0);\r\n if (replicated && (bits.length !== 4 || bits.some((value) => value !== bits[0])))\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} operand ${operandIndex} requires four replicated immediate lanes`);\r\n }\r\n if (!replicated && bits.length !== 1)\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} operand ${operandIndex} requires one immediate lane`);\r\n }\r\n return bits[0];\r\n}\r\n\r\nfunction immediateCode(bits, type)\r\n{\r\n const literal = `0x${(bits >>> 0).toString(16).padStart(8, \"0\")}u`;\r\n return type === \"int32\" ? `bitcast<i32>(${literal})` : literal;\r\n}\r\n\r\nfunction validateValueRef(program, ref, expectedRegister, expectedComponent)\r\n{\r\n const value = program.values.find((entry) => entry.id === ref?.valueId);\r\n if (!value\r\n || value.register !== expectedRegister\r\n || ref.component !== expectedComponent\r\n || !value.writeMask.includes(expectedComponent))\r\n {\r\n throw new Error(`WGSL compute register dataflow references an incompatible ${expectedRegister}.${expectedComponent} value`);\r\n }\r\n if (value.origin === \"undefined-register\")\r\n {\r\n throw new Error(`WGSL compute reads undefined ${expectedRegister}.${expectedComponent}`);\r\n }\r\n return value;\r\n}\r\n\r\nfunction validateRead(program, instruction, operandIndex, operand, components, state, expectedReads)\r\n{\r\n const register = registerKey(operand);\r\n const matches = instruction.dataflow.reads.filter((entry) =>\r\n entry.kind === \"register-read\" && entry.operandIndex === operandIndex);\r\n if (matches.length !== 1)\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} has inconsistent read metadata for operand ${operandIndex}`);\r\n }\r\n const read = matches[0];\r\n if (read.register !== register\r\n || read.components?.length !== components.length\r\n || read.refs?.length !== components.length\r\n || components.some((component, index) =>\r\n read.components[index] !== component\r\n || !sameRef(read.refs[index], state.get(`${register}.${component}`))))\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} has stale or mismatched SSA reads for operand ${operandIndex}`);\r\n }\r\n components.forEach((component, index) =>\r\n validateValueRef(program, read.refs[index], register, component));\r\n expectedReads.add(read);\r\n return read;\r\n}\r\n\r\nfunction validateNoUnexpectedReads(instruction, expectedReads)\r\n{\r\n if (instruction.dataflow.reads.length !== expectedReads.size\r\n || instruction.dataflow.reads.some((read) => !expectedReads.has(read)))\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} has unexpected register or index reads`);\r\n }\r\n}\r\n\r\nfunction validateWrite(program, instruction, operandIndex, operand, state, writtenValueIds)\r\n{\r\n const writes = instruction.dataflow.writes;\r\n if (writes.length !== 1 || writes[0].operandIndex !== operandIndex)\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} requires one destination write at operand ${operandIndex}`);\r\n }\r\n const write = writes[0];\r\n const register = registerKey(operand);\r\n const component = operand.mask;\r\n const value = program.values.find((entry) => entry.id === write.valueId);\r\n if (write.register !== register || write.mask !== component\r\n || !value || value.origin !== \"instruction-write\"\r\n || value.instructionIndex !== instruction.index\r\n || value.register !== register || value.writeMask !== component\r\n || writtenValueIds.has(value.id))\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} has inconsistent destination SSA metadata`);\r\n }\r\n const previousComponents = COMPONENTS.filter((entry) => entry !== component);\r\n if (!write.previous\r\n || Object.keys(write.previous).sort().join(\"\") !== previousComponents.slice().sort().join(\"\")\r\n || previousComponents.some((entry) =>\r\n !sameRef(write.previous[entry], state.get(`${register}.${entry}`)))\r\n || Object.keys(write.result || {}).sort().join(\"\") !== COMPONENTS.slice().sort().join(\"\")\r\n || !sameRef(write.result[component], { valueId: value.id, component })\r\n || previousComponents.some((entry) =>\r\n !sameRef(write.result[entry], state.get(`${register}.${entry}`))))\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} has inconsistent previous/result SSA lanes`);\r\n }\r\n writtenValueIds.add(value.id);\r\n state.set(`${register}.${component}`, { valueId: value.id, component });\r\n return { write, value };\r\n}\r\n\r\nfunction valueStorageType(value, component)\r\n{\r\n const type = value?.componentTypes?.[component];\r\n if (!scalarTypeName(type))\r\n {\r\n throw new Error(`WGSL compute value ${value?.id || \"<missing>\"}.${component} has an unresolved type`);\r\n }\r\n return type;\r\n}\r\n\r\nfunction reinterpretCode(code, fromType, toType)\r\n{\r\n const from = scalarTypeName(fromType);\r\n const to = scalarTypeName(toType);\r\n if (!from || !to)\r\n {\r\n throw new Error(`WGSL compute cannot reinterpret ${fromType} to ${toType}`);\r\n }\r\n return from === to ? code : `bitcast<${to}>(${code})`;\r\n}\r\n\r\nfunction readCode(program, instruction, operandIndex, expectedType, state, expectedReads)\r\n{\r\n const operand = instruction.operands[operandIndex];\r\n if (operand?.typeName === \"immediate32\")\r\n {\r\n return immediateCode(immediateBits(operand, instruction, operandIndex, false), expectedType);\r\n }\r\n const component = validateScalarTempSource(operand, instruction, operandIndex);\r\n const read = validateRead(program, instruction, operandIndex, operand, [ component ], state, expectedReads);\r\n const value = validateValueRef(program, read.refs[0], read.register, component);\r\n return reinterpretCode(value.id, valueStorageType(value, component), expectedType);\r\n}\r\n\r\nfunction replicatedStoreCode(program, instruction, operandIndex, state, expectedReads)\r\n{\r\n const operand = instruction.operands[operandIndex];\r\n if (operand?.typeName === \"immediate32\")\r\n {\r\n return immediateCode(immediateBits(operand, instruction, operandIndex, true), \"uint32\");\r\n }\r\n validateFixedRegisterOperand(operand, instruction, operandIndex, \"temp\");\r\n if (operand.registerIndex !== 0\r\n || operand.componentCount !== 4 || operand.mask || operand.selected\r\n || operand.swizzle?.length !== 4\r\n || Array.from(operand.swizzle).some((component) => component !== operand.swizzle[0]))\r\n {\r\n throw new Error(`WGSL compute store instruction ${instruction.index} requires four replicated source lanes from temp[0]`);\r\n }\r\n const component = operand.swizzle[0];\r\n if (!COMPONENTS.includes(component))\r\n {\r\n throw new Error(`WGSL compute store instruction ${instruction.index} selects an invalid source lane`);\r\n }\r\n const components = Array(4).fill(component);\r\n const read = validateRead(program, instruction, operandIndex, operand, components, state, expectedReads);\r\n const value = validateValueRef(program, read.refs[0], read.register, component);\r\n return reinterpretCode(value.id, valueStorageType(value, component), \"uint32\");\r\n}\r\n\r\nfunction expectedOperandTypes(instruction)\r\n{\r\n if (instruction.opcodeName === \"ld\")\r\n {\r\n return [\r\n [ \"destination\", \"int32\" ],\r\n [ \"source\", \"uint32\" ],\r\n [ \"source\", \"unknown\" ]\r\n ];\r\n }\r\n const arithmetic = ARITHMETIC_RULES[instruction.opcodeName];\r\n if (arithmetic)\r\n {\r\n return instruction.operands.map((_, operandIndex) => [\r\n operandIndex === arithmetic.destinationOperand ? \"destination\" : \"source\",\r\n operandIndex === arithmetic.destinationOperand || arithmetic.sourceOperands.includes(operandIndex)\r\n ? arithmetic.resultType\r\n : \"unknown\"\r\n ]);\r\n }\r\n if (instruction.opcodeName === \"store_uav_typed\")\r\n {\r\n return [\r\n [ \"source\", \"unknown\" ],\r\n [ \"source\", \"uint32\" ],\r\n [ \"source\", \"uint32\" ]\r\n ];\r\n }\r\n return [];\r\n}\r\n\r\nfunction expectedRule(instruction)\r\n{\r\n if (instruction.opcodeName === \"ld\") return [ \"texture-load\", \"int32\" ];\r\n const arithmetic = ARITHMETIC_RULES[instruction.opcodeName];\r\n if (arithmetic) return [ arithmetic.rule, arithmetic.resultType ];\r\n if (instruction.opcodeName === \"store_uav_typed\") return [ \"typed-uav-store\", \"unknown\" ];\r\n return [ \"untyped\", \"unknown\" ];\r\n}\r\n\r\nfunction bitcastKey(entry)\r\n{\r\n if (entry.kind === \"read-bitcast\")\r\n {\r\n return [\r\n entry.kind, entry.operandIndex, entry.componentIndex, entry.valueId,\r\n entry.component, entry.from, entry.to\r\n ].join(\":\");\r\n }\r\n if (entry.kind === \"result-bitcast\")\r\n {\r\n return [\r\n entry.kind, entry.operandIndex, entry.valueId, entry.component,\r\n entry.from, entry.to\r\n ].join(\":\");\r\n }\r\n return [\r\n entry.kind, entry.operandIndex, entry.component, entry.from, entry.to,\r\n entry.uint32 >>> 0\r\n ].join(\":\");\r\n}\r\n\r\nfunction validateTypeInfo(program, instruction)\r\n{\r\n const [ rule, resultType ] = expectedRule(instruction);\r\n const operandTypes = expectedOperandTypes(instruction);\r\n const typeInfo = instruction.typeInfo;\r\n if (typeInfo?.kind !== \"instruction-types\"\r\n || typeInfo.rule !== rule\r\n || typeInfo.resultType !== resultType\r\n || typeInfo.conversion !== null\r\n || typeInfo.conditionProjection !== null\r\n || typeInfo.operandTypes?.length !== operandTypes.length\r\n || operandTypes.some(([ role, expectedType ], operandIndex) =>\r\n {\r\n const actual = typeInfo.operandTypes[operandIndex];\r\n return actual?.operandIndex !== operandIndex\r\n || actual.role !== role\r\n || actual.expectedType !== expectedType\r\n || actual.modifier !== \"none\"\r\n || actual.minPrecision !== \"default\";\r\n }))\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} has inconsistent type metadata`);\r\n }\r\n\r\n const required = [];\r\n for (const read of instruction.dataflow.reads)\r\n {\r\n if (read.kind !== \"register-read\")\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} has unsupported index-read type metadata`);\r\n }\r\n const expected = operandTypes[read.operandIndex]?.[1];\r\n if (!expected || expected === \"unknown\") continue;\r\n read.refs.forEach((ref, componentIndex) =>\r\n {\r\n const value = program.values.find((entry) => entry.id === ref.valueId);\r\n const storage = valueStorageType(value, ref.component);\r\n if (storage !== expected)\r\n {\r\n required.push({\r\n kind: \"read-bitcast\",\r\n operandIndex: read.operandIndex,\r\n componentIndex,\r\n valueId: ref.valueId,\r\n component: ref.component,\r\n from: storage,\r\n to: expected\r\n });\r\n }\r\n });\r\n }\r\n if (resultType !== \"unknown\")\r\n {\r\n for (const write of instruction.dataflow.writes)\r\n {\r\n for (const component of write.mask)\r\n {\r\n const value = program.values.find((entry) => entry.id === write.valueId);\r\n const storage = valueStorageType(value, component);\r\n if (storage !== resultType)\r\n {\r\n required.push({\r\n kind: \"result-bitcast\",\r\n operandIndex: write.operandIndex,\r\n valueId: write.valueId,\r\n component,\r\n from: resultType,\r\n to: storage\r\n });\r\n }\r\n }\r\n }\r\n }\r\n operandTypes.forEach(([, expectedType ], operandIndex) =>\r\n {\r\n const operand = instruction.operands[operandIndex];\r\n if (operand?.typeName !== \"immediate32\" || expectedType !== \"int32\") return;\r\n operand.immediateValues.forEach((value, componentIndex) =>\r\n {\r\n required.push({\r\n kind: \"immediate-bitcast\",\r\n operandIndex,\r\n component: COMPONENTS[componentIndex],\r\n from: \"uint32\",\r\n to: \"int32\",\r\n uint32: value.uint32 >>> 0\r\n });\r\n });\r\n });\r\n const requiredKeys = required.map(bitcastKey).sort();\r\n const actualKeys = (typeInfo.bitcasts || []).map(bitcastKey).sort();\r\n if (new Set(actualKeys).size !== actualKeys.length\r\n || requiredKeys.length !== actualKeys.length\r\n || requiredKeys.some((entry, index) => entry !== actualKeys[index]))\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} has inconsistent bitcast metadata`);\r\n }\r\n}\r\n\r\nfunction bindingRegister(binding)\r\n{\r\n return binding.range?.lowerBound ?? binding.registerIndex;\r\n}\r\n\r\nfunction bindingSpace(binding)\r\n{\r\n return binding.range?.registerSpace ?? 0;\r\n}\r\n\r\nfunction bindingIdentity(binding)\r\n{\r\n return `${binding.resourceKind}:${bindingSpace(binding)}:${bindingRegister(binding)}`;\r\n}\r\n\r\nfunction validateBindingRange(binding)\r\n{\r\n const registerIndex = binding.registerIndex;\r\n const range = binding.range;\r\n if (!Number.isInteger(registerIndex) || registerIndex < 0\r\n || range?.bindingModel !== \"sm5.0-register\"\r\n || range.rangeId !== null\r\n || range.lowerBound !== registerIndex\r\n || range.upperBound !== registerIndex\r\n || range.unbounded !== false\r\n || range.registerCount !== 1\r\n || range.registerSpace !== 0)\r\n {\r\n throw new Error(`WGSL compute binding ${binding.id || \"<unknown>\"} requires one fixed SM5.0 register`);\r\n }\r\n}\r\n\r\nfunction validateBindingDeclaration(program, binding, opcodeName, operandType, returnType)\r\n{\r\n const declarations = program.declarations.filter((entry) =>\r\n entry.dxbcOffset === binding.declarationOffset);\r\n if (declarations.length !== 1 || declarations[0].opcodeName !== opcodeName)\r\n {\r\n throw new Error(`WGSL compute binding ${binding.id} has inconsistent declaration identity`);\r\n }\r\n const declaration = declarations[0];\r\n const data = declaration.data;\r\n const operand = declaration.operands?.[0];\r\n validateReturnTypeMirror(\r\n binding.returnType,\r\n `WGSL compute binding ${binding.id}`);\r\n validateReturnTypeMirror(\r\n data?.returnType,\r\n `WGSL compute declaration at DXBC offset ${declaration.dxbcOffset}`);\r\n validateBindingRange(binding);\r\n if (binding.operandType !== operandType\r\n || binding.resourceDimension !== \"buffer\"\r\n || binding.structureStride !== null\r\n || binding.accessPattern !== null\r\n || binding.returnType?.returnTypeNames?.length !== 4\r\n || binding.returnType.returnTypeNames.some((entry) => entry !== returnType)\r\n || data?.registerIndex !== binding.registerIndex\r\n || data.resourceDimensionName !== \"buffer\"\r\n || (opcodeName === \"dcl_resource\" && data.sampleCount !== 0)\r\n || (opcodeName === \"dcl_unordered_access_view_typed\"\r\n && data.globallyCoherent !== false)\r\n || data.returnType?.returnTypeNames?.length !== 4\r\n || data.returnType.returnTypeNames.some((entry) => entry !== returnType)\r\n || declaration.operands?.length !== 1)\r\n {\r\n throw new Error(`WGSL compute binding ${binding.id} has an unsupported typed-buffer declaration`);\r\n }\r\n validateFixedRegisterOperand(\r\n operand,\r\n { index: `declaration@${declaration.dxbcOffset}` },\r\n 0,\r\n operandType);\r\n if (operand.componentCount !== 0 || operand.mask || operand.swizzle || operand.selected)\r\n {\r\n throw new Error(`WGSL compute binding ${binding.id} declaration has a malformed handle operand`);\r\n }\r\n}\r\n\r\nfunction portableBinding(binding)\r\n{\r\n return {\r\n identity: binding.identity,\r\n resourceKind: binding.resourceKind,\r\n generatedSymbol: binding.generatedSymbol,\r\n registerSpace: binding.registerSpace,\r\n registerIndex: binding.registerIndex,\r\n type: binding.type,\r\n buffer: binding.buffer\r\n };\r\n}\r\n\r\nfunction applyBindingPlan(bindings, bindingPlan)\r\n{\r\n if (bindingPlan === null || bindingPlan === undefined) return bindings;\r\n if (bindingPlan?.format !== \"CJS_WGSL_BINDING_PLAN\"\r\n || bindingPlan.formatVersion !== 2\r\n || !Array.isArray(bindingPlan.bindings)\r\n || bindingPlan.bindings.length !== bindings.length)\r\n {\r\n throw new TypeError(\"WGSL compute binding plan must provide exact version 2 compute coverage\");\r\n }\r\n const planned = new Map();\r\n const slots = new Set();\r\n for (const entry of bindingPlan.bindings)\r\n {\r\n const identity = `${entry.resourceKind}:${entry.registerSpace}:${entry.registerIndex}`;\r\n const slot = `${entry.group}:${entry.binding}`;\r\n if (entry.identity !== identity\r\n || entry.scopeIdentity !== `${identity}@compute`\r\n || entry.stages?.length !== 1 || entry.stages[0] !== \"compute\"\r\n || !Number.isInteger(entry.group) || entry.group < 0\r\n || !Number.isInteger(entry.binding) || entry.binding < 0\r\n || planned.has(identity) || slots.has(slot))\r\n {\r\n throw new Error(`WGSL compute binding plan contains an invalid entry ${entry.identity || identity}`);\r\n }\r\n planned.set(identity, entry);\r\n slots.add(slot);\r\n }\r\n return bindings.map((binding) =>\r\n {\r\n const entry = planned.get(binding.identity);\r\n if (!entry\r\n || JSON.stringify(portableBinding(binding)) !== JSON.stringify({\r\n identity: entry.identity,\r\n resourceKind: entry.resourceKind,\r\n generatedSymbol: entry.generatedSymbol,\r\n registerSpace: entry.registerSpace,\r\n registerIndex: entry.registerIndex,\r\n type: entry.type,\r\n buffer: entry.buffer\r\n }))\r\n {\r\n throw new Error(`WGSL compute binding plan layout for ${binding.identity} does not match the shader declaration`);\r\n }\r\n return { ...binding, scopeIdentity: entry.scopeIdentity, group: entry.group, binding: entry.binding };\r\n });\r\n}\r\n\r\n/**\r\n * Lowers the two scalar typed-buffer bindings used by the first compute slice.\r\n *\r\n * @param {object} program Frozen CJS shader IR.\r\n * @param {object|null} [bindingPlan] Optional exact compute-only binding plan.\r\n * @returns {object[]} Frozen WebGPU binding records.\r\n */\r\nexport function lowerComputeBindingLayout(program, bindingPlan = null)\r\n{\r\n if (program?.format !== \"CJS_SHADER_IR\" || program.formatVersion !== 1)\r\n {\r\n throw new TypeError(\"WGSL compute binding lowering expects CJS_SHADER_IR version 1 input\");\r\n }\r\n const bindings = Array.from(program.bindings || []).sort((left, right) =>\r\n bindingSpace(left) - bindingSpace(right)\r\n || (KIND_ORDER[left.resourceKind] ?? 99) - (KIND_ORDER[right.resourceKind] ?? 99)\r\n || bindingRegister(left) - bindingRegister(right)\r\n || left.declarationOffset - right.declarationOffset);\r\n if (bindings.length !== 2\r\n || bindings.filter((entry) => entry.resourceKind === \"sampled-resource\").length !== 1\r\n || bindings.filter((entry) => entry.resourceKind === \"storage-resource\").length !== 1)\r\n {\r\n throw new Error(\"WGSL compute body slice requires exactly one typed SRV and one typed UAV\");\r\n }\r\n const identities = new Set();\r\n const lowered = bindings.map((binding, bindingIndex) =>\r\n {\r\n const identity = bindingIdentity(binding);\r\n if (identities.has(identity))\r\n {\r\n throw new Error(`WGSL compute binding layout contains duplicate ${identity}`);\r\n }\r\n identities.add(identity);\r\n const sampled = binding.resourceKind === \"sampled-resource\";\r\n validateBindingDeclaration(\r\n program,\r\n binding,\r\n sampled ? \"dcl_resource\" : \"dcl_unordered_access_view_typed\",\r\n sampled ? \"resource\" : \"uav\",\r\n sampled ? \"sint\" : \"uint\");\r\n const registerIndex = bindingRegister(binding);\r\n const registerSpace = bindingSpace(binding);\r\n return {\r\n kind: \"wgsl-binding\",\r\n id: binding.id,\r\n identity,\r\n scopeIdentity: `${identity}@compute`,\r\n resourceKind: binding.resourceKind,\r\n generatedSymbol: `${KIND_PREFIX[binding.resourceKind]}${registerIndex}`,\r\n registerSpace,\r\n registerIndex,\r\n rangeId: null,\r\n group: 0,\r\n binding: bindingIndex,\r\n visibility: \"compute\",\r\n declarationOffset: binding.declarationOffset,\r\n declaration: sampled ? \"var<storage, read>\" : \"var<storage, read_write>\",\r\n type: sampled ? \"array<i32>\" : \"array<atomic<u32>>\",\r\n buffer: {\r\n type: sampled ? \"read-only-storage\" : \"storage\",\r\n hasDynamicOffset: false,\r\n minBindingSize: 4\r\n }\r\n };\r\n });\r\n return deepFreeze(applyBindingPlan(lowered, bindingPlan));\r\n}\r\n\r\nfunction bindingForOperand(bindings, resourceKind, operand, instruction, operandIndex)\r\n{\r\n validateFixedHandleOperand(instruction, operandIndex, operand.typeName, \"compute\");\r\n const matches = bindings.filter((entry) =>\r\n entry.resourceKind === resourceKind\r\n && entry.registerIndex === operand.registerIndex\r\n && entry.registerSpace === 0);\r\n if (matches.length !== 1)\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} has an unresolved ${resourceKind} binding`);\r\n }\r\n return validateFixedHandleBinding(operand, matches[0], \"compute\");\r\n}\r\n\r\nfunction validateProgramShape(program)\r\n{\r\n if (program?.format !== \"CJS_SHADER_IR\" || program.formatVersion !== 1)\r\n {\r\n throw new TypeError(\"WGSL compute lowering expects CJS_SHADER_IR version 1 input\");\r\n }\r\n if (program.stage !== \"compute\") throw new Error(`WGSL compute lowering cannot lower ${program.stage}`);\r\n if (program.shaderModel?.major !== 5 || program.shaderModel.minor !== 0)\r\n {\r\n throw new Error(\"WGSL compute body slice currently supports only SM5.0\");\r\n }\r\n if ((program.signatures?.input || []).length\r\n || (program.signatures?.output || []).length\r\n || (program.signatures?.patch || []).length\r\n || program.immediateConstantBuffer\r\n || program.constTables)\r\n {\r\n throw new Error(\"WGSL compute body slice does not support signatures or constant tables\");\r\n }\r\n if (program.declarations?.length !== DECLARATION_OPCODES.length\r\n || DECLARATION_OPCODES.some((opcodeName, index) =>\r\n program.declarations[index]?.opcodeName !== opcodeName))\r\n {\r\n throw new Error(\"WGSL compute declaration shape is not supported; the bounded body slice requires canonical global/SRV/UAV/temp/thread-group declarations\");\r\n }\r\n const temp = program.declarations[3];\r\n const group = program.declarations[4];\r\n if (temp.data?.tempCount !== 1\r\n || group.data?.threadGroupX !== 1\r\n || group.data?.threadGroupY !== 1\r\n || group.data?.threadGroupZ !== 1)\r\n {\r\n throw new Error(\"WGSL compute body slice requires one temporary and dcl_thread_group 1,1,1\");\r\n }\r\n requireRefactoringAllowed(program, \"compute\");\r\n if (!Array.isArray(program.instructions) || program.instructions.length < 2\r\n || program.instructions.at(-1)?.opcodeName !== \"ret\"\r\n || program.instructions.slice(0, -1).some((instruction) => instruction.opcodeName === \"ret\")\r\n || program.instructions.some((instruction) => !SUPPORTED_OPCODES.has(instruction.opcodeName))\r\n || program.instructions.some((instruction, index) =>\r\n instruction.index !== index\r\n || (index > 0 && instruction.dxbcOffset <= program.instructions[index - 1].dxbcOffset)))\r\n {\r\n throw new Error(\"WGSL compute body slice requires one straight-line supported instruction sequence ending in ret\");\r\n }\r\n const block = program.blocks?.[0];\r\n if (program.blocks?.length !== 1\r\n || block.id !== \"block0\" || block.index !== 0\r\n || block.startInstruction !== 0\r\n || block.endInstruction !== program.instructions.length - 1\r\n || block.terminator !== \"ret\"\r\n || block.reachable === false\r\n || block.successors?.length || block.predecessors?.length\r\n || block.mergeSite !== null\r\n || block.inputValueIds?.length\r\n || block.instructionIndices?.length !== program.instructions.length\r\n || block.instructionIndices.some((value, index) => value !== index))\r\n {\r\n throw new Error(\"WGSL compute body slice requires one canonical reachable return block\");\r\n }\r\n}\r\n\r\nfunction validateInstructionEnvelope(instruction)\r\n{\r\n const isReturn = instruction.opcodeName === \"ret\";\r\n if (instruction.controlKind !== (isReturn ? \"termination\" : null)\r\n || instruction.testBoolean !== null\r\n || instruction.saturate\r\n || instruction.preciseMask !== \"\"\r\n || (instruction.opcodeName !== \"ld\" && instruction.extensions?.length))\r\n {\r\n throw new Error(`WGSL compute instruction ${instruction.index} has unsupported control, modifier, or extension metadata`);\r\n }\r\n for (let operandIndex = 0; operandIndex < instruction.operands.length; operandIndex += 1)\r\n {\r\n validateCommonOperand(instruction.operands[operandIndex], instruction, operandIndex);\r\n }\r\n}\r\n\r\nfunction validateLoadExtensions(instruction)\r\n{\r\n const extensions = instruction.extensions || [];\r\n validateSm50ResourceExtensions(extensions, {\r\n resourceDimension: 1,\r\n resourceDimensionName: \"buffer\",\r\n structureStride: 0,\r\n resourceReturnTypes: [ 3, 3, 3, 3 ]\r\n }, `WGSL compute load instruction ${instruction.index}`);\r\n}\r\n\r\nfunction validateNullHighDestination(instruction)\r\n{\r\n const operand = instruction.operands[0];\r\n validateCommonOperand(operand, instruction, 0);\r\n if (operand.typeName !== \"null\"\r\n || operand.componentCount !== 0\r\n || operand.registerIndex !== null\r\n || operand.indices?.length\r\n || operand.mask || operand.swizzle || operand.selected\r\n || operand.immediateValues?.length)\r\n {\r\n throw new Error(`WGSL compute imul instruction ${instruction.index} requires a null high destination`);\r\n }\r\n}\r\n\r\nfunction seedRegisterState(program)\r\n{\r\n const state = new Map();\r\n const valueIds = new Set();\r\n for (const value of program.values || [])\r\n {\r\n if (valueIds.has(value.id))\r\n {\r\n throw new Error(`WGSL compute program contains duplicate value ${value.id}`);\r\n }\r\n valueIds.add(value.id);\r\n if (![ \"undefined-register\", \"instruction-write\" ].includes(value.origin)\r\n || value.register !== \"temp[0]\"\r\n || value.writeMask.length !== 1\r\n || !COMPONENTS.includes(value.writeMask)\r\n || Object.keys(value.componentTypes || {}).length !== 1\r\n || (value.origin === \"instruction-write\"\r\n ? !scalarTypeName(value.componentTypes[value.writeMask])\r\n : value.componentTypes[value.writeMask] !== \"unknown\"))\r\n {\r\n throw new Error(`WGSL compute value ${value.id} is outside the bounded temp[0] scalar slice`);\r\n }\r\n if (value.origin === \"undefined-register\")\r\n {\r\n if (value.instructionIndex !== null || value.blockId !== null || value.previous !== null)\r\n {\r\n throw new Error(`WGSL compute undefined value ${value.id} has inconsistent origin metadata`);\r\n }\r\n const key = `${value.register}.${value.writeMask}`;\r\n if (state.has(key))\r\n {\r\n throw new Error(`WGSL compute program contains duplicate undefined ${key}`);\r\n }\r\n state.set(key, { valueId: value.id, component: value.writeMask });\r\n }\r\n else if (value.blockId !== \"block0\")\r\n {\r\n throw new Error(`WGSL compute instruction value ${value.id} belongs to an unexpected block`);\r\n }\r\n }\r\n return state;\r\n}\r\n\r\nfunction validateBlockOutput(program, state)\r\n{\r\n const outputs = program.blocks[0].outputValues || [];\r\n const expected = Array.from(state, ([ key, ref ]) =>\r\n {\r\n const split = key.lastIndexOf(\".\");\r\n return { register: key.slice(0, split), component: key.slice(split + 1), ref };\r\n }).sort((left, right) =>\r\n compareUtf8(left.register, right.register) || compareUtf8(left.component, right.component));\r\n const actual = outputs.slice().sort((left, right) =>\r\n compareUtf8(left.register, right.register) || compareUtf8(left.component, right.component));\r\n if (actual.length !== expected.length\r\n || expected.some((entry, index) =>\r\n actual[index]?.register !== entry.register\r\n || actual[index]?.component !== entry.component\r\n || !sameRef(actual[index]?.ref, entry.ref)))\r\n {\r\n throw new Error(\"WGSL compute block output does not match the final scalar register state\");\r\n }\r\n}\r\n\r\n/**\r\n * Lowers the bounded setdrawparameters/setsortargs compute slice into typed SSA.\r\n *\r\n * @param {object} program Frozen CJS shader IR.\r\n * @param {object} [options] Optional exact compute-only binding plan.\r\n * @returns {object} Frozen typed compute program.\r\n */\r\nfunction lowerScalarWordComputeProgram(program, options = {})\r\n{\r\n validateProgramShape(program);\r\n const bindings = lowerComputeBindingLayout(program, options.bindingPlan ?? null);\r\n const state = seedRegisterState(program);\r\n const writtenValueIds = new Set();\r\n const statements = [];\r\n\r\n for (const instruction of program.instructions)\r\n {\r\n validateInstructionEnvelope(instruction);\r\n validateTypeInfo(program, instruction);\r\n const expectedReads = new Set();\r\n\r\n if (instruction.opcodeName === \"ret\")\r\n {\r\n if (instruction.operands.length || instruction.dataflow.reads.length || instruction.dataflow.writes.length)\r\n {\r\n throw new Error(`WGSL compute return instruction ${instruction.index} must be operand-free`);\r\n }\r\n statements.push({\r\n kind: \"return\",\r\n instructionIndex: instruction.index,\r\n dxbcOffset: instruction.dxbcOffset\r\n });\r\n continue;\r\n }\r\n\r\n if (instruction.opcodeName === \"ld\")\r\n {\r\n if (instruction.operands.length !== 3)\r\n {\r\n throw new Error(`WGSL compute load instruction ${instruction.index} requires three operands`);\r\n }\r\n validateLoadExtensions(instruction);\r\n const destination = instruction.operands[0];\r\n validateDestinationOperand(destination, instruction, 0);\r\n if (destination.mask !== \"x\")\r\n {\r\n throw new Error(`WGSL compute load instruction ${instruction.index} scalar-word profile requires the x destination lane`);\r\n }\r\n const address = immediateCode(\r\n immediateBits(instruction.operands[1], instruction, 1, true),\r\n \"uint32\");\r\n const resource = validateFixedRegisterOperand(\r\n instruction.operands[2], instruction, 2, \"resource\");\r\n if (resource.componentCount !== 4 || resource.swizzle !== \"xyzw\"\r\n || resource.mask || resource.selected)\r\n {\r\n throw new Error(`WGSL compute load instruction ${instruction.index} requires a canonical xyzw resource selection`);\r\n }\r\n const binding = bindingForOperand(\r\n bindings, \"sampled-resource\", resource, instruction, 2);\r\n const { write, value } = validateWrite(\r\n program, instruction, 0, destination, state, writtenValueIds);\r\n validateNoUnexpectedReads(instruction, expectedReads);\r\n const length = `arrayLength(&${binding.generatedSymbol})`;\r\n const intrinsic = `select(0i, ${binding.generatedSymbol}[min(${address}, ${length} - 1u)], ${address} < ${length})`;\r\n const storage = valueStorageType(value, write.mask);\r\n statements.push({\r\n kind: \"let\",\r\n instructionIndex: instruction.index,\r\n dxbcOffset: instruction.dxbcOffset,\r\n name: value.id,\r\n type: scalarTypeName(storage),\r\n expression: {\r\n code: reinterpretCode(intrinsic, \"int32\", storage),\r\n type: scalarTypeName(storage)\r\n }\r\n });\r\n continue;\r\n }\r\n\r\n const arithmetic = ARITHMETIC_RULES[instruction.opcodeName];\r\n if (arithmetic)\r\n {\r\n if (instruction.operands.length !== (instruction.opcodeName === \"imul\" ? 4 : 3))\r\n {\r\n throw new Error(`WGSL compute ${instruction.opcodeName} instruction ${instruction.index} has an unsupported operand count`);\r\n }\r\n if (instruction.opcodeName === \"imul\") validateNullHighDestination(instruction);\r\n const destination = instruction.operands[arithmetic.destinationOperand];\r\n validateDestinationOperand(destination, instruction, arithmetic.destinationOperand);\r\n const sources = arithmetic.sourceOperands.map((operandIndex) =>\r\n readCode(program, instruction, operandIndex, arithmetic.sourceType, state, expectedReads));\r\n validateNoUnexpectedReads(instruction, expectedReads);\r\n const intrinsic = arithmetic.functionName\r\n ? `${arithmetic.functionName}(${sources.join(\", \")})`\r\n : `(${sources[0]} ${arithmetic.operator} ${sources[1]})`;\r\n const { write, value } = validateWrite(\r\n program, instruction, arithmetic.destinationOperand,\r\n destination, state, writtenValueIds);\r\n const storage = valueStorageType(value, write.mask);\r\n statements.push({\r\n kind: \"let\",\r\n instructionIndex: instruction.index,\r\n dxbcOffset: instruction.dxbcOffset,\r\n name: value.id,\r\n type: scalarTypeName(storage),\r\n expression: {\r\n code: reinterpretCode(intrinsic, arithmetic.resultType, storage),\r\n type: scalarTypeName(storage)\r\n }\r\n });\r\n continue;\r\n }\r\n\r\n if (instruction.opcodeName === \"store_uav_typed\")\r\n {\r\n if (instruction.operands.length !== 3 || instruction.dataflow.writes.length)\r\n {\r\n throw new Error(`WGSL compute store instruction ${instruction.index} requires three source operands`);\r\n }\r\n const uav = validateFixedRegisterOperand(\r\n instruction.operands[0], instruction, 0, \"uav\");\r\n if (uav.componentCount !== 4 || uav.mask !== \"xyzw\"\r\n || uav.swizzle || uav.selected)\r\n {\r\n throw new Error(`WGSL compute store instruction ${instruction.index} requires a full xyzw UAV mask`);\r\n }\r\n const binding = bindingForOperand(\r\n bindings, \"storage-resource\", uav, instruction, 0);\r\n const address = immediateCode(\r\n immediateBits(instruction.operands[1], instruction, 1, true),\r\n \"uint32\");\r\n const value = replicatedStoreCode(\r\n program, instruction, 2, state, expectedReads);\r\n validateNoUnexpectedReads(instruction, expectedReads);\r\n statements.push({\r\n kind: \"if\",\r\n instructionIndex: instruction.index,\r\n dxbcOffset: instruction.dxbcOffset,\r\n condition: {\r\n code: `${address} < arrayLength(&${binding.generatedSymbol})`,\r\n type: \"bool\"\r\n },\r\n statements: [ {\r\n kind: \"call\",\r\n instructionIndex: instruction.index,\r\n dxbcOffset: instruction.dxbcOffset,\r\n expression: {\r\n code: `atomicStore(&${binding.generatedSymbol}[${address}], ${value})`,\r\n type: \"void\"\r\n }\r\n } ]\r\n });\r\n }\r\n }\r\n\r\n if (writtenValueIds.size !== program.values.filter((value) =>\r\n value.origin === \"instruction-write\").length)\r\n {\r\n throw new Error(\"WGSL compute program contains an unowned instruction-write value\");\r\n }\r\n validateBlockOutput(program, state);\r\n return deepFreeze({\r\n kind: \"typed-shader-program\",\r\n format: \"CJS_TYPED_SHADER\",\r\n formatVersion: 1,\r\n source: program.source,\r\n stage: \"compute\",\r\n entryPoint: \"main\",\r\n threadGroupSize: [ 1, 1, 1 ],\r\n bindings,\r\n statements\r\n });\r\n}\r\n\r\n/**\r\n * Routes one compute program to an exact declaration-shaped lowering profile.\r\n * Once a profile is selected its validation errors are final; malformed input\r\n * never falls through to a broader profile.\r\n *\r\n * @param {object} program Frozen CJS shader IR.\r\n * @param {object} [options] Optional exact compute-only binding plan.\r\n * @returns {object} Frozen typed compute program.\r\n */\r\nexport function lowerComputeProgram(program, options = {})\r\n{\r\n validateExactComputeEnvelope(program, \"WGSL compute\");\r\n if (isParticleClearResetCandidate(program))\r\n {\r\n return lowerParticleClearResetComputeProgram(program, options);\r\n }\r\n if (isParticleClearInitializeCandidate(program))\r\n {\r\n return lowerParticleClearInitializeComputeProgram(program, options);\r\n }\r\n if (isParticleEmitComputeCandidate(program))\r\n {\r\n return lowerParticleEmitComputeProgram(program, options);\r\n }\r\n if (isCreateHistogramsComputeProfile(program))\r\n {\r\n return lowerCreateHistogramsComputeProgram(program, options);\r\n }\r\n if (isMergeHistogramsComputeProfile(program))\r\n {\r\n return lowerMergeHistogramsComputeProgram(program, options);\r\n }\r\n if (isSortComputeProfile(program))\r\n {\r\n return lowerSortComputeProgram(program, options);\r\n }\r\n if (isSortInnerComputeProfile(program))\r\n {\r\n return lowerSortInnerComputeProgram(program, options);\r\n }\r\n if (isSortStepComputeProfile(program))\r\n {\r\n return lowerSortStepComputeProgram(program, options);\r\n }\r\n if (isSkinVerticesComputeProfile(program))\r\n {\r\n return lowerSkinVerticesComputeProgram(program, options);\r\n }\r\n return lowerScalarWordComputeProgram(program, options);\r\n}\r\n"],"names":["COMPONENTS","Object","freeze","DECLARATION_OPCODES","ARITHMETIC_RULES","imul","rule","resultType","destinationOperand","sourceOperands","sourceType","operator","umax","functionName","iadd","ushr","SUPPORTED_OPCODES","Set","keys","KIND_ORDER","KIND_PREFIX","deepFreeze","value","isFrozen","entry","values","scalarTypeName","type","int32","uint32","bitpattern32","canonicalRef","ref","valueId","component","sameRef","left","right","registerKey","operand","typeName","registerIndex","validateCommonOperand","instruction","operandIndex","modifierName","minPrecisionName","nonUniform","Error","index","validateFixedRegisterOperand","indices","Number","isInteger","length","relative","validateDestinationOperand","componentCount","includes","mask","swizzle","selected","validateScalarTempSource","immediateBits","replicated","immediateValues","some","bits","map","immediateCode","literal","toString","padStart","validateValueRef","program","expectedRegister","expectedComponent","find","id","register","writeMask","origin","validateRead","components","state","expectedReads","matches","dataflow","reads","filter","kind","read","refs","get","forEach","add","validateNoUnexpectedReads","size","has","validateWrite","writtenValueIds","writes","write","instructionIndex","previousComponents","previous","sort","join","slice","result","set","valueStorageType","componentTypes","reinterpretCode","code","fromType","toType","from","to","readCode","expectedType","operands","replicatedStoreCode","Array","fill","expectedOperandTypes","opcodeName","arithmetic","_","expectedRule","bitcastKey","componentIndex","validateTypeInfo","operandTypes","typeInfo","conversion","conditionProjection","role","actual","modifier","minPrecision","required","expected","storage","push","requiredKeys","actualKeys","bitcasts","bindingRegister","binding","range","lowerBound","bindingSpace","registerSpace","bindingIdentity","resourceKind","validateBindingRange","bindingModel","rangeId","upperBound","unbounded","registerCount","validateBindingDeclaration","operandType","returnType","declarations","dxbcOffset","declarationOffset","declaration","data","validateReturnTypeMirror","resourceDimension","structureStride","accessPattern","returnTypeNames","resourceDimensionName","sampleCount","globallyCoherent","portableBinding","identity","generatedSymbol","buffer","applyBindingPlan","bindings","bindingPlan","undefined","format","formatVersion","isArray","TypeError","planned","Map","slots","slot","group","scopeIdentity","stages","JSON","stringify","lowerComputeBindingLayout","identities","lowered","bindingIndex","sampled","visibility","hasDynamicOffset","minBindingSize","bindingForOperand","validateFixedHandleOperand","validateFixedHandleBinding","validateProgramShape","stage","shaderModel","major","minor","signatures","input","output","patch","immediateConstantBuffer","constTables","temp","tempCount","threadGroupX","threadGroupY","threadGroupZ","requireRefactoringAllowed","instructions","at","block","blocks","startInstruction","endInstruction","terminator","reachable","successors","predecessors","mergeSite","inputValueIds","instructionIndices","validateInstructionEnvelope","isReturn","controlKind","testBoolean","saturate","preciseMask","extensions","validateLoadExtensions","validateSm50ResourceExtensions","resourceReturnTypes","validateNullHighDestination","seedRegisterState","valueIds","blockId","key","validateBlockOutput","outputs","outputValues","split","lastIndexOf","compareUtf8","lowerScalarWordComputeProgram","options","statements","destination","address","resource","intrinsic","name","expression","sources","uav","condition","source","entryPoint","threadGroupSize","lowerComputeProgram","validateExactComputeEnvelope","isParticleClearResetCandidate","lowerParticleClearResetComputeProgram","isParticleClearInitializeCandidate","lowerParticleClearInitializeComputeProgram","isParticleEmitComputeCandidate","lowerParticleEmitComputeProgram","isCreateHistogramsComputeProfile","lowerCreateHistogramsComputeProgram","isMergeHistogramsComputeProfile","lowerMergeHistogramsComputeProgram","isSortComputeProfile","lowerSortComputeProgram","isSortInnerComputeProfile","lowerSortInnerComputeProgram","isSortStepComputeProfile","lowerSortStepComputeProgram","isSkinVerticesComputeProfile","lowerSkinVerticesComputeProgram"],"mappings":";;;;;;;;;;;;;AA2CA,MAAMA,UAAU,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE,CAAC;AACxD,MAAMC,mBAAmB,GAAGF,MAAM,CAACC,MAAM,CAAC,CACtC,kBAAkB,EAClB,cAAc,EACd,iCAAiC,EACjC,WAAW,EACX,kBAAkB,CACrB,CAAC;AACF,MAAME,gBAAgB,GAAGH,MAAM,CAACC,MAAM,CAAC;AACnCG,EAAAA,IAAI,EAAEJ,MAAM,CAACC,MAAM,CAAC;AAChBI,IAAAA,IAAI,EAAE,gBAAgB;AACtBC,IAAAA,UAAU,EAAE,OAAO;AACnBC,IAAAA,kBAAkB,EAAE,CAAC;IACrBC,cAAc,EAAER,MAAM,CAACC,MAAM,CAAC,CAAE,CAAC,EAAE,CAAC,CAAE,CAAC;AACvCQ,IAAAA,UAAU,EAAE,OAAO;AACnBC,IAAAA,QAAQ,EAAE;AACd,GAAC,CAAC;AACFC,EAAAA,IAAI,EAAEX,MAAM,CAACC,MAAM,CAAC;AAChBI,IAAAA,IAAI,EAAE,kBAAkB;AACxBC,IAAAA,UAAU,EAAE,QAAQ;AACpBC,IAAAA,kB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AAC,EACtC;AACI,IAAA,OAAOyN,4BAA4B,CAACzN,OAAO,EAAE4L,OAAO,CAAC;AACzD,EAAA;AACA,EAAA,IAAI8B,wBAAwB,CAAC1N,OAAO,CAAC,EACrC;AACI,IAAA,OAAO2N,2BAA2B,CAAC3N,OAAO,EAAE4L,OAAO,CAAC;AACxD,EAAA;AACA,EAAA,IAAIgC,4BAA4B,CAAC5N,OAAO,CAAC,EACzC;AACI,IAAA,OAAO6N,+BAA+B,CAAC7N,OAAO,EAAE4L,OAAO,CAAC;AAC5D,EAAA;AACA,EAAA,OAAOD,6BAA6B,CAAC3L,OAAO,EAAE4L,OAAO,CAAC;AAC1D;;;;"}
@@ -1,3 +1,5 @@
1
+ import { compareUtf8 } from '../../../../format/compareUtf8.js';
2
+
1
3
  const SCALAR_TYPE_NAMES = Object.freeze({
2
4
  float32: "f32",
3
5
  int32: "i32",
@@ -30,13 +32,13 @@ function blockForInstruction(program, instructionIndex) {
30
32
  return program.blocks.find(block => instructionIndex >= block.startInstruction && instructionIndex <= block.endInstruction) || null;
31
33
  }
32
34
 
33
- /**
34
- * Whether a lowered statement definitely returns on every path: a `return`, an
35
- * `if`/`else` whose both arms terminate, or a `switch` with a default whose
36
- * every clause terminates. Code after such a statement is unreachable.
37
- *
38
- * @param {object[]} statements Lowered statement list.
39
- * @returns {boolean} True when the list's last statement terminates all paths.
35
+ /**
36
+ * Whether a lowered statement definitely returns on every path: a `return`, an
37
+ * `if`/`else` whose both arms terminate, or a `switch` with a default whose
38
+ * every clause terminates. Code after such a statement is unreachable.
39
+ *
40
+ * @param {object[]} statements Lowered statement list.
41
+ * @returns {boolean} True when the list's last statement terminates all paths.
40
42
  */
41
43
  function terminatesAllPaths(statements) {
42
44
  const statement = statements.at(-1);
@@ -109,19 +111,19 @@ function definitionDominates(value, targetBlockId, targetInstruction, dominators
109
111
  return value.blockId !== targetBlockId || value.origin !== "instruction-write" || value.instructionIndex < targetInstruction;
110
112
  }
111
113
 
112
- /**
113
- * Whether a two-armed selection merge input can be referenced at its arm-tail
114
- * merge assignment. The fast path is lexical dominance. A selection region is
115
- * acyclic, so an input that does NOT dominate its arm tail is still safe when it
116
- * is a value `hoistEscapingValues` can lift to a function-top `var`: an ordinary
117
- * instruction result (always emitted as a `let`) or a live merge phi (emitted as
118
- * a `var` by its own plan). This is the inherited-input case — the arm tail only
119
- * carries the register through, and its incoming ref resolves to an upstream
120
- * definition. On the path that reaches the arm tail the value was assigned before
121
- * the merge write, so the hoisted var's zero initializer is unobservable.
122
- * (Loops cannot use this relaxation: a back-edge could reach the assignment with
123
- * the value defined in a different iteration.) Undefined-register inputs are
124
- * handled by the caller; anything else fails closed.
114
+ /**
115
+ * Whether a two-armed selection merge input can be referenced at its arm-tail
116
+ * merge assignment. The fast path is lexical dominance. A selection region is
117
+ * acyclic, so an input that does NOT dominate its arm tail is still safe when it
118
+ * is a value `hoistEscapingValues` can lift to a function-top `var`: an ordinary
119
+ * instruction result (always emitted as a `let`) or a live merge phi (emitted as
120
+ * a `var` by its own plan). This is the inherited-input case — the arm tail only
121
+ * carries the register through, and its incoming ref resolves to an upstream
122
+ * definition. On the path that reaches the arm tail the value was assigned before
123
+ * the merge write, so the hoisted var's zero initializer is unobservable.
124
+ * (Loops cannot use this relaxation: a back-edge could reach the assignment with
125
+ * the value defined in a different iteration.) Undefined-register inputs are
126
+ * handled by the caller; anything else fails closed.
125
127
  */
126
128
  function armInputUsable(value, armBlockId, boundaryInstruction, dominators, live) {
127
129
  if (definitionDominates(value, armBlockId, boundaryInstruction, dominators)) return true;
@@ -129,16 +131,16 @@ function armInputUsable(value, armBlockId, boundaryInstruction, dominators, live
129
131
  return value?.origin === "control-flow-merge" && live.has(value.id);
130
132
  }
131
133
 
132
- /**
133
- * The value a register+component actually holds at the exit of a block, found by
134
- * walking the dominator chain from that block to the nearest dominating block
135
- * whose `outputValues` define the register. A break predecessor frequently only
136
- * INHERITS the register (never redefines it on that path), so it is absent from
137
- * its own `outputValues`. Canonical phi inputs do retain the CFG predecessor as
138
- * `blockId`, but their value ref may resolve to an upstream definition; this walk
139
- * derives that same reaching value directly from block state.
140
- *
141
- * @returns {{valueId: string, component: string}|null} The reaching ref, or null.
134
+ /**
135
+ * The value a register+component actually holds at the exit of a block, found by
136
+ * walking the dominator chain from that block to the nearest dominating block
137
+ * whose `outputValues` define the register. A break predecessor frequently only
138
+ * INHERITS the register (never redefines it on that path), so it is absent from
139
+ * its own `outputValues`. Canonical phi inputs do retain the CFG predecessor as
140
+ * `blockId`, but their value ref may resolve to an upstream definition; this walk
141
+ * derives that same reaching value directly from block state.
142
+ *
143
+ * @returns {{valueId: string, component: string}|null} The reaching ref, or null.
142
144
  */
143
145
  function reachingRef(program, blockId, register, component, dominators) {
144
146
  const domSet = dominators.get(blockId);
@@ -172,7 +174,7 @@ function selectionConditionId(instruction) {
172
174
  return read ? `${read.refs[0].valueId}.${read.refs[0].component}` : `selection:${instruction.index}`;
173
175
  }
174
176
  function undefinedTraversalKey(valueId, constraints) {
175
- return JSON.stringify([valueId, Array.from(constraints.entries()).sort(([left], [right]) => left.localeCompare(right))]);
177
+ return JSON.stringify([valueId, Array.from(constraints.entries()).sort(([left], [right]) => compareUtf8(left, right))]);
176
178
  }
177
179
  function undefinedPathMaskedByAnd(use, constraints) {
178
180
  const {
@@ -525,19 +527,19 @@ function buildLoopPlan(program, region, values, live, dominators, stage) {
525
527
  };
526
528
  }
527
529
 
528
- /**
529
- * Plans every structured selection and switch region for WGSL emission. Each
530
- * selection plan records the header/join blocks, arm tail identities,
531
- * condition projection, and the scalar float merge values that must become
532
- * mutable variables; two-armed regions identify their arm tails through
533
- * selection-merge/fallthrough join edges, while no-else regions treat the
534
- * header fall-through as the false edge. Switch plans record grouped
535
- * break-terminated case clauses, immediate selectors, and per-clause merge
536
- * incoming values at the after-endswitch join.
537
- *
538
- * @param {object} program Frozen CJS shader IR.
539
- * @param {string} stage Stage label for diagnostics ("vertex" or "fragment").
540
- * @returns {Map<number, object>} Region plans keyed by region start instruction.
530
+ /**
531
+ * Plans every structured selection and switch region for WGSL emission. Each
532
+ * selection plan records the header/join blocks, arm tail identities,
533
+ * condition projection, and the scalar float merge values that must become
534
+ * mutable variables; two-armed regions identify their arm tails through
535
+ * selection-merge/fallthrough join edges, while no-else regions treat the
536
+ * header fall-through as the false edge. Switch plans record grouped
537
+ * break-terminated case clauses, immediate selectors, and per-clause merge
538
+ * incoming values at the after-endswitch join.
539
+ *
540
+ * @param {object} program Frozen CJS shader IR.
541
+ * @param {string} stage Stage label for diagnostics ("vertex" or "fragment").
542
+ * @returns {Map<number, object>} Region plans keyed by region start instruction.
541
543
  */
542
544
  function buildSelectionPlans(program, stage) {
543
545
  const values = new Map(program.values.map(value => [value.id, value]));