@carbonenginejs/runtime-resource 0.11.1 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/dist/CjsResMan.js +4 -4
  2. package/dist/CjsResMan.js.map +1 -1
  3. package/dist/_virtual/_rollupPluginBabelHelpers.js +1 -4
  4. package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
  5. package/dist/format/CjsByteReader.js +310 -0
  6. package/dist/format/CjsByteReader.js.map +1 -0
  7. package/dist/format/CjsByteWriter.js +242 -0
  8. package/dist/format/CjsByteWriter.js.map +1 -0
  9. package/dist/format/CjsFormatError.js +41 -0
  10. package/dist/format/CjsFormatError.js.map +1 -0
  11. package/dist/format/CjsStringTable.js +268 -0
  12. package/dist/format/CjsStringTable.js.map +1 -0
  13. package/dist/format/carbonEffect/CjsCarbonEffectReader.js +361 -0
  14. package/dist/format/carbonEffect/CjsCarbonEffectReader.js.map +1 -0
  15. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js +373 -0
  16. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -0
  17. package/dist/format/carbonEffect/carbonDescriptionFromPortable.js +372 -0
  18. package/dist/format/carbonEffect/carbonDescriptionFromPortable.js.map +1 -0
  19. package/dist/format/carbonEffect/carbonEffectBackendBlock.js +427 -0
  20. package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -0
  21. package/dist/format/carbonEffect/carbonEffectRecords.js +955 -0
  22. package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -0
  23. package/dist/format/compareUtf8.js +36 -0
  24. package/dist/format/compareUtf8.js.map +1 -0
  25. package/dist/format/index.js +11 -0
  26. package/dist/format/index.js.map +1 -0
  27. package/dist/formats/bnk/CjsBnkFormat.js +18 -2
  28. package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
  29. package/dist/formats/bnk/core/eventAction.js +305 -0
  30. package/dist/formats/bnk/core/eventAction.js.map +1 -0
  31. package/dist/formats/bnk/core/graph.js +3 -6
  32. package/dist/formats/bnk/core/graph.js.map +1 -1
  33. package/dist/formats/bnk/core/helpers.js +62 -11
  34. package/dist/formats/bnk/core/helpers.js.map +1 -1
  35. package/dist/formats/bnk/core/nodeBase.js +532 -0
  36. package/dist/formats/bnk/core/nodeBase.js.map +1 -0
  37. package/dist/formats/bnk/core/sfxNodes.js +632 -0
  38. package/dist/formats/bnk/core/sfxNodes.js.map +1 -0
  39. package/dist/formats/bnk/core/soundbanksInfo.js +59 -51
  40. package/dist/formats/bnk/core/soundbanksInfo.js.map +1 -1
  41. package/dist/formats/gr2/CjsGr2Format.js +256 -13
  42. package/dist/formats/gr2/CjsGr2Format.js.map +1 -1
  43. package/dist/formats/gr2/core/helpers.js +15 -15
  44. package/dist/formats/gr2/core/helpers.js.map +1 -1
  45. package/dist/formats/gr2/core/json.js +1 -1
  46. package/dist/formats/gr2/core/json.js.map +1 -1
  47. package/dist/formats/gr2/core/targets.js +1 -1
  48. package/dist/formats/gr2/core/targets.js.map +1 -1
  49. package/dist/formats/gr2/index.js +0 -1
  50. package/dist/formats/gr2/index.js.map +1 -1
  51. package/dist/formats/hlsl/core/HlslReader.js +7 -257
  52. package/dist/formats/hlsl/core/HlslReader.js.map +1 -1
  53. package/dist/formats/hlsl/core/analysis.js +1 -1
  54. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +781 -0
  55. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -0
  56. package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +21 -1
  57. package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -1
  58. package/dist/formats/hlsl/index.js +1 -0
  59. package/dist/formats/hlsl/index.js.map +1 -1
  60. package/dist/formats/index.js +3 -6
  61. package/dist/formats/index.js.map +1 -1
  62. package/dist/formats/webgl/core/cewg/CewgPackage.js +2 -1
  63. package/dist/formats/webgl/core/cewg/CewgPackage.js.map +1 -1
  64. package/dist/formats/webgl/core/cewg/binary.js +11 -93
  65. package/dist/formats/webgl/core/cewg/binary.js.map +1 -1
  66. package/dist/formats/webgl/core/effectPackage.js +4 -1
  67. package/dist/formats/webgl/core/effectPackage.js.map +1 -1
  68. package/dist/formats/webgl/core/errors.js +3 -3
  69. package/dist/formats/webgl/core/errors.js.map +1 -1
  70. package/dist/formats/webgpu/CjsWebgpuFormat.js +4 -23
  71. package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
  72. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +197 -0
  73. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -0
  74. package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js +368 -0
  75. package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js.map +1 -0
  76. package/dist/formats/webgpu/core/cewgpu/containerViews.js +355 -0
  77. package/dist/formats/webgpu/core/cewgpu/containerViews.js.map +1 -0
  78. package/dist/formats/webgpu/core/cewgpu/validateContainer.js +90 -0
  79. package/dist/formats/webgpu/core/cewgpu/validateContainer.js.map +1 -0
  80. package/dist/formats/webgpu/core/effectBackendBodySet.js +21 -20
  81. package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
  82. package/dist/formats/webgpu/core/helpers.js +87 -92
  83. package/dist/formats/webgpu/core/helpers.js.map +1 -1
  84. package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +14 -13
  85. package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js.map +1 -1
  86. package/dist/formats/webgpu/core/ir/inferValueTypes.js +10 -8
  87. package/dist/formats/webgpu/core/ir/inferValueTypes.js.map +1 -1
  88. package/dist/formats/webgpu/core/packageEffect.js +94 -9
  89. package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
  90. package/dist/formats/webgpu/core/packageMetadata.js +10 -1
  91. package/dist/formats/webgpu/core/packageMetadata.js.map +1 -1
  92. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +17 -15
  93. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
  94. package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +13 -12
  95. package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js.map +1 -1
  96. package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +9 -8
  97. package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -1
  98. package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +23 -22
  99. package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js.map +1 -1
  100. package/dist/formats/webgpu/core/wgsl/selectionPlans.js +46 -44
  101. package/dist/formats/webgpu/core/wgsl/selectionPlans.js.map +1 -1
  102. package/dist/resource/CjsResource.js +700 -684
  103. package/dist/resource/CjsResource.js.map +1 -1
  104. package/dist/resource/Tr2LightProfileRes.js +18 -27
  105. package/dist/resource/Tr2LightProfileRes.js.map +1 -1
  106. package/dist/resource/audio/CjsAudioBufferRes.js +2 -2
  107. package/dist/resource/audio/CjsAudioBufferRes.js.map +1 -1
  108. package/dist/resource/audio/CjsAudioRes.js +2 -2
  109. package/dist/resource/audio/CjsAudioRes.js.map +1 -1
  110. package/dist/resource/geometry/TriGeometryRes.js +605 -586
  111. package/dist/resource/geometry/TriGeometryRes.js.map +1 -1
  112. package/dist/resource/geometry/granny/Tr2GrannyStateRes.js +21 -30
  113. package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -1
  114. package/dist/resource/geometry/granny/TriGrannyRes.js +21 -30
  115. package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -1
  116. package/dist/resource/shader/Tr2EffectRes.js +9 -7
  117. package/dist/resource/shader/Tr2EffectRes.js.map +1 -1
  118. package/dist/resource/shader/Tr2MaterialArea.js +5 -3
  119. package/dist/resource/shader/Tr2MaterialArea.js.map +1 -1
  120. package/dist/resource/shader/Tr2MaterialMesh.js +4 -2
  121. package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -1
  122. package/dist/resource/shader/Tr2MaterialRes.js +5 -3
  123. package/dist/resource/shader/Tr2MaterialRes.js.map +1 -1
  124. package/dist/resource/shader/Tr2Shader.js +26 -21
  125. package/dist/resource/shader/Tr2Shader.js.map +1 -1
  126. package/dist/resource/shader/Tr2ShaderPermutation.js +8 -6
  127. package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -1
  128. package/dist/resource/shader/reflection/Tr2EffectDefine.js +5 -3
  129. package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -1
  130. package/dist/resource/shader/reflection/Tr2EffectDescription.js +5 -3
  131. package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -1
  132. package/dist/resource/shader/reflection/Tr2EffectLibrary.js +17 -15
  133. package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -1
  134. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +11 -9
  135. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
  136. package/dist/resource/shader/reflection/Tr2EffectResource.js +8 -6
  137. package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
  138. package/dist/resource/shader/reflection/Tr2EffectStageInput.js +15 -13
  139. package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
  140. package/dist/resource/shader/reflection/Tr2EffectTechnique.js +7 -5
  141. package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -1
  142. package/dist/resource/shader/reflection/Tr2Pass.js +11 -9
  143. package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
  144. package/dist/resource/shader/sampler/Tr2SamplerSetup.js +8 -6
  145. package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -1
  146. package/dist/resource/texture/CjsTextureArrayRes.js +400 -411
  147. package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -1
  148. package/dist/resource/texture/Tr2ImageRes.js +99 -95
  149. package/dist/resource/texture/Tr2ImageRes.js.map +1 -1
  150. package/dist/resource/texture/TriTextureRes.js +312 -273
  151. package/dist/resource/texture/TriTextureRes.js.map +1 -1
  152. package/docs/README.md +13 -1
  153. package/docs/architecture.md +3 -3
  154. package/docs/concepts/resource-lifecycle.md +9 -2
  155. package/docs/concepts/shader-resource-model.md +114 -0
  156. package/docs/concepts/writing-an-engine-adapter.md +115 -0
  157. package/docs/formats/README.md +24 -1
  158. package/docs/formats/carbon-effect-container.md +452 -0
  159. package/docs/formats/dxbc/README.md +68 -0
  160. package/docs/formats/dxbc/architecture.md +80 -0
  161. package/docs/formats/dxbc/reference/api.md +77 -0
  162. package/docs/formats/dxbc/reference/classes/README.md +9 -0
  163. package/docs/formats/dxbc/reference/decoded-output.md +122 -0
  164. package/docs/formats/gr2.md +3 -4
  165. package/docs/formats/hlsl/README.md +54 -0
  166. package/docs/formats/hlsl/architecture.md +67 -0
  167. package/docs/formats/hlsl/guides/hydrating-json-output.md +62 -0
  168. package/docs/formats/hlsl/guides/reading-effects.md +64 -0
  169. package/docs/formats/hlsl/reference/advanced-analysis.md +66 -0
  170. package/docs/formats/hlsl/reference/api.md +98 -0
  171. package/docs/formats/hlsl/reference/classes/README.md +11 -0
  172. package/docs/formats/hlsl/reference/json-graph.md +100 -0
  173. package/docs/formats/hlsl/reference/portable-reflection.md +141 -0
  174. package/docs/formats/provenance.md +32 -17
  175. package/docs/formats/webgl/README.md +57 -0
  176. package/docs/formats/webgl/architecture.md +70 -0
  177. package/docs/formats/webgl/carbon-constant-layouts.md +326 -0
  178. package/docs/formats/webgl/decl-io.md +1234 -0
  179. package/docs/formats/webgl/effect-reflection.md +127 -0
  180. package/docs/formats/webgl/memory-structured.md +871 -0
  181. package/docs/formats/webgl/reference/classes/README.md +9 -0
  182. package/docs/formats/webgl/texture-sample.md +964 -0
  183. package/docs/formats/webgpu/README.md +84 -0
  184. package/docs/formats/webgpu/architecture.md +96 -0
  185. package/docs/formats/webgpu/formats/cewgpu.md +216 -0
  186. package/docs/formats/webgpu/guides/effect-packaging.md +191 -0
  187. package/docs/formats/webgpu/reference/api.md +197 -0
  188. package/docs/formats/webgpu/reference/classes/README.md +9 -0
  189. package/docs/formats/webgpu/reference/wgsl-compatibility.md +1543 -0
  190. package/docs/formats/wwise.md +45 -4
  191. package/docs/reference/classes/core.md +80 -0
  192. package/docs/reference/classes/formats.md +24 -34
  193. package/docs/reference/events.md +25 -0
  194. package/docs/reference/motherlode-cache.md +22 -8
  195. package/docs/reference/workers.md +5 -5
  196. package/docs/roadmap.md +61 -41
  197. package/format-notices/bnk/NOTICE +5 -4
  198. package/format-notices/webgl/NOTICE +1 -1
  199. package/package.json +2 -1
  200. package/dist/formats/gr2/core/CjsFormatGr2.js +0 -273
  201. package/dist/formats/gr2/core/CjsFormatGr2.js.map +0 -1
  202. package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js +0 -415
  203. package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js.map +0 -1
  204. package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js +0 -100
  205. package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js.map +0 -1
  206. package/dist/formats/webgpu/core/cewgpu/binary.js +0 -93
  207. package/dist/formats/webgpu/core/cewgpu/binary.js.map +0 -1
  208. package/dist/formats/webgpu/core/cewgpu/tags.js +0 -17
  209. package/dist/formats/webgpu/core/cewgpu/tags.js.map +0 -1
  210. package/dist/formats/webgpu/core/effectPackageValidation.js +0 -1078
  211. package/dist/formats/webgpu/core/effectPackageValidation.js.map +0 -1
@@ -0,0 +1,9 @@
1
+ # DXBC class catalog
2
+
3
+ Status: Deprecated
4
+ Scope: `@carbonenginejs/runtime-resource/formats/dxbc` maintained classes
5
+ Audience: Users, maintainers, and automated readers
6
+ Summary: Points to the canonical package-wide class catalog after format-package consolidation.
7
+
8
+ The maintained DXBC entries now live in the
9
+ [package-wide formats class catalog](../../../../reference/classes/formats.md#dxbc).
@@ -0,0 +1,122 @@
1
+ # Decoded output contract
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-resource/formats/dxbc` JSON output
5
+ Audience: Shader-tool authors and lowering-backend authors
6
+ Summary: Defines the stable top-level JSON fields and the decoder records consumed by shader-lowering packages.
7
+
8
+ ## Top-level result
9
+
10
+ `CjsDxbcFormat.read(bytes)` returns:
11
+
12
+ | Field | Meaning |
13
+ | --- | --- |
14
+ | `source` | Caller-provided diagnostic label. |
15
+ | `container` | Container version, declared size, and chunk summaries. |
16
+ | `program` | Shader stage, shader model, chunk tag, and token count, or `null`. |
17
+ | `inputSignature` | Input signature elements, or `null`. |
18
+ | `outputSignature` | Output signature elements, or `null`. |
19
+ | `patchSignature` | Patch-constant signature elements, or `null`. |
20
+ | `instructions` | Decoded instruction records, or `null` when disabled or absent. |
21
+
22
+ `Inspect` returns a smaller record containing the container/chunk summary,
23
+ stage name, shader model, and input/output element counts.
24
+
25
+ ## Container records
26
+
27
+ The container summary includes `version`, `totalSize`, and ordered `chunks`.
28
+ Each chunk record includes its four-character code, byte offset, and payload
29
+ size. JSON output omits raw chunk bytes.
30
+
31
+ ## Program records
32
+
33
+ Program metadata includes:
34
+
35
+ - `fourCC`: `SHEX` or `SHDR`;
36
+ - numeric and named program type;
37
+ - major and minor shader-model version; and
38
+ - declared program length in 32-bit words.
39
+
40
+ Recognized program names are pixel, vertex, geometry, hull, domain, and
41
+ compute. An unknown numeric type remains observable as `"unknown"`.
42
+
43
+ ## Signature elements
44
+
45
+ Each signature element records its semantic name/index, system-value and
46
+ component types, register index, masks, stream, and minimum-precision value
47
+ when that signature layout provides one.
48
+
49
+ The reader supports the SM4 and SM5 signature chunk layouts used by `ISGN`,
50
+ `ISG1`, `OSGN`, `OSG1`, `OSG5`, `PCSG`, and `PSG1`.
51
+
52
+ ## Instruction records
53
+
54
+ Each instruction begins with its source token offset, opcode number/name,
55
+ declared length, and decoded control bits. Depending on the opcode, the record
56
+ may also include:
57
+
58
+ - destination and source operands with component selection and index records;
59
+ - opcode and operand extensions;
60
+ - declaration-specific fields;
61
+ - resource dimensions and return types;
62
+ - sampler, interpolation, precision, topology, or system-value metadata;
63
+ - custom-data payloads; and
64
+ - unprojected declaration words in `tailTokens`.
65
+
66
+ Executable instructions reject leftover or missing operand words. Declaration
67
+ records may preserve unfamiliar trailing payload words when their instruction
68
+ framing is valid.
69
+
70
+ ### Compute shared memory and synchronization
71
+
72
+ Compute thread-group shared-memory declarations expose their register and
73
+ complete allocation shape:
74
+
75
+ | Declaration | Fields |
76
+ | --- | --- |
77
+ | `dcl_thread_group_shared_memory_raw` | `registerIndex`, `byteCount` |
78
+ | `dcl_thread_group_shared_memory_structured` | `registerIndex`, `structureStride`, `structureCount` |
79
+
80
+ The declaration operand must identify one immediate thread-group shared-memory
81
+ register. Byte counts and structure strides are positive and DWORD-aligned;
82
+ structured element counts are positive. Any additional well-framed declaration
83
+ words remain observable through `tailTokens`.
84
+
85
+ The `sync` instruction exposes its numeric `syncFlags` mask and a canonical
86
+ bit-order `syncFlagNames` array. The recognized names are
87
+ `threads_in_group`, `thread_group_shared_memory`,
88
+ `thread_group_uav_memory`, and `global_uav_memory`. These control bits are
89
+ separate from arithmetic result controls, so `sync` never reports saturation.
90
+ Unknown bits remain set in the numeric eight-bit mask even though they have no
91
+ entry in the recognized-name array. Reserved operand and opcode-control bits
92
+ are rejected rather than projected onto the canonical records.
93
+
94
+ ## Shader Model 5.1 bindings
95
+
96
+ SM5.1 resource declarations may include `bindingRange`:
97
+
98
+ | Field | Meaning |
99
+ | --- | --- |
100
+ | `rangeId` | Class-local binding-range identity. |
101
+ | `lowerBound` / `upperBound` | Declared register bounds. |
102
+ | `unbounded` | Whether the upper bound represents an unbounded range. |
103
+ | `registerCount` | Finite range size, otherwise `null`. |
104
+ | `registerSpace` | D3D register space. |
105
+
106
+ Executable resource, sampler, UAV, and constant-buffer operands may include a
107
+ `resourceReference` retaining the range identity, index records, and
108
+ non-uniform flag. Range identity remains separate from the actual register
109
+ index needed by an explicit-binding backend.
110
+
111
+ SM5.0 declarations keep their direct-register shape.
112
+
113
+ ## JSON conversion
114
+
115
+ Typed arrays become number arrays, arrays are converted recursively, maps
116
+ become plain objects, sets become arrays, and objects with `toJSON` use that
117
+ projection.
118
+
119
+ ## Related documentation
120
+
121
+ - [Public API reference](api.md)
122
+ - [Architecture and boundaries](../architecture.md)
@@ -32,10 +32,9 @@ const summary = CjsGr2Format.inspect(bytes);
32
32
  const asynchronousGraph = await CjsGr2Format.readAsync(bytes);
33
33
  ```
34
34
 
35
- The wrapper exposes the normal runtime-resource format metadata and
36
- `isSupported(bytes)` magic probe. It also exports the migrated
37
- `CjsFormatGr2` reader engine for compatibility, but new consumers should use
38
- `CjsGr2Format`.
35
+ `CjsGr2Format` is the one public class: the reader engine plus the normal
36
+ runtime-resource format metadata and the `isSupported(bytes)` magic probe.
37
+ The barrel exports nothing else.
39
38
 
40
39
  Register it with `CjsResMan` when GR2/GSF should participate in ordinary
41
40
  resource loading:
@@ -0,0 +1,54 @@
1
+ # Package documentation
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-resource/formats/hlsl`
5
+ Audience: Users and integrators
6
+ Summary: Documentation home for the compiled Carbon/Trinity effect-container reader.
7
+
8
+ ## Purpose
9
+
10
+ `@carbonenginejs/runtime-resource/formats/hlsl` reads versions 8 through 15 of the compiled
11
+ effect container used by Carbon/Trinity. It resolves a permutation and exposes
12
+ techniques, passes, stage metadata, render states, signatures, and opaque
13
+ shader bytecode as JavaScript data.
14
+
15
+ ```js
16
+ import CjsHlslFormat from "@carbonenginejs/runtime-resource/formats/hlsl";
17
+
18
+ const metadata = CjsHlslFormat.read(bytes, {
19
+ emit: "metadata"
20
+ });
21
+ ```
22
+
23
+ ## Where it fits
24
+
25
+ - Use this package for the effect container and its metadata.
26
+ - Use `@carbonenginejs/runtime-resource/formats/dxbc` to decode supported embedded Direct3D
27
+ shader bytecode.
28
+ - Translation backends such as `@carbonenginejs/runtime-resource/formats/webgpu` can consume
29
+ the metadata and bytecode through their own integration layers.
30
+ - `@carbonenginejs/runtime-resource` consumes packaged portable reflection and
31
+ owns canonical `Tr2EffectRes`/`Tr2Shader` hydration, selection, and caching.
32
+ - `@carbonenginejs/runtime-trinity` consumes that shader graph through its
33
+ mutable effect/material facade, parameters, options, and sampler overrides.
34
+
35
+ The package does not compile HLSL source, translate shader instructions,
36
+ construct canonical runtime model instances, or provide a rendering runtime.
37
+
38
+ ## Start here
39
+
40
+ - [Architecture](architecture.md)
41
+ - [Reading effects](guides/reading-effects.md)
42
+ - [Hydrating JSON output](guides/hydrating-json-output.md)
43
+ - [API reference](reference/api.md)
44
+ - [Advanced analysis exports](reference/advanced-analysis.md)
45
+ - [JSON graph reference](reference/json-graph.md)
46
+ - [Portable body reflection](reference/portable-reflection.md)
47
+ - [Class catalog](reference/classes/README.md)
48
+
49
+ ## Compatibility
50
+
51
+ Supported input types are `.sm_hi`, `.sm_lo`, and `.sm_depth` compiled effect
52
+ bodies. Unsupported headers, invalid offsets, truncated data, and invalid
53
+ permutation selections fail with an error rather than returning a partial
54
+ success value.
@@ -0,0 +1,67 @@
1
+ # Architecture
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-resource/formats/hlsl` implementation boundaries
5
+ Audience: Integrators and maintainers
6
+ Summary: Explains the package boundary, parsing flow, output modes, and platform adapters.
7
+
8
+ ## Ownership boundary
9
+
10
+ The package owns the compiled Carbon/Trinity effect-container boundary:
11
+ headers, string tables, permutation selection, effect descriptions,
12
+ techniques, passes, render states, stage metadata, signatures, and the
13
+ packaging of opaque shader bytecode.
14
+
15
+ It does not decode shader instructions, compile source code, or own runtime
16
+ resource binding. Those responsibilities remain with bytecode-format,
17
+ translation, and runtime packages.
18
+
19
+ ## Read flow
20
+
21
+ ```text
22
+ caller bytes
23
+ -> input and option normalization
24
+ -> effect header, strings, and permutation axes
25
+ -> selected compiled body
26
+ -> techniques, passes, and stage metadata
27
+ -> json | metadata | raw output
28
+ ```
29
+
30
+ `src/CjsHlslFormat.js` is the supported reader boundary. Binary utilities and
31
+ format-shaped compatibility models live below `src/core` and `src/carbon`.
32
+ Their same-named `Tr2*` classes are internal parser DTOs, not canonical runtime
33
+ model identity, and are not independent package entry points.
34
+
35
+ ## Output modes
36
+
37
+ - `json` is the default interoperable data graph and may include opaque
38
+ bytecode and constant-value bytes.
39
+ - `metadata` is a compact, bytecode-free graph for inspection and pipeline
40
+ planning.
41
+ - `raw` exposes internal effect-model instances for advanced tooling and is
42
+ not a stable schema.
43
+ - `@carbonenginejs/runtime-resource/formats/hlsl/portable` copies one exact body into a versioned,
44
+ runtime-neutral source-reflection contract. Authored defaults and programs stay
45
+ separate from mutable renderer realization.
46
+
47
+ `runtime-resource` owns canonical `Tr2EffectRes`/`Tr2Shader` hydration,
48
+ permutation selection, and caching. `runtime-trinity` owns the mutable
49
+ effect/material facade, parameters, authored options, and sampler overrides.
50
+ Engines own GPU realization.
51
+
52
+ The graph shapes are documented in
53
+ [reference/json-graph.md](reference/json-graph.md).
54
+
55
+ ## Platform boundary
56
+
57
+ `read`, `inspect`, and `toJSON` operate on caller-provided bytes and work
58
+ without filesystem access. `readFile` and the CLI are Node-specific adapters.
59
+ The package has no runtime dependencies.
60
+
61
+ ## Error boundary
62
+
63
+ Structural failures include the source label and read context where available.
64
+ The reader rejects unsupported versions and unsafe reads instead of silently
65
+ guessing a layout. A selected compiled body can record its own decode failure
66
+ in raw or JSON-oriented inspection data where the format model supports that
67
+ state.
@@ -0,0 +1,62 @@
1
+ # Hydrating JSON output
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-resource/formats/hlsl` JSON node hydration
5
+ Audience: Advanced users and integrators
6
+ Summary: Explains how callers can replace selected plain JSON nodes with their own constructors.
7
+
8
+ ## Register constructors
9
+
10
+ The default `json` output uses plain objects. The `classes` option can
11
+ instantiate selected node kinds with caller-provided constructors:
12
+
13
+ ```js
14
+ import CjsHlslFormat from "@carbonenginejs/runtime-resource/formats/hlsl";
15
+
16
+ const effect = CjsHlslFormat.read(bytes, {
17
+ classes: {
18
+ Technique: MyTechnique,
19
+ StageInput: MyStageInput
20
+ }
21
+ });
22
+ ```
23
+
24
+ Supported keys are exposed as `CjsHlslFormat.CLASS_KEYS`:
25
+
26
+ ```text
27
+ Root
28
+ Permutation
29
+ EffectDescription
30
+ Technique
31
+ Pass
32
+ StageInput
33
+ Constant
34
+ Resource
35
+ Sampler
36
+ ShaderBytecode
37
+ ```
38
+
39
+ ## Reuse a profile
40
+
41
+ ```js
42
+ const reader = new CjsHlslFormat();
43
+
44
+ reader.SetClass("Technique", MyTechnique);
45
+ reader.SetClasses({ StageInput: MyStageInput });
46
+
47
+ reader.HasClass("Technique");
48
+ reader.GetClass("Technique");
49
+
50
+ const effect = reader.Read(bytes);
51
+ ```
52
+
53
+ Hydration changes object prototypes, not the documented field shape. Nested
54
+ records without a class key remain plain JSON-compatible data. Depending on
55
+ the caller's constructors as a serialization schema is discouraged; persist
56
+ the documented graph fields instead.
57
+
58
+ This feature is caller-selected JSON projection only. It does not consume the
59
+ versioned portable-reflection contract and does not construct canonical
60
+ runtime `Tr2EffectRes` or `Tr2Shader` instances. Canonical
61
+ `CJS_EFFECT_BODY_REFLECTION` hydration belongs to
62
+ `@carbonenginejs/runtime-resource`.
@@ -0,0 +1,64 @@
1
+ # Reading effects
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-resource/formats/hlsl` read workflows
5
+ Audience: Users and integrators
6
+ Summary: Shows browser-neutral byte reads, permutation selection, inspection, and Node file workflows.
7
+
8
+ ## Read caller-provided bytes
9
+
10
+ ```js
11
+ import CjsHlslFormat from "@carbonenginejs/runtime-resource/formats/hlsl";
12
+
13
+ const response = await fetch("/shaders/effect.sm_hi");
14
+ const bytes = new Uint8Array(await response.arrayBuffer());
15
+ const effect = CjsHlslFormat.read(bytes);
16
+ ```
17
+
18
+ Use `inspect` when only header and technique summary information is needed:
19
+
20
+ ```js
21
+ const summary = CjsHlslFormat.inspect(bytes, {
22
+ source: "effect.sm_hi"
23
+ });
24
+ ```
25
+
26
+ ## Select a permutation
27
+
28
+ Without a `permutation` option, the reader applies the container's default
29
+ selection rules. Override individual axes by name and value:
30
+
31
+ ```js
32
+ const effect = CjsHlslFormat.read(bytes, {
33
+ permutation: [
34
+ { name: "BLEND_MODE", value: "TRANSPARENT" }
35
+ ]
36
+ });
37
+ ```
38
+
39
+ A `Map` of names to values is also accepted. Unknown axes or invalid values
40
+ are rejected rather than silently ignored.
41
+
42
+ ## Read compact metadata
43
+
44
+ ```js
45
+ const metadata = CjsHlslFormat.read(bytes, {
46
+ emit: CjsHlslFormat.OUTPUT_METADATA
47
+ });
48
+ ```
49
+
50
+ Metadata output omits embedded bytecode and constant-value bytes. It retains
51
+ the selected options, techniques, passes, stage resources, signatures, and
52
+ render-state records needed for inspection and pipeline planning.
53
+
54
+ ## Read a file in Node
55
+
56
+ ```js
57
+ const effect = await CjsHlslFormat.readFile("effect.sm_hi");
58
+ ```
59
+
60
+ The CLI provides the same metadata workflow:
61
+
62
+ ```sh
63
+ format-hlsl metadata effect.sm_hi effect.json
64
+ ```
@@ -0,0 +1,66 @@
1
+ # Advanced analysis exports
2
+
3
+ Status: Experimental
4
+ Scope: `@carbonenginejs/runtime-resource/formats/hlsl` advanced named exports
5
+ Audience: Translation-tool authors and maintainers
6
+ Summary: Documents unstable helpers for raw graph analysis and binding-manifest construction.
7
+
8
+ ## Stability
9
+
10
+ These exports support translation and inspection tooling that needs internal
11
+ effect-model objects. Their shapes may change without a major version bump.
12
+ Use `CjsHlslFormat.read(..., { emit: "json" })` or `"metadata"` for the
13
+ supported data contracts.
14
+
15
+ ## `readEffectAnalysis`
16
+
17
+ ```js
18
+ import { readEffectAnalysis } from "@carbonenginejs/runtime-resource/formats/hlsl";
19
+
20
+ const analysis = readEffectAnalysis(bytes, {
21
+ source: "effect.sm_hi",
22
+ permutation: [
23
+ { name: "BLEND_MODE", value: "TRANSPARENT" }
24
+ ]
25
+ });
26
+ ```
27
+
28
+ The result contains the loaded effect resource, resolved shader, selected
29
+ option and body-index data, effect description, and a binding manifest when
30
+ an effect description is available.
31
+
32
+ The returned internal parser-DTO effect resource also has
33
+ `GetShaderByIndex(index)`. It decodes one exact permutation-table slot without
34
+ applying global or local option overrides; it is distinct from the canonical
35
+ runtime-resource method that hydrates and caches `Tr2Shader`. Use the versioned
36
+ portable subpath when the result must cross a package or serialization
37
+ boundary. Its `enumerateUniqueEffectBodies(effectRes)` helper inventories
38
+ first-seen raw body identities without populating the parser's mutable shader
39
+ cache.
40
+
41
+ ## `Tr2EffectBindingManifest`
42
+
43
+ `Tr2EffectBindingManifest` is an exported advanced class that derives
44
+ register-named constant, resource, sampler, and UAV bindings from an internal
45
+ effect description.
46
+
47
+ ```js
48
+ import {
49
+ readEffectAnalysis,
50
+ Tr2EffectBindingManifest
51
+ } from "@carbonenginejs/runtime-resource/formats/hlsl";
52
+
53
+ const analysis = readEffectAnalysis(bytes);
54
+ analysis.bindingManifest instanceof Tr2EffectBindingManifest;
55
+ ```
56
+
57
+ ## Render-context helpers
58
+
59
+ `Tr2RenderContextEnum` contains the format's stage and render-context numeric
60
+ constants. `tr2ShaderStageName(value)` maps a known stage value to its
61
+ readable name. Both are advanced compatibility helpers rather than a stable
62
+ cross-package enumeration contract.
63
+
64
+ ## Related documentation
65
+
66
+ - [Portable body reflection](portable-reflection.md)
@@ -0,0 +1,98 @@
1
+ # API reference
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-resource/formats/hlsl` supported reader API
5
+ Audience: Users and integrators
6
+ Summary: Documents the reader class, options, output modes, and Node adapters.
7
+
8
+ ## Imports
9
+
10
+ The package root exports `CjsHlslFormat` as both the default and a named
11
+ export:
12
+
13
+ ```js
14
+ import CjsHlslFormat from "@carbonenginejs/runtime-resource/formats/hlsl";
15
+ import { CjsHlslFormat as NamedReader } from "@carbonenginejs/runtime-resource/formats/hlsl";
16
+ ```
17
+
18
+ Additional named exports intended for advanced tooling are documented
19
+ separately in [advanced-analysis.md](advanced-analysis.md).
20
+
21
+ The versioned `@carbonenginejs/runtime-resource/formats/hlsl/portable` subpath exposes exact
22
+ version-15 body-index reflection plus first-seen exact-byte unique-body
23
+ enumeration for backend packagers. See
24
+ [portable-reflection.md](portable-reflection.md).
25
+
26
+ ## Constructor
27
+
28
+ ```js
29
+ const reader = new CjsHlslFormat({
30
+ emit: "json",
31
+ source: "effect.sm_hi",
32
+ permutation: null,
33
+ classes: {}
34
+ });
35
+ ```
36
+
37
+ Options are reusable on an instance and can be overridden per call:
38
+
39
+ - `emit`: `"json"` (default), `"metadata"`, or advanced `"raw"` output.
40
+ - `source`: a caller-supplied label used in diagnostics and output.
41
+ - `permutation`: a `Map` or an array of `{ name, value }` selections.
42
+ - `classes`: constructors used for caller-selected JSON-node projection; this
43
+ is not canonical runtime shader hydration.
44
+
45
+ ## Instance methods
46
+
47
+ - `SetValues(options)` updates the reusable profile and returns the reader.
48
+ - `GetValues(options)` returns effective values with optional overrides.
49
+ - `SetClasses(classes)` and `SetClass(type, Class)` configure hydration.
50
+ - `GetClass(type)` and `HasClass(type)` inspect hydration registrations.
51
+ - `Read(input, options)` parses input and emits the configured graph.
52
+ - `Inspect(input, options)` returns header and technique summary data.
53
+ - `ToJSON(value)` converts reader output to JSON-compatible data.
54
+
55
+ ## Static methods
56
+
57
+ - `CjsHlslFormat.isSupported(input)` performs a header-level support check.
58
+ - `CjsHlslFormat.read(input, options)` performs a one-shot read.
59
+ - `CjsHlslFormat.inspect(input, options)` performs a one-shot inspection.
60
+ - `CjsHlslFormat.toJSON(value)` converts output to JSON-compatible data.
61
+ - `CjsHlslFormat.readFile(path, options)` reads and parses a file in Node.
62
+
63
+ Inputs may be `Uint8Array`, `ArrayBuffer`, `Buffer`, or `DataView` values.
64
+ Supported container versions are 8 through 15.
65
+
66
+ ## Constants
67
+
68
+ The class exposes `OUTPUT_JSON`, `OUTPUT_METADATA`, `OUTPUT_RAW`,
69
+ `CLASS_KEYS`, `type`, `mediaTypes`, `inputTypes`, `outputTypes`, and
70
+ `debugOutputTypes`. `inputTypes` contains `sm_hi`, `sm_lo`, and `sm_depth`.
71
+
72
+ ## Output stability
73
+
74
+ The `json` and `metadata` modes are the supported data contracts described in
75
+ [json-graph.md](json-graph.md). `raw` returns internal parser-DTO
76
+ `Tr2EffectRes` objects, not the canonical runtime-resource class, and may
77
+ change without a major version bump.
78
+
79
+ ## Repository metadata adapter
80
+
81
+ The repository provides a development script that writes metadata JSON. It is
82
+ not installed as a package `bin`:
83
+
84
+ ```sh
85
+ npm run metadata:hlsl -- effect.sm_hi
86
+ npm run metadata:hlsl -- effect.sm_hi effect.json
87
+ ```
88
+
89
+ When the output path is omitted, the CLI writes `<input-name>.json` in the
90
+ current working directory.
91
+
92
+ ## Related documentation
93
+
94
+ - [Reading effects](../guides/reading-effects.md)
95
+ - [Hydrating JSON output](../guides/hydrating-json-output.md)
96
+ - [Advanced analysis exports](advanced-analysis.md)
97
+ - [Portable body reflection](portable-reflection.md)
98
+ - [Class catalog](classes/README.md)
@@ -0,0 +1,11 @@
1
+ # Class catalog
2
+
3
+ Status: Deprecated
4
+ Scope: `@carbonenginejs/runtime-resource/formats/hlsl` maintained classes
5
+ Audience: Users, maintainers, and automated readers
6
+ Summary: Points to the canonical package-wide catalogs after format-package consolidation.
7
+
8
+ The maintained HLSL format entries now live in the
9
+ [package-wide formats class catalog](../../../../reference/classes/formats.md#hlsl).
10
+ Canonical runtime effect-resource and shader-reflection entries live in the
11
+ [resources class catalog](../../../../reference/classes/resources.md).
@@ -0,0 +1,100 @@
1
+ # JSON and metadata graphs
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-resource/formats/hlsl` emitted data
5
+ Audience: Users and integrators
6
+ Summary: Documents the default JSON graph, compact metadata graph, and permutation selection.
7
+
8
+ ## Default JSON graph
9
+
10
+ `emit: "json"` is the default:
11
+
12
+ ```text
13
+ Root
14
+ |- version, compilerVersion, sourcePath, bodyCount, loadError
15
+ |- permutations: Permutation[]
16
+ `- effect: EffectDescription | null
17
+ |- version, effectName, annotations, readError
18
+ `- techniques: Technique[]
19
+ `- passes: Pass[]
20
+ |- renderStates: { key, value }[]
21
+ `- stageInputs: (StageInput | null)[]
22
+ |- constants: Constant[]
23
+ |- resources: Resource[]
24
+ |- uavs: Resource[]
25
+ |- samplers: Sampler[]
26
+ |- signature
27
+ `- bytecode: ShaderBytecode | null
28
+ ```
29
+
30
+ Bytecode values are opaque payloads. A compatible bytecode-format package
31
+ must decode their instruction streams.
32
+
33
+ ## Permutation selection
34
+
35
+ By default, `effect` represents the container's default option set. Select
36
+ another compiled body with an array or `Map`:
37
+
38
+ ```js
39
+ const effect = CjsHlslFormat.read(bytes, {
40
+ permutation: [
41
+ { name: "BLEND_MODE", value: "TRANSPARENT" }
42
+ ]
43
+ });
44
+ ```
45
+
46
+ ## Metadata graph
47
+
48
+ `emit: "metadata"` returns compact inspection data without bytecode,
49
+ constant-value bytes, or runtime handles:
50
+
51
+ ```text
52
+ MetadataRoot
53
+ |- version, compilerVersion, sourcePath, bodyCount, loadError
54
+ |- permutations: Permutation[]
55
+ |- bodyIndex
56
+ |- selectedOptions: Option[]
57
+ `- effect: MetadataEffect | null
58
+ `- techniques: Technique[]
59
+ `- passes: Pass[]
60
+ |- renderStates: RenderState[]
61
+ `- stageInputs: (StageInput | null)[]
62
+ |- constantValueSize
63
+ |- constants: Constant[]
64
+ |- resources: Resource[]
65
+ |- uavs: Resource[]
66
+ |- samplers: Sampler[]
67
+ |- annotations
68
+ `- signature
69
+ ```
70
+
71
+ Each render-state record retains its numeric `key` and `value`. Known state
72
+ types can also include readable or typed fields such as `name`, `valueName`,
73
+ `valueFloat`, `valueHex`, or `valueFlags`.
74
+
75
+ ## Raw graph
76
+
77
+ `emit: "raw"` returns the internal parser-DTO `Tr2EffectRes` graph. It is not
78
+ the canonical runtime-resource class. It allows advanced callers to resolve
79
+ multiple permutations after one parse, but it is not a stable or
80
+ serialization-safe schema.
81
+
82
+ Raw stage and library inputs retain authored `sourceConstantValueSize` /
83
+ `sourceConstantValues` separately from Carbon-compatible mutable constant
84
+ buffers. Libraries retain their source `cjsShaderBytecode` directly. Use
85
+ `@carbonenginejs/runtime-resource/formats/hlsl/portable` to copy those facts into a validated
86
+ handle-free contract.
87
+
88
+ ## Compatibility and failures
89
+
90
+ The reader supports compiled effect versions 8 through 15. The root or
91
+ selected effect can contain format-defined error fields when a compiled body
92
+ cannot be decoded. Invalid input reads and unsupported layout decisions throw
93
+ rather than being filled with guessed values.
94
+
95
+ ## Related documentation
96
+
97
+ - [API reference](api.md)
98
+ - [Advanced analysis exports](advanced-analysis.md)
99
+ - [Portable body reflection](portable-reflection.md)
100
+ - [Reading effects](../guides/reading-effects.md)