@carbonenginejs/runtime-resource 0.10.0 → 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 (254) hide show
  1. package/dist/format/effect/effectPermutationGraph.js +257 -0
  2. package/dist/format/effect/effectPermutationGraph.js.map +1 -0
  3. package/dist/format/effect/effectReflectionPackage.js +636 -0
  4. package/dist/format/effect/effectReflectionPackage.js.map +1 -0
  5. package/dist/format/effect/sha256.js +114 -0
  6. package/dist/format/effect/sha256.js.map +1 -0
  7. package/dist/formats/dxbc/CjsDxbcFormat.js +142 -0
  8. package/dist/formats/dxbc/CjsDxbcFormat.js.map +1 -0
  9. package/dist/formats/dxbc/core/DxbcReader.js +266 -0
  10. package/dist/formats/dxbc/core/DxbcReader.js.map +1 -0
  11. package/dist/formats/dxbc/core/container.js +169 -0
  12. package/dist/formats/dxbc/core/container.js.map +1 -0
  13. package/dist/formats/dxbc/core/decoder.js +789 -0
  14. package/dist/formats/dxbc/core/decoder.js.map +1 -0
  15. package/dist/formats/dxbc/core/errors.js +19 -0
  16. package/dist/formats/dxbc/core/errors.js.map +1 -0
  17. package/dist/formats/dxbc/core/helpers.js +220 -0
  18. package/dist/formats/dxbc/core/helpers.js.map +1 -0
  19. package/dist/formats/dxbc/core/opcodes.js +45 -0
  20. package/dist/formats/dxbc/core/opcodes.js.map +1 -0
  21. package/dist/formats/dxbc/core/program.js +91 -0
  22. package/dist/formats/dxbc/core/program.js.map +1 -0
  23. package/dist/formats/dxbc/core/signature.js +172 -0
  24. package/dist/formats/dxbc/core/signature.js.map +1 -0
  25. package/dist/formats/dxbc/index.js +2 -0
  26. package/dist/formats/dxbc/index.js.map +1 -0
  27. package/dist/formats/hlsl/CjsHlslFormat.js +254 -0
  28. package/dist/formats/hlsl/CjsHlslFormat.js.map +1 -0
  29. package/dist/formats/hlsl/core/HlslBinaryUtils.js +15 -0
  30. package/dist/formats/hlsl/core/HlslBinaryUtils.js.map +1 -0
  31. package/dist/formats/hlsl/core/HlslEffectReadError.js +19 -0
  32. package/dist/formats/hlsl/core/HlslEffectReadError.js.map +1 -0
  33. package/dist/formats/hlsl/core/HlslEffectStateManager.js +130 -0
  34. package/dist/formats/hlsl/core/HlslEffectStateManager.js.map +1 -0
  35. package/dist/formats/hlsl/core/HlslReader.js +266 -0
  36. package/dist/formats/hlsl/core/HlslReader.js.map +1 -0
  37. package/dist/formats/hlsl/core/HlslRenderStateSetup.js +37 -0
  38. package/dist/formats/hlsl/core/HlslRenderStateSetup.js.map +1 -0
  39. package/dist/formats/hlsl/core/HlslResourceSetDescription.js +94 -0
  40. package/dist/formats/hlsl/core/HlslResourceSetDescription.js.map +1 -0
  41. package/dist/formats/hlsl/core/HlslShaderBytecode.js +44 -0
  42. package/dist/formats/hlsl/core/HlslShaderBytecode.js.map +1 -0
  43. package/dist/formats/hlsl/core/analysis.js +51 -0
  44. package/dist/formats/hlsl/core/analysis.js.map +1 -0
  45. package/dist/formats/hlsl/core/helpers.js +270 -0
  46. package/dist/formats/hlsl/core/helpers.js.map +1 -0
  47. package/dist/formats/hlsl/core/json.js +284 -0
  48. package/dist/formats/hlsl/core/json.js.map +1 -0
  49. package/dist/formats/hlsl/core/metadata.js +327 -0
  50. package/dist/formats/hlsl/core/metadata.js.map +1 -0
  51. package/dist/formats/hlsl/core/portableReflection.js +848 -0
  52. package/dist/formats/hlsl/core/portableReflection.js.map +1 -0
  53. package/dist/formats/hlsl/core/render-states.js +280 -0
  54. package/dist/formats/hlsl/core/render-states.js.map +1 -0
  55. package/dist/formats/hlsl/core/tr2/HlslRenderContextEnum.js +43 -0
  56. package/dist/formats/hlsl/core/tr2/HlslRenderContextEnum.js.map +1 -0
  57. package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +294 -0
  58. package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -0
  59. package/dist/formats/hlsl/core/tr2/resources/HlslShaderPermutation.js +33 -0
  60. package/dist/formats/hlsl/core/tr2/resources/HlslShaderPermutation.js.map +1 -0
  61. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js +416 -0
  62. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js.map +1 -0
  63. package/dist/formats/hlsl/core/tr2/shader/HlslEffectConstant.js +40 -0
  64. package/dist/formats/hlsl/core/tr2/shader/HlslEffectConstant.js.map +1 -0
  65. package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js +742 -0
  66. package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js.map +1 -0
  67. package/dist/formats/hlsl/core/tr2/shader/HlslEffectLibrary.js +52 -0
  68. package/dist/formats/hlsl/core/tr2/shader/HlslEffectLibrary.js.map +1 -0
  69. package/dist/formats/hlsl/core/tr2/shader/HlslEffectParameterAnnotation.js +38 -0
  70. package/dist/formats/hlsl/core/tr2/shader/HlslEffectParameterAnnotation.js.map +1 -0
  71. package/dist/formats/hlsl/core/tr2/shader/HlslEffectResource.js +50 -0
  72. package/dist/formats/hlsl/core/tr2/shader/HlslEffectResource.js.map +1 -0
  73. package/dist/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js +86 -0
  74. package/dist/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js.map +1 -0
  75. package/dist/formats/hlsl/core/tr2/shader/HlslEffectTechnique.js +31 -0
  76. package/dist/formats/hlsl/core/tr2/shader/HlslEffectTechnique.js.map +1 -0
  77. package/dist/formats/hlsl/core/tr2/shader/HlslPass.js +42 -0
  78. package/dist/formats/hlsl/core/tr2/shader/HlslPass.js.map +1 -0
  79. package/dist/formats/hlsl/core/tr2/shader/HlslSamplerDescription.js +55 -0
  80. package/dist/formats/hlsl/core/tr2/shader/HlslSamplerDescription.js.map +1 -0
  81. package/dist/formats/hlsl/core/tr2/shader/HlslSamplerSetup.js +29 -0
  82. package/dist/formats/hlsl/core/tr2/shader/HlslSamplerSetup.js.map +1 -0
  83. package/dist/formats/hlsl/core/tr2/shader/HlslShader.js +220 -0
  84. package/dist/formats/hlsl/core/tr2/shader/HlslShader.js.map +1 -0
  85. package/dist/formats/hlsl/core/tr2/shader/HlslShaderOption.js +30 -0
  86. package/dist/formats/hlsl/core/tr2/shader/HlslShaderOption.js.map +1 -0
  87. package/dist/formats/hlsl/index.js +2 -0
  88. package/dist/formats/hlsl/index.js.map +1 -0
  89. package/dist/formats/hlsl/portable.js +2 -0
  90. package/dist/formats/hlsl/portable.js.map +1 -0
  91. package/dist/formats/index.js +4 -0
  92. package/dist/formats/index.js.map +1 -1
  93. package/dist/formats/webgl/CjsWebglFormat.js +221 -0
  94. package/dist/formats/webgl/CjsWebglFormat.js.map +1 -0
  95. package/dist/formats/webgl/core/cewg/CewgPackage.js +339 -0
  96. package/dist/formats/webgl/core/cewg/CewgPackage.js.map +1 -0
  97. package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js +104 -0
  98. package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js.map +1 -0
  99. package/dist/formats/webgl/core/cewg/binary.js +101 -0
  100. package/dist/formats/webgl/core/cewg/binary.js.map +1 -0
  101. package/dist/formats/webgl/core/cewgCompleteness.js +81 -0
  102. package/dist/formats/webgl/core/cewgCompleteness.js.map +1 -0
  103. package/dist/formats/webgl/core/effectPackage.js +789 -0
  104. package/dist/formats/webgl/core/effectPackage.js.map +1 -0
  105. package/dist/formats/webgl/core/effectPackageValidation.js +331 -0
  106. package/dist/formats/webgl/core/effectPackageValidation.js.map +1 -0
  107. package/dist/formats/webgl/core/errors.js +27 -0
  108. package/dist/formats/webgl/core/errors.js.map +1 -0
  109. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +2678 -0
  110. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -0
  111. package/dist/formats/webgl/core/glsl/DxbcGlslHelpers.js +89 -0
  112. package/dist/formats/webgl/core/glsl/DxbcGlslHelpers.js.map +1 -0
  113. package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js +428 -0
  114. package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js.map +1 -0
  115. package/dist/formats/webgl/core/helpers.js +306 -0
  116. package/dist/formats/webgl/core/helpers.js.map +1 -0
  117. package/dist/formats/webgl/index.js +2 -0
  118. package/dist/formats/webgl/index.js.map +1 -0
  119. package/dist/formats/webgpu/CjsWebgpuFormat.js +376 -0
  120. package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -0
  121. package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js +415 -0
  122. package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js.map +1 -0
  123. package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js +100 -0
  124. package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js.map +1 -0
  125. package/dist/formats/webgpu/core/cewgpu/binary.js +93 -0
  126. package/dist/formats/webgpu/core/cewgpu/binary.js.map +1 -0
  127. package/dist/formats/webgpu/core/cewgpu/tags.js +17 -0
  128. package/dist/formats/webgpu/core/cewgpu/tags.js.map +1 -0
  129. package/dist/formats/webgpu/core/effectAnalysis.js +82 -0
  130. package/dist/formats/webgpu/core/effectAnalysis.js.map +1 -0
  131. package/dist/formats/webgpu/core/effectBackendBodySet.js +305 -0
  132. package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -0
  133. package/dist/formats/webgpu/core/effectPackageValidation.js +1078 -0
  134. package/dist/formats/webgpu/core/effectPackageValidation.js.map +1 -0
  135. package/dist/formats/webgpu/core/errors.js +20 -0
  136. package/dist/formats/webgpu/core/errors.js.map +1 -0
  137. package/dist/formats/webgpu/core/helpers.js +448 -0
  138. package/dist/formats/webgpu/core/helpers.js.map +1 -0
  139. package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +223 -0
  140. package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js.map +1 -0
  141. package/dist/formats/webgpu/core/ir/buildControlFlow.js +220 -0
  142. package/dist/formats/webgpu/core/ir/buildControlFlow.js.map +1 -0
  143. package/dist/formats/webgpu/core/ir/indexableTemps.js +137 -0
  144. package/dist/formats/webgpu/core/ir/indexableTemps.js.map +1 -0
  145. package/dist/formats/webgpu/core/ir/inferValueTypes.js +454 -0
  146. package/dist/formats/webgpu/core/ir/inferValueTypes.js.map +1 -0
  147. package/dist/formats/webgpu/core/ir/lowerDxbcToIr.js +494 -0
  148. package/dist/formats/webgpu/core/ir/lowerDxbcToIr.js.map +1 -0
  149. package/dist/formats/webgpu/core/ir/resolveRegisterFlow.js +177 -0
  150. package/dist/formats/webgpu/core/ir/resolveRegisterFlow.js.map +1 -0
  151. package/dist/formats/webgpu/core/ir/sourceLanes.js +61 -0
  152. package/dist/formats/webgpu/core/ir/sourceLanes.js.map +1 -0
  153. package/dist/formats/webgpu/core/packageEffect.js +300 -0
  154. package/dist/formats/webgpu/core/packageEffect.js.map +1 -0
  155. package/dist/formats/webgpu/core/packageEffectSelection.js +164 -0
  156. package/dist/formats/webgpu/core/packageEffectSelection.js.map +1 -0
  157. package/dist/formats/webgpu/core/packageMetadata.js +8 -0
  158. package/dist/formats/webgpu/core/packageMetadata.js.map +1 -0
  159. package/dist/formats/webgpu/core/schema.js +4 -0
  160. package/dist/formats/webgpu/core/schema.js.map +1 -0
  161. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +275 -0
  162. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -0
  163. package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +182 -0
  164. package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js.map +1 -0
  165. package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +324 -0
  166. package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -0
  167. package/dist/formats/webgpu/core/wgsl/emitWgsl.js +356 -0
  168. package/dist/formats/webgpu/core/wgsl/emitWgsl.js.map +1 -0
  169. package/dist/formats/webgpu/core/wgsl/hoistEscapingValues.js +77 -0
  170. package/dist/formats/webgpu/core/wgsl/hoistEscapingValues.js.map +1 -0
  171. package/dist/formats/webgpu/core/wgsl/lowerBindingLayout.js +451 -0
  172. package/dist/formats/webgpu/core/wgsl/lowerBindingLayout.js.map +1 -0
  173. package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +754 -0
  174. package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js.map +1 -0
  175. package/dist/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js +457 -0
  176. package/dist/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js.map +1 -0
  177. package/dist/formats/webgpu/core/wgsl/lowerFragmentProgram.js +1572 -0
  178. package/dist/formats/webgpu/core/wgsl/lowerFragmentProgram.js.map +1 -0
  179. package/dist/formats/webgpu/core/wgsl/lowerMergeHistogramsComputeProgram.js +659 -0
  180. package/dist/formats/webgpu/core/wgsl/lowerMergeHistogramsComputeProgram.js.map +1 -0
  181. package/dist/formats/webgpu/core/wgsl/lowerParticleClearComputePrograms.js +734 -0
  182. package/dist/formats/webgpu/core/wgsl/lowerParticleClearComputePrograms.js.map +1 -0
  183. package/dist/formats/webgpu/core/wgsl/lowerParticleEmitComputeProgram.js +583 -0
  184. package/dist/formats/webgpu/core/wgsl/lowerParticleEmitComputeProgram.js.map +1 -0
  185. package/dist/formats/webgpu/core/wgsl/lowerSkinVerticesComputeProgram.js +621 -0
  186. package/dist/formats/webgpu/core/wgsl/lowerSkinVerticesComputeProgram.js.map +1 -0
  187. package/dist/formats/webgpu/core/wgsl/lowerSortComputeProgram.js +824 -0
  188. package/dist/formats/webgpu/core/wgsl/lowerSortComputeProgram.js.map +1 -0
  189. package/dist/formats/webgpu/core/wgsl/lowerSortInnerComputeProgram.js +697 -0
  190. package/dist/formats/webgpu/core/wgsl/lowerSortInnerComputeProgram.js.map +1 -0
  191. package/dist/formats/webgpu/core/wgsl/lowerSortStepComputeProgram.js +559 -0
  192. package/dist/formats/webgpu/core/wgsl/lowerSortStepComputeProgram.js.map +1 -0
  193. package/dist/formats/webgpu/core/wgsl/lowerVertexProgram.js +1328 -0
  194. package/dist/formats/webgpu/core/wgsl/lowerVertexProgram.js.map +1 -0
  195. package/dist/formats/webgpu/core/wgsl/particleEmitSemanticDigest.js +110 -0
  196. package/dist/formats/webgpu/core/wgsl/particleEmitSemanticDigest.js.map +1 -0
  197. package/dist/formats/webgpu/core/wgsl/precisionControls.js +55 -0
  198. package/dist/formats/webgpu/core/wgsl/precisionControls.js.map +1 -0
  199. package/dist/formats/webgpu/core/wgsl/selectionPlans.js +758 -0
  200. package/dist/formats/webgpu/core/wgsl/selectionPlans.js.map +1 -0
  201. package/dist/formats/webgpu/core/wgsl/uniformity.js +78 -0
  202. package/dist/formats/webgpu/core/wgsl/uniformity.js.map +1 -0
  203. package/dist/formats/webgpu/core/wgsl/validateExactComputeIr.js +196 -0
  204. package/dist/formats/webgpu/core/wgsl/validateExactComputeIr.js.map +1 -0
  205. package/dist/formats/webgpu/core/wgsl/validateHandleOperand.js +37 -0
  206. package/dist/formats/webgpu/core/wgsl/validateHandleOperand.js.map +1 -0
  207. package/dist/formats/webgpu/index.js +2 -0
  208. package/dist/formats/webgpu/index.js.map +1 -0
  209. package/dist/resource/shader/Tr2EffectRes.js +159 -150
  210. package/dist/resource/shader/Tr2EffectRes.js.map +1 -1
  211. package/dist/resource/shader/Tr2MaterialArea.js +23 -28
  212. package/dist/resource/shader/Tr2MaterialArea.js.map +1 -1
  213. package/dist/resource/shader/Tr2MaterialMesh.js +21 -27
  214. package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -1
  215. package/dist/resource/shader/Tr2MaterialRes.js +24 -29
  216. package/dist/resource/shader/Tr2MaterialRes.js.map +1 -1
  217. package/dist/resource/shader/Tr2Shader.js +45 -39
  218. package/dist/resource/shader/Tr2Shader.js.map +1 -1
  219. package/dist/resource/shader/Tr2ShaderPermutation.js +30 -32
  220. package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -1
  221. package/dist/resource/shader/reflection/Tr2EffectConstant.js +113 -78
  222. package/dist/resource/shader/reflection/Tr2EffectConstant.js.map +1 -1
  223. package/dist/resource/shader/reflection/Tr2EffectDefine.js +17 -23
  224. package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -1
  225. package/dist/resource/shader/reflection/Tr2EffectDescription.js +23 -29
  226. package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -1
  227. package/dist/resource/shader/reflection/Tr2EffectLibrary.js +44 -40
  228. package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -1
  229. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +82 -86
  230. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
  231. package/dist/resource/shader/reflection/Tr2EffectResource.js +55 -61
  232. package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
  233. package/dist/resource/shader/reflection/Tr2EffectStageInput.js +49 -45
  234. package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
  235. package/dist/resource/shader/reflection/Tr2EffectTechnique.js +25 -30
  236. package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -1
  237. package/dist/resource/shader/reflection/Tr2Pass.js +30 -32
  238. package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
  239. package/dist/resource/shader/sampler/Tr2SamplerSetup.js +21 -26
  240. package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -1
  241. package/docs/formats/README.md +4 -0
  242. package/docs/formats/provenance.md +11 -3
  243. package/docs/reference/classes/formats.md +440 -0
  244. package/format-notices/dxbc/LICENSE +21 -0
  245. package/format-notices/dxbc/NOTICE +20 -0
  246. package/format-notices/hlsl/LICENSE +21 -0
  247. package/format-notices/hlsl/NOTICE +25 -0
  248. package/format-notices/webgl/LICENSE +21 -0
  249. package/format-notices/webgl/NOTICE +35 -0
  250. package/format-notices/webgpu/LICENSE +21 -0
  251. package/format-notices/webgpu/NOTICE +31 -0
  252. package/package.json +6 -1
  253. package/dist/resource/shader/portableValidation.js +0 -461
  254. package/dist/resource/shader/portableValidation.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decoder.js","sources":["../../../../../src/formats/dxbc/core/decoder.js"],"sourcesContent":["import { DxbcReadError } from \"./errors.js\";\nimport {\n DXBC_OPCODE_CUSTOMDATA,\n DxbcBooleanTestOpcodeNames,\n DxbcOpcodeNames,\n dxbcIsDeclarationOpcode,\n dxbcOpcodeName\n} from \"./opcodes.js\";\n\nconst COMPONENTS = [ \"x\", \"y\", \"z\", \"w\" ];\n\n/**\n * Operand register-file names indexed by the operand-token type field.\n */\nexport const DxbcOperandTypeNames = Object.freeze([\n \"temp\", \"input\", \"output\", \"indexable_temp\", \"immediate32\", \"immediate64\",\n \"sampler\", \"resource\", \"constant_buffer\", \"immediate_constant_buffer\",\n \"label\", \"input_primitive_id\", \"output_depth\", \"null\", \"rasterizer\",\n \"output_coverage\", \"stream\", \"function_body\", \"function_table\", \"interface\",\n \"function_input\", \"function_output\", \"output_control_point_id\",\n \"input_fork_instance_id\", \"input_join_instance_id\", \"input_control_point\",\n \"output_control_point\", \"input_patch_constant\", \"input_domain_point\",\n \"this_pointer\", \"uav\", \"thread_group_shared_memory\", \"input_thread_id\",\n \"input_thread_group_id\", \"input_thread_id_in_group\", \"input_coverage_mask\",\n \"input_thread_id_in_group_flattened\", \"input_gs_instance_id\",\n \"output_depth_greater_equal\", \"output_depth_less_equal\", \"cycle_counter\"\n]);\n\n/**\n * Operand modifier names indexed by the extended-operand modifier field.\n */\nexport const DxbcOperandModifierNames = Object.freeze([ \"none\", \"neg\", \"abs\", \"absneg\" ]);\n\n/**\n * System-value names indexed by DXBC name-token values.\n */\nexport const DxbcSystemValueNames = Object.freeze([\n \"undefined\", \"position\", \"clip_distance\", \"cull_distance\",\n \"render_target_array_index\", \"viewport_array_index\", \"vertex_id\",\n \"primitive_id\", \"instance_id\", \"is_front_face\", \"sample_index\"\n]);\n\n/**\n * Resource dimension names indexed by declaration resource-dimension ids.\n */\nexport const DxbcResourceDimensionNames = Object.freeze([\n \"unknown\", \"buffer\", \"texture1d\", \"texture2d\", \"texture2dms\", \"texture3d\",\n \"texturecube\", \"texture1darray\", \"texture2darray\", \"texture2dmsarray\",\n \"texturecubearray\", \"raw_buffer\", \"structured_buffer\"\n]);\n\n/**\n * Resource return-type names indexed by return-type nibble values.\n */\nexport const DxbcResourceReturnTypeNames = Object.freeze([\n \"unknown\", \"unorm\", \"snorm\", \"sint\", \"uint\", \"float\", \"mixed\", \"double\",\n \"continued\"\n]);\n\nconst RESINFO_RETURN_TYPE_NAMES = [ \"float\", \"rcpfloat\", \"uint\" ];\nconst SAMPLER_MODE_NAMES = [ \"default\", \"comparison\", \"mono\" ];\nconst INTERPOLATION_MODE_NAMES = [\n \"undefined\", \"constant\", \"linear\", \"linear_centroid\", \"linear_noperspective\",\n \"linear_noperspective_centroid\", \"linear_sample\", \"linear_noperspective_sample\"\n];\nconst MIN_PRECISION_NAMES = [ \"default\", \"float_16\", \"float_2_8\", \"reserved\", \"sint_16\", \"uint_16\" ];\nconst CUSTOM_DATA_CLASS_NAMES = [\n \"comment\", \"debug_info\", \"opaque\", \"dcl_immediate_constant_buffer\",\n \"shader_message\"\n];\nconst SYNC_FLAG_NAMES = [\n \"threads_in_group\",\n \"thread_group_shared_memory\",\n \"thread_group_uav_memory\",\n \"global_uav_memory\"\n];\n\nconst SM51_RESOURCE_OPERAND_TYPES = new Set([ 6, 7, 8, 30 ]);\nconst SM51_UNBOUNDED_REGISTER = 0xffffffff;\n\nfunction signExtend4(value)\n{\n return (value & 0x8) ? value - 0x10 : value;\n}\n\nfunction maskToComponents(mask)\n{\n return COMPONENTS.filter((_, index) => (mask & (1 << index)) !== 0).join(\"\");\n}\n\n/**\n * Decodes an opcode-extension token (`sample_controls`, `resource_dimension`,\n * or `resource_return_type`).\n *\n * @param {number} token Extension token.\n * @returns {object} Decoded extension record.\n */\nfunction decodeOpcodeExtension(token)\n{\n const type = token & 0x3f;\n const out = { token, type };\n if (type === 1)\n {\n out.typeName = \"sample_controls\";\n out.sampleOffsets = {\n u: signExtend4((token >>> 9) & 0xf),\n v: signExtend4((token >>> 13) & 0xf),\n w: signExtend4((token >>> 17) & 0xf)\n };\n }\n else if (type === 2)\n {\n out.typeName = \"resource_dimension\";\n out.resourceDimension = (token >>> 6) & 0x1f;\n out.resourceDimensionName = DxbcResourceDimensionNames[out.resourceDimension] || \"unknown\";\n out.structureStride = (token >>> 11) & 0xfff;\n }\n else if (type === 3)\n {\n out.typeName = \"resource_return_type\";\n out.resourceReturnTypes = [ 0, 1, 2, 3 ].map((coord) => (token >>> (coord * 4 + 6)) & 0xf);\n }\n else\n {\n out.typeName = type === 0 ? \"empty\" : `extended_opcode_${type}`;\n }\n return out;\n}\n\n/**\n * Decodes a standalone resource return-type token (four nibbles from bit 0).\n *\n * @param {number} token Return-type token.\n * @returns {{token:number,returnTypes:number[],returnTypeNames:string[]}} Decoded record.\n */\nfunction decodeReturnTypeToken(token)\n{\n const returnTypes = [ 0, 1, 2, 3 ].map((coord) => (token >>> (coord * 4)) & 0xf);\n return {\n token,\n returnTypes,\n returnTypeNames: returnTypes.map((value) => DxbcResourceReturnTypeNames[value] || `return_type_${value}`)\n };\n}\n\nfunction decodeSm51BindingRange(operand, registerSpace, fail)\n{\n if (operand.indices.length !== 3)\n {\n throw fail(\"SM5.1 resource declaration must use a 3D binding-range operand\", {\n indexDimension: operand.indices.length\n });\n }\n\n const values = operand.indices.map((index) =>\n {\n if (index.representation !== 0 || index.values.length !== 1 || index.relative)\n {\n throw fail(\"SM5.1 binding-range indices must be immediate32 values\", {\n dimension: index.dimension,\n representation: index.representation\n });\n }\n return index.values[0];\n });\n const [ rangeId, lowerBound, upperBound ] = values;\n const unbounded = upperBound === SM51_UNBOUNDED_REGISTER;\n if (!unbounded && upperBound < lowerBound)\n {\n throw fail(\"SM5.1 binding range has an upper bound below its lower bound\", {\n rangeId,\n lowerBound,\n upperBound\n });\n }\n\n return {\n bindingModel: \"sm5.1-range\",\n rangeId,\n lowerBound,\n upperBound,\n unbounded,\n registerCount: unbounded ? null : upperBound - lowerBound + 1,\n registerSpace\n };\n}\n\nfunction decodeSm51ResourceReference(operand)\n{\n if (!SM51_RESOURCE_OPERAND_TYPES.has(operand.type) || operand.indices.length === 0)\n {\n return null;\n }\n\n const reference = {\n bindingModel: \"sm5.1-range\",\n rangeId: operand.indices[0]?.values[0] ?? null,\n nonUniform: operand.nonUniform,\n absoluteIndex: null,\n bufferIndex: null,\n vectorOffset: null\n };\n if (operand.type === 8)\n {\n reference.bufferIndex = operand.indices[1] || null;\n reference.vectorOffset = operand.indices[2] || null;\n }\n else\n {\n reference.absoluteIndex = operand.indices[1] || null;\n }\n return reference;\n}\n\nfunction decodeThreadGroupSharedMemoryRegister(operand, fail)\n{\n if (operand.typeName !== \"thread_group_shared_memory\")\n {\n throw fail(\"DXBC thread-group shared-memory declaration must use a thread-group shared-memory operand\", {\n operandType: operand.type,\n operandTypeName: operand.typeName\n });\n }\n if (operand.componentCount !== 0)\n {\n throw fail(\"DXBC thread-group shared-memory declaration operand must not select components\", {\n componentCount: operand.componentCount,\n selectionModeName: operand.selectionModeName\n });\n }\n if ((operand.token & 0xfff) !== 0\n || (operand.token & 0x7e000000) !== 0\n || (operand.token >>> 31) !== 0\n || operand.modifierName !== \"none\"\n || operand.minPrecisionName !== \"default\"\n || operand.nonUniform)\n {\n throw fail(\"DXBC thread-group shared-memory declaration operand must be unmodified\", {\n token: operand.token,\n modifierName: operand.modifierName,\n minPrecisionName: operand.minPrecisionName,\n nonUniform: operand.nonUniform\n });\n }\n if (operand.indices.length !== 1)\n {\n throw fail(\"DXBC thread-group shared-memory declaration must use a 1D register operand\", {\n indexDimension: operand.indices.length\n });\n }\n\n const index = operand.indices[0];\n if (index.representation !== 0 || index.values.length !== 1 || index.relative)\n {\n throw fail(\"DXBC thread-group shared-memory register index must be an immediate32 value\", {\n representation: index.representation\n });\n }\n if (operand.length !== 2)\n {\n throw fail(\"DXBC thread-group shared-memory declaration operand has an unsupported encoding\", {\n length: operand.length\n });\n }\n return index.values[0];\n}\n\nfunction requirePositiveDwordAligned(value, fieldName, fail)\n{\n if (value === 0 || (value & 0x3) !== 0)\n {\n throw fail(`DXBC thread-group shared-memory ${fieldName} must be a positive multiple of 4`, {\n [fieldName]: value\n });\n }\n return value;\n}\n\n/**\n * SM4/SM5 instruction-stream decoder over a `DxbcShaderProgram` token array.\n *\n * Executable instructions decode strictly: operands must consume the exact\n * instruction length or the decoder throws. Declarations decode the payloads\n * the vertex/pixel corpus uses and keep any remaining dwords as `tailTokens`\n * so unusual stages stay inspectable without failing the framing walk.\n */\nexport class DxbcInstructionDecoder\n{\n /**\n * Creates an empty instruction decoder; call a read entry point to decode a token stream.\n */\n constructor()\n {\n this.tokens = new Uint32Array(0);\n this.instructions = [];\n this.source = \"memory\";\n }\n\n /**\n * Decodes every instruction in a shader program token stream.\n *\n * @param {import(\"./program.js\").DxbcShaderProgram} program Parsed `SHEX`/`SHDR` program.\n * @param {object} [options] Decode options.\n * @param {string} [options.source] Source name used in error details.\n * @returns {DxbcInstructionDecoder} This decoder.\n */\n Decode(program, options = {})\n {\n this.tokens = program.tokens;\n this.source = options.source || program.source || \"memory\";\n this.programType = program.programType;\n this.programTypeName = program.programTypeName;\n this.majorVersion = program.majorVersion;\n this.minorVersion = program.minorVersion;\n this.instructions = [];\n\n let position = 2;\n while (position < this.tokens.length)\n {\n const instruction = this._decodeInstruction(position);\n this.instructions.push(instruction);\n position += instruction.length;\n }\n return this;\n }\n\n /**\n * Counts decoded instructions per mnemonic.\n *\n * @returns {Map<string, number>} Opcode-name histogram.\n */\n opcodeHistogram()\n {\n const histogram = new Map();\n for (const instruction of this.instructions)\n {\n histogram.set(instruction.opcodeName, (histogram.get(instruction.opcodeName) || 0) + 1);\n }\n return histogram;\n }\n\n /**\n * Decodes one instruction starting at a token position.\n *\n * @param {number} position Token index of the instruction's first token.\n * @returns {object} Instruction record.\n * @private\n */\n _decodeInstruction(position)\n {\n const token0 = this.tokens[position];\n const opcode = token0 & 0x7ff;\n const opcodeName = dxbcOpcodeName(opcode);\n\n if (opcode >= DxbcOpcodeNames.length)\n {\n throw new DxbcReadError(\"Unknown DXBC opcode\", {\n source: this.source,\n offset: position,\n opcode\n });\n }\n\n if (opcode === DXBC_OPCODE_CUSTOMDATA)\n {\n return this._decodeCustomData(position, token0);\n }\n\n const length = (token0 >>> 24) & 0x7f;\n if (length < 1 || position + length > this.tokens.length)\n {\n throw new DxbcReadError(\"DXBC instruction length lies outside the program\", {\n source: this.source,\n offset: position,\n opcode,\n opcodeName,\n length,\n programLength: this.tokens.length\n });\n }\n\n const extensions = [];\n let cursor = position + 1;\n let chainToken = token0;\n while ((chainToken >>> 31) === 1)\n {\n if (cursor >= position + length)\n {\n throw new DxbcReadError(\"DXBC extended-opcode chain overruns the instruction\", {\n source: this.source,\n offset: position,\n opcodeName\n });\n }\n chainToken = this.tokens[cursor];\n extensions.push(decodeOpcodeExtension(chainToken));\n cursor += 1;\n }\n\n const instruction = {\n offset: position,\n opcode,\n opcodeName,\n length,\n token0,\n isDeclaration: dxbcIsDeclarationOpcode(opcode),\n saturate: opcodeName === \"sync\" ? false : (token0 & 0x00002000) !== 0,\n preciseMask: maskToComponents((token0 >>> 19) & 0xf),\n extensions,\n operands: [],\n declaration: null,\n customData: null,\n tailTokens: []\n };\n\n if (DxbcBooleanTestOpcodeNames.has(opcodeName))\n {\n instruction.testBoolean = ((token0 >>> 18) & 1) === 0 ? \"zero\" : \"nonzero\";\n }\n if (opcodeName === \"resinfo\")\n {\n const returnType = (token0 >>> 11) & 0x3;\n instruction.resinfoReturnType = returnType;\n instruction.resinfoReturnTypeName = RESINFO_RETURN_TYPE_NAMES[returnType] || `return_type_${returnType}`;\n }\n if (opcodeName === \"sync\")\n {\n instruction.syncFlags = (token0 >>> 11) & 0xff;\n instruction.syncFlagNames = SYNC_FLAG_NAMES.filter((_, index) =>\n (instruction.syncFlags & (1 << index)) !== 0);\n }\n\n const end = position + length;\n if (instruction.isDeclaration)\n {\n this._decodeDeclaration(instruction, cursor, end);\n }\n else if (opcodeName === \"sync\")\n {\n if (instruction.extensions.length\n || cursor !== end\n || (token0 & 0x00f80000) !== 0)\n {\n throw new DxbcReadError(\"DXBC sync instruction must not contain extensions, operands, or reserved controls\", {\n source: this.source,\n offset: instruction.offset,\n opcodeName\n });\n }\n }\n else\n {\n instruction.operands = this._decodeOperandRun(cursor, end, instruction);\n if (this.majorVersion === 5 && this.minorVersion >= 1)\n {\n for (const operand of instruction.operands)\n {\n const resourceReference = decodeSm51ResourceReference(operand);\n if (resourceReference) operand.resourceReference = resourceReference;\n }\n }\n }\n return instruction;\n }\n\n /**\n * Decodes a custom-data block, including immediate constant buffers.\n *\n * @param {number} position Token index of the custom-data token.\n * @param {number} token0 Custom-data opcode token.\n * @returns {object} Instruction record.\n * @private\n */\n _decodeCustomData(position, token0)\n {\n if (position + 1 >= this.tokens.length)\n {\n throw new DxbcReadError(\"DXBC custom-data block is missing its length token\", {\n source: this.source,\n offset: position\n });\n }\n const length = this.tokens[position + 1];\n if (length < 2 || position + length > this.tokens.length)\n {\n throw new DxbcReadError(\"DXBC custom-data length lies outside the program\", {\n source: this.source,\n offset: position,\n length,\n programLength: this.tokens.length\n });\n }\n\n const dataClass = token0 >>> 11;\n const customData = {\n dataClass,\n dataClassName: CUSTOM_DATA_CLASS_NAMES[dataClass] || `custom_data_${dataClass}`,\n valueCount: length - 2,\n immediateConstantBuffer: null\n };\n\n if (dataClass === 3)\n {\n if ((length - 2) % 4 !== 0)\n {\n throw new DxbcReadError(\"DXBC immediate constant buffer is not vec4-aligned\", {\n source: this.source,\n offset: position,\n length\n });\n }\n const floatView = new Float32Array(this.tokens.buffer, this.tokens.byteOffset, this.tokens.length);\n const rows = [];\n for (let index = position + 2; index < position + length; index += 4)\n {\n rows.push([ 0, 1, 2, 3 ].map((component) => ({\n uint32: this.tokens[index + component],\n float32: floatView[index + component]\n })));\n }\n customData.immediateConstantBuffer = rows;\n }\n\n return {\n offset: position,\n opcode: DXBC_OPCODE_CUSTOMDATA,\n opcodeName: \"customdata\",\n length,\n token0,\n isDeclaration: true,\n saturate: false,\n preciseMask: \"\",\n extensions: [],\n operands: [],\n declaration: null,\n customData,\n tailTokens: []\n };\n }\n\n /**\n * Decodes declaration payloads for the opcodes the WebGL corpus exercises,\n * keeping unconsumed dwords as raw tail tokens.\n *\n * @param {object} instruction Instruction record being filled.\n * @param {number} cursor Token index after the opcode and extension tokens.\n * @param {number} end Exclusive token index of the instruction end.\n * @private\n */\n _decodeDeclaration(instruction, cursor, end)\n {\n const token0 = instruction.token0;\n const name = instruction.opcodeName;\n const declaration = {};\n instruction.declaration = declaration;\n\n const takeOperand = () =>\n {\n const operand = this._decodeOperand(cursor, end, instruction);\n instruction.operands.push(operand);\n cursor += operand.length;\n return operand;\n };\n const takeToken = () =>\n {\n if (cursor >= end)\n {\n throw new DxbcReadError(\"DXBC declaration payload is truncated\", {\n source: this.source,\n offset: instruction.offset,\n opcodeName: name\n });\n }\n const value = this.tokens[cursor];\n cursor += 1;\n return value;\n };\n const failDeclaration = (message, details = {}) => new DxbcReadError(message, {\n source: this.source,\n offset: instruction.offset,\n opcodeName: name,\n ...details\n });\n const applyBindingRange = (operand, registerSpace) =>\n {\n const bindingRange = decodeSm51BindingRange(operand, registerSpace, failDeclaration);\n declaration.bindingModel = bindingRange.bindingModel;\n declaration.bindingRange = bindingRange;\n declaration.registerIndex = bindingRange.lowerBound;\n };\n const isSm51 = this.majorVersion === 5 && this.minorVersion >= 1;\n\n switch (name)\n {\n case \"dcl_global_flags\":\n // Kept unshifted (bits 11-23) so values compare directly against the\n // GLOBAL_FLAG_* constants in HLSLcc's tokens.h.\n declaration.globalFlags = token0 & 0x00fff800;\n declaration.refactoringAllowed = (token0 & (1 << 11)) !== 0;\n break;\n case \"dcl_temps\":\n declaration.tempCount = takeToken();\n break;\n case \"dcl_indexable_temp\":\n declaration.registerIndex = takeToken();\n declaration.registerCount = takeToken();\n declaration.componentCount = takeToken();\n break;\n case \"dcl_constant_buffer\": {\n declaration.accessPattern = ((token0 >>> 11) & 1) === 0 ? \"immediate_indexed\" : \"dynamic_indexed\";\n const operand = takeOperand();\n if (isSm51)\n {\n declaration.sizeInVec4 = takeToken();\n applyBindingRange(operand, takeToken());\n }\n else\n {\n declaration.registerIndex = operand.indices[0]?.values[0] ?? null;\n declaration.sizeInVec4 = operand.indices[1]?.values[0] ?? null;\n }\n break;\n }\n case \"dcl_sampler\": {\n const samplerMode = (token0 >>> 11) & 0x3;\n declaration.samplerMode = samplerMode;\n declaration.samplerModeName = SAMPLER_MODE_NAMES[samplerMode] || `sampler_mode_${samplerMode}`;\n const operand = takeOperand();\n if (isSm51) applyBindingRange(operand, takeToken());\n else declaration.registerIndex = operand.registerIndex;\n break;\n }\n case \"dcl_resource\": {\n const dimension = (token0 >>> 11) & 0x1f;\n declaration.resourceDimension = dimension;\n declaration.resourceDimensionName = DxbcResourceDimensionNames[dimension] || `dimension_${dimension}`;\n declaration.sampleCount = (token0 >>> 16) & 0x7f;\n const operand = takeOperand();\n declaration.returnType = decodeReturnTypeToken(takeToken());\n if (isSm51) applyBindingRange(operand, takeToken());\n else declaration.registerIndex = operand.registerIndex;\n break;\n }\n case \"dcl_resource_raw\": {\n const operand = takeOperand();\n if (isSm51) applyBindingRange(operand, takeToken());\n else declaration.registerIndex = operand.registerIndex;\n break;\n }\n case \"dcl_resource_structured\": {\n const operand = takeOperand();\n // Corpus reality: the byte stride is a trailing dword after the operand\n // (48 for BoneTransforms float4x3 rows, 4 for uint index lists). The\n // extended-opcode RESOURCE_DIM stride is a fork-added fallback only.\n const extensionStride = instruction.extensions.find((ext) => ext.typeName === \"resource_dimension\");\n declaration.structureStride = cursor < end ? takeToken() : (extensionStride?.structureStride ?? null);\n if (isSm51) applyBindingRange(operand, takeToken());\n else declaration.registerIndex = operand.registerIndex;\n break;\n }\n case \"dcl_input\": {\n const operand = takeOperand();\n declaration.registerIndex = operand.registerIndex;\n // Compute-stage pseudo-inputs (thread id / thread group id / thread id\n // in group / flattened thread id in group) are distinguished purely by\n // the operand's own type field, not by register index — surface it so\n // the emitter can branch without re-decoding the operand.\n declaration.operandType = operand.type;\n declaration.operandTypeName = operand.typeName;\n break;\n }\n case \"dcl_output\":\n declaration.registerIndex = takeOperand().registerIndex;\n break;\n case \"dcl_thread_group\":\n // Three raw dwords, no operand (`decode.cpp` OPCODE_DCL_THREAD_GROUP:\n // pui32Token[1..3] are the X/Y/Z workgroup sizes).\n declaration.threadGroupX = takeToken();\n declaration.threadGroupY = takeToken();\n declaration.threadGroupZ = takeToken();\n break;\n case \"dcl_unordered_access_view_typed\": {\n // Same dimension-bits layout as `dcl_resource` (bits 11-15); bit 16 is\n // the globally-coherent access flag here rather than an MS sample count.\n const dimension = (token0 >>> 11) & 0x1f;\n declaration.resourceDimension = dimension;\n declaration.resourceDimensionName = DxbcResourceDimensionNames[dimension] || `dimension_${dimension}`;\n declaration.globallyCoherent = (token0 & 0x00010000) !== 0;\n const operand = takeOperand();\n declaration.returnType = decodeReturnTypeToken(takeToken());\n if (isSm51) applyBindingRange(operand, takeToken());\n else declaration.registerIndex = operand.registerIndex;\n break;\n }\n case \"dcl_unordered_access_view_raw\": {\n const operand = takeOperand();\n declaration.globallyCoherent = (token0 & 0x00010000) !== 0;\n if (isSm51) applyBindingRange(operand, takeToken());\n else declaration.registerIndex = operand.registerIndex;\n break;\n }\n case \"dcl_unordered_access_view_structured\": {\n const operand = takeOperand();\n declaration.globallyCoherent = (token0 & 0x00010000) !== 0;\n declaration.structureStride = takeToken();\n if (isSm51) applyBindingRange(operand, takeToken());\n else declaration.registerIndex = operand.registerIndex;\n break;\n }\n case \"dcl_thread_group_shared_memory_raw\": {\n const operand = takeOperand();\n declaration.registerIndex = decodeThreadGroupSharedMemoryRegister(operand, failDeclaration);\n declaration.byteCount = requirePositiveDwordAligned(takeToken(), \"byteCount\", failDeclaration);\n break;\n }\n case \"dcl_thread_group_shared_memory_structured\": {\n const operand = takeOperand();\n declaration.registerIndex = decodeThreadGroupSharedMemoryRegister(operand, failDeclaration);\n declaration.structureStride = requirePositiveDwordAligned(takeToken(), \"structureStride\", failDeclaration);\n declaration.structureCount = takeToken();\n if (declaration.structureCount === 0)\n {\n throw failDeclaration(\"DXBC thread-group shared-memory structureCount must be positive\");\n }\n break;\n }\n case \"dcl_input_ps\": {\n const interpolation = (token0 >>> 11) & 0xf;\n declaration.interpolationMode = interpolation;\n declaration.interpolationModeName = INTERPOLATION_MODE_NAMES[interpolation] || `interpolation_${interpolation}`;\n declaration.registerIndex = takeOperand().registerIndex;\n break;\n }\n case \"dcl_input_sgv\":\n case \"dcl_input_siv\":\n case \"dcl_output_sgv\":\n case \"dcl_output_siv\":\n case \"dcl_input_ps_sgv\":\n case \"dcl_input_ps_siv\": {\n if (name === \"dcl_input_ps_siv\")\n {\n const interpolation = (token0 >>> 11) & 0xf;\n declaration.interpolationMode = interpolation;\n declaration.interpolationModeName = INTERPOLATION_MODE_NAMES[interpolation] || `interpolation_${interpolation}`;\n }\n declaration.registerIndex = takeOperand().registerIndex;\n const nameToken = takeToken();\n declaration.systemValue = nameToken & 0xffff;\n declaration.systemValueName = DxbcSystemValueNames[declaration.systemValue] || `name_${declaration.systemValue}`;\n break;\n }\n case \"dcl_index_range\":\n declaration.registerIndex = takeOperand().registerIndex;\n declaration.indexRange = takeToken();\n break;\n default:\n instruction.declaration = null;\n break;\n }\n\n if (cursor < end)\n {\n instruction.tailTokens = Array.from(this.tokens.subarray(cursor, end));\n }\n }\n\n /**\n * Decodes a run of operands that must consume the region exactly.\n *\n * @param {number} cursor Token index of the first operand.\n * @param {number} end Exclusive token index of the instruction end.\n * @param {object} instruction Instruction record used in error details.\n * @returns {object[]} Decoded operands.\n * @private\n */\n _decodeOperandRun(cursor, end, instruction)\n {\n const operands = [];\n while (cursor < end)\n {\n const operand = this._decodeOperand(cursor, end, instruction);\n operands.push(operand);\n cursor += operand.length;\n }\n if (cursor !== end)\n {\n throw new DxbcReadError(\"DXBC operands overran the instruction length\", {\n source: this.source,\n offset: instruction.offset,\n opcodeName: instruction.opcodeName\n });\n }\n return operands;\n }\n\n /**\n * Decodes one operand, including extension tokens, register indices,\n * relative-index nested operands, and immediate values.\n *\n * @param {number} cursor Token index of the operand token.\n * @param {number} end Exclusive token index of the instruction end.\n * @param {object} instruction Instruction record used in error details.\n * @param {number} [depth] Relative-operand nesting depth.\n * @returns {object} Decoded operand with its consumed token `length`.\n * @private\n */\n _decodeOperand(cursor, end, instruction, depth = 0)\n {\n const fail = (message, details = {}) => new DxbcReadError(message, {\n source: this.source,\n offset: instruction.offset,\n opcodeName: instruction.opcodeName,\n operandCursor: cursor,\n ...details\n });\n\n if (cursor >= end)\n {\n throw fail(\"DXBC operand lies outside the instruction\");\n }\n if (depth > 4)\n {\n throw fail(\"DXBC relative operand nesting is too deep\");\n }\n\n const token = this.tokens[cursor];\n const type = (token >>> 12) & 0xff;\n const componentCountMode = token & 0x3;\n const selectionMode = (token >>> 2) & 0x3;\n const operand = {\n token,\n type,\n typeName: DxbcOperandTypeNames[type] || `operand_type_${type}`,\n componentCount: componentCountMode === 0 ? 0 : (componentCountMode === 1 ? 1 : 4),\n selectionModeName: \"none\",\n mask: \"\",\n swizzle: \"\",\n selected: \"\",\n modifierName: \"none\",\n minPrecisionName: \"default\",\n nonUniform: false,\n registerIndex: null,\n indices: [],\n immediateValues: [],\n length: 1\n };\n if (componentCountMode === 3)\n {\n throw fail(\"DXBC N-component operands are not supported\", { token });\n }\n\n if (operand.componentCount === 4)\n {\n if (selectionMode === 0)\n {\n operand.selectionModeName = \"mask\";\n operand.mask = maskToComponents((token >>> 4) & 0xf);\n }\n else if (selectionMode === 1)\n {\n operand.selectionModeName = \"swizzle\";\n operand.swizzle = [ 0, 1, 2, 3 ]\n .map((slot) => COMPONENTS[(token >>> (4 + slot * 2)) & 0x3])\n .join(\"\");\n }\n else if (selectionMode === 2)\n {\n operand.selectionModeName = \"select1\";\n operand.selected = COMPONENTS[(token >>> 4) & 0x3];\n }\n }\n\n let chainToken = token;\n while ((chainToken >>> 31) === 1)\n {\n if (cursor + operand.length >= end)\n {\n throw fail(\"DXBC extended-operand chain overruns the instruction\");\n }\n chainToken = this.tokens[cursor + operand.length];\n operand.length += 1;\n if ((chainToken & 0x3f) === 1)\n {\n const modifier = (chainToken >>> 6) & 0xff;\n const minPrecision = (chainToken >>> 14) & 0x7;\n operand.modifierName = DxbcOperandModifierNames[modifier] || `modifier_${modifier}`;\n operand.minPrecisionName = MIN_PRECISION_NAMES[minPrecision] || `min_precision_${minPrecision}`;\n operand.nonUniform = ((chainToken >>> 17) & 1) !== 0;\n }\n }\n\n const indexDimension = (token >>> 20) & 0x3;\n for (let dimension = 0; dimension < indexDimension; dimension += 1)\n {\n const representation = (token >>> (22 + dimension * 3)) & 0x7;\n const index = { dimension, representation, values: [], relative: null };\n const immediateCount = representation === 1 || representation === 4 ? 2 : (representation === 2 ? 0 : 1);\n\n for (let word = 0; word < immediateCount; word += 1)\n {\n if (cursor + operand.length >= end)\n {\n throw fail(\"DXBC operand index lies outside the instruction\", { dimension, representation });\n }\n index.values.push(this.tokens[cursor + operand.length]);\n operand.length += 1;\n }\n if (representation >= 2 && representation <= 4)\n {\n const relative = this._decodeOperand(cursor + operand.length, end, instruction, depth + 1);\n index.relative = relative;\n operand.length += relative.length;\n }\n else if (representation > 4)\n {\n throw fail(\"Unknown DXBC operand index representation\", { dimension, representation });\n }\n\n if (dimension === 0 && index.values.length > 0)\n {\n operand.registerIndex = index.values[0];\n }\n operand.indices.push(index);\n }\n\n if (type === 4 || type === 5)\n {\n const words = operand.componentCount * (type === 5 ? 2 : 1);\n if (cursor + operand.length + words > end)\n {\n throw fail(\"DXBC immediate values lie outside the instruction\");\n }\n const floatView = new Float32Array(this.tokens.buffer, this.tokens.byteOffset, this.tokens.length);\n for (let word = 0; word < words; word += 1)\n {\n operand.immediateValues.push({\n uint32: this.tokens[cursor + operand.length + word],\n float32: type === 4 ? floatView[cursor + operand.length + word] : null\n });\n }\n operand.length += words;\n }\n\n return operand;\n }\n}\n"],"names":["COMPONENTS","DxbcOperandTypeNames","Object","freeze","DxbcOperandModifierNames","DxbcSystemValueNames","DxbcResourceDimensionNames","DxbcResourceReturnTypeNames","RESINFO_RETURN_TYPE_NAMES","SAMPLER_MODE_NAMES","INTERPOLATION_MODE_NAMES","MIN_PRECISION_NAMES","CUSTOM_DATA_CLASS_NAMES","SYNC_FLAG_NAMES","SM51_RESOURCE_OPERAND_TYPES","Set","SM51_UNBOUNDED_REGISTER","signExtend4","value","maskToComponents","mask","filter","_","index","join","decodeOpcodeExtension","token","type","out","typeName","sampleOffsets","u","v","w","resourceDimension","resourceDimensionName","structureStride","resourceReturnTypes","map","coord","decodeReturnTypeToken","returnTypes","returnTypeNames","decodeSm51BindingRange","operand","registerSpace","fail","indices","length","indexDimension","values","representation","relative","dimension","rangeId","lowerBound","upperBound","unbounded","bindingModel","registerCount","decodeSm51ResourceReference","has","reference","nonUniform","absoluteIndex","bufferIndex","vectorOffset","decodeThreadGroupSharedMemoryRegister","operandType","operandTypeName","componentCount","selectionModeName","modifierName","minPrecisionName","requirePositiveDwordAligned","fieldName","DxbcInstructionDecoder","constructor","tokens","Uint32Array","instructions","source","Decode","program","options","programType","programTypeName","majorVersion","minorVersion","position","instruction","_decodeInstruction","push","opcodeHistogram","histogram","Map","set","opcodeName","get","token0","opcode","dxbcOpcodeName","DxbcOpcodeNames","DxbcReadError","offset","DXBC_OPCODE_CUSTOMDATA","_decodeCustomData","programLength","extensions","cursor","chainToken","isDeclaration","dxbcIsDeclarationOpcode","saturate","preciseMask","operands","declaration","customData","tailTokens","DxbcBooleanTestOpcodeNames","testBoolean","returnType","resinfoReturnType","resinfoReturnTypeName","syncFlags","syncFlagNames","end","_decodeDeclaration","_decodeOperandRun","resourceReference","dataClass","dataClassName","valueCount","immediateConstantBuffer","floatView","Float32Array","buffer","byteOffset","rows","component","uint32","float32","name","takeOperand","_decodeOperand","takeToken","failDeclaration","message","details","applyBindingRange","bindingRange","registerIndex","isSm51","globalFlags","refactoringAllowed","tempCount","accessPattern","sizeInVec4","samplerMode","samplerModeName","sampleCount","extensionStride","find","ext","threadGroupX","threadGroupY","threadGroupZ","globallyCoherent","byteCount","structureCount","interpolation","interpolationMode","interpolationModeName","nameToken","systemValue","systemValueName","indexRange","Array","from","subarray","depth","operandCursor","componentCountMode","selectionMode","swizzle","selected","immediateValues","slot","modifier","minPrecision","immediateCount","word","words"],"mappings":";;;AASA,MAAMA,UAAU,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE;;AAEzC;AACA;AACA;MACaC,oBAAoB,GAAGC,MAAM,CAACC,MAAM,CAAC,CAC9C,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EACzE,SAAS,EAAE,UAAU,EAAE,iBAAiB,EAAE,2BAA2B,EACrE,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EACnE,iBAAiB,EAAE,QAAQ,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAC3E,gBAAgB,EAAE,iBAAiB,EAAE,yBAAyB,EAC9D,wBAAwB,EAAE,wBAAwB,EAAE,qBAAqB,EACzE,sBAAsB,EAAE,sBAAsB,EAAE,oBAAoB,EACpE,cAAc,EAAE,KAAK,EAAE,4BAA4B,EAAE,iBAAiB,EACtE,uBAAuB,EAAE,0BAA0B,EAAE,qBAAqB,EAC1E,oCAAoC,EAAE,sBAAsB,EAC5D,4BAA4B,EAAE,yBAAyB,EAAE,eAAe,CAC3E;;AAED;AACA;AACA;MACaC,wBAAwB,GAAGF,MAAM,CAACC,MAAM,CAAC,CAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAE;;AAExF;AACA;AACA;AACO,MAAME,oBAAoB,GAAGH,MAAM,CAACC,MAAM,CAAC,CAC9C,WAAW,EAAE,UAAU,EA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 @@
1
+ /**
2
+ * Error raised when DirectX shader bytecode cannot be decoded safely.
3
+ */
4
+ class DxbcReadError extends Error {
5
+ /**
6
+ * Creates a bytecode-read error with structured location details.
7
+ *
8
+ * @param {string} message Human-readable failure reason.
9
+ * @param {object} [details] Extra reader state such as source, offset, or size.
10
+ */
11
+ constructor(message, details = {}) {
12
+ super(message);
13
+ this.name = "DxbcReadError";
14
+ this.details = details;
15
+ }
16
+ }
17
+
18
+ export { DxbcReadError };
19
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sources":["../../../../../src/formats/dxbc/core/errors.js"],"sourcesContent":["/**\n * Error raised when DirectX shader bytecode cannot be decoded safely.\n */\nexport class DxbcReadError extends Error\n{\n /**\n * Creates a bytecode-read error with structured location details.\n *\n * @param {string} message Human-readable failure reason.\n * @param {object} [details] Extra reader state such as source, offset, or size.\n */\n constructor(message, details = {})\n {\n super(message);\n this.name = \"DxbcReadError\";\n this.details = details;\n }\n}\n"],"names":["DxbcReadError","Error","constructor","message","details","name"],"mappings":"AAAA;AACA;AACA;AACO,MAAMA,aAAa,SAASC,KAAK,CACxC;AACI;AACJ;AACA;AACA;AACA;AACA;AACIC,EAAAA,WAAWA,CAACC,OAAO,EAAEC,OAAO,GAAG,EAAE,EACjC;IACI,KAAK,CAACD,OAAO,CAAC;IACd,IAAI,CAACE,IAAI,GAAG,eAAe;IAC3B,IAAI,CAACD,OAAO,GAAGA,OAAO;AAC1B,EAAA;AACJ;;;;"}
@@ -0,0 +1,220 @@
1
+ import { DxbcContainer } from './container.js';
2
+ import { DxbcSignatureChunk } from './signature.js';
3
+ import { DxbcShaderProgram } from './program.js';
4
+ import { DxbcInstructionDecoder } from './decoder.js';
5
+
6
+ /**
7
+ * Internal read-pipeline glue for CjsDxbcFormat.
8
+ *
9
+ * Keeps the public class file small: input normalization, option
10
+ * normalization, the shared read path used by both the instance and the
11
+ * static one-shots, and JSON conversion live here.
12
+ */
13
+
14
+ const OUTPUT_JSON = "json";
15
+ const OUTPUT_RAW = "raw";
16
+ const DEFAULT_VALUES = Object.freeze({
17
+ emit: OUTPUT_JSON,
18
+ source: "memory",
19
+ decodeInstructions: true
20
+ });
21
+ const VALID_EMITS = new Set([OUTPUT_JSON, OUTPUT_RAW]);
22
+ const INPUT_SIGNATURE_TAGS = ["ISGN", "ISG1"];
23
+ const OUTPUT_SIGNATURE_TAGS = ["OSGN", "OSG1", "OSG5"];
24
+ const PATCH_SIGNATURE_TAGS = ["PCSG", "PSG1"];
25
+
26
+ /**
27
+ * Merge format values over a base set and validate them.
28
+ *
29
+ * @param {object} base Current values.
30
+ * @param {object} [options] Values to merge in.
31
+ * @param {string} [readerName] Reader name used in error messages.
32
+ * @returns {object} A validated copy of the merged values.
33
+ */
34
+ function normalizeValues(base, options = {}, readerName = "CjsDxbcFormat") {
35
+ const values = {
36
+ ...base,
37
+ ...options
38
+ };
39
+ if (!VALID_EMITS.has(values.emit)) {
40
+ throw new TypeError(`${readerName}: emit must be "${OUTPUT_JSON}" or "${OUTPUT_RAW}", got ${JSON.stringify(values.emit)}`);
41
+ }
42
+ if (typeof values.source !== "string" || !values.source) {
43
+ values.source = DEFAULT_VALUES.source;
44
+ }
45
+ values.decodeInstructions = !!values.decodeInstructions;
46
+ return {
47
+ emit: values.emit,
48
+ source: values.source,
49
+ decodeInstructions: values.decodeInstructions
50
+ };
51
+ }
52
+
53
+ /**
54
+ * Normalize caller input into a Uint8Array of DXBC bytes.
55
+ *
56
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.
57
+ * @returns {Uint8Array} The payload bytes.
58
+ */
59
+ function toBytes(input) {
60
+ if (input instanceof Uint8Array) return input;
61
+ if (typeof ArrayBuffer !== "undefined" && input instanceof ArrayBuffer) return new Uint8Array(input);
62
+ if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
63
+ throw new TypeError("CjsDxbcFormat: input must be DXBC bytes (Uint8Array, Buffer, DataView or ArrayBuffer)");
64
+ }
65
+
66
+ /**
67
+ * Read a signature chunk group from a container if present.
68
+ *
69
+ * @param {DxbcContainer} container Parsed container.
70
+ * @param {string[]} tags Chunk fourCC candidates in priority order.
71
+ * @param {string} source Source name for errors.
72
+ * @returns {?DxbcSignatureChunk} Parsed signature or null.
73
+ */
74
+ function readSignature(container, tags, source) {
75
+ for (const tag of tags) {
76
+ const chunk = container.getChunk(tag);
77
+ if (chunk) return new DxbcSignatureChunk().Read(chunk, {
78
+ source
79
+ });
80
+ }
81
+ return null;
82
+ }
83
+
84
+ /**
85
+ * The shared read path used by the instance Read and the static read.
86
+ *
87
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input DXBC payload.
88
+ * @param {object} values Normalized format values.
89
+ * @returns {object} Raw read result (class instances).
90
+ */
91
+ function readRaw(input, values) {
92
+ const bytes = toBytes(input);
93
+ const source = values.source;
94
+ const container = new DxbcContainer().Read(bytes, {
95
+ source
96
+ });
97
+ const shex = container.getChunk("SHEX") || container.getChunk("SHDR");
98
+ const result = {
99
+ source,
100
+ container,
101
+ program: null,
102
+ decoder: null,
103
+ inputSignature: readSignature(container, INPUT_SIGNATURE_TAGS, source),
104
+ outputSignature: readSignature(container, OUTPUT_SIGNATURE_TAGS, source),
105
+ patchSignature: readSignature(container, PATCH_SIGNATURE_TAGS, source)
106
+ };
107
+ if (shex) {
108
+ result.program = new DxbcShaderProgram().Read(shex, {
109
+ source
110
+ });
111
+ if (values.decodeInstructions) {
112
+ result.decoder = new DxbcInstructionDecoder().Decode(result.program, {
113
+ source
114
+ });
115
+ }
116
+ }
117
+ return result;
118
+ }
119
+
120
+ /**
121
+ * Convert a raw read result to plain JSON-compatible data.
122
+ *
123
+ * @param {object} raw Raw read result from readRaw.
124
+ * @returns {object} Plain data.
125
+ */
126
+ function rawToJson(raw) {
127
+ return toJsonValue({
128
+ source: raw.source,
129
+ container: raw.container.toJSON(),
130
+ program: raw.program ? {
131
+ fourCC: raw.program.fourCC,
132
+ programType: raw.program.programType,
133
+ programTypeName: raw.program.programTypeName,
134
+ majorVersion: raw.program.majorVersion,
135
+ minorVersion: raw.program.minorVersion,
136
+ lengthDwords: raw.program.lengthDwords
137
+ } : null,
138
+ inputSignature: raw.inputSignature ? raw.inputSignature.elements : null,
139
+ outputSignature: raw.outputSignature ? raw.outputSignature.elements : null,
140
+ patchSignature: raw.patchSignature ? raw.patchSignature.elements : null,
141
+ instructions: raw.decoder ? raw.decoder.instructions : null
142
+ });
143
+ }
144
+
145
+ /**
146
+ * Shared read entry honouring the emit mode.
147
+ *
148
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input DXBC payload.
149
+ * @param {object} values Normalized format values.
150
+ * @returns {object} Raw result or plain JSON data per values.emit.
151
+ */
152
+ function readWithValues(input, values) {
153
+ const raw = readRaw(input, values);
154
+ return values.emit === OUTPUT_RAW ? raw : rawToJson(raw);
155
+ }
156
+
157
+ /**
158
+ * Cheap inspection: container/program facts without instruction decode.
159
+ *
160
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input DXBC payload.
161
+ * @param {object} values Normalized format values.
162
+ * @returns {object} Plain summary data.
163
+ */
164
+ function inspectWithValues(input, values) {
165
+ const raw = readRaw(input, {
166
+ ...values,
167
+ decodeInstructions: false
168
+ });
169
+ return toJsonValue({
170
+ source: raw.source,
171
+ isDxbc: true,
172
+ version: raw.container.version,
173
+ totalSize: raw.container.totalSize,
174
+ chunks: raw.container.chunks.map(({
175
+ fourCC,
176
+ offset,
177
+ size
178
+ }) => ({
179
+ fourCC,
180
+ offset,
181
+ size
182
+ })),
183
+ programTypeName: raw.program ? raw.program.programTypeName : null,
184
+ shaderModel: raw.program ? `${raw.program.majorVersion}.${raw.program.minorVersion}` : null,
185
+ inputElementCount: raw.inputSignature ? raw.inputSignature.elements.length : 0,
186
+ outputElementCount: raw.outputSignature ? raw.outputSignature.elements.length : 0
187
+ });
188
+ }
189
+
190
+ /**
191
+ * Deep-convert a value to plain JSON-compatible data. Typed arrays become
192
+ * plain number arrays; Maps/Sets become objects/arrays; class instances
193
+ * with toJSON are honoured.
194
+ *
195
+ * @param {any} value Value to convert.
196
+ * @returns {any} Plain data.
197
+ */
198
+ function toJsonValue(value) {
199
+ if (value === null || value === undefined) return value ?? null;
200
+ if (typeof value === "number" || typeof value === "string" || typeof value === "boolean") return value;
201
+ if (typeof value === "bigint") return value.toString();
202
+ if (ArrayBuffer.isView(value)) return Array.from(value);
203
+ if (Array.isArray(value)) return value.map(toJsonValue);
204
+ if (value instanceof Map) {
205
+ const out = {};
206
+ for (const [key, entry] of value) out[key] = toJsonValue(entry);
207
+ return out;
208
+ }
209
+ if (value instanceof Set) return Array.from(value, toJsonValue);
210
+ if (typeof value === "object") {
211
+ if (typeof value.toJSON === "function") return toJsonValue(value.toJSON());
212
+ const out = {};
213
+ for (const key of Object.keys(value)) out[key] = toJsonValue(value[key]);
214
+ return out;
215
+ }
216
+ return null;
217
+ }
218
+
219
+ export { DEFAULT_VALUES, OUTPUT_JSON, OUTPUT_RAW, inspectWithValues, normalizeValues, rawToJson, readRaw, readWithValues, toBytes, toJsonValue };
220
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sources":["../../../../../src/formats/dxbc/core/helpers.js"],"sourcesContent":["/**\n * Internal read-pipeline glue for CjsDxbcFormat.\n *\n * Keeps the public class file small: input normalization, option\n * normalization, the shared read path used by both the instance and the\n * static one-shots, and JSON conversion live here.\n */\n\nimport { DxbcContainer } from \"./container.js\";\nimport { DxbcSignatureChunk } from \"./signature.js\";\nimport { DxbcShaderProgram } from \"./program.js\";\nimport { DxbcInstructionDecoder } from \"./decoder.js\";\nimport { DxbcReadError } from \"./errors.js\";\n\nexport const OUTPUT_JSON = \"json\";\nexport const OUTPUT_RAW = \"raw\";\n\nexport const DEFAULT_VALUES = Object.freeze({\n emit: OUTPUT_JSON,\n source: \"memory\",\n decodeInstructions: true\n});\n\nconst VALID_EMITS = new Set([ OUTPUT_JSON, OUTPUT_RAW ]);\n\nconst INPUT_SIGNATURE_TAGS = [ \"ISGN\", \"ISG1\" ];\nconst OUTPUT_SIGNATURE_TAGS = [ \"OSGN\", \"OSG1\", \"OSG5\" ];\nconst PATCH_SIGNATURE_TAGS = [ \"PCSG\", \"PSG1\" ];\n\n/**\n * Merge format values over a base set and validate them.\n *\n * @param {object} base Current values.\n * @param {object} [options] Values to merge in.\n * @param {string} [readerName] Reader name used in error messages.\n * @returns {object} A validated copy of the merged values.\n */\nexport function normalizeValues(base, options = {}, readerName = \"CjsDxbcFormat\")\n{\n const values = { ...base, ...options };\n\n if (!VALID_EMITS.has(values.emit))\n {\n throw new TypeError(`${readerName}: emit must be \"${OUTPUT_JSON}\" or \"${OUTPUT_RAW}\", got ${JSON.stringify(values.emit)}`);\n }\n if (typeof values.source !== \"string\" || !values.source)\n {\n values.source = DEFAULT_VALUES.source;\n }\n values.decodeInstructions = !!values.decodeInstructions;\n\n return {\n emit: values.emit,\n source: values.source,\n decodeInstructions: values.decodeInstructions\n };\n}\n\n/**\n * Normalize caller input into a Uint8Array of DXBC bytes.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.\n * @returns {Uint8Array} The payload bytes.\n */\nexport function toBytes(input)\n{\n if (input instanceof Uint8Array) return input;\n if (typeof ArrayBuffer !== \"undefined\" && input instanceof ArrayBuffer) return new Uint8Array(input);\n if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n throw new TypeError(\"CjsDxbcFormat: input must be DXBC bytes (Uint8Array, Buffer, DataView or ArrayBuffer)\");\n}\n\n/**\n * Read a signature chunk group from a container if present.\n *\n * @param {DxbcContainer} container Parsed container.\n * @param {string[]} tags Chunk fourCC candidates in priority order.\n * @param {string} source Source name for errors.\n * @returns {?DxbcSignatureChunk} Parsed signature or null.\n */\nfunction readSignature(container, tags, source)\n{\n for (const tag of tags)\n {\n const chunk = container.getChunk(tag);\n if (chunk) return new DxbcSignatureChunk().Read(chunk, { source });\n }\n return null;\n}\n\n/**\n * The shared read path used by the instance Read and the static read.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input DXBC payload.\n * @param {object} values Normalized format values.\n * @returns {object} Raw read result (class instances).\n */\nexport function readRaw(input, values)\n{\n const bytes = toBytes(input);\n const source = values.source;\n const container = new DxbcContainer().Read(bytes, { source });\n const shex = container.getChunk(\"SHEX\") || container.getChunk(\"SHDR\");\n\n const result = {\n source,\n container,\n program: null,\n decoder: null,\n inputSignature: readSignature(container, INPUT_SIGNATURE_TAGS, source),\n outputSignature: readSignature(container, OUTPUT_SIGNATURE_TAGS, source),\n patchSignature: readSignature(container, PATCH_SIGNATURE_TAGS, source)\n };\n\n if (shex)\n {\n result.program = new DxbcShaderProgram().Read(shex, { source });\n if (values.decodeInstructions)\n {\n result.decoder = new DxbcInstructionDecoder().Decode(result.program, { source });\n }\n }\n\n return result;\n}\n\n/**\n * Convert a raw read result to plain JSON-compatible data.\n *\n * @param {object} raw Raw read result from readRaw.\n * @returns {object} Plain data.\n */\nexport function rawToJson(raw)\n{\n return toJsonValue({\n source: raw.source,\n container: raw.container.toJSON(),\n program: raw.program\n ? {\n fourCC: raw.program.fourCC,\n programType: raw.program.programType,\n programTypeName: raw.program.programTypeName,\n majorVersion: raw.program.majorVersion,\n minorVersion: raw.program.minorVersion,\n lengthDwords: raw.program.lengthDwords\n }\n : null,\n inputSignature: raw.inputSignature ? raw.inputSignature.elements : null,\n outputSignature: raw.outputSignature ? raw.outputSignature.elements : null,\n patchSignature: raw.patchSignature ? raw.patchSignature.elements : null,\n instructions: raw.decoder ? raw.decoder.instructions : null\n });\n}\n\n/**\n * Shared read entry honouring the emit mode.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input DXBC payload.\n * @param {object} values Normalized format values.\n * @returns {object} Raw result or plain JSON data per values.emit.\n */\nexport function readWithValues(input, values)\n{\n const raw = readRaw(input, values);\n return values.emit === OUTPUT_RAW ? raw : rawToJson(raw);\n}\n\n/**\n * Cheap inspection: container/program facts without instruction decode.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input DXBC payload.\n * @param {object} values Normalized format values.\n * @returns {object} Plain summary data.\n */\nexport function inspectWithValues(input, values)\n{\n const raw = readRaw(input, { ...values, decodeInstructions: false });\n return toJsonValue({\n source: raw.source,\n isDxbc: true,\n version: raw.container.version,\n totalSize: raw.container.totalSize,\n chunks: raw.container.chunks.map(({ fourCC, offset, size }) => ({ fourCC, offset, size })),\n programTypeName: raw.program ? raw.program.programTypeName : null,\n shaderModel: raw.program ? `${raw.program.majorVersion}.${raw.program.minorVersion}` : null,\n inputElementCount: raw.inputSignature ? raw.inputSignature.elements.length : 0,\n outputElementCount: raw.outputSignature ? raw.outputSignature.elements.length : 0\n });\n}\n\n/**\n * Deep-convert a value to plain JSON-compatible data. Typed arrays become\n * plain number arrays; Maps/Sets become objects/arrays; class instances\n * with toJSON are honoured.\n *\n * @param {any} value Value to convert.\n * @returns {any} Plain data.\n */\nexport function toJsonValue(value)\n{\n if (value === null || value === undefined) return value ?? null;\n if (typeof value === \"number\" || typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"bigint\") return value.toString();\n if (ArrayBuffer.isView(value)) return Array.from(value);\n if (Array.isArray(value)) return value.map(toJsonValue);\n if (value instanceof Map)\n {\n const out = {};\n for (const [ key, entry ] of value) out[key] = toJsonValue(entry);\n return out;\n }\n if (value instanceof Set) return Array.from(value, toJsonValue);\n if (typeof value === \"object\")\n {\n if (typeof value.toJSON === \"function\") return toJsonValue(value.toJSON());\n const out = {};\n for (const key of Object.keys(value)) out[key] = toJsonValue(value[key]);\n return out;\n }\n return null;\n}\n\nexport { DxbcReadError };\n"],"names":["OUTPUT_JSON","OUTPUT_RAW","DEFAULT_VALUES","Object","freeze","emit","source","decodeInstructions","VALID_EMITS","Set","INPUT_SIGNATURE_TAGS","OUTPUT_SIGNATURE_TAGS","PATCH_SIGNATURE_TAGS","normalizeValues","base","options","readerName","values","has","TypeError","JSON","stringify","toBytes","input","Uint8Array","ArrayBuffer","isView","buffer","byteOffset","byteLength","readSignature","container","tags","tag","chunk","getChunk","DxbcSignatureChunk","Read","readRaw","bytes","DxbcContainer","shex","result","program","decoder","inputSignature","outputSignature","patchSignature","DxbcShaderProgram","DxbcInstructionDecoder","Decode","rawToJson","raw","toJsonValue","toJSON","fourCC","programType","programTypeName","majorVersion","minorVersion","lengthDwords","elements","instructions","readWithValues","inspectWithValues","isDxbc","version","totalSize","chunks","map","offset","size","shaderModel","inputElementCount","length","outputElementCount","value","undefined","toString","Array","from","isArray","Map","out","key","entry","keys"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQO,MAAMA,WAAW,GAAG;AACpB,MAAMC,UAAU,GAAG;MAEbC,cAAc,GAAGC,MAAM,CAACC,MAAM,CAAC;AACxCC,EAAAA,IAAI,EAAEL,WAAW;AACjBM,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,kBAAkB,EAAE;AACxB,CAAC;AAED,MAAMC,WAAW,GAAG,IAAIC,GAAG,CAAC,CAAET,WAAW,EAAEC,UAAU,CAAE,CAAC;AAExD,MAAMS,oBAAoB,GAAG,CAAE,MAAM,EAAE,MAAM,CAAE;AAC/C,MAAMC,qBAAqB,GAAG,CAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAE;AACxD,MAAMC,oBAAoB,GAAG,CAAE,MAAM,EAAE,MAAM,CAAE;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAACC,IAAI,EAAEC,OAAO,GAAG,EAAE,EAAEC,UAAU,GAAG,eAAe,EAChF;AACI,EAAA,MAAMC,MAAM,GAAG;AAAE,IAAA,GAAGH,IAAI;IAAE,GAAGC;GAAS;EAEtC,IAAI,CAACP,WAAW,CAACU,GAAG,CAACD,MAAM,CAACZ,IAAI,CAAC,EACjC;AACI,IAAA,MAAM,IAAIc,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AAC,GAAG/B,WAAW,CAACuB,KAAK,CAACQ,GAAG,CAAC,CAAC;AACxE,IAAA,OAAOD,GAAG;AACd,EAAA;AACA,EAAA,OAAO,IAAI;AACf;;;;"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * SM4/SM5 opcode identifiers for DXBC `SHEX`/`SHDR` token streams.
3
+ *
4
+ * Values match the D3D10/D3D11 token-stream opcode enumeration, validated
5
+ * against `vendor/HLSLcc/src/internal_includes/tokens.h` (`OPCODE_TYPE`).
6
+ */
7
+ const DXBC_OPCODE_CUSTOMDATA = 53;
8
+
9
+ /**
10
+ * Opcode names indexed by opcode id 0-217.
11
+ */
12
+ const DxbcOpcodeNames = Object.freeze(["add", "and", "break", "breakc", "call", "callc", "case", "continue", "continuec", "cut", "default", "deriv_rtx", "deriv_rty", "discard", "div", "dp2", "dp3", "dp4", "else", "emit", "emit_then_cut", "endif", "endloop", "endswitch", "eq", "exp", "frc", "ftoi", "ftou", "ge", "iadd", "if", "ieq", "ige", "ilt", "imad", "imax", "imin", "imul", "ine", "ineg", "ishl", "ishr", "itof", "label", "ld", "ld_ms", "log", "loop", "lt", "mad", "min", "max", "customdata", "mov", "movc", "mul", "ne", "nop", "not", "or", "resinfo", "ret", "retc", "round_ne", "round_ni", "round_pi", "round_z", "rsq", "sample", "sample_c", "sample_c_lz", "sample_l", "sample_d", "sample_b", "sqrt", "switch", "sincos", "udiv", "ult", "uge", "umul", "umad", "umax", "umin", "ushr", "utof", "xor", "dcl_resource", "dcl_constant_buffer", "dcl_sampler", "dcl_index_range", "dcl_gs_output_primitive_topology", "dcl_gs_input_primitive", "dcl_max_output_vertex_count", "dcl_input", "dcl_input_sgv", "dcl_input_siv", "dcl_input_ps", "dcl_input_ps_sgv", "dcl_input_ps_siv", "dcl_output", "dcl_output_sgv", "dcl_output_siv", "dcl_temps", "dcl_indexable_temp", "dcl_global_flags", "reserved0", "lod", "gather4", "sample_pos", "sample_info", "reserved1", "hs_decls", "hs_control_point_phase", "hs_fork_phase", "hs_join_phase", "emit_stream", "cut_stream", "emitthencut_stream", "interface_call", "bufinfo", "deriv_rtx_coarse", "deriv_rtx_fine", "deriv_rty_coarse", "deriv_rty_fine", "gather4_c", "gather4_po", "gather4_po_c", "rcp", "f32tof16", "f16tof32", "uaddc", "usubb", "countbits", "firstbit_hi", "firstbit_lo", "firstbit_shi", "ubfe", "ibfe", "bfi", "bfrev", "swapc", "dcl_stream", "dcl_function_body", "dcl_function_table", "dcl_interface", "dcl_input_control_point_count", "dcl_output_control_point_count", "dcl_tess_domain", "dcl_tess_partitioning", "dcl_tess_output_primitive", "dcl_hs_max_tessfactor", "dcl_hs_fork_phase_instance_count", "dcl_hs_join_phase_instance_count", "dcl_thread_group", "dcl_unordered_access_view_typed", "dcl_unordered_access_view_raw", "dcl_unordered_access_view_structured", "dcl_thread_group_shared_memory_raw", "dcl_thread_group_shared_memory_structured", "dcl_resource_raw", "dcl_resource_structured", "ld_uav_typed", "store_uav_typed", "ld_raw", "store_raw", "ld_structured", "store_structured", "atomic_and", "atomic_or", "atomic_xor", "atomic_cmp_store", "atomic_iadd", "atomic_imax", "atomic_imin", "atomic_umax", "atomic_umin", "imm_atomic_alloc", "imm_atomic_consume", "imm_atomic_iadd", "imm_atomic_and", "imm_atomic_or", "imm_atomic_xor", "imm_atomic_exch", "imm_atomic_cmp_exch", "imm_atomic_imax", "imm_atomic_imin", "imm_atomic_umax", "imm_atomic_umin", "sync", "dadd", "dmax", "dmin", "dmul", "deq", "dge", "dlt", "dne", "dmov", "dmovc", "dtof", "ftod", "eval_snapped", "eval_sample_index", "eval_centroid", "dcl_gs_instance_count", "abort", "debug_break", "reserved2", "ddiv", "dfma", "drcp", "msad", "dtoi", "dtou", "itod", "utod"]);
13
+
14
+ /**
15
+ * Opcodes whose control bits carry a zero/nonzero boolean test.
16
+ */
17
+ const DxbcBooleanTestOpcodeNames = Object.freeze(new Set(["breakc", "callc", "continuec", "discard", "if", "retc"]));
18
+ const DECLARATION_RANGES = [[88, 106], [113, 116], [143, 162], [206, 206]];
19
+
20
+ /**
21
+ * Resolves an opcode id to a stable mnemonic.
22
+ *
23
+ * @param {number} opcode Opcode id from the instruction token.
24
+ * @returns {string} Mnemonic or `opcode_<id>` for unknown values.
25
+ */
26
+ function dxbcOpcodeName(opcode) {
27
+ return DxbcOpcodeNames[opcode] || `opcode_${opcode}`;
28
+ }
29
+
30
+ /**
31
+ * Checks whether an opcode id belongs to the declaration/phase block rather
32
+ * than the executable instruction set.
33
+ *
34
+ * @param {number} opcode Opcode id from the instruction token.
35
+ * @returns {boolean} True for `dcl_*`, hull-phase, and custom-data opcodes.
36
+ */
37
+ function dxbcIsDeclarationOpcode(opcode) {
38
+ if (opcode === DXBC_OPCODE_CUSTOMDATA) {
39
+ return true;
40
+ }
41
+ return DECLARATION_RANGES.some(([start, end]) => opcode >= start && opcode <= end);
42
+ }
43
+
44
+ export { DXBC_OPCODE_CUSTOMDATA, DxbcBooleanTestOpcodeNames, DxbcOpcodeNames, dxbcIsDeclarationOpcode, dxbcOpcodeName };
45
+ //# sourceMappingURL=opcodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opcodes.js","sources":["../../../../../src/formats/dxbc/core/opcodes.js"],"sourcesContent":["/**\n * SM4/SM5 opcode identifiers for DXBC `SHEX`/`SHDR` token streams.\n *\n * Values match the D3D10/D3D11 token-stream opcode enumeration, validated\n * against `vendor/HLSLcc/src/internal_includes/tokens.h` (`OPCODE_TYPE`).\n */\nexport const DXBC_OPCODE_CUSTOMDATA = 53;\n\n/**\n * Opcode names indexed by opcode id 0-217.\n */\nexport const DxbcOpcodeNames = Object.freeze([\n \"add\", \"and\", \"break\", \"breakc\", \"call\", \"callc\", \"case\", \"continue\",\n \"continuec\", \"cut\", \"default\", \"deriv_rtx\", \"deriv_rty\", \"discard\", \"div\",\n \"dp2\", \"dp3\", \"dp4\", \"else\", \"emit\", \"emit_then_cut\", \"endif\", \"endloop\",\n \"endswitch\", \"eq\", \"exp\", \"frc\", \"ftoi\", \"ftou\", \"ge\", \"iadd\", \"if\", \"ieq\",\n \"ige\", \"ilt\", \"imad\", \"imax\", \"imin\", \"imul\", \"ine\", \"ineg\", \"ishl\", \"ishr\",\n \"itof\", \"label\", \"ld\", \"ld_ms\", \"log\", \"loop\", \"lt\", \"mad\", \"min\", \"max\",\n \"customdata\", \"mov\", \"movc\", \"mul\", \"ne\", \"nop\", \"not\", \"or\", \"resinfo\",\n \"ret\", \"retc\", \"round_ne\", \"round_ni\", \"round_pi\", \"round_z\", \"rsq\",\n \"sample\", \"sample_c\", \"sample_c_lz\", \"sample_l\", \"sample_d\", \"sample_b\",\n \"sqrt\", \"switch\", \"sincos\", \"udiv\", \"ult\", \"uge\", \"umul\", \"umad\", \"umax\",\n \"umin\", \"ushr\", \"utof\", \"xor\", \"dcl_resource\", \"dcl_constant_buffer\",\n \"dcl_sampler\", \"dcl_index_range\", \"dcl_gs_output_primitive_topology\",\n \"dcl_gs_input_primitive\", \"dcl_max_output_vertex_count\", \"dcl_input\",\n \"dcl_input_sgv\", \"dcl_input_siv\", \"dcl_input_ps\", \"dcl_input_ps_sgv\",\n \"dcl_input_ps_siv\", \"dcl_output\", \"dcl_output_sgv\", \"dcl_output_siv\",\n \"dcl_temps\", \"dcl_indexable_temp\", \"dcl_global_flags\", \"reserved0\", \"lod\",\n \"gather4\", \"sample_pos\", \"sample_info\", \"reserved1\", \"hs_decls\",\n \"hs_control_point_phase\", \"hs_fork_phase\", \"hs_join_phase\", \"emit_stream\",\n \"cut_stream\", \"emitthencut_stream\", \"interface_call\", \"bufinfo\",\n \"deriv_rtx_coarse\", \"deriv_rtx_fine\", \"deriv_rty_coarse\", \"deriv_rty_fine\",\n \"gather4_c\", \"gather4_po\", \"gather4_po_c\", \"rcp\", \"f32tof16\", \"f16tof32\",\n \"uaddc\", \"usubb\", \"countbits\", \"firstbit_hi\", \"firstbit_lo\", \"firstbit_shi\",\n \"ubfe\", \"ibfe\", \"bfi\", \"bfrev\", \"swapc\", \"dcl_stream\", \"dcl_function_body\",\n \"dcl_function_table\", \"dcl_interface\", \"dcl_input_control_point_count\",\n \"dcl_output_control_point_count\", \"dcl_tess_domain\", \"dcl_tess_partitioning\",\n \"dcl_tess_output_primitive\", \"dcl_hs_max_tessfactor\",\n \"dcl_hs_fork_phase_instance_count\", \"dcl_hs_join_phase_instance_count\",\n \"dcl_thread_group\", \"dcl_unordered_access_view_typed\",\n \"dcl_unordered_access_view_raw\", \"dcl_unordered_access_view_structured\",\n \"dcl_thread_group_shared_memory_raw\",\n \"dcl_thread_group_shared_memory_structured\", \"dcl_resource_raw\",\n \"dcl_resource_structured\", \"ld_uav_typed\", \"store_uav_typed\", \"ld_raw\",\n \"store_raw\", \"ld_structured\", \"store_structured\", \"atomic_and\", \"atomic_or\",\n \"atomic_xor\", \"atomic_cmp_store\", \"atomic_iadd\", \"atomic_imax\",\n \"atomic_imin\", \"atomic_umax\", \"atomic_umin\", \"imm_atomic_alloc\",\n \"imm_atomic_consume\", \"imm_atomic_iadd\", \"imm_atomic_and\", \"imm_atomic_or\",\n \"imm_atomic_xor\", \"imm_atomic_exch\", \"imm_atomic_cmp_exch\",\n \"imm_atomic_imax\", \"imm_atomic_imin\", \"imm_atomic_umax\", \"imm_atomic_umin\",\n \"sync\", \"dadd\", \"dmax\", \"dmin\", \"dmul\", \"deq\", \"dge\", \"dlt\", \"dne\", \"dmov\",\n \"dmovc\", \"dtof\", \"ftod\", \"eval_snapped\", \"eval_sample_index\",\n \"eval_centroid\", \"dcl_gs_instance_count\", \"abort\", \"debug_break\",\n \"reserved2\", \"ddiv\", \"dfma\", \"drcp\", \"msad\", \"dtoi\", \"dtou\", \"itod\", \"utod\"\n]);\n\n/**\n * Opcodes whose control bits carry a zero/nonzero boolean test.\n */\nexport const DxbcBooleanTestOpcodeNames = Object.freeze(new Set([\n \"breakc\", \"callc\", \"continuec\", \"discard\", \"if\", \"retc\"\n]));\n\nconst DECLARATION_RANGES = [\n [ 88, 106 ],\n [ 113, 116 ],\n [ 143, 162 ],\n [ 206, 206 ]\n];\n\n/**\n * Resolves an opcode id to a stable mnemonic.\n *\n * @param {number} opcode Opcode id from the instruction token.\n * @returns {string} Mnemonic or `opcode_<id>` for unknown values.\n */\nexport function dxbcOpcodeName(opcode)\n{\n return DxbcOpcodeNames[opcode] || `opcode_${opcode}`;\n}\n\n/**\n * Checks whether an opcode id belongs to the declaration/phase block rather\n * than the executable instruction set.\n *\n * @param {number} opcode Opcode id from the instruction token.\n * @returns {boolean} True for `dcl_*`, hull-phase, and custom-data opcodes.\n */\nexport function dxbcIsDeclarationOpcode(opcode)\n{\n if (opcode === DXBC_OPCODE_CUSTOMDATA)\n {\n return true;\n }\n return DECLARATION_RANGES.some(([ start, end ]) => opcode >= start && opcode <= end);\n}\n"],"names":["DXBC_OPCODE_CUSTOMDATA","DxbcOpcodeNames","Object","freeze","DxbcBooleanTestOpcodeNames","Set","DECLARATION_RANGES","dxbcOpcodeName","opcode","dxbcIsDeclarationOpcode","some","start","end"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,sBAAsB,GAAG;;AAEtC;AACA;AACA;AACO,MAAMC,eAAe,GAAGC,MAAM,CAACC,MAAM,CAAC,CACzC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EACpE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EACzE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EACxE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAC1E,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EA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AAM,CAC1D,CAAC;AAEF,MAAMC,kBAAkB,GAAG,CACvB,CAAE,EAAE,EAAE,GAAG,CAAE,EACX,CAAE,GAAG,EAAE,GAAG,CAAE,EACZ,CAAE,GAAG,EAAE,GAAG,CAAE,EACZ,CAAE,GAAG,EAAE,GAAG,CAAE,CACf;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAACC,MAAM,EACrC;AACI,EAAA,OAAOP,eAAe,CAACO,MAAM,CAAC,IAAI,CAAA,OAAA,EAAUA,MAAM,CAAA,CAAE;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,uBAAuBA,CAACD,MAAM,EAC9C;EACI,IAAIA,MAAM,KAAKR,sBAAsB,EACrC;AACI,IAAA,OAAO,IAAI;AACf,EAAA;AACA,EAAA,OAAOM,kBAAkB,CAACI,IAAI,CAAC,CAAC,CAAEC,KAAK,EAAEC,GAAG,CAAE,KAAKJ,MAAM,IAAIG,KAAK,IAAIH,MAAM,IAAII,GAAG,CAAC;AACxF;;;;"}
@@ -0,0 +1,91 @@
1
+ import { DxbcReadError } from './errors.js';
2
+
3
+ /**
4
+ * Program type names indexed by the SM4/SM5 version-token program-type field.
5
+ */
6
+ const DxbcProgramTypeNames = Object.freeze(["pixel", "vertex", "geometry", "hull", "domain", "compute"]);
7
+
8
+ /**
9
+ * DXBC shader program chunk reader for `SHEX`/`SHDR` token streams.
10
+ *
11
+ * Decodes the version header and exposes the raw instruction tokens for the
12
+ * translator stages that follow. Token interpretation stays out of this class
13
+ * so container inspection never depends on opcode coverage.
14
+ */
15
+ class DxbcShaderProgram {
16
+ /**
17
+ * Creates an empty shader program; call a read entry point to populate its version, stage, and instructions.
18
+ */
19
+ constructor() {
20
+ this.fourCC = "";
21
+ this.majorVersion = 0;
22
+ this.minorVersion = 0;
23
+ this.programType = 0;
24
+ this.programTypeName = "unknown";
25
+ this.lengthDwords = 0;
26
+ this.tokens = new Uint32Array(0);
27
+ this.source = "memory";
28
+ }
29
+
30
+ /**
31
+ * Reads the program version header and copies the aligned token stream.
32
+ *
33
+ * @param {{fourCC:string,bytes:Uint8Array}} chunk Chunk record from `DxbcContainer`.
34
+ * @param {object} [options] Read options.
35
+ * @param {string} [options.source] Source name used in error details.
36
+ * @returns {DxbcShaderProgram} This program.
37
+ */
38
+ Read(chunk, options = {}) {
39
+ this.fourCC = chunk.fourCC;
40
+ this.source = options.source || "memory";
41
+ const bytes = chunk.bytes;
42
+ if (bytes.length < 8) {
43
+ throw new DxbcReadError("DXBC shader chunk is smaller than the program header", {
44
+ source: this.source,
45
+ fourCC: this.fourCC,
46
+ chunkSize: bytes.length
47
+ });
48
+ }
49
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
50
+ const versionToken = view.getUint32(0, true);
51
+ this.minorVersion = versionToken & 0xf;
52
+ this.majorVersion = versionToken >>> 4 & 0xf;
53
+ this.programType = versionToken >>> 16 & 0xffff;
54
+ this.programTypeName = DxbcProgramTypeNames[this.programType] || "unknown";
55
+ this.lengthDwords = view.getUint32(4, true);
56
+ if (this.lengthDwords < 2 || this.lengthDwords * 4 > bytes.length) {
57
+ throw new DxbcReadError("DXBC program length disagrees with the chunk size", {
58
+ source: this.source,
59
+ fourCC: this.fourCC,
60
+ lengthDwords: this.lengthDwords,
61
+ chunkSize: bytes.length
62
+ });
63
+ }
64
+
65
+ // Copy through DataView so unaligned subarrays and big-endian hosts both decode correctly.
66
+ this.tokens = new Uint32Array(this.lengthDwords);
67
+ for (let index = 0; index < this.lengthDwords; index += 1) {
68
+ this.tokens[index] = view.getUint32(index * 4, true);
69
+ }
70
+ return this;
71
+ }
72
+
73
+ /**
74
+ * Returns serializable program metadata while omitting the token stream.
75
+ *
76
+ * @returns {object} JSON-safe program summary.
77
+ */
78
+ toJSON() {
79
+ return {
80
+ fourCC: this.fourCC,
81
+ majorVersion: this.majorVersion,
82
+ minorVersion: this.minorVersion,
83
+ programType: this.programType,
84
+ programTypeName: this.programTypeName,
85
+ lengthDwords: this.lengthDwords
86
+ };
87
+ }
88
+ }
89
+
90
+ export { DxbcProgramTypeNames, DxbcShaderProgram };
91
+ //# sourceMappingURL=program.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.js","sources":["../../../../../src/formats/dxbc/core/program.js"],"sourcesContent":["import { DxbcReadError } from \"./errors.js\";\n\n/**\n * Program type names indexed by the SM4/SM5 version-token program-type field.\n */\nexport const DxbcProgramTypeNames = Object.freeze([\n \"pixel\",\n \"vertex\",\n \"geometry\",\n \"hull\",\n \"domain\",\n \"compute\"\n]);\n\n/**\n * DXBC shader program chunk reader for `SHEX`/`SHDR` token streams.\n *\n * Decodes the version header and exposes the raw instruction tokens for the\n * translator stages that follow. Token interpretation stays out of this class\n * so container inspection never depends on opcode coverage.\n */\nexport class DxbcShaderProgram\n{\n /**\n * Creates an empty shader program; call a read entry point to populate its version, stage, and instructions.\n */\n constructor()\n {\n this.fourCC = \"\";\n this.majorVersion = 0;\n this.minorVersion = 0;\n this.programType = 0;\n this.programTypeName = \"unknown\";\n this.lengthDwords = 0;\n this.tokens = new Uint32Array(0);\n this.source = \"memory\";\n }\n\n /**\n * Reads the program version header and copies the aligned token stream.\n *\n * @param {{fourCC:string,bytes:Uint8Array}} chunk Chunk record from `DxbcContainer`.\n * @param {object} [options] Read options.\n * @param {string} [options.source] Source name used in error details.\n * @returns {DxbcShaderProgram} This program.\n */\n Read(chunk, options = {})\n {\n this.fourCC = chunk.fourCC;\n this.source = options.source || \"memory\";\n const bytes = chunk.bytes;\n if (bytes.length < 8)\n {\n throw new DxbcReadError(\"DXBC shader chunk is smaller than the program header\", {\n source: this.source,\n fourCC: this.fourCC,\n chunkSize: bytes.length\n });\n }\n\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const versionToken = view.getUint32(0, true);\n this.minorVersion = versionToken & 0xf;\n this.majorVersion = (versionToken >>> 4) & 0xf;\n this.programType = (versionToken >>> 16) & 0xffff;\n this.programTypeName = DxbcProgramTypeNames[this.programType] || \"unknown\";\n this.lengthDwords = view.getUint32(4, true);\n if (this.lengthDwords < 2 || this.lengthDwords * 4 > bytes.length)\n {\n throw new DxbcReadError(\"DXBC program length disagrees with the chunk size\", {\n source: this.source,\n fourCC: this.fourCC,\n lengthDwords: this.lengthDwords,\n chunkSize: bytes.length\n });\n }\n\n // Copy through DataView so unaligned subarrays and big-endian hosts both decode correctly.\n this.tokens = new Uint32Array(this.lengthDwords);\n for (let index = 0; index < this.lengthDwords; index += 1)\n {\n this.tokens[index] = view.getUint32(index * 4, true);\n }\n return this;\n }\n\n /**\n * Returns serializable program metadata while omitting the token stream.\n *\n * @returns {object} JSON-safe program summary.\n */\n toJSON()\n {\n return {\n fourCC: this.fourCC,\n majorVersion: this.majorVersion,\n minorVersion: this.minorVersion,\n programType: this.programType,\n programTypeName: this.programTypeName,\n lengthDwords: this.lengthDwords\n };\n }\n}\n"],"names":["DxbcProgramTypeNames","Object","freeze","DxbcShaderProgram","constructor","fourCC","majorVersion","minorVersion","programType","programTypeName","lengthDwords","tokens","Uint32Array","source","Read","chunk","options","bytes","length","DxbcReadError","chunkSize","view","DataView","buffer","byteOffset","byteLength","versionToken","getUint32","index","toJSON"],"mappings":";;AAEA;AACA;AACA;AACO,MAAMA,oBAAoB,GAAGC,MAAM,CAACC,MAAM,CAAC,CAC9C,OAAO,EACP,QAAQ,EACR,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,CACZ;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,iBAAiB,CAC9B;AACI;AACJ;AACA;AACIC,EAAAA,WAAWA,GACX;IACI,IAAI,CAACC,MAAM,GAAG,EAAE;IAChB,IAAI,CAACC,YAAY,GAAG,CAAC;IACrB,IAAI,CAACC,YAAY,GAAG,CAAC;IACrB,IAAI,CAACC,WAAW,GAAG,CAAC;IACpB,IAAI,CAACC,eAAe,GAAG,SAAS;IAChC,IAAI,CAACC,YAAY,GAAG,CAAC;AACrB,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