@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,25 @@
1
+ carbonenginejs/format-hlsl
2
+ ==========================
3
+
4
+ A pure-JavaScript reader for CCP's Tr2 compiled effect container format
5
+ (`.sm_hi` / `.sm_lo` / `.sm_depth` bodies): the permutation axes, technique
6
+ and pass tables, and per-stage constant/resource/sampler metadata that make
7
+ up one compiled Carbon/Trinity effect resource.
8
+
9
+ Contains no CarbonEngine or Fenris Creations (CCP Games) code. The container layout and
10
+ data-shape model were reverse-engineered from compiled effect files, historical
11
+ GLES shader assets, and observed CarbonEngine source-code structure. Those
12
+ sources informed field names and layout hypotheses; the implementation here is
13
+ original CarbonEngineJS code.
14
+
15
+ No CarbonEngine or Fenris Creations (CCP Games) source files, tooling, proprietary documentation, or
16
+ shader compiler code are included in this repository. Shader bytecode bodies are
17
+ kept as opaque bytes (`CjsShaderBytecode`) — this package does not decode
18
+ DXBC/HLSL bytecode.
19
+
20
+ This package is not affiliated with or endorsed by CCP Games.
21
+
22
+ CarbonEngineJS-facing code is copyright cppctamber / CarbonEngineJS
23
+ contributors.
24
+
25
+ Repository license: MIT. See LICENSE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 cppctamber / CarbonEngineJS contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,35 @@
1
+ carbonenginejs/format-webgl
2
+ ===========================
3
+
4
+ A pure-JavaScript reader/builder for CarbonEngineJS `.cewg` WebGL shader
5
+ packages, and a DXBC (Direct3D compiled shader bytecode) to GLSL ES 3.00
6
+ emitter for the WebGL2 vertex/pixel/map-style-compute stages ccpwgl targets.
7
+
8
+ Contains no Microsoft, CarbonEngine, or Fenris Creations (CCP Games) code. The CEWG container format (a flat
9
+ four-byte-tagged chunk layout: `INFO`/`META`/`GLSL`/...) is a CarbonEngineJS
10
+ invention, not a Microsoft, CarbonEngine, or Fenris Creations (CCP Games) one. The DXBC token-stream layout follows
11
+ Microsoft's public d3d11TokenizedProgramFormat documentation (consumed here
12
+ only through `@carbonenginejs/format-dxbc`'s public format; this package
13
+ decodes no DXBC bytes itself). Unity Technologies' HLSLcc (MIT) was used as
14
+ a behavioral reference while auditing the GLSL lowering rules this emitter
15
+ implements; no HLSLcc source is included in this repository.
16
+
17
+ CarbonEngine and Fenris Creations (CCP Games) are mentioned for
18
+ interoperability and target-runtime context. This package is not affiliated with
19
+ or endorsed by CCP Games.
20
+
21
+ Provenance
22
+ ----------
23
+
24
+ The CEWG package reader/builder and the DXBC-to-GLSL emitter were originally
25
+ developed in this project's own prior-work repository,
26
+ `hlslreader` (`src/carbon/webgl/CewgPackage.js`, `CewgPackageBuilder.js`, and
27
+ `src/dxbc/glsl/*.js`), and ported here with import/error-class adjustments
28
+ only (see README for the ported-file list). No third-party, CarbonEngine, or
29
+ Fenris Creations (CCP Games) source was copied; both repositories are
30
+ cppctamber / CarbonEngineJS original work.
31
+
32
+ CarbonEngineJS-facing code is copyright cppctamber / CarbonEngineJS
33
+ contributors.
34
+
35
+ Repository license: MIT. See LICENSE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CarbonEngineJS contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,31 @@
1
+ format-webgpu
2
+
3
+ Copyright (c) CarbonEngineJS contributors.
4
+ CarbonEngine source material, formats, class names, and schema semantics remain
5
+ copyright their original CarbonEngine authors.
6
+ Fenris Creations (CCP Games) source material, tools, assets, shader behavior,
7
+ and EVE-related data remain copyright their original holders.
8
+
9
+ This package is a CarbonEngineJS-facing reader/builder for `.cewgpu` WebGPU
10
+ package data plus offline effect-analysis helpers. It contains original project
11
+ code only unless this notice is expanded with third-party attribution.
12
+ CarbonEngine and Fenris Creations (CCP Games) are mentioned for
13
+ interoperability, provenance, and future migration context only. This package is
14
+ not affiliated with or endorsed by CCP Games.
15
+
16
+ Provenance and legal requirements
17
+ ---------------------------------
18
+
19
+ This scaffold currently contains CarbonEngineJS original project code only. It
20
+ does not include copied CarbonEngine source code or third-party parser code.
21
+
22
+ If future work copies, ports, translates, or derives from CarbonEngine, ccpwgl,
23
+ Fenris Creations (CCP Games) / EVE assets or tools, or any third-party library,
24
+ update this NOTICE before committing that work with:
25
+
26
+ - upstream copyright holders;
27
+ - upstream project/repository, file path, and revision when known;
28
+ - upstream license name, license text or required notice location, and any
29
+ redistribution obligations;
30
+ - whether the material was copied/ported/adapted, or used only as a behavioral
31
+ reference with no copied expression.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carbonenginejs/runtime-resource",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "CarbonEngineJS resource lifecycle, cache, source, and object loading contracts.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -20,6 +20,11 @@
20
20
  "./formats/bnk": "./dist/formats/bnk/index.js",
21
21
  "./formats/cmf": "./dist/formats/cmf/index.js",
22
22
  "./formats/dds": "./dist/formats/dds/index.js",
23
+ "./formats/dxbc": "./dist/formats/dxbc/index.js",
24
+ "./formats/hlsl": "./dist/formats/hlsl/index.js",
25
+ "./formats/hlsl/portable": "./dist/formats/hlsl/portable.js",
26
+ "./formats/webgl": "./dist/formats/webgl/index.js",
27
+ "./formats/webgpu": "./dist/formats/webgpu/index.js",
23
28
  "./formats/fbx": "./dist/formats/fbx/index.js",
24
29
  "./formats/flac": "./dist/formats/flac/index.js",
25
30
  "./formats/gif": "./dist/formats/gif/index.js",
@@ -1,461 +0,0 @@
1
- import { isPlainObject, isUint32, isUint8 } from '@carbonenginejs/runtime-utils/is';
2
-
3
- const EFFECT_BODY_REFLECTION_FORMAT = "CJS_EFFECT_BODY_REFLECTION";
4
- const EFFECT_BODY_REFLECTION_VERSION = 1;
5
- const PORTABLE_EFFECT_VERSION = 15;
6
- const UINT32_MAX = 0xffffffff;
7
- const CONSTANT_BYTES_MAX = 4096;
8
- const STAGE_NAMES = Object.freeze(["vertex", "pixel", "compute", "geometry", "hull", "domain"]);
9
-
10
- /**
11
- * Validate the complete portable reflection v1 consumer contract.
12
- *
13
- * This intentionally mirrors the browser-safe producer schema without adding
14
- * a runtime-resource dependency on a format package.
15
- *
16
- * @param {object} document Candidate portable reflection.
17
- * @returns {object} The validated input document.
18
- */
19
- function validatePortableEffectReflection(document) {
20
- requireExactKeys(document, ["format", "formatVersion", "mode", "keyScope", "coverage", "source", "permutationIndex", "sourceRecord", "effect"], "Portable effect body reflection");
21
- requireExactKeys(document.coverage, ["bodies", "reflection", "sourcePrograms", "constantDefaults"], "Portable reflection coverage");
22
- if (document.format !== EFFECT_BODY_REFLECTION_FORMAT || document.formatVersion !== EFFECT_BODY_REFLECTION_VERSION || document.mode !== "single-body" || document.keyScope !== "body-local" || document.coverage.bodies !== "single" || document.coverage.reflection !== "complete" || document.coverage.sourcePrograms !== "complete" || document.coverage.constantDefaults !== "exact") {
23
- throw new Error("Portable effect body reflection schema or coverage is unsupported");
24
- }
25
- if (!isUint32(document.permutationIndex)) {
26
- throw new Error("Portable reflection permutationIndex must fit uint32");
27
- }
28
- validateSource(document.source);
29
- if (!isPlainObject(document.sourceRecord)) {
30
- throw new Error("Portable reflection sourceRecord must be an object");
31
- }
32
- const sourceRecord = document.sourceRecord;
33
- requireExactKeys(sourceRecord, ["offset", "byteLength"], "Portable reflection sourceRecord");
34
- if (!isUint32(sourceRecord.offset)) {
35
- throw new Error("Portable reflection sourceRecord offset must fit uint32");
36
- }
37
- if (!isUint32(sourceRecord.byteLength)) {
38
- throw new Error("Portable reflection sourceRecord byteLength must fit uint32");
39
- }
40
- if (!sourceRecord.byteLength || sourceRecord.offset + sourceRecord.byteLength > document.source.byteLength) {
41
- throw new Error("Portable reflection sourceRecord is outside the source envelope");
42
- }
43
- if (!isPlainObject(document.effect)) {
44
- throw new Error("Portable reflection effect must be an object");
45
- }
46
- const effect = document.effect;
47
- requireExactKeys(effect, ["annotations", "annotationGroupCount", "techniqueCount", "techniques"], "Portable reflection effect");
48
- if (!Array.isArray(effect.annotations) || !Array.isArray(effect.techniques) || effect.annotationGroupCount !== effect.annotations.length || effect.techniqueCount !== effect.techniques.length) {
49
- throw new Error("Portable reflection effect is malformed");
50
- }
51
- validateAnnotationGroups(effect.annotations, "effect annotations");
52
- const techniqueKeys = new Set();
53
- for (const [techniqueIndex, technique] of effect.techniques.entries()) {
54
- const context = `technique ${techniqueIndex}`;
55
- requireExactKeys(technique, ["key", "name", "passCount", "libraryCount", "passes", "libraries"], `Portable reflection ${context}`);
56
- requireKey(technique.key, `technique${techniqueIndex}`, context, techniqueKeys);
57
- if (typeof technique.name !== "string" || !Array.isArray(technique.passes) || !Array.isArray(technique.libraries) || technique.passCount !== technique.passes.length || technique.libraryCount !== technique.libraries.length) {
58
- throw new Error(`Portable reflection ${context} is malformed`);
59
- }
60
- const passKeys = new Set();
61
- for (const [passIndex, pass] of technique.passes.entries()) {
62
- const passKey = `${technique.key}.pass${passIndex}`;
63
- requireExactKeys(pass, ["key", "renderStateCount", "renderStates", "stageCount", "stages"], `Portable reflection ${context} pass ${passIndex}`);
64
- requireKey(pass.key, passKey, `${context} pass ${passIndex}`, passKeys);
65
- validatePass(pass, document.source);
66
- }
67
- const libraryKeys = new Set();
68
- for (const [libraryIndex, library] of technique.libraries.entries()) {
69
- const libraryKey = `${technique.key}.library${libraryIndex}`;
70
- requireExactKeys(library, ["key", "payloadSize", "sourceProgram", "exportCount", "exports", "hitGroupName", "globalInput", "localInput"], `Portable reflection ${context} library ${libraryIndex}`);
71
- requireKey(library.key, libraryKey, `${context} library ${libraryIndex}`, libraryKeys);
72
- validateLibrary(library, document.source);
73
- }
74
- }
75
- return document;
76
- }
77
-
78
- /** Whether a value is a complete valid portable reflection v1 document. */
79
- function isPortableEffectReflection(value) {
80
- try {
81
- validatePortableEffectReflection(value);
82
- return true;
83
- } catch {
84
- return false;
85
- }
86
- }
87
-
88
- /**
89
- * Validate one portable stage/library input independently.
90
- *
91
- * @param {object} input Portable input record.
92
- * @param {string} [context] Diagnostic context.
93
- * @returns {object} The validated input.
94
- */
95
- function validatePortableEffectInput(input, context = "standalone input") {
96
- validateInput(input, context);
97
- return input;
98
- }
99
- function validateSource(source) {
100
- requireExactKeys(source, ["label", "effectVersion", "compilerVersion", "nativeHash", "stringTableByteLength", "byteLength"], "Portable reflection source");
101
- if (typeof source.label !== "string") {
102
- throw new Error("Portable reflection source label is malformed");
103
- }
104
- if (!isUint32(source.effectVersion)) {
105
- throw new Error("Portable reflection effectVersion must fit uint32");
106
- }
107
- if (!isUint32(source.stringTableByteLength)) {
108
- throw new Error("Portable reflection stringTableByteLength must fit uint32");
109
- }
110
- if (!isUint32(source.byteLength)) {
111
- throw new Error("Portable reflection source byteLength must fit uint32");
112
- }
113
- if (!source.byteLength || source.stringTableByteLength > source.byteLength || source.effectVersion !== PORTABLE_EFFECT_VERSION) {
114
- throw new Error("Portable reflection source envelope is unsupported");
115
- }
116
- if (source.compilerVersion === null) {
117
- throw new Error("Portable reflection v15 compiler identity is incomplete");
118
- }
119
- if (!isUint32(source.compilerVersion)) {
120
- throw new Error("Portable reflection compilerVersion must fit uint32");
121
- }
122
- if (!(source.nativeHash instanceof Uint8Array) || source.nativeHash.byteLength !== 32) {
123
- throw new Error("Portable reflection v15 source identity is incomplete");
124
- }
125
- }
126
- function validatePass(pass, source) {
127
- if (!Array.isArray(pass.renderStates) || !Array.isArray(pass.stages) || pass.renderStateCount !== pass.renderStates.length || pass.stageCount !== pass.stages.length) {
128
- throw new Error(`Portable reflection pass ${pass.key} is malformed`);
129
- }
130
- validateRegisterIndexed(pass.renderStates, "state", `pass ${pass.key} render states`, entry => {
131
- requireExactKeys(entry, ["state", "value"], `Portable reflection pass ${pass.key} render state`);
132
- if (!isUint32(entry.value)) {
133
- throw new Error(`pass ${pass.key} render-state value must fit uint32`);
134
- }
135
- });
136
- const stageTypes = new Set();
137
- const stageKeys = new Set();
138
- for (const stage of pass.stages) {
139
- requireExactKeys(stage, ["key", "stageType", "stageName", "sourceProgram", "input"], `Portable reflection pass ${pass.key} stage`);
140
- if (!isUint32(stage.stageType)) {
141
- throw new Error(`pass ${pass.key} stage type must fit uint32`);
142
- }
143
- if (stage.stageType >= STAGE_NAMES.length || stageTypes.has(stage.stageType)) {
144
- throw new Error(`Portable reflection pass ${pass.key} stage type is invalid or duplicated`);
145
- }
146
- stageTypes.add(stage.stageType);
147
- requireKey(stage.key, `${pass.key}.stage${stage.stageType}`, `pass ${pass.key} stage`, stageKeys);
148
- if (stage.stageName !== STAGE_NAMES[stage.stageType]) {
149
- throw new Error(`Portable reflection stage ${stage.key} name disagrees`);
150
- }
151
- validateSourceProgram(stage.sourceProgram, "stage", stage.stageType, stage.stageName, source.stringTableByteLength);
152
- validateInput(stage.input, stage.key);
153
- }
154
- }
155
- function validateLibrary(library, source) {
156
- if (!isUint32(library.payloadSize)) {
157
- throw new Error(`library ${library.key} payloadSize must fit uint32`);
158
- }
159
- validateSourceProgram(library.sourceProgram, "library", null, null, source.stringTableByteLength);
160
- if (!Array.isArray(library.exports) || library.exportCount !== library.exports.length || typeof library.hitGroupName !== "string") {
161
- throw new Error(`Portable reflection library ${library.key} is malformed`);
162
- }
163
- const identities = new Set();
164
- for (const [index, entry] of library.exports.entries()) {
165
- requireExactKeys(entry, ["type", "name"], `Portable reflection library ${library.key} export ${index}`);
166
- if (!isUint8(entry.type)) {
167
- throw new Error(`library ${library.key} export ${index} type must fit uint8`);
168
- }
169
- const identity = `${entry.type}:${entry.name}`;
170
- if (entry.type > 4 || typeof entry.name !== "string" || !entry.name || identities.has(identity)) {
171
- throw new Error(`Portable reflection library ${library.key} export ${index} ` + "is malformed or duplicated");
172
- }
173
- identities.add(identity);
174
- }
175
- validateInput(library.globalInput, `${library.key}.globalInput`);
176
- validateInput(library.localInput, `${library.key}.localInput`);
177
- }
178
- function validateSourceProgram(program, expectedKind, stageType, stageName, stringTableByteLength) {
179
- requireExactKeys(program, expectedKind === "stage" ? ["kind", "stageType", "stageName", "shaderSize", "stringTableOffset", "bytes"] : ["kind", "shaderSize", "stringTableOffset", "bytes"], "Portable reflection source program");
180
- if (program.kind !== expectedKind) {
181
- throw new Error("Portable reflection source program kind disagrees");
182
- }
183
- if (expectedKind === "stage" && (program.stageType !== stageType || program.stageName !== stageName)) {
184
- throw new Error("Portable reflection source program stage identity disagrees");
185
- }
186
- if (!isUint32(program.shaderSize)) {
187
- throw new Error("Portable reflection source program shaderSize must fit uint32");
188
- }
189
- if (!(program.bytes instanceof Uint8Array) || !program.bytes.byteLength || program.shaderSize !== program.bytes.byteLength) {
190
- throw new Error("Portable reflection source program bytes are incomplete");
191
- }
192
- if (!isUint32(program.stringTableOffset)) {
193
- throw new Error("Portable reflection source program stringTableOffset must fit uint32");
194
- }
195
- if (program.stringTableOffset + program.shaderSize > stringTableByteLength) {
196
- throw new Error("Portable reflection source program is outside the shared string table");
197
- }
198
- }
199
- function validateInput(input, context) {
200
- requireExactKeys(input, ["constantDefaults", "constantCount", "constants", "resourceCount", "resources", "uavCount", "uavs", "samplerCount", "samplers", "annotationCount", "annotations", "signature"], `Portable reflection ${context} input`);
201
- if (!isPlainObject(input.constantDefaults)) {
202
- throw new Error(`Portable reflection ${context} constant defaults must be an object`);
203
- }
204
- const defaults = input.constantDefaults;
205
- requireExactKeys(defaults, ["declaredByteLength", "bytes"], `Portable reflection ${context} constant defaults`);
206
- if (!isUint32(defaults.declaredByteLength)) {
207
- throw new Error(`Portable reflection ${context} constant-default length must fit uint32`);
208
- }
209
- if (!(defaults.bytes instanceof Uint8Array) || defaults.declaredByteLength !== defaults.bytes.byteLength || defaults.bytes.byteLength > CONSTANT_BYTES_MAX) {
210
- throw new Error(`Portable reflection ${context} constant defaults are invalid`);
211
- }
212
- if (!Array.isArray(input.constants) || !Array.isArray(input.resources) || !Array.isArray(input.uavs) || !Array.isArray(input.samplers) || !Array.isArray(input.annotations) || input.constantCount !== input.constants.length || input.resourceCount !== input.resources.length || input.uavCount !== input.uavs.length || input.samplerCount !== input.samplers.length || input.annotationCount !== input.annotations.length) {
213
- throw new Error(`Portable reflection ${context} input collections are malformed`);
214
- }
215
- const constantNames = new Set();
216
- for (const [index, constant] of input.constants.entries()) {
217
- requireExactKeys(constant, ["name", "offset", "size", "type", "dimension", "elements", "isSRGB", "isAutoregister"], `Portable reflection ${context} constant ${index}`);
218
- if (typeof constant.name !== "string" || !constant.name || constantNames.has(constant.name)) {
219
- throw new Error(`Portable reflection ${context} constant ${index} ` + "is malformed or duplicated");
220
- }
221
- constantNames.add(constant.name);
222
- if (!isUint32(constant.offset)) {
223
- throw new Error(`${context} constant ${constant.name} offset must fit uint32`);
224
- }
225
- if (!isUint32(constant.size)) {
226
- throw new Error(`${context} constant ${constant.name} size must fit uint32`);
227
- }
228
- if (!isUint8(constant.type)) {
229
- throw new Error(`${context} constant ${constant.name} type must fit uint8`);
230
- }
231
- if (!isUint8(constant.dimension)) {
232
- throw new Error(`${context} constant ${constant.name} dimension must fit uint8`);
233
- }
234
- if (!isUint32(constant.elements)) {
235
- throw new Error(`${context} constant ${constant.name} elements must fit uint32`);
236
- }
237
- if (!constant.size || constant.type > 4 || constant.dimension < 1 || constant.offset + constant.size > CONSTANT_BYTES_MAX || typeof constant.isSRGB !== "boolean" || typeof constant.isAutoregister !== "boolean") {
238
- throw new Error(`Portable reflection ${context} constant ${constant.name} is invalid`);
239
- }
240
- }
241
- validateResourceList(input.resources, `${context} resources`);
242
- validateResourceList(input.uavs, `${context} UAVs`);
243
- validateSamplerList(input.samplers, `${context} samplers`);
244
- validateAnnotations(input.annotations, `${context} annotations`);
245
- validateSignature(input.signature, context);
246
- validateMapSignatureReconciliation(input, context);
247
- }
248
- function validateResourceList(entries, context) {
249
- validateRegisterIndexed(entries, "registerIndex", context, entry => {
250
- requireExactKeys(entry, ["registerIndex", "name", "type", "arrayElements", "isSRGB", "isAutoregister"], `Portable reflection ${context} entry`);
251
- if (!isUint8(entry.registerIndex)) {
252
- throw new Error(`${context} registerIndex must fit uint8`);
253
- }
254
- if (!isUint8(entry.type)) {
255
- throw new Error(`${context} type must fit uint8`);
256
- }
257
- if (!isUint32(entry.arrayElements)) {
258
- throw new Error(`${context} arrayElements must fit uint32`);
259
- }
260
- if (typeof entry.name !== "string" || !entry.name || typeof entry.isSRGB !== "boolean" || typeof entry.isAutoregister !== "boolean") {
261
- throw new Error(`Portable reflection ${context} entry is malformed`);
262
- }
263
- });
264
- }
265
- function validateSamplerList(entries, context) {
266
- validateRegisterIndexed(entries, "registerIndex", context, entry => {
267
- requireExactKeys(entry, ["registerIndex", "name", "isDynamic", "descriptor"], `Portable reflection ${context} entry`);
268
- if (!isUint8(entry.registerIndex)) {
269
- throw new Error(`${context} registerIndex must fit uint8`);
270
- }
271
- if (typeof entry.isDynamic !== "boolean" || entry.isDynamic && typeof entry.name !== "string" || !entry.isDynamic && entry.name !== null) {
272
- throw new Error(`Portable reflection ${context} entry is malformed`);
273
- }
274
- validateSamplerDescriptor(entry.descriptor, context, false);
275
- });
276
- }
277
- function validateSignature(signature, context) {
278
- requireExactKeys(signature, ["pipelineInputCount", "pipelineInputs", "registerCount", "registers", "staticSamplerCount", "staticSamplers", "threadGroupSize"], `Portable reflection ${context} signature`);
279
- if (!Array.isArray(signature.pipelineInputs) || !Array.isArray(signature.registers) || !Array.isArray(signature.staticSamplers) || signature.pipelineInputCount !== signature.pipelineInputs.length || signature.registerCount !== signature.registers.length || signature.staticSamplerCount !== signature.staticSamplers.length) {
280
- throw new Error(`Portable reflection ${context} signature is malformed`);
281
- }
282
- for (const [index, input] of signature.pipelineInputs.entries()) {
283
- requireExactKeys(input, ["usage", "registerIndex", "usageIndex", "usedMask", "type", "dimension"], `Portable reflection ${context} pipeline input ${index}`);
284
- for (const field of ["usage", "registerIndex", "usageIndex", "usedMask", "type", "dimension"]) {
285
- if (!isUint8(input[field])) {
286
- throw new Error(`${context} pipeline input ${index} ${field} must fit uint8`);
287
- }
288
- }
289
- }
290
- const registerRanges = new Map();
291
- for (const [index, register] of signature.registers.entries()) {
292
- requireExactKeys(register, ["registerType", "registerIndex", "arrayCount", "registerCount", "registerSpace"], `Portable reflection ${context} register ${index}`);
293
- if (!isUint8(register.registerType)) {
294
- throw new Error(`${context} register ${index} type must fit uint8`);
295
- }
296
- if (!isUint32(register.registerIndex)) {
297
- throw new Error(`${context} register ${index} index must fit uint32`);
298
- }
299
- if (!isUint32(register.arrayCount)) {
300
- throw new Error(`${context} register ${index} arrayCount must fit uint32`);
301
- }
302
- if (!isUint32(register.registerCount)) {
303
- throw new Error(`${context} register ${index} registerCount must fit uint32`);
304
- }
305
- if (!isUint8(register.registerSpace)) {
306
- throw new Error(`${context} register ${index} space must fit uint8`);
307
- }
308
- const classification = registerClass(register.registerType);
309
- const unbounded = register.arrayCount === 0 && register.registerCount === 0;
310
- const rangeEnd = unbounded ? UINT32_MAX + 1 : register.registerIndex + register.registerCount;
311
- if (register.registerCount !== register.arrayCount || unbounded && classification !== "sampler" && classification !== "resource" && classification !== "uav" || rangeEnd > UINT32_MAX + 1) {
312
- throw new Error(`Portable reflection ${context} register ${index} is malformed`);
313
- }
314
- const rangeKey = `${classification}:${register.registerSpace}`;
315
- const ranges = registerRanges.get(rangeKey) ?? [];
316
- if (ranges.some(([start, end]) => register.registerIndex < end && rangeEnd > start)) {
317
- throw new Error(`Portable reflection ${context} signature register range overlaps`);
318
- }
319
- ranges.push([register.registerIndex, rangeEnd]);
320
- registerRanges.set(rangeKey, ranges);
321
- }
322
- validateRegisterIndexed(signature.staticSamplers, "registerIndex", `${context} static samplers`, entry => {
323
- requireExactKeys(entry, ["registerIndex", "registerSpace", "descriptor"], `Portable reflection ${context} static sampler`);
324
- if (!isUint8(entry.registerSpace)) {
325
- throw new Error(`${context} static sampler space must fit uint8`);
326
- }
327
- validateSamplerDescriptor(entry.descriptor, context, true);
328
- }, entry => `${entry.registerSpace}:${entry.registerIndex}`);
329
- if (!isPlainObject(signature.threadGroupSize)) {
330
- throw new Error(`Portable reflection ${context} threadGroupSize must be an object`);
331
- }
332
- const group = signature.threadGroupSize;
333
- requireExactKeys(group, ["x", "y", "z"], `Portable reflection ${context} threadGroupSize`);
334
- for (const field of ["x", "y", "z"]) {
335
- if (!isUint32(group[field])) {
336
- throw new Error(`${context} threadGroupSize.${field} must fit uint32`);
337
- }
338
- }
339
- }
340
- function validateMapSignatureReconciliation(input, context) {
341
- validateMappedBindings(input.resources, input.signature.registers.filter(entry => registerClass(entry.registerType) === "resource"), `${context} resources`);
342
- validateMappedBindings(input.uavs, input.signature.registers.filter(entry => registerClass(entry.registerType) === "uav"), `${context} UAVs`);
343
- for (const sampler of input.samplers) {
344
- const matches = sampler.isDynamic ? input.signature.registers.filter(entry => registerClass(entry.registerType) === "sampler" && entry.registerIndex === sampler.registerIndex) : input.signature.staticSamplers.filter(entry => entry.registerIndex === sampler.registerIndex);
345
- if (matches.length > 1 || matches.length === 1 && sampler.isDynamic && matches[0].arrayCount !== 0 && matches[0].arrayCount !== 1) {
346
- throw new Error(`Portable reflection ${context} sampler map disagrees with its signature`);
347
- }
348
- }
349
- }
350
- function validateMappedBindings(entries, registers, context) {
351
- for (const entry of entries) {
352
- const matches = registers.filter(register => register.registerIndex === entry.registerIndex);
353
- if (matches.length !== 1 || matches[0].arrayCount !== entry.arrayElements) {
354
- throw new Error(`Portable reflection ${context} map disagrees with its signature`);
355
- }
356
- }
357
- }
358
- function registerClass(registerType) {
359
- if (registerType === 0) return "constantBuffer";
360
- if (registerType === 1) return "sampler";
361
- if (registerType >= 32 && registerType <= 63) return "resource";
362
- if (registerType >= 64 && registerType <= 95) return "uav";
363
- return `raw${registerType}`;
364
- }
365
- function validateSamplerDescriptor(descriptor, context, staticSampler) {
366
- requireExactKeys(descriptor, ["comparison", "minFilter", "magFilter", "mipFilter", "addressU", "addressV", "addressW", "mipLODBiasRaw", "maxAnisotropy", "comparisonFunc", staticSampler ? "borderColor" : "borderColorRaw", "minLODRaw", "maxLODRaw"], `Portable reflection ${context} sampler descriptor`);
367
- if (typeof descriptor.comparison !== "boolean") {
368
- throw new Error(`Portable reflection ${context} sampler comparison is malformed`);
369
- }
370
- for (const field of ["minFilter", "magFilter", "mipFilter", "addressU", "addressV", "addressW", "maxAnisotropy", "comparisonFunc"]) {
371
- if (!isUint8(descriptor[field])) {
372
- throw new Error(`${context} sampler ${field} must fit uint8`);
373
- }
374
- }
375
- for (const field of ["mipLODBiasRaw", "minLODRaw", "maxLODRaw"]) {
376
- if (!isUint32(descriptor[field])) {
377
- throw new Error(`${context} sampler ${field} must fit uint32`);
378
- }
379
- }
380
- if (staticSampler) {
381
- if (!isUint8(descriptor.borderColor)) {
382
- throw new Error(`${context} static sampler borderColor must fit uint8`);
383
- }
384
- } else if (!Array.isArray(descriptor.borderColorRaw) || descriptor.borderColorRaw.length !== 4) {
385
- throw new Error(`Portable reflection ${context} sampler borderColorRaw is malformed`);
386
- } else {
387
- for (const [index, value] of descriptor.borderColorRaw.entries()) {
388
- if (!isUint32(value)) {
389
- throw new Error(`${context} sampler borderColorRaw[${index}] must fit uint32`);
390
- }
391
- }
392
- }
393
- }
394
- function validateAnnotationGroups(groups, context) {
395
- const names = new Set();
396
- for (const [index, group] of groups.entries()) {
397
- requireExactKeys(group, ["parameterName", "annotations"], `Portable reflection ${context} group ${index}`);
398
- if (typeof group.parameterName !== "string" || names.has(group.parameterName) || !Array.isArray(group.annotations)) {
399
- throw new Error(`Portable reflection ${context} group ${index} ` + "is malformed or duplicated");
400
- }
401
- names.add(group.parameterName);
402
- validateAnnotations(group.annotations, `${context} ${group.parameterName}`);
403
- }
404
- }
405
- function validateAnnotations(annotations, context) {
406
- for (const [index, annotation] of annotations.entries()) {
407
- requireExactKeys(annotation, annotation?.type === 3 ? ["name", "type", "stringValue"] : ["name", "type", "rawValue"], `Portable reflection ${context} annotation ${index}`);
408
- if (typeof annotation.name !== "string" || !annotation.name) {
409
- throw new Error(`Portable reflection ${context} annotation ${index} is malformed`);
410
- }
411
- if (!isUint8(annotation.type)) {
412
- throw new Error(`${context} annotation ${index} type must fit uint8`);
413
- }
414
- if (annotation.type === 3) {
415
- if (typeof annotation.stringValue !== "string") {
416
- throw new Error(`Portable reflection ${context} string annotation is malformed`);
417
- }
418
- } else if (annotation.type <= 2) {
419
- if (!isUint32(annotation.rawValue)) {
420
- throw new Error(`${context} annotation ${index} rawValue must fit uint32`);
421
- }
422
- } else {
423
- throw new Error(`Portable reflection ${context} annotation type is unsupported`);
424
- }
425
- }
426
- }
427
- function validateRegisterIndexed(entries, field, context, validate, identityFor = null) {
428
- const identities = new Set();
429
- for (const [index, entry] of entries.entries()) {
430
- if (!isPlainObject(entry)) {
431
- throw new Error(`Portable reflection ${context} entry ${index} must be an object`);
432
- }
433
- if (!isUint32(entry[field])) {
434
- throw new Error(`${context} entry ${index} ${field} must fit uint32`);
435
- }
436
- const identity = identityFor ? identityFor(entry) : entry[field];
437
- if (identities.has(identity)) {
438
- throw new Error(`Portable reflection ${context} entry ${index} is duplicated`);
439
- }
440
- identities.add(identity);
441
- validate(entry);
442
- }
443
- }
444
- function requireKey(value, expected, context, keys) {
445
- if (value !== expected || keys.has(value)) {
446
- throw new Error(`Portable reflection ${context} key is malformed or duplicated`);
447
- }
448
- keys.add(value);
449
- }
450
- function requireExactKeys(value, allowed, context) {
451
- if (!isPlainObject(value)) {
452
- throw new Error(`${context} must be an object`);
453
- }
454
- const actual = Reflect.ownKeys(value);
455
- if (actual.length !== allowed.length || actual.some(key => typeof key !== "string" || !allowed.includes(key))) {
456
- throw new Error(`${context} has unsupported or missing fields`);
457
- }
458
- }
459
-
460
- export { isPortableEffectReflection, validatePortableEffectInput, validatePortableEffectReflection };
461
- //# sourceMappingURL=portableValidation.js.map