@carbonenginejs/runtime-resource 0.9.2 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (544) hide show
  1. package/NOTICE +3 -2
  2. package/README.md +47 -6
  3. package/dist/CjsMotherLode.js +88 -88
  4. package/dist/CjsMotherLode.js.map +1 -1
  5. package/dist/CjsResMan.js +717 -228
  6. package/dist/CjsResMan.js.map +1 -1
  7. package/dist/CjsResManFetchProvider.js +94 -0
  8. package/dist/CjsResManFetchProvider.js.map +1 -0
  9. package/dist/{CjsResManQueue.js → CjsResManWorkQueue.js} +112 -25
  10. package/dist/CjsResManWorkQueue.js.map +1 -0
  11. package/dist/format/CjsBlueReader.js +89 -0
  12. package/dist/format/CjsBlueReader.js.map +1 -1
  13. package/dist/format/CjsFormat.js +42 -16
  14. package/dist/format/CjsFormat.js.map +1 -1
  15. package/dist/format/CjsReader.js +4 -0
  16. package/dist/format/CjsReader.js.map +1 -1
  17. package/dist/format/CjsResourceProbe.js +2 -0
  18. package/dist/format/CjsResourceProbe.js.map +1 -1
  19. package/dist/format/effect/effectPermutationGraph.js +257 -0
  20. package/dist/format/effect/effectPermutationGraph.js.map +1 -0
  21. package/dist/format/effect/effectReflectionPackage.js +636 -0
  22. package/dist/format/effect/effectReflectionPackage.js.map +1 -0
  23. package/dist/format/effect/sha256.js +114 -0
  24. package/dist/format/effect/sha256.js.map +1 -0
  25. package/dist/format/payloadContract.js +20 -0
  26. package/dist/format/payloadContract.js.map +1 -1
  27. package/dist/formats/black/CjsBlackFormat.js +15 -1
  28. package/dist/formats/black/CjsBlackFormat.js.map +1 -1
  29. package/dist/formats/black/core/CjsBlackBinaryReader.js +103 -0
  30. package/dist/formats/black/core/CjsBlackBinaryReader.js.map +1 -1
  31. package/dist/formats/black/core/CjsBlackPropertyReaders.js +61 -0
  32. package/dist/formats/black/core/CjsBlackPropertyReaders.js.map +1 -1
  33. package/dist/formats/black/core/CjsBlackReader.js +125 -0
  34. package/dist/formats/black/core/CjsBlackReader.js.map +1 -1
  35. package/dist/formats/black/core/CjsBlackSchemaRegistry.js +103 -0
  36. package/dist/formats/black/core/CjsBlackSchemaRegistry.js.map +1 -1
  37. package/dist/formats/black/core/helpers.js +17 -0
  38. package/dist/formats/black/core/helpers.js.map +1 -1
  39. package/dist/formats/bnk/CjsBnkFormat.js +8 -0
  40. package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
  41. package/dist/formats/bnk/core/helpers.js +20 -0
  42. package/dist/formats/bnk/core/helpers.js.map +1 -1
  43. package/dist/formats/bnk/core/musicNodes.js +40 -3
  44. package/dist/formats/bnk/core/musicNodes.js.map +1 -1
  45. package/dist/formats/bnk/core/soundbanksInfo.js +2 -0
  46. package/dist/formats/bnk/core/soundbanksInfo.js.map +1 -1
  47. package/dist/formats/cmf/core/binary.js +71 -0
  48. package/dist/formats/cmf/core/binary.js.map +1 -1
  49. package/dist/formats/cmf/core/buffers.js +4 -0
  50. package/dist/formats/cmf/core/buffers.js.map +1 -1
  51. package/dist/formats/cmf/core/helpers.js +31 -0
  52. package/dist/formats/cmf/core/helpers.js.map +1 -1
  53. package/dist/formats/cmf/core/schema.js +10 -0
  54. package/dist/formats/cmf/core/schema.js.map +1 -1
  55. package/dist/formats/cmf/core/shared.js +9 -0
  56. package/dist/formats/cmf/core/shared.js.map +1 -1
  57. package/dist/formats/cmf/core/writer.js +54 -0
  58. package/dist/formats/cmf/core/writer.js.map +1 -1
  59. package/dist/formats/dds/core/bc6h.js +10 -0
  60. package/dist/formats/dds/core/bc6h.js.map +1 -1
  61. package/dist/formats/dds/core/bc7.js +16 -0
  62. package/dist/formats/dds/core/bc7.js.map +1 -1
  63. package/dist/formats/dds/core/helpers.js +47 -0
  64. package/dist/formats/dds/core/helpers.js.map +1 -1
  65. package/dist/formats/dxbc/CjsDxbcFormat.js +142 -0
  66. package/dist/formats/dxbc/CjsDxbcFormat.js.map +1 -0
  67. package/dist/formats/dxbc/core/DxbcReader.js +266 -0
  68. package/dist/formats/dxbc/core/DxbcReader.js.map +1 -0
  69. package/dist/formats/dxbc/core/container.js +169 -0
  70. package/dist/formats/dxbc/core/container.js.map +1 -0
  71. package/dist/formats/dxbc/core/decoder.js +789 -0
  72. package/dist/formats/dxbc/core/decoder.js.map +1 -0
  73. package/dist/formats/dxbc/core/errors.js +19 -0
  74. package/dist/formats/dxbc/core/errors.js.map +1 -0
  75. package/dist/formats/dxbc/core/helpers.js +220 -0
  76. package/dist/formats/dxbc/core/helpers.js.map +1 -0
  77. package/dist/formats/dxbc/core/opcodes.js +45 -0
  78. package/dist/formats/dxbc/core/opcodes.js.map +1 -0
  79. package/dist/formats/dxbc/core/program.js +91 -0
  80. package/dist/formats/dxbc/core/program.js.map +1 -0
  81. package/dist/formats/dxbc/core/signature.js +172 -0
  82. package/dist/formats/dxbc/core/signature.js.map +1 -0
  83. package/dist/formats/dxbc/index.js +2 -0
  84. package/dist/formats/dxbc/index.js.map +1 -0
  85. package/dist/formats/fbx/core/helpers.js +21 -0
  86. package/dist/formats/fbx/core/helpers.js.map +1 -1
  87. package/dist/formats/flac/CjsFlacFormat.js +49 -0
  88. package/dist/formats/flac/CjsFlacFormat.js.map +1 -1
  89. package/dist/formats/flac/core/helpers.js +20 -0
  90. package/dist/formats/flac/core/helpers.js.map +1 -1
  91. package/dist/formats/gif/CjsGifFormat.js +49 -0
  92. package/dist/formats/gif/CjsGifFormat.js.map +1 -1
  93. package/dist/formats/gif/core/helpers.js +20 -0
  94. package/dist/formats/gif/core/helpers.js.map +1 -1
  95. package/dist/formats/gltf/core/helpers.js +15 -0
  96. package/dist/formats/gltf/core/helpers.js.map +1 -1
  97. package/dist/formats/gltf/core/parser.js +13 -0
  98. package/dist/formats/gltf/core/parser.js.map +1 -1
  99. package/dist/formats/gltf/core/targets.js +10 -0
  100. package/dist/formats/gltf/core/targets.js.map +1 -1
  101. package/dist/formats/gr2/core/bitknit2.js +2 -0
  102. package/dist/formats/gr2/core/bitknit2.js.map +1 -1
  103. package/dist/formats/gr2/core/helpers.js +20 -0
  104. package/dist/formats/gr2/core/helpers.js.map +1 -1
  105. package/dist/formats/gr2/core/targets.js +10 -0
  106. package/dist/formats/gr2/core/targets.js.map +1 -1
  107. package/dist/formats/hlsl/CjsHlslFormat.js +254 -0
  108. package/dist/formats/hlsl/CjsHlslFormat.js.map +1 -0
  109. package/dist/formats/hlsl/core/HlslBinaryUtils.js +15 -0
  110. package/dist/formats/hlsl/core/HlslBinaryUtils.js.map +1 -0
  111. package/dist/formats/hlsl/core/HlslEffectReadError.js +19 -0
  112. package/dist/formats/hlsl/core/HlslEffectReadError.js.map +1 -0
  113. package/dist/formats/hlsl/core/HlslEffectStateManager.js +130 -0
  114. package/dist/formats/hlsl/core/HlslEffectStateManager.js.map +1 -0
  115. package/dist/formats/hlsl/core/HlslReader.js +266 -0
  116. package/dist/formats/hlsl/core/HlslReader.js.map +1 -0
  117. package/dist/formats/hlsl/core/HlslRenderStateSetup.js +37 -0
  118. package/dist/formats/hlsl/core/HlslRenderStateSetup.js.map +1 -0
  119. package/dist/formats/hlsl/core/HlslResourceSetDescription.js +94 -0
  120. package/dist/formats/hlsl/core/HlslResourceSetDescription.js.map +1 -0
  121. package/dist/formats/hlsl/core/HlslShaderBytecode.js +44 -0
  122. package/dist/formats/hlsl/core/HlslShaderBytecode.js.map +1 -0
  123. package/dist/formats/hlsl/core/analysis.js +51 -0
  124. package/dist/formats/hlsl/core/analysis.js.map +1 -0
  125. package/dist/formats/hlsl/core/helpers.js +270 -0
  126. package/dist/formats/hlsl/core/helpers.js.map +1 -0
  127. package/dist/formats/hlsl/core/json.js +284 -0
  128. package/dist/formats/hlsl/core/json.js.map +1 -0
  129. package/dist/formats/hlsl/core/metadata.js +327 -0
  130. package/dist/formats/hlsl/core/metadata.js.map +1 -0
  131. package/dist/formats/hlsl/core/portableReflection.js +848 -0
  132. package/dist/formats/hlsl/core/portableReflection.js.map +1 -0
  133. package/dist/formats/hlsl/core/render-states.js +280 -0
  134. package/dist/formats/hlsl/core/render-states.js.map +1 -0
  135. package/dist/formats/hlsl/core/tr2/HlslRenderContextEnum.js +43 -0
  136. package/dist/formats/hlsl/core/tr2/HlslRenderContextEnum.js.map +1 -0
  137. package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +294 -0
  138. package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -0
  139. package/dist/formats/hlsl/core/tr2/resources/HlslShaderPermutation.js +33 -0
  140. package/dist/formats/hlsl/core/tr2/resources/HlslShaderPermutation.js.map +1 -0
  141. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js +416 -0
  142. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js.map +1 -0
  143. package/dist/formats/hlsl/core/tr2/shader/HlslEffectConstant.js +40 -0
  144. package/dist/formats/hlsl/core/tr2/shader/HlslEffectConstant.js.map +1 -0
  145. package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js +742 -0
  146. package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js.map +1 -0
  147. package/dist/formats/hlsl/core/tr2/shader/HlslEffectLibrary.js +52 -0
  148. package/dist/formats/hlsl/core/tr2/shader/HlslEffectLibrary.js.map +1 -0
  149. package/dist/formats/hlsl/core/tr2/shader/HlslEffectParameterAnnotation.js +38 -0
  150. package/dist/formats/hlsl/core/tr2/shader/HlslEffectParameterAnnotation.js.map +1 -0
  151. package/dist/formats/hlsl/core/tr2/shader/HlslEffectResource.js +50 -0
  152. package/dist/formats/hlsl/core/tr2/shader/HlslEffectResource.js.map +1 -0
  153. package/dist/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js +86 -0
  154. package/dist/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js.map +1 -0
  155. package/dist/formats/hlsl/core/tr2/shader/HlslEffectTechnique.js +31 -0
  156. package/dist/formats/hlsl/core/tr2/shader/HlslEffectTechnique.js.map +1 -0
  157. package/dist/formats/hlsl/core/tr2/shader/HlslPass.js +42 -0
  158. package/dist/formats/hlsl/core/tr2/shader/HlslPass.js.map +1 -0
  159. package/dist/formats/hlsl/core/tr2/shader/HlslSamplerDescription.js +55 -0
  160. package/dist/formats/hlsl/core/tr2/shader/HlslSamplerDescription.js.map +1 -0
  161. package/dist/formats/hlsl/core/tr2/shader/HlslSamplerSetup.js +29 -0
  162. package/dist/formats/hlsl/core/tr2/shader/HlslSamplerSetup.js.map +1 -0
  163. package/dist/formats/hlsl/core/tr2/shader/HlslShader.js +220 -0
  164. package/dist/formats/hlsl/core/tr2/shader/HlslShader.js.map +1 -0
  165. package/dist/formats/hlsl/core/tr2/shader/HlslShaderOption.js +30 -0
  166. package/dist/formats/hlsl/core/tr2/shader/HlslShaderOption.js.map +1 -0
  167. package/dist/formats/hlsl/index.js +2 -0
  168. package/dist/formats/hlsl/index.js.map +1 -0
  169. package/dist/formats/hlsl/portable.js +2 -0
  170. package/dist/formats/hlsl/portable.js.map +1 -0
  171. package/dist/formats/index.js +4 -0
  172. package/dist/formats/index.js.map +1 -1
  173. package/dist/formats/jpeg/core/helpers.js +52 -0
  174. package/dist/formats/jpeg/core/helpers.js.map +1 -1
  175. package/dist/formats/jpeg/core/jpeg.js +93 -0
  176. package/dist/formats/jpeg/core/jpeg.js.map +1 -1
  177. package/dist/formats/mp3/core/helpers.js +37 -0
  178. package/dist/formats/mp3/core/helpers.js.map +1 -1
  179. package/dist/formats/mp4/core/helpers.js +35 -0
  180. package/dist/formats/mp4/core/helpers.js.map +1 -1
  181. package/dist/formats/ogg/CjsOggFormat.js +49 -0
  182. package/dist/formats/ogg/CjsOggFormat.js.map +1 -1
  183. package/dist/formats/ogg/core/helpers.js +23 -0
  184. package/dist/formats/ogg/core/helpers.js.map +1 -1
  185. package/dist/formats/ogg/core/vorbis.js +13 -0
  186. package/dist/formats/ogg/core/vorbis.js.map +1 -1
  187. package/dist/formats/png/core/helpers.js +52 -0
  188. package/dist/formats/png/core/helpers.js.map +1 -1
  189. package/dist/formats/red/CjsRedFormat.js +2 -0
  190. package/dist/formats/red/CjsRedFormat.js.map +1 -1
  191. package/dist/formats/red/core/CjsRedReader.js +52 -0
  192. package/dist/formats/red/core/CjsRedReader.js.map +1 -1
  193. package/dist/formats/red/core/helpers.js +19 -0
  194. package/dist/formats/red/core/helpers.js.map +1 -1
  195. package/dist/formats/stl/core/stl.js +8 -0
  196. package/dist/formats/stl/core/stl.js.map +1 -1
  197. package/dist/formats/stl/core/targets.js +10 -0
  198. package/dist/formats/stl/core/targets.js.map +1 -1
  199. package/dist/formats/tga/core/helpers.js +47 -0
  200. package/dist/formats/tga/core/helpers.js.map +1 -1
  201. package/dist/formats/wav/core/helpers.js +37 -0
  202. package/dist/formats/wav/core/helpers.js.map +1 -1
  203. package/dist/formats/webgl/CjsWebglFormat.js +221 -0
  204. package/dist/formats/webgl/CjsWebglFormat.js.map +1 -0
  205. package/dist/formats/webgl/core/cewg/CewgPackage.js +339 -0
  206. package/dist/formats/webgl/core/cewg/CewgPackage.js.map +1 -0
  207. package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js +104 -0
  208. package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js.map +1 -0
  209. package/dist/formats/webgl/core/cewg/binary.js +101 -0
  210. package/dist/formats/webgl/core/cewg/binary.js.map +1 -0
  211. package/dist/formats/webgl/core/cewgCompleteness.js +81 -0
  212. package/dist/formats/webgl/core/cewgCompleteness.js.map +1 -0
  213. package/dist/formats/webgl/core/effectPackage.js +789 -0
  214. package/dist/formats/webgl/core/effectPackage.js.map +1 -0
  215. package/dist/formats/webgl/core/effectPackageValidation.js +331 -0
  216. package/dist/formats/webgl/core/effectPackageValidation.js.map +1 -0
  217. package/dist/formats/webgl/core/errors.js +27 -0
  218. package/dist/formats/webgl/core/errors.js.map +1 -0
  219. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +2678 -0
  220. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -0
  221. package/dist/formats/webgl/core/glsl/DxbcGlslHelpers.js +89 -0
  222. package/dist/formats/webgl/core/glsl/DxbcGlslHelpers.js.map +1 -0
  223. package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js +428 -0
  224. package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js.map +1 -0
  225. package/dist/formats/webgl/core/helpers.js +306 -0
  226. package/dist/formats/webgl/core/helpers.js.map +1 -0
  227. package/dist/formats/webgl/index.js +2 -0
  228. package/dist/formats/webgl/index.js.map +1 -0
  229. package/dist/formats/webgpu/CjsWebgpuFormat.js +376 -0
  230. package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -0
  231. package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js +415 -0
  232. package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js.map +1 -0
  233. package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js +100 -0
  234. package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js.map +1 -0
  235. package/dist/formats/webgpu/core/cewgpu/binary.js +93 -0
  236. package/dist/formats/webgpu/core/cewgpu/binary.js.map +1 -0
  237. package/dist/formats/webgpu/core/cewgpu/tags.js +17 -0
  238. package/dist/formats/webgpu/core/cewgpu/tags.js.map +1 -0
  239. package/dist/formats/webgpu/core/effectAnalysis.js +82 -0
  240. package/dist/formats/webgpu/core/effectAnalysis.js.map +1 -0
  241. package/dist/formats/webgpu/core/effectBackendBodySet.js +305 -0
  242. package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -0
  243. package/dist/formats/webgpu/core/effectPackageValidation.js +1078 -0
  244. package/dist/formats/webgpu/core/effectPackageValidation.js.map +1 -0
  245. package/dist/formats/webgpu/core/errors.js +20 -0
  246. package/dist/formats/webgpu/core/errors.js.map +1 -0
  247. package/dist/formats/webgpu/core/helpers.js +448 -0
  248. package/dist/formats/webgpu/core/helpers.js.map +1 -0
  249. package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +223 -0
  250. package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js.map +1 -0
  251. package/dist/formats/webgpu/core/ir/buildControlFlow.js +220 -0
  252. package/dist/formats/webgpu/core/ir/buildControlFlow.js.map +1 -0
  253. package/dist/formats/webgpu/core/ir/indexableTemps.js +137 -0
  254. package/dist/formats/webgpu/core/ir/indexableTemps.js.map +1 -0
  255. package/dist/formats/webgpu/core/ir/inferValueTypes.js +454 -0
  256. package/dist/formats/webgpu/core/ir/inferValueTypes.js.map +1 -0
  257. package/dist/formats/webgpu/core/ir/lowerDxbcToIr.js +494 -0
  258. package/dist/formats/webgpu/core/ir/lowerDxbcToIr.js.map +1 -0
  259. package/dist/formats/webgpu/core/ir/resolveRegisterFlow.js +177 -0
  260. package/dist/formats/webgpu/core/ir/resolveRegisterFlow.js.map +1 -0
  261. package/dist/formats/webgpu/core/ir/sourceLanes.js +61 -0
  262. package/dist/formats/webgpu/core/ir/sourceLanes.js.map +1 -0
  263. package/dist/formats/webgpu/core/packageEffect.js +300 -0
  264. package/dist/formats/webgpu/core/packageEffect.js.map +1 -0
  265. package/dist/formats/webgpu/core/packageEffectSelection.js +164 -0
  266. package/dist/formats/webgpu/core/packageEffectSelection.js.map +1 -0
  267. package/dist/formats/webgpu/core/packageMetadata.js +8 -0
  268. package/dist/formats/webgpu/core/packageMetadata.js.map +1 -0
  269. package/dist/formats/webgpu/core/schema.js +4 -0
  270. package/dist/formats/webgpu/core/schema.js.map +1 -0
  271. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +275 -0
  272. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -0
  273. package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +182 -0
  274. package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js.map +1 -0
  275. package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +324 -0
  276. package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -0
  277. package/dist/formats/webgpu/core/wgsl/emitWgsl.js +356 -0
  278. package/dist/formats/webgpu/core/wgsl/emitWgsl.js.map +1 -0
  279. package/dist/formats/webgpu/core/wgsl/hoistEscapingValues.js +77 -0
  280. package/dist/formats/webgpu/core/wgsl/hoistEscapingValues.js.map +1 -0
  281. package/dist/formats/webgpu/core/wgsl/lowerBindingLayout.js +451 -0
  282. package/dist/formats/webgpu/core/wgsl/lowerBindingLayout.js.map +1 -0
  283. package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +754 -0
  284. package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js.map +1 -0
  285. package/dist/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js +457 -0
  286. package/dist/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js.map +1 -0
  287. package/dist/formats/webgpu/core/wgsl/lowerFragmentProgram.js +1572 -0
  288. package/dist/formats/webgpu/core/wgsl/lowerFragmentProgram.js.map +1 -0
  289. package/dist/formats/webgpu/core/wgsl/lowerMergeHistogramsComputeProgram.js +659 -0
  290. package/dist/formats/webgpu/core/wgsl/lowerMergeHistogramsComputeProgram.js.map +1 -0
  291. package/dist/formats/webgpu/core/wgsl/lowerParticleClearComputePrograms.js +734 -0
  292. package/dist/formats/webgpu/core/wgsl/lowerParticleClearComputePrograms.js.map +1 -0
  293. package/dist/formats/webgpu/core/wgsl/lowerParticleEmitComputeProgram.js +583 -0
  294. package/dist/formats/webgpu/core/wgsl/lowerParticleEmitComputeProgram.js.map +1 -0
  295. package/dist/formats/webgpu/core/wgsl/lowerSkinVerticesComputeProgram.js +621 -0
  296. package/dist/formats/webgpu/core/wgsl/lowerSkinVerticesComputeProgram.js.map +1 -0
  297. package/dist/formats/webgpu/core/wgsl/lowerSortComputeProgram.js +824 -0
  298. package/dist/formats/webgpu/core/wgsl/lowerSortComputeProgram.js.map +1 -0
  299. package/dist/formats/webgpu/core/wgsl/lowerSortInnerComputeProgram.js +697 -0
  300. package/dist/formats/webgpu/core/wgsl/lowerSortInnerComputeProgram.js.map +1 -0
  301. package/dist/formats/webgpu/core/wgsl/lowerSortStepComputeProgram.js +559 -0
  302. package/dist/formats/webgpu/core/wgsl/lowerSortStepComputeProgram.js.map +1 -0
  303. package/dist/formats/webgpu/core/wgsl/lowerVertexProgram.js +1328 -0
  304. package/dist/formats/webgpu/core/wgsl/lowerVertexProgram.js.map +1 -0
  305. package/dist/formats/webgpu/core/wgsl/particleEmitSemanticDigest.js +110 -0
  306. package/dist/formats/webgpu/core/wgsl/particleEmitSemanticDigest.js.map +1 -0
  307. package/dist/formats/webgpu/core/wgsl/precisionControls.js +55 -0
  308. package/dist/formats/webgpu/core/wgsl/precisionControls.js.map +1 -0
  309. package/dist/formats/webgpu/core/wgsl/selectionPlans.js +758 -0
  310. package/dist/formats/webgpu/core/wgsl/selectionPlans.js.map +1 -0
  311. package/dist/formats/webgpu/core/wgsl/uniformity.js +78 -0
  312. package/dist/formats/webgpu/core/wgsl/uniformity.js.map +1 -0
  313. package/dist/formats/webgpu/core/wgsl/validateExactComputeIr.js +196 -0
  314. package/dist/formats/webgpu/core/wgsl/validateExactComputeIr.js.map +1 -0
  315. package/dist/formats/webgpu/core/wgsl/validateHandleOperand.js +37 -0
  316. package/dist/formats/webgpu/core/wgsl/validateHandleOperand.js.map +1 -0
  317. package/dist/formats/webgpu/index.js +2 -0
  318. package/dist/formats/webgpu/index.js.map +1 -0
  319. package/dist/formats/webm/core/helpers.js +35 -0
  320. package/dist/formats/webm/core/helpers.js.map +1 -1
  321. package/dist/formats/webp/CjsWebpFormat.js +49 -0
  322. package/dist/formats/webp/CjsWebpFormat.js.map +1 -1
  323. package/dist/formats/webp/core/helpers.js +23 -0
  324. package/dist/formats/webp/core/helpers.js.map +1 -1
  325. package/dist/formats/wem/CjsWemFormat.js +8 -0
  326. package/dist/formats/wem/CjsWemFormat.js.map +1 -1
  327. package/dist/formats/wem/core/bitStream.js +2 -0
  328. package/dist/formats/wem/core/bitStream.js.map +1 -1
  329. package/dist/formats/wem/core/helpers.js +20 -0
  330. package/dist/formats/wem/core/helpers.js.map +1 -1
  331. package/dist/formats/yaml/CjsYamlFormat.js +45 -0
  332. package/dist/formats/yaml/CjsYamlFormat.js.map +1 -1
  333. package/dist/formats/yaml/core/CjsYamlReader.js +91 -0
  334. package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -1
  335. package/dist/formats/yaml/core/helpers.js +10 -0
  336. package/dist/formats/yaml/core/helpers.js.map +1 -1
  337. package/dist/index.js +56 -43
  338. package/dist/index.js.map +1 -1
  339. package/dist/{CjsResource.js → resource/CjsResource.js} +232 -17
  340. package/dist/resource/CjsResource.js.map +1 -0
  341. package/dist/{resources → resource}/Tr2LightProfileRes.js +4 -3
  342. package/dist/resource/Tr2LightProfileRes.js.map +1 -0
  343. package/dist/{resources → resource/audio}/AudioGeometryResData.js +1 -1
  344. package/dist/resource/audio/AudioGeometryResData.js.map +1 -0
  345. package/dist/resource/audio/CjsAudioBufferRes.js +86 -0
  346. package/dist/resource/audio/CjsAudioBufferRes.js.map +1 -0
  347. package/dist/resource/audio/CjsAudioRes.js +213 -0
  348. package/dist/resource/audio/CjsAudioRes.js.map +1 -0
  349. package/dist/resource/audio/index.js +4 -0
  350. package/dist/resource/audio/index.js.map +1 -0
  351. package/dist/{resources → resource/geometry}/MeshDecalData.js +1 -1
  352. package/dist/resource/geometry/MeshDecalData.js.map +1 -0
  353. package/dist/{resources → resource/geometry}/MeshDecalLodData.js +1 -1
  354. package/dist/resource/geometry/MeshDecalLodData.js.map +1 -0
  355. package/dist/resource/geometry/TriGeometryRes.js +656 -0
  356. package/dist/resource/geometry/TriGeometryRes.js.map +1 -0
  357. package/dist/{resources → resource/geometry}/TriGeometryResAreaData.js +1 -1
  358. package/dist/resource/geometry/TriGeometryResAreaData.js.map +1 -0
  359. package/dist/{resources → resource/geometry}/TriGeometryResJointData.js +1 -1
  360. package/dist/resource/geometry/TriGeometryResJointData.js.map +1 -0
  361. package/dist/{resources → resource/geometry}/TriGeometryResLodData.js +1 -1
  362. package/dist/resource/geometry/TriGeometryResLodData.js.map +1 -0
  363. package/dist/{resources → resource/geometry}/TriGeometryResMeshData.js +1 -1
  364. package/dist/resource/geometry/TriGeometryResMeshData.js.map +1 -0
  365. package/dist/{resources → resource/geometry}/TriGeometryResSkeletonData.js +1 -1
  366. package/dist/resource/geometry/TriGeometryResSkeletonData.js.map +1 -0
  367. package/dist/{resources → resource/geometry}/TriJointBinding.js +1 -1
  368. package/dist/resource/geometry/TriJointBinding.js.map +1 -0
  369. package/dist/{resources → resource/geometry}/TriMorphTargetGeometryConstants.js +1 -1
  370. package/dist/resource/geometry/TriMorphTargetGeometryConstants.js.map +1 -0
  371. package/dist/{resources → resource/geometry}/TriRtGeometryConstants.js +1 -1
  372. package/dist/resource/geometry/TriRtGeometryConstants.js.map +1 -0
  373. package/dist/{resources → resource/geometry/granny}/GStateBindingCallbackData.js +1 -1
  374. package/dist/resource/geometry/granny/GStateBindingCallbackData.js.map +1 -0
  375. package/dist/{resources → resource/geometry/granny}/Tr2GrannyIntersectionResult.js +1 -1
  376. package/dist/resource/geometry/granny/Tr2GrannyIntersectionResult.js.map +1 -0
  377. package/dist/{resources → resource/geometry/granny}/Tr2GrannyStateRes.js +6 -5
  378. package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -0
  379. package/dist/{resources → resource/geometry/granny}/TriGrannyRes.js +6 -5
  380. package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -0
  381. package/dist/{resources → resource/geometry/granny}/enums.js +1 -9
  382. package/dist/resource/geometry/granny/enums.js.map +1 -0
  383. package/dist/resource/geometry/granny/index.js +6 -0
  384. package/dist/resource/geometry/granny/index.js.map +1 -0
  385. package/dist/resource/geometry/index.js +17 -0
  386. package/dist/resource/geometry/index.js.map +1 -0
  387. package/dist/resource/index.js +52 -0
  388. package/dist/resource/index.js.map +1 -0
  389. package/dist/resource/resourceBoundary.js +64 -0
  390. package/dist/resource/resourceBoundary.js.map +1 -0
  391. package/dist/resource/shader/Tr2EffectRes.js +429 -0
  392. package/dist/resource/shader/Tr2EffectRes.js.map +1 -0
  393. package/dist/resource/shader/Tr2MaterialArea.js +34 -0
  394. package/dist/resource/shader/Tr2MaterialArea.js.map +1 -0
  395. package/dist/resource/shader/Tr2MaterialMesh.js +30 -0
  396. package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -0
  397. package/dist/resource/shader/Tr2MaterialRes.js +35 -0
  398. package/dist/resource/shader/Tr2MaterialRes.js.map +1 -0
  399. package/dist/resource/shader/Tr2Shader.js +256 -0
  400. package/dist/resource/shader/Tr2Shader.js.map +1 -0
  401. package/dist/resource/shader/Tr2ShaderPermutation.js +47 -0
  402. package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -0
  403. package/dist/resource/shader/index.js +17 -0
  404. package/dist/resource/shader/index.js.map +1 -0
  405. package/dist/resource/shader/portable.js +33 -0
  406. package/dist/resource/shader/portable.js.map +1 -0
  407. package/dist/resource/shader/reflection/Tr2EffectConstant.js +135 -0
  408. package/dist/resource/shader/reflection/Tr2EffectConstant.js.map +1 -0
  409. package/dist/resource/shader/reflection/Tr2EffectDefine.js +28 -0
  410. package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -0
  411. package/dist/resource/shader/reflection/Tr2EffectDescription.js +107 -0
  412. package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -0
  413. package/dist/resource/shader/reflection/Tr2EffectLibrary.js +145 -0
  414. package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -0
  415. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +103 -0
  416. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -0
  417. package/dist/resource/shader/reflection/Tr2EffectResource.js +84 -0
  418. package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -0
  419. package/dist/resource/shader/reflection/Tr2EffectStageInput.js +239 -0
  420. package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -0
  421. package/dist/resource/shader/reflection/Tr2EffectTechnique.js +66 -0
  422. package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -0
  423. package/dist/resource/shader/reflection/Tr2Pass.js +109 -0
  424. package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -0
  425. package/dist/resource/shader/sampler/Tr2SamplerSetup.js +75 -0
  426. package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -0
  427. package/dist/{texture → resource/texture}/CjsTextureArrayRes.js +83 -6
  428. package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -0
  429. package/dist/{texture/CjsTextureParameterProxy.js → resource/texture/CjsTextureArrayResParameterProxy.js} +56 -10
  430. package/dist/resource/texture/CjsTextureArrayResParameterProxy.js.map +1 -0
  431. package/dist/{resources → resource/texture}/Tr2ImageRes.js +6 -4
  432. package/dist/resource/texture/Tr2ImageRes.js.map +1 -0
  433. package/dist/{resources → resource/texture}/Tr2TextureLodManager.js +3 -1
  434. package/dist/resource/texture/Tr2TextureLodManager.js.map +1 -0
  435. package/dist/{resources → resource/texture}/Tr2TextureLodUpdateRequest.js +1 -1
  436. package/dist/resource/texture/Tr2TextureLodUpdateRequest.js.map +1 -0
  437. package/dist/{resources → resource/texture}/Tr2TexturePackChannel.js +1 -1
  438. package/dist/resource/texture/Tr2TexturePackChannel.js.map +1 -0
  439. package/dist/{resources → resource/texture}/Tr2TexturePipeline.js +6 -4
  440. package/dist/resource/texture/Tr2TexturePipeline.js.map +1 -0
  441. package/dist/{resources → resource/texture}/Tr2TexturePipelineParams.js +1 -1
  442. package/dist/resource/texture/Tr2TexturePipelineParams.js.map +1 -0
  443. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepCompress.js +1 -1
  444. package/dist/resource/texture/Tr2TexturePipelineStepCompress.js.map +1 -0
  445. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepGenerateMips.js +1 -1
  446. package/dist/resource/texture/Tr2TexturePipelineStepGenerateMips.js.map +1 -0
  447. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepLimitSize.js +1 -1
  448. package/dist/resource/texture/Tr2TexturePipelineStepLimitSize.js.map +1 -0
  449. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepLoad.js +1 -1
  450. package/dist/resource/texture/Tr2TexturePipelineStepLoad.js.map +1 -0
  451. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepPack.js +1 -1
  452. package/dist/resource/texture/Tr2TexturePipelineStepPack.js.map +1 -0
  453. package/dist/{resources → resource/texture}/TriTextureRes.js +42 -26
  454. package/dist/resource/texture/TriTextureRes.js.map +1 -0
  455. package/dist/resource/texture/index.js +15 -0
  456. package/dist/resource/texture/index.js.map +1 -0
  457. package/dist/{resources → resource/texture}/texturePipelineBehavior.js +59 -59
  458. package/dist/resource/texture/texturePipelineBehavior.js.map +1 -0
  459. package/dist/worker/CjsResManMainThreadLoader.js +87 -0
  460. package/dist/worker/CjsResManMainThreadLoader.js.map +1 -0
  461. package/dist/worker/CjsResManWorker.js +217 -0
  462. package/dist/worker/CjsResManWorker.js.map +1 -0
  463. package/dist/worker/CjsResManWorkerLoader.js +434 -0
  464. package/dist/worker/CjsResManWorkerLoader.js.map +1 -0
  465. package/dist/worker/protocol.js +12 -0
  466. package/dist/worker/protocol.js.map +1 -0
  467. package/docs/README.md +16 -3
  468. package/docs/architecture.md +39 -16
  469. package/docs/concepts/resource-lifecycle.md +2 -1
  470. package/docs/formats/README.md +8 -0
  471. package/docs/formats/provenance.md +11 -3
  472. package/docs/reference/classes/README.md +6 -4
  473. package/docs/reference/classes/audio.md +30 -0
  474. package/docs/reference/classes/core.md +31 -11
  475. package/docs/reference/classes/formats.md +440 -0
  476. package/docs/reference/classes/resources.md +151 -41
  477. package/docs/reference/classes/texture.md +7 -7
  478. package/docs/reference/motherlode-cache.md +17 -0
  479. package/docs/reference/queues.md +9 -1
  480. package/docs/reference/workers.md +135 -0
  481. package/docs/roadmap.md +27 -1
  482. package/format-notices/dxbc/LICENSE +21 -0
  483. package/format-notices/dxbc/NOTICE +20 -0
  484. package/format-notices/hlsl/LICENSE +21 -0
  485. package/format-notices/hlsl/NOTICE +25 -0
  486. package/format-notices/webgl/LICENSE +21 -0
  487. package/format-notices/webgl/NOTICE +35 -0
  488. package/format-notices/webgpu/LICENSE +21 -0
  489. package/format-notices/webgpu/NOTICE +31 -0
  490. package/package.json +13 -1
  491. package/dist/CjsResManQueue.js.map +0 -1
  492. package/dist/CjsResource.js.map +0 -1
  493. package/dist/CjsResourceSource.js +0 -68
  494. package/dist/CjsResourceSource.js.map +0 -1
  495. package/dist/resourcePath.js +0 -18
  496. package/dist/resourcePath.js.map +0 -1
  497. package/dist/resourceStates.js +0 -9
  498. package/dist/resourceStates.js.map +0 -1
  499. package/dist/resources/AudioGeometryResData.js.map +0 -1
  500. package/dist/resources/GStateBindingCallbackData.js.map +0 -1
  501. package/dist/resources/MeshDecalData.js.map +0 -1
  502. package/dist/resources/MeshDecalLodData.js.map +0 -1
  503. package/dist/resources/Tr2EffectRes.js +0 -71
  504. package/dist/resources/Tr2EffectRes.js.map +0 -1
  505. package/dist/resources/Tr2GrannyIntersectionResult.js.map +0 -1
  506. package/dist/resources/Tr2GrannyStateRes.js.map +0 -1
  507. package/dist/resources/Tr2ImageRes.js.map +0 -1
  508. package/dist/resources/Tr2LightProfileRes.js.map +0 -1
  509. package/dist/resources/Tr2MaterialArea.js +0 -34
  510. package/dist/resources/Tr2MaterialArea.js.map +0 -1
  511. package/dist/resources/Tr2MaterialMesh.js +0 -31
  512. package/dist/resources/Tr2MaterialMesh.js.map +0 -1
  513. package/dist/resources/Tr2MaterialRes.js +0 -34
  514. package/dist/resources/Tr2MaterialRes.js.map +0 -1
  515. package/dist/resources/Tr2ShaderPermutation.js +0 -43
  516. package/dist/resources/Tr2ShaderPermutation.js.map +0 -1
  517. package/dist/resources/Tr2TextureLodManager.js.map +0 -1
  518. package/dist/resources/Tr2TextureLodUpdateRequest.js.map +0 -1
  519. package/dist/resources/Tr2TexturePackChannel.js.map +0 -1
  520. package/dist/resources/Tr2TexturePipeline.js.map +0 -1
  521. package/dist/resources/Tr2TexturePipelineParams.js.map +0 -1
  522. package/dist/resources/Tr2TexturePipelineStepCompress.js.map +0 -1
  523. package/dist/resources/Tr2TexturePipelineStepGenerateMips.js.map +0 -1
  524. package/dist/resources/Tr2TexturePipelineStepLimitSize.js.map +0 -1
  525. package/dist/resources/Tr2TexturePipelineStepLoad.js.map +0 -1
  526. package/dist/resources/Tr2TexturePipelineStepPack.js.map +0 -1
  527. package/dist/resources/TriGeometryRes.js +0 -239
  528. package/dist/resources/TriGeometryRes.js.map +0 -1
  529. package/dist/resources/TriGeometryResAreaData.js.map +0 -1
  530. package/dist/resources/TriGeometryResJointData.js.map +0 -1
  531. package/dist/resources/TriGeometryResLodData.js.map +0 -1
  532. package/dist/resources/TriGeometryResMeshData.js.map +0 -1
  533. package/dist/resources/TriGeometryResSkeletonData.js.map +0 -1
  534. package/dist/resources/TriGrannyRes.js.map +0 -1
  535. package/dist/resources/TriJointBinding.js.map +0 -1
  536. package/dist/resources/TriMorphTargetGeometryConstants.js.map +0 -1
  537. package/dist/resources/TriRtGeometryConstants.js.map +0 -1
  538. package/dist/resources/TriTextureRes.js.map +0 -1
  539. package/dist/resources/enums.js.map +0 -1
  540. package/dist/resources/resourceBoundary.js +0 -47
  541. package/dist/resources/resourceBoundary.js.map +0 -1
  542. package/dist/resources/texturePipelineBehavior.js.map +0 -1
  543. package/dist/texture/CjsTextureArrayRes.js.map +0 -1
  544. package/dist/texture/CjsTextureParameterProxy.js.map +0 -1
@@ -0,0 +1,137 @@
1
+ const COMPONENTS = "xyzw";
2
+ const DESTINATION_MASK = /^x?y?z?w?$/u;
3
+ function fail(reason) {
4
+ throw new Error(`Shader IR indexable temp is not supported: ${reason}`);
5
+ }
6
+ function validateComponents(operand, role, componentCount) {
7
+ const valid = COMPONENTS.slice(0, componentCount);
8
+ if (role === "destination") {
9
+ if (typeof operand.mask !== "string" || !operand.mask || !DESTINATION_MASK.test(operand.mask) || Array.from(operand.mask).some(component => !valid.includes(component)) || operand.swizzle || operand.selected) {
10
+ fail("a destination requires one canonical in-range write mask");
11
+ }
12
+ return;
13
+ }
14
+ if (operand.mask) {
15
+ fail("a source indexable temp requires swizzle or select component mode");
16
+ }
17
+ if ([operand.swizzle, operand.selected].filter(Boolean).length > 1) {
18
+ fail("a source requires exactly one component-selection mode");
19
+ }
20
+ if (operand.swizzle && (operand.swizzle.length !== 4 || Array.from(operand.swizzle).some(component => !valid.includes(component))) || operand.selected && (operand.selected.length !== 1 || !valid.includes(operand.selected))) {
21
+ fail("a source selects an invalid or out-of-range component");
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Validates the declaration-backed identity of an indexable-temp operand.
27
+ * Mutable fixed slots are returned as ordinary SSA register identities.
28
+ * Reads from an extracted immutable table return null so they bypass register
29
+ * SSA and lower through the table expression path instead.
30
+ *
31
+ * @param {object} program Shader IR program under construction or lowering.
32
+ * @param {object} operand Indexable-temp operand.
33
+ * @param {"source"|"destination"} role Operand role.
34
+ * @returns {{registerIndex:number, slotIndex:number, key:string}|null} Fixed SSA address, or null for a const-table read.
35
+ */
36
+ function validateIndexableTempOperand(program, operand, role) {
37
+ if (operand?.typeName !== "indexable_temp") return null;
38
+ if (!["source", "destination"].includes(role)) throw new TypeError("Invalid indexable-temp operand role");
39
+ const indices = operand.indices;
40
+ if (!Array.isArray(indices) || indices.length !== 2) {
41
+ fail("an operand requires exactly [register][slot] indices");
42
+ }
43
+ const registerIndex = indices[0];
44
+ if (registerIndex?.relative || !Array.isArray(registerIndex?.values) || registerIndex.values.length !== 1 || !Number.isInteger(registerIndex.values[0]) || registerIndex.values[0] < 0) {
45
+ fail("the register index must be one fixed non-negative integer");
46
+ }
47
+ const register = registerIndex.values[0];
48
+ if (!Number.isInteger(operand.registerIndex) || operand.registerIndex !== register) {
49
+ fail("the operand register identity does not match its first index");
50
+ }
51
+ const declarations = (program.declarations || []).filter(declaration => declaration.opcodeName === "dcl_indexable_temp" && declaration.data?.registerIndex === register);
52
+ if (declarations.length !== 1) {
53
+ fail(declarations.length ? `x${register} has duplicate declarations` : `x${register} is undeclared`);
54
+ }
55
+ const declaration = declarations[0].data;
56
+ if (!Number.isInteger(declaration.registerCount) || declaration.registerCount < 1) {
57
+ fail(`x${register} has no usable slot count`);
58
+ }
59
+ if (!Number.isInteger(declaration.componentCount) || declaration.componentCount < 1 || declaration.componentCount > 4) {
60
+ fail(`x${register} has an invalid component count`);
61
+ }
62
+ if (operand.componentCount !== 4) {
63
+ fail(`x${register} operand is not four-component`);
64
+ }
65
+ validateComponents(operand, role, declaration.componentCount);
66
+ const tables = (program.constTables || []).filter(table => table.registerIndex === register);
67
+ if (tables.length > 1) fail(`x${register} aliases duplicate immutable constant tables`);
68
+ if (tables.length && role === "destination") fail(`x${register} aliases an immutable constant table`);
69
+ const slotIndex = indices[1];
70
+ if (slotIndex?.relative) {
71
+ if (!Array.isArray(slotIndex.values) || slotIndex.values.length > 1 || slotIndex.values.length === 1 && (!Number.isInteger(slotIndex.values[0]) || slotIndex.values[0] < 0)) {
72
+ fail(`x${register} has an invalid relative slot base`);
73
+ }
74
+ if (tables.length && role === "source") return null;
75
+ fail(`x${register} uses relative ${role} addressing`);
76
+ }
77
+ if (!Array.isArray(slotIndex?.values) || slotIndex.values.length !== 1 || !Number.isInteger(slotIndex.values[0]) || slotIndex.values[0] < 0) {
78
+ fail(`x${register} requires one fixed non-negative slot index`);
79
+ }
80
+ const slot = slotIndex.values[0];
81
+ if (slot >= declaration.registerCount) {
82
+ fail(`x${register}[${slot}] is outside its declared range`);
83
+ }
84
+ if (tables.length) return null;
85
+ if (declaration.componentCount !== 4) {
86
+ fail(`x${register}[${slot}] is not a four-component mutable operand`);
87
+ }
88
+ return {
89
+ registerIndex: register,
90
+ slotIndex: slot,
91
+ key: `indexable_temp[${register},${slot}]`
92
+ };
93
+ }
94
+
95
+ /**
96
+ * Cross-checks a fixed source operand against its canonical SSA read record.
97
+ *
98
+ * @param {object} program Frozen shader IR program.
99
+ * @param {object} operand Indexable-temp source operand.
100
+ * @param {object} read Register-read or index-read dataflow record.
101
+ * @param {string[]} expectedComponents Components selected by the current operand metadata.
102
+ * @returns {{registerIndex:number, slotIndex:number,key:string}} Validated fixed address.
103
+ */
104
+ function validateIndexableTempRead(program, operand, read, expectedComponents) {
105
+ if (operand?.typeName !== "indexable_temp") return null;
106
+ const address = validateIndexableTempOperand(program, operand, "source");
107
+ if (!address || read?.register !== address.key || !Array.isArray(read.refs) || !read.refs.length || !Array.isArray(expectedComponents) || expectedComponents.length !== read.refs.length || read.refs.some((ref, index) => ref.component !== expectedComponents[index]) || Array.isArray(read.components) && (read.components.length !== expectedComponents.length || read.components.some((component, index) => component !== expectedComponents[index]))) {
108
+ fail("a fixed source has inconsistent register dataflow");
109
+ }
110
+ for (const ref of read.refs) {
111
+ const value = program.values.find(entry => entry.id === ref.valueId);
112
+ if (!value || value.register !== address.key) {
113
+ fail("a fixed source references a value from another register");
114
+ }
115
+ }
116
+ return address;
117
+ }
118
+
119
+ /**
120
+ * Cross-checks a fixed destination operand against its canonical SSA write.
121
+ *
122
+ * @param {object} program Frozen shader IR program.
123
+ * @param {object} operand Indexable-temp destination operand.
124
+ * @param {object} write Register-write dataflow record.
125
+ * @returns {{registerIndex:number, slotIndex:number,key:string}} Validated fixed address.
126
+ */
127
+ function validateIndexableTempWrite(program, operand, write) {
128
+ const address = validateIndexableTempOperand(program, operand, "destination");
129
+ const value = program.values.find(entry => entry.id === write?.valueId);
130
+ if (!address || write?.register !== address.key || write.mask !== operand.mask || !value || value.register !== address.key || value.writeMask !== write.mask) {
131
+ fail("a fixed destination has inconsistent indexable-temp dataflow");
132
+ }
133
+ return address;
134
+ }
135
+
136
+ export { validateIndexableTempOperand, validateIndexableTempRead, validateIndexableTempWrite };
137
+ //# sourceMappingURL=indexableTemps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexableTemps.js","sources":["../../../../../../src/formats/webgpu/core/ir/indexableTemps.js"],"sourcesContent":["const COMPONENTS = \"xyzw\";\nconst DESTINATION_MASK = /^x?y?z?w?$/u;\n\nfunction fail(reason)\n{\n throw new Error(`Shader IR indexable temp is not supported: ${reason}`);\n}\n\nfunction validateComponents(operand, role, componentCount)\n{\n const valid = COMPONENTS.slice(0, componentCount);\n if (role === \"destination\")\n {\n if (typeof operand.mask !== \"string\" || !operand.mask\n || !DESTINATION_MASK.test(operand.mask)\n || Array.from(operand.mask).some((component) => !valid.includes(component))\n || operand.swizzle || operand.selected)\n {\n fail(\"a destination requires one canonical in-range write mask\");\n }\n return;\n }\n if (operand.mask)\n {\n fail(\"a source indexable temp requires swizzle or select component mode\");\n }\n if ([ operand.swizzle, operand.selected ].filter(Boolean).length > 1)\n {\n fail(\"a source requires exactly one component-selection mode\");\n }\n if ((operand.swizzle && (operand.swizzle.length !== 4\n || Array.from(operand.swizzle).some((component) => !valid.includes(component))))\n || (operand.selected && (operand.selected.length !== 1 || !valid.includes(operand.selected))))\n {\n fail(\"a source selects an invalid or out-of-range component\");\n }\n}\n\n/**\n * Validates the declaration-backed identity of an indexable-temp operand.\n * Mutable fixed slots are returned as ordinary SSA register identities.\n * Reads from an extracted immutable table return null so they bypass register\n * SSA and lower through the table expression path instead.\n *\n * @param {object} program Shader IR program under construction or lowering.\n * @param {object} operand Indexable-temp operand.\n * @param {\"source\"|\"destination\"} role Operand role.\n * @returns {{registerIndex:number, slotIndex:number, key:string}|null} Fixed SSA address, or null for a const-table read.\n */\nexport function validateIndexableTempOperand(program, operand, role)\n{\n if (operand?.typeName !== \"indexable_temp\") return null;\n if (![ \"source\", \"destination\" ].includes(role)) throw new TypeError(\"Invalid indexable-temp operand role\");\n\n const indices = operand.indices;\n if (!Array.isArray(indices) || indices.length !== 2)\n {\n fail(\"an operand requires exactly [register][slot] indices\");\n }\n const registerIndex = indices[0];\n if (registerIndex?.relative\n || !Array.isArray(registerIndex?.values)\n || registerIndex.values.length !== 1\n || !Number.isInteger(registerIndex.values[0])\n || registerIndex.values[0] < 0)\n {\n fail(\"the register index must be one fixed non-negative integer\");\n }\n const register = registerIndex.values[0];\n if (!Number.isInteger(operand.registerIndex) || operand.registerIndex !== register)\n {\n fail(\"the operand register identity does not match its first index\");\n }\n\n const declarations = (program.declarations || []).filter((declaration) =>\n declaration.opcodeName === \"dcl_indexable_temp\"\n && declaration.data?.registerIndex === register);\n if (declarations.length !== 1)\n {\n fail(declarations.length ? `x${register} has duplicate declarations` : `x${register} is undeclared`);\n }\n const declaration = declarations[0].data;\n if (!Number.isInteger(declaration.registerCount) || declaration.registerCount < 1)\n {\n fail(`x${register} has no usable slot count`);\n }\n if (!Number.isInteger(declaration.componentCount)\n || declaration.componentCount < 1 || declaration.componentCount > 4)\n {\n fail(`x${register} has an invalid component count`);\n }\n if (operand.componentCount !== 4)\n {\n fail(`x${register} operand is not four-component`);\n }\n validateComponents(operand, role, declaration.componentCount);\n\n const tables = (program.constTables || []).filter((table) => table.registerIndex === register);\n if (tables.length > 1) fail(`x${register} aliases duplicate immutable constant tables`);\n if (tables.length && role === \"destination\") fail(`x${register} aliases an immutable constant table`);\n\n const slotIndex = indices[1];\n if (slotIndex?.relative)\n {\n if (!Array.isArray(slotIndex.values) || slotIndex.values.length > 1\n || (slotIndex.values.length === 1\n && (!Number.isInteger(slotIndex.values[0]) || slotIndex.values[0] < 0)))\n {\n fail(`x${register} has an invalid relative slot base`);\n }\n if (tables.length && role === \"source\") return null;\n fail(`x${register} uses relative ${role} addressing`);\n }\n if (!Array.isArray(slotIndex?.values)\n || slotIndex.values.length !== 1\n || !Number.isInteger(slotIndex.values[0])\n || slotIndex.values[0] < 0)\n {\n fail(`x${register} requires one fixed non-negative slot index`);\n }\n const slot = slotIndex.values[0];\n if (slot >= declaration.registerCount)\n {\n fail(`x${register}[${slot}] is outside its declared range`);\n }\n if (tables.length) return null;\n if (declaration.componentCount !== 4)\n {\n fail(`x${register}[${slot}] is not a four-component mutable operand`);\n }\n return { registerIndex: register, slotIndex: slot, key: `indexable_temp[${register},${slot}]` };\n}\n\n/**\n * Cross-checks a fixed source operand against its canonical SSA read record.\n *\n * @param {object} program Frozen shader IR program.\n * @param {object} operand Indexable-temp source operand.\n * @param {object} read Register-read or index-read dataflow record.\n * @param {string[]} expectedComponents Components selected by the current operand metadata.\n * @returns {{registerIndex:number, slotIndex:number,key:string}} Validated fixed address.\n */\nexport function validateIndexableTempRead(program, operand, read, expectedComponents)\n{\n if (operand?.typeName !== \"indexable_temp\") return null;\n const address = validateIndexableTempOperand(program, operand, \"source\");\n if (!address || read?.register !== address.key || !Array.isArray(read.refs) || !read.refs.length\n || !Array.isArray(expectedComponents) || expectedComponents.length !== read.refs.length\n || read.refs.some((ref, index) => ref.component !== expectedComponents[index])\n || (Array.isArray(read.components)\n && (read.components.length !== expectedComponents.length\n || read.components.some((component, index) => component !== expectedComponents[index]))))\n {\n fail(\"a fixed source has inconsistent register dataflow\");\n }\n for (const ref of read.refs)\n {\n const value = program.values.find((entry) => entry.id === ref.valueId);\n if (!value || value.register !== address.key)\n {\n fail(\"a fixed source references a value from another register\");\n }\n }\n return address;\n}\n\n/**\n * Cross-checks a fixed destination operand against its canonical SSA write.\n *\n * @param {object} program Frozen shader IR program.\n * @param {object} operand Indexable-temp destination operand.\n * @param {object} write Register-write dataflow record.\n * @returns {{registerIndex:number, slotIndex:number,key:string}} Validated fixed address.\n */\nexport function validateIndexableTempWrite(program, operand, write)\n{\n const address = validateIndexableTempOperand(program, operand, \"destination\");\n const value = program.values.find((entry) => entry.id === write?.valueId);\n if (!address || write?.register !== address.key || write.mask !== operand.mask\n || !value || value.register !== address.key || value.writeMask !== write.mask)\n {\n fail(\"a fixed destination has inconsistent indexable-temp dataflow\");\n }\n return address;\n}\n"],"names":["COMPONENTS","DESTINATION_MASK","fail","reason","Error","validateComponents","operand","role","componentCount","valid","slice","mask","test","Array","from","some","component","includes","swizzle","selected","filter","Boolean","length","validateIndexableTempOperand","program","typeName","TypeError","indices","isArray","registerIndex","relative","values","Number","isInteger","register","declarations","declaration","opcodeName","data","registerCount","tables","constTables","table","slotIndex","slot","key","validateIndexableTempRead","read","expectedComponents","address","refs","ref","index","components","value","find","entry","id","valueId","validateIndexableTempWrite","write","writeMask"],"mappings":"AAAA,MAAMA,UAAU,GAAG,MAAM;AACzB,MAAMC,gBAAgB,GAAG,aAAa;AAEtC,SAASC,IAAIA,CAACC,MAAM,EACpB;AACI,EAAA,MAAM,IAAIC,KAAK,CAAC,CAAA,2CAAA,EAA8CD,MAAM,EAAE,CAAC;AAC3E;AAEA,SAASE,kBAAkBA,CAACC,OAAO,EAAEC,IAAI,EAAEC,cAAc,EACzD;EACI,MAAMC,KAAK,GAAGT,UAAU,CAACU,KAAK,CAAC,CAAC,EAAEF,cAAc,CAAC;EACjD,IAAID,IAAI,KAAK,aAAa,EAC1B;IACI,IAAI,OAAOD,OAAO,CAACK,IAAI,KAAK,QAAQ,IAAI,CAACL,OAAO,CAACK,IAAI,IAC9C,CAACV,gBAAgB,CAACW,IAAI,CAACN,OAAO,CAACK,IAAI,CAAC,IACpCE,KAAK,CAACC,IAAI,CAACR,OAAO,CAACK,IAAI,CAAC,CAACI,IAAI,CAAEC,SAAS,IAAK,CAACP,KAAK,CAACQ,QAAQ,CAACD,SAAS,CAAC,CAAC,IACxEV,OAAO,CAACY,OAAO,IAAIZ,OAAO,CAACa,QAAQ,EAC1C;MACIjB,IAAI,CAAC,0DAA0D,CAAC;AACpE,IAAA;AACA,IAAA;AACJ,EAAA;EACA,IAAII,OAAO,CAACK,IAAI,EAChB;IACIT,IAAI,CAAC,mEAAmE,CAAC;AAC7E,EAAA;AACA,EAAA,IAAI,CAAEI,OAAO,CAACY,OAAO,EAAEZ,OAAO,CAACa,QAAQ,CAAE,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,MAAM,GAAG,CAAC,EACpE;IACIpB,IAAI,CAAC,wDAAwD,CAAC;AAClE,EAAA;EACA,IAAKI,OAAO,CAACY,OAAO,KAAKZ,OAAO,CAACY,OAAO,CAACI,MAAM,KAA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ACA,EAAA,OAAO+C,OAAO;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASU,0BAA0BA,CAACnC,OAAO,EAAElB,OAAO,EAAEsD,KAAK,EAClE;EACI,MAAMX,OAAO,GAAG1B,4BAA4B,CAACC,OAAO,EAAElB,OAAO,EAAE,aAAa,CAAC;AAC7E,EAAA,MAAMgD,KAAK,GAAG9B,OAAO,CAACO,MAAM,CAACwB,IAAI,CAAEC,KAAK,IAAKA,KAAK,CAACC,EAAE,KAAKG,KAAK,EAAEF,OAAO,CAAC;AACzE,EAAA,IAAI,CAACT,OAAO,IAAIW,KAAK,EAAE1B,QAAQ,KAAKe,OAAO,CAACJ,GAAG,IAAIe,KAAK,CAACjD,IAAI,KAAKL,OAAO,CAACK,IAAI,IACvE,CAAC2C,KAAK,IAAIA,KAAK,CAACpB,QAAQ,KAAKe,OAAO,CAACJ,GAAG,IAAIS,KAAK,CAACO,SAAS,KAAKD,KAAK,CAACjD,IAAI,EACjF;IACIT,IAAI,CAAC,8DAA8D,CAAC;AACxE,EAAA;AACA,EAAA,OAAO+C,OAAO;AAClB;;;;"}
@@ -0,0 +1,454 @@
1
+ const COMPONENTS = ["x", "y", "z", "w"];
2
+ const COMPONENT_INDEX = new Map(COMPONENTS.map((component, index) => [component, index]));
3
+ const SCALAR_TYPES = Object.freeze(["unknown", "float32", "int32", "uint32", "bool", "bitpattern32"]);
4
+ const FLOAT_OPS = new Set(["add", "deriv_rtx", "deriv_rty", "deriv_rtx_coarse", "deriv_rtx_fine", "deriv_rty_coarse", "deriv_rty_fine", "div", "dp2", "dp3", "dp4", "exp", "frc", "log", "mad", "max", "min", "mul", "rcp", "round_ne", "round_ni", "round_pi", "round_z", "rsq", "sqrt", "sincos"]);
5
+ const FLOAT_COMPARE = new Set(["eq", "ge", "lt", "ne"]);
6
+ const INT_OPS = new Set(["iadd", "imad", "imax", "imin", "imul", "ineg", "ishl", "ishr"]);
7
+ const INT_COMPARE = new Set(["ieq", "ige", "ilt", "ine"]);
8
+ const UINT_OPS = new Set(["countbits", "firstbit_hi", "firstbit_lo", "firstbit_shi", "uaddc", "ubfe", "udiv", "umad", "umax", "umin", "umul", "ushr", "usubb"]);
9
+ const UINT_COMPARE = new Set(["uge", "ult"]);
10
+ const BITWISE_OPS = new Set(["and", "not", "or", "xor"]);
11
+ const CONTROL_MASK_OPS = new Set(["breakc", "continuec", "discard", "if", "retc", "switch"]);
12
+ const SAMPLE_OPS = new Set(["sample", "sample_b", "sample_c", "sample_c_lz", "sample_d", "sample_l"]);
13
+ function bindingResultType(program, instruction, operandTypeName, resourceKind) {
14
+ const resource = instruction.operands.find(operand => operand.typeName === operandTypeName);
15
+ const reference = resource?.resourceReference;
16
+ const binding = program.bindings.find(entry => entry.resourceKind === resourceKind && (reference?.rangeId !== null && reference?.rangeId !== undefined ? entry.range.rangeId === reference.rangeId : entry.registerIndex === resource?.registerIndex));
17
+ const mapped = (binding?.returnType?.returnTypeNames || []).map(type => ({
18
+ unorm: "float32",
19
+ snorm: "float32",
20
+ float: "float32",
21
+ sint: "int32",
22
+ uint: "uint32"
23
+ })[type] || "unknown");
24
+ const concrete = mapped.filter(type => type !== "unknown");
25
+ if (!concrete.length) return null;
26
+ return new Set(concrete).size === 1 ? concrete[0] : "bitpattern32";
27
+ }
28
+ function sampleResultType(program, instruction) {
29
+ return bindingResultType(program, instruction, "resource", "sampled-resource");
30
+ }
31
+ function ruleFor(opcodeName, program, instruction) {
32
+ if (FLOAT_OPS.has(opcodeName)) return {
33
+ name: "float-arithmetic",
34
+ destination: "float32",
35
+ sources: "float32"
36
+ };
37
+ if (FLOAT_COMPARE.has(opcodeName)) return {
38
+ name: "float-comparison-mask",
39
+ destination: "uint32",
40
+ sources: "float32"
41
+ };
42
+ if (INT_OPS.has(opcodeName)) return {
43
+ name: "signed-integer",
44
+ destination: "int32",
45
+ sources: "int32"
46
+ };
47
+ if (INT_COMPARE.has(opcodeName)) return {
48
+ name: "signed-comparison-mask",
49
+ destination: "uint32",
50
+ sources: "int32"
51
+ };
52
+ if (UINT_OPS.has(opcodeName)) return {
53
+ name: "unsigned-integer",
54
+ destination: "uint32",
55
+ sources: "uint32"
56
+ };
57
+ if (UINT_COMPARE.has(opcodeName)) return {
58
+ name: "unsigned-comparison-mask",
59
+ destination: "uint32",
60
+ sources: "uint32"
61
+ };
62
+ if (BITWISE_OPS.has(opcodeName)) return {
63
+ name: "bitwise",
64
+ destination: "uint32",
65
+ sources: "uint32"
66
+ };
67
+ if (CONTROL_MASK_OPS.has(opcodeName)) return {
68
+ name: "control-mask",
69
+ destination: null,
70
+ sourceByOperand: {
71
+ 0: "uint32"
72
+ },
73
+ conditionProjection: "nonzero"
74
+ };
75
+ if (SAMPLE_OPS.has(opcodeName)) {
76
+ const sourceByOperand = {
77
+ 1: "float32"
78
+ };
79
+ if (["sample_b", "sample_c", "sample_l"].includes(opcodeName)) sourceByOperand[4] = "float32";
80
+ if (opcodeName === "sample_d") Object.assign(sourceByOperand, {
81
+ 4: "float32",
82
+ 5: "float32"
83
+ });
84
+ return {
85
+ name: "sample-resource",
86
+ destination: sampleResultType(program, instruction),
87
+ sourceByOperand
88
+ };
89
+ }
90
+ if (opcodeName === "resinfo") {
91
+ return {
92
+ name: "resource-info",
93
+ destination: instruction?.resinfoReturnTypeName === "uint" ? "uint32" : "float32"
94
+ };
95
+ }
96
+ if (opcodeName === "f16tof32") return {
97
+ name: "half-unpack",
98
+ destination: "float32",
99
+ sourceByOperand: {
100
+ 1: "uint32"
101
+ }
102
+ };
103
+ if (opcodeName === "f32tof16") return {
104
+ name: "half-pack",
105
+ destination: "uint32",
106
+ sourceByOperand: {
107
+ 1: "float32"
108
+ }
109
+ };
110
+ if (opcodeName === "ld") {
111
+ return {
112
+ name: "texture-load",
113
+ destination: sampleResultType(program, instruction),
114
+ sourceByOperand: {
115
+ 1: "uint32"
116
+ }
117
+ };
118
+ }
119
+ if (opcodeName === "atomic_iadd") {
120
+ return {
121
+ name: "atomic-add",
122
+ destination: null,
123
+ sourceByOperand: {
124
+ 1: "uint32",
125
+ 2: "uint32"
126
+ }
127
+ };
128
+ }
129
+ if (opcodeName === "store_uav_typed") {
130
+ return {
131
+ name: "typed-uav-store",
132
+ destination: null,
133
+ sourceByOperand: {
134
+ 1: "uint32",
135
+ 2: bindingResultType(program, instruction, "uav", "storage-resource")
136
+ }
137
+ };
138
+ }
139
+ if (opcodeName === "ld_structured") {
140
+ return {
141
+ name: "structured-load",
142
+ destination: null,
143
+ sourceByOperand: {
144
+ 1: "uint32",
145
+ 2: "uint32"
146
+ }
147
+ };
148
+ }
149
+ if (opcodeName === "store_structured") {
150
+ return {
151
+ name: "structured-store",
152
+ destination: null,
153
+ sourceByOperand: {
154
+ 1: "uint32",
155
+ 2: "uint32"
156
+ }
157
+ };
158
+ }
159
+ const conversions = {
160
+ ftoi: ["int32", "float32"],
161
+ ftou: ["uint32", "float32"],
162
+ itof: ["float32", "int32"],
163
+ utof: ["float32", "uint32"]
164
+ };
165
+ if (conversions[opcodeName]) {
166
+ const [destination, source] = conversions[opcodeName];
167
+ return {
168
+ name: "numeric-conversion",
169
+ destination,
170
+ sourceByOperand: {
171
+ 1: source
172
+ },
173
+ conversion: {
174
+ from: source,
175
+ to: destination
176
+ }
177
+ };
178
+ }
179
+ if (opcodeName === "mov") return {
180
+ name: "move",
181
+ destination: null,
182
+ equalitySources: [1]
183
+ };
184
+ if (opcodeName === "movc") return {
185
+ name: "conditional-move",
186
+ destination: null,
187
+ sourceByOperand: {
188
+ 1: "uint32"
189
+ },
190
+ equalitySources: [2, 3]
191
+ };
192
+ return {
193
+ name: "untyped",
194
+ destination: null
195
+ };
196
+ }
197
+ function nodeKey(ref) {
198
+ return `${ref.valueId}.${ref.component}`;
199
+ }
200
+ function valueComponents(value) {
201
+ return Array.from(value.writeMask || "");
202
+ }
203
+ function signatureType(program, register, component) {
204
+ if (["output_depth", "output_depth_greater_equal", "output_depth_less_equal"].includes(register)) return "float32";
205
+ const match = /^(input|output)\[(\d+)/.exec(register);
206
+ if (!match) return null;
207
+ const elements = program.signatures?.[match[1]] || [];
208
+ const componentBit = 1 << COMPONENT_INDEX.get(component);
209
+ const element = elements.find(entry => entry.registerIndex === Number(match[2]) && entry.mask & componentBit);
210
+ return element && SCALAR_TYPES.includes(element.componentTypeName) ? element.componentTypeName : null;
211
+ }
212
+ function correspondingRef(refs, index) {
213
+ if (!refs.length) return null;
214
+ return refs.length === 1 ? refs[0] : refs[index % refs.length];
215
+ }
216
+
217
+ /**
218
+ * Infers component storage types from opcode domains, signatures, moves, and
219
+ * SSA merges. Conflicting typeless-register uses become `bitpattern32` and
220
+ * receive explicit per-use reinterpret records.
221
+ *
222
+ * @param {object} program Mutable shader IR under construction.
223
+ * @returns {object} The same program.
224
+ */
225
+ function inferValueTypes(program) {
226
+ const parent = new Map();
227
+ const constraints = new Map();
228
+ const ensure = ref => {
229
+ const key = nodeKey(ref);
230
+ if (!parent.has(key)) {
231
+ parent.set(key, key);
232
+ constraints.set(key, new Set());
233
+ }
234
+ return key;
235
+ };
236
+ const find = key => {
237
+ let current = key;
238
+ while (parent.get(current) !== current) current = parent.get(current);
239
+ while (parent.get(key) !== key) {
240
+ const next = parent.get(key);
241
+ parent.set(key, current);
242
+ key = next;
243
+ }
244
+ return current;
245
+ };
246
+ const union = (leftRef, rightRef) => {
247
+ const left = find(ensure(leftRef));
248
+ const right = find(ensure(rightRef));
249
+ if (left === right) return;
250
+ const [root, child] = left.localeCompare(right) <= 0 ? [left, right] : [right, left];
251
+ parent.set(child, root);
252
+ for (const type of constraints.get(child)) constraints.get(root).add(type);
253
+ };
254
+ const constrain = (ref, type) => {
255
+ if (!type) return;
256
+ constraints.get(find(ensure(ref))).add(type);
257
+ };
258
+ for (const value of program.values) {
259
+ for (const component of valueComponents(value)) ensure({
260
+ valueId: value.id,
261
+ component
262
+ });
263
+ if (value.origin === "control-flow-merge") {
264
+ const mergeRef = {
265
+ valueId: value.id,
266
+ component: value.writeMask
267
+ };
268
+ for (const incoming of value.incoming) union(mergeRef, incoming);
269
+ }
270
+ }
271
+ for (const instruction of program.instructions) {
272
+ const rule = ruleFor(instruction.opcodeName, program, instruction);
273
+ const writes = instruction.dataflow.writes;
274
+ for (const sourceOperandIndex of rule.equalitySources || []) {
275
+ const read = instruction.dataflow.reads.find(entry => entry.operandIndex === sourceOperandIndex && entry.kind !== "index-read");
276
+ if (!read) continue;
277
+ for (const write of writes) {
278
+ Array.from(write.mask).forEach((component, index) => {
279
+ const sourceRef = correspondingRef(read.refs, index);
280
+ if (sourceRef) union({
281
+ valueId: write.valueId,
282
+ component
283
+ }, sourceRef);
284
+ });
285
+ }
286
+ }
287
+ }
288
+ for (const value of program.values) {
289
+ for (const component of valueComponents(value)) {
290
+ const type = signatureType(program, value.register, component);
291
+ if (type) constrain({
292
+ valueId: value.id,
293
+ component
294
+ }, type);
295
+ }
296
+ }
297
+ for (const instruction of program.instructions) {
298
+ const rule = ruleFor(instruction.opcodeName, program, instruction);
299
+ if (rule.destination) {
300
+ for (const write of instruction.dataflow.writes) {
301
+ for (const component of write.mask) constrain({
302
+ valueId: write.valueId,
303
+ component
304
+ }, rule.destination);
305
+ }
306
+ }
307
+ for (const read of instruction.dataflow.reads) {
308
+ if (read.kind === "index-read") continue;
309
+ const expected = rule.sourceByOperand?.[read.operandIndex] ?? rule.sources ?? null;
310
+ for (const ref of read.refs) constrain(ref, expected);
311
+ }
312
+ }
313
+
314
+ // A live value (read by an instruction or feeding a phi) whose type is
315
+ // otherwise unconstrained — e.g. an immediate `0` that only ever flows
316
+ // through moves and never reaches a typed use — defaults to raw bitpattern32
317
+ // bits so it can be emitted. This covers EVERY lane of a live value, not
318
+ // just the read lane: an emitted multi-lane value needs a type for its dead
319
+ // lanes too (the vector constructor references all of them). Because moves
320
+ // union source and destination, the default propagates consistently across
321
+ // the whole move chain and any phi it feeds. Genuinely dead writes are never
322
+ // read, keep no constraint (stay `unknown`), and are dropped by the lowerers.
323
+ const liveValueIds = new Set();
324
+ for (const instruction of program.instructions) {
325
+ for (const read of instruction.dataflow.reads) {
326
+ if (read.kind === "index-read") continue;
327
+ for (const ref of read.refs) liveValueIds.add(ref.valueId);
328
+ }
329
+ }
330
+ for (const value of program.values) {
331
+ for (const incoming of value.incoming || []) liveValueIds.add(incoming.valueId);
332
+ }
333
+ for (const value of program.values) {
334
+ if (!liveValueIds.has(value.id)) continue;
335
+ for (const component of valueComponents(value)) {
336
+ const ref = {
337
+ valueId: value.id,
338
+ component
339
+ };
340
+ if (!constraints.get(find(ensure(ref))).size) constrain(ref, "bitpattern32");
341
+ }
342
+ }
343
+ const typeForRef = ref => {
344
+ const types = Array.from(constraints.get(find(ensure(ref))));
345
+ if (types.length === 0) return "unknown";
346
+ return types.length === 1 ? types[0] : "bitpattern32";
347
+ };
348
+ for (const value of program.values) {
349
+ value.componentTypes = {};
350
+ for (const component of valueComponents(value)) {
351
+ value.componentTypes[component] = typeForRef({
352
+ valueId: value.id,
353
+ component
354
+ });
355
+ }
356
+ }
357
+ for (const instruction of program.instructions) {
358
+ const rule = ruleFor(instruction.opcodeName, program, instruction);
359
+ const writes = instruction.dataflow.writes;
360
+ const destinationTypes = writes.flatMap(write => Array.from(write.mask).map(component => program.values.find(value => value.id === write.valueId)?.componentTypes[component])).filter(Boolean);
361
+ const moveType = destinationTypes.length && new Set(destinationTypes).size === 1 ? destinationTypes[0] : null;
362
+ const operandTypes = instruction.operands.map((operand, operandIndex) => {
363
+ let expectedType = rule.sourceByOperand?.[operandIndex] ?? null;
364
+ if (!expectedType && rule.sources && operandIndex > 0) expectedType = rule.sources;
365
+ if (!expectedType && (rule.equalitySources || []).includes(operandIndex)) expectedType = moveType;
366
+ if (instruction.dataflow.writes.some(write => write.operandIndex === operandIndex)) expectedType = rule.destination ?? moveType;
367
+ return {
368
+ operandIndex,
369
+ role: instruction.dataflow.writes.some(write => write.operandIndex === operandIndex) ? "destination" : "source",
370
+ expectedType: expectedType || "unknown",
371
+ modifier: operand.modifierName || "none",
372
+ minPrecision: operand.minPrecisionName || "default",
373
+ immediate: operand.typeName === "immediate32" ? operand.immediateValues.map((value, component) => ({
374
+ component: COMPONENTS[component],
375
+ uint32: value.uint32,
376
+ float32: value.float32
377
+ })) : null
378
+ };
379
+ });
380
+ const bitcasts = [];
381
+ for (const read of instruction.dataflow.reads) {
382
+ if (read.kind === "index-read") continue;
383
+ let expected = rule.sourceByOperand?.[read.operandIndex] ?? rule.sources ?? null;
384
+ if (!expected && (rule.equalitySources || []).includes(read.operandIndex)) expected = moveType;
385
+ if (!expected || expected === "unknown") continue;
386
+ read.refs.forEach((ref, componentIndex) => {
387
+ const storage = typeForRef(ref);
388
+ if (storage !== expected && storage !== "unknown") {
389
+ bitcasts.push({
390
+ kind: "read-bitcast",
391
+ operandIndex: read.operandIndex,
392
+ componentIndex,
393
+ valueId: ref.valueId,
394
+ component: ref.component,
395
+ from: storage,
396
+ to: expected
397
+ });
398
+ }
399
+ });
400
+ }
401
+ for (const write of writes) {
402
+ if (!rule.destination) continue;
403
+ Array.from(write.mask).forEach(component => {
404
+ const storage = typeForRef({
405
+ valueId: write.valueId,
406
+ component
407
+ });
408
+ if (storage !== rule.destination && storage !== "unknown") {
409
+ bitcasts.push({
410
+ kind: "result-bitcast",
411
+ operandIndex: write.operandIndex,
412
+ valueId: write.valueId,
413
+ component,
414
+ from: rule.destination,
415
+ to: storage
416
+ });
417
+ }
418
+ });
419
+ }
420
+ for (const operand of operandTypes) {
421
+ if (!operand.immediate || !["float32", "int32"].includes(operand.expectedType)) continue;
422
+ for (const immediate of operand.immediate) {
423
+ bitcasts.push({
424
+ kind: "immediate-bitcast",
425
+ operandIndex: operand.operandIndex,
426
+ component: immediate.component,
427
+ from: "uint32",
428
+ to: operand.expectedType,
429
+ uint32: immediate.uint32
430
+ });
431
+ }
432
+ }
433
+ instruction.typeInfo = {
434
+ kind: "instruction-types",
435
+ rule: rule.name,
436
+ resultType: rule.destination ?? moveType ?? "unknown",
437
+ conversion: rule.conversion || null,
438
+ conditionProjection: rule.conditionProjection || null,
439
+ operandTypes,
440
+ bitcasts
441
+ };
442
+ }
443
+ program.typeSystem = {
444
+ kind: "scalar-type-system",
445
+ scalarTypes: SCALAR_TYPES.slice(),
446
+ comparisonResult: "uint32-mask",
447
+ conditionProjection: "nonzero",
448
+ registerStorage: "component-granular"
449
+ };
450
+ return program;
451
+ }
452
+
453
+ export { SCALAR_TYPES, inferValueTypes };
454
+ //# sourceMappingURL=inferValueTypes.js.map