@zephyr3d/scene 0.9.2 → 0.9.4
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.
- package/dist/animation/animationset.js +135 -135
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/ik/ik_chain_builder.js +68 -0
- package/dist/animation/ik/ik_chain_builder.js.map +1 -0
- package/dist/animation/ik/ik_pole_constraint.js +2 -7
- package/dist/animation/ik/ik_pole_constraint.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +146 -146
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/math.js +16 -0
- package/dist/animation/joint_dynamics/math.js.map +1 -0
- package/dist/animation/spring/spring_system.js +75 -75
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring2/constraints.js.map +1 -1
- package/dist/animation/spring2/controller.js +64 -64
- package/dist/animation/spring2/controller.js.map +1 -1
- package/dist/animation/spring2/math.js.map +1 -1
- package/dist/animation/spring2/spring_system.js +8 -8
- package/dist/animation/spring2/spring_system.js.map +1 -1
- package/dist/app/engine.js +119 -71
- package/dist/app/engine.js.map +1 -1
- package/dist/asset/assetmanager.js +296 -244
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +1 -0
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/camera/camera.js +184 -184
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +685 -38
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/material/material.js +290 -290
- package/dist/material/material.js.map +1 -1
- package/dist/material/msdf_text.js +180 -0
- package/dist/material/msdf_text.js.map +1 -0
- package/dist/material/msdf_text_sprite.js +64 -0
- package/dist/material/msdf_text_sprite.js.map +1 -0
- package/dist/material/pbrblueprint.js +123 -108
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/shader/helper.js +6 -3
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/sprite_sdf.js +106 -0
- package/dist/material/sprite_sdf.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +38 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +10 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +127 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +263 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +1 -0
- package/dist/posteffect/ssr.js +1 -0
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/render/abuffer_oit.js +1 -0
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js +3 -4
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +28 -0
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/drawable_mixin.js +1 -0
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +1 -0
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +1 -0
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +1 -0
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/render_queue.js +1 -0
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/rendergraph/history_resource_manager.js +93 -93
- package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +3 -3
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/render/rendergraph/types.js +22 -22
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/scene/basesprite.js +1 -5
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +29 -17
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +1 -0
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/mesh.js +8 -9
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +96 -0
- package/dist/scene/meshdrawable.js.map +1 -0
- package/dist/scene/msdftext.js +341 -0
- package/dist/scene/msdftext.js.map +1 -0
- package/dist/scene/msdftextsprite.js +349 -0
- package/dist/scene/msdftextsprite.js.map +1 -0
- package/dist/scene/particlesys.js +1 -0
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +1 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +6 -0
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/sdftextsprite.js +322 -0
- package/dist/scene/sdftextsprite.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +1 -0
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +1 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/textsprite.js +120 -0
- package/dist/scene/textsprite.js.map +1 -0
- package/dist/scene/water.js +1 -0
- package/dist/scene/water.js.map +1 -1
- package/dist/shadow/shader.js +1 -0
- package/dist/shadow/shader.js.map +1 -1
- package/dist/shapes/torus.js +90 -59
- package/dist/shapes/torus.js.map +1 -1
- package/dist/src/animation/animation.js +127 -0
- package/dist/src/animation/animation.js.map +1 -0
- package/dist/src/animation/animationset.js +255 -0
- package/dist/src/animation/animationset.js.map +1 -0
- package/dist/src/animation/animationtrack.js +34 -0
- package/dist/src/animation/animationtrack.js.map +1 -0
- package/dist/src/animation/eulerrotationtrack.js +52 -0
- package/dist/src/animation/eulerrotationtrack.js.map +1 -0
- package/dist/src/animation/morphtarget.js +93 -0
- package/dist/src/animation/morphtarget.js.map +1 -0
- package/dist/src/animation/morphtrack.js +70 -0
- package/dist/src/animation/morphtrack.js.map +1 -0
- package/dist/src/animation/proptrack.js +161 -0
- package/dist/src/animation/proptrack.js.map +1 -0
- package/dist/src/animation/rotationtrack.js +51 -0
- package/dist/src/animation/rotationtrack.js.map +1 -0
- package/dist/src/animation/scaletrack.js +50 -0
- package/dist/src/animation/scaletrack.js.map +1 -0
- package/dist/src/animation/skeleton.js +204 -0
- package/dist/src/animation/skeleton.js.map +1 -0
- package/dist/src/animation/translationtrack.js +50 -0
- package/dist/src/animation/translationtrack.js.map +1 -0
- package/dist/src/app/app.js +129 -0
- package/dist/src/app/app.js.map +1 -0
- package/dist/src/app/inputmgr.js +267 -0
- package/dist/src/app/inputmgr.js.map +1 -0
- package/dist/src/asset/assetmanager.js +404 -0
- package/dist/src/asset/assetmanager.js.map +1 -0
- package/dist/src/asset/builtin.js +337 -0
- package/dist/src/asset/builtin.js.map +1 -0
- package/dist/src/asset/loaders/dds/dds.js +470 -0
- package/dist/src/asset/loaders/dds/dds.js.map +1 -0
- package/dist/src/asset/loaders/dds/dds_loader.js +28 -0
- package/dist/src/asset/loaders/dds/dds_loader.js.map +1 -0
- package/dist/src/asset/loaders/gltf/gltf_loader.js +1265 -0
- package/dist/src/asset/loaders/gltf/gltf_loader.js.map +1 -0
- package/dist/src/asset/loaders/gltf/helpers.js +327 -0
- package/dist/src/asset/loaders/gltf/helpers.js.map +1 -0
- package/dist/src/asset/loaders/hdr/hdr.js +180 -0
- package/dist/src/asset/loaders/hdr/hdr.js.map +1 -0
- package/dist/src/asset/loaders/image/tga_Loader.js +116 -0
- package/dist/src/asset/loaders/image/tga_Loader.js.map +1 -0
- package/dist/src/asset/loaders/image/webimage_loader.js +63 -0
- package/dist/src/asset/loaders/image/webimage_loader.js.map +1 -0
- package/dist/src/asset/loaders/loader.js +45 -0
- package/dist/src/asset/loaders/loader.js.map +1 -0
- package/dist/src/asset/model.js +414 -0
- package/dist/src/asset/model.js.map +1 -0
- package/dist/src/blitter/bilateralblur.js +221 -0
- package/dist/src/blitter/bilateralblur.js.map +1 -0
- package/dist/src/blitter/blitter.js +390 -0
- package/dist/src/blitter/blitter.js.map +1 -0
- package/dist/src/blitter/box.js +118 -0
- package/dist/src/blitter/box.js.map +1 -0
- package/dist/src/blitter/copy.js +22 -0
- package/dist/src/blitter/copy.js.map +1 -0
- package/dist/src/blitter/gaussianblur.js +228 -0
- package/dist/src/blitter/gaussianblur.js.map +1 -0
- package/dist/src/camera/base.js +92 -0
- package/dist/src/camera/base.js.map +1 -0
- package/dist/src/camera/camera.js +1005 -0
- package/dist/src/camera/camera.js.map +1 -0
- package/dist/src/camera/fps.js +238 -0
- package/dist/src/camera/fps.js.map +1 -0
- package/dist/src/camera/orbit.js +245 -0
- package/dist/src/camera/orbit.js.map +1 -0
- package/dist/src/camera/orthocamera.js +167 -0
- package/dist/src/camera/orthocamera.js.map +1 -0
- package/dist/src/camera/perspectivecamera.js +141 -0
- package/dist/src/camera/perspectivecamera.js.map +1 -0
- package/dist/src/index.js +120 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/material/blinn.js +81 -0
- package/dist/src/material/blinn.js.map +1 -0
- package/dist/src/material/grassmaterial.js +113 -0
- package/dist/src/material/grassmaterial.js.map +1 -0
- package/dist/src/material/lambert.js +92 -0
- package/dist/src/material/lambert.js.map +1 -0
- package/dist/src/material/material.js +301 -0
- package/dist/src/material/material.js.map +1 -0
- package/dist/src/material/meshmaterial.js +704 -0
- package/dist/src/material/meshmaterial.js.map +1 -0
- package/dist/src/material/mixins/albedocolor.js +76 -0
- package/dist/src/material/mixins/albedocolor.js.map +1 -0
- package/dist/src/material/mixins/foliage.js +47 -0
- package/dist/src/material/mixins/foliage.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/blinnphong.js +112 -0
- package/dist/src/material/mixins/lightmodel/blinnphong.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/lambert.js +58 -0
- package/dist/src/material/mixins/lightmodel/lambert.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +178 -0
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +139 -0
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -0
- package/dist/src/material/mixins/lit.js +476 -0
- package/dist/src/material/mixins/lit.js.map +1 -0
- package/dist/src/material/mixins/pbr/common.js +918 -0
- package/dist/src/material/mixins/pbr/common.js.map +1 -0
- package/dist/src/material/mixins/texture.js +172 -0
- package/dist/src/material/mixins/texture.js.map +1 -0
- package/dist/src/material/mixins/vertexcolor.js +56 -0
- package/dist/src/material/mixins/vertexcolor.js.map +1 -0
- package/dist/src/material/particle.js +178 -0
- package/dist/src/material/particle.js.map +1 -0
- package/dist/src/material/pbrmr.js +97 -0
- package/dist/src/material/pbrmr.js.map +1 -0
- package/dist/src/material/pbrsg.js +97 -0
- package/dist/src/material/pbrsg.js.map +1 -0
- package/dist/src/material/shader/helper.js +1209 -0
- package/dist/src/material/shader/helper.js.map +1 -0
- package/dist/src/material/terrain-cm.js +606 -0
- package/dist/src/material/terrain-cm.js.map +1 -0
- package/dist/src/material/terrainmaterial.js +375 -0
- package/dist/src/material/terrainmaterial.js.map +1 -0
- package/dist/src/material/unlit.js +41 -0
- package/dist/src/material/unlit.js.map +1 -0
- package/dist/src/material/water.js +417 -0
- package/dist/src/material/water.js.map +1 -0
- package/dist/src/posteffect/bloom.js +361 -0
- package/dist/src/posteffect/bloom.js.map +1 -0
- package/dist/src/posteffect/compositor.js +226 -0
- package/dist/src/posteffect/compositor.js.map +1 -0
- package/dist/src/posteffect/fxaa.js +273 -0
- package/dist/src/posteffect/fxaa.js.map +1 -0
- package/dist/src/posteffect/grayscale.js +69 -0
- package/dist/src/posteffect/grayscale.js.map +1 -0
- package/dist/src/posteffect/motionblur.js +96 -0
- package/dist/src/posteffect/motionblur.js.map +1 -0
- package/dist/src/posteffect/posteffect.js +126 -0
- package/dist/src/posteffect/posteffect.js.map +1 -0
- package/dist/src/posteffect/sao.js +324 -0
- package/dist/src/posteffect/sao.js.map +1 -0
- package/dist/src/posteffect/ssr.js +489 -0
- package/dist/src/posteffect/ssr.js.map +1 -0
- package/dist/src/posteffect/taa.js +172 -0
- package/dist/src/posteffect/taa.js.map +1 -0
- package/dist/src/posteffect/tonemap.js +94 -0
- package/dist/src/posteffect/tonemap.js.map +1 -0
- package/dist/src/render/abuffer_oit.js +361 -0
- package/dist/src/render/abuffer_oit.js.map +1 -0
- package/dist/src/render/clipmap.js +851 -0
- package/dist/src/render/clipmap.js.map +1 -0
- package/dist/src/render/cluster_light.js +333 -0
- package/dist/src/render/cluster_light.js.map +1 -0
- package/dist/src/render/cull_visitor.js +187 -0
- package/dist/src/render/cull_visitor.js.map +1 -0
- package/dist/src/render/depthpass.js +68 -0
- package/dist/src/render/depthpass.js.map +1 -0
- package/dist/src/render/drawable_mixin.js +227 -0
- package/dist/src/render/drawable_mixin.js.map +1 -0
- package/dist/src/render/envlight.js +463 -0
- package/dist/src/render/envlight.js.map +1 -0
- package/dist/src/render/fbm_wavegenerator.js +251 -0
- package/dist/src/render/fbm_wavegenerator.js.map +1 -0
- package/dist/src/render/fft_wavegenerator.js +1006 -0
- package/dist/src/render/fft_wavegenerator.js.map +1 -0
- package/dist/src/render/fullscreenquad.js +38 -0
- package/dist/src/render/fullscreenquad.js.map +1 -0
- package/dist/src/render/gerstner_wavegenerator.js +314 -0
- package/dist/src/render/gerstner_wavegenerator.js.map +1 -0
- package/dist/src/render/globalbindgroup_allocator.js +60 -0
- package/dist/src/render/globalbindgroup_allocator.js.map +1 -0
- package/dist/src/render/hzb.js +273 -0
- package/dist/src/render/hzb.js.map +1 -0
- package/dist/src/render/lightpass.js +172 -0
- package/dist/src/render/lightpass.js.map +1 -0
- package/dist/src/render/objectcolorpass.js +51 -0
- package/dist/src/render/objectcolorpass.js.map +1 -0
- package/dist/src/render/primitive.js +364 -0
- package/dist/src/render/primitive.js.map +1 -0
- package/dist/src/render/render_queue.js +467 -0
- package/dist/src/render/render_queue.js.map +1 -0
- package/dist/src/render/renderbundle_wrapper.js +152 -0
- package/dist/src/render/renderbundle_wrapper.js.map +1 -0
- package/dist/src/render/renderer.js +455 -0
- package/dist/src/render/renderer.js.map +1 -0
- package/dist/src/render/renderpass.js +200 -0
- package/dist/src/render/renderpass.js.map +1 -0
- package/dist/src/render/shadowmap_pass.js +56 -0
- package/dist/src/render/shadowmap_pass.js.map +1 -0
- package/dist/src/render/sky.js +1103 -0
- package/dist/src/render/sky.js.map +1 -0
- package/dist/src/render/weightedblended_oit.js +168 -0
- package/dist/src/render/weightedblended_oit.js.map +1 -0
- package/dist/src/scene/batchgroup.js +162 -0
- package/dist/src/scene/batchgroup.js.map +1 -0
- package/dist/src/scene/environment.js +209 -0
- package/dist/src/scene/environment.js.map +1 -0
- package/dist/src/scene/graph_node.js +72 -0
- package/dist/src/scene/graph_node.js.map +1 -0
- package/dist/src/scene/light.js +416 -0
- package/dist/src/scene/light.js.map +1 -0
- package/dist/src/scene/mesh.js +341 -0
- package/dist/src/scene/mesh.js.map +1 -0
- package/dist/src/scene/octree.js +649 -0
- package/dist/src/scene/octree.js.map +1 -0
- package/dist/src/scene/particlesys.js +738 -0
- package/dist/src/scene/particlesys.js.map +1 -0
- package/dist/src/scene/raycast_visitor.js +103 -0
- package/dist/src/scene/raycast_visitor.js.map +1 -0
- package/dist/src/scene/scene.js +284 -0
- package/dist/src/scene/scene.js.map +1 -0
- package/dist/src/scene/scene_node.js +732 -0
- package/dist/src/scene/scene_node.js.map +1 -0
- package/dist/src/scene/terrain/grass.js +278 -0
- package/dist/src/scene/terrain/grass.js.map +1 -0
- package/dist/src/scene/terrain/heightfield.js +475 -0
- package/dist/src/scene/terrain/heightfield.js.map +1 -0
- package/dist/src/scene/terrain/patch.js +530 -0
- package/dist/src/scene/terrain/patch.js.map +1 -0
- package/dist/src/scene/terrain/quadtree.js +461 -0
- package/dist/src/scene/terrain/quadtree.js.map +1 -0
- package/dist/src/scene/terrain/terrain.js +246 -0
- package/dist/src/scene/terrain/terrain.js.map +1 -0
- package/dist/src/scene/terrain-cm/grass.js +594 -0
- package/dist/src/scene/terrain-cm/grass.js.map +1 -0
- package/dist/src/scene/terrain-cm/grassmaterial.js +159 -0
- package/dist/src/scene/terrain-cm/grassmaterial.js.map +1 -0
- package/dist/src/scene/terrain-cm/terrain-cm.js +538 -0
- package/dist/src/scene/terrain-cm/terrain-cm.js.map +1 -0
- package/dist/src/scene/water.js +374 -0
- package/dist/src/scene/water.js.map +1 -0
- package/dist/src/shaders/atmosphere.js +957 -0
- package/dist/src/shaders/atmosphere.js.map +1 -0
- package/dist/src/shaders/fog.js +112 -0
- package/dist/src/shaders/fog.js.map +1 -0
- package/dist/src/shaders/misc.js +266 -0
- package/dist/src/shaders/misc.js.map +1 -0
- package/dist/src/shaders/noise.js +222 -0
- package/dist/src/shaders/noise.js.map +1 -0
- package/dist/src/shaders/pbr.js +51 -0
- package/dist/src/shaders/pbr.js.map +1 -0
- package/dist/src/shaders/shadow.js +636 -0
- package/dist/src/shaders/shadow.js.map +1 -0
- package/dist/src/shaders/ssr.js +490 -0
- package/dist/src/shaders/ssr.js.map +1 -0
- package/dist/src/shaders/temporal.js +215 -0
- package/dist/src/shaders/temporal.js.map +1 -0
- package/dist/src/shaders/water.js +756 -0
- package/dist/src/shaders/water.js.map +1 -0
- package/dist/src/shadow/esm.js +237 -0
- package/dist/src/shadow/esm.js.map +1 -0
- package/dist/src/shadow/pcf_opt.js +181 -0
- package/dist/src/shadow/pcf_opt.js.map +1 -0
- package/dist/src/shadow/pcf_pd.js +189 -0
- package/dist/src/shadow/pcf_pd.js.map +1 -0
- package/dist/src/shadow/shader.js +37 -0
- package/dist/src/shadow/shader.js.map +1 -0
- package/dist/src/shadow/shadow_impl.js +15 -0
- package/dist/src/shadow/shadow_impl.js.map +1 -0
- package/dist/src/shadow/shadowmapper.js +790 -0
- package/dist/src/shadow/shadowmapper.js.map +1 -0
- package/dist/src/shadow/ssm.js +159 -0
- package/dist/src/shadow/ssm.js.map +1 -0
- package/dist/src/shadow/vsm.js +297 -0
- package/dist/src/shadow/vsm.js.map +1 -0
- package/dist/src/shapes/box.js +386 -0
- package/dist/src/shapes/box.js.map +1 -0
- package/dist/src/shapes/cylinder.js +125 -0
- package/dist/src/shapes/cylinder.js.map +1 -0
- package/dist/src/shapes/plane.js +88 -0
- package/dist/src/shapes/plane.js.map +1 -0
- package/dist/src/shapes/shape.js +87 -0
- package/dist/src/shapes/shape.js.map +1 -0
- package/dist/src/shapes/sphere.js +114 -0
- package/dist/src/shapes/sphere.js.map +1 -0
- package/dist/src/shapes/tetrahedron.js +188 -0
- package/dist/src/shapes/tetrahedron.js.map +1 -0
- package/dist/src/shapes/torus.js +111 -0
- package/dist/src/shapes/torus.js.map +1 -0
- package/dist/src/utility/aabbtree.js +400 -0
- package/dist/src/utility/aabbtree.js.map +1 -0
- package/dist/src/utility/bounding_volume.js +29 -0
- package/dist/src/utility/bounding_volume.js.map +1 -0
- package/dist/src/utility/debug.js +28 -0
- package/dist/src/utility/debug.js.map +1 -0
- package/dist/src/utility/draco/decoder.js +116 -0
- package/dist/src/utility/draco/decoder.js.map +1 -0
- package/dist/src/utility/misc.js +105 -0
- package/dist/src/utility/misc.js.map +1 -0
- package/dist/src/utility/panorama.js +163 -0
- package/dist/src/utility/panorama.js.map +1 -0
- package/dist/src/utility/pmrem.js +354 -0
- package/dist/src/utility/pmrem.js.map +1 -0
- package/dist/src/utility/rendermipmap.js +115 -0
- package/dist/src/utility/rendermipmap.js.map +1 -0
- package/dist/src/utility/serialization/json.js +402 -0
- package/dist/src/utility/serialization/json.js.map +1 -0
- package/dist/src/utility/serialization/manager.js +623 -0
- package/dist/src/utility/serialization/manager.js.map +1 -0
- package/dist/src/utility/serialization/scene/animation.js +248 -0
- package/dist/src/utility/serialization/scene/animation.js.map +1 -0
- package/dist/src/utility/serialization/scene/batch.js +59 -0
- package/dist/src/utility/serialization/scene/batch.js.map +1 -0
- package/dist/src/utility/serialization/scene/camera.js +790 -0
- package/dist/src/utility/serialization/scene/camera.js.map +1 -0
- package/dist/src/utility/serialization/scene/common.js +222 -0
- package/dist/src/utility/serialization/scene/common.js.map +1 -0
- package/dist/src/utility/serialization/scene/light.js +575 -0
- package/dist/src/utility/serialization/scene/light.js.map +1 -0
- package/dist/src/utility/serialization/scene/material.js +1111 -0
- package/dist/src/utility/serialization/scene/material.js.map +1 -0
- package/dist/src/utility/serialization/scene/mesh.js +148 -0
- package/dist/src/utility/serialization/scene/mesh.js.map +1 -0
- package/dist/src/utility/serialization/scene/misc.js +39 -0
- package/dist/src/utility/serialization/scene/misc.js.map +1 -0
- package/dist/src/utility/serialization/scene/node.js +451 -0
- package/dist/src/utility/serialization/scene/node.js.map +1 -0
- package/dist/src/utility/serialization/scene/particle.js +425 -0
- package/dist/src/utility/serialization/scene/particle.js.map +1 -0
- package/dist/src/utility/serialization/scene/primitive.js +692 -0
- package/dist/src/utility/serialization/scene/primitive.js.map +1 -0
- package/dist/src/utility/serialization/scene/scene.js +704 -0
- package/dist/src/utility/serialization/scene/scene.js.map +1 -0
- package/dist/src/utility/serialization/scene/terrain.js +488 -0
- package/dist/src/utility/serialization/scene/terrain.js.map +1 -0
- package/dist/src/utility/serialization/scene/water.js +465 -0
- package/dist/src/utility/serialization/scene/water.js.map +1 -0
- package/dist/src/utility/shprojector.js +297 -0
- package/dist/src/utility/shprojector.js.map +1 -0
- package/dist/src/utility/textures/ggxlut.js +213 -0
- package/dist/src/utility/textures/ggxlut.js.map +1 -0
- package/dist/src/utility/textures/gradientnoise.js +62 -0
- package/dist/src/utility/textures/gradientnoise.js.map +1 -0
- package/dist/src/utility/textures/randomnoise.js +41 -0
- package/dist/src/utility/textures/randomnoise.js.map +1 -0
- package/dist/src/values.js +162 -0
- package/dist/src/values.js.map +1 -0
- package/dist/text/font/font_asset.js +884 -0
- package/dist/text/font/font_asset.js.map +1 -0
- package/dist/text/font/sfnt_reader.js +43 -0
- package/dist/text/font/sfnt_reader.js.map +1 -0
- package/dist/text/msdf/generator.js +417 -0
- package/dist/text/msdf/generator.js.map +1 -0
- package/dist/text/msdf/shape.js +143 -0
- package/dist/text/msdf/shape.js.map +1 -0
- package/dist/text/runtime/msdf_glyph_atlas.js +146 -0
- package/dist/text/runtime/msdf_glyph_atlas.js.map +1 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js +47 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js.map +1 -0
- package/dist/text/runtime/text_layout.js +96 -0
- package/dist/text/runtime/text_layout.js.map +1 -0
- package/dist/utility/blueprint/material/common.js +7 -0
- package/dist/utility/blueprint/material/common.js.map +1 -0
- package/dist/utility/blueprint/material/inputs.js +1275 -1091
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +505 -490
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/pbr.js +32 -0
- package/dist/utility/blueprint/material/pbr.js.map +1 -1
- package/dist/utility/serialization/blueprint/constants.js +255 -0
- package/dist/utility/serialization/blueprint/constants.js.map +1 -0
- package/dist/utility/serialization/blueprint/material/constants.js +203 -0
- package/dist/utility/serialization/blueprint/material/constants.js.map +1 -0
- package/dist/utility/serialization/blueprint/material/texture.js +165 -0
- package/dist/utility/serialization/blueprint/material/texture.js.map +1 -0
- package/dist/utility/serialization/manager.js +55 -11
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +2 -0
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +2 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +2 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +2 -0
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1 -0
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +2 -0
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +2 -0
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +2 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +1 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +2 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +2 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +516 -0
- package/dist/utility/serialization/scene/text.js.map +1 -0
- package/dist/utility/serialization/scene/water.js +2 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js +4 -4
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/values.js +1 -5
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
- package/dist/animation/joint_dynamics/vrm_spring_bone.js +0 -46
- package/dist/animation/joint_dynamics/vrm_spring_bone.js.map +0 -1
- package/dist/animation/spring/spring_bone.js +0 -240
- package/dist/animation/spring/spring_bone.js.map +0 -1
- package/dist/animation/spring/spring_bone_collider.js +0 -198
- package/dist/animation/spring/spring_bone_collider.js.map +0 -1
- package/dist/animation/spring/spring_bone_constraint.js +0 -170
- package/dist/animation/spring/spring_bone_constraint.js.map +0 -1
- package/dist/animation/spring/spring_bone_system.js +0 -328
- package/dist/animation/spring/spring_bone_system.js.map +0 -1
- package/dist/render/sky_motion_vector.js +0 -85
- package/dist/render/sky_motion_vector.js.map +0 -1
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manages cross-frame history resources that can be imported into a render graph.
|
|
3
|
-
*
|
|
4
|
-
* History resources are textures that persist across frames for temporal effects
|
|
5
|
-
* like TAA, motion blur, or temporal upscaling. Previous-frame textures can be
|
|
6
|
-
* imported into a {@link RenderGraph}, and current-frame textures are committed
|
|
7
|
-
* only after graph execution succeeds.
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* ```ts
|
|
11
|
-
* const historyMgr = new HistoryResourceManager(allocator);
|
|
12
|
-
* historyMgr.beginFrame();
|
|
13
|
-
* const prev = historyMgr.importPrevious(graph, 'taaColor');
|
|
14
|
-
* // declare builder.read(prev) if non-null
|
|
15
|
-
* historyMgr.bindImportedTextures(executor);
|
|
16
|
-
* // after successful execution:
|
|
17
|
-
* historyMgr.commitFrame();
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).
|
|
21
|
-
* @public
|
|
1
|
+
/**
|
|
2
|
+
* Manages cross-frame history resources that can be imported into a render graph.
|
|
3
|
+
*
|
|
4
|
+
* History resources are textures that persist across frames for temporal effects
|
|
5
|
+
* like TAA, motion blur, or temporal upscaling. Previous-frame textures can be
|
|
6
|
+
* imported into a {@link RenderGraph}, and current-frame textures are committed
|
|
7
|
+
* only after graph execution succeeds.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* ```ts
|
|
11
|
+
* const historyMgr = new HistoryResourceManager(allocator);
|
|
12
|
+
* historyMgr.beginFrame();
|
|
13
|
+
* const prev = historyMgr.importPrevious(graph, 'taaColor');
|
|
14
|
+
* // declare builder.read(prev) if non-null
|
|
15
|
+
* historyMgr.bindImportedTextures(executor);
|
|
16
|
+
* // after successful execution:
|
|
17
|
+
* historyMgr.commitFrame();
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).
|
|
21
|
+
* @public
|
|
22
22
|
*/ class HistoryResourceManager {
|
|
23
23
|
_resources = new Map();
|
|
24
24
|
_allocator;
|
|
25
25
|
_pendingImports = new Map();
|
|
26
26
|
_pendingCommits = new Map();
|
|
27
27
|
_readScopeStack = [];
|
|
28
|
-
/**
|
|
29
|
-
* Create a new history resource manager.
|
|
30
|
-
*
|
|
31
|
-
* @param allocator - Texture allocator for creating history textures.
|
|
28
|
+
/**
|
|
29
|
+
* Create a new history resource manager.
|
|
30
|
+
*
|
|
31
|
+
* @param allocator - Texture allocator for creating history textures.
|
|
32
32
|
*/ constructor(allocator){
|
|
33
33
|
this._allocator = allocator;
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Get the previous-frame texture resolved by the current render graph pass.
|
|
37
|
-
*
|
|
38
|
-
* The resource must have been imported with {@link HistoryResourceManager.importPrevious} or
|
|
39
|
-
* {@link HistoryResourceManager.importPreviousIfCompatible}, declared as a pass read, and bound with
|
|
40
|
-
* {@link HistoryResourceManager.beginReadScope} before this method is called.
|
|
41
|
-
*
|
|
42
|
-
* @param name - Name of the history resource.
|
|
43
|
-
* @returns The graph-resolved previous-frame texture.
|
|
44
|
-
* @throws If no read scope is active for the resource.
|
|
35
|
+
/**
|
|
36
|
+
* Get the previous-frame texture resolved by the current render graph pass.
|
|
37
|
+
*
|
|
38
|
+
* The resource must have been imported with {@link HistoryResourceManager.importPrevious} or
|
|
39
|
+
* {@link HistoryResourceManager.importPreviousIfCompatible}, declared as a pass read, and bound with
|
|
40
|
+
* {@link HistoryResourceManager.beginReadScope} before this method is called.
|
|
41
|
+
*
|
|
42
|
+
* @param name - Name of the history resource.
|
|
43
|
+
* @returns The graph-resolved previous-frame texture.
|
|
44
|
+
* @throws If no read scope is active for the resource.
|
|
45
45
|
*/ getPrevious(name) {
|
|
46
46
|
const scoped = this._getScopedRead(name);
|
|
47
47
|
if (scoped) {
|
|
@@ -49,32 +49,32 @@
|
|
|
49
49
|
}
|
|
50
50
|
throw new Error(`History resource '${name}' is not available in the current render graph read scope. ` + `Import it and declare a pass read before accessing it.`);
|
|
51
51
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Check whether a valid history resource exists and matches the descriptor.
|
|
54
|
-
*
|
|
55
|
-
* @param name - Name of the history resource.
|
|
56
|
-
* @param desc - Expected texture descriptor.
|
|
57
|
-
* @param size - Expected resolved size.
|
|
58
|
-
* @returns True if the resource exists, is valid, and matches.
|
|
52
|
+
/**
|
|
53
|
+
* Check whether a valid history resource exists and matches the descriptor.
|
|
54
|
+
*
|
|
55
|
+
* @param name - Name of the history resource.
|
|
56
|
+
* @param desc - Expected texture descriptor.
|
|
57
|
+
* @param size - Expected resolved size.
|
|
58
|
+
* @returns True if the resource exists, is valid, and matches.
|
|
59
59
|
*/ isCompatible(name, desc, size) {
|
|
60
60
|
const resource = this._resources.get(name);
|
|
61
61
|
return !!resource?.valid && this._matches(resource, desc, size);
|
|
62
62
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Start collecting graph imports and deferred commits for a new frame.
|
|
63
|
+
/**
|
|
64
|
+
* Start collecting graph imports and deferred commits for a new frame.
|
|
65
65
|
*/ beginFrame() {
|
|
66
66
|
this.discardFrame();
|
|
67
67
|
this._pendingImports.clear();
|
|
68
68
|
this._readScopeStack.length = 0;
|
|
69
69
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Import the latest committed texture for a history resource into the graph.
|
|
72
|
-
*
|
|
73
|
-
* Returns null when the resource has no valid previous frame.
|
|
74
|
-
*
|
|
75
|
-
* @param graph - Render graph to import into.
|
|
76
|
-
* @param name - History resource name.
|
|
77
|
-
* @returns Imported graph handle, or null when no valid previous texture exists.
|
|
70
|
+
/**
|
|
71
|
+
* Import the latest committed texture for a history resource into the graph.
|
|
72
|
+
*
|
|
73
|
+
* Returns null when the resource has no valid previous frame.
|
|
74
|
+
*
|
|
75
|
+
* @param graph - Render graph to import into.
|
|
76
|
+
* @param name - History resource name.
|
|
77
|
+
* @returns Imported graph handle, or null when no valid previous texture exists.
|
|
78
78
|
*/ importPrevious(graph, name) {
|
|
79
79
|
const resource = this._resources.get(name);
|
|
80
80
|
const texture = resource?.valid ? resource.textures[resource.currentIndex] : null;
|
|
@@ -85,34 +85,34 @@
|
|
|
85
85
|
this._pendingImports.set(handle, texture);
|
|
86
86
|
return handle;
|
|
87
87
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Import the latest committed texture only when it matches the expected shape.
|
|
90
|
-
*
|
|
91
|
-
* This is the preferred API for effects that can declare their history reads
|
|
92
|
-
* while building the graph: incompatible history is treated as absent, so the
|
|
93
|
-
* pass does not declare stale reads after resize or format changes.
|
|
94
|
-
*
|
|
95
|
-
* @param graph - Render graph to import into.
|
|
96
|
-
* @param name - History resource name.
|
|
97
|
-
* @param desc - Expected texture descriptor.
|
|
98
|
-
* @param size - Expected resolved size.
|
|
99
|
-
* @returns Imported graph handle, or null when no compatible history exists.
|
|
88
|
+
/**
|
|
89
|
+
* Import the latest committed texture only when it matches the expected shape.
|
|
90
|
+
*
|
|
91
|
+
* This is the preferred API for effects that can declare their history reads
|
|
92
|
+
* while building the graph: incompatible history is treated as absent, so the
|
|
93
|
+
* pass does not declare stale reads after resize or format changes.
|
|
94
|
+
*
|
|
95
|
+
* @param graph - Render graph to import into.
|
|
96
|
+
* @param name - History resource name.
|
|
97
|
+
* @param desc - Expected texture descriptor.
|
|
98
|
+
* @param size - Expected resolved size.
|
|
99
|
+
* @returns Imported graph handle, or null when no compatible history exists.
|
|
100
100
|
*/ importPreviousIfCompatible(graph, name, desc, size) {
|
|
101
101
|
return this.isCompatible(name, desc, size) ? this.importPrevious(graph, name) : null;
|
|
102
102
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Bind all history imports created for this frame to the executor.
|
|
105
|
-
*
|
|
106
|
-
* @param executor - Render graph executor for the current frame.
|
|
103
|
+
/**
|
|
104
|
+
* Bind all history imports created for this frame to the executor.
|
|
105
|
+
*
|
|
106
|
+
* @param executor - Render graph executor for the current frame.
|
|
107
107
|
*/ bindImportedTextures(executor) {
|
|
108
108
|
for (const [handle, texture] of this._pendingImports){
|
|
109
109
|
executor.setImportedTexture(handle, texture);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
/**
|
|
113
|
-
* Make resolved history textures available to code executing inside a pass.
|
|
114
|
-
*
|
|
115
|
-
* @param bindings - History name to resolved texture bindings.
|
|
112
|
+
/**
|
|
113
|
+
* Make resolved history textures available to code executing inside a pass.
|
|
114
|
+
*
|
|
115
|
+
* @param bindings - History name to resolved texture bindings.
|
|
116
116
|
*/ beginReadScope(bindings) {
|
|
117
117
|
const scope = new Map();
|
|
118
118
|
for (const binding of bindings){
|
|
@@ -120,22 +120,22 @@
|
|
|
120
120
|
}
|
|
121
121
|
this._readScopeStack.push(scope);
|
|
122
122
|
}
|
|
123
|
-
/**
|
|
124
|
-
* End the most recent history read scope.
|
|
123
|
+
/**
|
|
124
|
+
* End the most recent history read scope.
|
|
125
125
|
*/ endReadScope() {
|
|
126
126
|
this._readScopeStack.pop();
|
|
127
127
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Queue a current-frame texture to become the next previous-frame history.
|
|
130
|
-
*
|
|
131
|
-
* The texture is committed only when {@link HistoryResourceManager.commitFrame} is called. If the
|
|
132
|
-
* frame fails, {@link HistoryResourceManager.discardFrame} releases owned pending textures instead.
|
|
133
|
-
*
|
|
134
|
-
* @param name - History resource name.
|
|
135
|
-
* @param desc - Texture descriptor.
|
|
136
|
-
* @param size - Resolved texture size.
|
|
137
|
-
* @param texture - Texture produced by the current frame.
|
|
138
|
-
* @param ownsTexture - Whether this manager should release the texture later.
|
|
128
|
+
/**
|
|
129
|
+
* Queue a current-frame texture to become the next previous-frame history.
|
|
130
|
+
*
|
|
131
|
+
* The texture is committed only when {@link HistoryResourceManager.commitFrame} is called. If the
|
|
132
|
+
* frame fails, {@link HistoryResourceManager.discardFrame} releases owned pending textures instead.
|
|
133
|
+
*
|
|
134
|
+
* @param name - History resource name.
|
|
135
|
+
* @param desc - Texture descriptor.
|
|
136
|
+
* @param size - Resolved texture size.
|
|
137
|
+
* @param texture - Texture produced by the current frame.
|
|
138
|
+
* @param ownsTexture - Whether this manager should release the texture later.
|
|
139
139
|
*/ queueCommit(name, desc, size, texture, ownsTexture = true) {
|
|
140
140
|
const existing = this._pendingCommits.get(name);
|
|
141
141
|
if (existing?.ownsTexture) {
|
|
@@ -152,8 +152,8 @@
|
|
|
152
152
|
ownsTexture
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
|
-
/**
|
|
156
|
-
* Commit all current-frame history writes.
|
|
155
|
+
/**
|
|
156
|
+
* Commit all current-frame history writes.
|
|
157
157
|
*/ commitFrame() {
|
|
158
158
|
for (const [name, pending] of this._pendingCommits){
|
|
159
159
|
let resource = this._resources.get(name);
|
|
@@ -200,8 +200,8 @@
|
|
|
200
200
|
this._pendingImports.clear();
|
|
201
201
|
this._readScopeStack.length = 0;
|
|
202
202
|
}
|
|
203
|
-
/**
|
|
204
|
-
* Discard all uncommitted frame history writes.
|
|
203
|
+
/**
|
|
204
|
+
* Discard all uncommitted frame history writes.
|
|
205
205
|
*/ discardFrame() {
|
|
206
206
|
for (const pending of this._pendingCommits.values()){
|
|
207
207
|
if (pending.ownsTexture) {
|
|
@@ -212,10 +212,10 @@
|
|
|
212
212
|
this._pendingImports.clear();
|
|
213
213
|
this._readScopeStack.length = 0;
|
|
214
214
|
}
|
|
215
|
-
/**
|
|
216
|
-
* Release all history resources and clear the manager.
|
|
217
|
-
*
|
|
218
|
-
* Call this when disposing the render context or when history is no longer needed.
|
|
215
|
+
/**
|
|
216
|
+
* Release all history resources and clear the manager.
|
|
217
|
+
*
|
|
218
|
+
* Call this when disposing the render context or when history is no longer needed.
|
|
219
219
|
*/ dispose() {
|
|
220
220
|
this.discardFrame();
|
|
221
221
|
for (const resource of this._resources.values()){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history_resource_manager.js","sources":["../../../src/render/rendergraph/history_resource_manager.ts"],"sourcesContent":["import type { Texture2D } from '@zephyr3d/device';\nimport type { RenderGraph } from './rendergraph';\nimport type { RenderGraphExecutor } from './executor';\nimport type { RGHandle, RGTextureAllocator, RGTextureDesc, RGResolvedSize } from './types';\n\ninterface HistoryResource<TTexture> {\n desc: RGTextureDesc;\n size: RGResolvedSize;\n textures: [TTexture | null, TTexture | null];\n ownsTexture: [boolean, boolean];\n currentIndex: number;\n valid: boolean;\n}\n\ninterface PendingHistoryCommit<TTexture> {\n desc: RGTextureDesc;\n size: RGResolvedSize;\n texture: TTexture;\n ownsTexture: boolean;\n}\n\n/**\n * Manages cross-frame history resources that can be imported into a render graph.\n *\n * History resources are textures that persist across frames for temporal effects\n * like TAA, motion blur, or temporal upscaling. Previous-frame textures can be\n * imported into a {@link RenderGraph}, and current-frame textures are committed\n * only after graph execution succeeds.\n *\n * Usage:\n * ```ts\n * const historyMgr = new HistoryResourceManager(allocator);\n * historyMgr.beginFrame();\n * const prev = historyMgr.importPrevious(graph, 'taaColor');\n * // declare builder.read(prev) if non-null\n * historyMgr.bindImportedTextures(executor);\n * // after successful execution:\n * historyMgr.commitFrame();\n * ```\n *\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\n * @public\n */\nexport class HistoryResourceManager<TTexture = Texture2D> {\n private _resources: Map<string, HistoryResource<TTexture>> = new Map();\n private _allocator: RGTextureAllocator<TTexture>;\n private _pendingImports: Map<RGHandle, TTexture> = new Map();\n private _pendingCommits: Map<string, PendingHistoryCommit<TTexture>> = new Map();\n private _readScopeStack: Array<Map<string, TTexture>> = [];\n\n /**\n * Create a new history resource manager.\n *\n * @param allocator - Texture allocator for creating history textures.\n */\n constructor(allocator: RGTextureAllocator<TTexture>) {\n this._allocator = allocator;\n }\n\n /**\n * Get the previous-frame texture resolved by the current render graph pass.\n *\n * The resource must have been imported with {@link HistoryResourceManager.importPrevious} or\n * {@link HistoryResourceManager.importPreviousIfCompatible}, declared as a pass read, and bound with\n * {@link HistoryResourceManager.beginReadScope} before this method is called.\n *\n * @param name - Name of the history resource.\n * @returns The graph-resolved previous-frame texture.\n * @throws If no read scope is active for the resource.\n */\n getPrevious(name: string): TTexture {\n const scoped = this._getScopedRead(name);\n if (scoped) {\n return scoped;\n }\n throw new Error(\n `History resource '${name}' is not available in the current render graph read scope. ` +\n `Import it and declare a pass read before accessing it.`\n );\n }\n\n /**\n * Check whether a valid history resource exists and matches the descriptor.\n *\n * @param name - Name of the history resource.\n * @param desc - Expected texture descriptor.\n * @param size - Expected resolved size.\n * @returns True if the resource exists, is valid, and matches.\n */\n isCompatible(name: string, desc: RGTextureDesc, size: RGResolvedSize): boolean {\n const resource = this._resources.get(name);\n return !!resource?.valid && this._matches(resource, desc, size);\n }\n\n /**\n * Start collecting graph imports and deferred commits for a new frame.\n */\n beginFrame(): void {\n this.discardFrame();\n this._pendingImports.clear();\n this._readScopeStack.length = 0;\n }\n\n /**\n * Import the latest committed texture for a history resource into the graph.\n *\n * Returns null when the resource has no valid previous frame.\n *\n * @param graph - Render graph to import into.\n * @param name - History resource name.\n * @returns Imported graph handle, or null when no valid previous texture exists.\n */\n importPrevious(graph: RenderGraph, name: string): RGHandle | null {\n const resource = this._resources.get(name);\n const texture = resource?.valid ? resource.textures[resource.currentIndex] : null;\n if (!texture) {\n return null;\n }\n const handle = graph.importTexture(`history:${name}:previous`);\n this._pendingImports.set(handle, texture);\n return handle;\n }\n\n /**\n * Import the latest committed texture only when it matches the expected shape.\n *\n * This is the preferred API for effects that can declare their history reads\n * while building the graph: incompatible history is treated as absent, so the\n * pass does not declare stale reads after resize or format changes.\n *\n * @param graph - Render graph to import into.\n * @param name - History resource name.\n * @param desc - Expected texture descriptor.\n * @param size - Expected resolved size.\n * @returns Imported graph handle, or null when no compatible history exists.\n */\n importPreviousIfCompatible(\n graph: RenderGraph,\n name: string,\n desc: RGTextureDesc,\n size: RGResolvedSize\n ): RGHandle | null {\n return this.isCompatible(name, desc, size) ? this.importPrevious(graph, name) : null;\n }\n\n /**\n * Bind all history imports created for this frame to the executor.\n *\n * @param executor - Render graph executor for the current frame.\n */\n bindImportedTextures(executor: Pick<RenderGraphExecutor<TTexture>, 'setImportedTexture'>): void {\n for (const [handle, texture] of this._pendingImports) {\n executor.setImportedTexture(handle, texture);\n }\n }\n\n /**\n * Make resolved history textures available to code executing inside a pass.\n *\n * @param bindings - History name to resolved texture bindings.\n */\n beginReadScope(bindings: Array<{ name: string; texture: TTexture }>): void {\n const scope = new Map<string, TTexture>();\n for (const binding of bindings) {\n scope.set(binding.name, binding.texture);\n }\n this._readScopeStack.push(scope);\n }\n\n /**\n * End the most recent history read scope.\n */\n endReadScope(): void {\n this._readScopeStack.pop();\n }\n\n /**\n * Queue a current-frame texture to become the next previous-frame history.\n *\n * The texture is committed only when {@link HistoryResourceManager.commitFrame} is called. If the\n * frame fails, {@link HistoryResourceManager.discardFrame} releases owned pending textures instead.\n *\n * @param name - History resource name.\n * @param desc - Texture descriptor.\n * @param size - Resolved texture size.\n * @param texture - Texture produced by the current frame.\n * @param ownsTexture - Whether this manager should release the texture later.\n */\n queueCommit(\n name: string,\n desc: RGTextureDesc,\n size: RGResolvedSize,\n texture: TTexture,\n ownsTexture = true\n ): void {\n const existing = this._pendingCommits.get(name);\n if (existing?.ownsTexture) {\n this._allocator.release(existing.texture);\n }\n this._pendingCommits.set(name, {\n desc: { ...desc },\n size: { ...size },\n texture,\n ownsTexture\n });\n }\n\n /**\n * Commit all current-frame history writes.\n */\n commitFrame(): void {\n for (const [name, pending] of this._pendingCommits) {\n let resource = this._resources.get(name);\n if (resource && !this._matches(resource, pending.desc, pending.size)) {\n this._releaseResource(resource);\n this._resources.delete(name);\n resource = undefined;\n }\n if (!resource) {\n resource = {\n desc: { ...pending.desc },\n size: { ...pending.size },\n textures: [null, null],\n ownsTexture: [false, false],\n currentIndex: 0,\n valid: false\n };\n this._resources.set(name, resource);\n }\n\n const writeIndex = resource.valid ? 1 - resource.currentIndex : resource.currentIndex;\n this._releaseSlot(resource, writeIndex);\n resource.textures[writeIndex] = pending.texture;\n resource.ownsTexture[writeIndex] = pending.ownsTexture;\n resource.desc = { ...pending.desc };\n resource.size = { ...pending.size };\n resource.currentIndex = writeIndex;\n resource.valid = true;\n }\n this._pendingCommits.clear();\n this._pendingImports.clear();\n this._readScopeStack.length = 0;\n }\n\n /**\n * Discard all uncommitted frame history writes.\n */\n discardFrame(): void {\n for (const pending of this._pendingCommits.values()) {\n if (pending.ownsTexture) {\n this._allocator.release(pending.texture);\n }\n }\n this._pendingCommits.clear();\n this._pendingImports.clear();\n this._readScopeStack.length = 0;\n }\n\n /**\n * Release all history resources and clear the manager.\n *\n * Call this when disposing the render context or when history is no longer needed.\n */\n dispose(): void {\n this.discardFrame();\n for (const resource of this._resources.values()) {\n this._releaseResource(resource);\n }\n this._resources.clear();\n }\n\n /** @internal */\n private _getScopedRead(name: string): TTexture | null {\n for (let i = this._readScopeStack.length - 1; i >= 0; i--) {\n const texture = this._readScopeStack[i].get(name);\n if (texture) {\n return texture;\n }\n }\n return null;\n }\n\n /** @internal */\n private _matches(resource: HistoryResource<TTexture>, desc: RGTextureDesc, size: RGResolvedSize): boolean {\n return (\n resource.desc.format === desc.format &&\n (resource.desc.mipLevels ?? 1) === (desc.mipLevels ?? 1) &&\n resource.size.width === size.width &&\n resource.size.height === size.height\n );\n }\n\n /** @internal */\n private _releaseResource(resource: HistoryResource<TTexture>): void {\n this._releaseSlot(resource, 0);\n this._releaseSlot(resource, 1);\n resource.valid = false;\n }\n\n /** @internal */\n private _releaseSlot(resource: HistoryResource<TTexture>, index: number): void {\n const texture = resource.textures[index];\n if (!texture) {\n return;\n }\n const otherIndex = 1 - index;\n if (resource.ownsTexture[index] && resource.textures[otherIndex] !== texture) {\n this._allocator.release(texture);\n }\n resource.textures[index] = null;\n resource.ownsTexture[index] = false;\n }\n}\n"],"names":["HistoryResourceManager","_resources","Map","_allocator","_pendingImports","_pendingCommits","_readScopeStack","allocator","getPrevious","name","scoped","_getScopedRead","Error","isCompatible","desc","size","resource","get","valid","_matches","beginFrame","discardFrame","clear","length","importPrevious","graph","texture","textures","currentIndex","handle","importTexture","set","importPreviousIfCompatible","bindImportedTextures","executor","setImportedTexture","beginReadScope","bindings","scope","binding","push","endReadScope","pop","queueCommit","ownsTexture","existing","release","commitFrame","pending","_releaseResource","delete","undefined","writeIndex","_releaseSlot","values","dispose","i","format","mipLevels","width","height","index","otherIndex"],"mappings":"AAqBA;;;;;;;;;;;;;;;;;;;;;AAqBC,IACM,MAAMA,sBAAAA,CAAAA;AACHC,IAAAA,UAAAA,GAAqD,IAAIC,GAAM,EAAA;IAC/DC,UAAyC;AACzCC,IAAAA,eAAAA,GAA2C,IAAIF,GAAM,EAAA;AACrDG,IAAAA,eAAAA,GAA+D,IAAIH,GAAM,EAAA;AACzEI,IAAAA,eAAAA,GAAgD,EAAE;AAE1D;;;;MAKA,WAAA,CAAYC,SAAuC,CAAE;QACnD,IAAI,CAACJ,UAAU,GAAGI,SAAAA;AACpB;AAEA;;;;;;;;;;MAWAC,WAAAA,CAAYC,IAAY,EAAY;AAClC,QAAA,MAAMC,MAAS,GAAA,IAAI,CAACC,cAAc,CAACF,IAAAA,CAAAA;AACnC,QAAA,IAAIC,MAAQ,EAAA;YACV,OAAOA,MAAAA;AACT;QACA,MAAM,IAAIE,KACR,CAAA,CAAC,kBAAkB,EAAEH,IAAK,CAAA,2DAA2D,CAAC,GACpF,CAAC,sDAAsD,CAAC,CAAA;AAE9D;AAEA;;;;;;;AAOC,MACDI,aAAaJ,IAAY,EAAEK,IAAmB,EAAEC,IAAoB,EAAW;AAC7E,QAAA,MAAMC,WAAW,IAAI,CAACf,UAAU,CAACgB,GAAG,CAACR,IAAAA,CAAAA;QACrC,OAAO,CAAC,CAACO,QAAUE,EAAAA,KAAAA,IAAS,IAAI,CAACC,QAAQ,CAACH,QAAAA,EAAUF,IAAMC,EAAAA,IAAAA,CAAAA;AAC5D;AAEA;;AAEC,MACDK,UAAmB,GAAA;AACjB,QAAA,IAAI,CAACC,YAAY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5C,IAAK4C,CAAAA,SAAS,IAAI,CAAA,CAAA,IACtD1C,QAASD,CAAAA,IAAI,CAAC4C,KAAK,KAAK5C,IAAK4C,CAAAA,KAAK,IAClC3C,QAASD,CAAAA,IAAI,CAAC6C,MAAM,KAAK7C,KAAK6C,MAAM;AAExC;AAEA,qBACQX,gBAAiBjC,CAAAA,QAAmC,EAAQ;QAClE,IAAI,CAACqC,YAAY,CAACrC,QAAU,EAAA,CAAA,CAAA;QAC5B,IAAI,CAACqC,YAAY,CAACrC,QAAU,EAAA,CAAA,CAAA;AAC5BA,QAAAA,QAAAA,CAASE,KAAK,GAAG,KAAA;AACnB;AAEA,qBACA,YAAQmC,CAAarC,QAAmC,EAAE6C,KAAa,EAAQ;AAC7E,QAAA,MAAMnC,OAAUV,GAAAA,QAAAA,CAASW,QAAQ,CAACkC,KAAM,CAAA;AACxC,QAAA,IAAI,CAACnC,OAAS,EAAA;AACZ,YAAA;AACF;AACA,QAAA,MAAMoC,aAAa,CAAID,GAAAA,KAAAA;QACvB,IAAI7C,QAAAA,CAAS4B,WAAW,CAACiB,KAAM,CAAA,IAAI7C,SAASW,QAAQ,CAACmC,UAAW,CAAA,KAAKpC,OAAS,EAAA;AAC5E,YAAA,IAAI,CAACvB,UAAU,CAAC2C,OAAO,CAACpB,OAAAA,CAAAA;AAC1B;QACAV,QAASW,CAAAA,QAAQ,CAACkC,KAAAA,CAAM,GAAG,IAAA;QAC3B7C,QAAS4B,CAAAA,WAAW,CAACiB,KAAAA,CAAM,GAAG,KAAA;AAChC;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"history_resource_manager.js","sources":["../../../src/render/rendergraph/history_resource_manager.ts"],"sourcesContent":["import type { Texture2D } from '@zephyr3d/device';\r\nimport type { RenderGraph } from './rendergraph';\r\nimport type { RenderGraphExecutor } from './executor';\r\nimport type { RGHandle, RGTextureAllocator, RGTextureDesc, RGResolvedSize } from './types';\r\n\r\ninterface HistoryResource<TTexture> {\r\n desc: RGTextureDesc;\r\n size: RGResolvedSize;\r\n textures: [TTexture | null, TTexture | null];\r\n ownsTexture: [boolean, boolean];\r\n currentIndex: number;\r\n valid: boolean;\r\n}\r\n\r\ninterface PendingHistoryCommit<TTexture> {\r\n desc: RGTextureDesc;\r\n size: RGResolvedSize;\r\n texture: TTexture;\r\n ownsTexture: boolean;\r\n}\r\n\r\n/**\r\n * Manages cross-frame history resources that can be imported into a render graph.\r\n *\r\n * History resources are textures that persist across frames for temporal effects\r\n * like TAA, motion blur, or temporal upscaling. Previous-frame textures can be\r\n * imported into a {@link RenderGraph}, and current-frame textures are committed\r\n * only after graph execution succeeds.\r\n *\r\n * Usage:\r\n * ```ts\r\n * const historyMgr = new HistoryResourceManager(allocator);\r\n * historyMgr.beginFrame();\r\n * const prev = historyMgr.importPrevious(graph, 'taaColor');\r\n * // declare builder.read(prev) if non-null\r\n * historyMgr.bindImportedTextures(executor);\r\n * // after successful execution:\r\n * historyMgr.commitFrame();\r\n * ```\r\n *\r\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\r\n * @public\r\n */\r\nexport class HistoryResourceManager<TTexture = Texture2D> {\r\n private _resources: Map<string, HistoryResource<TTexture>> = new Map();\r\n private _allocator: RGTextureAllocator<TTexture>;\r\n private _pendingImports: Map<RGHandle, TTexture> = new Map();\r\n private _pendingCommits: Map<string, PendingHistoryCommit<TTexture>> = new Map();\r\n private _readScopeStack: Array<Map<string, TTexture>> = [];\r\n\r\n /**\r\n * Create a new history resource manager.\r\n *\r\n * @param allocator - Texture allocator for creating history textures.\r\n */\r\n constructor(allocator: RGTextureAllocator<TTexture>) {\r\n this._allocator = allocator;\r\n }\r\n\r\n /**\r\n * Get the previous-frame texture resolved by the current render graph pass.\r\n *\r\n * The resource must have been imported with {@link HistoryResourceManager.importPrevious} or\r\n * {@link HistoryResourceManager.importPreviousIfCompatible}, declared as a pass read, and bound with\r\n * {@link HistoryResourceManager.beginReadScope} before this method is called.\r\n *\r\n * @param name - Name of the history resource.\r\n * @returns The graph-resolved previous-frame texture.\r\n * @throws If no read scope is active for the resource.\r\n */\r\n getPrevious(name: string): TTexture {\r\n const scoped = this._getScopedRead(name);\r\n if (scoped) {\r\n return scoped;\r\n }\r\n throw new Error(\r\n `History resource '${name}' is not available in the current render graph read scope. ` +\r\n `Import it and declare a pass read before accessing it.`\r\n );\r\n }\r\n\r\n /**\r\n * Check whether a valid history resource exists and matches the descriptor.\r\n *\r\n * @param name - Name of the history resource.\r\n * @param desc - Expected texture descriptor.\r\n * @param size - Expected resolved size.\r\n * @returns True if the resource exists, is valid, and matches.\r\n */\r\n isCompatible(name: string, desc: RGTextureDesc, size: RGResolvedSize): boolean {\r\n const resource = this._resources.get(name);\r\n return !!resource?.valid && this._matches(resource, desc, size);\r\n }\r\n\r\n /**\r\n * Start collecting graph imports and deferred commits for a new frame.\r\n */\r\n beginFrame(): void {\r\n this.discardFrame();\r\n this._pendingImports.clear();\r\n this._readScopeStack.length = 0;\r\n }\r\n\r\n /**\r\n * Import the latest committed texture for a history resource into the graph.\r\n *\r\n * Returns null when the resource has no valid previous frame.\r\n *\r\n * @param graph - Render graph to import into.\r\n * @param name - History resource name.\r\n * @returns Imported graph handle, or null when no valid previous texture exists.\r\n */\r\n importPrevious(graph: RenderGraph, name: string): RGHandle | null {\r\n const resource = this._resources.get(name);\r\n const texture = resource?.valid ? resource.textures[resource.currentIndex] : null;\r\n if (!texture) {\r\n return null;\r\n }\r\n const handle = graph.importTexture(`history:${name}:previous`);\r\n this._pendingImports.set(handle, texture);\r\n return handle;\r\n }\r\n\r\n /**\r\n * Import the latest committed texture only when it matches the expected shape.\r\n *\r\n * This is the preferred API for effects that can declare their history reads\r\n * while building the graph: incompatible history is treated as absent, so the\r\n * pass does not declare stale reads after resize or format changes.\r\n *\r\n * @param graph - Render graph to import into.\r\n * @param name - History resource name.\r\n * @param desc - Expected texture descriptor.\r\n * @param size - Expected resolved size.\r\n * @returns Imported graph handle, or null when no compatible history exists.\r\n */\r\n importPreviousIfCompatible(\r\n graph: RenderGraph,\r\n name: string,\r\n desc: RGTextureDesc,\r\n size: RGResolvedSize\r\n ): RGHandle | null {\r\n return this.isCompatible(name, desc, size) ? this.importPrevious(graph, name) : null;\r\n }\r\n\r\n /**\r\n * Bind all history imports created for this frame to the executor.\r\n *\r\n * @param executor - Render graph executor for the current frame.\r\n */\r\n bindImportedTextures(executor: Pick<RenderGraphExecutor<TTexture>, 'setImportedTexture'>): void {\r\n for (const [handle, texture] of this._pendingImports) {\r\n executor.setImportedTexture(handle, texture);\r\n }\r\n }\r\n\r\n /**\r\n * Make resolved history textures available to code executing inside a pass.\r\n *\r\n * @param bindings - History name to resolved texture bindings.\r\n */\r\n beginReadScope(bindings: Array<{ name: string; texture: TTexture }>): void {\r\n const scope = new Map<string, TTexture>();\r\n for (const binding of bindings) {\r\n scope.set(binding.name, binding.texture);\r\n }\r\n this._readScopeStack.push(scope);\r\n }\r\n\r\n /**\r\n * End the most recent history read scope.\r\n */\r\n endReadScope(): void {\r\n this._readScopeStack.pop();\r\n }\r\n\r\n /**\r\n * Queue a current-frame texture to become the next previous-frame history.\r\n *\r\n * The texture is committed only when {@link HistoryResourceManager.commitFrame} is called. If the\r\n * frame fails, {@link HistoryResourceManager.discardFrame} releases owned pending textures instead.\r\n *\r\n * @param name - History resource name.\r\n * @param desc - Texture descriptor.\r\n * @param size - Resolved texture size.\r\n * @param texture - Texture produced by the current frame.\r\n * @param ownsTexture - Whether this manager should release the texture later.\r\n */\r\n queueCommit(\r\n name: string,\r\n desc: RGTextureDesc,\r\n size: RGResolvedSize,\r\n texture: TTexture,\r\n ownsTexture = true\r\n ): void {\r\n const existing = this._pendingCommits.get(name);\r\n if (existing?.ownsTexture) {\r\n this._allocator.release(existing.texture);\r\n }\r\n this._pendingCommits.set(name, {\r\n desc: { ...desc },\r\n size: { ...size },\r\n texture,\r\n ownsTexture\r\n });\r\n }\r\n\r\n /**\r\n * Commit all current-frame history writes.\r\n */\r\n commitFrame(): void {\r\n for (const [name, pending] of this._pendingCommits) {\r\n let resource = this._resources.get(name);\r\n if (resource && !this._matches(resource, pending.desc, pending.size)) {\r\n this._releaseResource(resource);\r\n this._resources.delete(name);\r\n resource = undefined;\r\n }\r\n if (!resource) {\r\n resource = {\r\n desc: { ...pending.desc },\r\n size: { ...pending.size },\r\n textures: [null, null],\r\n ownsTexture: [false, false],\r\n currentIndex: 0,\r\n valid: false\r\n };\r\n this._resources.set(name, resource);\r\n }\r\n\r\n const writeIndex = resource.valid ? 1 - resource.currentIndex : resource.currentIndex;\r\n this._releaseSlot(resource, writeIndex);\r\n resource.textures[writeIndex] = pending.texture;\r\n resource.ownsTexture[writeIndex] = pending.ownsTexture;\r\n resource.desc = { ...pending.desc };\r\n resource.size = { ...pending.size };\r\n resource.currentIndex = writeIndex;\r\n resource.valid = true;\r\n }\r\n this._pendingCommits.clear();\r\n this._pendingImports.clear();\r\n this._readScopeStack.length = 0;\r\n }\r\n\r\n /**\r\n * Discard all uncommitted frame history writes.\r\n */\r\n discardFrame(): void {\r\n for (const pending of this._pendingCommits.values()) {\r\n if (pending.ownsTexture) {\r\n this._allocator.release(pending.texture);\r\n }\r\n }\r\n this._pendingCommits.clear();\r\n this._pendingImports.clear();\r\n this._readScopeStack.length = 0;\r\n }\r\n\r\n /**\r\n * Release all history resources and clear the manager.\r\n *\r\n * Call this when disposing the render context or when history is no longer needed.\r\n */\r\n dispose(): void {\r\n this.discardFrame();\r\n for (const resource of this._resources.values()) {\r\n this._releaseResource(resource);\r\n }\r\n this._resources.clear();\r\n }\r\n\r\n /** @internal */\r\n private _getScopedRead(name: string): TTexture | null {\r\n for (let i = this._readScopeStack.length - 1; i >= 0; i--) {\r\n const texture = this._readScopeStack[i].get(name);\r\n if (texture) {\r\n return texture;\r\n }\r\n }\r\n return null;\r\n }\r\n\r\n /** @internal */\r\n private _matches(resource: HistoryResource<TTexture>, desc: RGTextureDesc, size: RGResolvedSize): boolean {\r\n return (\r\n resource.desc.format === desc.format &&\r\n (resource.desc.mipLevels ?? 1) === (desc.mipLevels ?? 1) &&\r\n resource.size.width === size.width &&\r\n resource.size.height === size.height\r\n );\r\n }\r\n\r\n /** @internal */\r\n private _releaseResource(resource: HistoryResource<TTexture>): void {\r\n this._releaseSlot(resource, 0);\r\n this._releaseSlot(resource, 1);\r\n resource.valid = false;\r\n }\r\n\r\n /** @internal */\r\n private _releaseSlot(resource: HistoryResource<TTexture>, index: number): void {\r\n const texture = resource.textures[index];\r\n if (!texture) {\r\n return;\r\n }\r\n const otherIndex = 1 - index;\r\n if (resource.ownsTexture[index] && resource.textures[otherIndex] !== texture) {\r\n this._allocator.release(texture);\r\n }\r\n resource.textures[index] = null;\r\n resource.ownsTexture[index] = false;\r\n }\r\n}\r\n"],"names":["HistoryResourceManager","_resources","Map","_allocator","_pendingImports","_pendingCommits","_readScopeStack","allocator","getPrevious","name","scoped","_getScopedRead","Error","isCompatible","desc","size","resource","get","valid","_matches","beginFrame","discardFrame","clear","length","importPrevious","graph","texture","textures","currentIndex","handle","importTexture","set","importPreviousIfCompatible","bindImportedTextures","executor","setImportedTexture","beginReadScope","bindings","scope","binding","push","endReadScope","pop","queueCommit","ownsTexture","existing","release","commitFrame","pending","_releaseResource","delete","undefined","writeIndex","_releaseSlot","values","dispose","i","format","mipLevels","width","height","index","otherIndex"],"mappings":"AAqBA;;;;;;;;;;;;;;;;;;;;;AAqBC,IACM,MAAMA,sBAAAA,CAAAA;AACHC,IAAAA,UAAAA,GAAqD,IAAIC,GAAM,EAAA;IAC/DC,UAAyC;AACzCC,IAAAA,eAAAA,GAA2C,IAAIF,GAAM,EAAA;AACrDG,IAAAA,eAAAA,GAA+D,IAAIH,GAAM,EAAA;AACzEI,IAAAA,eAAAA,GAAgD,EAAE;AAE1D;;;;MAKA,WAAA,CAAYC,SAAuC,CAAE;QACnD,IAAI,CAACJ,UAAU,GAAGI,SAAAA;AACpB;AAEA;;;;;;;;;;MAWAC,WAAAA,CAAYC,IAAY,EAAY;AAClC,QAAA,MAAMC,M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,CAACiB,KAAM,CAAA,IAAI7C,SAASW,QAAQ,CAACmC,UAAW,CAAA,KAAKpC,OAAS,EAAA;AAC5E,YAAA,IAAI,CAACvB,UAAU,CAAC2C,OAAO,CAACpB,OAAAA,CAAAA;AAC1B;QACAV,QAASW,CAAAA,QAAQ,CAACkC,KAAAA,CAAM,GAAG,IAAA;QAC3B7C,QAAS4B,CAAAA,WAAW,CAACiB,KAAAA,CAAM,GAAG,KAAA;AAChC;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history_resources.js","sources":["../../../src/render/rendergraph/history_resources.ts"],"sourcesContent":["/**\n * Resource names for render graph history resources.\n * @public\n */\nexport const RGHistoryResources = {\n TAA_COLOR: 'taaColor',\n TAA_MOTION_VECTOR: 'taaMotionVector'\n} as const;\n"],"names":["RGHistoryResources","TAA_COLOR","TAA_MOTION_VECTOR"],"mappings":"AAAA;;;UAIaA,kBAAqB,GAAA;IAChCC,SAAW,EAAA,UAAA;IACXC,iBAAmB,EAAA;AACrB;;;;"}
|
|
1
|
+
{"version":3,"file":"history_resources.js","sources":["../../../src/render/rendergraph/history_resources.ts"],"sourcesContent":["/**\r\n * Resource names for render graph history resources.\r\n * @public\r\n */\r\nexport const RGHistoryResources = {\r\n TAA_COLOR: 'taaColor',\r\n TAA_MOTION_VECTOR: 'taaMotionVector'\r\n} as const;\r\n"],"names":["RGHistoryResources","TAA_COLOR","TAA_MOTION_VECTOR"],"mappings":"AAAA;;;UAIaA,kBAAqB,GAAA;IAChCC,SAAW,EAAA,UAAA;IACXC,iBAAmB,EAAA;AACrB;;;;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// ─── Handles ────────────────────────────────────────────────────────────
|
|
2
|
-
/**
|
|
3
|
-
* Opaque handle referencing a resource within the render graph.
|
|
4
|
-
*
|
|
5
|
-
* Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RGPassBuilder.createFramebuffer},
|
|
6
|
-
* {@link RenderGraph.importTexture}, or {@link RGPassBuilder.write}. They are lightweight identifiers
|
|
7
|
-
* used to declare dependencies between passes.
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
2
|
+
/**
|
|
3
|
+
* Opaque handle referencing a resource within the render graph.
|
|
4
|
+
*
|
|
5
|
+
* Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RGPassBuilder.createFramebuffer},
|
|
6
|
+
* {@link RenderGraph.importTexture}, or {@link RGPassBuilder.write}. They are lightweight identifiers
|
|
7
|
+
* used to declare dependencies between passes.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
10
|
*/ class RGHandle {
|
|
11
11
|
/** @internal */ _id;
|
|
12
12
|
/** @internal */ _name;
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
return this._name;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Internal bookkeeping for a resource within the render graph.
|
|
23
|
-
* @public
|
|
21
|
+
/**
|
|
22
|
+
* Internal bookkeeping for a resource within the render graph.
|
|
23
|
+
* @public
|
|
24
24
|
*/ class RGResource {
|
|
25
25
|
id;
|
|
26
26
|
name;
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
this.physicalId = physicalId;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Ordered execution step inside a render graph pass.
|
|
42
|
-
*
|
|
43
|
-
* Subpasses share the parent pass's resource declarations, lifetime, culling,
|
|
44
|
-
* and access validation. They are intended to make multi-step pass bodies
|
|
45
|
-
* explicit without splitting graph-level resource dependencies.
|
|
46
|
-
*
|
|
47
|
-
* @public
|
|
40
|
+
/**
|
|
41
|
+
* Ordered execution step inside a render graph pass.
|
|
42
|
+
*
|
|
43
|
+
* Subpasses share the parent pass's resource declarations, lifetime, culling,
|
|
44
|
+
* and access validation. They are intended to make multi-step pass bodies
|
|
45
|
+
* explicit without splitting graph-level resource dependencies.
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
48
|
*/ class RGSubpass {
|
|
49
49
|
name;
|
|
50
50
|
executeFn;
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
this.executeFn = executeFn;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Internal bookkeeping for a pass within the render graph.
|
|
58
|
-
* @public
|
|
56
|
+
/**
|
|
57
|
+
* Internal bookkeeping for a pass within the render graph.
|
|
58
|
+
* @public
|
|
59
59
|
*/ class RGPass {
|
|
60
60
|
index;
|
|
61
61
|
name;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type { TextureFormat } from '@zephyr3d/device';\n\n// ─── Resource Descriptors ───────────────────────────────────────────────\n\n/**\n * Sizing mode for render graph textures.\n *\n * - 'absolute': fixed pixel dimensions\n * - 'backbuffer-relative': scaled relative to the backbuffer size\n *\n * @public\n */\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\n\n/**\n * Descriptor for a transient texture resource within the render graph.\n *\n * Transient textures are allocated and released automatically by the graph compiler.\n *\n * @public\n */\nexport interface RGTextureDesc {\n /** Debug label for this resource. */\n label?: string;\n /** Texture format (e.g. 'rgba8unorm', 'r32f', 'rgba16f'). */\n format: TextureFormat;\n /** Sizing mode. Default 'backbuffer-relative'. */\n sizeMode?: RGSizeMode;\n /** Width in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\n width?: number;\n /** Height in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\n height?: number;\n /** Number of mip levels. Default 1. */\n mipLevels?: number;\n}\n\n// ─── Handles ────────────────────────────────────────────────────────────\n\n/**\n * Opaque handle referencing a resource within the render graph.\n *\n * Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RGPassBuilder.createFramebuffer},\n * {@link RenderGraph.importTexture}, or {@link RGPassBuilder.write}. They are lightweight identifiers\n * used to declare dependencies between passes.\n *\n * @public\n */\nexport class RGHandle {\n /** @internal */\n readonly _id: number;\n /** @internal */\n readonly _name: string;\n\n /** @internal */\n constructor(id: number, name: string) {\n this._id = id;\n this._name = name;\n }\n\n /** Debug-friendly name of the referenced resource. */\n get name(): string {\n return this._name;\n }\n}\n\n// ─── Internal Resource Tracking ─────────────────────────────────────────\n\n/** @public */\nexport type RGResourceKind = 'transient' | 'imported' | 'token' | 'framebuffer';\n\n/**\n * Internal bookkeeping for a resource within the render graph.\n * @public\n */\nexport class RGResource {\n readonly id: number;\n readonly name: string;\n readonly kind: RGResourceKind;\n readonly desc: RGTextureDesc | RGFramebufferDesc | null;\n /** Resource ID of the physical backing resource used by imported versions. */\n readonly physicalId: number;\n /** The pass that creates / writes this resource (null for imported until written). */\n producer: RGPass | null = null;\n /** Passes that read this resource. */\n readonly consumers: RGPass[] = [];\n\n constructor(\n id: number,\n name: string,\n kind: RGResourceKind,\n desc: RGTextureDesc | RGFramebufferDesc | null,\n physicalId = id\n ) {\n this.id = id;\n this.name = name;\n this.kind = kind;\n this.desc = desc;\n this.physicalId = physicalId;\n }\n}\n\n// ─── Internal Pass Tracking ─────────────────────────────────────────────\n\n// ─── Execution Context ──────────────────────────────────────────────\n\n/**\n * Context passed to pass execute callbacks during graph execution.\n *\n * Provides access to resolved GPU resources by their handles.\n *\n * @public\n */\nexport interface RGExecuteContext {\n /**\n * Resolve a handle to the actual GPU texture object.\n *\n * For transient resources, this returns the texture allocated by the executor.\n * For imported resources, this returns the texture registered via\n * {@link RenderGraphExecutor.setImportedTexture}. The handle must be declared\n * by the current pass with {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\n *\n * @param handle - Handle of the resource to resolve.\n * @returns The resolved texture object (type depends on the allocator).\n */\n getTexture<TTexture = unknown>(handle: RGHandle): TTexture;\n\n /**\n * Resolve a framebuffer handle to the actual backend framebuffer object.\n *\n * The handle must be declared by the current pass with {@link RGPassBuilder.read}\n * or created by the same pass with {@link RGPassBuilder.createFramebuffer}.\n *\n * @param handle - Handle returned from {@link RGPassBuilder.createFramebuffer}.\n * @returns The resolved framebuffer object (type depends on the allocator).\n */\n getFramebuffer<TFramebuffer = unknown>(handle: RGHandle): TFramebuffer;\n\n /**\n * Create a temporary framebuffer managed by the graph executor.\n *\n * The framebuffer is released automatically when graph execution finishes or\n * aborts. Attachments may be actual backend resources or texture formats,\n * depending on the allocator implementation. If an attachment is an\n * {@link RGHandle}, the current pass must declare it with\n * {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\n *\n * @param desc - Framebuffer descriptor.\n * @returns The allocated framebuffer object (type depends on the allocator).\n */\n createFramebuffer<TFramebuffer = unknown>(desc: RGFramebufferDesc): TFramebuffer;\n\n /**\n * Register a cleanup callback to run when graph execution finishes or aborts.\n *\n * Callbacks run in reverse registration order. Use this for temporary objects\n * created inside pass execution that are not graph resources, such as pooled\n * framebuffers wrapping graph-managed textures. If pass execution throws, the\n * executor still runs cleanup callbacks and preserves the original pass error\n * ahead of cleanup errors.\n *\n * @param callback - Cleanup function to invoke after execution.\n */\n deferCleanup(callback: () => void): void;\n}\n\n/**\n * Execute callback signature.\n *\n * The callback receives a context for resolving handles to GPU resources,\n * plus the user data returned from the setup function.\n *\n * @public\n */\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\n\n/**\n * Ordered execution step inside a render graph pass.\n *\n * Subpasses share the parent pass's resource declarations, lifetime, culling,\n * and access validation. They are intended to make multi-step pass bodies\n * explicit without splitting graph-level resource dependencies.\n *\n * @public\n */\nexport class RGSubpass<T = unknown> {\n readonly name: string;\n readonly executeFn: RGExecuteFn<T>;\n\n constructor(name: string, executeFn: RGExecuteFn<T>) {\n this.name = name;\n this.executeFn = executeFn;\n }\n}\n\n/**\n * Internal bookkeeping for a pass within the render graph.\n * @public\n */\nexport class RGPass<T = unknown> {\n readonly index: number;\n readonly name: string;\n /** Resources this pass reads (dependencies). */\n readonly reads: RGResource[] = [];\n /** Resources this pass creates or writes. */\n readonly writes: RGResource[] = [];\n /** Passes that must complete before this pass due to non-resource hazards. */\n readonly dependencies: RGPass[] = [];\n /** Whether this pass has side effects and must not be culled. */\n hasSideEffect = false;\n /** User data returned from the setup function. */\n data: T | null = null;\n /** Execute callback. */\n executeFn: RGExecuteFn<T> | null = null;\n /** Ordered subpasses for passes with multiple logical execution steps. */\n readonly subpasses: RGSubpass<T>[] = [];\n /** Set during compilation: true if this pass is needed. */\n alive = true;\n\n constructor(index: number, name: string) {\n this.index = index;\n this.name = name;\n }\n}\n\n// ─── Pass Builder ───────────────────────────────────────────────────────\n\n/**\n * Builder interface used within the setup callback of {@link RenderGraph.addPass}\n * to declare a pass's resource requirements.\n *\n * @public\n */\nexport interface RGPassBuilder {\n /**\n * Declare a read dependency on an existing resource.\n *\n * The resource must have been created by a prior pass or imported into the graph.\n *\n * @param handle - Handle of the resource to read.\n */\n read(handle: RGHandle): void;\n\n /**\n * Declare that this pass writes a new version of an existing resource.\n *\n * The returned handle represents the post-write version. Use it for subsequent\n * reads and as the graph output passed to {@link RenderGraph.compile}. Passing\n * an older version of the same resource to `compile()` is rejected because it\n * usually means the caller ignored the handle returned by `write()`. If the pass\n * needs the previous contents, call {@link RGPassBuilder.read} on the input handle explicitly\n * before writing.\n *\n * @param handle - Handle of the resource to write to.\n * @returns A handle referencing the newly written version.\n */\n write(handle: RGHandle): RGHandle;\n\n /**\n * Create a new transient texture resource that this pass will produce.\n *\n * @param desc - Texture descriptor.\n * @returns A handle referencing the newly created resource.\n */\n createTexture(desc: RGTextureDesc): RGHandle;\n\n /**\n * Create a logical dependency token produced by this pass.\n *\n * Tokens do not resolve to GPU resources and are not allocated by the executor.\n * They are useful for ordering passes whose dependencies are side effects rather\n * than texture reads/writes.\n *\n * @param name - Debug label for this token.\n * @returns A handle referencing the newly created token.\n */\n createToken(name?: string): RGHandle;\n\n /**\n * Create a graph-managed framebuffer view.\n *\n * The graph compiler infers dependencies from any attachment handles in the\n * descriptor. The executor creates and releases the framebuffer automatically.\n *\n * @param desc - Framebuffer descriptor.\n * @returns A handle referencing the framebuffer view.\n */\n createFramebuffer(desc: RGFramebufferDesc): RGHandle;\n\n /**\n * Mark this pass as having side effects.\n *\n * Side-effect passes are never culled by the graph compiler, regardless of\n * whether their outputs are consumed. Use this for GPU readback, picking,\n * debug overlays, etc.\n */\n sideEffect(): void;\n\n /**\n * Add an ordered logical subpass to this pass.\n *\n * Subpasses execute in registration order and share the parent pass's declared\n * reads, writes, framebuffer views, and user data. A pass may use either\n * subpasses or {@link RGPassBuilder.setExecute}, but not both.\n *\n * @param name - Debug label for the subpass.\n * @param fn - Callback invoked when this subpass executes.\n */\n addSubpass<D>(name: string, fn: RGExecuteFn<D>): void;\n\n /**\n * Set the execution callback for this pass.\n *\n * A pass may use either this method or {@link RGPassBuilder.addSubpass}, but not both.\n *\n * @param fn - Callback invoked during graph execution.\n */\n setExecute<D>(fn: RGExecuteFn<D>): void;\n}\n\n// ─── Compiled Graph ─────────────────────────────────────────────────────\n\n/**\n * Lifetime information for a resource within the compiled graph.\n *\n * @public\n */\nexport interface RGResourceLifetime {\n /** The resource. */\n readonly resource: RGResource;\n /** Index of the first pass that uses (produces or reads) this resource. */\n readonly firstUse: number;\n /** Index of the last pass that uses this resource. */\n readonly lastUse: number;\n}\n\n/**\n * Result of compiling a render graph.\n *\n * Contains the ordered list of passes to execute and lifetime information\n * for automatic resource management.\n *\n * @public\n */\nexport interface CompiledRenderGraph {\n /** Topologically sorted passes (only non-culled passes). */\n readonly orderedPasses: ReadonlyArray<RGPass>;\n /** Resource lifetime information keyed by resource ID. */\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\n}\n\n// ─── Texture Allocator ──────────────────────────────────────────────\n\n/**\n * Resolved dimensions for a texture allocation.\n * @public\n */\nexport interface RGResolvedSize {\n width: number;\n height: number;\n}\n\n/**\n * Descriptor for a framebuffer view managed by the graph or created temporarily during pass execution.\n *\n * This is intentionally backend-agnostic: graph-managed descriptors may use\n * {@link RGHandle} attachments, and executor-created descriptors use resolved\n * resources or texture formats understood by the allocator.\n *\n * @public\n */\nexport interface RGFramebufferDesc {\n /** Debug label for this framebuffer. */\n label?: string;\n /** Framebuffer width. Required when attachments are formats. */\n width?: number;\n /** Framebuffer height. Required when attachments are formats. */\n height?: number;\n /** Color attachments or formats. */\n colorAttachments: unknown | unknown[] | null;\n /** Depth/stencil attachment or format. */\n depthAttachment?: unknown | null;\n /** Whether color attachments created from formats should support mipmapping. */\n mipmapping?: boolean;\n /** Framebuffer sample count. */\n sampleCount?: number;\n /** Whether to ignore depth/stencil during MSAA resolve. */\n ignoreDepthStencil?: boolean;\n /** Attachment mip level. */\n attachmentMipLevel?: number;\n /** Attachment cubemap face. */\n attachmentCubeface?: number;\n /** Attachment array layer. */\n attachmentLayer?: number;\n}\n\n/**\n * Interface for allocating and releasing transient textures.\n *\n * Implement this to bridge the render graph with your GPU device's resource pool.\n * The executor calls `allocate()` before a resource's first use and\n * `release()` after its last use.\n *\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\n * @public\n */\nexport interface RGTextureAllocator<TTexture = unknown, TFramebuffer = unknown> {\n /**\n * Allocate a transient texture matching the given descriptor and resolved size.\n *\n * @param desc - The texture descriptor from the pass builder.\n * @param size - The resolved pixel dimensions.\n * @returns The allocated texture object.\n */\n allocate(desc: RGTextureDesc, size: RGResolvedSize): TTexture;\n\n /**\n * Release a previously allocated transient texture back to the pool.\n *\n * @param texture - The texture to release.\n */\n release(texture: TTexture): void;\n\n /**\n * Allocate a temporary framebuffer matching the given descriptor.\n *\n * Implementations should not auto-release this framebuffer; the graph executor\n * calls {@link RGTextureAllocator.releaseFramebuffer} when execution completes or aborts.\n *\n * @param desc - Framebuffer descriptor.\n * @returns The allocated framebuffer object.\n */\n allocateFramebuffer?(desc: RGFramebufferDesc): TFramebuffer;\n\n /**\n * Release a previously allocated temporary framebuffer.\n *\n * @param framebuffer - The framebuffer to release.\n */\n releaseFramebuffer?(framebuffer: TFramebuffer): void;\n}\n"],"names":["RGHandle","id","name","_id","_name","RGResource","kind","desc","producer","consumers","physicalId","RGSubpass","executeFn","RGPass","index","reads","writes","dependencies","hasSideEffect","data","subpasses","alive"],"mappings":"AAoCA;AAEA;;;;;;;;AAQC,IACM,MAAMA,QAAAA,CAAAA;qBAEX,GAAqB;qBAErB,KAAuB;AAEvB,qBACA,WAAA,CAAYC,EAAU,EAAEC,IAAY,CAAE;QACpC,IAAI,CAACC,GAAG,GAAGF,EAAAA;QACX,IAAI,CAACG,KAAK,GAAGF,IAAAA;AACf;2DAGA,IAAIA,IAAe,GAAA;QACjB,OAAO,IAAI,CAACE,KAAK;AACnB;AACF;AAOA;;;AAGC,IACM,MAAMC,UAAAA,CAAAA;IACFJ,EAAW;IACXC,IAAa;IACbI,IAAqB;IACrBC,IAA+C;mFAExD,UAA4B;2FAE5BC,WAA0B,IAAK;AAC/B,2CACSC,SAAsB,GAAA,EAAE;IAEjC,WACER,CAAAA,EAAU,EACVC,IAAY,EACZI,IAAoB,EACpBC,IAA8C,EAC9CG,UAAaT,GAAAA,EAAE,CACf;QACA,IAAI,CAACA,EAAE,GAAGA,EAAAA;QACV,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACI,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACG,UAAU,GAAGA,UAAAA;AACpB;AACF;AA4EA;;;;;;;;AAQC,IACM,MAAMC,SAAAA,CAAAA;IACFT,IAAa;IACbU,SAA0B;IAEnC,WAAYV,CAAAA,IAAY,EAAEU,SAAyB,CAAE;QACnD,IAAI,CAACV,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACU,SAAS,GAAGA,SAAAA;AACnB;AACF;AAEA;;;AAGC,IACM,MAAMC,MAAAA,CAAAA;IACFC,KAAc;IACdZ,IAAa;AACtB,qDACSa,KAAsB,GAAA,EAAE;AACjC,kDACSC,MAAuB,GAAA,EAAE;AAClC,mFACSC,YAAyB,GAAA,EAAE;sEAEpCC,gBAAgB,KAAM;uDAEtBC,OAAiB,IAAK;6BAEtBP,YAAmC,IAAK;AACxC,+EACSQ,SAA4B,GAAA,EAAE;gEAEvCC,QAAQ,IAAK;IAEb,WAAYP,CAAAA,KAAa,EAAEZ,IAAY,CAAE;QACvC,IAAI,CAACY,KAAK,GAAGA,KAAAA;QACb,IAAI,CAACZ,IAAI,GAAGA,IAAAA;AACd;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type { TextureFormat } from '@zephyr3d/device';\r\n\r\n// ─── Resource Descriptors ───────────────────────────────────────────────\r\n\r\n/**\r\n * Sizing mode for render graph textures.\r\n *\r\n * - 'absolute': fixed pixel dimensions\r\n * - 'backbuffer-relative': scaled relative to the backbuffer size\r\n *\r\n * @public\r\n */\r\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\r\n\r\n/**\r\n * Descriptor for a transient texture resource within the render graph.\r\n *\r\n * Transient textures are allocated and released automatically by the graph compiler.\r\n *\r\n * @public\r\n */\r\nexport interface RGTextureDesc {\r\n /** Debug label for this resource. */\r\n label?: string;\r\n /** Texture format (e.g. 'rgba8unorm', 'r32f', 'rgba16f'). */\r\n format: TextureFormat;\r\n /** Sizing mode. Default 'backbuffer-relative'. */\r\n sizeMode?: RGSizeMode;\r\n /** Width in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n width?: number;\r\n /** Height in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n height?: number;\r\n /** Number of mip levels. Default 1. */\r\n mipLevels?: number;\r\n}\r\n\r\n// ─── Handles ────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Opaque handle referencing a resource within the render graph.\r\n *\r\n * Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RGPassBuilder.createFramebuffer},\r\n * {@link RenderGraph.importTexture}, or {@link RGPassBuilder.write}. They are lightweight identifiers\r\n * used to declare dependencies between passes.\r\n *\r\n * @public\r\n */\r\nexport class RGHandle {\r\n /** @internal */\r\n readonly _id: number;\r\n /** @internal */\r\n readonly _name: string;\r\n\r\n /** @internal */\r\n constructor(id: number, name: string) {\r\n this._id = id;\r\n this._name = name;\r\n }\r\n\r\n /** Debug-friendly name of the referenced resource. */\r\n get name(): string {\r\n return this._name;\r\n }\r\n}\r\n\r\n// ─── Internal Resource Tracking ─────────────────────────────────────────\r\n\r\n/** @public */\r\nexport type RGResourceKind = 'transient' | 'imported' | 'token' | 'framebuffer';\r\n\r\n/**\r\n * Internal bookkeeping for a resource within the render graph.\r\n * @public\r\n */\r\nexport class RGResource {\r\n readonly id: number;\r\n readonly name: string;\r\n readonly kind: RGResourceKind;\r\n readonly desc: RGTextureDesc | RGFramebufferDesc | null;\r\n /** Resource ID of the physical backing resource used by imported versions. */\r\n readonly physicalId: number;\r\n /** The pass that creates / writes this resource (null for imported until written). */\r\n producer: RGPass | null = null;\r\n /** Passes that read this resource. */\r\n readonly consumers: RGPass[] = [];\r\n\r\n constructor(\r\n id: number,\r\n name: string,\r\n kind: RGResourceKind,\r\n desc: RGTextureDesc | RGFramebufferDesc | null,\r\n physicalId = id\r\n ) {\r\n this.id = id;\r\n this.name = name;\r\n this.kind = kind;\r\n this.desc = desc;\r\n this.physicalId = physicalId;\r\n }\r\n}\r\n\r\n// ─── Internal Pass Tracking ─────────────────────────────────────────────\r\n\r\n// ─── Execution Context ──────────────────────────────────────────────\r\n\r\n/**\r\n * Context passed to pass execute callbacks during graph execution.\r\n *\r\n * Provides access to resolved GPU resources by their handles.\r\n *\r\n * @public\r\n */\r\nexport interface RGExecuteContext {\r\n /**\r\n * Resolve a handle to the actual GPU texture object.\r\n *\r\n * For transient resources, this returns the texture allocated by the executor.\r\n * For imported resources, this returns the texture registered via\r\n * {@link RenderGraphExecutor.setImportedTexture}. The handle must be declared\r\n * by the current pass with {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\r\n *\r\n * @param handle - Handle of the resource to resolve.\r\n * @returns The resolved texture object (type depends on the allocator).\r\n */\r\n getTexture<TTexture = unknown>(handle: RGHandle): TTexture;\r\n\r\n /**\r\n * Resolve a framebuffer handle to the actual backend framebuffer object.\r\n *\r\n * The handle must be declared by the current pass with {@link RGPassBuilder.read}\r\n * or created by the same pass with {@link RGPassBuilder.createFramebuffer}.\r\n *\r\n * @param handle - Handle returned from {@link RGPassBuilder.createFramebuffer}.\r\n * @returns The resolved framebuffer object (type depends on the allocator).\r\n */\r\n getFramebuffer<TFramebuffer = unknown>(handle: RGHandle): TFramebuffer;\r\n\r\n /**\r\n * Create a temporary framebuffer managed by the graph executor.\r\n *\r\n * The framebuffer is released automatically when graph execution finishes or\r\n * aborts. Attachments may be actual backend resources or texture formats,\r\n * depending on the allocator implementation. If an attachment is an\r\n * {@link RGHandle}, the current pass must declare it with\r\n * {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\r\n *\r\n * @param desc - Framebuffer descriptor.\r\n * @returns The allocated framebuffer object (type depends on the allocator).\r\n */\r\n createFramebuffer<TFramebuffer = unknown>(desc: RGFramebufferDesc): TFramebuffer;\r\n\r\n /**\r\n * Register a cleanup callback to run when graph execution finishes or aborts.\r\n *\r\n * Callbacks run in reverse registration order. Use this for temporary objects\r\n * created inside pass execution that are not graph resources, such as pooled\r\n * framebuffers wrapping graph-managed textures. If pass execution throws, the\r\n * executor still runs cleanup callbacks and preserves the original pass error\r\n * ahead of cleanup errors.\r\n *\r\n * @param callback - Cleanup function to invoke after execution.\r\n */\r\n deferCleanup(callback: () => void): void;\r\n}\r\n\r\n/**\r\n * Execute callback signature.\r\n *\r\n * The callback receives a context for resolving handles to GPU resources,\r\n * plus the user data returned from the setup function.\r\n *\r\n * @public\r\n */\r\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\r\n\r\n/**\r\n * Ordered execution step inside a render graph pass.\r\n *\r\n * Subpasses share the parent pass's resource declarations, lifetime, culling,\r\n * and access validation. They are intended to make multi-step pass bodies\r\n * explicit without splitting graph-level resource dependencies.\r\n *\r\n * @public\r\n */\r\nexport class RGSubpass<T = unknown> {\r\n readonly name: string;\r\n readonly executeFn: RGExecuteFn<T>;\r\n\r\n constructor(name: string, executeFn: RGExecuteFn<T>) {\r\n this.name = name;\r\n this.executeFn = executeFn;\r\n }\r\n}\r\n\r\n/**\r\n * Internal bookkeeping for a pass within the render graph.\r\n * @public\r\n */\r\nexport class RGPass<T = unknown> {\r\n readonly index: number;\r\n readonly name: string;\r\n /** Resources this pass reads (dependencies). */\r\n readonly reads: RGResource[] = [];\r\n /** Resources this pass creates or writes. */\r\n readonly writes: RGResource[] = [];\r\n /** Passes that must complete before this pass due to non-resource hazards. */\r\n readonly dependencies: RGPass[] = [];\r\n /** Whether this pass has side effects and must not be culled. */\r\n hasSideEffect = false;\r\n /** User data returned from the setup function. */\r\n data: T | null = null;\r\n /** Execute callback. */\r\n executeFn: RGExecuteFn<T> | null = null;\r\n /** Ordered subpasses for passes with multiple logical execution steps. */\r\n readonly subpasses: RGSubpass<T>[] = [];\r\n /** Set during compilation: true if this pass is needed. */\r\n alive = true;\r\n\r\n constructor(index: number, name: string) {\r\n this.index = index;\r\n this.name = name;\r\n }\r\n}\r\n\r\n// ─── Pass Builder ───────────────────────────────────────────────────────\r\n\r\n/**\r\n * Builder interface used within the setup callback of {@link RenderGraph.addPass}\r\n * to declare a pass's resource requirements.\r\n *\r\n * @public\r\n */\r\nexport interface RGPassBuilder {\r\n /**\r\n * Declare a read dependency on an existing resource.\r\n *\r\n * The resource must have been created by a prior pass or imported into the graph.\r\n *\r\n * @param handle - Handle of the resource to read.\r\n */\r\n read(handle: RGHandle): void;\r\n\r\n /**\r\n * Declare that this pass writes a new version of an existing resource.\r\n *\r\n * The returned handle represents the post-write version. Use it for subsequent\r\n * reads and as the graph output passed to {@link RenderGraph.compile}. Passing\r\n * an older version of the same resource to `compile()` is rejected because it\r\n * usually means the caller ignored the handle returned by `write()`. If the pass\r\n * needs the previous contents, call {@link RGPassBuilder.read} on the input handle explicitly\r\n * before writing.\r\n *\r\n * @param handle - Handle of the resource to write to.\r\n * @returns A handle referencing the newly written version.\r\n */\r\n write(handle: RGHandle): RGHandle;\r\n\r\n /**\r\n * Create a new transient texture resource that this pass will produce.\r\n *\r\n * @param desc - Texture descriptor.\r\n * @returns A handle referencing the newly created resource.\r\n */\r\n createTexture(desc: RGTextureDesc): RGHandle;\r\n\r\n /**\r\n * Create a logical dependency token produced by this pass.\r\n *\r\n * Tokens do not resolve to GPU resources and are not allocated by the executor.\r\n * They are useful for ordering passes whose dependencies are side effects rather\r\n * than texture reads/writes.\r\n *\r\n * @param name - Debug label for this token.\r\n * @returns A handle referencing the newly created token.\r\n */\r\n createToken(name?: string): RGHandle;\r\n\r\n /**\r\n * Create a graph-managed framebuffer view.\r\n *\r\n * The graph compiler infers dependencies from any attachment handles in the\r\n * descriptor. The executor creates and releases the framebuffer automatically.\r\n *\r\n * @param desc - Framebuffer descriptor.\r\n * @returns A handle referencing the framebuffer view.\r\n */\r\n createFramebuffer(desc: RGFramebufferDesc): RGHandle;\r\n\r\n /**\r\n * Mark this pass as having side effects.\r\n *\r\n * Side-effect passes are never culled by the graph compiler, regardless of\r\n * whether their outputs are consumed. Use this for GPU readback, picking,\r\n * debug overlays, etc.\r\n */\r\n sideEffect(): void;\r\n\r\n /**\r\n * Add an ordered logical subpass to this pass.\r\n *\r\n * Subpasses execute in registration order and share the parent pass's declared\r\n * reads, writes, framebuffer views, and user data. A pass may use either\r\n * subpasses or {@link RGPassBuilder.setExecute}, but not both.\r\n *\r\n * @param name - Debug label for the subpass.\r\n * @param fn - Callback invoked when this subpass executes.\r\n */\r\n addSubpass<D>(name: string, fn: RGExecuteFn<D>): void;\r\n\r\n /**\r\n * Set the execution callback for this pass.\r\n *\r\n * A pass may use either this method or {@link RGPassBuilder.addSubpass}, but not both.\r\n *\r\n * @param fn - Callback invoked during graph execution.\r\n */\r\n setExecute<D>(fn: RGExecuteFn<D>): void;\r\n}\r\n\r\n// ─── Compiled Graph ─────────────────────────────────────────────────────\r\n\r\n/**\r\n * Lifetime information for a resource within the compiled graph.\r\n *\r\n * @public\r\n */\r\nexport interface RGResourceLifetime {\r\n /** The resource. */\r\n readonly resource: RGResource;\r\n /** Index of the first pass that uses (produces or reads) this resource. */\r\n readonly firstUse: number;\r\n /** Index of the last pass that uses this resource. */\r\n readonly lastUse: number;\r\n}\r\n\r\n/**\r\n * Result of compiling a render graph.\r\n *\r\n * Contains the ordered list of passes to execute and lifetime information\r\n * for automatic resource management.\r\n *\r\n * @public\r\n */\r\nexport interface CompiledRenderGraph {\r\n /** Topologically sorted passes (only non-culled passes). */\r\n readonly orderedPasses: ReadonlyArray<RGPass>;\r\n /** Resource lifetime information keyed by resource ID. */\r\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\r\n}\r\n\r\n// ─── Texture Allocator ──────────────────────────────────────────────\r\n\r\n/**\r\n * Resolved dimensions for a texture allocation.\r\n * @public\r\n */\r\nexport interface RGResolvedSize {\r\n width: number;\r\n height: number;\r\n}\r\n\r\n/**\r\n * Descriptor for a framebuffer view managed by the graph or created temporarily during pass execution.\r\n *\r\n * This is intentionally backend-agnostic: graph-managed descriptors may use\r\n * {@link RGHandle} attachments, and executor-created descriptors use resolved\r\n * resources or texture formats understood by the allocator.\r\n *\r\n * @public\r\n */\r\nexport interface RGFramebufferDesc {\r\n /** Debug label for this framebuffer. */\r\n label?: string;\r\n /** Framebuffer width. Required when attachments are formats. */\r\n width?: number;\r\n /** Framebuffer height. Required when attachments are formats. */\r\n height?: number;\r\n /** Color attachments or formats. */\r\n colorAttachments: unknown | unknown[] | null;\r\n /** Depth/stencil attachment or format. */\r\n depthAttachment?: unknown | null;\r\n /** Whether color attachments created from formats should support mipmapping. */\r\n mipmapping?: boolean;\r\n /** Framebuffer sample count. */\r\n sampleCount?: number;\r\n /** Whether to ignore depth/stencil during MSAA resolve. */\r\n ignoreDepthStencil?: boolean;\r\n /** Attachment mip level. */\r\n attachmentMipLevel?: number;\r\n /** Attachment cubemap face. */\r\n attachmentCubeface?: number;\r\n /** Attachment array layer. */\r\n attachmentLayer?: number;\r\n}\r\n\r\n/**\r\n * Interface for allocating and releasing transient textures.\r\n *\r\n * Implement this to bridge the render graph with your GPU device's resource pool.\r\n * The executor calls `allocate()` before a resource's first use and\r\n * `release()` after its last use.\r\n *\r\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\r\n * @public\r\n */\r\nexport interface RGTextureAllocator<TTexture = unknown, TFramebuffer = unknown> {\r\n /**\r\n * Allocate a transient texture matching the given descriptor and resolved size.\r\n *\r\n * @param desc - The texture descriptor from the pass builder.\r\n * @param size - The resolved pixel dimensions.\r\n * @returns The allocated texture object.\r\n */\r\n allocate(desc: RGTextureDesc, size: RGResolvedSize): TTexture;\r\n\r\n /**\r\n * Release a previously allocated transient texture back to the pool.\r\n *\r\n * @param texture - The texture to release.\r\n */\r\n release(texture: TTexture): void;\r\n\r\n /**\r\n * Allocate a temporary framebuffer matching the given descriptor.\r\n *\r\n * Implementations should not auto-release this framebuffer; the graph executor\r\n * calls {@link RGTextureAllocator.releaseFramebuffer} when execution completes or aborts.\r\n *\r\n * @param desc - Framebuffer descriptor.\r\n * @returns The allocated framebuffer object.\r\n */\r\n allocateFramebuffer?(desc: RGFramebufferDesc): TFramebuffer;\r\n\r\n /**\r\n * Release a previously allocated temporary framebuffer.\r\n *\r\n * @param framebuffer - The framebuffer to release.\r\n */\r\n releaseFramebuffer?(framebuffer: TFramebuffer): void;\r\n}\r\n"],"names":["RGHandle","id","name","_id","_name","RGResource","kind","desc","producer","consumers","physicalId","RGSubpass","executeFn","RGPass","index","reads","writes","dependencies","hasSideEffect","data","subpasses","alive"],"mappings":"AAoCA;AAEA;;;;;;;;AAQC,IACM,MAAMA,QAAAA,CAAAA;qBAEX,GAAqB;qBAErB,KAAuB;AAEvB,qBACA,WAAA,CAAYC,EAAU,EAAEC,IAAY,CAAE;QACpC,IAAI,CAACC,GAAG,GAAGF,EAAAA;QACX,IAAI,CAACG,KAAK,GAAGF,IA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'../material/pbrsg.js';
|
|
|
19
19
|
import '../material/pbrblueprint.js';
|
|
20
20
|
import { SpriteMaterial } from '../material/sprite.js';
|
|
21
21
|
import '../material/sprite_std.js';
|
|
22
|
+
import '../material/msdf_text.js';
|
|
22
23
|
import '../utility/blueprint/material/texture.js';
|
|
23
24
|
import '../render/rendergraph/forward_plus_builder.js';
|
|
24
25
|
import '../render/sky.js';
|
|
@@ -59,11 +60,6 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
|
|
|
59
60
|
this._materialChangeTag = null;
|
|
60
61
|
}
|
|
61
62
|
/**
|
|
62
|
-
* {@inheritDoc Drawable.getName}
|
|
63
|
-
*/ getName() {
|
|
64
|
-
return this._name;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
63
|
* Returns the batch instance ID for the current render pass.
|
|
68
64
|
*/ getInstanceId(_renderPass) {
|
|
69
65
|
return `${this._instanceHash}:${this.worldMatrixDet >= 0}`;
|