@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
@@ -1 +1 @@
1
- {"version":3,"file":"TriTextureRes.js","sources":["../../../../src/resource/texture/TriTextureRes.js"],"sourcesContent":["// Source: trinity/trinity/Resources/TriTextureRes.h\n// Source: trinity/trinity/Resources/TriTextureRes.cpp\n// Source: trinity/trinity/Resources/TriTextureRes_Blue.cpp\nimport { carbon, impl, io, type } from \"@carbonenginejs/runtime-utils/schema\";\nimport { CjsResource } from \"../CjsResource.js\";\nimport {\n ResourcePayloadType,\n validateRgbaPayload,\n validateTexturePayload,\n validateVideoPayload\n} from \"../../format/payloadContract.js\";\nimport {\n resourceBoundaryError,\n resourcePayloadError,\n validateResourcePayload\n} from \"../resourceBoundary.js\";\n\n/**\n * Resource record that owns Carbon-style texture identity and validated\n * texture, RGBA, or video payload facts with mirrored dimension/format\n * metadata, while engine packages decide what those facts become on a device.\n *\n * The resource never creates or retains a backend texture.\n */\n@type.define({ className: \"TriTextureRes\", family: \"resources\" })\nexport class TriTextureRes extends CjsResource\n{\n @io.read\n @type.unknown\n format = null;\n\n @io.persist\n @type.unknown\n type = null;\n\n @io.read\n @type.color\n averageColor = [0, 0, 0, 0];\n\n @io.read\n @type.uint32\n depth = 0;\n\n @io.readwrite\n @type.float32\n cutoutHeight = 1;\n\n @io.read\n @type.uint32\n height = 0;\n\n @io.read\n @type.boolean\n lodEnabled = false;\n\n @io.read\n @type.boolean\n hadLodRequests = false;\n\n @io.read\n @type.uint32\n cpuMip = 0;\n\n @io.read\n @type.uint32\n gpuMip = 0;\n\n @io.read\n @type.unknown\n wrappedRenderTarget = null;\n\n @io.read\n @type.uint32\n originalResolution = 0;\n\n @io.read\n @type.uint64\n originalMemoryUsage = 0;\n\n @io.readwrite\n @type.string\n name = \"\";\n\n @io.read\n @type.uint32\n arraySize = 0;\n\n @io.readwrite\n @type.float32\n cutoutWidth = 1;\n\n @io.read\n @type.uint32\n width = 0;\n\n @io.readwrite\n @type.float32\n cutoutX = 0;\n\n @io.readwrite\n @type.float32\n cutoutY = 0;\n\n /** Creates a TriTextureRes with caller-provided initial state. */\n constructor(values = null) {\n super();\n this.SetValues(values || {}, {\n markDirty: false,\n skipUpdate: true,\n skipEvents: true\n });\n }\n\n /**\n * Attach a plain texture, RGBA, or video payload and mirror Carbon-exposed\n * metadata. Invalid payloads are rejected before replacing the current one.\n *\n * @param {object|null} payload\n * @param {object|null} options\n * @returns {TriTextureRes}\n */\n SetPayload(payload = null, options = null) {\n if (payload === null) {\n super.SetPayload(null);\n return this;\n }\n\n const validator = {\n [ResourcePayloadType.RGBA]: validateRgbaPayload,\n [ResourcePayloadType.TEXTURE]: validateTexturePayload,\n [ResourcePayloadType.VIDEO]: validateVideoPayload\n }[payload?.payloadType];\n if (!validator) {\n throw resourcePayloadError(\n \"TriTextureRes\",\n 'Expected payloadType \"rgba\", \"texture\", or \"video\".',\n \"payloadType\"\n );\n }\n validateResourcePayload(\"TriTextureRes\", payload, validator);\n\n const values = { ...(options || {}) };\n if (payload.pixelFormat !== undefined || payload.format !== undefined) values.format = payload.pixelFormat || payload.format;\n if (payload.width !== undefined) values.width = payload.width;\n if (payload.height !== undefined) values.height = payload.height;\n if (payload.depth !== undefined) values.depth = payload.depth;\n if (payload.arraySize !== undefined) values.arraySize = payload.arraySize;\n else if (Array.isArray(payload.faces)) values.arraySize = payload.faces.length;\n if (payload.mipCount !== undefined) values.cpuMip = payload.mipCount;\n else if (payload.payloadType === ResourcePayloadType.RGBA) values.cpuMip = 1;\n if (payload.hadLodRequests !== undefined) values.hadLodRequests = !!payload.hadLodRequests;\n values.originalMemoryUsage = getPayloadMemoryUsage(payload);\n values.originalResolution = Math.max(payload.width || 0, payload.height || 0, this.originalResolution || 0);\n\n super.SetPayload(payload);\n this.SetValues(values);\n return this;\n }\n\n /**\n * Return the number of mip levels known to this texture resource.\n *\n * @returns {number}\n */\n @carbon.method\n @impl.adapted\n GetMipCount() {\n return this.GetPayload()?.mipCount || this.cpuMip || 0;\n }\n\n /**\n * Return the multisample type for this texture.\n *\n * @returns {number}\n */\n @carbon.method\n @impl.adapted\n GetMsaaType() {\n const payload = this.GetPayload();\n return payload?.multiSampleType ?? payload?.msaaType ?? payload?.samples ?? 1;\n }\n\n /**\n * Return the multisample quality for this texture.\n *\n * @returns {number}\n */\n @carbon.method\n @impl.adapted\n GetMsaaQuality() {\n const payload = this.GetPayload();\n return payload?.multiSampleQuality ?? payload?.msaaQuality ?? 0;\n }\n\n /**\n * Return true if this texture has received LOD requests.\n *\n * @returns {boolean}\n */\n @carbon.method\n @impl.adapted\n HadLodRequests() {\n return this.hadLodRequests;\n }\n\n /**\n * Return the shader-resource-view heap index when a backend owns one.\n *\n * @returns {number}\n */\n @carbon.method\n @impl.notSupported\n GetSrvIndexInHeap() {\n throw resourceBoundaryError(\"TriTextureRes\", \"GetSrvIndexInHeap\", \"Runtime-resource does not own descriptor heaps.\");\n }\n\n /**\n * Save this texture asynchronously.\n *\n * @param {string} path\n * @returns {boolean}\n */\n @carbon.method\n @impl.notSupported\n SaveAsync(path = \"\") {\n throw resourceBoundaryError(\n \"TriTextureRes\",\n \"SaveAsync\",\n `Use a format writer and caller-owned destination to save texture payloads${path ? ` (${path})` : \"\"}.`\n );\n }\n\n /**\n * Save this texture synchronously.\n *\n * @param {string} path\n * @returns {boolean}\n */\n @carbon.method\n @impl.notSupported\n Save(path = \"\") {\n throw resourceBoundaryError(\n \"TriTextureRes\",\n \"Save\",\n `Use a format writer and caller-owned destination to save texture payloads${path ? ` (${path})` : \"\"}.`\n );\n }\n\n /**\n * Return true if an asynchronous save is active.\n *\n * @returns {boolean}\n */\n @carbon.method\n @impl.noop\n IsSaving() {\n return false;\n }\n\n /**\n * Return true if the asynchronous save operation has completed.\n *\n * @returns {boolean}\n */\n @carbon.method\n @impl.noop\n IsSaveCompleted() {\n return true;\n }\n\n /**\n * Return true if the asynchronous save operation succeeded.\n *\n * @returns {boolean}\n */\n @carbon.method\n @impl.noop\n IsSaveSucceeded() {\n return false;\n }\n\n /**\n * Wait for an asynchronous save operation.\n *\n * @returns {boolean}\n */\n @carbon.method\n @impl.noop\n WaitForSave() {\n return this.IsSaveCompleted();\n }\n\n /**\n * Device texture allocation belongs to engine-gpu.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notSupported\n CreateEmptyTexture() {\n throw resourceBoundaryError(\"TriTextureRes\", \"CreateEmptyTexture\", \"Use engine-gpu to allocate device textures.\");\n }\n\n /**\n * Render-target wrapping belongs to engine-gpu.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notSupported\n SetFromRenderTarget() {\n throw resourceBoundaryError(\"TriTextureRes\", \"SetFromRenderTarget\", \"Runtime-resource does not own render targets.\");\n }\n\n /**\n * Create a texture copy from a render target.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notSupported\n CreateAndCopyFromRenderTarget() {\n throw resourceBoundaryError(\"TriTextureRes\", \"CreateAndCopyFromRenderTarget\", \"Runtime-resource does not own render targets.\");\n }\n\n /**\n * Create a device texture from a host bitmap.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notSupported\n CreateFromHostBitmap() {\n throw resourceBoundaryError(\"TriTextureRes\", \"CreateFromHostBitmap\", \"Use engine-gpu to allocate and upload texture data.\");\n }\n\n /**\n * Create this texture from another texture resource.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notSupported\n CreateFromTexture() {\n throw resourceBoundaryError(\"TriTextureRes\", \"CreateFromTexture\", \"Use engine-gpu to copy device textures.\");\n }\n\n /**\n * Return true if this texture owns a backend allocation object.\n *\n * @param {string|number} type\n * @param {string|number} object\n * @returns {boolean}\n */\n @carbon.method\n @impl.adapted\n HasALObject(type, object) {\n return this.HasAdapterResource(`${type}:${object}`);\n }\n\n /**\n * Return an engine-owned texture pipeline object when attached.\n *\n * @returns {*}\n */\n @carbon.method\n @impl.adapted\n GetPipeline() {\n return this.GetAdapterResource(\"pipeline\");\n }\n\n /**\n * Return memory size for the original non-LODed texture.\n *\n * @returns {number}\n */\n @carbon.method\n @impl.adapted\n GetOriginalMemoryUsage() {\n return this.originalMemoryUsage || getPayloadMemoryUsage(this.GetPayload());\n }\n\n /**\n * Store the average color reported by decoded texture data.\n *\n * @param {number} red\n * @param {number} green\n * @param {number} blue\n * @param {number} alpha\n * @returns {TriTextureRes}\n */\n @carbon.method\n @impl.adapted\n SetAverageColor(red = 0, green = 0, blue = 0, alpha = 0) {\n this.averageColor = [red, green, blue, alpha];\n return this;\n }\n\n /**\n * Update a texture subresource.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notSupported\n UpdateSubresource() {\n throw resourceBoundaryError(\"TriTextureRes\", \"UpdateSubresource\", \"Use engine-gpu to upload texture bytes.\");\n }\n\n /**\n * Resource preparation does not decide device upload policy.\n *\n * @returns {boolean}\n */\n @carbon.method\n @impl.adapted\n PrepareResources() {\n return this.IsPrepared();\n }\n\n static payload = \"texture\";\n}\n\nfunction getPayloadMemoryUsage(payload)\n{\n if (!payload || typeof payload !== \"object\") return 0;\n if (Number.isSafeInteger(payload.originalMemoryUsage) && payload.originalMemoryUsage >= 0)\n {\n return payload.originalMemoryUsage;\n }\n return ArrayBuffer.isView(payload.data) || payload.data instanceof ArrayBuffer\n ? payload.data.byteLength\n : 0;\n}\n"],"names":["_TriTextureRes","_identity","TriTextureRes","CjsResource","e","_init_format","_init_extra_format","_init_type","_init_extra_type","_init_averageColor","_init_extra_averageColor","_init_depth","_init_extra_depth","_init_cutoutHeight","_init_extra_cutoutHeight","_init_height","_init_extra_height","_init_lodEnabled","_init_extra_lodEnabled","_init_hadLodRequests","_init_extra_hadLodRequests","_init_cpuMip","_init_extra_cpuMip","_init_gpuMip","_init_extra_gpuMip","_init_wrappedRenderTarget","_init_extra_wrappedRenderTarget","_init_originalResolution","_init_extra_originalResolution","_init_originalMemoryUsage","_init_extra_originalMemoryUsage","_init_name","_init_extra_name","_init_arraySize","_init_extra_arraySize","_init_cutoutWidth","_init_extra_cutoutWidth","_init_width","_init_extra_width","_init_cutoutX","_init_extra_cutoutX","_init_cutoutY","_init_extra_cutoutY","_initProto","c","_initClass","_applyDecs","type","define","className","family","io","read","unknown","persist","color","uint32","readwrite","float32","boolean","uint64","string","carbon","method","impl","adapted","notSupported","noop","format","averageColor","depth","cutoutHeight","height","lodEnabled","hadLodRequests","cpuMip","gpuMip","wrappedRenderTarget","originalResolution","originalMemoryUsage","name","arraySize","cutoutWidth","width","cutoutX","cutoutY","constructor","values","SetValues","markDirty","skipUpdate","skipEvents","SetPayload","payload","options","validator","ResourcePayloadType","RGBA","validateRgbaPayload","TEXTURE","validateTexturePayload","VIDEO","validateVideoPayload","payloadType","resourcePayloadError","validateResourcePayload","pixelFormat","undefined","Array","isArray","faces","length","mipCount","getPayloadMemoryUsage","Math","max","GetMipCount","GetPayload","GetMsaaType","multiSampleType","msaaType","samples","GetMsaaQuality","multiSampleQuality","msaaQuality","HadLodRequests","GetSrvIndexInHeap","resourceBoundaryError","SaveAsync","path","Save","IsSaving","IsSaveCompleted","IsSaveSucceeded","WaitForSave","CreateEmptyTexture","SetFromRenderTarget","CreateAndCopyFromRenderTarget","CreateFromHostBitmap","CreateFromTexture","HasALObject","object","HasAdapterResource","GetPipeline","GetAdapterResource","GetOriginalMemoryUsage","SetAverageColor","red","green","blue","alpha","UpdateSubresource","PrepareResources","IsPrepared","Number","isSafeInteger","ArrayBuffer","isView","data","byteLength"],"mappings":";;;;;;;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AANA,IAAAA;AAAA,IAAA,cAAAC,SAAA,CAAA;AAAA,EAAA,QAOA,MAAAC,aAAA,SACmCC,YAAW,CAC9C;AAAA,IAAA;AAAA,MAAA,CAAA;AAAAC,QAAAA,CAAA,GAAAC,YAAA,EAAAC,kBAAA,EAAAC,UAAA,EAAAC,gBAAA,EAAAC,kBAAA,EAAAC,wBAAA,EAAAC,WAAA,EAAAC,iBAAA,EAAAC,kBAAA,EAAAC,wBAAA,EAAAC,YAAA,EAAAC,kBAAA,EAAAC,gBAAA,EAAAC,sBAAA,EAAAC,oBAAA,EAAAC,0BAAA,EAAAC,YAAA,EAAAC,kBAAA,EAAAC,YAAA,EAAAC,kBAAA,EAAAC,yBAAA,EAAAC,+BAAA,EAAAC,wBAAA,EAAAC,8BAAA,EAAAC,yBAAA,EAAAC,+BAAA,EAAAC,UAAA,EAAAC,gBAAA,EAAAC,eAAA,EAAAC,qBAAA,EAAAC,iBAAA,EAAAC,uBAAA,EAAAC,WAAA,EAAAC,iBAAA,EAAAC,aAAA,EAAAC,mBAAA,EAAAC,aAAA,EAAAC,mBAAA,EAAAC,UAAA,CAAA;QAAAC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sources":["../../../../src/resource/texture/TriTextureRes.js"],"sourcesContent":["// Source: trinity/trinity/Resources/TriTextureRes.h\n// Source: trinity/trinity/Resources/TriTextureRes.cpp\n// Source: trinity/trinity/Resources/TriTextureRes_Blue.cpp\nimport { CjsSchema, carbon, impl, io, type } from \"@carbonenginejs/runtime-utils/schema\";\nimport { CjsResource } from \"../CjsResource.js\";\nimport {\n ResourcePayloadType,\n validateRgbaPayload,\n validateTexturePayload,\n validateVideoPayload\n} from \"../../format/payloadContract.js\";\nimport {\n resourceBoundaryError,\n resourcePayloadError,\n validateResourcePayload\n} from \"../resourceBoundary.js\";\n\n/**\n * Resource record that owns Carbon-style texture identity and validated\n * texture, RGBA, or video payload facts with mirrored dimension/format\n * metadata, while engine packages decide what those facts become on a device.\n *\n * The resource never creates or retains a backend texture.\n */\nexport class TriTextureRes extends CjsResource\n{\n format = null;\n type = null;\n averageColor = [0, 0, 0, 0];\n depth = 0;\n cutoutHeight = 1;\n height = 0;\n lodEnabled = false;\n hadLodRequests = false;\n cpuMip = 0;\n gpuMip = 0;\n wrappedRenderTarget = null;\n originalResolution = 0;\n originalMemoryUsage = 0;\n name = \"\";\n arraySize = 0;\n cutoutWidth = 1;\n width = 0;\n cutoutX = 0;\n cutoutY = 0;\n\n /** Creates a TriTextureRes with caller-provided initial state. */\n constructor(values = null) {\n super();\n this.SetValues(values || {}, {\n markDirty: false,\n skipUpdate: true,\n skipEvents: true\n });\n }\n\n /**\n * Attach a plain texture, RGBA, or video payload and mirror Carbon-exposed\n * metadata. Invalid payloads are rejected before replacing the current one.\n *\n * @param {object|null} payload\n * @param {object|null} options\n * @returns {TriTextureRes}\n */\n SetPayload(payload = null, options = null) {\n if (payload === null) {\n super.SetPayload(null);\n return this;\n }\n\n const validator = {\n [ResourcePayloadType.RGBA]: validateRgbaPayload,\n [ResourcePayloadType.TEXTURE]: validateTexturePayload,\n [ResourcePayloadType.VIDEO]: validateVideoPayload\n }[payload?.payloadType];\n if (!validator) {\n throw resourcePayloadError(\n \"TriTextureRes\",\n 'Expected payloadType \"rgba\", \"texture\", or \"video\".',\n \"payloadType\"\n );\n }\n validateResourcePayload(\"TriTextureRes\", payload, validator);\n\n const values = { ...(options || {}) };\n if (payload.pixelFormat !== undefined || payload.format !== undefined) values.format = payload.pixelFormat || payload.format;\n if (payload.width !== undefined) values.width = payload.width;\n if (payload.height !== undefined) values.height = payload.height;\n if (payload.depth !== undefined) values.depth = payload.depth;\n if (payload.arraySize !== undefined) values.arraySize = payload.arraySize;\n else if (Array.isArray(payload.faces)) values.arraySize = payload.faces.length;\n if (payload.mipCount !== undefined) values.cpuMip = payload.mipCount;\n else if (payload.payloadType === ResourcePayloadType.RGBA) values.cpuMip = 1;\n if (payload.hadLodRequests !== undefined) values.hadLodRequests = !!payload.hadLodRequests;\n values.originalMemoryUsage = getPayloadMemoryUsage(payload);\n values.originalResolution = Math.max(payload.width || 0, payload.height || 0, this.originalResolution || 0);\n\n super.SetPayload(payload);\n this.SetValues(values);\n return this;\n }\n\n /**\n * Return the number of mip levels known to this texture resource.\n *\n * @returns {number}\n */\n GetMipCount() {\n return this.GetPayload()?.mipCount || this.cpuMip || 0;\n }\n\n /**\n * Return the multisample type for this texture.\n *\n * @returns {number}\n */\n GetMsaaType() {\n const payload = this.GetPayload();\n return payload?.multiSampleType ?? payload?.msaaType ?? payload?.samples ?? 1;\n }\n\n /**\n * Return the multisample quality for this texture.\n *\n * @returns {number}\n */\n GetMsaaQuality() {\n const payload = this.GetPayload();\n return payload?.multiSampleQuality ?? payload?.msaaQuality ?? 0;\n }\n\n /**\n * Return true if this texture has received LOD requests.\n *\n * @returns {boolean}\n */\n HadLodRequests() {\n return this.hadLodRequests;\n }\n\n /**\n * Return the shader-resource-view heap index when a backend owns one.\n *\n * @returns {number}\n */\n GetSrvIndexInHeap() {\n throw resourceBoundaryError(\"TriTextureRes\", \"GetSrvIndexInHeap\", \"Runtime-resource does not own descriptor heaps.\");\n }\n\n /**\n * Save this texture asynchronously.\n *\n * @param {string} path\n * @returns {boolean}\n */\n SaveAsync(path = \"\") {\n throw resourceBoundaryError(\n \"TriTextureRes\",\n \"SaveAsync\",\n `Use a format writer and caller-owned destination to save texture payloads${path ? ` (${path})` : \"\"}.`\n );\n }\n\n /**\n * Save this texture synchronously.\n *\n * @param {string} path\n * @returns {boolean}\n */\n Save(path = \"\") {\n throw resourceBoundaryError(\n \"TriTextureRes\",\n \"Save\",\n `Use a format writer and caller-owned destination to save texture payloads${path ? ` (${path})` : \"\"}.`\n );\n }\n\n /**\n * Return true if an asynchronous save is active.\n *\n * @returns {boolean}\n */\n IsSaving() {\n return false;\n }\n\n /**\n * Return true if the asynchronous save operation has completed.\n *\n * @returns {boolean}\n */\n IsSaveCompleted() {\n return true;\n }\n\n /**\n * Return true if the asynchronous save operation succeeded.\n *\n * @returns {boolean}\n */\n IsSaveSucceeded() {\n return false;\n }\n\n /**\n * Wait for an asynchronous save operation.\n *\n * @returns {boolean}\n */\n WaitForSave() {\n return this.IsSaveCompleted();\n }\n\n /**\n * Device texture allocation belongs to engine-gpu.\n *\n * @throws {Error}\n */\n CreateEmptyTexture() {\n throw resourceBoundaryError(\"TriTextureRes\", \"CreateEmptyTexture\", \"Use engine-gpu to allocate device textures.\");\n }\n\n /**\n * Render-target wrapping belongs to engine-gpu.\n *\n * @throws {Error}\n */\n SetFromRenderTarget() {\n throw resourceBoundaryError(\"TriTextureRes\", \"SetFromRenderTarget\", \"Runtime-resource does not own render targets.\");\n }\n\n /**\n * Create a texture copy from a render target.\n *\n * @throws {Error}\n */\n CreateAndCopyFromRenderTarget() {\n throw resourceBoundaryError(\"TriTextureRes\", \"CreateAndCopyFromRenderTarget\", \"Runtime-resource does not own render targets.\");\n }\n\n /**\n * Create a device texture from a host bitmap.\n *\n * @throws {Error}\n */\n CreateFromHostBitmap() {\n throw resourceBoundaryError(\"TriTextureRes\", \"CreateFromHostBitmap\", \"Use engine-gpu to allocate and upload texture data.\");\n }\n\n /**\n * Create this texture from another texture resource.\n *\n * @throws {Error}\n */\n CreateFromTexture() {\n throw resourceBoundaryError(\"TriTextureRes\", \"CreateFromTexture\", \"Use engine-gpu to copy device textures.\");\n }\n\n /**\n * Return true if this texture owns a backend allocation object.\n *\n * @param {string|number} type\n * @param {string|number} object\n * @returns {boolean}\n */\n HasALObject(type, object) {\n return this.HasAdapterResource(`${type}:${object}`);\n }\n\n /**\n * Return an engine-owned texture pipeline object when attached.\n *\n * @returns {*}\n */\n GetPipeline() {\n return this.GetAdapterResource(\"pipeline\");\n }\n\n /**\n * Return memory size for the original non-LODed texture.\n *\n * @returns {number}\n */\n GetOriginalMemoryUsage() {\n return this.originalMemoryUsage || getPayloadMemoryUsage(this.GetPayload());\n }\n\n /**\n * Store the average color reported by decoded texture data.\n *\n * @param {number} red\n * @param {number} green\n * @param {number} blue\n * @param {number} alpha\n * @returns {TriTextureRes}\n */\n SetAverageColor(red = 0, green = 0, blue = 0, alpha = 0) {\n this.averageColor = [red, green, blue, alpha];\n return this;\n }\n\n /**\n * Update a texture subresource.\n *\n * @throws {Error}\n */\n UpdateSubresource() {\n throw resourceBoundaryError(\"TriTextureRes\", \"UpdateSubresource\", \"Use engine-gpu to upload texture bytes.\");\n }\n\n /**\n * Resource preparation does not decide device upload policy.\n *\n * @returns {boolean}\n */\n PrepareResources() {\n return this.IsPrepared();\n }\n\n static payload = \"texture\";\n}\n\nfunction getPayloadMemoryUsage(payload)\n{\n if (!payload || typeof payload !== \"object\") return 0;\n if (Number.isSafeInteger(payload.originalMemoryUsage) && payload.originalMemoryUsage >= 0)\n {\n return payload.originalMemoryUsage;\n }\n return ArrayBuffer.isView(payload.data) || payload.data instanceof ArrayBuffer\n ? payload.data.byteLength\n : 0;\n}\n\n// Declared as data rather than with decorators, so the resource tree loads from\n// source without a transform. Field order is key order, and GetValues() exports\n// in that order.\nCjsSchema.define(TriTextureRes, {\n className: \"TriTextureRes\",\n family: \"resources\",\n fields: {\n format: [ type.unknown, io.read ],\n type: [ type.unknown, io.persist ],\n averageColor: [ type.color, io.read ],\n depth: [ type.uint32, io.read ],\n cutoutHeight: [ type.float32, io.readwrite ],\n height: [ type.uint32, io.read ],\n lodEnabled: [ type.boolean, io.read ],\n hadLodRequests: [ type.boolean, io.read ],\n cpuMip: [ type.uint32, io.read ],\n gpuMip: [ type.uint32, io.read ],\n wrappedRenderTarget: [ type.unknown, io.read ],\n originalResolution: [ type.uint32, io.read ],\n originalMemoryUsage: [ type.uint64, io.read ],\n name: [ type.string, io.readwrite ],\n arraySize: [ type.uint32, io.read ],\n cutoutWidth: [ type.float32, io.readwrite ],\n width: [ type.uint32, io.read ],\n cutoutX: [ type.float32, io.readwrite ],\n cutoutY: [ type.float32, io.readwrite ]\n },\n methods: {\n GetMipCount: [ carbon.method, impl.adapted ],\n GetMsaaType: [ carbon.method, impl.adapted ],\n GetMsaaQuality: [ carbon.method, impl.adapted ],\n HadLodRequests: [ carbon.method, impl.adapted ],\n GetSrvIndexInHeap: [ carbon.method, impl.notSupported ],\n SaveAsync: [ carbon.method, impl.notSupported ],\n Save: [ carbon.method, impl.notSupported ],\n IsSaving: [ carbon.method, impl.noop ],\n IsSaveCompleted: [ carbon.method, impl.noop ],\n IsSaveSucceeded: [ carbon.method, impl.noop ],\n WaitForSave: [ carbon.method, impl.noop ],\n CreateEmptyTexture: [ carbon.method, impl.notSupported ],\n SetFromRenderTarget: [ carbon.method, impl.notSupported ],\n CreateAndCopyFromRenderTarget: [ carbon.method, impl.notSupported ],\n CreateFromHostBitmap: [ carbon.method, impl.notSupported ],\n CreateFromTexture: [ carbon.method, impl.notSupported ],\n HasALObject: [ carbon.method, impl.adapted ],\n GetPipeline: [ carbon.method, impl.adapted ],\n GetOriginalMemoryUsage: [ carbon.method, impl.adapted ],\n SetAverageColor: [ carbon.method, impl.adapted ],\n UpdateSubresource: [ carbon.method, impl.notSupported ],\n PrepareResources: [ carbon.method, impl.adapted ]\n }\n});\n"],"names":["TriTextureRes","CjsResource","format","type","averageColor","depth","cutoutHeight","height","lodEnabled","hadLodRequests","cpuMip","gpuMip","wrappedRenderTarget","originalResolution","originalMemoryUsage","name","arraySize","cutoutWidth","width","cutoutX","cutoutY","constructor","values","SetValues","markDirty","skipUpdate","skipEvents","SetPayload","payload","options","validator","ResourcePayloadType","RGBA","validateRgbaPayload","TEXTURE","validateTexturePayload","VIDEO","validateVideoPayload","payloadType","resourcePayloadError","validateResourcePayload","pixelFormat","undefined","Array","isArray","faces","length","mipCount","getPayloadMemoryUsage","Math","max","GetMipCount","GetPayload","GetMsaaType","multiSampleType","msaaType","samples","GetMsaaQuality","multiSampleQuality","msaaQuality","HadLodRequests","GetSrvIndexInHeap","resourceBoundaryError","SaveAsync","path","Save","IsSaving","IsSaveCompleted","IsSaveSucceeded","WaitForSave","CreateEmptyTexture","SetFromRenderTarget","CreateAndCopyFromRenderTarget","CreateFromHostBitmap","CreateFromTexture","HasALObject","object","HasAdapterResource","GetPipeline","GetAdapterResource","GetOriginalMemoryUsage","SetAverageColor","red","green","blue","alpha","UpdateSubresource","PrepareResources","IsPrepared","Number","isSafeInteger","ArrayBuffer","isView","data","byteLength","CjsSchema","define","className","family","fields","unknown","io","read","persist","color","uint32","float32","readwrite","boolean","uint64","string","methods","carbon","method","impl","adapted","notSupported","noop"],"mappings":";;;;;AAAA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,SAASC,WAAW,CAC9C;AACEC,EAAAA,MAAM,GAAG,IAAI;AACbC,EAAAA,IAAI,GAAG,IAAI;EACXC,YAAY,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAC3BC,EAAAA,KAAK,GAAG,CAAC;AACTC,EAAAA,YAAY,GAAG,CAAC;AAChBC,EAAAA,MAAM,GAAG,CAAC;AACVC,EAAAA,UAAU,GAAG,KAAK;AAClBC,EAAAA,cAAc,GAAG,KAAK;AACtBC,EAAAA,MAAM,GAAG,CAAC;AACVC,EAAAA,MAAM,GAAG,CA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AAM,CAACC,MAAM,EAAEC,IAAI,CAACC,OAAO,CAAE;IAChD7B,iBAAiB,EAAE,CAAE0B,MAAM,CAACC,MAAM,EAAEC,IAAI,CAACE,YAAY,CAAE;IACvD7B,gBAAgB,EAAE,CAAEyB,MAAM,CAACC,MAAM,EAAEC,IAAI,CAACC,OAAO;AACjD;AACF,CAAC,CAAC;;;;"}
package/docs/README.md CHANGED
@@ -47,7 +47,9 @@ hydration boundary.
47
47
 
48
48
  - [Architecture and boundaries](architecture.md)
49
49
  - [Resource lifecycle concepts](concepts/resource-lifecycle.md)
50
+ - [Shader resource model](concepts/shader-resource-model.md)
50
51
  - [Format subpaths](formats/README.md)
52
+ - [Carbon compiled-effect container](formats/carbon-effect-container.md)
51
53
 
52
54
  ## Documentation map
53
55
 
@@ -55,6 +57,12 @@ hydration boundary.
55
57
  GPU-free split.
56
58
  - [concepts/resource-lifecycle.md](concepts/resource-lifecycle.md): states,
57
59
  the load/prepare split, and the request workflow.
60
+ - [concepts/shader-resource-model.md](concepts/shader-resource-model.md): how
61
+ `Tr2EffectRes`, `Tr2Shader` and `Tr2Effect` relate, verified against Carbon —
62
+ one file, many permutations, many effects sharing them.
63
+ - [concepts/writing-an-engine-adapter.md](concepts/writing-an-engine-adapter.md):
64
+ the coupling rules and the reflection/topology seam for engine packages —
65
+ read before writing a second engine.
58
66
  - [reference/motherlode-cache.md](reference/motherlode-cache.md): canonical
59
67
  identity, byte-budget cache, payload retention, and purge contracts.
60
68
  - [reference/reload.md](reference/reload.md): the candidate-first atomic
@@ -77,10 +85,14 @@ hydration boundary.
77
85
  one-sentence class-purpose catalog.
78
86
  - [formats/README.md](formats/README.md): format import map and per-format
79
87
  output notes.
88
+ - [formats/carbon-effect-container.md](formats/carbon-effect-container.md): the
89
+ public v15 compiled-effect binary layout, extension rules, shared byte reader
90
+ and writer, and arena offset policy a byte-exact re-emit depends on.
80
91
  - [formats/gr2.md](formats/gr2.md): Granny GR2/GSF reading, output modes,
81
92
  conversions, graph shape, and class hydration.
82
93
  - [formats/wwise.md](formats/wwise.md): Wwise soundbank and media readers.
83
94
  - [formats/stl.md](formats/stl.md): STL geometry export.
84
95
  - [formats/provenance.md](formats/provenance.md): format ownership, fork
85
96
  provenance, and retained snapshots.
86
- - [roadmap.md](roadmap.md): approved future direction that is not implemented.
97
+ - [roadmap.md](roadmap.md): approved future direction with explicit current
98
+ boundary context where needed to interpret the plan.
@@ -74,9 +74,9 @@ historical mapping.
74
74
 
75
75
  - WebGL/WebGPU realization, allocations, upload accounting, device budgets,
76
76
  capability limits, and device-loss recovery (engine packages).
77
- - Shader binary decoding, backend translation, and package serialization remain
78
- in the standalone shader-format packages. Backend shader objects remain in
79
- engine packages.
77
+ - Shader binary decoding, backend translation, and package serialization live
78
+ in the explicit `runtime-resource/formats/{hlsl,dxbc,webgl,webgpu}` subpaths.
79
+ Backend shader objects remain in engine packages.
80
80
  - AudioBuffer construction, playback, or audio manager behavior.
81
81
  - Audio-library document construction, enrichment, media-ID interpretation,
82
82
  and delivery-route selection.
@@ -183,10 +183,13 @@ failure: destroy candidate -> LOADED (CPU payload retained)
183
183
 
184
184
  ccpwgl keeps every resource in `Tw2MotherLode` until it is explicitly cleared
185
185
  or auto-purged, and its `IsGood()` implicitly calls `KeepAlive()`, so many
186
- read/check paths keep resources resident. CarbonEngineJS is deliberately more
186
+ read/check paths keep resources resident. CarbonEngineJS retains that behavior
187
+ for the resource being queried, while keeping payload retention and hard locks
187
188
  explicit:
188
189
 
189
- - `IsGood()`, `IsPrepared()`, and `HasLoaded()` remain pure state checks.
190
+ - `IsGood()` calls `KeepAlive()` before checking preparation. It renews this
191
+ handle and starts its bounded reload path when the handle is `PURGED`.
192
+ - `IsPrepared()` and `HasLoaded()` remain pure state checks.
190
193
  - `KeepAlive()` and `KeepPayloadAlive()` are the explicit liveness operations.
191
194
  - `Lock()` / `Unlock()` maintain a non-underflowing count and prevent identity
192
195
  and payload eviction during a sweep.
@@ -195,6 +198,10 @@ explicit:
195
198
  never infers JavaScript reachability. `CjsResMan.Update()` may request it
196
199
  only under an explicitly configured automatic policy.
197
200
 
201
+ Generic liveness never walks arbitrary child fields. `IsGood()` renews only the
202
+ handle on which it is called; an aggregate consumer that owns child resources
203
+ must query or retain those children explicitly.
204
+
198
205
  The CPU/GPU split adds an axis that ccpwgl blurs: CPU payload memory and
199
206
  device memory are different budgets. Retention therefore distinguishes:
200
207
 
@@ -0,0 +1,114 @@
1
+ # Shader resource model
2
+
3
+ Status: Stable
4
+ Scope: `@carbonenginejs/runtime-resource`, with notes on `@carbonenginejs/runtime-trinity`
5
+ Audience: Anyone touching `Tr2EffectRes`, `Tr2Shader`, `Tr2Effect`, or shader effect formats
6
+ Summary: Explains how one effect file, its permutations, and the objects that resolve them relate.
7
+
8
+ ## Three levels
9
+
10
+ The distinction between resource, resolved shader, and effect instance is
11
+ load-bearing:
12
+
13
+ | Level | Represents | Owns |
14
+ | --- | --- | --- |
15
+ | `Tr2EffectRes` | One effect file | Bytes, permutation axes, offset table, and a cache of resolved shaders |
16
+ | `Tr2Shader` | One permutation | Techniques and passes for one option set |
17
+ | `Tr2Effect` | One instance | Authored options, a resource reference, and the currently resolved shader |
18
+
19
+ One file yields many shaders. One shader represents one permutation. Many
20
+ effect instances may share the same resource and cached shader.
21
+
22
+ ## Carbon model
23
+
24
+ Carbon's `Tr2EffectRes` retains the whole compiled file, its permutation
25
+ records, and a map from permutation index to `Tr2Shader`. Its
26
+ `GetShader(options, count)` resolves an option tuple to an index and reuses the
27
+ cached shader for that index.
28
+
29
+ `Tr2Effect` inherits the shader pointer from `Tr2Material`. Rebuilding an
30
+ effect clears that pointer and resolves it again through the resource. This
31
+ creates two deliberate caches:
32
+
33
+ - the resource caches one hydrated shader per permutation index; and
34
+ - each effect instance caches its currently resolved pointer.
35
+
36
+ Changing effect options therefore selects another shader from the same loaded
37
+ file rather than loading another file.
38
+
39
+ ## Runtime-resource model
40
+
41
+ `runtime-resource/src/resource/shader/Tr2EffectRes.js` follows the same shape:
42
+
43
+ | Carbon | Runtime-resource |
44
+ | --- | --- |
45
+ | shader map keyed by permutation index | private `#shaders` map |
46
+ | `GetShader(options, count)` | option resolution followed by `GetShaderByIndex` |
47
+ | permutation records | `permutationGraph.axes` and `variants` |
48
+ | offset-table body lookup | portable reflection lookup; Carbon-record adapter pending |
49
+ | retained file bytes | `GetPayload()` |
50
+
51
+ `runtime-trinity`'s `Tr2Effect.RebuildCachedDataInternal` clears and
52
+ re-resolves its shader through the effect resource. Renderer-owned pipelines,
53
+ bind groups, and GPU handles are not part of this device-free graph.
54
+
55
+ ## Package coverage
56
+
57
+ Carbon effect files carry every permutation and select through a dense offset
58
+ table. Representative source files demonstrate why body count and permutation
59
+ count are different:
60
+
61
+ | File | Permutations | Distinct bodies |
62
+ | --- | ---: | ---: |
63
+ | `effect.dx11/.../unpacked_quadv5.sm_hi` | 480 | 144 |
64
+ | `effect.gles2/.../geometryviewer.sm_hi` | 80 | 27 |
65
+ | `effect.gles2/.../textureviewer.sm_hi` | 18 | 3 |
66
+
67
+ Current `.cewgpu` bytes use Carbon's version-15 record layout and retain every
68
+ permutation row and representable non-program description fields. Non-dynamic
69
+ sampler names are unrecoverable and stage order is canonicalized. Emitted body
70
+ dedupe follows exact emitted bytes, so it need not preserve the original source
71
+ alias partition. `mode: "selected"` narrows which body receives translated
72
+ WGSL; it does not discard source permutations. `mode: "all"` attempts every
73
+ distinct body after the resolved selection passes the initial translation gate.
74
+
75
+ `.cewg` remains its own CEWG chunk format. Its current package contract also
76
+ preserves complete source permutation topology and supports selected versus
77
+ all backend coverage.
78
+
79
+ The selected/all distinction is therefore backend translation scope, not
80
+ source cardinality. A resource can still reason about every option tuple even
81
+ when some bodies have no translated backend program.
82
+
83
+ ## Current integration boundaries
84
+
85
+ The wire topology is complete, but two adapters still require focused
86
+ regression proof:
87
+
88
+ - the raw CEWGPU container's Carbon description must be converted to the
89
+ portable envelope expected by `Tr2Shader.fromPortable`; and
90
+ - the engine's derived body-program view must agree on stable pass-unit
91
+ identity.
92
+
93
+ Until those adapters are reconciled, the presence of every permutation proves
94
+ source preservation, not successful runtime hydration or execution.
95
+
96
+ ## Reading the model without inventing gaps
97
+
98
+ Three recurring mistakes explain most false conclusions in this area:
99
+
100
+ 1. **Searching only one package.** `Tr2EffectRes` is in runtime-resource while
101
+ `Tr2Effect` is in runtime-trinity.
102
+ 2. **Searching only the derived class.** The effect's shader pointer is
103
+ declared on its `Tr2Material` base.
104
+ 3. **Confusing permutation rows with stored bodies.** Several rows may alias
105
+ one description body while remaining distinct option selections.
106
+
107
+ When an expected mechanism appears absent, check the owner package, base
108
+ classes, and record indirection before treating the absence as a design gap.
109
+
110
+ ## Related documentation
111
+
112
+ - [CEWGPU effect container](../formats/webgpu/formats/cewgpu.md)
113
+ - [Carbon compiled-effect container](../formats/carbon-effect-container.md)
114
+ - [WebGPU effect packaging](../formats/webgpu/guides/effect-packaging.md)
@@ -0,0 +1,115 @@
1
+ # Writing an engine adapter
2
+
3
+ Status: Stable
4
+ Scope: `@carbonenginejs/runtime-resource`, addressed to engine packages
5
+ Audience: Anyone building `engine-webgl`, a second WebGPU engine, or any package that realizes CPU payloads into backend objects
6
+ Summary: The coupling rules, the reflection/topology seam, and the two mistakes `engine-webgpu` already made that a second engine must not repeat.
7
+
8
+ ## Read this before writing a second engine
9
+
10
+ `engine-webgpu` is currently the only engine package. Most of its shape is right
11
+ and worth copying. Two things are not, and both are easier to avoid than to undo.
12
+ This document exists because the second engine is being written after the first
13
+ one's mistakes were diagnosed but before they were fixed.
14
+
15
+ ## The coupling rule
16
+
17
+ **Engine packages take functions and duck-typed objects. They do not import the
18
+ layers above or beside them.**
19
+
20
+ `engine-webgpu` declares this as a non-goal and holds it: no dependency on
21
+ `runtime-core`, `runtime-resource`, or `runtime-trinity`. Three existing seams
22
+ show the pattern, and a new engine should reach for one of them rather than
23
+ inventing a fourth:
24
+
25
+ | seam | shape |
26
+ |---|---|
27
+ | `CjsWebGPUPackage.fromBytes(bytes, { read })` | the format reader arrives as a **function** |
28
+ | `CjsWebGPUTrinityBatchDispatcher(hooks)` | `ResolveMaterial` / `ResolveBindings` arrive as **hooks**; the batch is duck-typed on the `Tr2RenderBatch` shape |
29
+ | `CjsTextureArrayRes` | the engine calls `ConsumeUpdateRequest()`, prepares a candidate, then `CommitPreparedAdapterRevision()` — **the resource layer owns the state machine and never holds engine code** |
30
+
31
+ The third is the most instructive. Realization is not a callback the resource
32
+ layer fires into the engine; it is a request the engine consumes and a commit it
33
+ returns. The engine drives its own frame, which is what an engine must do, while
34
+ the resource layer keeps the queue, the revisions, and the failure handling.
35
+
36
+ ## What the resource layer owns
37
+
38
+ Resource identity, the cache, CPU payload lifecycle, format selection, the
39
+ load/publication queues, and **permutation selection**. It stops at a published
40
+ CPU payload; it hands out objects and accepts commits.
41
+
42
+ It is GPU-free and stays that way. It does not define GPU-shaped interfaces for
43
+ engines to implement, which is precisely why the consume/commit shape is used
44
+ instead of an injected realizer.
45
+
46
+ ## The seam: reflection from the shader, topology from the package
47
+
48
+ This is the distinction the first engine got wrong.
49
+
50
+ **Carbon reflection belongs to `Tr2Shader`.** One file yields many shaders, one
51
+ shader is one permutation, and many effects share them — see
52
+ [shader-resource-model.md](shader-resource-model.md). The surface is
53
+ `GetConstant(name)`, `GetResource(name)`, `GetParameterAnnotations(parameterName)`,
54
+ `GetEffectDescription()` and `iterateStages()`, reachable through
55
+ `GetPortableEffectReflection` -> `Tr2Shader.fromPortable`.
56
+
57
+ **Backend binding topology belongs to the package**, because it has no Carbon
58
+ counterpart — it comes from the lowered IR, not from Carbon's D3D-era reflection.
59
+
60
+ | ask the shader | ask the package |
61
+ |---|---|
62
+ | `constants[].{name, offset, size}` | `group`, `binding`, `visibility` |
63
+ | resource `type`, `isSRGB` | `generatedSymbol`, `resourceKind` |
64
+ | annotations | `registerIndex`, `registerSpace` |
65
+ | the parameter's name | `viewDimension` |
66
+
67
+ If you find yourself wanting *richer package reflection*, you are on the wrong
68
+ side of this table. The data you want is on the shader, and it is there because
69
+ Carbon put it there.
70
+
71
+ ## The two mistakes not to copy
72
+
73
+ ### 1. Do not read format-package records for Carbon reflection
74
+
75
+ `engine-webgpu/src/core/packageHelpers.js` and
76
+ `src/core/spaceObjectMainBindings.js` read `metadataName`, `heapView`,
77
+ `carbon.type`, `carbon.isSRGB` and `carbon.constants[].{name, offset, size}`
78
+ directly out of the format package, to pack real material uniform bytes. Twelve
79
+ lines, two files, and a known layering defect: engine code must consume the
80
+ resource-owned `Tr2Shader` reflection graph rather than make format-package
81
+ records its material API.
82
+
83
+ It is deferred rather than fixed because nothing can use that path until the
84
+ shader work lands, so the break is theoretical. That is a reason not to rush it,
85
+ not a reason to reproduce it.
86
+
87
+ ### 2. Do not reimplement permutation selection
88
+
89
+ `Tr2EffectRes` already keeps a permutation-index-keyed shader cache and resolves
90
+ options through it — Carbon's own mechanism, and ours matches. An engine that
91
+ grows its own index-keyed resolution is writing a second copy of a tested thing.
92
+
93
+ Building pipelines, bind groups and GPU objects is **not** duplication; that is
94
+ the engine's whole job. The line falls exactly where the table above falls.
95
+
96
+ ## runtime-core is optional
97
+
98
+ `runtime-core` wires named services by default — `RegisterResourceBehavior`
99
+ registers "a structural request policy without importing its owner", and the
100
+ resource manager, space-object factory and audio manager register the same way.
101
+ It is a convenience wrapper, not a dependency.
102
+
103
+ Every hook it registers can be passed by hand. An engine that only works when
104
+ `runtime-core` is present has taken a dependency through the back door.
105
+
106
+ ## Checklist for a new engine package
107
+
108
+ - no imports of `runtime-core`, `runtime-resource`, or `runtime-trinity`
109
+ - readers, material resolvers and batch shapes arrive injected or duck-typed
110
+ - Carbon reflection is read from a shader object handed in, never from format
111
+ records
112
+ - permutation selection is asked for, never reimplemented
113
+ - long-lived state machines and queues stay in the resource layer; the engine
114
+ consumes requests and commits results
115
+ - the package works with `runtime-core` absent
@@ -3,7 +3,7 @@
3
3
  Status: Evolving
4
4
  Scope: `@carbonenginejs/runtime-resource/formats`
5
5
  Audience: Users and integrators
6
- Summary: Maps every non-shader format subpath and records cross-format output conventions.
6
+ Summary: Maps every owned format subpath and records cross-format output conventions.
7
7
 
8
8
  ## Import rule
9
9
 
@@ -70,6 +70,29 @@ Detailed pages: [Granny GR2 and GSF](gr2.md),
70
70
  history, retained snapshots, and donor licensing are recorded in
71
71
  [provenance.md](provenance.md).
72
72
 
73
+ ## Black and Red reader boundary
74
+
75
+ `CjsBlackReader` and `CjsRedReader` share `CjsBlueReader` as an output and
76
+ hydration backend. The shared layer owns payload/runtime target creation,
77
+ payload-reference markers, hydration-adapter coordination, reports, and
78
+ runtime finalization. It does not own transport framing or graph traversal.
79
+
80
+ Black retains its binary buffer and cursor, string tables, numeric reference
81
+ tokens, schema/descriptor field resolution, skip behavior, and
82
+ Black-specific property readers. Structure-list parsing and skipping therefore
83
+ remain on the Black side. Red retains YAML parsing, anchors and aliases, typed
84
+ table decoding, and lenient named-field assignment. Red is the YAML-encoded
85
+ Blue graph transport; the generic `CjsYamlFormat` reader is separate and does
86
+ not use the Blue backend.
87
+
88
+ These readers are source-bound and garbage-collected rather than explicitly
89
+ disposed. A read entry point resets its graph state before walking the same
90
+ bound source again; Black also restores its binary cursor. Runtime hydration
91
+ constructs a target when its node is encountered, applies that node's values
92
+ after its children have been read, and defers all `finalize` calls until the
93
+ complete graph is available. Untyped Red maps remain plain value objects and
94
+ do not enter the runtime adapter lifecycle.
95
+
73
96
  ## Granny GR2/GSF
74
97
 
75
98
  `CjsGr2Format` reads `.gr2` geometry/skeleton/animation graphs and `.gsf`