@zephyr3d/scene 0.9.25 → 0.9.27

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 (299) hide show
  1. package/dist/animation/animationset.js +92 -30
  2. package/dist/animation/animationset.js.map +1 -1
  3. package/dist/animation/hair/gpu_hair_simulation.js +1090 -0
  4. package/dist/animation/hair/gpu_hair_simulation.js.map +1 -0
  5. package/dist/animation/joint_dynamics/controller.js +7 -5
  6. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  7. package/dist/animation/joint_dynamics/convex_collider.js +320 -0
  8. package/dist/animation/joint_dynamics/convex_collider.js.map +1 -0
  9. package/dist/animation/joint_dynamics/joint_dynamics_system.js +81 -5
  10. package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
  11. package/dist/animation/morphtrack.js +3 -4
  12. package/dist/animation/morphtrack.js.map +1 -1
  13. package/dist/animation/skeleton.js +79 -25
  14. package/dist/animation/skeleton.js.map +1 -1
  15. package/dist/animation/spring/multi_chain_spring_system.js +577 -179
  16. package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
  17. package/dist/animation/spring/spring_collider.js +4 -3
  18. package/dist/animation/spring/spring_collider.js.map +1 -1
  19. package/dist/animation/spring/spring_node_pose_tracker.js +40 -0
  20. package/dist/animation/spring/spring_node_pose_tracker.js.map +1 -0
  21. package/dist/animation/spring/spring_particle.js +2 -0
  22. package/dist/animation/spring/spring_particle.js.map +1 -1
  23. package/dist/animation/spring/spring_system.js +11 -3
  24. package/dist/animation/spring/spring_system.js.map +1 -1
  25. package/dist/animation/spring_modifier.js +10 -0
  26. package/dist/animation/spring_modifier.js.map +1 -1
  27. package/dist/app/engine.js +53 -43
  28. package/dist/app/engine.js.map +1 -1
  29. package/dist/app/scriptingsystem.js +119 -6
  30. package/dist/app/scriptingsystem.js.map +1 -1
  31. package/dist/app/scriptregistry.js +3 -2
  32. package/dist/app/scriptregistry.js.map +1 -1
  33. package/dist/asset/assetmanager.js +284 -67
  34. package/dist/asset/assetmanager.js.map +1 -1
  35. package/dist/asset/loaders/zhair/zhair_format.js +288 -0
  36. package/dist/asset/loaders/zhair/zhair_format.js.map +1 -0
  37. package/dist/asset/loaders/zhair/zhair_loader.js +221 -0
  38. package/dist/asset/loaders/zhair/zhair_loader.js.map +1 -0
  39. package/dist/asset/model.js +184 -69
  40. package/dist/asset/model.js.map +1 -1
  41. package/dist/camera/camera.js +268 -44
  42. package/dist/camera/camera.js.map +1 -1
  43. package/dist/camera/perspectivecamera.js +3 -1
  44. package/dist/camera/perspectivecamera.js.map +1 -1
  45. package/dist/index.d.ts +9044 -5139
  46. package/dist/index.js +17 -6
  47. package/dist/index.js.map +1 -1
  48. package/dist/material/eye.js +932 -0
  49. package/dist/material/eye.js.map +1 -0
  50. package/dist/material/hair.js +917 -0
  51. package/dist/material/hair.js.map +1 -0
  52. package/dist/material/hairstrand.js +842 -0
  53. package/dist/material/hairstrand.js.map +1 -0
  54. package/dist/material/hairstrand_data.js +162 -0
  55. package/dist/material/hairstrand_data.js.map +1 -0
  56. package/dist/material/lambert.js +5 -2
  57. package/dist/material/lambert.js.map +1 -1
  58. package/dist/material/material.js +48 -10
  59. package/dist/material/material.js.map +1 -1
  60. package/dist/material/meshmaterial.js +120 -19
  61. package/dist/material/meshmaterial.js.map +1 -1
  62. package/dist/material/mixins/albedocolor.js +1 -1
  63. package/dist/material/mixins/albedocolor.js.map +1 -1
  64. package/dist/material/mixins/lightmodel/blinnphong.js +5 -3
  65. package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
  66. package/dist/material/mixins/lightmodel/lambert.js +5 -4
  67. package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
  68. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +3 -3
  69. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
  70. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +5 -5
  71. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  72. package/dist/material/mixins/lightmodel/pbrspecularglossness.js +3 -3
  73. package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
  74. package/dist/material/mixins/lit.js +106 -19
  75. package/dist/material/mixins/lit.js.map +1 -1
  76. package/dist/material/mixins/pbr/common.js +4 -4
  77. package/dist/material/mixins/pbr/common.js.map +1 -1
  78. package/dist/material/mixins/texture.js +48 -11
  79. package/dist/material/mixins/texture.js.map +1 -1
  80. package/dist/material/mtoon.js +6 -5
  81. package/dist/material/mtoon.js.map +1 -1
  82. package/dist/material/pbrblueprint.js +146 -28
  83. package/dist/material/pbrblueprint.js.map +1 -1
  84. package/dist/material/pbrblueprint_instance.js +501 -0
  85. package/dist/material/pbrblueprint_instance.js.map +1 -0
  86. package/dist/material/pbrmr.js +15 -16
  87. package/dist/material/pbrmr.js.map +1 -1
  88. package/dist/material/shader/helper.js +734 -23
  89. package/dist/material/shader/helper.js.map +1 -1
  90. package/dist/material/shader/terrain_blend.js +55 -0
  91. package/dist/material/shader/terrain_blend.js.map +1 -0
  92. package/dist/material/skin.js +192 -32
  93. package/dist/material/skin.js.map +1 -1
  94. package/dist/material/spriteblueprint.js +16 -1
  95. package/dist/material/spriteblueprint.js.map +1 -1
  96. package/dist/material/subsurfaceprofile.js +86 -23
  97. package/dist/material/subsurfaceprofile.js.map +1 -1
  98. package/dist/material/water.js +2059 -72
  99. package/dist/material/water.js.map +1 -1
  100. package/dist/posteffect/bloom.js +167 -7
  101. package/dist/posteffect/bloom.js.map +1 -1
  102. package/dist/posteffect/coloradjust.js +2 -1
  103. package/dist/posteffect/coloradjust.js.map +1 -1
  104. package/dist/posteffect/compositor.js.map +1 -1
  105. package/dist/posteffect/fxaa.js +2 -1
  106. package/dist/posteffect/fxaa.js.map +1 -1
  107. package/dist/posteffect/grayscale.js +3 -1
  108. package/dist/posteffect/grayscale.js.map +1 -1
  109. package/dist/posteffect/motionblur.js +664 -56
  110. package/dist/posteffect/motionblur.js.map +1 -1
  111. package/dist/posteffect/posteffect.js +12 -1
  112. package/dist/posteffect/posteffect.js.map +1 -1
  113. package/dist/posteffect/sao.js +46 -44
  114. package/dist/posteffect/sao.js.map +1 -1
  115. package/dist/posteffect/skinsss.js +368 -69
  116. package/dist/posteffect/skinsss.js.map +1 -1
  117. package/dist/posteffect/ssgi.js +16 -9
  118. package/dist/posteffect/ssgi.js.map +1 -1
  119. package/dist/posteffect/ssr.js +3 -0
  120. package/dist/posteffect/ssr.js.map +1 -1
  121. package/dist/posteffect/sss.js +121 -36
  122. package/dist/posteffect/sss.js.map +1 -1
  123. package/dist/posteffect/taa.js.map +1 -1
  124. package/dist/posteffect/tonemap.js +44 -1
  125. package/dist/posteffect/tonemap.js.map +1 -1
  126. package/dist/render/abuffer_oit.js +8 -2
  127. package/dist/render/abuffer_oit.js.map +1 -1
  128. package/dist/render/clipmap.js +156 -5
  129. package/dist/render/clipmap.js.map +1 -1
  130. package/dist/render/cull_visitor.js +20 -0
  131. package/dist/render/cull_visitor.js.map +1 -1
  132. package/dist/render/depthpass.js +36 -2
  133. package/dist/render/depthpass.js.map +1 -1
  134. package/dist/render/drawable_mixin.js +26 -1
  135. package/dist/render/drawable_mixin.js.map +1 -1
  136. package/dist/render/dualdepthpeeling_oit.js +3 -2
  137. package/dist/render/dualdepthpeeling_oit.js.map +1 -1
  138. package/dist/render/envlight.js +1 -1
  139. package/dist/render/envlight.js.map +1 -1
  140. package/dist/render/fbm_wavegenerator.js +6 -3
  141. package/dist/render/fbm_wavegenerator.js.map +1 -1
  142. package/dist/render/fft_wavegenerator.js +57 -15
  143. package/dist/render/fft_wavegenerator.js.map +1 -1
  144. package/dist/render/gerstner_wavegenerator.js +130 -20
  145. package/dist/render/gerstner_wavegenerator.js.map +1 -1
  146. package/dist/render/globalbindgroup_allocator.js +3 -0
  147. package/dist/render/globalbindgroup_allocator.js.map +1 -1
  148. package/dist/render/hzb.js +80 -22
  149. package/dist/render/hzb.js.map +1 -1
  150. package/dist/render/lightpass.js +6 -3
  151. package/dist/render/lightpass.js.map +1 -1
  152. package/dist/render/oit.js +29 -0
  153. package/dist/render/oit.js.map +1 -0
  154. package/dist/render/render_queue.js +39 -0
  155. package/dist/render/render_queue.js.map +1 -1
  156. package/dist/render/renderer.js +4 -0
  157. package/dist/render/renderer.js.map +1 -1
  158. package/dist/render/rendergraph/blackboard.js +1 -0
  159. package/dist/render/rendergraph/blackboard.js.map +1 -1
  160. package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
  161. package/dist/render/rendergraph/executor.js +2 -0
  162. package/dist/render/rendergraph/executor.js.map +1 -1
  163. package/dist/render/rendergraph/forward_plus_builder.js +379 -10
  164. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
  165. package/dist/render/rendergraph/frame_resource_requirements.js +1 -0
  166. package/dist/render/rendergraph/frame_resource_requirements.js.map +1 -1
  167. package/dist/render/rendergraph/history_resources.js +8 -1
  168. package/dist/render/rendergraph/history_resources.js.map +1 -1
  169. package/dist/render/rendergraph/rendergraph.js.map +1 -1
  170. package/dist/render/rendergraph/texture_affinity_cache.js +1 -1
  171. package/dist/render/rendergraph/texture_affinity_cache.js.map +1 -1
  172. package/dist/render/rendergraph/types.js.map +1 -1
  173. package/dist/render/shadow_mask_pass.js +73 -8
  174. package/dist/render/shadow_mask_pass.js.map +1 -1
  175. package/dist/render/sky.js +166 -126
  176. package/dist/render/sky.js.map +1 -1
  177. package/dist/render/underwater.js +624 -0
  178. package/dist/render/underwater.js.map +1 -0
  179. package/dist/render/water_caustics.js +1380 -0
  180. package/dist/render/water_caustics.js.map +1 -0
  181. package/dist/render/weightedblended_oit.js +3 -2
  182. package/dist/render/weightedblended_oit.js.map +1 -1
  183. package/dist/scene/basesprite.js +8 -0
  184. package/dist/scene/basesprite.js.map +1 -1
  185. package/dist/scene/batchgroup.js +3 -0
  186. package/dist/scene/batchgroup.js.map +1 -1
  187. package/dist/scene/environment.js +4 -1
  188. package/dist/scene/environment.js.map +1 -1
  189. package/dist/scene/hair.js +963 -0
  190. package/dist/scene/hair.js.map +1 -0
  191. package/dist/scene/light.js +5 -1
  192. package/dist/scene/light.js.map +1 -1
  193. package/dist/scene/mesh.js +481 -47
  194. package/dist/scene/mesh.js.map +1 -1
  195. package/dist/scene/meshdrawable.js +6 -0
  196. package/dist/scene/meshdrawable.js.map +1 -1
  197. package/dist/scene/msdftext.js +3 -0
  198. package/dist/scene/msdftext.js.map +1 -1
  199. package/dist/scene/msdftextsprite.js +3 -0
  200. package/dist/scene/msdftextsprite.js.map +1 -1
  201. package/dist/scene/particlesys.js +6 -0
  202. package/dist/scene/particlesys.js.map +1 -1
  203. package/dist/scene/scene.js +3 -0
  204. package/dist/scene/scene.js.map +1 -1
  205. package/dist/scene/scene_node.js +6 -1
  206. package/dist/scene/scene_node.js.map +1 -1
  207. package/dist/scene/terrain-cm/grass.js +3 -0
  208. package/dist/scene/terrain-cm/grass.js.map +1 -1
  209. package/dist/scene/terrain-cm/grassmaterial.js +3 -0
  210. package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
  211. package/dist/scene/terrain-cm/terrain-cm.js +6 -0
  212. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  213. package/dist/scene/terrain-cm/texture_cache.js +309 -0
  214. package/dist/scene/terrain-cm/texture_cache.js.map +1 -0
  215. package/dist/scene/water.js +546 -4
  216. package/dist/scene/water.js.map +1 -1
  217. package/dist/shaders/atmosphere.js.map +1 -1
  218. package/dist/shaders/diffusion.js +54 -0
  219. package/dist/shaders/diffusion.js.map +1 -0
  220. package/dist/shaders/shadow.js +33 -21
  221. package/dist/shaders/shadow.js.map +1 -1
  222. package/dist/shaders/temporal.js +71 -33
  223. package/dist/shaders/temporal.js.map +1 -1
  224. package/dist/shaders/water.js +22 -19
  225. package/dist/shaders/water.js.map +1 -1
  226. package/dist/shaders/water_medium.js +56 -0
  227. package/dist/shaders/water_medium.js.map +1 -0
  228. package/dist/shadow/dom.js +546 -0
  229. package/dist/shadow/dom.js.map +1 -0
  230. package/dist/shadow/pcf_opt.js +3 -5
  231. package/dist/shadow/pcf_opt.js.map +1 -1
  232. package/dist/shadow/pcf_pd.js +1 -1
  233. package/dist/shadow/pcf_pd.js.map +1 -1
  234. package/dist/shadow/receiver_bias.js +41 -0
  235. package/dist/shadow/receiver_bias.js.map +1 -0
  236. package/dist/shadow/shader.js +20 -60
  237. package/dist/shadow/shader.js.map +1 -1
  238. package/dist/shadow/shadow_impl.js +89 -0
  239. package/dist/shadow/shadow_impl.js.map +1 -1
  240. package/dist/shadow/shadow_region.js +1 -1
  241. package/dist/shadow/shadow_region.js.map +1 -1
  242. package/dist/shadow/shadowmapper.js +150 -37
  243. package/dist/shadow/shadowmapper.js.map +1 -1
  244. package/dist/shapes/shape.js +11 -2
  245. package/dist/shapes/shape.js.map +1 -1
  246. package/dist/shapes/sphere.js +50 -9
  247. package/dist/shapes/sphere.js.map +1 -1
  248. package/dist/utility/blueprint/common/constants.js +112 -2
  249. package/dist/utility/blueprint/common/constants.js.map +1 -1
  250. package/dist/utility/blueprint/material/func.js +142 -49
  251. package/dist/utility/blueprint/material/func.js.map +1 -1
  252. package/dist/utility/blueprint/material/ir.js +490 -25
  253. package/dist/utility/blueprint/material/ir.js.map +1 -1
  254. package/dist/utility/blueprint/material/texture.js +898 -4
  255. package/dist/utility/blueprint/material/texture.js.map +1 -1
  256. package/dist/utility/serialization/manager.js +434 -101
  257. package/dist/utility/serialization/manager.js.map +1 -1
  258. package/dist/utility/serialization/scene/animation.js +401 -5
  259. package/dist/utility/serialization/scene/animation.js.map +1 -1
  260. package/dist/utility/serialization/scene/batch.js +4 -0
  261. package/dist/utility/serialization/scene/batch.js.map +1 -1
  262. package/dist/utility/serialization/scene/camera.js +186 -26
  263. package/dist/utility/serialization/scene/camera.js.map +1 -1
  264. package/dist/utility/serialization/scene/common.js +26 -5
  265. package/dist/utility/serialization/scene/common.js.map +1 -1
  266. package/dist/utility/serialization/scene/hair.js +1141 -0
  267. package/dist/utility/serialization/scene/hair.js.map +1 -0
  268. package/dist/utility/serialization/scene/light.js +84 -4
  269. package/dist/utility/serialization/scene/light.js.map +1 -1
  270. package/dist/utility/serialization/scene/material.js +1867 -166
  271. package/dist/utility/serialization/scene/material.js.map +1 -1
  272. package/dist/utility/serialization/scene/mesh.js +231 -14
  273. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  274. package/dist/utility/serialization/scene/node.js +141 -7
  275. package/dist/utility/serialization/scene/node.js.map +1 -1
  276. package/dist/utility/serialization/scene/particle.js +4 -0
  277. package/dist/utility/serialization/scene/particle.js.map +1 -1
  278. package/dist/utility/serialization/scene/primitive.js +18 -0
  279. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  280. package/dist/utility/serialization/scene/sprite.js +4 -0
  281. package/dist/utility/serialization/scene/sprite.js.map +1 -1
  282. package/dist/utility/serialization/scene/terrain.js +4 -0
  283. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  284. package/dist/utility/serialization/scene/text.js +4 -0
  285. package/dist/utility/serialization/scene/text.js.map +1 -1
  286. package/dist/utility/serialization/scene/water.js +1105 -21
  287. package/dist/utility/serialization/scene/water.js.map +1 -1
  288. package/dist/utility/serialization/types.js.map +1 -1
  289. package/dist/utility/shprojector.js +9 -8
  290. package/dist/utility/shprojector.js.map +1 -1
  291. package/dist/values.js +49 -2
  292. package/dist/values.js.map +1 -1
  293. package/package.json +3 -3
  294. package/dist/render/rendergraph/frame_graph_context.js +0 -41
  295. package/dist/render/rendergraph/frame_graph_context.js.map +0 -1
  296. package/dist/shaders/ssgi.js +0 -63
  297. package/dist/shaders/ssgi.js.map +0 -1
  298. package/dist/shaders/ssgi_reprojection.js +0 -118
  299. package/dist/shaders/ssgi_reprojection.js.map +0 -1
@@ -4,6 +4,7 @@
4
4
  }
5
5
  target.motionVector = !!target.motionVector || !!source.motionVector;
6
6
  target.hiZ = !!target.hiZ || !!source.hiZ;
7
+ target.hiZNearest = !!target.hiZNearest || !!source.hiZNearest;
7
8
  target.sceneNormal = !!target.sceneNormal || !!source.sceneNormal;
8
9
  target.sceneRoughness = !!target.sceneRoughness || !!source.sceneRoughness;
9
10
  target.shadowMask = !!target.shadowMask || !!source.shadowMask;
@@ -1 +1 @@
1
- {"version":3,"file":"frame_resource_requirements.js","sources":["../../../src/render/rendergraph/frame_resource_requirements.ts"],"sourcesContent":["/** Frame resources requested before Forward+ module setup. @public */\r\nexport interface FrameResourceRequirements {\r\n motionVector?: boolean;\r\n hiZ?: boolean;\r\n sceneNormal?: boolean;\r\n sceneRoughness?: boolean;\r\n shadowMask?: boolean;\r\n}\r\n\r\n/** Merge frame-resource requirements using monotonic OR semantics. @public */\r\nexport function mergeFrameResourceRequirements(\r\n target: FrameResourceRequirements,\r\n source: FrameResourceRequirements | null | undefined\r\n): FrameResourceRequirements {\r\n if (!source) {\r\n return target;\r\n }\r\n target.motionVector = !!target.motionVector || !!source.motionVector;\r\n target.hiZ = !!target.hiZ || !!source.hiZ;\r\n target.sceneNormal = !!target.sceneNormal || !!source.sceneNormal;\r\n target.sceneRoughness = !!target.sceneRoughness || !!source.sceneRoughness;\r\n target.shadowMask = !!target.shadowMask || !!source.shadowMask;\r\n return target;\r\n}\r\n"],"names":["mergeFrameResourceRequirements","target","source","motionVector","hiZ","sceneNormal","sceneRoughness","shadowMask"],"mappings":"AAAA,sJAUO,SAASA,8BACdC,CAAAA,MAAiC,EACjCC,MAAoD,EAAA;AAEpD,IAAA,IAAI,CAACA,MAAQ,EAAA;QACX,OAAOD,MAAAA;AACT;IACAA,MAAOE,CAAAA,YAAY,GAAG,CAAC,CAACF,MAAAA,CAAOE,YAAY,IAAI,CAAC,CAACD,MAAAA,CAAOC,YAAY;IACpEF,MAAOG,CAAAA,GAAG,GAAG,CAAC,CAACH,MAAAA,CAAOG,GAAG,IAAI,CAAC,CAACF,MAAAA,CAAOE,GAAG;IACzCH,MAAOI,CAAAA,WAAW,GAAG,CAAC,CAACJ,MAAAA,CAAOI,WAAW,IAAI,CAAC,CAACH,MAAAA,CAAOG,WAAW;IACjEJ,MAAOK,CAAAA,cAAc,GAAG,CAAC,CAACL,MAAAA,CAAOK,cAAc,IAAI,CAAC,CAACJ,MAAAA,CAAOI,cAAc;IAC1EL,MAAOM,CAAAA,UAAU,GAAG,CAAC,CAACN,MAAAA,CAAOM,UAAU,IAAI,CAAC,CAACL,MAAAA,CAAOK,UAAU;IAC9D,OAAON,MAAAA;AACT;;;;"}
1
+ {"version":3,"file":"frame_resource_requirements.js","sources":["../../../src/render/rendergraph/frame_resource_requirements.ts"],"sourcesContent":["/** Frame resources requested before Forward+ module setup. @public */\r\nexport interface FrameResourceRequirements {\r\n motionVector?: boolean;\r\n hiZ?: boolean;\r\n /**\r\n * The Hi-Z pyramid's nearest-depth channel, for proximity queries.\r\n *\r\n * Implies {@link FrameResourceRequirements.hiZ} - it is a second channel of\r\n * the same pyramid, not a separate resource - and costs that pyramid's\r\n * bandwidth twice over, so it is requested separately from it.\r\n */\r\n hiZNearest?: boolean;\r\n sceneNormal?: boolean;\r\n sceneRoughness?: boolean;\r\n shadowMask?: boolean;\r\n}\r\n\r\n/** Merge frame-resource requirements using monotonic OR semantics. @public */\r\nexport function mergeFrameResourceRequirements(\r\n target: FrameResourceRequirements,\r\n source: FrameResourceRequirements | null | undefined\r\n): FrameResourceRequirements {\r\n if (!source) {\r\n return target;\r\n }\r\n target.motionVector = !!target.motionVector || !!source.motionVector;\r\n target.hiZ = !!target.hiZ || !!source.hiZ;\r\n target.hiZNearest = !!target.hiZNearest || !!source.hiZNearest;\r\n target.sceneNormal = !!target.sceneNormal || !!source.sceneNormal;\r\n target.sceneRoughness = !!target.sceneRoughness || !!source.sceneRoughness;\r\n target.shadowMask = !!target.shadowMask || !!source.shadowMask;\r\n return target;\r\n}\r\n"],"names":["mergeFrameResourceRequirements","target","source","motionVector","hiZ","hiZNearest","sceneNormal","sceneRoughness","shadowMask"],"mappings":"AAAA,sJAkBO,SAASA,8BACdC,CAAAA,MAAiC,EACjCC,MAAoD,EAAA;AAEpD,IAAA,IAAI,CAACA,MAAQ,EAAA;QACX,OAAOD,MAAAA;AACT;IACAA,MAAOE,CAAAA,YAAY,GAAG,CAAC,CAACF,MAAAA,CAAOE,YAAY,IAAI,CAAC,CAACD,MAAAA,CAAOC,YAAY;IACpEF,MAAOG,CAAAA,GAAG,GAAG,CAAC,CAACH,MAAAA,CAAOG,GAAG,IAAI,CAAC,CAACF,MAAAA,CAAOE,GAAG;IACzCH,MAAOI,CAAAA,UAAU,GAAG,CAAC,CAACJ,MAAAA,CAAOI,UAAU,IAAI,CAAC,CAACH,MAAAA,CAAOG,UAAU;IAC9DJ,MAAOK,CAAAA,WAAW,GAAG,CAAC,CAACL,MAAAA,CAAOK,WAAW,IAAI,CAAC,CAACJ,MAAAA,CAAOI,WAAW;IACjEL,MAAOM,CAAAA,cAAc,GAAG,CAAC,CAACN,MAAAA,CAAOM,cAAc,IAAI,CAAC,CAACL,MAAAA,CAAOK,cAAc;IAC1EN,MAAOO,CAAAA,UAAU,GAAG,CAAC,CAACP,MAAAA,CAAOO,UAAU,IAAI,CAAC,CAACN,MAAAA,CAAOM,UAAU;IAC9D,OAAOP,MAAAA;AACT;;;;"}
@@ -7,7 +7,14 @@
7
7
  /** Denoised diffuse irradiance reprojected into the next frame's lighting pass. */ SSGI_IRRADIANCE: 'ssgiIrradiance',
8
8
  /** Depth/normal surface data used to validate SSGI reprojection. */ SSGI_SURFACE: 'ssgiSurface',
9
9
  /** First and second luminance moments used by the SSGI temporal filter. */ SSGI_MOMENTS: 'ssgiMoments',
10
- /** Temporally accumulated screen space ambient occlusion traced alongside SSGI. */ SSGI_AO: 'ssgiAO'
10
+ /** Temporally accumulated screen space ambient occlusion traced alongside SSGI. */ SSGI_AO: 'ssgiAO',
11
+ /**
12
+ * Previous frame's resolved water caustic map.
13
+ *
14
+ * Reprojected in light space rather than screen space: the map is an
15
+ * orthographic slice perpendicular to the sun, so it needs no motion vectors
16
+ * and survives the camera turning on the spot.
17
+ */ WATER_CAUSTICS: 'waterCaustics'
11
18
  };
12
19
 
13
20
  export { RGHistoryResources };
@@ -1 +1 @@
1
- {"version":3,"file":"history_resources.js","sources":["../../../src/render/rendergraph/history_resources.ts"],"sourcesContent":["/** Render graph history resource names. @public */\r\nexport const RGHistoryResources = {\r\n TAA_COLOR: 'taaColor',\r\n TAA_MOTION_VECTOR: 'taaMotionVector',\r\n SSR_REFLECT: 'ssrReflect',\r\n SSR_MOTION_VECTOR: 'ssrMotionVector',\r\n /** Opaque linear-HDR scene color sampled by SSGI rays on the next frame. */\r\n SSGI_SCENE_COLOR: 'ssgiSceneColor',\r\n /** Denoised diffuse irradiance reprojected into the next frame's lighting pass. */\r\n SSGI_IRRADIANCE: 'ssgiIrradiance',\r\n /** Depth/normal surface data used to validate SSGI reprojection. */\r\n SSGI_SURFACE: 'ssgiSurface',\r\n /** First and second luminance moments used by the SSGI temporal filter. */\r\n SSGI_MOMENTS: 'ssgiMoments',\r\n /** Temporally accumulated screen space ambient occlusion traced alongside SSGI. */\r\n SSGI_AO: 'ssgiAO'\r\n} as const;\r\n"],"names":["RGHistoryResources","TAA_COLOR","TAA_MOTION_VECTOR","SSR_REFLECT","SSR_MOTION_VECTOR","SSGI_SCENE_COLOR","SSGI_IRRADIANCE","SSGI_SURFACE","SSGI_MOMENTS","SSGI_AO"],"mappings":"AAAA,oDACO,MAAMA,kBAAqB,GAAA;IAChCC,SAAW,EAAA,UAAA;IACXC,iBAAmB,EAAA,iBAAA;IACnBC,WAAa,EAAA,YAAA;IACbC,iBAAmB,EAAA,iBAAA;AACnB,iFACAC,gBAAkB,EAAA,gBAAA;AAClB,wFACAC,eAAiB,EAAA,gBAAA;AACjB,yEACAC,YAAc,EAAA,aAAA;AACd,gFACAC,YAAc,EAAA,aAAA;AACd,wFACAC,OAAS,EAAA;AACX;;;;"}
1
+ {"version":3,"file":"history_resources.js","sources":["../../../src/render/rendergraph/history_resources.ts"],"sourcesContent":["/** Render graph history resource names. @public */\r\nexport const RGHistoryResources = {\r\n TAA_COLOR: 'taaColor',\r\n TAA_MOTION_VECTOR: 'taaMotionVector',\r\n SSR_REFLECT: 'ssrReflect',\r\n SSR_MOTION_VECTOR: 'ssrMotionVector',\r\n /** Opaque linear-HDR scene color sampled by SSGI rays on the next frame. */\r\n SSGI_SCENE_COLOR: 'ssgiSceneColor',\r\n /** Denoised diffuse irradiance reprojected into the next frame's lighting pass. */\r\n SSGI_IRRADIANCE: 'ssgiIrradiance',\r\n /** Depth/normal surface data used to validate SSGI reprojection. */\r\n SSGI_SURFACE: 'ssgiSurface',\r\n /** First and second luminance moments used by the SSGI temporal filter. */\r\n SSGI_MOMENTS: 'ssgiMoments',\r\n /** Temporally accumulated screen space ambient occlusion traced alongside SSGI. */\r\n SSGI_AO: 'ssgiAO',\r\n /**\r\n * Previous frame's resolved water caustic map.\r\n *\r\n * Reprojected in light space rather than screen space: the map is an\r\n * orthographic slice perpendicular to the sun, so it needs no motion vectors\r\n * and survives the camera turning on the spot.\r\n */\r\n WATER_CAUSTICS: 'waterCaustics'\r\n} as const;\r\n"],"names":["RGHistoryResources","TAA_COLOR","TAA_MOTION_VECTOR","SSR_REFLECT","SSR_MOTION_VECTOR","SSGI_SCENE_COLOR","SSGI_IRRADIANCE","SSGI_SURFACE","SSGI_MOMENTS","SSGI_AO","WATER_CAUSTICS"],"mappings":"AAAA,oDACO,MAAMA,kBAAqB,GAAA;IAChCC,SAAW,EAAA,UAAA;IACXC,iBAAmB,EAAA,iBAAA;IACnBC,WAAa,EAAA,YAAA;IACbC,iBAAmB,EAAA,iBAAA;AACnB,iFACAC,gBAAkB,EAAA,gBAAA;AAClB,wFACAC,eAAiB,EAAA,gBAAA;AACjB,yEACAC,YAAc,EAAA,aAAA;AACd,gFACAC,YAAc,EAAA,aAAA;AACd,wFACAC,OAAS,EAAA,QAAA;AACT;;;;;;AAMC,MACDC,cAAgB,EAAA;AAClB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"rendergraph.js","sources":["../../../src/render/rendergraph/rendergraph.ts"],"sourcesContent":["import {\r\n RGHandle,\r\n type RGTextureHandle,\r\n type RGFramebufferHandle,\r\n type RGTokenHandle,\r\n RGResource,\r\n RGPass,\r\n RGSubpass,\r\n type RGTextureDesc,\r\n type RGFramebufferDesc,\r\n type RGPassBuilder,\r\n type RGExecuteFn,\r\n type RGExecuteContext,\r\n type CompiledRenderGraph,\r\n type RGResourceLifetime,\r\n type RGWriteOptions\r\n} from './types';\r\n\r\n/** Declarative render pass and resource dependency graph. @public */\r\nexport class RenderGraph {\r\n private _nextResourceId = 0;\r\n private _resources: Map<number, RGResource> = new Map();\r\n private _passes: RGPass<any>[] = [];\r\n private _compiled: CompiledRenderGraph | null = null;\r\n private _lastWriterByPhysicalId = new Map<number, RGPass<any>>();\r\n /** Deduplicates warnings across per-frame graph instances. */\r\n private static _warnedCulledPasses = new Set<string>();\r\n\r\n /** Import an external texture that the graph does not own. */\r\n importTexture<TTexture = unknown>(name: string): RGTextureHandle<TTexture> {\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, 'texture');\r\n }\r\n\r\n /**\r\n * Add a pass. The setup callback declares dependencies and execution.\r\n */\r\n addPass<T = void>(name: string, setup: (builder: RGPassBuilder) => T): T {\r\n let nameOccurrence = 0;\r\n for (const existing of this._passes) {\r\n if (existing.name === name) {\r\n nameOccurrence++;\r\n }\r\n }\r\n const pass = new RGPass<T>(this._passes.length, name, nameOccurrence);\r\n const builder = this._createBuilder(pass);\r\n const initialResourceIds = new Set(this._resources.keys());\r\n try {\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 } catch (error) {\r\n for (const id of this._resources.keys()) {\r\n if (!initialResourceIds.has(id)) {\r\n this._resources.delete(id);\r\n }\r\n }\r\n for (const resource of this._resources.values()) {\r\n for (let i = resource.consumers.length - 1; i >= 0; i--) {\r\n if (resource.consumers[i] === pass) {\r\n resource.consumers.splice(i, 1);\r\n }\r\n }\r\n if (resource.nextWriter === pass) {\r\n resource.nextWriter = null;\r\n }\r\n }\r\n // Remove WAR edges added to existing passes before setup failed.\r\n for (const existing of this._passes) {\r\n for (let i = existing.warDependencies.length - 1; i >= 0; i--) {\r\n if (existing.warDependencies[i] === pass) {\r\n existing.warDependencies.splice(i, 1);\r\n }\r\n }\r\n }\r\n this._lastWriterByPhysicalId.clear();\r\n for (const resource of this._resources.values()) {\r\n if (resource.producer) {\r\n this._lastWriterByPhysicalId.set(resource.physicalId, resource.producer);\r\n }\r\n }\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Cull dead passes, sort dependencies, and calculate resource lifetimes.\r\n * Outputs must be their latest written versions.\r\n */\r\n compile(outputs: RGHandle[]): CompiledRenderGraph {\r\n this._validateOutputs(outputs);\r\n this._cullDeadPasses(outputs);\r\n const ordered = this._topologicalSort();\r\n const lifetimes = this._analyzeLifetimes(ordered);\r\n this._validateAllocationKeys(lifetimes);\r\n\r\n this._compiled = { orderedPasses: ordered, lifetimes };\r\n return this._compiled;\r\n }\r\n\r\n /** @internal Test-only callback runner; resource-managed code uses RenderGraphExecutor. */\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 };\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 /** Clear all passes, resources, and compiled state. */\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 this._lastWriterByPhysicalId.clear();\r\n }\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<any>> {\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 _createBuilder<T>(pass: RGPass<T>): RGPassBuilder<T> {\r\n const graph = this;\r\n const textureLabelOccurrences = new Map<string, number>();\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 graph._declareRead(pass, res);\r\n },\r\n write<TTexture>(\r\n handle: RGTextureHandle<TTexture> | RGHandle,\r\n options: RGWriteOptions | undefined\r\n ): RGTextureHandle<TTexture> {\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 const discard = options?.load === 'discard';\r\n const previousWriter = graph._lastWriterByPhysicalId.get(res.physicalId);\r\n if (previousWriter && previousWriter !== pass) {\r\n const dependencies = discard ? pass.orderingDependencies : pass.dependencies;\r\n if (!dependencies.includes(previousWriter)) {\r\n dependencies.push(previousWriter);\r\n }\r\n }\r\n // WAR orders live readers before the overwrite without retaining them.\r\n for (const consumer of res.consumers) {\r\n if (consumer !== pass && !pass.warDependencies.includes(consumer)) {\r\n pass.warDependencies.push(consumer);\r\n }\r\n }\r\n if (res.producer && res.producer !== pass) {\r\n const dependencies = discard ? pass.orderingDependencies : pass.dependencies;\r\n if (!dependencies.includes(res.producer)) {\r\n dependencies.push(res.producer);\r\n }\r\n }\r\n const id = graph._nextResourceId++;\r\n const versionName = `${res.name}@${pass.name}`;\r\n const version = new RGResource(\r\n id,\r\n versionName,\r\n res.kind,\r\n res.desc,\r\n res.physicalId,\r\n res.allocationKey\r\n );\r\n version.producer = pass;\r\n // WAW edges make the first overwrite sufficient for stale readers.\r\n if (!res.nextWriter) {\r\n res.nextWriter = pass;\r\n }\r\n graph._resources.set(id, version);\r\n graph._lastWriterByPhysicalId.set(res.physicalId, pass);\r\n if (!pass.writes.includes(version)) {\r\n pass.writes.push(version);\r\n }\r\n return new RGHandle(id, versionName, 'texture');\r\n },\r\n createTexture<TTexture = unknown>(desc: RGTextureDesc): RGTextureHandle<TTexture> {\r\n if (desc.allocationKey !== undefined && desc.allocationKey.length === 0) {\r\n throw new Error(`RenderGraph: pass \"${pass.name}\" specified an empty texture allocationKey.`);\r\n }\r\n const id = graph._nextResourceId++;\r\n const name = desc.label ?? `_tex_${id}`;\r\n const labelKey = desc.label ?? '<unnamed>';\r\n const labelOccurrence = textureLabelOccurrences.get(labelKey) ?? 0;\r\n textureLabelOccurrences.set(labelKey, labelOccurrence + 1);\r\n const allocationKey =\r\n desc.allocationKey ??\r\n `rg:${JSON.stringify([pass.name, pass.nameOccurrence, desc.label ?? null, labelOccurrence])}`;\r\n const res = new RGResource(id, name, 'transient', desc, id, allocationKey);\r\n res.producer = pass;\r\n graph._resources.set(id, res);\r\n graph._lastWriterByPhysicalId.set(res.physicalId, pass);\r\n pass.writes.push(res);\r\n return new RGHandle(id, name, 'texture');\r\n },\r\n createToken(name?: string): RGTokenHandle {\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, 'token');\r\n },\r\n createFramebuffer<TFramebuffer = unknown>(desc: RGFramebufferDesc): RGFramebufferHandle<TFramebuffer> {\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 graph._lastWriterByPhysicalId.set(res.physicalId, pass);\r\n pass.writes.push(res);\r\n graph._declareFramebufferAttachmentDeps(pass, desc);\r\n return new RGHandle(id, name, 'framebuffer');\r\n },\r\n sideEffect(): void {\r\n pass.hasSideEffect = true;\r\n },\r\n addSubpass<D = T>(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 unknown as RGExecuteFn<T>));\r\n },\r\n setExecute<D = T>(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 unknown as RGExecuteFn<T>;\r\n }\r\n };\r\n }\r\n\r\n private _validateAllocationKeys(lifetimes: ReadonlyMap<number, RGResourceLifetime>): void {\r\n const physicalByKey = new Map<string, number>();\r\n for (const lifetime of lifetimes.values()) {\r\n const resource = lifetime.resource;\r\n if (resource.kind !== 'transient' || !resource.allocationKey) {\r\n continue;\r\n }\r\n const existingPhysicalId = physicalByKey.get(resource.allocationKey);\r\n if (existingPhysicalId !== undefined && existingPhysicalId !== resource.physicalId) {\r\n throw new Error(\r\n `RenderGraph: transient allocationKey \"${resource.allocationKey}\" is used by multiple resources. ` +\r\n 'Use a unique allocationKey for each logical texture.'\r\n );\r\n }\r\n physicalByKey.set(resource.allocationKey, resource.physicalId);\r\n }\r\n }\r\n\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 private _cullDeadPasses(outputs: RGHandle[]): void {\r\n for (const pass of this._passes) {\r\n pass.alive = false;\r\n }\r\n\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<any>) => {\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 // WAR dependencies order passes but do not propagate liveness.\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 for (const pass of this._passes) {\r\n if (pass.hasSideEffect) {\r\n markPassAlive(pass);\r\n }\r\n }\r\n\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 // Warn when an ordering-only pass may have omitted sideEffect or an output.\r\n for (const pass of this._passes) {\r\n if (\r\n !pass.alive &&\r\n !pass.hasSideEffect &&\r\n pass.warDependencies.length > 0 &&\r\n !RenderGraph._warnedCulledPasses.has(pass.name)\r\n ) {\r\n RenderGraph._warnedCulledPasses.add(pass.name);\r\n console.warn(\r\n `RenderGraph: pass \"${pass.name}\" was culled but is referenced by WAR ` +\r\n `ordering edges. If its work must run, call sideEffect() or route its ` +\r\n `output into a compile() sink.`\r\n );\r\n }\r\n }\r\n }\r\n\r\n private _declareRead(pass: RGPass<any>, res: RGResource): void {\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 // A stale-version read must precede its first overwrite.\r\n if (res.nextWriter && res.nextWriter !== pass && !res.nextWriter.warDependencies.includes(pass)) {\r\n res.nextWriter.warDependencies.push(pass);\r\n }\r\n }\r\n\r\n private _declareFramebufferAttachmentDeps(\r\n pass: RGPass<any>,\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 this._declareRead(pass, res);\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 _topologicalSort(): RGPass<any>[] {\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 const aliveSet = new Set(alivePasses);\r\n const inDegree = new Map<RGPass<any>, number>();\r\n const adjacency = new Map<RGPass<any>, RGPass<any>[]>();\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<any>, to: RGPass<any>) => {\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 for (const dependency of pass.orderingDependencies) {\r\n addEdge(dependency, pass);\r\n }\r\n for (const dependency of pass.warDependencies) {\r\n addEdge(dependency, pass);\r\n }\r\n }\r\n\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 const queue: RGPass<any>[] = [];\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<any>[] = [];\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 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 _analyzeLifetimes(orderedPasses: RGPass<any>[]): Map<number, RGResourceLifetime> {\r\n const lifetimes = new Map<number, { resource: RGResource; firstUse: number; lastUse: number }>();\r\n\r\n const orderMap = new Map<RGPass<any>, 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 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 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 // Attachment textures must outlive every framebuffer use.\r\n for (const lifetime of lifetimes.values()) {\r\n const res = lifetime.resource;\r\n if (res.kind !== 'framebuffer' || !res.desc) {\r\n continue;\r\n }\r\n const desc = res.desc as RGFramebufferDesc;\r\n const extend = (attachment: unknown) => {\r\n if (!(attachment instanceof RGHandle)) {\r\n return;\r\n }\r\n const attachmentLifetime = lifetimes.get(attachment._id);\r\n if (attachmentLifetime) {\r\n attachmentLifetime.firstUse = Math.min(attachmentLifetime.firstUse, lifetime.firstUse);\r\n attachmentLifetime.lastUse = Math.max(attachmentLifetime.lastUse, lifetime.lastUse);\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 extend(attachment);\r\n }\r\n extend(desc.depthAttachment);\r\n }\r\n\r\n return lifetimes;\r\n }\r\n}\r\n"],"names":["RenderGraph","_nextResourceId","_resources","Map","_passes","_compiled","_lastWriterByPhysicalId","_warnedCulledPasses","Set","importTexture","name","id","resource","RGResource","set","RGHandle","addPass","setup","nameOccurrence","existing","pass","RGPass","length","builder","_createBuilder","initialResourceIds","keys","data","push","error","has","delete","values","i","consumers","splice","nextWriter","warDependencies","clear","producer","physicalId","compile","outputs","_validateOutputs","_cullDeadPasses","ordered","_topologicalSort","lifetimes","_analyzeLifetimes","_validateAllocationKeys","orderedPasses","execute","compiled","noopCtx","getTexture","Error","getFramebuffer","createFramebuffer","deferCleanup","subpasses","subpass","executeFn","reset","getResource","handle","get","_id","passes","resources","graph","textureLabelOccurrences","read","res","_declareRead","write","options","kind","discard","load","previousWriter","dependencies","orderingDependencies","includes","consumer","versionName","version","desc","allocationKey","writes","createTexture","undefined","label","labelKey","labelOccurrence","JSON","stringify","createToken","tokenName","_declareFramebufferAttachmentDeps","sideEffect","hasSideEffect","addSubpass","fn","RGSubpass","setExecute","physicalByKey","lifetime","existingPhysicalId","latestVersions","current","latest","alive","neededResources","stack","markResourceNeeded","add","markPassAlive","dep","reads","dependency","pop","console","warn","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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AAAA,OAAO,GAAGJ,IAAKE,CAAAA,GAAG,CAACI,kBAAmBF,CAAAA,OAAO,EAAEnD,QAAAA,CAASmD,OAAO,CAAA;AACpF;AACF,aAAA;AACA,YAAA,MAAMhC,MAASC,GAAAA,KAAAA,CAAMC,OAAO,CAACzC,IAAK0C,CAAAA,gBAAgB,CAC9C1C,GAAAA,IAAAA,CAAK0C,gBAAgB,GACrB1C,IAAK0C,CAAAA,gBAAgB,GACnB;AAAC1C,gBAAAA,IAAAA,CAAK0C;AAAiB,aAAA,GACvB,EAAE;YACR,KAAK,MAAMJ,cAAcC,MAAQ,CAAA;gBAC/BiC,MAAOlC,CAAAA,UAAAA,CAAAA;AACT;AACAkC,YAAAA,MAAAA,CAAOxE,KAAK2C,eAAe,CAAA;AAC7B;QAEA,OAAOlF,SAAAA;AACT;AACF;;;;"}
1
+ {"version":3,"file":"rendergraph.js","sources":["../../../src/render/rendergraph/rendergraph.ts"],"sourcesContent":["import {\r\n RGHandle,\r\n type RGTextureHandle,\r\n type RGFramebufferHandle,\r\n type RGTokenHandle,\r\n RGResource,\r\n RGPass,\r\n RGSubpass,\r\n type RGTextureDesc,\r\n type RGFramebufferDesc,\r\n type RGPassBuilder,\r\n type RGExecuteFn,\r\n type RGExecuteContext,\r\n type CompiledRenderGraph,\r\n type RGResourceLifetime,\r\n type RGWriteOptions\r\n} from './types';\r\nimport type { BaseTexture } from '@zephyr3d/device';\r\n\r\n/** Declarative render pass and resource dependency graph. @public */\r\nexport class RenderGraph {\r\n private _nextResourceId = 0;\r\n private _resources: Map<number, RGResource> = new Map();\r\n private _passes: RGPass<any>[] = [];\r\n private _compiled: CompiledRenderGraph | null = null;\r\n private _lastWriterByPhysicalId = new Map<number, RGPass<any>>();\r\n /** Deduplicates warnings across per-frame graph instances. */\r\n private static _warnedCulledPasses = new Set<string>();\r\n\r\n /** Import an external texture that the graph does not own. */\r\n importTexture<TTexture = BaseTexture>(name: string): RGTextureHandle<TTexture> {\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, 'texture');\r\n }\r\n\r\n /**\r\n * Add a pass. The setup callback declares dependencies and execution.\r\n */\r\n addPass<T = void>(name: string, setup: (builder: RGPassBuilder) => T): T {\r\n let nameOccurrence = 0;\r\n for (const existing of this._passes) {\r\n if (existing.name === name) {\r\n nameOccurrence++;\r\n }\r\n }\r\n const pass = new RGPass<T>(this._passes.length, name, nameOccurrence);\r\n const builder = this._createBuilder(pass);\r\n const initialResourceIds = new Set(this._resources.keys());\r\n try {\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 } catch (error) {\r\n for (const id of this._resources.keys()) {\r\n if (!initialResourceIds.has(id)) {\r\n this._resources.delete(id);\r\n }\r\n }\r\n for (const resource of this._resources.values()) {\r\n for (let i = resource.consumers.length - 1; i >= 0; i--) {\r\n if (resource.consumers[i] === pass) {\r\n resource.consumers.splice(i, 1);\r\n }\r\n }\r\n if (resource.nextWriter === pass) {\r\n resource.nextWriter = null;\r\n }\r\n }\r\n // Remove WAR edges added to existing passes before setup failed.\r\n for (const existing of this._passes) {\r\n for (let i = existing.warDependencies.length - 1; i >= 0; i--) {\r\n if (existing.warDependencies[i] === pass) {\r\n existing.warDependencies.splice(i, 1);\r\n }\r\n }\r\n }\r\n this._lastWriterByPhysicalId.clear();\r\n for (const resource of this._resources.values()) {\r\n if (resource.producer) {\r\n this._lastWriterByPhysicalId.set(resource.physicalId, resource.producer);\r\n }\r\n }\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Cull dead passes, sort dependencies, and calculate resource lifetimes.\r\n * Outputs must be their latest written versions.\r\n */\r\n compile(outputs: RGHandle[]): CompiledRenderGraph {\r\n this._validateOutputs(outputs);\r\n this._cullDeadPasses(outputs);\r\n const ordered = this._topologicalSort();\r\n const lifetimes = this._analyzeLifetimes(ordered);\r\n this._validateAllocationKeys(lifetimes);\r\n\r\n this._compiled = { orderedPasses: ordered, lifetimes };\r\n return this._compiled;\r\n }\r\n\r\n /** @internal Test-only callback runner; resource-managed code uses RenderGraphExecutor. */\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 };\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 /** Clear all passes, resources, and compiled state. */\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 this._lastWriterByPhysicalId.clear();\r\n }\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<any>> {\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 _createBuilder<T>(pass: RGPass<T>): RGPassBuilder<T> {\r\n const graph = this;\r\n const textureLabelOccurrences = new Map<string, number>();\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 graph._declareRead(pass, res);\r\n },\r\n write<TTexture>(\r\n handle: RGTextureHandle<TTexture> | RGHandle,\r\n options: RGWriteOptions | undefined\r\n ): RGTextureHandle<TTexture> {\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 const discard = options?.load === 'discard';\r\n const previousWriter = graph._lastWriterByPhysicalId.get(res.physicalId);\r\n if (previousWriter && previousWriter !== pass) {\r\n const dependencies = discard ? pass.orderingDependencies : pass.dependencies;\r\n if (!dependencies.includes(previousWriter)) {\r\n dependencies.push(previousWriter);\r\n }\r\n }\r\n // WAR orders live readers before the overwrite without retaining them.\r\n for (const consumer of res.consumers) {\r\n if (consumer !== pass && !pass.warDependencies.includes(consumer)) {\r\n pass.warDependencies.push(consumer);\r\n }\r\n }\r\n if (res.producer && res.producer !== pass) {\r\n const dependencies = discard ? pass.orderingDependencies : pass.dependencies;\r\n if (!dependencies.includes(res.producer)) {\r\n dependencies.push(res.producer);\r\n }\r\n }\r\n const id = graph._nextResourceId++;\r\n const versionName = `${res.name}@${pass.name}`;\r\n const version = new RGResource(\r\n id,\r\n versionName,\r\n res.kind,\r\n res.desc,\r\n res.physicalId,\r\n res.allocationKey\r\n );\r\n version.producer = pass;\r\n // WAW edges make the first overwrite sufficient for stale readers.\r\n if (!res.nextWriter) {\r\n res.nextWriter = pass;\r\n }\r\n graph._resources.set(id, version);\r\n graph._lastWriterByPhysicalId.set(res.physicalId, pass);\r\n if (!pass.writes.includes(version)) {\r\n pass.writes.push(version);\r\n }\r\n return new RGHandle(id, versionName, 'texture');\r\n },\r\n createTexture<TTexture = BaseTexture>(desc: RGTextureDesc): RGTextureHandle<TTexture> {\r\n if (desc.allocationKey !== undefined && desc.allocationKey.length === 0) {\r\n throw new Error(`RenderGraph: pass \"${pass.name}\" specified an empty texture allocationKey.`);\r\n }\r\n const id = graph._nextResourceId++;\r\n const name = desc.label ?? `_tex_${id}`;\r\n const labelKey = desc.label ?? '<unnamed>';\r\n const labelOccurrence = textureLabelOccurrences.get(labelKey) ?? 0;\r\n textureLabelOccurrences.set(labelKey, labelOccurrence + 1);\r\n const allocationKey =\r\n desc.allocationKey ??\r\n `rg:${JSON.stringify([pass.name, pass.nameOccurrence, desc.label ?? null, labelOccurrence])}`;\r\n const res = new RGResource(id, name, 'transient', desc, id, allocationKey);\r\n res.producer = pass;\r\n graph._resources.set(id, res);\r\n graph._lastWriterByPhysicalId.set(res.physicalId, pass);\r\n pass.writes.push(res);\r\n return new RGHandle(id, name, 'texture');\r\n },\r\n createToken(name?: string): RGTokenHandle {\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, 'token');\r\n },\r\n createFramebuffer(desc: RGFramebufferDesc): RGFramebufferHandle {\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 graph._lastWriterByPhysicalId.set(res.physicalId, pass);\r\n pass.writes.push(res);\r\n graph._declareFramebufferAttachmentDeps(pass, desc);\r\n return new RGHandle(id, name, 'framebuffer');\r\n },\r\n sideEffect(): void {\r\n pass.hasSideEffect = true;\r\n },\r\n addSubpass<D = T>(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 unknown as RGExecuteFn<T>));\r\n },\r\n setExecute<D = T>(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 unknown as RGExecuteFn<T>;\r\n }\r\n };\r\n }\r\n\r\n private _validateAllocationKeys(lifetimes: ReadonlyMap<number, RGResourceLifetime>): void {\r\n const physicalByKey = new Map<string, number>();\r\n for (const lifetime of lifetimes.values()) {\r\n const resource = lifetime.resource;\r\n if (resource.kind !== 'transient' || !resource.allocationKey) {\r\n continue;\r\n }\r\n const existingPhysicalId = physicalByKey.get(resource.allocationKey);\r\n if (existingPhysicalId !== undefined && existingPhysicalId !== resource.physicalId) {\r\n throw new Error(\r\n `RenderGraph: transient allocationKey \"${resource.allocationKey}\" is used by multiple resources. ` +\r\n 'Use a unique allocationKey for each logical texture.'\r\n );\r\n }\r\n physicalByKey.set(resource.allocationKey, resource.physicalId);\r\n }\r\n }\r\n\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 private _cullDeadPasses(outputs: RGHandle[]): void {\r\n for (const pass of this._passes) {\r\n pass.alive = false;\r\n }\r\n\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<any>) => {\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 // WAR dependencies order passes but do not propagate liveness.\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 for (const pass of this._passes) {\r\n if (pass.hasSideEffect) {\r\n markPassAlive(pass);\r\n }\r\n }\r\n\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 // Warn when an ordering-only pass may have omitted sideEffect or an output.\r\n for (const pass of this._passes) {\r\n if (\r\n !pass.alive &&\r\n !pass.hasSideEffect &&\r\n pass.warDependencies.length > 0 &&\r\n !RenderGraph._warnedCulledPasses.has(pass.name)\r\n ) {\r\n RenderGraph._warnedCulledPasses.add(pass.name);\r\n console.warn(\r\n `RenderGraph: pass \"${pass.name}\" was culled but is referenced by WAR ` +\r\n `ordering edges. If its work must run, call sideEffect() or route its ` +\r\n `output into a compile() sink.`\r\n );\r\n }\r\n }\r\n }\r\n\r\n private _declareRead(pass: RGPass<any>, res: RGResource): void {\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 // A stale-version read must precede its first overwrite.\r\n if (res.nextWriter && res.nextWriter !== pass && !res.nextWriter.warDependencies.includes(pass)) {\r\n res.nextWriter.warDependencies.push(pass);\r\n }\r\n }\r\n\r\n private _declareFramebufferAttachmentDeps(\r\n pass: RGPass<any>,\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 this._declareRead(pass, res);\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 _topologicalSort(): RGPass<any>[] {\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 const aliveSet = new Set(alivePasses);\r\n const inDegree = new Map<RGPass<any>, number>();\r\n const adjacency = new Map<RGPass<any>, RGPass<any>[]>();\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<any>, to: RGPass<any>) => {\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 for (const dependency of pass.orderingDependencies) {\r\n addEdge(dependency, pass);\r\n }\r\n for (const dependency of pass.warDependencies) {\r\n addEdge(dependency, pass);\r\n }\r\n }\r\n\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 const queue: RGPass<any>[] = [];\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<any>[] = [];\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 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 _analyzeLifetimes(orderedPasses: RGPass<any>[]): Map<number, RGResourceLifetime> {\r\n const lifetimes = new Map<number, { resource: RGResource; firstUse: number; lastUse: number }>();\r\n\r\n const orderMap = new Map<RGPass<any>, 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 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 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 // Attachment textures must outlive every framebuffer use.\r\n for (const lifetime of lifetimes.values()) {\r\n const res = lifetime.resource;\r\n if (res.kind !== 'framebuffer' || !res.desc) {\r\n continue;\r\n }\r\n const desc = res.desc as RGFramebufferDesc;\r\n const extend = (attachment: unknown) => {\r\n if (!(attachment instanceof RGHandle)) {\r\n return;\r\n }\r\n const attachmentLifetime = lifetimes.get(attachment._id);\r\n if (attachmentLifetime) {\r\n attachmentLifetime.firstUse = Math.min(attachmentLifetime.firstUse, lifetime.firstUse);\r\n attachmentLifetime.lastUse = Math.max(attachmentLifetime.lastUse, lifetime.lastUse);\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 extend(attachment);\r\n }\r\n extend(desc.depthAttachment);\r\n }\r\n\r\n return lifetimes;\r\n }\r\n}\r\n"],"names":["RenderGraph","_nextResourceId","_resources","Map","_passes","_compiled","_lastWriterByPhysicalId","_warnedCulledPasses","Set","importTexture","name","id","resource","RGResource","set","RGHandle","addPass","setup","nameOccurrence","existing","pass","RGPass","length","builder","_createBuilder","initialResourceIds","keys","data","push","error","has","delete","values","i","consumers","splice","nextWriter","warDependencies","clear","producer","physicalId","compile","outputs","_validateOutputs","_cullDeadPasses","ordered","_topologicalSort","lifetimes","_analyzeLifetimes","_validateAllocationKeys","orderedPasses","execute","compiled","noopCtx","getTexture","Error","getFramebuffer","createFramebuffer","deferCleanup","subpasses","subpass","executeFn","reset","getResource","handle","get","_id","passes","resources","graph","textureLabelOccurrences","read","res","_declareRead","write","options","kind","discard","load","previousWriter","dependencies","orderingDependencies","includes","consumer","versionName","version","desc","allocationKey","writes","createTexture","undefined","label","labelKey","labelOccurrence","JSON","stringify","createToken","tokenName","_declareFramebufferAttachmentDeps","sideEffect","hasSideEffect","addSubpass","fn","RGSubpass","setExecute","physicalByKey","lifetime","existingPhysicalId","latestVersions","current","latest","alive","neededResources","stack","markResourceNeeded","add","markPassAlive","dep","reads","dependency","pop","console","warn","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","first","Infinity","last","idx","Math","min","max","firstUse","lastUse","extend","attachmentLifetime"],"mappings":";;AAmBA,sEACO,MAAMA,WAAAA,CAAAA;AACHC,IAAAA,eAAAA,GAAkB,CAAE;AACpBC,IAAAA,UAAAA,GAAsC,IAAIC,GAAM,EAAA;AAChDC,IAAAA,OAAAA,GAAyB,EAAE;AAC3BC,IAAAA,SAAAA,GAAwC,IAAK;AAC7CC,IAAAA,uBAAAA,GAA0B,IAAIH,GAA2B,EAAA;AACjE,mEACA,OAAeI,mBAAsB,GAAA,IAAIC,GAAc,EAAA;mEAGvDC,aAAsCC,CAAAA,IAAY,EAA6B;QAC7E,MAAMC,EAAAA,GAAK,IAAI,CAACV,eAAe,EAAA;AAC/B,QAAA,MAAMW,QAAW,GAAA,IAAIC,UAAWF,CAAAA,EAAAA,EAAID,MAAM,UAAY,EAAA,IAAA,CAAA;AACtD,QAAA,IAAI,CAACR,UAAU,CAACY,GAAG,CAACH,EAAIC,EAAAA,QAAAA,CAAAA;QACxB,IAAI,CAACP,SAAS,GAAG,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;YACzC,MAAMwC,GAAAA,GAAMkC,SAAS9F,QAAQ;AAC7B,YAAA,IAAI4D,IAAII,IAAI,KAAK,iBAAiB,CAACJ,GAAAA,CAAIc,IAAI,EAAE;AAC3C,gBAAA;AACF;YACA,MAAMA,IAAAA,GAAOd,IAAIc,IAAI;AACrB,YAAA,MAAMwE,SAAS,CAAClC,UAAAA,GAAAA;AACd,gBAAA,IAAI,EAAEA,UAAsB7G,YAAAA,QAAO,CAAI,EAAA;AACrC,oBAAA;AACF;AACA,gBAAA,MAAMgJ,kBAAqBhH,GAAAA,SAAAA,CAAUkB,GAAG,CAAC2D,WAAW1D,GAAG,CAAA;AACvD,gBAAA,IAAI6F,kBAAoB,EAAA;oBACtBA,kBAAmBH,CAAAA,QAAQ,GAAGH,IAAKC,CAAAA,GAAG,CAACK,kBAAmBH,CAAAA,QAAQ,EAAElD,QAAAA,CAASkD,QAAQ,CAAA;oBACrFG,kBAAmBF,CAAAA,OAAO,GAAGJ,IAAKE,CAAAA,GAAG,CAACI,kBAAmBF,CAAAA,OAAO,EAAEnD,QAAAA,CAASmD,OAAO,CAAA;AACpF;AACF,aAAA;AACA,YAAA,MAAMhC,MAASC,GAAAA,KAAAA,CAAMC,OAAO,CAACzC,IAAK0C,CAAAA,gBAAgB,CAC9C1C,GAAAA,IAAAA,CAAK0C,gBAAgB,GACrB1C,IAAK0C,CAAAA,gBAAgB,GACnB;AAAC1C,gBAAAA,IAAAA,CAAK0C;AAAiB,aAAA,GACvB,EAAE;YACR,KAAK,MAAMJ,cAAcC,MAAQ,CAAA;gBAC/BiC,MAAOlC,CAAAA,UAAAA,CAAAA;AACT;AACAkC,YAAAA,MAAAA,CAAOxE,KAAK2C,eAAe,CAAA;AAC7B;QAEA,OAAOlF,SAAAA;AACT;AACF;;;;"}
@@ -1,4 +1,4 @@
1
- /** A texture and the resolved descriptor it satisfied in the previous execution. */ /** Remembers transient texture identities across executions without owning them. @public */ class RGTextureAffinityCache {
1
+ /** Remembers transient texture identities across executions without owning them. @public */ class RGTextureAffinityCache {
2
2
  /** @internal */ _entries = new Map();
3
3
  /** Number of logical resources remembered from the last successful execution. */ get size() {
4
4
  return this._entries.size;
@@ -1 +1 @@
1
- {"version":3,"file":"texture_affinity_cache.js","sources":["../../../src/render/rendergraph/texture_affinity_cache.ts"],"sourcesContent":["/** A texture and the resolved descriptor it satisfied in the previous execution. */\r\ninterface RGTextureAffinityEntry<TTexture> {\r\n texture: TTexture;\r\n descriptorSignature: string;\r\n}\r\n\r\n/** Remembers transient texture identities across executions without owning them. @public */\r\nexport class RGTextureAffinityCache<TTexture = unknown> {\r\n /** @internal */\r\n private _entries = new Map<string, RGTextureAffinityEntry<TTexture>>();\r\n\r\n /** Number of logical resources remembered from the last successful execution. */\r\n get size(): number {\r\n return this._entries.size;\r\n }\r\n\r\n /** Remove all remembered allocations without releasing the referenced textures. */\r\n clear(): void {\r\n this._entries.clear();\r\n }\r\n\r\n /** @internal */\r\n getPreferredTexture(allocationKey: string, descriptorSignature: string): TTexture | undefined {\r\n const entry = this._entries.get(allocationKey);\r\n return entry?.descriptorSignature === descriptorSignature ? entry.texture : undefined;\r\n }\r\n\r\n /** @internal */\r\n replace(entries: ReadonlyMap<string, RGTextureAffinityEntry<TTexture>>): void {\r\n this._entries = new Map(entries);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport type { RGTextureAffinityEntry };\r\n"],"names":["RGTextureAffinityCache","_entries","Map","size","clear","getPreferredTexture","allocationKey","descriptorSignature","entry","get","texture","undefined","replace","entries"],"mappings":"AAAA,kLAOO,MAAMA,sBAAAA,CAAAA;AACX,qBACQC,QAAW,GAAA,IAAIC,GAAgD,EAAA;sFAGvE,IAAIC,IAAe,GAAA;AACjB,QAAA,OAAO,IAAI,CAACF,QAAQ,CAACE,IAAI;AAC3B;AAEA,wFACAC,KAAc,GAAA;QACZ,IAAI,CAACH,QAAQ,CAACG,KAAK,EAAA;AACrB;AAEA,qBACAC,mBAAAA,CAAoBC,aAAqB,EAAEC,mBAA2B,EAAwB;AAC5F,QAAA,MAAMC,QAAQ,IAAI,CAACP,QAAQ,CAACQ,GAAG,CAACH,aAAAA,CAAAA;AAChC,QAAA,OAAOE,KAAOD,EAAAA,mBAAAA,KAAwBA,mBAAsBC,GAAAA,KAAAA,CAAME,OAAO,GAAGC,SAAAA;AAC9E;qBAGAC,OAAQC,CAAAA,OAA8D,EAAQ;AAC5E,QAAA,IAAI,CAACZ,QAAQ,GAAG,IAAIC,GAAIW,CAAAA,OAAAA,CAAAA;AAC1B;AACF;;;;"}
1
+ {"version":3,"file":"texture_affinity_cache.js","sources":["../../../src/render/rendergraph/texture_affinity_cache.ts"],"sourcesContent":["import type { BaseTexture } from '@zephyr3d/device';\r\n\r\n/** A texture and the resolved descriptor it satisfied in the previous execution. */\r\ninterface RGTextureAffinityEntry<TTexture> {\r\n texture: TTexture;\r\n descriptorSignature: string;\r\n}\r\n\r\n/** Remembers transient texture identities across executions without owning them. @public */\r\nexport class RGTextureAffinityCache<TTexture = BaseTexture> {\r\n /** @internal */\r\n private _entries = new Map<string, RGTextureAffinityEntry<TTexture>>();\r\n\r\n /** Number of logical resources remembered from the last successful execution. */\r\n get size(): number {\r\n return this._entries.size;\r\n }\r\n\r\n /** Remove all remembered allocations without releasing the referenced textures. */\r\n clear(): void {\r\n this._entries.clear();\r\n }\r\n\r\n /** @internal */\r\n getPreferredTexture(allocationKey: string, descriptorSignature: string): TTexture | undefined {\r\n const entry = this._entries.get(allocationKey);\r\n return entry?.descriptorSignature === descriptorSignature ? entry.texture : undefined;\r\n }\r\n\r\n /** @internal */\r\n replace(entries: ReadonlyMap<string, RGTextureAffinityEntry<TTexture>>): void {\r\n this._entries = new Map(entries);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport type { RGTextureAffinityEntry };\r\n"],"names":["RGTextureAffinityCache","_entries","Map","size","clear","getPreferredTexture","allocationKey","descriptorSignature","entry","get","texture","undefined","replace","entries"],"mappings":"AAQA,6FACO,MAAMA,sBAAAA,CAAAA;AACX,qBACQC,QAAW,GAAA,IAAIC,GAAgD,EAAA;sFAGvE,IAAIC,IAAe,GAAA;AACjB,QAAA,OAAO,IAAI,CAACF,QAAQ,CAACE,IAAI;AAC3B;AAEA,wFACAC,KAAc,GAAA;QACZ,IAAI,CAACH,QAAQ,CAACG,KAAK,EAAA;AACrB;AAEA,qBACAC,mBAAAA,CAAoBC,aAAqB,EAAEC,mBAA2B,EAAwB;AAC5F,QAAA,MAAMC,QAAQ,IAAI,CAACP,QAAQ,CAACQ,GAAG,CAACH,aAAAA,CAAAA;AAChC,QAAA,OAAOE,KAAOD,EAAAA,mBAAAA,KAAwBA,mBAAsBC,GAAAA,KAAAA,CAAME,OAAO,GAAGC,SAAAA;AAC9E;qBAGAC,OAAQC,CAAAA,OAA8D,EAAQ;AAC5E,QAAA,IAAI,CAACZ,QAAQ,GAAG,IAAIC,GAAIW,CAAAA,OAAAA,CAAAA;AAC1B;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type { AbstractDevice, TextureFormat, TimestampQueryStatus } from '@zephyr3d/device';\r\nimport type { RGTextureAffinityCache } from './texture_affinity_cache';\r\n\r\n/**\r\n * Texture size mode: fixed pixels or a backbuffer-relative scale. @public\r\n */\r\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\r\n\r\n/** Descriptor for a graph-managed transient texture. @public */\r\nexport interface RGTextureDesc {\r\n /** Debug label for this resource. */\r\n label?: string;\r\n /**\r\n * Stable identity used to prefer the same pooled texture across graph executions.\r\n * When omitted, the graph derives one from the declaring pass and resource label.\r\n */\r\n allocationKey?: string;\r\n /** Texture format. */\r\n format: TextureFormat;\r\n /** Sizing mode. Default 'backbuffer-relative'. */\r\n sizeMode?: RGSizeMode;\r\n /** Pixel width or backbuffer scale. Default 1. */\r\n width?: number;\r\n /** Pixel height or backbuffer scale. Default 1. */\r\n height?: number;\r\n /** Number of mip levels. Default 1. */\r\n mipLevels?: number;\r\n /** Array layers. Any defined value, including 1, requests a 2D array texture. */\r\n arrayLayers?: number;\r\n}\r\n\r\n/** Resource kinds that can be referenced by a graph handle. @public */\r\nexport type RGHandleKind = 'texture' | 'framebuffer' | 'token';\r\n\r\n/** Opaque render graph resource handle. @public */\r\nexport class RGHandle<K extends RGHandleKind = RGHandleKind, TValue = unknown> {\r\n /** Compile-time backing resource type. */\r\n declare readonly _value: TValue;\r\n /** @internal */\r\n readonly _id: number;\r\n /** @internal */\r\n readonly _name: string;\r\n /** Resource kind used for compile-time and runtime validation. */\r\n readonly kind: K;\r\n\r\n /** @internal */\r\n constructor(id: number, name: string, kind: K = 'texture' as K) {\r\n this._id = id;\r\n this._name = name;\r\n this.kind = kind;\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/** Texture resource handle. @public */\r\nexport type RGTextureHandle<TTexture = unknown> = RGHandle<'texture', TTexture>;\r\n\r\n/** Framebuffer resource handle. @public */\r\nexport type RGFramebufferHandle<TFramebuffer = unknown> = RGHandle<'framebuffer', TFramebuffer>;\r\n\r\n/** Ordering-only resource handle. @public */\r\nexport type RGTokenHandle = RGHandle<'token', void>;\r\n\r\n/** @public */\r\nexport type RGResourceKind = 'transient' | 'imported' | 'token' | 'framebuffer';\r\n\r\n/** Render graph resource metadata. @public */\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 /** Stable identity used for cross-frame transient texture allocation affinity. */\r\n readonly allocationKey: string | null;\r\n /** The pass that creates / writes this resource (null for imported until written). */\r\n producer: RGPass<any> | null = null;\r\n /** The pass that superseded this version via write(), or null while latest. */\r\n nextWriter: RGPass<any> | null = null;\r\n /** Passes that read this resource. */\r\n readonly consumers: RGPass<any>[] = [];\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 allocationKey: string | null = null\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 this.allocationKey = allocationKey;\r\n }\r\n}\r\n\r\n/** Resolves resources during pass execution. @public */\r\nexport interface RGExecuteContext {\r\n /**\r\n * Resolve a declared texture handle. Imported textures must first be bound on\r\n * the executor.\r\n */\r\n getTexture<TTexture>(handle: RGTextureHandle<TTexture>): TTexture;\r\n /** Resolve a texture handle stored in a generic resource container. */\r\n getTexture<TTexture = unknown>(handle: RGHandle<RGHandleKind, any>): TTexture;\r\n\r\n /** Resolve a framebuffer declared or created by the current pass. */\r\n getFramebuffer<TFramebuffer>(handle: RGFramebufferHandle<TFramebuffer>): TFramebuffer;\r\n /** Resolve a framebuffer handle stored in a generic resource container. */\r\n getFramebuffer<TFramebuffer = unknown>(handle: RGHandle<RGHandleKind, any>): TFramebuffer;\r\n\r\n /**\r\n * Create a temporary framebuffer released after execution. Handle attachments\r\n * must be declared by the current pass.\r\n */\r\n createFramebuffer<TFramebuffer = unknown>(desc: RGFramebufferDesc): TFramebuffer;\r\n\r\n /**\r\n * Run cleanup after execution or abort. Callbacks run in reverse order.\r\n */\r\n deferCleanup(callback: () => void): void;\r\n}\r\n\r\n/** Render graph execute callback. @public */\r\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\r\n\r\n/** Ordered step sharing its parent pass's resources and lifetime. @public */\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/** Controls whether a write needs the previous resource contents. @public */\r\nexport interface RGWriteOptions {\r\n /**\r\n * Use `discard` for a full overwrite so old-content producers may be culled.\r\n * Default `load`.\r\n */\r\n load?: 'load' | 'discard';\r\n}\r\n\r\n/** Render graph pass metadata. @public */\r\nexport class RGPass<T = void> {\r\n readonly index: number;\r\n readonly name: string;\r\n /** Occurrence of this pass name within the graph, used for stable allocation keys. */\r\n readonly nameOccurrence: number;\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 /**\r\n * RAW/WAW predecessors that propagate liveness.\r\n */\r\n readonly dependencies: RGPass<any>[] = [];\r\n /** WAW predecessors used only for ordering, including discard writes. */\r\n readonly orderingDependencies: RGPass<any>[] = [];\r\n /** WAR predecessors used only when both passes are alive. */\r\n readonly warDependencies: RGPass<any>[] = [];\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, nameOccurrence = 0) {\r\n this.index = index;\r\n this.name = name;\r\n this.nameOccurrence = nameOccurrence;\r\n }\r\n}\r\n\r\n/** Declares a pass's resource access and execution callback. @public */\r\nexport interface RGPassBuilder<TData = any> {\r\n /** Declare a read of an existing resource. */\r\n read(handle: RGHandle): void;\r\n\r\n /**\r\n * Write a new resource version. Use the returned handle for later reads and\r\n * graph outputs. `discard` permits old-content producers to be culled.\r\n */\r\n write<TTexture>(handle: RGTextureHandle<TTexture>, options?: RGWriteOptions): RGTextureHandle<TTexture>;\r\n\r\n /** Generic-container fallback; runtime validation still applies. */\r\n write(handle: RGHandle, options?: RGWriteOptions): RGTextureHandle;\r\n\r\n /** Create a transient texture produced by this pass. */\r\n createTexture<TTexture = unknown>(desc: RGTextureDesc): RGTextureHandle<TTexture>;\r\n\r\n /** Create a logical token for ordering passes without resource dependencies. */\r\n createToken(name?: string): RGTokenHandle;\r\n\r\n /** Create a graph-managed framebuffer and infer attachment dependencies. */\r\n createFramebuffer<TFramebuffer = unknown>(desc: RGFramebufferDesc): RGFramebufferHandle<TFramebuffer>;\r\n\r\n /** Prevent this pass from being culled. */\r\n sideEffect(): void;\r\n\r\n /** Add an ordered subpass. Cannot be combined with {@link setExecute}. */\r\n addSubpass<D = TData>(name: string, fn: RGExecuteFn<D>): void;\r\n\r\n /** Set the pass callback. Cannot be combined with {@link addSubpass}. */\r\n setExecute<D = TData>(fn: RGExecuteFn<D>): void;\r\n}\r\n\r\n/** Compiled resource lifetime. @public */\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/** Ordered passes and resource lifetimes from graph compilation. @public */\r\nexport interface CompiledRenderGraph {\r\n /** Topologically sorted passes (only non-culled passes). */\r\n readonly orderedPasses: ReadonlyArray<RGPass<any>>;\r\n /** Resource lifetime information keyed by resource ID. */\r\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\r\n}\r\n\r\n/** Profiling scope type. @public */\r\nexport type RGProfileScopeType = 'graph' | 'pass' | 'subpass';\r\n\r\n/** GPU timestamp profiling options. @public */\r\nexport interface RGProfilingOptions {\r\n /** Enable render graph timestamp profiling. Default true when an options object is provided. */\r\n enabled?: boolean;\r\n /** Measure the whole graph execution. Default true. */\r\n graph?: boolean;\r\n /** Measure every render graph pass. Default true. */\r\n pass?: boolean;\r\n /** Measure every subpass and expose it as a child scope. Default true. */\r\n subpass?: boolean;\r\n /** Include pending upload/copy commands at timestamp boundaries. Default true. */\r\n includePendingUploads?: boolean;\r\n /** Allow graph profile scopes to remain open across frame boundaries. Default false. */\r\n allowCrossFrame?: boolean;\r\n /** Maximum unresolved profile frames kept by the executor. Default 3. */\r\n maxPendingFrames?: number;\r\n /** Root graph profile label. Default 'RenderGraph'. */\r\n label?: string;\r\n /** Device used for timestamp queries. If omitted, the scene global getDevice() is used. */\r\n device?: AbstractDevice;\r\n}\r\n\r\n/** Render graph executor options. @public */\r\nexport interface RenderGraphExecutorOptions<TTexture = unknown> {\r\n /** Device used for timestamp queries. If omitted, the scene global getDevice() is used. */\r\n device?: AbstractDevice;\r\n /** Render graph timestamp profiling options. Default false. */\r\n profiling?: boolean | RGProfilingOptions;\r\n /** Cross-execution affinity state used to stabilize transient texture identities. */\r\n textureAffinityCache?: RGTextureAffinityCache<TTexture>;\r\n}\r\n\r\n/** External resources bound for one graph execution. @public */\r\nexport interface RenderGraphExecutionBindings<TTexture = unknown> {\r\n /** Imported graph texture handles and their physical textures. */\r\n readonly importedTextures?: ReadonlyMap<RGTextureHandle<TTexture>, TTexture>;\r\n}\r\n\r\n/** Resolved GPU timing for one scope. @public */\r\nexport interface RGProfileScopeResult {\r\n /** Scope label. */\r\n name: string;\r\n /** Scope type. */\r\n type: RGProfileScopeType;\r\n /** Timestamp query id used by the device, or 0 for synthetic/unsupported scopes. */\r\n queryId: number;\r\n /** GPU duration in milliseconds. */\r\n durationMs: number;\r\n /** Timestamp result status. */\r\n status: TimestampQueryStatus;\r\n /** Child scopes. */\r\n children: RGProfileScopeResult[];\r\n /** Optional diagnostic message. */\r\n message?: string;\r\n}\r\n\r\n/** GPU timing tree for one graph execution. @public */\r\nexport interface RGProfileResult {\r\n /** Render frame id when profiling began. */\r\n frameId: number;\r\n /** Aggregate profile status. */\r\n status: TimestampQueryStatus;\r\n /** Root graph scope. */\r\n graph: RGProfileScopeResult;\r\n /** Top-level pass scopes. Same objects as graph.children. */\r\n passes: RGProfileScopeResult[];\r\n}\r\n\r\n/** Resolved texture dimensions. @public */\r\nexport interface RGResolvedSize {\r\n width: number;\r\n height: number;\r\n}\r\n\r\nexport type RGTextureAttachment<TTexture = unknown> = RGTextureHandle<TTexture> | TTexture | TextureFormat;\r\n\r\n/** Backend-independent framebuffer descriptor. @public */\r\nexport interface RGFramebufferDesc<TTexture = unknown> {\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: RGTextureAttachment<TTexture> | RGTextureAttachment<TTexture>[] | null;\r\n /** Depth/stencil attachment or format. */\r\n depthAttachment?: RGTextureAttachment<TTexture> | 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 * Framebuffers are released before their attachments at the same pass boundary.\r\n * A released framebuffer must retain its attachments until texture release.\r\n *\r\n * @public\r\n */\r\nexport interface RGTextureAllocator<TTexture = unknown, TFramebuffer = unknown> {\r\n /** Allocate a transient texture, preferring a compatible prior allocation. */\r\n allocate(desc: RGTextureDesc, size: RGResolvedSize, preferred?: TTexture): TTexture;\r\n\r\n /** Release a transient texture. */\r\n release(texture: TTexture): void;\r\n\r\n /**\r\n * Retain a transient texture beyond graph execution. The external owner must\r\n * later release it.\r\n */\r\n retain?(texture: TTexture): void;\r\n\r\n /** Allocate a framebuffer released by the executor. */\r\n allocateFramebuffer?(desc: RGFramebufferDesc): TFramebuffer;\r\n\r\n /** Release a temporary framebuffer. */\r\n releaseFramebuffer?(framebuffer: TFramebuffer): void;\r\n}\r\n"],"names":["RGHandle","id","name","kind","_id","_name","RGResource","desc","producer","nextWriter","consumers","physicalId","allocationKey","RGSubpass","executeFn","RGPass","index","reads","writes","dependencies","orderingDependencies","warDependencies","hasSideEffect","data","subpasses","alive","nameOccurrence"],"mappings":"AAkCA,oDACO,MAAMA,QAAAA,CAAAA;qBAIX,GAAqB;qBAErB,KAAuB;uEAEvB,IAAiB;qBAGjB,YAAYC,EAAU,EAAEC,IAAY,EAAEC,IAAAA,GAAU,SAAc,CAAE;QAC9D,IAAI,CAACC,GAAG,GAAGH,EAAAA;QACX,IAAI,CAACI,KAAK,GAAGH,IAAAA;QACb,IAAI,CAACC,IAAI,GAAGA,IAAAA;AACd;2DAGA,IAAID,IAAe,GAAA;QACjB,OAAO,IAAI,CAACG,KAAK;AACnB;AACF;AAcA,+CACO,MAAMC,UAAAA,CAAAA;IACFL,EAAW;IACXC,IAAa;IACbC,IAAqB;IACrBI,IAA+C;mFAExD,UAA4B;uFAE5B,aAAsC;2FAEtCC,WAA+B,IAAK;oFAEpCC,aAAiC,IAAK;AACtC,2CACSC,SAA2B,GAAA,EAAE;AAEtC,IAAA,WAAA,CACET,EAAU,EACVC,IAAY,EACZC,IAAoB,EACpBI,IAA8C,EAC9CI,UAAaV,GAAAA,EAAE,EACfW,aAAAA,GAA+B,IAAI,CACnC;QACA,IAAI,CAACX,EAAE,GAAGA,EAAAA;QACV,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACI,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACI,UAAU,GAAGA,UAAAA;QAClB,IAAI,CAACC,aAAa,GAAGA,aAAAA;AACvB;AACF;AAgCA,8EACO,MAAMC,SAAAA,CAAAA;IACFX,IAAa;IACbY,SAA0B;IAEnC,WAAYZ,CAAAA,IAAY,EAAEY,SAAyB,CAAE;QACnD,IAAI,CAACZ,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACY,SAAS,GAAGA,SAAAA;AACnB;AACF;AAWA,2CACO,MAAMC,MAAAA,CAAAA;IACFC,KAAc;IACdd,IAAa;2FAEtB,cAAgC;AAChC,qDACSe,KAAsB,GAAA,EAAE;AACjC,kDACSC,MAAuB,GAAA,EAAE;AAClC;;MAGSC,YAA8B,GAAA,EAAE;AACzC,8EACSC,oBAAsC,GAAA,EAAE;AACjD,kEACSC,eAAiC,GAAA,EAAE;sEAE5CC,gBAAgB,KAAM;uDAEtBC,OAAiB,IAAK;6BAEtBT,YAAmC,IAAK;AACxC,+EACSU,SAA4B,GAAA,EAAE;gEAEvCC,QAAQ,IAAK;AAEb,IAAA,WAAA,CAAYT,KAAa,EAAEd,IAAY,EAAEwB,cAAAA,GAAiB,CAAC,CAAE;QAC3D,IAAI,CAACV,KAAK,GAAGA,KAAAA;QACb,IAAI,CAACd,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACwB,cAAc,GAAGA,cAAAA;AACxB;AACF;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type {\r\n AbstractDevice,\r\n BaseTexture,\r\n FrameBuffer,\r\n TextureFormat,\r\n TimestampQueryStatus\r\n} from '@zephyr3d/device';\r\nimport type { RGTextureAffinityCache } from './texture_affinity_cache';\r\n\r\n/**\r\n * Texture size mode: fixed pixels or a backbuffer-relative scale. @public\r\n */\r\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\r\n\r\n/** Descriptor for a graph-managed transient texture. @public */\r\nexport interface RGTextureDesc {\r\n /** Debug label for this resource. */\r\n label?: string;\r\n /**\r\n * Stable identity used to prefer the same pooled texture across graph executions.\r\n * When omitted, the graph derives one from the declaring pass and resource label.\r\n */\r\n allocationKey?: string;\r\n /** Texture format. */\r\n format: TextureFormat;\r\n /** Sizing mode. Default 'backbuffer-relative'. */\r\n sizeMode?: RGSizeMode;\r\n /** Pixel width or backbuffer scale. Default 1. */\r\n width?: number;\r\n /** Pixel height or backbuffer scale. Default 1. */\r\n height?: number;\r\n /** Number of mip levels. Default 1. */\r\n mipLevels?: number;\r\n /** Array layers. Any defined value, including 1, requests a 2D array texture. */\r\n arrayLayers?: number;\r\n}\r\n\r\n/** Resource kinds that can be referenced by a graph handle. @public */\r\nexport type RGHandleKind = 'texture' | 'framebuffer' | 'token';\r\n\r\n/** Opaque render graph resource handle. @public */\r\nexport class RGHandle<K extends RGHandleKind = RGHandleKind, TValue = unknown> {\r\n /** Compile-time backing resource type. */\r\n declare readonly _value: TValue;\r\n /** @internal */\r\n readonly _id: number;\r\n /** @internal */\r\n readonly _name: string;\r\n /** Resource kind used for compile-time and runtime validation. */\r\n readonly kind: K;\r\n\r\n /** @internal */\r\n constructor(id: number, name: string, kind: K = 'texture' as K) {\r\n this._id = id;\r\n this._name = name;\r\n this.kind = kind;\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/** Texture resource handle. @public */\r\nexport type RGTextureHandle<TTexture = BaseTexture> = RGHandle<'texture', TTexture>;\r\n\r\n/** Framebuffer resource handle. @public */\r\nexport type RGFramebufferHandle = RGHandle<'framebuffer', FrameBuffer>;\r\n\r\n/** Ordering-only resource handle. @public */\r\nexport type RGTokenHandle = RGHandle<'token', void>;\r\n\r\n/** @public */\r\nexport type RGResourceKind = 'transient' | 'imported' | 'token' | 'framebuffer';\r\n\r\n/** Render graph resource metadata. @public */\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 /** Stable identity used for cross-frame transient texture allocation affinity. */\r\n readonly allocationKey: string | null;\r\n /** The pass that creates / writes this resource (null for imported until written). */\r\n producer: RGPass<any> | null = null;\r\n /** The pass that superseded this version via write(), or null while latest. */\r\n nextWriter: RGPass<any> | null = null;\r\n /** Passes that read this resource. */\r\n readonly consumers: RGPass<any>[] = [];\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 allocationKey: string | null = null\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 this.allocationKey = allocationKey;\r\n }\r\n}\r\n\r\n/** Resolves resources during pass execution. @public */\r\nexport interface RGExecuteContext {\r\n /**\r\n * Resolve a declared texture handle. Imported textures must first be bound on\r\n * the executor.\r\n */\r\n getTexture<TTexture>(handle: RGTextureHandle<TTexture>): TTexture;\r\n /** Resolve a texture handle stored in a generic resource container. */\r\n getTexture<TTexture = BaseTexture>(handle: RGHandle<RGHandleKind, any>): TTexture;\r\n\r\n /** Resolve a framebuffer declared or created by the current pass. */\r\n getFramebuffer(handle: RGFramebufferHandle): FrameBuffer;\r\n /** Resolve a framebuffer handle stored in a generic resource container. */\r\n getFramebuffer(handle: RGHandle<RGHandleKind, any>): FrameBuffer;\r\n\r\n /**\r\n * Create a temporary framebuffer released after execution. Handle attachments\r\n * must be declared by the current pass.\r\n */\r\n createFramebuffer(desc: RGFramebufferDesc): FrameBuffer;\r\n\r\n /**\r\n * Run cleanup after execution or abort. Callbacks run in reverse order.\r\n */\r\n deferCleanup(callback: () => void): void;\r\n}\r\n\r\n/** Render graph execute callback. @public */\r\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\r\n\r\n/** Ordered step sharing its parent pass's resources and lifetime. @public */\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/** Controls whether a write needs the previous resource contents. @public */\r\nexport interface RGWriteOptions {\r\n /**\r\n * Use `discard` for a full overwrite so old-content producers may be culled.\r\n * Default `load`.\r\n */\r\n load?: 'load' | 'discard';\r\n}\r\n\r\n/** Render graph pass metadata. @public */\r\nexport class RGPass<T = void> {\r\n readonly index: number;\r\n readonly name: string;\r\n /** Occurrence of this pass name within the graph, used for stable allocation keys. */\r\n readonly nameOccurrence: number;\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 /**\r\n * RAW/WAW predecessors that propagate liveness.\r\n */\r\n readonly dependencies: RGPass<any>[] = [];\r\n /** WAW predecessors used only for ordering, including discard writes. */\r\n readonly orderingDependencies: RGPass<any>[] = [];\r\n /** WAR predecessors used only when both passes are alive. */\r\n readonly warDependencies: RGPass<any>[] = [];\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, nameOccurrence = 0) {\r\n this.index = index;\r\n this.name = name;\r\n this.nameOccurrence = nameOccurrence;\r\n }\r\n}\r\n\r\n/** Declares a pass's resource access and execution callback. @public */\r\nexport interface RGPassBuilder<TData = any> {\r\n /** Declare a read of an existing resource. */\r\n read(handle: RGHandle): void;\r\n\r\n /**\r\n * Write a new resource version. Use the returned handle for later reads and\r\n * graph outputs. `discard` permits old-content producers to be culled.\r\n */\r\n write<TTexture>(handle: RGTextureHandle<TTexture>, options?: RGWriteOptions): RGTextureHandle<TTexture>;\r\n\r\n /** Generic-container fallback; runtime validation still applies. */\r\n write(handle: RGHandle, options?: RGWriteOptions): RGTextureHandle;\r\n\r\n /** Create a transient texture produced by this pass. */\r\n createTexture<TTexture = BaseTexture>(desc: RGTextureDesc): RGTextureHandle<TTexture>;\r\n\r\n /** Create a logical token for ordering passes without resource dependencies. */\r\n createToken(name?: string): RGTokenHandle;\r\n\r\n /** Create a graph-managed framebuffer and infer attachment dependencies. */\r\n createFramebuffer(desc: RGFramebufferDesc): RGFramebufferHandle;\r\n\r\n /** Prevent this pass from being culled. */\r\n sideEffect(): void;\r\n\r\n /** Add an ordered subpass. Cannot be combined with {@link setExecute}. */\r\n addSubpass<D = TData>(name: string, fn: RGExecuteFn<D>): void;\r\n\r\n /** Set the pass callback. Cannot be combined with {@link addSubpass}. */\r\n setExecute<D = TData>(fn: RGExecuteFn<D>): void;\r\n}\r\n\r\n/** Compiled resource lifetime. @public */\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/** Ordered passes and resource lifetimes from graph compilation. @public */\r\nexport interface CompiledRenderGraph {\r\n /** Topologically sorted passes (only non-culled passes). */\r\n readonly orderedPasses: ReadonlyArray<RGPass<any>>;\r\n /** Resource lifetime information keyed by resource ID. */\r\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\r\n}\r\n\r\n/** Profiling scope type. @public */\r\nexport type RGProfileScopeType = 'graph' | 'pass' | 'subpass';\r\n\r\n/** GPU timestamp profiling options. @public */\r\nexport interface RGProfilingOptions {\r\n /** Enable render graph timestamp profiling. Default true when an options object is provided. */\r\n enabled?: boolean;\r\n /** Measure the whole graph execution. Default true. */\r\n graph?: boolean;\r\n /** Measure every render graph pass. Default true. */\r\n pass?: boolean;\r\n /** Measure every subpass and expose it as a child scope. Default true. */\r\n subpass?: boolean;\r\n /** Include pending upload/copy commands at timestamp boundaries. Default true. */\r\n includePendingUploads?: boolean;\r\n /** Allow graph profile scopes to remain open across frame boundaries. Default false. */\r\n allowCrossFrame?: boolean;\r\n /** Maximum unresolved profile frames kept by the executor. Default 3. */\r\n maxPendingFrames?: number;\r\n /** Root graph profile label. Default 'RenderGraph'. */\r\n label?: string;\r\n /** Device used for timestamp queries. If omitted, the scene global getDevice() is used. */\r\n device?: AbstractDevice;\r\n}\r\n\r\n/** Render graph executor options. @public */\r\nexport interface RenderGraphExecutorOptions<TTexture = BaseTexture> {\r\n /** Device used for timestamp queries. If omitted, the scene global getDevice() is used. */\r\n device?: AbstractDevice;\r\n /** Render graph timestamp profiling options. Default false. */\r\n profiling?: boolean | RGProfilingOptions;\r\n /** Cross-execution affinity state used to stabilize transient texture identities. */\r\n textureAffinityCache?: RGTextureAffinityCache<TTexture>;\r\n}\r\n\r\n/** External resources bound for one graph execution. @public */\r\nexport interface RenderGraphExecutionBindings<TTexture = BaseTexture> {\r\n /** Imported graph texture handles and their physical textures. */\r\n readonly importedTextures?: ReadonlyMap<RGTextureHandle<TTexture>, TTexture>;\r\n}\r\n\r\n/** Resolved GPU timing for one scope. @public */\r\nexport interface RGProfileScopeResult {\r\n /** Scope label. */\r\n name: string;\r\n /** Scope type. */\r\n type: RGProfileScopeType;\r\n /** Timestamp query id used by the device, or 0 for synthetic/unsupported scopes. */\r\n queryId: number;\r\n /** GPU duration in milliseconds. */\r\n durationMs: number;\r\n /** Timestamp result status. */\r\n status: TimestampQueryStatus;\r\n /** Child scopes. */\r\n children: RGProfileScopeResult[];\r\n /** Optional diagnostic message. */\r\n message?: string;\r\n}\r\n\r\n/** GPU timing tree for one graph execution. @public */\r\nexport interface RGProfileResult {\r\n /** Render frame id when profiling began. */\r\n frameId: number;\r\n /** Aggregate profile status. */\r\n status: TimestampQueryStatus;\r\n /** Root graph scope. */\r\n graph: RGProfileScopeResult;\r\n /** Top-level pass scopes. Same objects as graph.children. */\r\n passes: RGProfileScopeResult[];\r\n}\r\n\r\n/** Resolved texture dimensions. @public */\r\nexport interface RGResolvedSize {\r\n width: number;\r\n height: number;\r\n}\r\n\r\nexport type RGTextureAttachment<TTexture = BaseTexture> =\r\n | RGTextureHandle<TTexture>\r\n | TTexture\r\n | TextureFormat;\r\n\r\n/** Backend-independent framebuffer descriptor. @public */\r\nexport interface RGFramebufferDesc<TTexture = BaseTexture> {\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: RGTextureAttachment<TTexture> | RGTextureAttachment<TTexture>[] | null;\r\n /** Depth/stencil attachment or format. */\r\n depthAttachment?: RGTextureAttachment<TTexture> | 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 * Framebuffers are released before their attachments at the same pass boundary.\r\n * A released framebuffer must retain its attachments until texture release.\r\n *\r\n * @public\r\n */\r\nexport interface RGTextureAllocator<TTexture = BaseTexture> {\r\n /** Allocate a transient texture, preferring a compatible prior allocation. */\r\n allocate(desc: RGTextureDesc, size: RGResolvedSize, preferred?: TTexture): TTexture;\r\n\r\n /** Release a transient texture. */\r\n release(texture: TTexture): void;\r\n\r\n /**\r\n * Retain a transient texture beyond graph execution. The external owner must\r\n * later release it.\r\n */\r\n retain?(texture: TTexture): void;\r\n\r\n /** Allocate a framebuffer released by the executor. */\r\n allocateFramebuffer?(desc: RGFramebufferDesc): FrameBuffer;\r\n\r\n /** Release a temporary framebuffer. */\r\n releaseFramebuffer?(framebuffer: FrameBuffer): void;\r\n}\r\n"],"names":["RGHandle","id","name","kind","_id","_name","RGResource","desc","producer","nextWriter","consumers","physicalId","allocationKey","RGSubpass","executeFn","RGPass","index","reads","writes","dependencies","orderingDependencies","warDependencies","hasSideEffect","data","subpasses","alive","nameOccurrence"],"mappings":"AAwCA,oDACO,MAAMA,QAAAA,CAAAA;qBAIX,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EACSC,oBAAsC,GAAA,EAAE;AACjD,kEACSC,eAAiC,GAAA,EAAE;sEAE5CC,gBAAgB,KAAM;uDAEtBC,OAAiB,IAAK;6BAEtBT,YAAmC,IAAK;AACxC,+EACSU,SAA4B,GAAA,EAAE;gEAEvCC,QAAQ,IAAK;AAEb,IAAA,WAAA,CAAYT,KAAa,EAAEd,IAAY,EAAEwB,cAAAA,GAAiB,CAAC,CAAE;QAC3D,IAAI,CAACV,KAAK,GAAGA,KAAAA;QACb,IAAI,CAACd,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACwB,cAAc,GAAGA,cAAAA;AACxB;AACF;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { Vector2, Vector4, DEPTH_FARTHEST } from '@zephyr3d/base';
2
2
  import { ShaderHelper } from '../material/shader/helper.js';
3
3
  import { drawFullscreenQuad } from './fullscreenquad.js';
4
- import { MAX_SHADOW_MASK_LIGHTS } from '../values.js';
4
+ import { MAX_SHADOW_MASK_LIGHTS, LIGHT_TYPE_DIRECTIONAL } from '../values.js';
5
5
  import { fetchSampler } from '../utility/misc.js';
6
6
 
7
7
  const UNIFORM_NAME_SHADOW_MAP = 'Z_UniformShadowMap';
@@ -33,6 +33,7 @@ const UNIFORM_NAME_SHADOW_MAP = 'Z_UniformShadowMap';
33
33
  /** Bind groups paired with each cached program. */ _bindGroups;
34
34
  /** One render state per RGBA channel (color mask selects the target channel). */ _channelStates;
35
35
  _nearFar;
36
+ _invRenderSize;
36
37
  _cameraPosition;
37
38
  _cameraParams;
38
39
  constructor(){
@@ -40,6 +41,7 @@ const UNIFORM_NAME_SHADOW_MAP = 'Z_UniformShadowMap';
40
41
  this._bindGroups = new Map();
41
42
  this._channelStates = null;
42
43
  this._nearFar = new Vector2();
44
+ this._invRenderSize = new Vector2();
43
45
  this._cameraPosition = new Vector4();
44
46
  this._cameraParams = new Vector4();
45
47
  }
@@ -168,6 +170,9 @@ const UNIFORM_NAME_SHADOW_MAP = 'Z_UniformShadowMap';
168
170
  });
169
171
  bindGroup.setValue('invViewProjMatrix', camera.invViewProjectionMatrix);
170
172
  bindGroup.setValue('cameraNearFar', this._nearFar);
173
+ // Neighbour tap spacing for the depth-based normal reconstruction.
174
+ this._invRenderSize.setXY(1 / depthTexture.width, 1 / depthTexture.height);
175
+ bindGroup.setValue('invRenderSize', this._invRenderSize);
171
176
  bindGroup.setValue('flip', this.needFlip(ctx.device) ? 1 : 0);
172
177
  bindGroup.setTexture('depthTex', depthTexture, fetchSampler('clamp_nearest_nomip'));
173
178
  bindGroup.setTexture(UNIFORM_NAME_SHADOW_MAP, shadowMapParams.shadowMap, shadowMapParams.shadowMapSampler);
@@ -182,6 +187,7 @@ const UNIFORM_NAME_SHADOW_MAP = 'Z_UniformShadowMap';
182
187
  createProgram(ctx, shadowMapParams) {
183
188
  const device = ctx.device;
184
189
  const numCascades = shadowMapParams.numShadowCascades;
190
+ const lightType = shadowMapParams.lightType;
185
191
  const shadowMap = shadowMapParams.shadowMap;
186
192
  const program = device.buildRenderProgram({
187
193
  label: 'ShadowMask',
@@ -236,13 +242,60 @@ const UNIFORM_NAME_SHADOW_MAP = 'Z_UniformShadowMap';
236
242
  this.depthTex = pb.tex2D().sampleType('unfilterable-float').uniform(0);
237
243
  this.invViewProjMatrix = pb.mat4().uniform(0);
238
244
  this.cameraNearFar = pb.vec2().uniform(0);
245
+ this.invRenderSize = pb.vec2().uniform(0);
239
246
  this.$outputs.color = pb.vec4();
247
+ /**
248
+ * Geometric normal recovered from the depth prepass.
249
+ *
250
+ * The opaque queue takes its shadows from this mask rather than from
251
+ * each material's calculateShadow, so this is the only place the normal
252
+ * offset can be applied on that path - and a fullscreen pass has no
253
+ * interpolated normal to use.
254
+ *
255
+ * Naive cross(dpdx, dpdy) spans depth discontinuities and produces a
256
+ * wild normal along every silhouette. Taking the nearer neighbour on
257
+ * each axis keeps the basis on one surface instead.
258
+ */ pb.func('zReconstructNormal', [
259
+ pb.vec2('uv'),
260
+ pb.vec4('center')
261
+ ], function() {
262
+ this.$l.dx = pb.vec2(this.invRenderSize.x, 0);
263
+ this.$l.dy = pb.vec2(0, this.invRenderSize.y);
264
+ this.$l.right = ShaderHelper.samplePositionFromDepth(this, this.depthTex, pb.add(this.uv, this.dx), this.invViewProjMatrix, this.cameraNearFar);
265
+ this.$l.left = ShaderHelper.samplePositionFromDepth(this, this.depthTex, pb.sub(this.uv, this.dx), this.invViewProjMatrix, this.cameraNearFar);
266
+ this.$l.up = ShaderHelper.samplePositionFromDepth(this, this.depthTex, pb.add(this.uv, this.dy), this.invViewProjMatrix, this.cameraNearFar);
267
+ this.$l.down = ShaderHelper.samplePositionFromDepth(this, this.depthTex, pb.sub(this.uv, this.dy), this.invViewProjMatrix, this.cameraNearFar);
268
+ this.$l.edgeX = pb.sub(this.right.xyz, this.center.xyz);
269
+ this.$if(pb.lessThan(pb.abs(pb.sub(this.left.w, this.center.w)), pb.abs(pb.sub(this.right.w, this.center.w))), function() {
270
+ this.edgeX = pb.sub(this.center.xyz, this.left.xyz);
271
+ });
272
+ this.$l.edgeY = pb.sub(this.up.xyz, this.center.xyz);
273
+ this.$if(pb.lessThan(pb.abs(pb.sub(this.down.w, this.center.w)), pb.abs(pb.sub(this.up.w, this.center.w))), function() {
274
+ this.edgeY = pb.sub(this.center.xyz, this.down.xyz);
275
+ });
276
+ this.$l.n = pb.cross(this.edgeX, this.edgeY);
277
+ this.$l.len = pb.length(this.n);
278
+ // Degenerate footprint (flat depth, or a pixel with no geometry):
279
+ // report a zero normal, which yields a zero offset downstream.
280
+ this.$if(pb.lessThan(this.len, 1e-12), function() {
281
+ this.$return(pb.vec3(0));
282
+ });
283
+ this.n = pb.div(this.n, this.len);
284
+ // The cross product's sign depends on which neighbours were picked, so
285
+ // orient it towards the camera rather than tracking that.
286
+ this.$l.toEye = pb.sub(this.camera.position.xyz, this.center.xyz);
287
+ this.$if(pb.lessThan(pb.dot(this.n, this.toEye), 0), function() {
288
+ this.n = pb.neg(this.n);
289
+ });
290
+ this.$return(this.n);
291
+ });
240
292
  // Explicit-depth cascade selection (fragCoord.z is invalid in a fullscreen
241
293
  // pass). Mirrors posteffect/sss.ts calculateTransmissionShadow.
242
294
  pb.func('zShadowMaskFactor', [
243
295
  pb.vec3('worldPos'),
244
296
  pb.float('depth01'),
245
- pb.float('NoL')
297
+ pb.float('NoL'),
298
+ pb.vec3('worldNormal')
246
299
  ], function() {
247
300
  if (numCascades > 1) {
248
301
  this.$l.linearDepth = pb.mul(this.depth01, this.camera.params.y);
@@ -250,16 +303,17 @@ const UNIFORM_NAME_SHADOW_MAP = 'Z_UniformShadowMap';
250
303
  this.$l.comparison = pb.vec4(pb.greaterThan(pb.vec4(this.linearDepth), this.splitDistances));
251
304
  this.$l.cascadeFlags = pb.vec4(pb.float(pb.greaterThan(this.light.shadowCascades, 0)), pb.float(pb.greaterThan(this.light.shadowCascades, 1)), pb.float(pb.greaterThan(this.light.shadowCascades, 2)), pb.float(pb.greaterThan(this.light.shadowCascades, 3)));
252
305
  this.$l.split = pb.int(pb.dot(this.comparison, this.cascadeFlags));
306
+ this.$l.biasedPos = ShaderHelper.applyShadowNormalOffset(shadowMapParams.lightType, this, this.worldPos, this.worldNormal, this.NoL, ShaderHelper.getShadowCascadeBiasScale(this, this.split));
253
307
  if (device.type === 'webgl') {
254
308
  this.$l.shadowVertex = pb.vec4();
255
309
  this.$for(pb.int('cascade'), 0, 4, function() {
256
310
  this.$if(pb.equal(this.cascade, this.split), function() {
257
- this.shadowVertex = ShaderHelper.calculateShadowSpaceVertex(this, pb.vec4(this.worldPos, 1), this.cascade);
311
+ this.shadowVertex = ShaderHelper.calculateShadowSpaceVertex(this, pb.vec4(this.biasedPos, 1), this.cascade);
258
312
  this.$break();
259
313
  });
260
314
  });
261
315
  } else {
262
- this.$l.shadowVertex = ShaderHelper.calculateShadowSpaceVertex(this, pb.vec4(this.worldPos, 1), this.split);
316
+ this.$l.shadowVertex = ShaderHelper.calculateShadowSpaceVertex(this, pb.vec4(this.biasedPos, 1), this.split);
263
317
  }
264
318
  this.$l.shadow = shadowMapParams.impl.computeShadowCSM(shadowMapParams, this, this.shadowVertex, this.NoL, this.split);
265
319
  this.$l.shadowDistance = this.light.shadowCameraParams.w;
@@ -267,7 +321,8 @@ const UNIFORM_NAME_SHADOW_MAP = 'Z_UniformShadowMap';
267
321
  this.shadow = pb.mix(1, this.shadow, this.light.shadowStrength);
268
322
  this.$return(pb.clamp(this.shadow, 0, 1));
269
323
  } else {
270
- this.$l.shadowVertex = ShaderHelper.calculateShadowSpaceVertex(this, pb.vec4(this.worldPos, 1));
324
+ this.$l.biasedPos = ShaderHelper.applyShadowNormalOffset(shadowMapParams.lightType, this, this.worldPos, this.worldNormal, this.NoL);
325
+ this.$l.shadowVertex = ShaderHelper.calculateShadowSpaceVertex(this, pb.vec4(this.biasedPos, 1));
271
326
  this.$l.shadow = shadowMapParams.impl.computeShadow(shadowMapParams, this, this.shadowVertex, this.NoL);
272
327
  this.$l.shadowDistance = this.light.shadowCameraParams.w;
273
328
  this.shadow = pb.mix(this.shadow, 1, pb.smoothStep(pb.mul(this.shadowDistance, 0.8), this.shadowDistance, pb.distance(this.camera.position.xyz, this.worldPos)));
@@ -277,9 +332,19 @@ const UNIFORM_NAME_SHADOW_MAP = 'Z_UniformShadowMap';
277
332
  });
278
333
  pb.main(function() {
279
334
  this.$l.pos = ShaderHelper.samplePositionFromDepth(this, this.depthTex, this.$inputs.uv, this.invViewProjMatrix, this.cameraNearFar);
280
- // NoL is unavailable in a fullscreen pass (no geometric normal); it only
281
- // feeds normal-offset bias, so a conservative 1.0 is used.
282
- this.$l.factor = this.zShadowMaskFactor(this.pos.xyz, this.pos.w, pb.float(1));
335
+ // The normal is recovered from the depth prepass rather than
336
+ // interpolated, because this pass is where the opaque queue's shadows
337
+ // are decided and normal offset bias needs one.
338
+ this.$l.normal = this.zReconstructNormal(this.$inputs.uv, this.pos);
339
+ this.$l.lightDir = lightType === LIGHT_TYPE_DIRECTIONAL ? pb.neg(this.light.directionAndCutoff.xyz) : pb.normalize(pb.sub(this.light.positionAndRange.xyz, this.pos.xyz));
340
+ // A zero normal (degenerate reconstruction) gives NoL 0, hence the
341
+ // largest offset. Clamp to 1 there instead so those pixels fall back to
342
+ // the unoffset behaviour rather than being pushed the furthest.
343
+ this.$l.NoL = pb.float(1);
344
+ this.$if(pb.greaterThan(pb.dot(this.normal, this.normal), 0.5), function() {
345
+ this.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);
346
+ });
347
+ this.$l.factor = this.zShadowMaskFactor(this.pos.xyz, this.pos.w, this.NoL, this.normal);
283
348
  this.$outputs.color = pb.vec4(this.factor);
284
349
  });
285
350
  }