@carbonenginejs/runtime-resource 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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,448 @@
1
+ import { CjsDxbcFormat } from '../../dxbc/CjsDxbcFormat.js';
2
+ import { readEffectAnalysis, normalizeBytecodeBytes } from './effectAnalysis.js';
3
+ import { CewgpuPackage } from './cewgpu/CewgpuPackage.js';
4
+ import { CewgpuPackageBuilder } from './cewgpu/CewgpuPackageBuilder.js';
5
+ import { validateEffectPackageEnvelope } from './effectPackageValidation.js';
6
+ import { WebgpuReadError } from './errors.js';
7
+ import { lowerDxbcToIr } from './ir/lowerDxbcToIr.js';
8
+ import { normalizeEffectPermutation, validateResolvedPermutation } from './packageEffectSelection.js';
9
+
10
+ const OUTPUT_JSON = "json";
11
+ const OUTPUT_RAW = "raw";
12
+ const CEWGPU_MAGIC = "CWGP";
13
+ const CEWGPU_FORMAT = "CEWGPU";
14
+ const CEWGPU_ANALYSIS_FORMAT = "CEWGPU_ANALYSIS";
15
+ const CEWGPU_ANALYSIS_VERSION = 1;
16
+ const DEFAULT_VALUES = Object.freeze({
17
+ emit: OUTPUT_JSON,
18
+ source: "memory",
19
+ decodeInstructions: true,
20
+ permutation: null,
21
+ schema: null,
22
+ classes: Object.freeze({})
23
+ });
24
+ const OPTION_KEYS = new Set(["emit", "source", "decodeInstructions", "permutation", "schema", "classes"]);
25
+ function hasOwn(value, key) {
26
+ return Object.prototype.hasOwnProperty.call(value, key);
27
+ }
28
+ function normalizeEmit(emit, readerName) {
29
+ if (emit === undefined || emit === OUTPUT_JSON) return OUTPUT_JSON;
30
+ if (emit === OUTPUT_RAW) return OUTPUT_RAW;
31
+ throw new TypeError(`${readerName}: emit must be "${OUTPUT_JSON}" or "${OUTPUT_RAW}", got ${JSON.stringify(emit)}`);
32
+ }
33
+ function assertKnownOptions(options, readerName) {
34
+ for (const key of Object.keys(options)) {
35
+ if (!OPTION_KEYS.has(key)) {
36
+ throw new TypeError(`${readerName}: unknown option ${JSON.stringify(key)}`);
37
+ }
38
+ }
39
+ }
40
+ function classMap(values) {
41
+ return values && values.classes ? values.classes : {};
42
+ }
43
+ function cloneValues(values) {
44
+ return {
45
+ emit: values.emit,
46
+ source: values.source ?? DEFAULT_VALUES.source,
47
+ decodeInstructions: values.decodeInstructions ?? DEFAULT_VALUES.decodeInstructions,
48
+ permutation: values.permutation ?? null,
49
+ schema: values.schema ?? null,
50
+ classes: {
51
+ ...classMap(values)
52
+ }
53
+ };
54
+ }
55
+
56
+ /**
57
+ * Rejects class override keys outside a format reader's supported class set.
58
+ *
59
+ * @param {string[]} classKeys Supported class override keys.
60
+ * @param {string} key Candidate override key.
61
+ * @param {string} readerName Reader name used in diagnostics.
62
+ */
63
+ function validateClassKey(classKeys, key, readerName) {
64
+ if (!classKeys.includes(key)) {
65
+ throw new Error(`${readerName} unknown class type "${String(key)}"`);
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Validates one constructor supplied through a format reader class override.
71
+ *
72
+ * @param {string[]} classKeys Supported class override keys.
73
+ * @param {string} type Candidate override key.
74
+ * @param {Function} Class Candidate constructor.
75
+ * @param {string} readerName Reader name used in diagnostics.
76
+ */
77
+ function validateClass(classKeys, type, Class, readerName) {
78
+ validateClassKey(classKeys, type, readerName);
79
+ if (typeof Class !== "function") {
80
+ throw new TypeError(`${readerName} class "${type}" must be a constructor`);
81
+ }
82
+ }
83
+ function mergeClasses(values, classes, classKeys, readerName) {
84
+ if (!classes || typeof classes !== "object") {
85
+ throw new TypeError(`${readerName} classes option must be an object`);
86
+ }
87
+ const next = {
88
+ ...values.classes
89
+ };
90
+ for (const [type, Class] of Object.entries(classes)) {
91
+ validateClass(classKeys, type, Class, readerName);
92
+ next[type] = Class;
93
+ }
94
+ values.classes = next;
95
+ }
96
+
97
+ /**
98
+ * Merge format values over a base set and validate them.
99
+ *
100
+ * @param {object} base Current values.
101
+ * @param {object} [options] Values to merge in.
102
+ * @param {string[]} classKeys Valid class keys.
103
+ * @param {string} readerName Reader name used in error messages.
104
+ * @returns {object} A validated copy of the merged values.
105
+ */
106
+ function normalizeValues(base, options = {}, classKeys = [], readerName = "CjsWebgpuFormat") {
107
+ if (!options || typeof options !== "object") {
108
+ throw new TypeError(`${readerName} options must be an object`);
109
+ }
110
+ assertKnownOptions(options, readerName);
111
+ const values = cloneValues(base);
112
+ if (hasOwn(options, "emit")) values.emit = normalizeEmit(options.emit, readerName);
113
+ if (hasOwn(options, "source")) values.source = typeof options.source === "string" && options.source ? options.source : DEFAULT_VALUES.source;
114
+ if (hasOwn(options, "decodeInstructions")) values.decodeInstructions = !!options.decodeInstructions;
115
+ if (hasOwn(options, "permutation")) values.permutation = options.permutation ?? null;
116
+ if (hasOwn(options, "schema")) values.schema = options.schema ?? null;
117
+ if (hasOwn(options, "classes")) mergeClasses(values, options.classes, classKeys, readerName);
118
+ return values;
119
+ }
120
+
121
+ /**
122
+ * Normalize caller input into a Uint8Array of package bytes.
123
+ *
124
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.
125
+ * @returns {Uint8Array} The payload bytes.
126
+ */
127
+ function toBytes(input) {
128
+ if (input instanceof Uint8Array) return input;
129
+ if (typeof ArrayBuffer !== "undefined" && input instanceof ArrayBuffer) return new Uint8Array(input);
130
+ if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
131
+ throw new TypeError("CjsWebgpuFormat: input must be CEWGPU package bytes (Uint8Array, Buffer, DataView or ArrayBuffer)");
132
+ }
133
+
134
+ /**
135
+ * Sniffs whether a payload starts with the CEWGPU container magic.
136
+ *
137
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.
138
+ * @returns {boolean} True when the payload looks like a CEWGPU package.
139
+ */
140
+ function isCewgpu(input) {
141
+ try {
142
+ const bytes = toBytes(input);
143
+ return bytes.length >= CEWGPU_MAGIC.length && CEWGPU_MAGIC.split("").every((char, index) => bytes[index] === char.charCodeAt(0));
144
+ } catch {
145
+ return false;
146
+ }
147
+ }
148
+
149
+ /**
150
+ * The shared read path used by the instance Read/Inspect and static one-shots.
151
+ *
152
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU package payload.
153
+ * @param {object} values Normalized format values.
154
+ * @returns {CewgpuPackage} The loaded package.
155
+ */
156
+ function readRaw(input, values) {
157
+ const bytes = toBytes(input);
158
+ const pkg = new CewgpuPackage();
159
+ const ok = pkg.Read(bytes, {
160
+ sourcePath: values.source
161
+ });
162
+ if (!ok) {
163
+ throw new WebgpuReadError(pkg.readError ? pkg.readError.message : "Failed to read CEWGPU package", {
164
+ source: values.source,
165
+ cause: pkg.readError || null
166
+ });
167
+ }
168
+ try {
169
+ validateEffectPackageEnvelope(pkg);
170
+ } catch (error) {
171
+ throw new WebgpuReadError(error.message, {
172
+ source: values.source,
173
+ cause: error
174
+ });
175
+ }
176
+ return pkg;
177
+ }
178
+ function analysisStages(pkg) {
179
+ const analysisJson = pkg.analysisJson;
180
+ return Array.isArray(analysisJson?.stages) ? analysisJson.stages : [];
181
+ }
182
+ function wgslShaders(pkg) {
183
+ const wgslJson = pkg.wgslJson;
184
+ return Array.isArray(wgslJson?.shaders) ? wgslJson.shaders : [];
185
+ }
186
+ function wgslLayouts(pkg) {
187
+ const wgslJson = pkg.wgslJson;
188
+ return Array.isArray(wgslJson?.layouts) ? wgslJson.layouts : [];
189
+ }
190
+
191
+ /**
192
+ * Converts a loaded package to the documented plain JSON shape.
193
+ *
194
+ * @param {CewgpuPackage} pkg Loaded package.
195
+ * @returns {object} Plain JSON data.
196
+ */
197
+ function packageToJson(pkg) {
198
+ return toJsonValue({
199
+ format: CEWGPU_FORMAT,
200
+ version: pkg.version,
201
+ sourcePath: pkg.sourcePath,
202
+ chunks: pkg.chunks.map(({
203
+ tag,
204
+ size,
205
+ offset
206
+ }) => ({
207
+ tag,
208
+ size,
209
+ offset
210
+ })),
211
+ info: pkg.info,
212
+ metadata: pkg.metadata,
213
+ permutationGraph: pkg.permutationGraph,
214
+ reflection: pkg.reflection,
215
+ reflectionBlobByteLength: pkg.reflectionBlobBytes?.byteLength ?? 0,
216
+ analysis: pkg.analysisJson !== null ? pkg.analysisJson : pkg.analysis,
217
+ wgsl: pkg.wgslJson !== null ? pkg.wgslJson : pkg.wgsl,
218
+ stages: analysisStages(pkg),
219
+ shaders: wgslShaders(pkg),
220
+ layouts: wgslLayouts(pkg)
221
+ });
222
+ }
223
+
224
+ /**
225
+ * Shared read entry honouring the emit mode.
226
+ *
227
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU package payload.
228
+ * @param {object} values Normalized format values.
229
+ * @returns {CewgpuPackage|object} Raw package or plain JSON package data.
230
+ */
231
+ function readWithValues(input, values) {
232
+ const pkg = readRaw(input, values);
233
+ return values.emit === OUTPUT_RAW ? pkg : packageToJson(pkg);
234
+ }
235
+
236
+ /**
237
+ * Cheap inspection: version, chunk tags/sizes, analysis-stage counts, and
238
+ * WGSL shader counts without building the full JSON package shape.
239
+ *
240
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU package payload.
241
+ * @param {object} values Normalized format values.
242
+ * @returns {object} Plain summary data.
243
+ */
244
+ function inspectWithValues(input, values) {
245
+ const pkg = readRaw(input, values);
246
+ const info = pkg.info;
247
+ const permutationGraph = pkg.permutationGraph;
248
+ return {
249
+ source: values.source,
250
+ isCewgpu: true,
251
+ version: pkg.version,
252
+ chunks: pkg.chunks.map(({
253
+ tag,
254
+ size,
255
+ offset
256
+ }) => ({
257
+ tag,
258
+ size,
259
+ offset
260
+ })),
261
+ permutationCount: permutationGraph?.variants?.length ?? 0,
262
+ uniqueBodyCount: permutationGraph?.bodies?.length ?? 0,
263
+ reflectionBodyCount: info?.effectReflection?.bodyCount ?? 0,
264
+ reflectionSourceProgramCount: info?.effectReflection?.sourceProgramCount ?? 0,
265
+ reflectionBlobCount: info?.effectReflection?.blobCount ?? 0,
266
+ reflectionBlobByteLength: info?.effectReflection?.blobByteLength ?? 0,
267
+ stageCount: analysisStages(pkg).length,
268
+ shaderCount: wgslShaders(pkg).length,
269
+ layoutCount: wgslLayouts(pkg).length
270
+ };
271
+ }
272
+
273
+ /**
274
+ * Assembles a CEWGPU package from ordered chunk payloads.
275
+ *
276
+ * @param {Array<[string, string|object|Uint8Array|ArrayBuffer|ArrayBufferView]>} chunks Ordered package chunks.
277
+ * @returns {Uint8Array} Package bytes.
278
+ */
279
+ function buildPackage(chunks) {
280
+ return CewgpuPackageBuilder.build(chunks);
281
+ }
282
+ function dxbcSource(source, key) {
283
+ return source ? `${source}#${key}` : key;
284
+ }
285
+ function resolvedStageBytecode(stage, key, bytecodeByKey) {
286
+ if (!Number.isInteger(stage.stageType) || !Number.isInteger(stage.passIndex) || typeof stage.techniqueName !== "string" || !stage.techniqueName || typeof stage.stageName !== "string" || !stage.stageName) {
287
+ throw new Error(`${key} manifest stage identity is invalid`);
288
+ }
289
+ const innerStageType = stage.shaderBytecode?.stageType;
290
+ if (innerStageType !== undefined && !Number.isInteger(innerStageType)) {
291
+ throw new Error(`${key} manifest stage bytecode type is invalid`);
292
+ }
293
+ let raw = bytecodeByKey?.get(key);
294
+ if (!raw && bytecodeByKey instanceof Map) {
295
+ raw = Array.from(bytecodeByKey.values()).find(entry => entry.techniqueName === stage.techniqueName && entry.passIndex === stage.passIndex && entry.stageType === stage.stageType);
296
+ }
297
+ if (!raw) return stage.shaderBytecode?.bytes;
298
+ if (!Number.isInteger(raw.stageType) || stage.stageType !== raw.stageType || innerStageType !== undefined && innerStageType !== raw.stageType || stage.stageName !== raw.stageName || stage.shaderBytecode?.stageName !== undefined && stage.shaderBytecode.stageName !== raw.stageName) {
299
+ throw new Error(`${key} manifest and raw stage metadata disagree`);
300
+ }
301
+ if (stage.shaderBytecode?.bytes !== undefined) {
302
+ const manifestBytes = normalizeBytecodeBytes(stage.shaderBytecode.bytes, `${key} manifest stage bytecode`);
303
+ if (!manifestBytes || manifestBytes.length !== raw.bytes.length || manifestBytes.some((value, index) => value !== raw.bytes[index])) {
304
+ throw new Error(`${key} manifest and raw stage bytecode disagree`);
305
+ }
306
+ }
307
+ return raw.bytes;
308
+ }
309
+ function analyzeStage(stage, options) {
310
+ const key = `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`;
311
+ const shaderBytecode = stage.shaderBytecode && typeof stage.shaderBytecode === "object" ? {
312
+ ...stage.shaderBytecode
313
+ } : stage.shaderBytecode;
314
+ if (shaderBytecode && typeof shaderBytecode === "object") {
315
+ delete shaderBytecode.bytes;
316
+ }
317
+ const out = {
318
+ ...stage,
319
+ shaderBytecode,
320
+ key,
321
+ dxbc: null,
322
+ dxbcError: null,
323
+ ir: null,
324
+ irError: null
325
+ };
326
+ if (options.decodeBytecode === false) {
327
+ return out;
328
+ }
329
+ const bytecodeBytes = normalizeBytecodeBytes(options.bytecodeBytes ?? stage.shaderBytecode?.bytes, `${key} stage bytecode`);
330
+ if (!bytecodeBytes?.length) {
331
+ return out;
332
+ }
333
+ try {
334
+ out.dxbc = CjsDxbcFormat.read(bytecodeBytes, {
335
+ source: dxbcSource(options.source, key),
336
+ decodeInstructions: options.decodeInstructions
337
+ });
338
+ if (options.decodeInstructions && Array.isArray(out.dxbc.instructions)) {
339
+ try {
340
+ out.ir = lowerDxbcToIr(out.dxbc, {
341
+ source: dxbcSource(options.source, key)
342
+ });
343
+ } catch (error) {
344
+ out.irError = {
345
+ name: error.name,
346
+ message: error.message
347
+ };
348
+ }
349
+ }
350
+ } catch (error) {
351
+ out.dxbcError = {
352
+ name: error.name,
353
+ message: error.message
354
+ };
355
+ }
356
+ return out;
357
+ }
358
+
359
+ /**
360
+ * Builds the normalized WebGPU analysis document from a resolved effect.
361
+ *
362
+ * @param {object} resolved Raw resolved-effect context from `readEffectAnalysis`.
363
+ * @param {object} [options] Analysis options.
364
+ * @param {string} [options.source] Source label for diagnostics.
365
+ * @param {boolean} [options.decodeBytecode] Whether stage bytecode is inspected.
366
+ * @param {boolean} [options.decodeInstructions] Whether DXBC instructions are decoded.
367
+ * @returns {object} Plain JSON-compatible analysis data.
368
+ */
369
+ function buildEffectAnalysis(resolved, options = {}) {
370
+ const source = options.source || resolved.effectRes?.sourcePath || "memory";
371
+ const decodeBytecode = options.decodeBytecode !== undefined ? !!options.decodeBytecode : true;
372
+ const decodeInstructions = options.decodeInstructions !== undefined ? !!options.decodeInstructions : true;
373
+ const manifest = resolved.bindingManifest?.toJSON?.() ?? null;
374
+ const bytecodeByKey = resolved.stageBytecodeByKey instanceof Map ? resolved.stageBytecodeByKey : null;
375
+ const stages = (manifest?.stages || []).map(stage => {
376
+ const key = `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`;
377
+ return analyzeStage(stage, {
378
+ source,
379
+ decodeBytecode,
380
+ decodeInstructions,
381
+ bytecodeBytes: resolvedStageBytecode(stage, key, bytecodeByKey)
382
+ });
383
+ });
384
+ return toJsonValue({
385
+ format: CEWGPU_ANALYSIS_FORMAT,
386
+ formatVersion: CEWGPU_ANALYSIS_VERSION,
387
+ source,
388
+ effectVersion: resolved.effectDescription?.version ?? manifest?.version ?? resolved.effectRes?.m_version ?? null,
389
+ compilerVersion: resolved.effectRes?.m_compilerVersion ?? null,
390
+ effectName: manifest?.effectName || resolved.effectDescription?.effectName || null,
391
+ bodyIndex: resolved.selection?.bodyIndex ?? 0,
392
+ selectedOptions: resolved.selection?.selectedOptions ?? [],
393
+ passes: manifest?.passes || [],
394
+ stages
395
+ });
396
+ }
397
+
398
+ /**
399
+ * Analyzes one compiled effect payload into a normalized WebGPU-facing
400
+ * document: selected permutation, Carbon binding manifest, and per-stage DXBC
401
+ * decode.
402
+ *
403
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.
404
+ * @param {object} values Normalized format values.
405
+ * @returns {object} Plain JSON-compatible analysis data.
406
+ */
407
+ function analyzeEffectWithValues(input, values) {
408
+ const permutation = normalizeEffectPermutation(values.permutation);
409
+ const resolved = readEffectAnalysis(input, {
410
+ source: values.source,
411
+ permutation
412
+ });
413
+ validateResolvedPermutation(permutation, resolved.selection?.selectedOptions ?? []);
414
+ return buildEffectAnalysis(resolved, {
415
+ source: values.source,
416
+ decodeInstructions: values.decodeInstructions
417
+ });
418
+ }
419
+
420
+ /**
421
+ * Deep-convert a value to plain JSON-compatible data.
422
+ *
423
+ * @param {any} value Value to convert.
424
+ * @returns {any} Plain data.
425
+ */
426
+ function toJsonValue(value) {
427
+ if (value === null || value === undefined) return value ?? null;
428
+ if (typeof value === "number" || typeof value === "string" || typeof value === "boolean") return value;
429
+ if (typeof value === "bigint") return value.toString();
430
+ if (ArrayBuffer.isView(value)) return Array.from(value);
431
+ if (Array.isArray(value)) return value.map(toJsonValue);
432
+ if (value instanceof Map) {
433
+ const out = {};
434
+ for (const [key, entry] of value) out[key] = toJsonValue(entry);
435
+ return out;
436
+ }
437
+ if (value instanceof Set) return Array.from(value, toJsonValue);
438
+ if (typeof value === "object") {
439
+ if (typeof value.toJSON === "function") return toJsonValue(value.toJSON());
440
+ const out = {};
441
+ for (const key of Object.keys(value)) out[key] = toJsonValue(value[key]);
442
+ return out;
443
+ }
444
+ return null;
445
+ }
446
+
447
+ export { CEWGPU_ANALYSIS_FORMAT, CEWGPU_ANALYSIS_VERSION, CEWGPU_FORMAT, CEWGPU_MAGIC, DEFAULT_VALUES, OUTPUT_JSON, OUTPUT_RAW, WebgpuReadError, analyzeEffectWithValues, buildEffectAnalysis, buildPackage, inspectWithValues, isCewgpu, normalizeValues, packageToJson, readRaw, readWithValues, toBytes, toJsonValue, validateClass, validateClassKey };
448
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sources":["../../../../../src/formats/webgpu/core/helpers.js"],"sourcesContent":["import CjsDxbcFormat from \"../../dxbc/index.js\";\nimport { normalizeBytecodeBytes, readEffectAnalysis } from \"./effectAnalysis.js\";\n\nimport { CewgpuPackage } from \"./cewgpu/CewgpuPackage.js\";\nimport { CewgpuPackageBuilder } from \"./cewgpu/CewgpuPackageBuilder.js\";\nimport { validateEffectPackageEnvelope } from \"./effectPackageValidation.js\";\nimport { WebgpuReadError } from \"./errors.js\";\nimport { lowerDxbcToIr } from \"./ir/lowerDxbcToIr.js\";\nimport {\n normalizeEffectPermutation,\n validateResolvedPermutation\n} from \"./packageEffectSelection.js\";\n\nexport const OUTPUT_JSON = \"json\";\nexport const OUTPUT_RAW = \"raw\";\nexport const CEWGPU_MAGIC = \"CWGP\";\nexport const CEWGPU_FORMAT = \"CEWGPU\";\nexport const CEWGPU_ANALYSIS_FORMAT = \"CEWGPU_ANALYSIS\";\nexport const CEWGPU_ANALYSIS_VERSION = 1;\n\nexport const DEFAULT_VALUES = Object.freeze({\n emit: OUTPUT_JSON,\n source: \"memory\",\n decodeInstructions: true,\n permutation: null,\n schema: null,\n classes: Object.freeze({})\n});\n\nconst OPTION_KEYS = new Set([ \"emit\", \"source\", \"decodeInstructions\", \"permutation\", \"schema\", \"classes\" ]);\nconst VALID_EMITS = new Set([ OUTPUT_JSON, OUTPUT_RAW ]);\n\nfunction hasOwn(value, key)\n{\n return Object.prototype.hasOwnProperty.call(value, key);\n}\n\nfunction normalizeEmit(emit, readerName)\n{\n if (emit === undefined || emit === OUTPUT_JSON) return OUTPUT_JSON;\n if (emit === OUTPUT_RAW) return OUTPUT_RAW;\n throw new TypeError(`${readerName}: emit must be \"${OUTPUT_JSON}\" or \"${OUTPUT_RAW}\", got ${JSON.stringify(emit)}`);\n}\n\nfunction assertKnownOptions(options, readerName)\n{\n for (const key of Object.keys(options))\n {\n if (!OPTION_KEYS.has(key))\n {\n throw new TypeError(`${readerName}: unknown option ${JSON.stringify(key)}`);\n }\n }\n}\n\nfunction classMap(values)\n{\n return values && values.classes ? values.classes : {};\n}\n\nfunction cloneValues(values)\n{\n return {\n emit: values.emit,\n source: values.source ?? DEFAULT_VALUES.source,\n decodeInstructions: values.decodeInstructions ?? DEFAULT_VALUES.decodeInstructions,\n permutation: values.permutation ?? null,\n schema: values.schema ?? null,\n classes: { ...classMap(values) }\n };\n}\n\n/**\n * Rejects class override keys outside a format reader's supported class set.\n *\n * @param {string[]} classKeys Supported class override keys.\n * @param {string} key Candidate override key.\n * @param {string} readerName Reader name used in diagnostics.\n */\nexport function validateClassKey(classKeys, key, readerName)\n{\n if (!classKeys.includes(key))\n {\n throw new Error(`${readerName} unknown class type \"${String(key)}\"`);\n }\n}\n\n/**\n * Validates one constructor supplied through a format reader class override.\n *\n * @param {string[]} classKeys Supported class override keys.\n * @param {string} type Candidate override key.\n * @param {Function} Class Candidate constructor.\n * @param {string} readerName Reader name used in diagnostics.\n */\nexport function validateClass(classKeys, type, Class, readerName)\n{\n validateClassKey(classKeys, type, readerName);\n if (typeof Class !== \"function\")\n {\n throw new TypeError(`${readerName} class \"${type}\" must be a constructor`);\n }\n}\n\nfunction mergeClasses(values, classes, classKeys, readerName)\n{\n if (!classes || typeof classes !== \"object\")\n {\n throw new TypeError(`${readerName} classes option must be an object`);\n }\n\n const next = { ...values.classes };\n for (const [ type, Class ] of Object.entries(classes))\n {\n validateClass(classKeys, type, Class, readerName);\n next[type] = Class;\n }\n values.classes = next;\n}\n\n/**\n * Merge format values over a base set and validate them.\n *\n * @param {object} base Current values.\n * @param {object} [options] Values to merge in.\n * @param {string[]} classKeys Valid class keys.\n * @param {string} readerName Reader name used in error messages.\n * @returns {object} A validated copy of the merged values.\n */\nexport function normalizeValues(base, options = {}, classKeys = [], readerName = \"CjsWebgpuFormat\")\n{\n if (!options || typeof options !== \"object\")\n {\n throw new TypeError(`${readerName} options must be an object`);\n }\n\n assertKnownOptions(options, readerName);\n\n const values = cloneValues(base);\n if (hasOwn(options, \"emit\")) values.emit = normalizeEmit(options.emit, readerName);\n if (hasOwn(options, \"source\")) values.source = typeof options.source === \"string\" && options.source ? options.source : DEFAULT_VALUES.source;\n if (hasOwn(options, \"decodeInstructions\")) values.decodeInstructions = !!options.decodeInstructions;\n if (hasOwn(options, \"permutation\")) values.permutation = options.permutation ?? null;\n if (hasOwn(options, \"schema\")) values.schema = options.schema ?? null;\n if (hasOwn(options, \"classes\")) mergeClasses(values, options.classes, classKeys, readerName);\n return values;\n}\n\n/**\n * Normalize caller input into a Uint8Array of package bytes.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.\n * @returns {Uint8Array} The payload bytes.\n */\nexport function toBytes(input)\n{\n if (input instanceof Uint8Array) return input;\n if (typeof ArrayBuffer !== \"undefined\" && input instanceof ArrayBuffer) return new Uint8Array(input);\n if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n throw new TypeError(\"CjsWebgpuFormat: input must be CEWGPU package bytes (Uint8Array, Buffer, DataView or ArrayBuffer)\");\n}\n\n/**\n * Sniffs whether a payload starts with the CEWGPU container magic.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.\n * @returns {boolean} True when the payload looks like a CEWGPU package.\n */\nexport function isCewgpu(input)\n{\n try\n {\n const bytes = toBytes(input);\n return bytes.length >= CEWGPU_MAGIC.length\n && CEWGPU_MAGIC.split(\"\").every((char, index) => bytes[index] === char.charCodeAt(0));\n }\n catch\n {\n return false;\n }\n}\n\n/**\n * The shared read path used by the instance Read/Inspect and static one-shots.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU package payload.\n * @param {object} values Normalized format values.\n * @returns {CewgpuPackage} The loaded package.\n */\nexport function readRaw(input, values)\n{\n const bytes = toBytes(input);\n const pkg = new CewgpuPackage();\n const ok = pkg.Read(bytes, { sourcePath: values.source });\n\n if (!ok)\n {\n throw new WebgpuReadError(\n pkg.readError ? pkg.readError.message : \"Failed to read CEWGPU package\",\n {\n source: values.source,\n cause: pkg.readError || null\n }\n );\n }\n\n try\n {\n validateEffectPackageEnvelope(pkg);\n }\n catch (error)\n {\n throw new WebgpuReadError(error.message, {\n source: values.source,\n cause: error\n });\n }\n\n return pkg;\n}\n\nfunction analysisStages(pkg)\n{\n const analysisJson = pkg.analysisJson;\n return Array.isArray(analysisJson?.stages) ? analysisJson.stages : [];\n}\n\nfunction wgslShaders(pkg)\n{\n const wgslJson = pkg.wgslJson;\n return Array.isArray(wgslJson?.shaders) ? wgslJson.shaders : [];\n}\n\nfunction wgslLayouts(pkg)\n{\n const wgslJson = pkg.wgslJson;\n return Array.isArray(wgslJson?.layouts) ? wgslJson.layouts : [];\n}\n\n/**\n * Converts a loaded package to the documented plain JSON shape.\n *\n * @param {CewgpuPackage} pkg Loaded package.\n * @returns {object} Plain JSON data.\n */\nexport function packageToJson(pkg)\n{\n return toJsonValue({\n format: CEWGPU_FORMAT,\n version: pkg.version,\n sourcePath: pkg.sourcePath,\n chunks: pkg.chunks.map(({ tag, size, offset }) => ({ tag, size, offset })),\n info: pkg.info,\n metadata: pkg.metadata,\n permutationGraph: pkg.permutationGraph,\n reflection: pkg.reflection,\n reflectionBlobByteLength: pkg.reflectionBlobBytes?.byteLength ?? 0,\n analysis: pkg.analysisJson !== null ? pkg.analysisJson : pkg.analysis,\n wgsl: pkg.wgslJson !== null ? pkg.wgslJson : pkg.wgsl,\n stages: analysisStages(pkg),\n shaders: wgslShaders(pkg),\n layouts: wgslLayouts(pkg)\n });\n}\n\n/**\n * Shared read entry honouring the emit mode.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU package payload.\n * @param {object} values Normalized format values.\n * @returns {CewgpuPackage|object} Raw package or plain JSON package data.\n */\nexport function readWithValues(input, values)\n{\n const pkg = readRaw(input, values);\n return values.emit === OUTPUT_RAW ? pkg : packageToJson(pkg);\n}\n\n/**\n * Cheap inspection: version, chunk tags/sizes, analysis-stage counts, and\n * WGSL shader counts without building the full JSON package shape.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWGPU package payload.\n * @param {object} values Normalized format values.\n * @returns {object} Plain summary data.\n */\nexport function inspectWithValues(input, values)\n{\n const pkg = readRaw(input, values);\n const info = pkg.info;\n const permutationGraph = pkg.permutationGraph;\n return {\n source: values.source,\n isCewgpu: true,\n version: pkg.version,\n chunks: pkg.chunks.map(({ tag, size, offset }) => ({ tag, size, offset })),\n permutationCount: permutationGraph?.variants?.length ?? 0,\n uniqueBodyCount: permutationGraph?.bodies?.length ?? 0,\n reflectionBodyCount: info?.effectReflection?.bodyCount ?? 0,\n reflectionSourceProgramCount:\n info?.effectReflection?.sourceProgramCount ?? 0,\n reflectionBlobCount: info?.effectReflection?.blobCount ?? 0,\n reflectionBlobByteLength:\n info?.effectReflection?.blobByteLength ?? 0,\n stageCount: analysisStages(pkg).length,\n shaderCount: wgslShaders(pkg).length,\n layoutCount: wgslLayouts(pkg).length\n };\n}\n\n/**\n * Assembles a CEWGPU package from ordered chunk payloads.\n *\n * @param {Array<[string, string|object|Uint8Array|ArrayBuffer|ArrayBufferView]>} chunks Ordered package chunks.\n * @returns {Uint8Array} Package bytes.\n */\nexport function buildPackage(chunks)\n{\n return CewgpuPackageBuilder.build(chunks);\n}\n\nfunction dxbcSource(source, key)\n{\n return source ? `${source}#${key}` : key;\n}\n\nfunction resolvedStageBytecode(stage, key, bytecodeByKey)\n{\n if (!Number.isInteger(stage.stageType)\n || !Number.isInteger(stage.passIndex)\n || typeof stage.techniqueName !== \"string\"\n || !stage.techniqueName\n || typeof stage.stageName !== \"string\"\n || !stage.stageName)\n {\n throw new Error(`${key} manifest stage identity is invalid`);\n }\n\n const innerStageType = stage.shaderBytecode?.stageType;\n if (innerStageType !== undefined && !Number.isInteger(innerStageType))\n {\n throw new Error(`${key} manifest stage bytecode type is invalid`);\n }\n\n let raw = bytecodeByKey?.get(key);\n if (!raw && bytecodeByKey instanceof Map)\n {\n raw = Array.from(bytecodeByKey.values()).find((entry) =>\n entry.techniqueName === stage.techniqueName\n && entry.passIndex === stage.passIndex\n && entry.stageType === stage.stageType\n );\n }\n if (!raw) return stage.shaderBytecode?.bytes;\n\n if (!Number.isInteger(raw.stageType)\n || stage.stageType !== raw.stageType\n || (innerStageType !== undefined && innerStageType !== raw.stageType)\n || stage.stageName !== raw.stageName\n || (stage.shaderBytecode?.stageName !== undefined\n && stage.shaderBytecode.stageName !== raw.stageName))\n {\n throw new Error(`${key} manifest and raw stage metadata disagree`);\n }\n\n if (stage.shaderBytecode?.bytes !== undefined)\n {\n const manifestBytes = normalizeBytecodeBytes(\n stage.shaderBytecode.bytes,\n `${key} manifest stage bytecode`\n );\n if (!manifestBytes\n || manifestBytes.length !== raw.bytes.length\n || manifestBytes.some((value, index) => value !== raw.bytes[index]))\n {\n throw new Error(`${key} manifest and raw stage bytecode disagree`);\n }\n }\n\n return raw.bytes;\n}\n\nfunction analyzeStage(stage, options)\n{\n const key = `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`;\n const shaderBytecode = stage.shaderBytecode && typeof stage.shaderBytecode === \"object\"\n ? { ...stage.shaderBytecode }\n : stage.shaderBytecode;\n if (shaderBytecode && typeof shaderBytecode === \"object\")\n {\n delete shaderBytecode.bytes;\n }\n const out = {\n ...stage,\n shaderBytecode,\n key,\n dxbc: null,\n dxbcError: null,\n ir: null,\n irError: null\n };\n\n if (options.decodeBytecode === false)\n {\n return out;\n }\n\n const bytecodeBytes = normalizeBytecodeBytes(\n options.bytecodeBytes ?? stage.shaderBytecode?.bytes,\n `${key} stage bytecode`\n );\n if (!bytecodeBytes?.length)\n {\n return out;\n }\n\n try\n {\n out.dxbc = CjsDxbcFormat.read(bytecodeBytes, {\n source: dxbcSource(options.source, key),\n decodeInstructions: options.decodeInstructions\n });\n if (options.decodeInstructions && Array.isArray(out.dxbc.instructions))\n {\n try\n {\n out.ir = lowerDxbcToIr(out.dxbc, { source: dxbcSource(options.source, key) });\n }\n catch (error)\n {\n out.irError = {\n name: error.name,\n message: error.message\n };\n }\n }\n }\n catch (error)\n {\n out.dxbcError = {\n name: error.name,\n message: error.message\n };\n }\n\n return out;\n}\n\n/**\n * Builds the normalized WebGPU analysis document from a resolved effect.\n *\n * @param {object} resolved Raw resolved-effect context from `readEffectAnalysis`.\n * @param {object} [options] Analysis options.\n * @param {string} [options.source] Source label for diagnostics.\n * @param {boolean} [options.decodeBytecode] Whether stage bytecode is inspected.\n * @param {boolean} [options.decodeInstructions] Whether DXBC instructions are decoded.\n * @returns {object} Plain JSON-compatible analysis data.\n */\nexport function buildEffectAnalysis(resolved, options = {})\n{\n const source = options.source || resolved.effectRes?.sourcePath || \"memory\";\n const decodeBytecode = options.decodeBytecode !== undefined ? !!options.decodeBytecode : true;\n const decodeInstructions = options.decodeInstructions !== undefined ? !!options.decodeInstructions : true;\n const manifest = resolved.bindingManifest?.toJSON?.() ?? null;\n const bytecodeByKey = resolved.stageBytecodeByKey instanceof Map\n ? resolved.stageBytecodeByKey\n : null;\n const stages = (manifest?.stages || []).map((stage) =>\n {\n const key = `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`;\n\n return analyzeStage(stage, {\n source,\n decodeBytecode,\n decodeInstructions,\n bytecodeBytes: resolvedStageBytecode(stage, key, bytecodeByKey)\n });\n });\n\n return toJsonValue({\n format: CEWGPU_ANALYSIS_FORMAT,\n formatVersion: CEWGPU_ANALYSIS_VERSION,\n source,\n effectVersion: resolved.effectDescription?.version ?? manifest?.version ?? resolved.effectRes?.m_version ?? null,\n compilerVersion: resolved.effectRes?.m_compilerVersion ?? null,\n effectName: manifest?.effectName || resolved.effectDescription?.effectName || null,\n bodyIndex: resolved.selection?.bodyIndex ?? 0,\n selectedOptions: resolved.selection?.selectedOptions ?? [],\n passes: manifest?.passes || [],\n stages\n });\n}\n\n/**\n * Analyzes one compiled effect payload into a normalized WebGPU-facing\n * document: selected permutation, Carbon binding manifest, and per-stage DXBC\n * decode.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.\n * @param {object} values Normalized format values.\n * @returns {object} Plain JSON-compatible analysis data.\n */\nexport function analyzeEffectWithValues(input, values)\n{\n const permutation = normalizeEffectPermutation(values.permutation);\n const resolved = readEffectAnalysis(input, {\n source: values.source,\n permutation\n });\n validateResolvedPermutation(\n permutation,\n resolved.selection?.selectedOptions ?? []\n );\n\n return buildEffectAnalysis(resolved, {\n source: values.source,\n decodeInstructions: values.decodeInstructions\n });\n}\n\n/**\n * Deep-convert a value to plain JSON-compatible data.\n *\n * @param {any} value Value to convert.\n * @returns {any} Plain data.\n */\nexport function toJsonValue(value)\n{\n if (value === null || value === undefined) return value ?? null;\n if (typeof value === \"number\" || typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"bigint\") return value.toString();\n if (ArrayBuffer.isView(value)) return Array.from(value);\n if (Array.isArray(value)) return value.map(toJsonValue);\n if (value instanceof Map)\n {\n const out = {};\n for (const [ key, entry ] of value) out[key] = toJsonValue(entry);\n return out;\n }\n if (value instanceof Set) return Array.from(value, toJsonValue);\n if (typeof value === \"object\")\n {\n if (typeof value.toJSON === \"function\") return toJsonValue(value.toJSON());\n const out = {};\n for (const key of Object.keys(value)) out[key] = toJsonValue(value[key]);\n return out;\n }\n return null;\n}\n\nexport { WebgpuReadError };\n"],"names":["OUTPUT_JSON","OUTPUT_RAW","CEWGPU_MAGIC","CEWGPU_FORMAT","CEWGPU_ANALYSIS_FORMAT","CEWGPU_ANALYSIS_VERSION","DEFAULT_VALUES","Object","freeze","emit","source","decodeInstructions","permutation","schema","classes","OPTION_KEYS","Set","hasOwn","value","key","prototype","hasOwnProperty","call","normalizeEmit","readerName","undefined","TypeError","JSON","stringify","assertKnownOptions","options","keys","has","classMap","values","cloneValues","validateClassKey","classKeys","includes","Error","String","validateClass","type","Class","mergeClasses","next","entries","normalizeValues","base","toBytes","input","Uint8Array","ArrayBuffer","isView","buffer","byteOffset","byteLength","isCewgpu","bytes","length","split","every","char","index","charCodeAt","readRaw","pkg","CewgpuPackage","ok","Read","sourcePath","WebgpuReadError","readError","message","cause","validateEffectPackageEnvelope","error","analysisStages","analysisJson","Array","isArray","stages","wgslShaders","wgslJson","shaders","wgslLayouts","layouts","packageToJson","toJsonValue","format","version","chunks","map","tag","size","offset","info","metadata","permutationGraph","reflection","reflectionBlobByteLength","reflectionBlobBytes","analysis","wgsl","readWithValues","inspectWithValues","permutationCount","variants","uniqueBodyCount","bodies","reflectionBodyCount","effectReflection","bodyCount","reflectionSourceProgramCount","sourceProgramCount","reflectionBlobCount","blobCount","blobByteLength","stageCount","shaderCount","layoutCount","buildPackage","CewgpuPackageBuilder","build","dxbcSource","resolvedStageBytecode","stage","bytecodeByKey","Number","isInteger","stageType","passIndex","techniqueName","stageName","innerStageType","shaderBytecode","raw","get","Map","from","find","entry","manifestBytes","normalizeBytecodeBytes","some","analyzeStage","out","dxbc","dxbcError","ir","irError","decodeBytecode","bytecodeBytes","CjsDxbcFormat","read","instructions","lowerDxbcToIr","name","buildEffectAnalysis","resolved","effectRes","manifest","bindingManifest","toJSON","stageBytecodeByKey","formatVersion","effectVersion","effectDescription","m_version","compilerVersion","m_compilerVersion","effectName","bodyIndex","selection","selectedOptions","passes","analyzeEffectWithValues","normalizeEffectPermutation","readEffectAnalysis","validateResolvedPermutation","toString"],"mappings":";;;;;;;;;AAaO,MAAMA,WAAW,GAAG;AACpB,MAAMC,UAAU,GAAG;AACnB,MAAMC,YAAY,GAAG;AACrB,MAAMC,aAAa,GAAG;AACtB,MAAMC,sBAAsB,GAAG;AAC/B,MAAMC,uBAAuB,GAAG;MAE1BC,cAAc,GAAGC,MAAM,CAACC,MAAM,CAAC;AACxCC,EAAAA,IAAI,EAAET,WAAW;AACjBU,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,kBAAkB,EAAE,IAAI;AACxBC,EAAAA,WAAW,EAAE,IAAI;AACjBC,EAAAA,MAAM,EAAE,IAAI;AACZC,EAAAA,OAAO,EAAEP,MAAM,CAACC,MAAM,CAAC,EAAE;AAC7B,CAAC;AAED,MAAMO,WAAW,GAAG,IAAIC,GAAG,CAAC,CAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,CAAE,CAAC;AAG3G,SAASC,MAAMA,CAACC,KAAK,EAAEC,GAAG,EAC1B;EACI,OAAOZ,MAA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