@zephyr3d/scene 0.9.1 → 0.9.3

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 (522) hide show
  1. package/dist/animation/animationset.js +2 -0
  2. package/dist/animation/animationset.js.map +1 -1
  3. package/dist/animation/cloth/gpu_cloth_system.js +9 -1
  4. package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
  5. package/dist/animation/fixed_geometry_cache_track.js +5 -1
  6. package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
  7. package/dist/animation/geometry_cache_utils.js +20 -4
  8. package/dist/animation/geometry_cache_utils.js.map +1 -1
  9. package/dist/animation/ik/ik_angle_constraint.js +2 -6
  10. package/dist/animation/ik/ik_angle_constraint.js.map +1 -1
  11. package/dist/animation/ik/ik_chain_builder.js +68 -0
  12. package/dist/animation/ik/ik_chain_builder.js.map +1 -0
  13. package/dist/animation/ik/ik_pole_constraint.js +2 -7
  14. package/dist/animation/ik/ik_pole_constraint.js.map +1 -1
  15. package/dist/animation/ik/two_bone_ik_solver.js +2 -6
  16. package/dist/animation/ik/two_bone_ik_solver.js.map +1 -1
  17. package/dist/animation/joint_dynamics/collision.js +60 -12
  18. package/dist/animation/joint_dynamics/collision.js.map +1 -1
  19. package/dist/animation/joint_dynamics/constraints.js +20 -4
  20. package/dist/animation/joint_dynamics/constraints.js.map +1 -1
  21. package/dist/animation/joint_dynamics/controller.js +94 -46
  22. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  23. package/dist/animation/joint_dynamics/math.js +16 -0
  24. package/dist/animation/joint_dynamics/math.js.map +1 -0
  25. package/dist/animation/joint_dynamics/solver.js +21 -11
  26. package/dist/animation/joint_dynamics/solver.js.map +1 -1
  27. package/dist/animation/joint_dynamics/types.js +15 -3
  28. package/dist/animation/joint_dynamics/types.js.map +1 -1
  29. package/dist/animation/pca_geometry_cache_track.js +5 -1
  30. package/dist/animation/pca_geometry_cache_track.js.map +1 -1
  31. package/dist/animation/skeleton.js +2 -2
  32. package/dist/animation/skeleton.js.map +1 -1
  33. package/dist/animation/skeleton_modifier.js +2 -6
  34. package/dist/animation/skeleton_modifier.js.map +1 -1
  35. package/dist/animation/spring/spring_particle.js +4 -4
  36. package/dist/animation/spring/spring_particle.js.map +1 -1
  37. package/dist/animation/spring/spring_system.js +13 -40
  38. package/dist/animation/spring/spring_system.js.map +1 -1
  39. package/dist/animation/spring2/constraints.js.map +1 -1
  40. package/dist/animation/spring2/controller.js +64 -64
  41. package/dist/animation/spring2/controller.js.map +1 -1
  42. package/dist/animation/spring2/math.js.map +1 -1
  43. package/dist/animation/spring2/spring_system.js +8 -8
  44. package/dist/animation/spring2/spring_system.js.map +1 -1
  45. package/dist/app/app.js.map +1 -1
  46. package/dist/app/engine.js +1 -1
  47. package/dist/app/engine.js.map +1 -1
  48. package/dist/app/screen.js +4 -4
  49. package/dist/app/screen.js.map +1 -1
  50. package/dist/app/scriptingsystem.js +24 -1
  51. package/dist/app/scriptingsystem.js.map +1 -1
  52. package/dist/app/scriptregistry.js +22 -1
  53. package/dist/app/scriptregistry.js.map +1 -1
  54. package/dist/asset/assetmanager.js +2 -2
  55. package/dist/asset/assetmanager.js.map +1 -1
  56. package/dist/asset/model.js +60 -60
  57. package/dist/asset/model.js.map +1 -1
  58. package/dist/camera/camera.js +1 -1
  59. package/dist/camera/camera.js.map +1 -1
  60. package/dist/camera/orbit.js.map +1 -1
  61. package/dist/index.d.ts +795 -266
  62. package/dist/index.js +3 -2
  63. package/dist/index.js.map +1 -1
  64. package/dist/material/material.js +3 -1
  65. package/dist/material/material.js.map +1 -1
  66. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  67. package/dist/material/shader/helper.js +281 -278
  68. package/dist/material/shader/helper.js.map +1 -1
  69. package/dist/material/sprite.js +6 -6
  70. package/dist/material/sprite.js.map +1 -1
  71. package/dist/material/terrain-cm.js +2 -2
  72. package/dist/material/terrain-cm.js.map +1 -1
  73. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +38 -0
  74. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +1 -0
  75. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +10 -0
  76. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +1 -0
  77. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +127 -0
  78. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +1 -0
  79. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +263 -0
  80. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +1 -0
  81. package/dist/posteffect/taa.js +31 -39
  82. package/dist/posteffect/taa.js.map +1 -1
  83. package/dist/render/cluster_light.js +3 -4
  84. package/dist/render/cluster_light.js.map +1 -1
  85. package/dist/render/drawable.js +5 -1
  86. package/dist/render/drawable.js.map +1 -1
  87. package/dist/render/rendergraph/device_pool_allocator.js +29 -3
  88. package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
  89. package/dist/render/rendergraph/executor.js +283 -33
  90. package/dist/render/rendergraph/executor.js.map +1 -1
  91. package/dist/render/rendergraph/forward_plus_builder.js +338 -108
  92. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
  93. package/dist/render/rendergraph/history_resource_manager.js +195 -115
  94. package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
  95. package/dist/render/rendergraph/history_resources.js +10 -0
  96. package/dist/render/rendergraph/history_resources.js.map +1 -0
  97. package/dist/render/rendergraph/rendergraph.js +162 -35
  98. package/dist/render/rendergraph/rendergraph.js.map +1 -1
  99. package/dist/render/rendergraph/types.js +25 -5
  100. package/dist/render/rendergraph/types.js.map +1 -1
  101. package/dist/render/rendertarget.js +5 -1
  102. package/dist/render/rendertarget.js.map +1 -1
  103. package/dist/render/screenrendertarget.js +5 -1
  104. package/dist/render/screenrendertarget.js.map +1 -1
  105. package/dist/render/sky.js +4 -4
  106. package/dist/render/sky.js.map +1 -1
  107. package/dist/scene/basesprite.js +2 -2
  108. package/dist/scene/basesprite.js.map +1 -1
  109. package/dist/scene/graph_node.js +1 -1
  110. package/dist/scene/graph_node.js.map +1 -1
  111. package/dist/scene/mesh.js +81 -97
  112. package/dist/scene/mesh.js.map +1 -1
  113. package/dist/scene/particlesys.js +1 -1
  114. package/dist/scene/particlesys.js.map +1 -1
  115. package/dist/scene/scene_node.js +228 -228
  116. package/dist/scene/scene_node.js.map +1 -1
  117. package/dist/scene/script_attachment.js +15 -3
  118. package/dist/scene/script_attachment.js.map +1 -1
  119. package/dist/scene/terrain-cm/terrain-cm.js +3 -3
  120. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  121. package/dist/shadow/shadowmapper.js.map +1 -1
  122. package/dist/shapes/box.js +1 -1
  123. package/dist/shapes/box.js.map +1 -1
  124. package/dist/shapes/capsule.js +0 -3
  125. package/dist/shapes/capsule.js.map +1 -1
  126. package/dist/shapes/cylinder.js +0 -3
  127. package/dist/shapes/cylinder.js.map +1 -1
  128. package/dist/shapes/plane.js +0 -3
  129. package/dist/shapes/plane.js.map +1 -1
  130. package/dist/shapes/tetrahedron.js +3 -9
  131. package/dist/shapes/tetrahedron.js.map +1 -1
  132. package/dist/shapes/torus.js +94 -66
  133. package/dist/shapes/torus.js.map +1 -1
  134. package/dist/src/animation/animation.js +127 -0
  135. package/dist/src/animation/animation.js.map +1 -0
  136. package/dist/src/animation/animationset.js +255 -0
  137. package/dist/src/animation/animationset.js.map +1 -0
  138. package/dist/src/animation/animationtrack.js +34 -0
  139. package/dist/src/animation/animationtrack.js.map +1 -0
  140. package/dist/src/animation/eulerrotationtrack.js +52 -0
  141. package/dist/src/animation/eulerrotationtrack.js.map +1 -0
  142. package/dist/src/animation/morphtarget.js +93 -0
  143. package/dist/src/animation/morphtarget.js.map +1 -0
  144. package/dist/src/animation/morphtrack.js +70 -0
  145. package/dist/src/animation/morphtrack.js.map +1 -0
  146. package/dist/src/animation/proptrack.js +161 -0
  147. package/dist/src/animation/proptrack.js.map +1 -0
  148. package/dist/src/animation/rotationtrack.js +51 -0
  149. package/dist/src/animation/rotationtrack.js.map +1 -0
  150. package/dist/src/animation/scaletrack.js +50 -0
  151. package/dist/src/animation/scaletrack.js.map +1 -0
  152. package/dist/src/animation/skeleton.js +204 -0
  153. package/dist/src/animation/skeleton.js.map +1 -0
  154. package/dist/src/animation/translationtrack.js +50 -0
  155. package/dist/src/animation/translationtrack.js.map +1 -0
  156. package/dist/src/app/app.js +129 -0
  157. package/dist/src/app/app.js.map +1 -0
  158. package/dist/src/app/inputmgr.js +267 -0
  159. package/dist/src/app/inputmgr.js.map +1 -0
  160. package/dist/src/asset/assetmanager.js +404 -0
  161. package/dist/src/asset/assetmanager.js.map +1 -0
  162. package/dist/src/asset/builtin.js +337 -0
  163. package/dist/src/asset/builtin.js.map +1 -0
  164. package/dist/src/asset/loaders/dds/dds.js +470 -0
  165. package/dist/src/asset/loaders/dds/dds.js.map +1 -0
  166. package/dist/src/asset/loaders/dds/dds_loader.js +28 -0
  167. package/dist/src/asset/loaders/dds/dds_loader.js.map +1 -0
  168. package/dist/src/asset/loaders/gltf/gltf_loader.js +1265 -0
  169. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +1 -0
  170. package/dist/src/asset/loaders/gltf/helpers.js +327 -0
  171. package/dist/src/asset/loaders/gltf/helpers.js.map +1 -0
  172. package/dist/src/asset/loaders/hdr/hdr.js +180 -0
  173. package/dist/src/asset/loaders/hdr/hdr.js.map +1 -0
  174. package/dist/src/asset/loaders/image/tga_Loader.js +116 -0
  175. package/dist/src/asset/loaders/image/tga_Loader.js.map +1 -0
  176. package/dist/src/asset/loaders/image/webimage_loader.js +63 -0
  177. package/dist/src/asset/loaders/image/webimage_loader.js.map +1 -0
  178. package/dist/src/asset/loaders/loader.js +45 -0
  179. package/dist/src/asset/loaders/loader.js.map +1 -0
  180. package/dist/src/asset/model.js +414 -0
  181. package/dist/src/asset/model.js.map +1 -0
  182. package/dist/src/blitter/bilateralblur.js +221 -0
  183. package/dist/src/blitter/bilateralblur.js.map +1 -0
  184. package/dist/src/blitter/blitter.js +390 -0
  185. package/dist/src/blitter/blitter.js.map +1 -0
  186. package/dist/src/blitter/box.js +118 -0
  187. package/dist/src/blitter/box.js.map +1 -0
  188. package/dist/src/blitter/copy.js +22 -0
  189. package/dist/src/blitter/copy.js.map +1 -0
  190. package/dist/src/blitter/gaussianblur.js +228 -0
  191. package/dist/src/blitter/gaussianblur.js.map +1 -0
  192. package/dist/src/camera/base.js +92 -0
  193. package/dist/src/camera/base.js.map +1 -0
  194. package/dist/src/camera/camera.js +1005 -0
  195. package/dist/src/camera/camera.js.map +1 -0
  196. package/dist/src/camera/fps.js +238 -0
  197. package/dist/src/camera/fps.js.map +1 -0
  198. package/dist/src/camera/orbit.js +245 -0
  199. package/dist/src/camera/orbit.js.map +1 -0
  200. package/dist/src/camera/orthocamera.js +167 -0
  201. package/dist/src/camera/orthocamera.js.map +1 -0
  202. package/dist/src/camera/perspectivecamera.js +141 -0
  203. package/dist/src/camera/perspectivecamera.js.map +1 -0
  204. package/dist/src/index.js +120 -0
  205. package/dist/src/index.js.map +1 -0
  206. package/dist/src/material/blinn.js +81 -0
  207. package/dist/src/material/blinn.js.map +1 -0
  208. package/dist/src/material/grassmaterial.js +113 -0
  209. package/dist/src/material/grassmaterial.js.map +1 -0
  210. package/dist/src/material/lambert.js +92 -0
  211. package/dist/src/material/lambert.js.map +1 -0
  212. package/dist/src/material/material.js +301 -0
  213. package/dist/src/material/material.js.map +1 -0
  214. package/dist/src/material/meshmaterial.js +704 -0
  215. package/dist/src/material/meshmaterial.js.map +1 -0
  216. package/dist/src/material/mixins/albedocolor.js +76 -0
  217. package/dist/src/material/mixins/albedocolor.js.map +1 -0
  218. package/dist/src/material/mixins/foliage.js +47 -0
  219. package/dist/src/material/mixins/foliage.js.map +1 -0
  220. package/dist/src/material/mixins/lightmodel/blinnphong.js +112 -0
  221. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +1 -0
  222. package/dist/src/material/mixins/lightmodel/lambert.js +58 -0
  223. package/dist/src/material/mixins/lightmodel/lambert.js.map +1 -0
  224. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +178 -0
  225. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -0
  226. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +139 -0
  227. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -0
  228. package/dist/src/material/mixins/lit.js +476 -0
  229. package/dist/src/material/mixins/lit.js.map +1 -0
  230. package/dist/src/material/mixins/pbr/common.js +918 -0
  231. package/dist/src/material/mixins/pbr/common.js.map +1 -0
  232. package/dist/src/material/mixins/texture.js +172 -0
  233. package/dist/src/material/mixins/texture.js.map +1 -0
  234. package/dist/src/material/mixins/vertexcolor.js +56 -0
  235. package/dist/src/material/mixins/vertexcolor.js.map +1 -0
  236. package/dist/src/material/particle.js +178 -0
  237. package/dist/src/material/particle.js.map +1 -0
  238. package/dist/src/material/pbrmr.js +97 -0
  239. package/dist/src/material/pbrmr.js.map +1 -0
  240. package/dist/src/material/pbrsg.js +97 -0
  241. package/dist/src/material/pbrsg.js.map +1 -0
  242. package/dist/src/material/shader/helper.js +1209 -0
  243. package/dist/src/material/shader/helper.js.map +1 -0
  244. package/dist/src/material/terrain-cm.js +606 -0
  245. package/dist/src/material/terrain-cm.js.map +1 -0
  246. package/dist/src/material/terrainmaterial.js +375 -0
  247. package/dist/src/material/terrainmaterial.js.map +1 -0
  248. package/dist/src/material/unlit.js +41 -0
  249. package/dist/src/material/unlit.js.map +1 -0
  250. package/dist/src/material/water.js +417 -0
  251. package/dist/src/material/water.js.map +1 -0
  252. package/dist/src/posteffect/bloom.js +361 -0
  253. package/dist/src/posteffect/bloom.js.map +1 -0
  254. package/dist/src/posteffect/compositor.js +226 -0
  255. package/dist/src/posteffect/compositor.js.map +1 -0
  256. package/dist/src/posteffect/fxaa.js +273 -0
  257. package/dist/src/posteffect/fxaa.js.map +1 -0
  258. package/dist/src/posteffect/grayscale.js +69 -0
  259. package/dist/src/posteffect/grayscale.js.map +1 -0
  260. package/dist/src/posteffect/motionblur.js +96 -0
  261. package/dist/src/posteffect/motionblur.js.map +1 -0
  262. package/dist/src/posteffect/posteffect.js +126 -0
  263. package/dist/src/posteffect/posteffect.js.map +1 -0
  264. package/dist/src/posteffect/sao.js +324 -0
  265. package/dist/src/posteffect/sao.js.map +1 -0
  266. package/dist/src/posteffect/ssr.js +489 -0
  267. package/dist/src/posteffect/ssr.js.map +1 -0
  268. package/dist/src/posteffect/taa.js +172 -0
  269. package/dist/src/posteffect/taa.js.map +1 -0
  270. package/dist/src/posteffect/tonemap.js +94 -0
  271. package/dist/src/posteffect/tonemap.js.map +1 -0
  272. package/dist/src/render/abuffer_oit.js +361 -0
  273. package/dist/src/render/abuffer_oit.js.map +1 -0
  274. package/dist/src/render/clipmap.js +851 -0
  275. package/dist/src/render/clipmap.js.map +1 -0
  276. package/dist/src/render/cluster_light.js +333 -0
  277. package/dist/src/render/cluster_light.js.map +1 -0
  278. package/dist/src/render/cull_visitor.js +187 -0
  279. package/dist/src/render/cull_visitor.js.map +1 -0
  280. package/dist/src/render/depthpass.js +68 -0
  281. package/dist/src/render/depthpass.js.map +1 -0
  282. package/dist/src/render/drawable_mixin.js +227 -0
  283. package/dist/src/render/drawable_mixin.js.map +1 -0
  284. package/dist/src/render/envlight.js +463 -0
  285. package/dist/src/render/envlight.js.map +1 -0
  286. package/dist/src/render/fbm_wavegenerator.js +251 -0
  287. package/dist/src/render/fbm_wavegenerator.js.map +1 -0
  288. package/dist/src/render/fft_wavegenerator.js +1006 -0
  289. package/dist/src/render/fft_wavegenerator.js.map +1 -0
  290. package/dist/src/render/fullscreenquad.js +38 -0
  291. package/dist/src/render/fullscreenquad.js.map +1 -0
  292. package/dist/src/render/gerstner_wavegenerator.js +314 -0
  293. package/dist/src/render/gerstner_wavegenerator.js.map +1 -0
  294. package/dist/src/render/globalbindgroup_allocator.js +60 -0
  295. package/dist/src/render/globalbindgroup_allocator.js.map +1 -0
  296. package/dist/src/render/hzb.js +273 -0
  297. package/dist/src/render/hzb.js.map +1 -0
  298. package/dist/src/render/lightpass.js +172 -0
  299. package/dist/src/render/lightpass.js.map +1 -0
  300. package/dist/src/render/objectcolorpass.js +51 -0
  301. package/dist/src/render/objectcolorpass.js.map +1 -0
  302. package/dist/src/render/primitive.js +364 -0
  303. package/dist/src/render/primitive.js.map +1 -0
  304. package/dist/src/render/render_queue.js +467 -0
  305. package/dist/src/render/render_queue.js.map +1 -0
  306. package/dist/src/render/renderbundle_wrapper.js +152 -0
  307. package/dist/src/render/renderbundle_wrapper.js.map +1 -0
  308. package/dist/src/render/renderer.js +455 -0
  309. package/dist/src/render/renderer.js.map +1 -0
  310. package/dist/src/render/renderpass.js +200 -0
  311. package/dist/src/render/renderpass.js.map +1 -0
  312. package/dist/src/render/shadowmap_pass.js +56 -0
  313. package/dist/src/render/shadowmap_pass.js.map +1 -0
  314. package/dist/src/render/sky.js +1103 -0
  315. package/dist/src/render/sky.js.map +1 -0
  316. package/dist/src/render/weightedblended_oit.js +168 -0
  317. package/dist/src/render/weightedblended_oit.js.map +1 -0
  318. package/dist/src/scene/batchgroup.js +162 -0
  319. package/dist/src/scene/batchgroup.js.map +1 -0
  320. package/dist/src/scene/environment.js +209 -0
  321. package/dist/src/scene/environment.js.map +1 -0
  322. package/dist/src/scene/graph_node.js +72 -0
  323. package/dist/src/scene/graph_node.js.map +1 -0
  324. package/dist/src/scene/light.js +416 -0
  325. package/dist/src/scene/light.js.map +1 -0
  326. package/dist/src/scene/mesh.js +341 -0
  327. package/dist/src/scene/mesh.js.map +1 -0
  328. package/dist/src/scene/octree.js +649 -0
  329. package/dist/src/scene/octree.js.map +1 -0
  330. package/dist/src/scene/particlesys.js +738 -0
  331. package/dist/src/scene/particlesys.js.map +1 -0
  332. package/dist/src/scene/raycast_visitor.js +103 -0
  333. package/dist/src/scene/raycast_visitor.js.map +1 -0
  334. package/dist/src/scene/scene.js +284 -0
  335. package/dist/src/scene/scene.js.map +1 -0
  336. package/dist/src/scene/scene_node.js +732 -0
  337. package/dist/src/scene/scene_node.js.map +1 -0
  338. package/dist/src/scene/terrain/grass.js +278 -0
  339. package/dist/src/scene/terrain/grass.js.map +1 -0
  340. package/dist/src/scene/terrain/heightfield.js +475 -0
  341. package/dist/src/scene/terrain/heightfield.js.map +1 -0
  342. package/dist/src/scene/terrain/patch.js +530 -0
  343. package/dist/src/scene/terrain/patch.js.map +1 -0
  344. package/dist/src/scene/terrain/quadtree.js +461 -0
  345. package/dist/src/scene/terrain/quadtree.js.map +1 -0
  346. package/dist/src/scene/terrain/terrain.js +246 -0
  347. package/dist/src/scene/terrain/terrain.js.map +1 -0
  348. package/dist/src/scene/terrain-cm/grass.js +594 -0
  349. package/dist/src/scene/terrain-cm/grass.js.map +1 -0
  350. package/dist/src/scene/terrain-cm/grassmaterial.js +159 -0
  351. package/dist/src/scene/terrain-cm/grassmaterial.js.map +1 -0
  352. package/dist/src/scene/terrain-cm/terrain-cm.js +538 -0
  353. package/dist/src/scene/terrain-cm/terrain-cm.js.map +1 -0
  354. package/dist/src/scene/water.js +374 -0
  355. package/dist/src/scene/water.js.map +1 -0
  356. package/dist/src/shaders/atmosphere.js +957 -0
  357. package/dist/src/shaders/atmosphere.js.map +1 -0
  358. package/dist/src/shaders/fog.js +112 -0
  359. package/dist/src/shaders/fog.js.map +1 -0
  360. package/dist/src/shaders/misc.js +266 -0
  361. package/dist/src/shaders/misc.js.map +1 -0
  362. package/dist/src/shaders/noise.js +222 -0
  363. package/dist/src/shaders/noise.js.map +1 -0
  364. package/dist/src/shaders/pbr.js +51 -0
  365. package/dist/src/shaders/pbr.js.map +1 -0
  366. package/dist/src/shaders/shadow.js +636 -0
  367. package/dist/src/shaders/shadow.js.map +1 -0
  368. package/dist/src/shaders/ssr.js +490 -0
  369. package/dist/src/shaders/ssr.js.map +1 -0
  370. package/dist/src/shaders/temporal.js +215 -0
  371. package/dist/src/shaders/temporal.js.map +1 -0
  372. package/dist/src/shaders/water.js +756 -0
  373. package/dist/src/shaders/water.js.map +1 -0
  374. package/dist/src/shadow/esm.js +237 -0
  375. package/dist/src/shadow/esm.js.map +1 -0
  376. package/dist/src/shadow/pcf_opt.js +181 -0
  377. package/dist/src/shadow/pcf_opt.js.map +1 -0
  378. package/dist/src/shadow/pcf_pd.js +189 -0
  379. package/dist/src/shadow/pcf_pd.js.map +1 -0
  380. package/dist/src/shadow/shader.js +37 -0
  381. package/dist/src/shadow/shader.js.map +1 -0
  382. package/dist/src/shadow/shadow_impl.js +15 -0
  383. package/dist/src/shadow/shadow_impl.js.map +1 -0
  384. package/dist/src/shadow/shadowmapper.js +790 -0
  385. package/dist/src/shadow/shadowmapper.js.map +1 -0
  386. package/dist/src/shadow/ssm.js +159 -0
  387. package/dist/src/shadow/ssm.js.map +1 -0
  388. package/dist/src/shadow/vsm.js +297 -0
  389. package/dist/src/shadow/vsm.js.map +1 -0
  390. package/dist/src/shapes/box.js +386 -0
  391. package/dist/src/shapes/box.js.map +1 -0
  392. package/dist/src/shapes/cylinder.js +125 -0
  393. package/dist/src/shapes/cylinder.js.map +1 -0
  394. package/dist/src/shapes/plane.js +88 -0
  395. package/dist/src/shapes/plane.js.map +1 -0
  396. package/dist/src/shapes/shape.js +87 -0
  397. package/dist/src/shapes/shape.js.map +1 -0
  398. package/dist/src/shapes/sphere.js +114 -0
  399. package/dist/src/shapes/sphere.js.map +1 -0
  400. package/dist/src/shapes/tetrahedron.js +188 -0
  401. package/dist/src/shapes/tetrahedron.js.map +1 -0
  402. package/dist/src/shapes/torus.js +111 -0
  403. package/dist/src/shapes/torus.js.map +1 -0
  404. package/dist/src/utility/aabbtree.js +400 -0
  405. package/dist/src/utility/aabbtree.js.map +1 -0
  406. package/dist/src/utility/bounding_volume.js +29 -0
  407. package/dist/src/utility/bounding_volume.js.map +1 -0
  408. package/dist/src/utility/debug.js +28 -0
  409. package/dist/src/utility/debug.js.map +1 -0
  410. package/dist/src/utility/draco/decoder.js +116 -0
  411. package/dist/src/utility/draco/decoder.js.map +1 -0
  412. package/dist/src/utility/misc.js +105 -0
  413. package/dist/src/utility/misc.js.map +1 -0
  414. package/dist/src/utility/panorama.js +163 -0
  415. package/dist/src/utility/panorama.js.map +1 -0
  416. package/dist/src/utility/pmrem.js +354 -0
  417. package/dist/src/utility/pmrem.js.map +1 -0
  418. package/dist/src/utility/rendermipmap.js +115 -0
  419. package/dist/src/utility/rendermipmap.js.map +1 -0
  420. package/dist/src/utility/serialization/json.js +402 -0
  421. package/dist/src/utility/serialization/json.js.map +1 -0
  422. package/dist/src/utility/serialization/manager.js +623 -0
  423. package/dist/src/utility/serialization/manager.js.map +1 -0
  424. package/dist/src/utility/serialization/scene/animation.js +248 -0
  425. package/dist/src/utility/serialization/scene/animation.js.map +1 -0
  426. package/dist/src/utility/serialization/scene/batch.js +59 -0
  427. package/dist/src/utility/serialization/scene/batch.js.map +1 -0
  428. package/dist/src/utility/serialization/scene/camera.js +790 -0
  429. package/dist/src/utility/serialization/scene/camera.js.map +1 -0
  430. package/dist/src/utility/serialization/scene/common.js +222 -0
  431. package/dist/src/utility/serialization/scene/common.js.map +1 -0
  432. package/dist/src/utility/serialization/scene/light.js +575 -0
  433. package/dist/src/utility/serialization/scene/light.js.map +1 -0
  434. package/dist/src/utility/serialization/scene/material.js +1111 -0
  435. package/dist/src/utility/serialization/scene/material.js.map +1 -0
  436. package/dist/src/utility/serialization/scene/mesh.js +148 -0
  437. package/dist/src/utility/serialization/scene/mesh.js.map +1 -0
  438. package/dist/src/utility/serialization/scene/misc.js +39 -0
  439. package/dist/src/utility/serialization/scene/misc.js.map +1 -0
  440. package/dist/src/utility/serialization/scene/node.js +451 -0
  441. package/dist/src/utility/serialization/scene/node.js.map +1 -0
  442. package/dist/src/utility/serialization/scene/particle.js +425 -0
  443. package/dist/src/utility/serialization/scene/particle.js.map +1 -0
  444. package/dist/src/utility/serialization/scene/primitive.js +692 -0
  445. package/dist/src/utility/serialization/scene/primitive.js.map +1 -0
  446. package/dist/src/utility/serialization/scene/scene.js +704 -0
  447. package/dist/src/utility/serialization/scene/scene.js.map +1 -0
  448. package/dist/src/utility/serialization/scene/terrain.js +488 -0
  449. package/dist/src/utility/serialization/scene/terrain.js.map +1 -0
  450. package/dist/src/utility/serialization/scene/water.js +465 -0
  451. package/dist/src/utility/serialization/scene/water.js.map +1 -0
  452. package/dist/src/utility/shprojector.js +297 -0
  453. package/dist/src/utility/shprojector.js.map +1 -0
  454. package/dist/src/utility/textures/ggxlut.js +213 -0
  455. package/dist/src/utility/textures/ggxlut.js.map +1 -0
  456. package/dist/src/utility/textures/gradientnoise.js +62 -0
  457. package/dist/src/utility/textures/gradientnoise.js.map +1 -0
  458. package/dist/src/utility/textures/randomnoise.js +41 -0
  459. package/dist/src/utility/textures/randomnoise.js.map +1 -0
  460. package/dist/src/values.js +162 -0
  461. package/dist/src/values.js.map +1 -0
  462. package/dist/utility/blueprint/material/common.js +7 -0
  463. package/dist/utility/blueprint/material/common.js.map +1 -0
  464. package/dist/utility/blueprint/material/inputs.js +3 -3
  465. package/dist/utility/blueprint/material/inputs.js.map +1 -1
  466. package/dist/utility/blueprint/material/ir.js +4 -4
  467. package/dist/utility/blueprint/material/ir.js.map +1 -1
  468. package/dist/utility/serialization/blueprint/constants.js +255 -0
  469. package/dist/utility/serialization/blueprint/constants.js.map +1 -0
  470. package/dist/utility/serialization/blueprint/material/constants.js +203 -0
  471. package/dist/utility/serialization/blueprint/material/constants.js.map +1 -0
  472. package/dist/utility/serialization/blueprint/material/texture.js +165 -0
  473. package/dist/utility/serialization/blueprint/material/texture.js.map +1 -0
  474. package/dist/utility/serialization/manager.js +299 -268
  475. package/dist/utility/serialization/manager.js.map +1 -1
  476. package/dist/utility/serialization/scene/animation.js +45 -0
  477. package/dist/utility/serialization/scene/animation.js.map +1 -1
  478. package/dist/utility/serialization/scene/camera.js +53 -0
  479. package/dist/utility/serialization/scene/camera.js.map +1 -1
  480. package/dist/utility/serialization/scene/common.js +10 -0
  481. package/dist/utility/serialization/scene/common.js.map +1 -1
  482. package/dist/utility/serialization/scene/light.js +30 -0
  483. package/dist/utility/serialization/scene/light.js.map +1 -1
  484. package/dist/utility/serialization/scene/material.js +63 -0
  485. package/dist/utility/serialization/scene/material.js.map +1 -1
  486. package/dist/utility/serialization/scene/mesh.js +11 -0
  487. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  488. package/dist/utility/serialization/scene/misc.js +2 -0
  489. package/dist/utility/serialization/scene/misc.js.map +1 -1
  490. package/dist/utility/serialization/scene/node.js +19 -0
  491. package/dist/utility/serialization/scene/node.js.map +1 -1
  492. package/dist/utility/serialization/scene/particle.js +22 -0
  493. package/dist/utility/serialization/scene/particle.js.map +1 -1
  494. package/dist/utility/serialization/scene/primitive.js +33 -0
  495. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  496. package/dist/utility/serialization/scene/scene.js +39 -0
  497. package/dist/utility/serialization/scene/scene.js.map +1 -1
  498. package/dist/utility/serialization/scene/script.js +2 -0
  499. package/dist/utility/serialization/scene/script.js.map +1 -1
  500. package/dist/utility/serialization/scene/sprite.js +6 -0
  501. package/dist/utility/serialization/scene/sprite.js.map +1 -1
  502. package/dist/utility/serialization/scene/terrain.js +9 -0
  503. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  504. package/dist/utility/serialization/scene/water.js +21 -0
  505. package/dist/utility/serialization/scene/water.js.map +1 -1
  506. package/dist/utility/serialization/types.js +5 -1
  507. package/dist/utility/serialization/types.js.map +1 -1
  508. package/dist/values.js +49 -53
  509. package/dist/values.js.map +1 -1
  510. package/package.json +2 -2
  511. package/dist/animation/joint_dynamics/vrm_spring_bone.js +0 -46
  512. package/dist/animation/joint_dynamics/vrm_spring_bone.js.map +0 -1
  513. package/dist/animation/spring/spring_bone.js +0 -240
  514. package/dist/animation/spring/spring_bone.js.map +0 -1
  515. package/dist/animation/spring/spring_bone_collider.js +0 -198
  516. package/dist/animation/spring/spring_bone_collider.js.map +0 -1
  517. package/dist/animation/spring/spring_bone_constraint.js +0 -170
  518. package/dist/animation/spring/spring_bone_constraint.js.map +0 -1
  519. package/dist/animation/spring/spring_bone_system.js +0 -328
  520. package/dist/animation/spring/spring_bone_system.js.map +0 -1
  521. package/dist/render/sky_motion_vector.js +0 -85
  522. package/dist/render/sky_motion_vector.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { RGHandle, RGPass, RGResource } from './types.js';
1
+ import { RGHandle, RGPass, RGResource, RGSubpass } from './types.js';
2
2
 
3
3
  /**
4
4
  * Render Graph — declarative, configurable render pipeline.
@@ -6,7 +6,7 @@ import { RGHandle, RGPass, RGResource } from './types.js';
6
6
  * Usage:
7
7
  * ```ts
8
8
  * const graph = new RenderGraph();
9
- * const backbuffer = graph.importTexture('backbuffer');
9
+ * let backbuffer = graph.importTexture('backbuffer');
10
10
  *
11
11
  * let linearDepth: RGHandle;
12
12
  * graph.addPass('DepthPrepass', (builder) => {
@@ -16,7 +16,7 @@ import { RGHandle, RGPass, RGResource } from './types.js';
16
16
  *
17
17
  * graph.addPass('LightPass', (builder) => {
18
18
  * builder.read(linearDepth);
19
- * builder.write(backbuffer);
19
+ * backbuffer = builder.write(backbuffer);
20
20
  * builder.setExecute(() => { ... });
21
21
  * });
22
22
  *
@@ -72,13 +72,13 @@ import { RGHandle, RGPass, RGResource } from './types.js';
72
72
  * Performs dead-pass culling, topological sorting, and resource lifetime analysis.
73
73
  *
74
74
  * @param outputs - Handles of resources that must be produced (graph sinks).
75
+ * If a resource was passed to {@link RGPassBuilder.write}, use the returned
76
+ * post-write handle here, not the original handle.
75
77
  * Passes that do not contribute to these outputs (directly or transitively)
76
78
  * are culled, unless marked as side-effect passes.
77
79
  * @returns The compiled graph ready for execution.
78
80
  */ compile(outputs) {
79
- if (this._compiled) {
80
- return this._compiled;
81
- }
81
+ this._validateOutputs(outputs);
82
82
  // 1. Mark alive passes via backward traversal from outputs + side-effect passes
83
83
  this._cullDeadPasses(outputs);
84
84
  // 2. Topological sort of alive passes
@@ -96,15 +96,28 @@ import { RGHandle, RGPass, RGResource } from './types.js';
96
96
  *
97
97
  * For automatic resource allocation/release, use {@link RenderGraphExecutor} instead.
98
98
  *
99
- * @param compiled - The compiled graph from {@link compile}.
99
+ * @param compiled - The compiled graph from {@link RenderGraph.compile}.
100
100
  */ execute(compiled) {
101
101
  const noopCtx = {
102
102
  getTexture () {
103
103
  throw new Error('RenderGraph.execute(): resource resolution not available. Use RenderGraphExecutor for managed execution.');
104
+ },
105
+ getFramebuffer () {
106
+ throw new Error('RenderGraph.execute(): framebuffer resolution not available. Use RenderGraphExecutor for managed execution.');
107
+ },
108
+ createFramebuffer () {
109
+ throw new Error('RenderGraph.execute(): framebuffer allocation not available. Use RenderGraphExecutor for managed execution.');
110
+ },
111
+ deferCleanup () {
112
+ // No-op in unmanaged execution mode.
104
113
  }
105
114
  };
106
115
  for (const pass of compiled.orderedPasses){
107
- if (pass.executeFn) {
116
+ if (pass.subpasses.length > 0) {
117
+ for (const subpass of pass.subpasses){
118
+ subpass.executeFn(noopCtx, pass.data);
119
+ }
120
+ } else if (pass.executeFn) {
108
121
  pass.executeFn(noopCtx, pass.data);
109
122
  }
110
123
  }
@@ -143,19 +156,41 @@ import { RGHandle, RGPass, RGResource } from './types.js';
143
156
  if (res.kind === 'transient' && !res.producer) {
144
157
  throw new Error(`RenderGraph: pass "${pass.name}" attempts to read transient resource "${res.name}" ` + `which has no producer. Ensure the resource is created before being read.`);
145
158
  }
146
- pass.reads.push(res);
147
- res.consumers.push(pass);
159
+ if (!pass.reads.includes(res)) {
160
+ pass.reads.push(res);
161
+ }
162
+ if (!res.consumers.includes(pass)) {
163
+ res.consumers.push(pass);
164
+ }
148
165
  },
149
166
  write (handle) {
150
167
  const res = graph._resources.get(handle._id);
151
168
  if (!res) {
152
169
  throw new Error(`RenderGraph: unknown resource "${handle.name}" (id=${handle._id})`);
153
170
  }
154
- if (res.producer && res.producer !== pass) {
155
- throw new Error(`RenderGraph: resource "${res.name}" already produced by pass "${res.producer.name}", ` + `cannot be written by pass "${pass.name}"`);
171
+ if (res.kind === 'token') {
172
+ throw new Error(`RenderGraph: pass "${pass.name}" attempts to write token "${res.name}". ` + `Use createToken() to produce ordering tokens.`);
156
173
  }
157
- res.producer = pass;
158
- pass.writes.push(res);
174
+ if (res.kind === 'framebuffer') {
175
+ throw new Error(`RenderGraph: pass "${pass.name}" attempts to write framebuffer "${res.name}". ` + `Create a new framebuffer view instead.`);
176
+ }
177
+ for (const consumer of res.consumers){
178
+ if (consumer !== pass && !pass.dependencies.includes(consumer)) {
179
+ pass.dependencies.push(consumer);
180
+ }
181
+ }
182
+ if (res.producer && res.producer !== pass && !pass.dependencies.includes(res.producer)) {
183
+ pass.dependencies.push(res.producer);
184
+ }
185
+ const id = graph._nextResourceId++;
186
+ const versionName = `${res.name}@${pass.name}`;
187
+ const version = new RGResource(id, versionName, res.kind, res.desc, res.physicalId);
188
+ version.producer = pass;
189
+ graph._resources.set(id, version);
190
+ if (!pass.writes.includes(version)) {
191
+ pass.writes.push(version);
192
+ }
193
+ return new RGHandle(id, versionName);
159
194
  },
160
195
  createTexture (desc) {
161
196
  const id = graph._nextResourceId++;
@@ -166,15 +201,62 @@ import { RGHandle, RGPass, RGResource } from './types.js';
166
201
  pass.writes.push(res);
167
202
  return new RGHandle(id, name);
168
203
  },
204
+ createToken (name) {
205
+ const id = graph._nextResourceId++;
206
+ const tokenName = name ?? `_token_${id}`;
207
+ const res = new RGResource(id, tokenName, 'token', null);
208
+ res.producer = pass;
209
+ graph._resources.set(id, res);
210
+ pass.writes.push(res);
211
+ return new RGHandle(id, tokenName);
212
+ },
213
+ createFramebuffer (desc) {
214
+ const id = graph._nextResourceId++;
215
+ const name = desc.label ?? `_fb_${id}`;
216
+ const res = new RGResource(id, name, 'framebuffer', desc);
217
+ res.producer = pass;
218
+ graph._resources.set(id, res);
219
+ pass.writes.push(res);
220
+ graph._declareFramebufferAttachmentDeps(pass, desc);
221
+ return new RGHandle(id, name);
222
+ },
169
223
  sideEffect () {
170
224
  pass.hasSideEffect = true;
171
225
  },
226
+ addSubpass (name, fn) {
227
+ if (pass.executeFn) {
228
+ throw new Error(`RenderGraph: pass "${pass.name}" cannot use addSubpass() after setExecute(). ` + `Use either subpasses or a single execute callback.`);
229
+ }
230
+ pass.subpasses.push(new RGSubpass(name, fn));
231
+ },
172
232
  setExecute (fn) {
233
+ if (pass.subpasses.length > 0) {
234
+ throw new Error(`RenderGraph: pass "${pass.name}" cannot use setExecute() after addSubpass(). ` + `Use either subpasses or a single execute callback.`);
235
+ }
173
236
  pass.executeFn = fn;
174
237
  }
175
238
  };
176
239
  }
177
240
  // ─── Private: Dead Pass Culling ─────────────────────────────────────
241
+ /** @internal */ _validateOutputs(outputs) {
242
+ const latestVersions = new Map();
243
+ for (const res of this._resources.values()){
244
+ const current = latestVersions.get(res.physicalId);
245
+ if (!current || res.id > current.id) {
246
+ latestVersions.set(res.physicalId, res);
247
+ }
248
+ }
249
+ for (const handle of outputs){
250
+ const res = this._resources.get(handle._id);
251
+ if (!res) {
252
+ throw new Error(`RenderGraph: unknown output resource "${handle.name}" (id=${handle._id})`);
253
+ }
254
+ const latest = latestVersions.get(res.physicalId);
255
+ if (latest && latest.id !== res.id) {
256
+ throw new Error(`RenderGraph: output resource "${res.name}" (id=${res.id}) is not the latest version. ` + `Use the handle returned by builder.write(); latest is "${latest.name}" (id=${latest.id}).`);
257
+ }
258
+ }
259
+ }
178
260
  /** @internal */ _cullDeadPasses(outputs) {
179
261
  // Start with all passes marked dead
180
262
  for (const pass of this._passes){
@@ -183,23 +265,35 @@ import { RGHandle, RGPass, RGResource } from './types.js';
183
265
  // Seed: resources that are requested outputs
184
266
  const neededResources = new Set();
185
267
  const stack = [];
186
- for (const handle of outputs){
187
- const res = this._resources.get(handle._id);
188
- if (res) {
268
+ const markResourceNeeded = (res)=>{
269
+ if (!neededResources.has(res.id)) {
189
270
  neededResources.add(res.id);
190
271
  stack.push(res);
191
272
  }
273
+ };
274
+ const markPassAlive = (pass)=>{
275
+ if (pass.alive) {
276
+ return;
277
+ }
278
+ pass.alive = true;
279
+ for (const dep of pass.reads){
280
+ markResourceNeeded(dep);
281
+ }
282
+ for (const dependency of pass.dependencies){
283
+ markPassAlive(dependency);
284
+ }
285
+ };
286
+ for (const handle of outputs){
287
+ const res = this._resources.get(handle._id);
288
+ if (!res) {
289
+ throw new Error(`RenderGraph: unknown output resource "${handle.name}" (id=${handle._id})`);
290
+ }
291
+ markResourceNeeded(res);
192
292
  }
193
293
  // Seed: side-effect passes (always alive) — push their read dependencies
194
294
  for (const pass of this._passes){
195
295
  if (pass.hasSideEffect) {
196
- pass.alive = true;
197
- for (const res of pass.reads){
198
- if (!neededResources.has(res.id)) {
199
- neededResources.add(res.id);
200
- stack.push(res);
201
- }
202
- }
296
+ markPassAlive(pass);
203
297
  }
204
298
  }
205
299
  // Backward traversal: for each needed resource, mark its producer alive
@@ -207,16 +301,38 @@ import { RGHandle, RGPass, RGResource } from './types.js';
207
301
  while(stack.length > 0){
208
302
  const res = stack.pop();
209
303
  const producer = res.producer;
210
- if (producer && !producer.alive) {
211
- producer.alive = true;
212
- for (const dep of producer.reads){
213
- if (!neededResources.has(dep.id)) {
214
- neededResources.add(dep.id);
215
- stack.push(dep);
304
+ if (producer) {
305
+ markPassAlive(producer);
306
+ }
307
+ }
308
+ }
309
+ /** @internal */ _declareFramebufferAttachmentDeps(pass, desc) {
310
+ const declare = (attachment)=>{
311
+ if (attachment instanceof RGHandle) {
312
+ const res = this._resources.get(attachment._id);
313
+ if (!res) {
314
+ throw new Error(`RenderGraph: unknown framebuffer attachment "${attachment.name}" (id=${attachment._id})`);
315
+ }
316
+ if (res.kind !== 'transient' && res.kind !== 'imported') {
317
+ throw new Error(`RenderGraph: framebuffer attachment "${res.name}" must be a texture resource, got ${res.kind}.`);
318
+ }
319
+ if (res.producer !== pass) {
320
+ if (!pass.reads.includes(res)) {
321
+ pass.reads.push(res);
322
+ }
323
+ if (!res.consumers.includes(pass)) {
324
+ res.consumers.push(pass);
216
325
  }
217
326
  }
218
327
  }
328
+ };
329
+ const colors = Array.isArray(desc.colorAttachments) ? desc.colorAttachments : desc.colorAttachments ? [
330
+ desc.colorAttachments
331
+ ] : [];
332
+ for (const attachment of colors){
333
+ declare(attachment);
219
334
  }
335
+ declare(desc.depthAttachment);
220
336
  }
221
337
  // ─── Private: Topological Sort (Kahn's Algorithm) ───────────────────
222
338
  /** @internal */ _topologicalSort() {
@@ -232,17 +348,28 @@ import { RGHandle, RGPass, RGResource } from './types.js';
232
348
  inDegree.set(pass, 0);
233
349
  adjacency.set(pass, []);
234
350
  }
351
+ const addEdge = (from, to)=>{
352
+ if (from === to || !aliveSet.has(from) || !aliveSet.has(to)) {
353
+ return;
354
+ }
355
+ const neighbors = adjacency.get(from);
356
+ if (!neighbors.includes(to)) {
357
+ neighbors.push(to);
358
+ inDegree.set(to, inDegree.get(to) + 1);
359
+ }
360
+ };
361
+ for (const pass of alivePasses){
362
+ for (const dependency of pass.dependencies){
363
+ addEdge(dependency, pass);
364
+ }
365
+ }
235
366
  // For each resource, its producer has an edge to each of its consumers
236
367
  for (const res of this._resources.values()){
237
368
  if (!res.producer || !aliveSet.has(res.producer)) {
238
369
  continue;
239
370
  }
240
371
  for (const consumer of res.consumers){
241
- if (!aliveSet.has(consumer)) {
242
- continue;
243
- }
244
- adjacency.get(res.producer).push(consumer);
245
- inDegree.set(consumer, inDegree.get(consumer) + 1);
372
+ addEdge(res.producer, consumer);
246
373
  }
247
374
  }
248
375
  // Kahn's algorithm
@@ -1 +1 @@
1
- {"version":3,"file":"rendergraph.js","sources":["../../../src/render/rendergraph/rendergraph.ts"],"sourcesContent":["import {\r\n RGHandle,\r\n RGResource,\r\n RGPass,\r\n type RGTextureDesc,\r\n type RGPassBuilder,\r\n type RGExecuteFn,\r\n type RGExecuteContext,\r\n type CompiledRenderGraph,\r\n type RGResourceLifetime\r\n} from './types';\r\n\r\n/**\r\n * Render Graph — declarative, configurable render pipeline.\r\n *\r\n * Usage:\r\n * ```ts\r\n * const graph = new RenderGraph();\r\n * const backbuffer = graph.importTexture('backbuffer');\r\n *\r\n * let linearDepth: RGHandle;\r\n * graph.addPass('DepthPrepass', (builder) => {\r\n * linearDepth = builder.createTexture({ format: 'r32f', label: 'linearDepth' });\r\n * builder.setExecute(() => { ... });\r\n * });\r\n *\r\n * graph.addPass('LightPass', (builder) => {\r\n * builder.read(linearDepth);\r\n * builder.write(backbuffer);\r\n * builder.setExecute(() => { ... });\r\n * });\r\n *\r\n * const compiled = graph.compile([backbuffer]);\r\n * graph.execute(compiled);\r\n * graph.reset();\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class RenderGraph {\r\n /** @internal */\r\n private _nextResourceId = 0;\r\n /** @internal */\r\n private _resources: Map<number, RGResource> = new Map();\r\n /** @internal */\r\n private _passes: RGPass[] = [];\r\n /** @internal */\r\n private _compiled: CompiledRenderGraph | null = null;\r\n\r\n // ─── Graph Building ─────────────────────────────────────────────────\r\n\r\n /**\r\n * Import an external (persistent) texture into the graph.\r\n *\r\n * Imported resources are not allocated or released by the graph.\r\n * Typically used for the backbuffer or any texture that outlives a single frame.\r\n *\r\n * @param name - Debug label for the imported resource.\r\n * @returns A handle referencing the imported resource.\r\n */\r\n importTexture(name: string): RGHandle {\r\n const id = this._nextResourceId++;\r\n const resource = new RGResource(id, name, 'imported', null);\r\n this._resources.set(id, resource);\r\n this._compiled = null;\r\n return new RGHandle(id, name);\r\n }\r\n\r\n /**\r\n * Add a render pass to the graph.\r\n *\r\n * The setup callback receives a {@link RGPassBuilder} to declare resource\r\n * dependencies. Call `builder.setExecute(fn)` inside setup to provide the\r\n * execution callback.\r\n *\r\n * @param name - Debug label for the pass.\r\n * @param setup - Setup callback that declares resources and sets the execute function.\r\n */\r\n addPass<T = void>(name: string, setup: (builder: RGPassBuilder) => T): T {\r\n const pass = new RGPass(this._passes.length, name);\r\n const builder = this._createBuilder(pass);\r\n const data = setup(builder);\r\n pass.data = data;\r\n this._passes.push(pass);\r\n this._compiled = null;\r\n return data;\r\n }\r\n\r\n // ─── Compilation ────────────────────────────────────────────────────\r\n\r\n /**\r\n * Compile the render graph.\r\n *\r\n * Performs dead-pass culling, topological sorting, and resource lifetime analysis.\r\n *\r\n * @param outputs - Handles of resources that must be produced (graph sinks).\r\n * Passes that do not contribute to these outputs (directly or transitively)\r\n * are culled, unless marked as side-effect passes.\r\n * @returns The compiled graph ready for execution.\r\n */\r\n compile(outputs: RGHandle[]): CompiledRenderGraph {\r\n if (this._compiled) {\r\n return this._compiled;\r\n }\r\n // 1. Mark alive passes via backward traversal from outputs + side-effect passes\r\n this._cullDeadPasses(outputs);\r\n // 2. Topological sort of alive passes\r\n const ordered = this._topologicalSort();\r\n // 3. Resource lifetime analysis\r\n const lifetimes = this._analyzeLifetimes(ordered);\r\n\r\n this._compiled = { orderedPasses: ordered, lifetimes };\r\n return this._compiled;\r\n }\r\n\r\n /**\r\n * Execute a compiled render graph (simple mode, no resource management).\r\n *\r\n * For automatic resource allocation/release, use {@link RenderGraphExecutor} instead.\r\n *\r\n * @param compiled - The compiled graph from {@link compile}.\r\n */\r\n execute(compiled: CompiledRenderGraph): void {\r\n const noopCtx: RGExecuteContext = {\r\n getTexture() {\r\n throw new Error(\r\n 'RenderGraph.execute(): resource resolution not available. Use RenderGraphExecutor for managed execution.'\r\n );\r\n }\r\n };\r\n for (const pass of compiled.orderedPasses) {\r\n if (pass.executeFn) {\r\n (pass.executeFn as RGExecuteFn<unknown>)(noopCtx, pass.data);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Reset the graph for the next frame.\r\n *\r\n * Clears all passes, transient resources, and compiled state.\r\n * Imported resources are also cleared — re-import them each frame.\r\n */\r\n reset(): void {\r\n this._passes.length = 0;\r\n this._resources.clear();\r\n this._nextResourceId = 0;\r\n this._compiled = null;\r\n }\r\n\r\n // ─── Accessors (for testing / debugging) ────────────────────────────\r\n\r\n /** @internal */\r\n getResource(handle: RGHandle): RGResource | undefined {\r\n return this._resources.get(handle._id);\r\n }\r\n\r\n /** @internal */\r\n get passes(): ReadonlyArray<RGPass> {\r\n return this._passes;\r\n }\r\n\r\n /** @internal */\r\n get resources(): ReadonlyMap<number, RGResource> {\r\n return this._resources;\r\n }\r\n\r\n // ─── Private: Builder ───────────────────────────────────────────────\r\n\r\n /** @internal */\r\n private _createBuilder(pass: RGPass): RGPassBuilder {\r\n const graph = this;\r\n return {\r\n read(handle: RGHandle): void {\r\n const res = graph._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n // Validate that transient resources have a producer\r\n if (res.kind === 'transient' && !res.producer) {\r\n throw new Error(\r\n `RenderGraph: pass \"${pass.name}\" attempts to read transient resource \"${res.name}\" ` +\r\n `which has no producer. Ensure the resource is created before being read.`\r\n );\r\n }\r\n pass.reads.push(res);\r\n res.consumers.push(pass);\r\n },\r\n write(handle: RGHandle): void {\r\n const res = graph._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n if (res.producer && res.producer !== pass) {\r\n throw new Error(\r\n `RenderGraph: resource \"${res.name}\" already produced by pass \"${res.producer.name}\", ` +\r\n `cannot be written by pass \"${pass.name}\"`\r\n );\r\n }\r\n res.producer = pass;\r\n pass.writes.push(res);\r\n },\r\n createTexture(desc: RGTextureDesc): RGHandle {\r\n const id = graph._nextResourceId++;\r\n const name = desc.label ?? `_tex_${id}`;\r\n const res = new RGResource(id, name, 'transient', desc);\r\n res.producer = pass;\r\n graph._resources.set(id, res);\r\n pass.writes.push(res);\r\n return new RGHandle(id, name);\r\n },\r\n sideEffect(): void {\r\n pass.hasSideEffect = true;\r\n },\r\n setExecute<D>(fn: RGExecuteFn<D>): void {\r\n pass.executeFn = fn as RGExecuteFn<unknown>;\r\n }\r\n };\r\n }\r\n\r\n // ─── Private: Dead Pass Culling ─────────────────────────────────────\r\n\r\n /** @internal */\r\n private _cullDeadPasses(outputs: RGHandle[]): void {\r\n // Start with all passes marked dead\r\n for (const pass of this._passes) {\r\n pass.alive = false;\r\n }\r\n\r\n // Seed: resources that are requested outputs\r\n const neededResources = new Set<number>();\r\n const stack: RGResource[] = [];\r\n\r\n for (const handle of outputs) {\r\n const res = this._resources.get(handle._id);\r\n if (res) {\r\n neededResources.add(res.id);\r\n stack.push(res);\r\n }\r\n }\r\n\r\n // Seed: side-effect passes (always alive) — push their read dependencies\r\n for (const pass of this._passes) {\r\n if (pass.hasSideEffect) {\r\n pass.alive = true;\r\n for (const res of pass.reads) {\r\n if (!neededResources.has(res.id)) {\r\n neededResources.add(res.id);\r\n stack.push(res);\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Backward traversal: for each needed resource, mark its producer alive\r\n // and recursively mark the producer's read dependencies as needed\r\n while (stack.length > 0) {\r\n const res = stack.pop()!;\r\n const producer = res.producer;\r\n if (producer && !producer.alive) {\r\n producer.alive = true;\r\n for (const dep of producer.reads) {\r\n if (!neededResources.has(dep.id)) {\r\n neededResources.add(dep.id);\r\n stack.push(dep);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // ─── Private: Topological Sort (Kahn's Algorithm) ───────────────────\r\n\r\n /** @internal */\r\n private _topologicalSort(): RGPass[] {\r\n const alivePasses = this._passes.filter((p) => p.alive);\r\n if (alivePasses.length === 0) {\r\n return [];\r\n }\r\n\r\n // Build adjacency: producer -> consumers (only among alive passes)\r\n const aliveSet = new Set(alivePasses);\r\n const inDegree = new Map<RGPass, number>();\r\n const adjacency = new Map<RGPass, RGPass[]>();\r\n\r\n for (const pass of alivePasses) {\r\n inDegree.set(pass, 0);\r\n adjacency.set(pass, []);\r\n }\r\n\r\n // For each resource, its producer has an edge to each of its consumers\r\n for (const res of this._resources.values()) {\r\n if (!res.producer || !aliveSet.has(res.producer)) {\r\n continue;\r\n }\r\n for (const consumer of res.consumers) {\r\n if (!aliveSet.has(consumer)) {\r\n continue;\r\n }\r\n adjacency.get(res.producer)!.push(consumer);\r\n inDegree.set(consumer, inDegree.get(consumer)! + 1);\r\n }\r\n }\r\n\r\n // Kahn's algorithm\r\n const queue: RGPass[] = [];\r\n for (const pass of alivePasses) {\r\n if (inDegree.get(pass) === 0) {\r\n queue.push(pass);\r\n }\r\n }\r\n\r\n const result: RGPass[] = [];\r\n while (queue.length > 0) {\r\n const pass = queue.shift()!;\r\n result.push(pass);\r\n for (const neighbor of adjacency.get(pass)!) {\r\n const deg = inDegree.get(neighbor)! - 1;\r\n inDegree.set(neighbor, deg);\r\n if (deg === 0) {\r\n queue.push(neighbor);\r\n }\r\n }\r\n }\r\n\r\n if (result.length !== alivePasses.length) {\r\n // Find passes that are part of the cycle (those with non-zero in-degree)\r\n const cycleParticipants: string[] = [];\r\n for (const [pass, degree] of inDegree) {\r\n if (degree > 0) {\r\n cycleParticipants.push(pass.name);\r\n }\r\n }\r\n throw new Error(\r\n `RenderGraph: circular dependency detected. ` +\r\n `Sorted ${result.length} of ${alivePasses.length} alive passes. ` +\r\n `Passes in cycle: [${cycleParticipants.join(', ')}]`\r\n );\r\n }\r\n\r\n return result;\r\n }\r\n\r\n // ─── Private: Resource Lifetime Analysis ────────────────────────────\r\n\r\n /** @internal */\r\n private _analyzeLifetimes(orderedPasses: RGPass[]): Map<number, RGResourceLifetime> {\r\n const lifetimes = new Map<number, RGResourceLifetime>();\r\n\r\n // Build pass -> order index map\r\n const orderMap = new Map<RGPass, number>();\r\n for (let i = 0; i < orderedPasses.length; i++) {\r\n orderMap.set(orderedPasses[i], i);\r\n }\r\n\r\n for (const res of this._resources.values()) {\r\n let first = Infinity;\r\n let last = -Infinity;\r\n\r\n // Producer\r\n if (res.producer && orderMap.has(res.producer)) {\r\n const idx = orderMap.get(res.producer)!;\r\n first = Math.min(first, idx);\r\n last = Math.max(last, idx);\r\n }\r\n\r\n // Consumers\r\n for (const consumer of res.consumers) {\r\n if (orderMap.has(consumer)) {\r\n const idx = orderMap.get(consumer)!;\r\n first = Math.min(first, idx);\r\n last = Math.max(last, idx);\r\n }\r\n }\r\n\r\n if (first !== Infinity) {\r\n lifetimes.set(res.id, { resource: res, firstUse: first, lastUse: last });\r\n }\r\n }\r\n\r\n return lifetimes;\r\n }\r\n}\r\n"],"names":["RenderGraph","_nextResourceId","_resources","Map","_passes","_compiled","importTexture","name","id","resource","RGResource","set","RGHandle","addPass","setup","pass","RGPass","length","builder","_createBuilder","data","push","compile","outputs","_cullDeadPasses","ordered","_topologicalSort","lifetimes","_analyzeLifetimes","orderedPasses","execute","compiled","noopCtx","getTexture","Error","executeFn","reset","clear","getResource","handle","get","_id","passes","resources","graph","read","res","kind","producer","reads","consumers","write","writes","createTexture","desc","label","sideEffect","hasSideEffect","setExecute","fn","alive","neededResources","Set","stack","add","has","pop","dep","alivePasses","filter","p","aliveSet","inDegree","adjacency","values","consumer","queue","result","shift","neighbor","deg","cycleParticipants","degree","join","orderMap","i","first","Infinity","last","idx","Math","min","max","firstUse","lastUse"],"mappings":";;AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BC,IACM,MAAMA,WAAAA,CAAAA;qBAEX,eAAQC,GAAkB,CAAE;AAC5B,qBACQC,UAAsC,GAAA,IAAIC,GAAM,EAAA;AACxD,qBACQC,OAAoB,GAAA,EAAE;qBAE9B,SAAQC,GAAwC,IAAK;;AAIrD;;;;;;;;MASAC,aAAAA,CAAcC,IAAY,EAAY;QACpC,MAAMC,EAAAA,GAAK,IAAI,CAACP,eAAe,EAAA;AAC/B,QAAA,MAAMQ,QAAW,GAAA,IAAIC,UAAWF,CAAAA,EAAAA,EAAID,MAAM,UAAY,EAAA,IAAA,CAAA;AACtD,QAAA,IAAI,CAACL,UAAU,CAACS,GAAG,CAACH,EAAIC,EAAAA,QAAAA,CAAAA;QACxB,IAAI,CAACJ,SAAS,GAAG,IAA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ph/rendergraph.ts"],"sourcesContent":["import {\r\n RGHandle,\r\n RGResource,\r\n RGPass,\r\n RGSubpass,\r\n type RGTextureDesc,\r\n type RGPassBuilder,\r\n type RGExecuteFn,\r\n type RGExecuteContext,\r\n type CompiledRenderGraph,\r\n type RGResourceLifetime\r\n} from './types';\r\n\r\n/**\r\n * Render Graph — declarative, configurable render pipeline.\r\n *\r\n * Usage:\r\n * ```ts\r\n * const graph = new RenderGraph();\r\n * let backbuffer = graph.importTexture('backbuffer');\r\n *\r\n * let linearDepth: RGHandle;\r\n * graph.addPass('DepthPrepass', (builder) => {\r\n * linearDepth = builder.createTexture({ format: 'r32f', label: 'linearDepth' });\r\n * builder.setExecute(() => { ... });\r\n * });\r\n *\r\n * graph.addPass('LightPass', (builder) => {\r\n * builder.read(linearDepth);\r\n * backbuffer = builder.write(backbuffer);\r\n * builder.setExecute(() => { ... });\r\n * });\r\n *\r\n * const compiled = graph.compile([backbuffer]);\r\n * graph.execute(compiled);\r\n * graph.reset();\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class RenderGraph {\r\n /** @internal */\r\n private _nextResourceId = 0;\r\n /** @internal */\r\n private _resources: Map<number, RGResource> = new Map();\r\n /** @internal */\r\n private _passes: RGPass[] = [];\r\n /** @internal */\r\n private _compiled: CompiledRenderGraph | null = null;\r\n\r\n // ─── Graph Building ─────────────────────────────────────────────────\r\n\r\n /**\r\n * Import an external (persistent) texture into the graph.\r\n *\r\n * Imported resources are not allocated or released by the graph.\r\n * Typically used for the backbuffer or any texture that outlives a single frame.\r\n *\r\n * @param name - Debug label for the imported resource.\r\n * @returns A handle referencing the imported resource.\r\n */\r\n importTexture(name: string): RGHandle {\r\n const id = this._nextResourceId++;\r\n const resource = new RGResource(id, name, 'imported', null);\r\n this._resources.set(id, resource);\r\n this._compiled = null;\r\n return new RGHandle(id, name);\r\n }\r\n\r\n /**\r\n * Add a render pass to the graph.\r\n *\r\n * The setup callback receives a {@link RGPassBuilder} to declare resource\r\n * dependencies. Call `builder.setExecute(fn)` inside setup to provide the\r\n * execution callback.\r\n *\r\n * @param name - Debug label for the pass.\r\n * @param setup - Setup callback that declares resources and sets the execute function.\r\n */\r\n addPass<T = void>(name: string, setup: (builder: RGPassBuilder) => T): T {\r\n const pass = new RGPass(this._passes.length, name);\r\n const builder = this._createBuilder(pass);\r\n const data = setup(builder);\r\n pass.data = data;\r\n this._passes.push(pass);\r\n this._compiled = null;\r\n return data;\r\n }\r\n\r\n // ─── Compilation ────────────────────────────────────────────────────\r\n\r\n /**\r\n * Compile the render graph.\r\n *\r\n * Performs dead-pass culling, topological sorting, and resource lifetime analysis.\r\n *\r\n * @param outputs - Handles of resources that must be produced (graph sinks).\r\n * If a resource was passed to {@link RGPassBuilder.write}, use the returned\r\n * post-write handle here, not the original handle.\r\n * Passes that do not contribute to these outputs (directly or transitively)\r\n * are culled, unless marked as side-effect passes.\r\n * @returns The compiled graph ready for execution.\r\n */\r\n compile(outputs: RGHandle[]): CompiledRenderGraph {\r\n this._validateOutputs(outputs);\r\n // 1. Mark alive passes via backward traversal from outputs + side-effect passes\r\n this._cullDeadPasses(outputs);\r\n // 2. Topological sort of alive passes\r\n const ordered = this._topologicalSort();\r\n // 3. Resource lifetime analysis\r\n const lifetimes = this._analyzeLifetimes(ordered);\r\n\r\n this._compiled = { orderedPasses: ordered, lifetimes };\r\n return this._compiled;\r\n }\r\n\r\n /**\r\n * Execute a compiled render graph (simple mode, no resource management).\r\n *\r\n * For automatic resource allocation/release, use {@link RenderGraphExecutor} instead.\r\n *\r\n * @param compiled - The compiled graph from {@link RenderGraph.compile}.\r\n */\r\n execute(compiled: CompiledRenderGraph): void {\r\n const noopCtx: RGExecuteContext = {\r\n getTexture() {\r\n throw new Error(\r\n 'RenderGraph.execute(): resource resolution not available. Use RenderGraphExecutor for managed execution.'\r\n );\r\n },\r\n getFramebuffer() {\r\n throw new Error(\r\n 'RenderGraph.execute(): framebuffer resolution not available. Use RenderGraphExecutor for managed execution.'\r\n );\r\n },\r\n createFramebuffer() {\r\n throw new Error(\r\n 'RenderGraph.execute(): framebuffer allocation not available. Use RenderGraphExecutor for managed execution.'\r\n );\r\n },\r\n deferCleanup() {\r\n // No-op in unmanaged execution mode.\r\n }\r\n };\r\n for (const pass of compiled.orderedPasses) {\r\n if (pass.subpasses.length > 0) {\r\n for (const subpass of pass.subpasses) {\r\n (subpass.executeFn as RGExecuteFn<unknown>)(noopCtx, pass.data);\r\n }\r\n } else if (pass.executeFn) {\r\n (pass.executeFn as RGExecuteFn<unknown>)(noopCtx, pass.data);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Reset the graph for the next frame.\r\n *\r\n * Clears all passes, transient resources, and compiled state.\r\n * Imported resources are also cleared — re-import them each frame.\r\n */\r\n reset(): void {\r\n this._passes.length = 0;\r\n this._resources.clear();\r\n this._nextResourceId = 0;\r\n this._compiled = null;\r\n }\r\n\r\n // ─── Accessors (for testing / debugging) ────────────────────────────\r\n\r\n /** @internal */\r\n getResource(handle: RGHandle): RGResource | undefined {\r\n return this._resources.get(handle._id);\r\n }\r\n\r\n /** @internal */\r\n get passes(): ReadonlyArray<RGPass> {\r\n return this._passes;\r\n }\r\n\r\n /** @internal */\r\n get resources(): ReadonlyMap<number, RGResource> {\r\n return this._resources;\r\n }\r\n\r\n // ─── Private: Builder ───────────────────────────────────────────────\r\n\r\n /** @internal */\r\n private _createBuilder(pass: RGPass): RGPassBuilder {\r\n const graph = this;\r\n return {\r\n read(handle: RGHandle): void {\r\n const res = graph._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n // Validate that transient resources have a producer\r\n if (res.kind === 'transient' && !res.producer) {\r\n throw new Error(\r\n `RenderGraph: pass \"${pass.name}\" attempts to read transient resource \"${res.name}\" ` +\r\n `which has no producer. Ensure the resource is created before being read.`\r\n );\r\n }\r\n if (!pass.reads.includes(res)) {\r\n pass.reads.push(res);\r\n }\r\n if (!res.consumers.includes(pass)) {\r\n res.consumers.push(pass);\r\n }\r\n },\r\n write(handle: RGHandle): RGHandle {\r\n const res = graph._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n if (res.kind === 'token') {\r\n throw new Error(\r\n `RenderGraph: pass \"${pass.name}\" attempts to write token \"${res.name}\". ` +\r\n `Use createToken() to produce ordering tokens.`\r\n );\r\n }\r\n if (res.kind === 'framebuffer') {\r\n throw new Error(\r\n `RenderGraph: pass \"${pass.name}\" attempts to write framebuffer \"${res.name}\". ` +\r\n `Create a new framebuffer view instead.`\r\n );\r\n }\r\n for (const consumer of res.consumers) {\r\n if (consumer !== pass && !pass.dependencies.includes(consumer)) {\r\n pass.dependencies.push(consumer);\r\n }\r\n }\r\n if (res.producer && res.producer !== pass && !pass.dependencies.includes(res.producer)) {\r\n pass.dependencies.push(res.producer);\r\n }\r\n const id = graph._nextResourceId++;\r\n const versionName = `${res.name}@${pass.name}`;\r\n const version = new RGResource(id, versionName, res.kind, res.desc, res.physicalId);\r\n version.producer = pass;\r\n graph._resources.set(id, version);\r\n if (!pass.writes.includes(version)) {\r\n pass.writes.push(version);\r\n }\r\n return new RGHandle(id, versionName);\r\n },\r\n createTexture(desc: RGTextureDesc): RGHandle {\r\n const id = graph._nextResourceId++;\r\n const name = desc.label ?? `_tex_${id}`;\r\n const res = new RGResource(id, name, 'transient', desc);\r\n res.producer = pass;\r\n graph._resources.set(id, res);\r\n pass.writes.push(res);\r\n return new RGHandle(id, name);\r\n },\r\n createToken(name?: string): RGHandle {\r\n const id = graph._nextResourceId++;\r\n const tokenName = name ?? `_token_${id}`;\r\n const res = new RGResource(id, tokenName, 'token', null);\r\n res.producer = pass;\r\n graph._resources.set(id, res);\r\n pass.writes.push(res);\r\n return new RGHandle(id, tokenName);\r\n },\r\n createFramebuffer(desc): RGHandle {\r\n const id = graph._nextResourceId++;\r\n const name = desc.label ?? `_fb_${id}`;\r\n const res = new RGResource(id, name, 'framebuffer', desc);\r\n res.producer = pass;\r\n graph._resources.set(id, res);\r\n pass.writes.push(res);\r\n graph._declareFramebufferAttachmentDeps(pass, desc);\r\n return new RGHandle(id, name);\r\n },\r\n sideEffect(): void {\r\n pass.hasSideEffect = true;\r\n },\r\n addSubpass<D>(name: string, fn: RGExecuteFn<D>): void {\r\n if (pass.executeFn) {\r\n throw new Error(\r\n `RenderGraph: pass \"${pass.name}\" cannot use addSubpass() after setExecute(). ` +\r\n `Use either subpasses or a single execute callback.`\r\n );\r\n }\r\n pass.subpasses.push(new RGSubpass(name, fn as RGExecuteFn<unknown>));\r\n },\r\n setExecute<D>(fn: RGExecuteFn<D>): void {\r\n if (pass.subpasses.length > 0) {\r\n throw new Error(\r\n `RenderGraph: pass \"${pass.name}\" cannot use setExecute() after addSubpass(). ` +\r\n `Use either subpasses or a single execute callback.`\r\n );\r\n }\r\n pass.executeFn = fn as RGExecuteFn<unknown>;\r\n }\r\n };\r\n }\r\n\r\n // ─── Private: Dead Pass Culling ─────────────────────────────────────\r\n\r\n /** @internal */\r\n private _validateOutputs(outputs: RGHandle[]): void {\r\n const latestVersions = new Map<number, RGResource>();\r\n for (const res of this._resources.values()) {\r\n const current = latestVersions.get(res.physicalId);\r\n if (!current || res.id > current.id) {\r\n latestVersions.set(res.physicalId, res);\r\n }\r\n }\r\n\r\n for (const handle of outputs) {\r\n const res = this._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown output resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n const latest = latestVersions.get(res.physicalId);\r\n if (latest && latest.id !== res.id) {\r\n throw new Error(\r\n `RenderGraph: output resource \"${res.name}\" (id=${res.id}) is not the latest version. ` +\r\n `Use the handle returned by builder.write(); latest is \"${latest.name}\" (id=${latest.id}).`\r\n );\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n private _cullDeadPasses(outputs: RGHandle[]): void {\r\n // Start with all passes marked dead\r\n for (const pass of this._passes) {\r\n pass.alive = false;\r\n }\r\n\r\n // Seed: resources that are requested outputs\r\n const neededResources = new Set<number>();\r\n const stack: RGResource[] = [];\r\n const markResourceNeeded = (res: RGResource) => {\r\n if (!neededResources.has(res.id)) {\r\n neededResources.add(res.id);\r\n stack.push(res);\r\n }\r\n };\r\n const markPassAlive = (pass: RGPass) => {\r\n if (pass.alive) {\r\n return;\r\n }\r\n pass.alive = true;\r\n for (const dep of pass.reads) {\r\n markResourceNeeded(dep);\r\n }\r\n for (const dependency of pass.dependencies) {\r\n markPassAlive(dependency);\r\n }\r\n };\r\n\r\n for (const handle of outputs) {\r\n const res = this._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown output resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n markResourceNeeded(res);\r\n }\r\n\r\n // Seed: side-effect passes (always alive) — push their read dependencies\r\n for (const pass of this._passes) {\r\n if (pass.hasSideEffect) {\r\n markPassAlive(pass);\r\n }\r\n }\r\n\r\n // Backward traversal: for each needed resource, mark its producer alive\r\n // and recursively mark the producer's read dependencies as needed\r\n while (stack.length > 0) {\r\n const res = stack.pop()!;\r\n const producer = res.producer;\r\n if (producer) {\r\n markPassAlive(producer);\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n private _declareFramebufferAttachmentDeps(\r\n pass: RGPass,\r\n desc: { colorAttachments: unknown | unknown[] | null; depthAttachment?: unknown | null }\r\n ): void {\r\n const declare = (attachment: unknown) => {\r\n if (attachment instanceof RGHandle) {\r\n const res = this._resources.get(attachment._id);\r\n if (!res) {\r\n throw new Error(\r\n `RenderGraph: unknown framebuffer attachment \"${attachment.name}\" (id=${attachment._id})`\r\n );\r\n }\r\n if (res.kind !== 'transient' && res.kind !== 'imported') {\r\n throw new Error(\r\n `RenderGraph: framebuffer attachment \"${res.name}\" must be a texture resource, got ${res.kind}.`\r\n );\r\n }\r\n if (res.producer !== pass) {\r\n if (!pass.reads.includes(res)) {\r\n pass.reads.push(res);\r\n }\r\n if (!res.consumers.includes(pass)) {\r\n res.consumers.push(pass);\r\n }\r\n }\r\n }\r\n };\r\n const colors = Array.isArray(desc.colorAttachments)\r\n ? desc.colorAttachments\r\n : desc.colorAttachments\r\n ? [desc.colorAttachments]\r\n : [];\r\n for (const attachment of colors) {\r\n declare(attachment);\r\n }\r\n declare(desc.depthAttachment);\r\n }\r\n\r\n // ─── Private: Topological Sort (Kahn's Algorithm) ───────────────────\r\n\r\n /** @internal */\r\n private _topologicalSort(): RGPass[] {\r\n const alivePasses = this._passes.filter((p) => p.alive);\r\n if (alivePasses.length === 0) {\r\n return [];\r\n }\r\n\r\n // Build adjacency: producer -> consumers (only among alive passes)\r\n const aliveSet = new Set(alivePasses);\r\n const inDegree = new Map<RGPass, number>();\r\n const adjacency = new Map<RGPass, RGPass[]>();\r\n\r\n for (const pass of alivePasses) {\r\n inDegree.set(pass, 0);\r\n adjacency.set(pass, []);\r\n }\r\n\r\n const addEdge = (from: RGPass, to: RGPass) => {\r\n if (from === to || !aliveSet.has(from) || !aliveSet.has(to)) {\r\n return;\r\n }\r\n const neighbors = adjacency.get(from)!;\r\n if (!neighbors.includes(to)) {\r\n neighbors.push(to);\r\n inDegree.set(to, inDegree.get(to)! + 1);\r\n }\r\n };\r\n\r\n for (const pass of alivePasses) {\r\n for (const dependency of pass.dependencies) {\r\n addEdge(dependency, pass);\r\n }\r\n }\r\n\r\n // For each resource, its producer has an edge to each of its consumers\r\n for (const res of this._resources.values()) {\r\n if (!res.producer || !aliveSet.has(res.producer)) {\r\n continue;\r\n }\r\n for (const consumer of res.consumers) {\r\n addEdge(res.producer, consumer);\r\n }\r\n }\r\n\r\n // Kahn's algorithm\r\n const queue: RGPass[] = [];\r\n for (const pass of alivePasses) {\r\n if (inDegree.get(pass) === 0) {\r\n queue.push(pass);\r\n }\r\n }\r\n\r\n const result: RGPass[] = [];\r\n while (queue.length > 0) {\r\n const pass = queue.shift()!;\r\n result.push(pass);\r\n for (const neighbor of adjacency.get(pass)!) {\r\n const deg = inDegree.get(neighbor)! - 1;\r\n inDegree.set(neighbor, deg);\r\n if (deg === 0) {\r\n queue.push(neighbor);\r\n }\r\n }\r\n }\r\n\r\n if (result.length !== alivePasses.length) {\r\n // Find passes that are part of the cycle (those with non-zero in-degree)\r\n const cycleParticipants: string[] = [];\r\n for (const [pass, degree] of inDegree) {\r\n if (degree > 0) {\r\n cycleParticipants.push(pass.name);\r\n }\r\n }\r\n throw new Error(\r\n `RenderGraph: circular dependency detected. ` +\r\n `Sorted ${result.length} of ${alivePasses.length} alive passes. ` +\r\n `Passes in cycle: [${cycleParticipants.join(', ')}]`\r\n );\r\n }\r\n\r\n return result;\r\n }\r\n\r\n // ─── Private: Resource Lifetime Analysis ────────────────────────────\r\n\r\n /** @internal */\r\n private _analyzeLifetimes(orderedPasses: RGPass[]): Map<number, RGResourceLifetime> {\r\n const lifetimes = new Map<number, RGResourceLifetime>();\r\n\r\n // Build pass -> order index map\r\n const orderMap = new Map<RGPass, number>();\r\n for (let i = 0; i < orderedPasses.length; i++) {\r\n orderMap.set(orderedPasses[i], i);\r\n }\r\n\r\n for (const res of this._resources.values()) {\r\n let first = Infinity;\r\n let last = -Infinity;\r\n\r\n // Producer\r\n if (res.producer && orderMap.has(res.producer)) {\r\n const idx = orderMap.get(res.producer)!;\r\n first = Math.min(first, idx);\r\n last = Math.max(last, idx);\r\n }\r\n\r\n // Consumers\r\n for (const consumer of res.consumers) {\r\n if (orderMap.has(consumer)) {\r\n const idx = orderMap.get(consumer)!;\r\n first = Math.min(first, idx);\r\n last = Math.max(last, idx);\r\n }\r\n }\r\n\r\n if (first !== Infinity) {\r\n lifetimes.set(res.id, { resource: res, firstUse: first, lastUse: last });\r\n }\r\n }\r\n\r\n return lifetimes;\r\n }\r\n}\r\n"],"names":["RenderGraph","_nextResourceId","_resources","Map","_passes","_compiled","importTexture","name","id","resource","RGResource","set","RGHandle","addPass","setup","pass","RGPass","length","builder","_createBuilder","data","push","compile","outputs","_validateOutputs","_cullDeadPasses","ordered","_topologicalSort","lifetimes","_analyzeLifetimes","orderedPasses","execute","compiled","noopCtx","getTexture","Error","getFramebuffer","createFramebuffer","deferCleanup","subpasses","subpass","executeFn","reset","clear","getResource","handle","get","_id","passes","resources","graph","read","res","kind","producer","reads","includes","consumers","write","consumer","dependencies","versionName","version","desc","physicalId","writes","createTexture","label","createToken","tokenName","_declareFramebufferAttachmentDeps","sideEffect","hasSideEffect","addSubpass","fn","RGSubpass","setExecute","latestVersions","values","current","latest","alive","neededResources","Set","stack","markResourceNeeded","has","add","markPassAlive","dep","dependency","pop","declare","attachment","colors","Array","isArray","colorAttachments","depthAttachment","alivePasses","filter","p","aliveSet","inDegree","adjacency","addEdge","from","to","neighbors","queue","result","shift","neighbor","deg","cycleParticipants","degree","join","orderMap","i","first","Infinity","last","idx","Math","min","max","firstUse","lastUse"],"mappings":";;AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BC,IACM,MAAMA,WAAAA,CAAAA;qBAEX,eAAQC,GAAkB,CAAE;AAC5B,qBACQC,UAAsC,GAAA,IAAIC,GAAM,EAAA;AACxD,qBACQC,OAAoB,GAAA,EAAE;qBAE9B,SAAQC,GAAwC,IAAK;;AAIrD;;;;;;;;MASAC,aAAAA,CAAcC,IAAY,EAAY;QACpC,MAAMC,EAAAA,GAAK,IAAI,CAACP,eAAe,EAAA;AAC/B,QAAA,MAAMQ,QAAW,GAAA,IAAIC,UAAWF,CAAAA,EAAAA,EAAID,MAAM,UAAY,EAAA,IAAA,CAAA;AACtD,QAAA,IAAI,CAACL,UAAU,CAACS,GAAG,CAACH,EAAIC,EAAAA,QAAAA,CAAAA;QACxB,IAAI,CAACJ,SAAS,GAAG,IAAA;QACjB,OAAO,IAAIO,SAASJ,EAAID,EAAAA,IAAAA,CAAAA;AAC1B;AAEA;;;;;;;;;AASC,MACDM,OAAkBN,CAAAA,IAAY,EAAEO,KAAoC,EAAK;QACvE,MAAMC,IAAAA,GAAO,IAAIC,MAAO,CAAA,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A,IAAYP,GAAIK,CAAAA,SAAS,CAAE;gBACpC,IAAI4D,QAAAA,CAAS/B,GAAG,CAAC3B,QAAW,CAAA,EAAA;oBAC1B,MAAM+D,GAAAA,GAAML,QAASvE,CAAAA,GAAG,CAACa,QAAAA,CAAAA;oBACzB4D,KAAQI,GAAAA,IAAAA,CAAKC,GAAG,CAACL,KAAOG,EAAAA,GAAAA,CAAAA;oBACxBD,IAAOE,GAAAA,IAAAA,CAAKE,GAAG,CAACJ,IAAMC,EAAAA,GAAAA,CAAAA;AACxB;AACF;AAEA,YAAA,IAAIH,UAAUC,QAAU,EAAA;AACtB5F,gBAAAA,SAAAA,CAAUjB,GAAG,CAACyC,GAAI5C,CAAAA,EAAE,EAAE;oBAAEC,QAAU2C,EAAAA,GAAAA;oBAAK0E,QAAUP,EAAAA,KAAAA;oBAAOQ,OAASN,EAAAA;AAAK,iBAAA,CAAA;AACxE;AACF;QAEA,OAAO7F,SAAAA;AACT;AACF;;;;"}
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * Opaque handle referencing a resource within the render graph.
4
4
  *
5
- * Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RenderGraph.importTexture},
6
- * or {@link RGPassBuilder.write}. They are lightweight identifiers used to declare
7
- * dependencies between passes.
5
+ * Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RGPassBuilder.createFramebuffer},
6
+ * {@link RenderGraph.importTexture}, or {@link RGPassBuilder.write}. They are lightweight identifiers
7
+ * used to declare dependencies between passes.
8
8
  *
9
9
  * @public
10
10
  */ class RGHandle {
@@ -26,13 +26,31 @@
26
26
  name;
27
27
  kind;
28
28
  desc;
29
+ /** Resource ID of the physical backing resource used by imported versions. */ physicalId;
29
30
  /** The pass that creates / writes this resource (null for imported until written). */ producer = null;
30
31
  /** Passes that read this resource. */ consumers = [];
31
- constructor(id, name, kind, desc){
32
+ constructor(id, name, kind, desc, physicalId = id){
32
33
  this.id = id;
33
34
  this.name = name;
34
35
  this.kind = kind;
35
36
  this.desc = desc;
37
+ this.physicalId = physicalId;
38
+ }
39
+ }
40
+ /**
41
+ * Ordered execution step inside a render graph pass.
42
+ *
43
+ * Subpasses share the parent pass's resource declarations, lifetime, culling,
44
+ * and access validation. They are intended to make multi-step pass bodies
45
+ * explicit without splitting graph-level resource dependencies.
46
+ *
47
+ * @public
48
+ */ class RGSubpass {
49
+ name;
50
+ executeFn;
51
+ constructor(name, executeFn){
52
+ this.name = name;
53
+ this.executeFn = executeFn;
36
54
  }
37
55
  }
38
56
  /**
@@ -43,9 +61,11 @@
43
61
  name;
44
62
  /** Resources this pass reads (dependencies). */ reads = [];
45
63
  /** Resources this pass creates or writes. */ writes = [];
64
+ /** Passes that must complete before this pass due to non-resource hazards. */ dependencies = [];
46
65
  /** Whether this pass has side effects and must not be culled. */ hasSideEffect = false;
47
66
  /** User data returned from the setup function. */ data = null;
48
67
  /** Execute callback. */ executeFn = null;
68
+ /** Ordered subpasses for passes with multiple logical execution steps. */ subpasses = [];
49
69
  /** Set during compilation: true if this pass is needed. */ alive = true;
50
70
  constructor(index, name){
51
71
  this.index = index;
@@ -53,5 +73,5 @@
53
73
  }
54
74
  }
55
75
 
56
- export { RGHandle, RGPass, RGResource };
76
+ export { RGHandle, RGPass, RGResource, RGSubpass };
57
77
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type { TextureFormat } from '@zephyr3d/device';\r\n\r\n// ─── Resource Descriptors ───────────────────────────────────────────────\r\n\r\n/**\r\n * Sizing mode for render graph textures.\r\n *\r\n * - 'absolute': fixed pixel dimensions\r\n * - 'backbuffer-relative': scaled relative to the backbuffer size\r\n *\r\n * @public\r\n */\r\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\r\n\r\n/**\r\n * Descriptor for a transient texture resource within the render graph.\r\n *\r\n * Transient textures are allocated and released automatically by the graph compiler.\r\n *\r\n * @public\r\n */\r\nexport interface RGTextureDesc {\r\n /** Debug label for this resource. */\r\n label?: string;\r\n /** Texture format (e.g. 'rgba8unorm', 'r32f', 'rgba16f'). */\r\n format: TextureFormat;\r\n /** Sizing mode. Default 'backbuffer-relative'. */\r\n sizeMode?: RGSizeMode;\r\n /** Width in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n width?: number;\r\n /** Height in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n height?: number;\r\n /** Number of mip levels. Default 1. */\r\n mipLevels?: number;\r\n}\r\n\r\n// ─── Handles ────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Opaque handle referencing a resource within the render graph.\r\n *\r\n * Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RenderGraph.importTexture},\r\n * or {@link RGPassBuilder.write}. They are lightweight identifiers used to declare\r\n * dependencies between passes.\r\n *\r\n * @public\r\n */\r\nexport class RGHandle {\r\n /** @internal */\r\n readonly _id: number;\r\n /** @internal */\r\n readonly _name: string;\r\n\r\n /** @internal */\r\n constructor(id: number, name: string) {\r\n this._id = id;\r\n this._name = name;\r\n }\r\n\r\n /** Debug-friendly name of the referenced resource. */\r\n get name(): string {\r\n return this._name;\r\n }\r\n}\r\n\r\n// ─── Internal Resource Tracking ─────────────────────────────────────────\r\n\r\n/** @public */\r\nexport type RGResourceKind = 'transient' | 'imported';\r\n\r\n/**\r\n * Internal bookkeeping for a resource within the render graph.\r\n * @public\r\n */\r\nexport class RGResource {\r\n readonly id: number;\r\n readonly name: string;\r\n readonly kind: RGResourceKind;\r\n readonly desc: RGTextureDesc | null;\r\n /** The pass that creates / writes this resource (null for imported until written). */\r\n producer: RGPass | null = null;\r\n /** Passes that read this resource. */\r\n readonly consumers: RGPass[] = [];\r\n\r\n constructor(id: number, name: string, kind: RGResourceKind, desc: RGTextureDesc | null) {\r\n this.id = id;\r\n this.name = name;\r\n this.kind = kind;\r\n this.desc = desc;\r\n }\r\n}\r\n\r\n// ─── Internal Pass Tracking ─────────────────────────────────────────────\r\n\r\n// ─── Execution Context ──────────────────────────────────────────────\r\n\r\n/**\r\n * Context passed to pass execute callbacks during graph execution.\r\n *\r\n * Provides access to resolved GPU resources by their handles.\r\n *\r\n * @public\r\n */\r\nexport interface RGExecuteContext {\r\n /**\r\n * Resolve a handle to the actual GPU texture object.\r\n *\r\n * For transient resources, this returns the texture allocated by the executor.\r\n * For imported resources, this returns the texture registered via\r\n * {@link RenderGraphExecutor.setImportedTexture}.\r\n *\r\n * @param handle - Handle of the resource to resolve.\r\n * @returns The resolved texture object (type depends on the allocator).\r\n */\r\n getTexture<TTexture = unknown>(handle: RGHandle): TTexture;\r\n}\r\n\r\n/**\r\n * Execute callback signature.\r\n *\r\n * The callback receives a context for resolving handles to GPU resources,\r\n * plus the user data returned from the setup function.\r\n *\r\n * @public\r\n */\r\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\r\n\r\n/**\r\n * Internal bookkeeping for a pass within the render graph.\r\n * @public\r\n */\r\nexport class RGPass<T = unknown> {\r\n readonly index: number;\r\n readonly name: string;\r\n /** Resources this pass reads (dependencies). */\r\n readonly reads: RGResource[] = [];\r\n /** Resources this pass creates or writes. */\r\n readonly writes: RGResource[] = [];\r\n /** Whether this pass has side effects and must not be culled. */\r\n hasSideEffect = false;\r\n /** User data returned from the setup function. */\r\n data: T | null = null;\r\n /** Execute callback. */\r\n executeFn: RGExecuteFn<T> | null = null;\r\n /** Set during compilation: true if this pass is needed. */\r\n alive = true;\r\n\r\n constructor(index: number, name: string) {\r\n this.index = index;\r\n this.name = name;\r\n }\r\n}\r\n\r\n// ─── Pass Builder ───────────────────────────────────────────────────────\r\n\r\n/**\r\n * Builder interface used within the setup callback of {@link RenderGraph.addPass}\r\n * to declare a pass's resource requirements.\r\n *\r\n * @public\r\n */\r\nexport interface RGPassBuilder {\r\n /**\r\n * Declare a read dependency on an existing resource.\r\n *\r\n * The resource must have been created by a prior pass or imported into the graph.\r\n *\r\n * @param handle - Handle of the resource to read.\r\n */\r\n read(handle: RGHandle): void;\r\n\r\n /**\r\n * Declare that this pass writes to an existing resource (typically an imported resource).\r\n *\r\n * @param handle - Handle of the resource to write to.\r\n */\r\n write(handle: RGHandle): void;\r\n\r\n /**\r\n * Create a new transient texture resource that this pass will produce.\r\n *\r\n * @param desc - Texture descriptor.\r\n * @returns A handle referencing the newly created resource.\r\n */\r\n createTexture(desc: RGTextureDesc): RGHandle;\r\n\r\n /**\r\n * Mark this pass as having side effects.\r\n *\r\n * Side-effect passes are never culled by the graph compiler, regardless of\r\n * whether their outputs are consumed. Use this for GPU readback, picking,\r\n * debug overlays, etc.\r\n */\r\n sideEffect(): void;\r\n\r\n /**\r\n * Set the execution callback for this pass.\r\n *\r\n * @param fn - Callback invoked during graph execution.\r\n */\r\n setExecute<D>(fn: RGExecuteFn<D>): void;\r\n}\r\n\r\n// ─── Compiled Graph ─────────────────────────────────────────────────────\r\n\r\n/**\r\n * Lifetime information for a resource within the compiled graph.\r\n *\r\n * @public\r\n */\r\nexport interface RGResourceLifetime {\r\n /** The resource. */\r\n readonly resource: RGResource;\r\n /** Index of the first pass that uses (produces or reads) this resource. */\r\n readonly firstUse: number;\r\n /** Index of the last pass that uses this resource. */\r\n readonly lastUse: number;\r\n}\r\n\r\n/**\r\n * Result of compiling a render graph.\r\n *\r\n * Contains the ordered list of passes to execute and lifetime information\r\n * for automatic resource management.\r\n *\r\n * @public\r\n */\r\nexport interface CompiledRenderGraph {\r\n /** Topologically sorted passes (only non-culled passes). */\r\n readonly orderedPasses: ReadonlyArray<RGPass>;\r\n /** Resource lifetime information keyed by resource ID. */\r\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\r\n}\r\n\r\n// ─── Texture Allocator ──────────────────────────────────────────────\r\n\r\n/**\r\n * Resolved dimensions for a texture allocation.\r\n * @public\r\n */\r\nexport interface RGResolvedSize {\r\n width: number;\r\n height: number;\r\n}\r\n\r\n/**\r\n * Interface for allocating and releasing transient textures.\r\n *\r\n * Implement this to bridge the render graph with your GPU device's resource pool.\r\n * The executor calls {@link allocate} before a resource's first use and\r\n * {@link release} after its last use.\r\n *\r\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\r\n * @public\r\n */\r\nexport interface RGTextureAllocator<TTexture = unknown> {\r\n /**\r\n * Allocate a transient texture matching the given descriptor and resolved size.\r\n *\r\n * @param desc - The texture descriptor from the pass builder.\r\n * @param size - The resolved pixel dimensions.\r\n * @returns The allocated texture object.\r\n */\r\n allocate(desc: RGTextureDesc, size: RGResolvedSize): TTexture;\r\n\r\n /**\r\n * Release a previously allocated transient texture back to the pool.\r\n *\r\n * @param texture - The texture to release.\r\n */\r\n release(texture: TTexture): void;\r\n}\r\n"],"names":["RGHandle","id","name","_id","_name","RGResource","kind","desc","producer","consumers","RGPass","index","reads","writes","hasSideEffect","data","executeFn","alive"],"mappings":"AAoCA;AAEA;;;;;;;;AAQC,IACM,MAAMA,QAAAA,CAAAA;qBAEX,GAAqB;qBAErB,KAAuB;AAEvB,qBACA,WAAA,CAAYC,EAAU,EAAEC,IAAY,CAAE;QACpC,IAAI,CAACC,GAAG,GAAGF,EAAAA;QACX,IAAI,CAACG,KAAK,GAAGF,IAAAA;AACf;2DAGA,IAAIA,IAAe,GAAA;QACjB,OAAO,IAAI,CAACE,KAAK;AACnB;AACF;AAOA;;;AAGC,IACM,MAAMC,UAAAA,CAAAA;IACFJ,EAAW;IACXC,IAAa;IACbI,IAAqB;IACrBC,IAA2B;2FAEpCC,WAA0B,IAAK;AAC/B,2CACSC,SAAsB,GAAA,EAAE;AAEjC,IAAA,WAAA,CAAYR,EAAU,EAAEC,IAAY,EAAEI,IAAoB,EAAEC,IAA0B,CAAE;QACtF,IAAI,CAACN,EAAE,GAAGA,EAAAA;QACV,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACI,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACC,IAAI,GAAGA,IAAAA;AACd;AACF;AAqCA;;;AAGC,IACM,MAAMG,MAAAA,CAAAA;IACFC,KAAc;IACdT,IAAa;AACtB,qDACSU,KAAsB,GAAA,EAAE;AACjC,kDACSC,MAAuB,GAAA,EAAE;sEAElCC,gBAAgB,KAAM;uDAEtBC,OAAiB,IAAK;6BAEtBC,YAAmC,IAAK;gEAExCC,QAAQ,IAAK;IAEb,WAAYN,CAAAA,KAAa,EAAET,IAAY,CAAE;QACvC,IAAI,CAACS,KAAK,GAAGA,KAAAA;QACb,IAAI,CAACT,IAAI,GAAGA,IAAAA;AACd;AACF;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type { TextureFormat } from '@zephyr3d/device';\r\n\r\n// ─── Resource Descriptors ───────────────────────────────────────────────\r\n\r\n/**\r\n * Sizing mode for render graph textures.\r\n *\r\n * - 'absolute': fixed pixel dimensions\r\n * - 'backbuffer-relative': scaled relative to the backbuffer size\r\n *\r\n * @public\r\n */\r\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\r\n\r\n/**\r\n * Descriptor for a transient texture resource within the render graph.\r\n *\r\n * Transient textures are allocated and released automatically by the graph compiler.\r\n *\r\n * @public\r\n */\r\nexport interface RGTextureDesc {\r\n /** Debug label for this resource. */\r\n label?: string;\r\n /** Texture format (e.g. 'rgba8unorm', 'r32f', 'rgba16f'). */\r\n format: TextureFormat;\r\n /** Sizing mode. Default 'backbuffer-relative'. */\r\n sizeMode?: RGSizeMode;\r\n /** Width in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n width?: number;\r\n /** Height in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n height?: number;\r\n /** Number of mip levels. Default 1. */\r\n mipLevels?: number;\r\n}\r\n\r\n// ─── Handles ────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Opaque handle referencing a resource within the render graph.\r\n *\r\n * Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RGPassBuilder.createFramebuffer},\r\n * {@link RenderGraph.importTexture}, or {@link RGPassBuilder.write}. They are lightweight identifiers\r\n * used to declare dependencies between passes.\r\n *\r\n * @public\r\n */\r\nexport class RGHandle {\r\n /** @internal */\r\n readonly _id: number;\r\n /** @internal */\r\n readonly _name: string;\r\n\r\n /** @internal */\r\n constructor(id: number, name: string) {\r\n this._id = id;\r\n this._name = name;\r\n }\r\n\r\n /** Debug-friendly name of the referenced resource. */\r\n get name(): string {\r\n return this._name;\r\n }\r\n}\r\n\r\n// ─── Internal Resource Tracking ─────────────────────────────────────────\r\n\r\n/** @public */\r\nexport type RGResourceKind = 'transient' | 'imported' | 'token' | 'framebuffer';\r\n\r\n/**\r\n * Internal bookkeeping for a resource within the render graph.\r\n * @public\r\n */\r\nexport class RGResource {\r\n readonly id: number;\r\n readonly name: string;\r\n readonly kind: RGResourceKind;\r\n readonly desc: RGTextureDesc | RGFramebufferDesc | null;\r\n /** Resource ID of the physical backing resource used by imported versions. */\r\n readonly physicalId: number;\r\n /** The pass that creates / writes this resource (null for imported until written). */\r\n producer: RGPass | null = null;\r\n /** Passes that read this resource. */\r\n readonly consumers: RGPass[] = [];\r\n\r\n constructor(\r\n id: number,\r\n name: string,\r\n kind: RGResourceKind,\r\n desc: RGTextureDesc | RGFramebufferDesc | null,\r\n physicalId = id\r\n ) {\r\n this.id = id;\r\n this.name = name;\r\n this.kind = kind;\r\n this.desc = desc;\r\n this.physicalId = physicalId;\r\n }\r\n}\r\n\r\n// ─── Internal Pass Tracking ─────────────────────────────────────────────\r\n\r\n// ─── Execution Context ──────────────────────────────────────────────\r\n\r\n/**\r\n * Context passed to pass execute callbacks during graph execution.\r\n *\r\n * Provides access to resolved GPU resources by their handles.\r\n *\r\n * @public\r\n */\r\nexport interface RGExecuteContext {\r\n /**\r\n * Resolve a handle to the actual GPU texture object.\r\n *\r\n * For transient resources, this returns the texture allocated by the executor.\r\n * For imported resources, this returns the texture registered via\r\n * {@link RenderGraphExecutor.setImportedTexture}. The handle must be declared\r\n * by the current pass with {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\r\n *\r\n * @param handle - Handle of the resource to resolve.\r\n * @returns The resolved texture object (type depends on the allocator).\r\n */\r\n getTexture<TTexture = unknown>(handle: RGHandle): TTexture;\r\n\r\n /**\r\n * Resolve a framebuffer handle to the actual backend framebuffer object.\r\n *\r\n * The handle must be declared by the current pass with {@link RGPassBuilder.read}\r\n * or created by the same pass with {@link RGPassBuilder.createFramebuffer}.\r\n *\r\n * @param handle - Handle returned from {@link RGPassBuilder.createFramebuffer}.\r\n * @returns The resolved framebuffer object (type depends on the allocator).\r\n */\r\n getFramebuffer<TFramebuffer = unknown>(handle: RGHandle): TFramebuffer;\r\n\r\n /**\r\n * Create a temporary framebuffer managed by the graph executor.\r\n *\r\n * The framebuffer is released automatically when graph execution finishes or\r\n * aborts. Attachments may be actual backend resources or texture formats,\r\n * depending on the allocator implementation. If an attachment is an\r\n * {@link RGHandle}, the current pass must declare it with\r\n * {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\r\n *\r\n * @param desc - Framebuffer descriptor.\r\n * @returns The allocated framebuffer object (type depends on the allocator).\r\n */\r\n createFramebuffer<TFramebuffer = unknown>(desc: RGFramebufferDesc): TFramebuffer;\r\n\r\n /**\r\n * Register a cleanup callback to run when graph execution finishes or aborts.\r\n *\r\n * Callbacks run in reverse registration order. Use this for temporary objects\r\n * created inside pass execution that are not graph resources, such as pooled\r\n * framebuffers wrapping graph-managed textures. If pass execution throws, the\r\n * executor still runs cleanup callbacks and preserves the original pass error\r\n * ahead of cleanup errors.\r\n *\r\n * @param callback - Cleanup function to invoke after execution.\r\n */\r\n deferCleanup(callback: () => void): void;\r\n}\r\n\r\n/**\r\n * Execute callback signature.\r\n *\r\n * The callback receives a context for resolving handles to GPU resources,\r\n * plus the user data returned from the setup function.\r\n *\r\n * @public\r\n */\r\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\r\n\r\n/**\r\n * Ordered execution step inside a render graph pass.\r\n *\r\n * Subpasses share the parent pass's resource declarations, lifetime, culling,\r\n * and access validation. They are intended to make multi-step pass bodies\r\n * explicit without splitting graph-level resource dependencies.\r\n *\r\n * @public\r\n */\r\nexport class RGSubpass<T = unknown> {\r\n readonly name: string;\r\n readonly executeFn: RGExecuteFn<T>;\r\n\r\n constructor(name: string, executeFn: RGExecuteFn<T>) {\r\n this.name = name;\r\n this.executeFn = executeFn;\r\n }\r\n}\r\n\r\n/**\r\n * Internal bookkeeping for a pass within the render graph.\r\n * @public\r\n */\r\nexport class RGPass<T = unknown> {\r\n readonly index: number;\r\n readonly name: string;\r\n /** Resources this pass reads (dependencies). */\r\n readonly reads: RGResource[] = [];\r\n /** Resources this pass creates or writes. */\r\n readonly writes: RGResource[] = [];\r\n /** Passes that must complete before this pass due to non-resource hazards. */\r\n readonly dependencies: RGPass[] = [];\r\n /** Whether this pass has side effects and must not be culled. */\r\n hasSideEffect = false;\r\n /** User data returned from the setup function. */\r\n data: T | null = null;\r\n /** Execute callback. */\r\n executeFn: RGExecuteFn<T> | null = null;\r\n /** Ordered subpasses for passes with multiple logical execution steps. */\r\n readonly subpasses: RGSubpass<T>[] = [];\r\n /** Set during compilation: true if this pass is needed. */\r\n alive = true;\r\n\r\n constructor(index: number, name: string) {\r\n this.index = index;\r\n this.name = name;\r\n }\r\n}\r\n\r\n// ─── Pass Builder ───────────────────────────────────────────────────────\r\n\r\n/**\r\n * Builder interface used within the setup callback of {@link RenderGraph.addPass}\r\n * to declare a pass's resource requirements.\r\n *\r\n * @public\r\n */\r\nexport interface RGPassBuilder {\r\n /**\r\n * Declare a read dependency on an existing resource.\r\n *\r\n * The resource must have been created by a prior pass or imported into the graph.\r\n *\r\n * @param handle - Handle of the resource to read.\r\n */\r\n read(handle: RGHandle): void;\r\n\r\n /**\r\n * Declare that this pass writes a new version of an existing resource.\r\n *\r\n * The returned handle represents the post-write version. Use it for subsequent\r\n * reads and as the graph output passed to {@link RenderGraph.compile}. Passing\r\n * an older version of the same resource to `compile()` is rejected because it\r\n * usually means the caller ignored the handle returned by `write()`. If the pass\r\n * needs the previous contents, call {@link RGPassBuilder.read} on the input handle explicitly\r\n * before writing.\r\n *\r\n * @param handle - Handle of the resource to write to.\r\n * @returns A handle referencing the newly written version.\r\n */\r\n write(handle: RGHandle): RGHandle;\r\n\r\n /**\r\n * Create a new transient texture resource that this pass will produce.\r\n *\r\n * @param desc - Texture descriptor.\r\n * @returns A handle referencing the newly created resource.\r\n */\r\n createTexture(desc: RGTextureDesc): RGHandle;\r\n\r\n /**\r\n * Create a logical dependency token produced by this pass.\r\n *\r\n * Tokens do not resolve to GPU resources and are not allocated by the executor.\r\n * They are useful for ordering passes whose dependencies are side effects rather\r\n * than texture reads/writes.\r\n *\r\n * @param name - Debug label for this token.\r\n * @returns A handle referencing the newly created token.\r\n */\r\n createToken(name?: string): RGHandle;\r\n\r\n /**\r\n * Create a graph-managed framebuffer view.\r\n *\r\n * The graph compiler infers dependencies from any attachment handles in the\r\n * descriptor. The executor creates and releases the framebuffer automatically.\r\n *\r\n * @param desc - Framebuffer descriptor.\r\n * @returns A handle referencing the framebuffer view.\r\n */\r\n createFramebuffer(desc: RGFramebufferDesc): RGHandle;\r\n\r\n /**\r\n * Mark this pass as having side effects.\r\n *\r\n * Side-effect passes are never culled by the graph compiler, regardless of\r\n * whether their outputs are consumed. Use this for GPU readback, picking,\r\n * debug overlays, etc.\r\n */\r\n sideEffect(): void;\r\n\r\n /**\r\n * Add an ordered logical subpass to this pass.\r\n *\r\n * Subpasses execute in registration order and share the parent pass's declared\r\n * reads, writes, framebuffer views, and user data. A pass may use either\r\n * subpasses or {@link RGPassBuilder.setExecute}, but not both.\r\n *\r\n * @param name - Debug label for the subpass.\r\n * @param fn - Callback invoked when this subpass executes.\r\n */\r\n addSubpass<D>(name: string, fn: RGExecuteFn<D>): void;\r\n\r\n /**\r\n * Set the execution callback for this pass.\r\n *\r\n * A pass may use either this method or {@link RGPassBuilder.addSubpass}, but not both.\r\n *\r\n * @param fn - Callback invoked during graph execution.\r\n */\r\n setExecute<D>(fn: RGExecuteFn<D>): void;\r\n}\r\n\r\n// ─── Compiled Graph ─────────────────────────────────────────────────────\r\n\r\n/**\r\n * Lifetime information for a resource within the compiled graph.\r\n *\r\n * @public\r\n */\r\nexport interface RGResourceLifetime {\r\n /** The resource. */\r\n readonly resource: RGResource;\r\n /** Index of the first pass that uses (produces or reads) this resource. */\r\n readonly firstUse: number;\r\n /** Index of the last pass that uses this resource. */\r\n readonly lastUse: number;\r\n}\r\n\r\n/**\r\n * Result of compiling a render graph.\r\n *\r\n * Contains the ordered list of passes to execute and lifetime information\r\n * for automatic resource management.\r\n *\r\n * @public\r\n */\r\nexport interface CompiledRenderGraph {\r\n /** Topologically sorted passes (only non-culled passes). */\r\n readonly orderedPasses: ReadonlyArray<RGPass>;\r\n /** Resource lifetime information keyed by resource ID. */\r\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\r\n}\r\n\r\n// ─── Texture Allocator ──────────────────────────────────────────────\r\n\r\n/**\r\n * Resolved dimensions for a texture allocation.\r\n * @public\r\n */\r\nexport interface RGResolvedSize {\r\n width: number;\r\n height: number;\r\n}\r\n\r\n/**\r\n * Descriptor for a framebuffer view managed by the graph or created temporarily during pass execution.\r\n *\r\n * This is intentionally backend-agnostic: graph-managed descriptors may use\r\n * {@link RGHandle} attachments, and executor-created descriptors use resolved\r\n * resources or texture formats understood by the allocator.\r\n *\r\n * @public\r\n */\r\nexport interface RGFramebufferDesc {\r\n /** Debug label for this framebuffer. */\r\n label?: string;\r\n /** Framebuffer width. Required when attachments are formats. */\r\n width?: number;\r\n /** Framebuffer height. Required when attachments are formats. */\r\n height?: number;\r\n /** Color attachments or formats. */\r\n colorAttachments: unknown | unknown[] | null;\r\n /** Depth/stencil attachment or format. */\r\n depthAttachment?: unknown | null;\r\n /** Whether color attachments created from formats should support mipmapping. */\r\n mipmapping?: boolean;\r\n /** Framebuffer sample count. */\r\n sampleCount?: number;\r\n /** Whether to ignore depth/stencil during MSAA resolve. */\r\n ignoreDepthStencil?: boolean;\r\n /** Attachment mip level. */\r\n attachmentMipLevel?: number;\r\n /** Attachment cubemap face. */\r\n attachmentCubeface?: number;\r\n /** Attachment array layer. */\r\n attachmentLayer?: number;\r\n}\r\n\r\n/**\r\n * Interface for allocating and releasing transient textures.\r\n *\r\n * Implement this to bridge the render graph with your GPU device's resource pool.\r\n * The executor calls `allocate()` before a resource's first use and\r\n * `release()` after its last use.\r\n *\r\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\r\n * @public\r\n */\r\nexport interface RGTextureAllocator<TTexture = unknown, TFramebuffer = unknown> {\r\n /**\r\n * Allocate a transient texture matching the given descriptor and resolved size.\r\n *\r\n * @param desc - The texture descriptor from the pass builder.\r\n * @param size - The resolved pixel dimensions.\r\n * @returns The allocated texture object.\r\n */\r\n allocate(desc: RGTextureDesc, size: RGResolvedSize): TTexture;\r\n\r\n /**\r\n * Release a previously allocated transient texture back to the pool.\r\n *\r\n * @param texture - The texture to release.\r\n */\r\n release(texture: TTexture): void;\r\n\r\n /**\r\n * Allocate a temporary framebuffer matching the given descriptor.\r\n *\r\n * Implementations should not auto-release this framebuffer; the graph executor\r\n * calls {@link RGTextureAllocator.releaseFramebuffer} when execution completes or aborts.\r\n *\r\n * @param desc - Framebuffer descriptor.\r\n * @returns The allocated framebuffer object.\r\n */\r\n allocateFramebuffer?(desc: RGFramebufferDesc): TFramebuffer;\r\n\r\n /**\r\n * Release a previously allocated temporary framebuffer.\r\n *\r\n * @param framebuffer - The framebuffer to release.\r\n */\r\n releaseFramebuffer?(framebuffer: TFramebuffer): void;\r\n}\r\n"],"names":["RGHandle","id","name","_id","_name","RGResource","kind","desc","producer","consumers","physicalId","RGSubpass","executeFn","RGPass","index","reads","writes","dependencies","hasSideEffect","data","subpasses","alive"],"mappings":"AAoCA;AAEA;;;;;;;;AAQC,IACM,MAAMA,QAAAA,CAAAA;qBAEX,GAAqB;qBAErB,KAAuB;AAEvB,qBACA,WAAA,CAAYC,EAAU,EAAEC,IAA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AGA,IAAAA;AACd;AACF;;;;"}
@@ -1,4 +1,8 @@
1
- class RenderTarget {
1
+ /**
2
+ * Abstract render target used to derive viewports and projection matrices.
3
+ *
4
+ * @public
5
+ */ class RenderTarget {
2
6
  }
3
7
 
4
8
  export { RenderTarget };
@@ -1 +1 @@
1
- {"version":3,"file":"rendertarget.js","sources":["../../src/render/rendertarget.ts"],"sourcesContent":["import type { Matrix4x4, Nullable } from '@zephyr3d/base';\r\n\r\nexport abstract class RenderTarget {\r\n abstract getVersion(): number;\r\n abstract calcViewport(outViewport?: Nullable<number[]>): number[];\r\n abstract calcRelativeViewport(outViewport?: Nullable<number[]>): number[];\r\n abstract calcPerspectiveProjection(\r\n fov: number,\r\n nearClip: number,\r\n farClip: number,\r\n outMatrix?: Matrix4x4\r\n ): Matrix4x4;\r\n abstract calcOrthographicProjection(nearClip: number, farClip: number, outMatrix?: Matrix4x4): Matrix4x4;\r\n}\r\n"],"names":["RenderTarget"],"mappings":"AAEO,MAAeA,YAAAA,CAAAA;AAWtB;;;;"}
1
+ {"version":3,"file":"rendertarget.js","sources":["../../src/render/rendertarget.ts"],"sourcesContent":["import type { Matrix4x4, Nullable } from '@zephyr3d/base';\r\n\r\n/**\r\n * Abstract render target used to derive viewports and projection matrices.\r\n *\r\n * @public\r\n */\r\nexport abstract class RenderTarget {\r\n abstract getVersion(): number;\r\n abstract calcViewport(outViewport?: Nullable<number[]>): number[];\r\n abstract calcRelativeViewport(outViewport?: Nullable<number[]>): number[];\r\n abstract calcPerspectiveProjection(\r\n fov: number,\r\n nearClip: number,\r\n farClip: number,\r\n outMatrix?: Matrix4x4\r\n ): Matrix4x4;\r\n abstract calcOrthographicProjection(nearClip: number, farClip: number, outMatrix?: Matrix4x4): Matrix4x4;\r\n}\r\n"],"names":["RenderTarget"],"mappings":"AAEA;;;;AAIC,IACM,MAAeA,YAAAA,CAAAA;AAWtB;;;;"}
@@ -2,7 +2,11 @@ import { Matrix4x4 } from '@zephyr3d/base';
2
2
  import { getEngine } from '../app/api.js';
3
3
  import { RenderTarget } from './rendertarget.js';
4
4
 
5
- class ScreenRenderTarget extends RenderTarget {
5
+ /**
6
+ * Render target backed by the engine screen adapter.
7
+ *
8
+ * @public
9
+ */ class ScreenRenderTarget extends RenderTarget {
6
10
  screenAdapter;
7
11
  constructor(screenAdapter){
8
12
  super();