@zephyr3d/scene 0.8.2 → 0.9.0
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 +473 -60
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/cloth/gpu_cloth_system.js +2516 -0
- package/dist/animation/cloth/gpu_cloth_system.js.map +1 -0
- package/dist/animation/fixed_geometry_cache_track.js +138 -0
- package/dist/animation/fixed_geometry_cache_track.js.map +1 -0
- package/dist/animation/geometry_cache_utils.js +120 -0
- package/dist/animation/geometry_cache_utils.js.map +1 -0
- package/dist/animation/ik_modifier.js +9 -1
- package/dist/animation/ik_modifier.js.map +1 -1
- package/dist/animation/joint_dynamics/collision.js +469 -0
- package/dist/animation/joint_dynamics/collision.js.map +1 -0
- package/dist/animation/joint_dynamics/constraints.js +329 -0
- package/dist/animation/joint_dynamics/constraints.js.map +1 -0
- package/dist/animation/joint_dynamics/controller.js +699 -0
- package/dist/animation/joint_dynamics/controller.js.map +1 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +393 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -0
- package/dist/animation/joint_dynamics/solver.js +794 -0
- package/dist/animation/joint_dynamics/solver.js.map +1 -0
- package/dist/animation/joint_dynamics/types.js +19 -0
- package/dist/animation/joint_dynamics/types.js.map +1 -0
- package/dist/animation/joint_dynamics/vrm_spring_bone.js +46 -0
- package/dist/animation/joint_dynamics/vrm_spring_bone.js.map +1 -0
- package/dist/animation/joint_dynamics_modifier.js +51 -0
- package/dist/animation/joint_dynamics_modifier.js.map +1 -0
- package/dist/animation/pca_geometry_cache_track.js +222 -0
- package/dist/animation/pca_geometry_cache_track.js.map +1 -0
- package/dist/animation/skeleton.js +2011 -139
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js +3 -5
- package/dist/animation/skeleton_modifier.js.map +1 -1
- package/dist/animation/spring/multi_chain_spring_system.js +2 -0
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
- package/dist/animation/spring/spring_chain.js +3 -2
- package/dist/animation/spring/spring_chain.js.map +1 -1
- package/dist/animation/spring/spring_collider.js +35 -5
- package/dist/animation/spring/spring_collider.js.map +1 -1
- package/dist/animation/spring/spring_particle.js +1 -0
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_system.js +325 -28
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring2/collision.js +469 -0
- package/dist/animation/spring2/collision.js.map +1 -0
- package/dist/animation/spring2/constraints.js +329 -0
- package/dist/animation/spring2/constraints.js.map +1 -0
- package/dist/animation/spring2/controller.js +434 -0
- package/dist/animation/spring2/controller.js.map +1 -0
- package/dist/animation/spring2/math.js +16 -0
- package/dist/animation/spring2/math.js.map +1 -0
- package/dist/animation/spring2/solver.js +624 -0
- package/dist/animation/spring2/solver.js.map +1 -0
- package/dist/animation/spring2/spring_system.js +118 -0
- package/dist/animation/spring2/spring_system.js.map +1 -0
- package/dist/animation/spring2/types.js +19 -0
- package/dist/animation/spring2/types.js.map +1 -0
- package/dist/animation/spring_modifier.js +17 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/app/engine.js +42 -15
- package/dist/app/engine.js.map +1 -1
- package/dist/app/runtimescript.js +132 -1
- package/dist/app/runtimescript.js.map +1 -1
- package/dist/app/screen.js +3 -3
- package/dist/app/screen.js.map +1 -1
- package/dist/app/scriptingsystem.js +69 -37
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +157 -146
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +2 -1
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/zabc/zabc_loader.js +570 -0
- package/dist/asset/loaders/zabc/zabc_loader.js.map +1 -0
- package/dist/asset/model.js +192 -0
- package/dist/asset/model.js.map +1 -1
- package/dist/camera/base.js +26 -7
- package/dist/camera/base.js.map +1 -1
- package/dist/camera/camera.js +146 -24
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/fps.js +2 -2
- package/dist/camera/fps.js.map +1 -1
- package/dist/camera/orbit.js +2 -2
- package/dist/camera/orbit.js.map +1 -1
- package/dist/index.d.ts +11728 -8535
- package/dist/index.js +29 -8
- package/dist/index.js.map +1 -1
- package/dist/material/lambert.js +1 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +9 -3
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +54 -7
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +17 -7
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +7 -2
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +108 -16
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +222 -14
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +24 -12
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +11 -8
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +72 -5
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/pbrblueprint.js +148 -1
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/pbrmr.js +125 -2
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/shader/helper.js +10 -4
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/water.js +2 -2
- package/dist/material/water.js.map +1 -1
- package/dist/posteffect/coloradjust.js +145 -0
- package/dist/posteffect/coloradjust.js.map +1 -0
- package/dist/posteffect/taa.js +68 -32
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/cluster_light.js +17 -12
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/deferredlightpass.js +510 -0
- package/dist/render/deferredlightpass.js.map +1 -0
- package/dist/render/deferredshadowlightpass.js +428 -0
- package/dist/render/deferredshadowlightpass.js.map +1 -0
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/drawable_mixin.js +21 -12
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +20 -22
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/gbufferpass.js +50 -0
- package/dist/render/gbufferpass.js.map +1 -0
- package/dist/render/lightpass.js +1 -2
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/primitive.js +1 -1
- package/dist/render/primitive.js.map +1 -1
- package/dist/render/render_queue.js +3 -2
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +5 -358
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/executor.js +15 -12
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +144 -88
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/history_resource_manager.js +178 -0
- package/dist/render/rendergraph/history_resource_manager.js.map +1 -0
- package/dist/render/rendergraph/rendergraph.js +12 -1
- package/dist/render/rendergraph/rendergraph.js.map +1 -1
- package/dist/render/rendergraph/types.js +2 -2
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/sky.js +26 -9
- package/dist/render/sky.js.map +1 -1
- package/dist/scene/basesprite.js +4 -3
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +4 -4
- package/dist/scene/environment.js +7 -4
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/light.js +184 -18
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +30 -0
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/particlesys.js +3 -2
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/raycast_visitor.js +29 -3
- package/dist/scene/raycast_visitor.js.map +1 -1
- package/dist/scene/scene.js +86 -19
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +87 -31
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/script_attachment.js +59 -0
- package/dist/scene/script_attachment.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +3 -2
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +4 -3
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/water.js +3 -2
- package/dist/scene/water.js.map +1 -1
- package/dist/shaders/shadow.js +2 -2
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shadow/shadowmapper.js +74 -4
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shapes/box.js +163 -0
- package/dist/shapes/box.js.map +1 -1
- package/dist/shapes/capsule.js +216 -0
- package/dist/shapes/capsule.js.map +1 -0
- package/dist/shapes/cylinder.js +91 -0
- package/dist/shapes/cylinder.js.map +1 -1
- package/dist/shapes/plane.js +32 -0
- package/dist/shapes/plane.js.map +1 -1
- package/dist/shapes/tetrahedron.js +211 -0
- package/dist/shapes/tetrahedron.js.map +1 -1
- package/dist/shapes/torus.js +173 -0
- package/dist/shapes/torus.js.map +1 -1
- package/dist/utility/blueprint/common/math.js +111 -1
- package/dist/utility/blueprint/common/math.js.map +1 -1
- package/dist/utility/blueprint/material/inputs.js +235 -1
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +154 -10
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/texture.js +273 -19
- package/dist/utility/blueprint/material/texture.js.map +1 -1
- package/dist/utility/serialization/json.js +12 -2
- package/dist/utility/serialization/json.js.map +1 -1
- package/dist/utility/serialization/manager.js +30 -11
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +250 -7
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +4 -2
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +154 -2
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/cloth_script.js +834 -0
- package/dist/utility/serialization/scene/cloth_script.js.map +1 -0
- package/dist/utility/serialization/scene/common.js +7 -0
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +120 -4
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +453 -1
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +4 -2
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +298 -10
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +4 -2
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +100 -3
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +130 -3
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/script.js +66 -0
- package/dist/utility/serialization/scene/script.js.map +1 -0
- package/dist/utility/serialization/scene/spring_script.js +596 -0
- package/dist/utility/serialization/scene/spring_script.js.map +1 -0
- package/dist/utility/serialization/scene/sprite.js +5 -3
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +4 -2
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +4 -2
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/values.js +5 -1
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","sources":["../../src/render/renderer.ts"],"sourcesContent":["import { LightPass } from './lightpass';\r\nimport { ShadowMapPass } from './shadowmap_pass';\r\nimport { DepthPass } from './depthpass';\r\nimport type { Nullable } from '@zephyr3d/base';\r\nimport { isPowerOf2, Matrix4x4, nextPowerOf2, Vector3, Vector4 } from '@zephyr3d/base';\r\nimport type {\r\n BindGroup,\r\n ColorState,\r\n FrameBuffer,\r\n GPUProgram,\r\n Texture2D,\r\n TextureFormat\r\n} from '@zephyr3d/device';\r\nimport { CopyBlitter } from '../blitter';\r\nimport type { DrawContext } from './drawable';\r\nimport type { RenderQueue } from './render_queue';\r\nimport type { PunctualLight, Scene } from '../scene';\r\nimport { type PickResult, Camera } from '../camera';\r\nimport { AbstractPostEffect, PostEffectLayer } from '../posteffect/posteffect';\r\nimport { ClusteredLight } from './cluster_light';\r\nimport { GlobalBindGroupAllocator } from './globalbindgroup_allocator';\r\nimport { ObjectColorPass } from './objectcolorpass';\r\nimport { buildHiZ } from './hzb';\r\nimport { MaterialVaryingFlags } from '../values';\r\nimport { fetchSampler } from '../utility/misc';\r\nimport type { Primitive } from '.';\r\nimport { BoxShape } from '../shapes';\r\nimport { getDevice } from '../app/api';\r\n\r\n/**\r\n * Forward render scheme\r\n * @internal\r\n */\r\nexport class SceneRenderer {\r\n /** @internal */\r\n private static _skyMotionVectorProgram: Nullable<GPUProgram> = null;\r\n /** @internal */\r\n private static _skyMotionVectorBindGroup: Nullable<BindGroup> = null;\r\n private static _box: Nullable<Primitive> = null;\r\n /** @internal */\r\n private static readonly _pickCamera = new Camera(null);\r\n /** @internal */\r\n private static readonly _scenePass = new LightPass();\r\n /** @internal */\r\n private static readonly _depthPass = new DepthPass();\r\n /** @internal */\r\n private static readonly _shadowMapPass = new ShadowMapPass();\r\n /** @internal */\r\n private static readonly _objectColorPass = new ObjectColorPass();\r\n /** @internal */\r\n private static _frontDepthColorState: Nullable<ColorState> = null;\r\n /** @internal */\r\n private static _backDepthColorState: Nullable<ColorState> = null;\r\n /** @internal */\r\n private static readonly _clusters: ClusteredLight[] = [];\r\n /** lighting render pass */\r\n static get sceneRenderPass() {\r\n return this._scenePass;\r\n }\r\n /** depth render pass */\r\n static get depthRenderPass() {\r\n return this._depthPass;\r\n }\r\n /** shadow map render pass */\r\n static get shadowMapRenderPass() {\r\n return this._shadowMapPass;\r\n }\r\n /** @internal */\r\n static getClusteredLight() {\r\n if (this._clusters.length > 0) {\r\n return this._clusters.pop()!;\r\n }\r\n return new ClusteredLight();\r\n }\r\n /** @internal */\r\n static freeClusteredLight(clusteredLight: ClusteredLight) {\r\n this._clusters.push(clusteredLight);\r\n }\r\n /**\r\n * Renders a scene by given camera\r\n * @param scene - The scene tondered\r\n * @param camera - The camera that will be used to render the scene\r\n * @param compositor - The compositor that will be used to apply postprocess effects\r\n */\r\n static renderScene(scene: Scene, camera: Camera): void {\r\n const device = getDevice();\r\n const colorFormat =\r\n camera.HDR && device.getDeviceCaps().textureCaps.supportHalfFloatColorBuffer ? 'rgba16f' : 'rgba8unorm';\r\n const depthFormat = device.getDeviceCaps().framebufferCaps.supportDepth32floatStencil8\r\n ? 'd32fs8'\r\n : 'd24s8';\r\n const globalBindGroupAllocator = GlobalBindGroupAllocator.get();\r\n scene.frameUpdate();\r\n scene.frameUpdatePerCamera(camera);\r\n if (camera && !device.isContextLost()) {\r\n const defaultViewport = !camera.viewport && !camera.scissor;\r\n const renderX = camera.viewport ? device.screenXToDevice(camera.viewport[0]) : 0;\r\n const renderY = camera.viewport ? device.screenYToDevice(camera.viewport[1]) : 0;\r\n const renderWidth = camera.viewport\r\n ? device.screenXToDevice(camera.viewport[2])\r\n : device.getDrawingBufferWidth();\r\n const renderHeight = camera.viewport\r\n ? device.screenYToDevice(camera.viewport[3])\r\n : device.getDrawingBufferHeight();\r\n if (renderWidth <= 0 || renderHeight <= 0) {\r\n camera.getPickResultResolveFunc()?.(null);\r\n return;\r\n }\r\n const tmpFramebuffer = defaultViewport\r\n ? null\r\n : device.pool.fetchTemporalFramebuffer(false, renderWidth, renderHeight, colorFormat, depthFormat);\r\n const originFramebuffer = device.getFramebuffer();\r\n if (tmpFramebuffer) {\r\n device.pushDeviceStates();\r\n device.setFramebuffer(tmpFramebuffer);\r\n }\r\n device.clearFrameBuffer(camera.clearColor, camera.clearDepth, camera.clearStencil);\r\n const SSR = camera.SSR && scene.env.light.envLight && scene.env.light.envLight.hasRadiance();\r\n const ctx: DrawContext = {\r\n device,\r\n scene,\r\n renderWidth,\r\n renderHeight,\r\n oit: null,\r\n motionVectors: device.type !== 'webgl' && (camera.TAA || camera.motionBlur),\r\n HiZ: camera.HiZ && device.type !== 'webgl',\r\n HiZTexture: null,\r\n globalBindGroupAllocator,\r\n camera,\r\n compositor: camera.compositor,\r\n queue: 0,\r\n lightBlending: false,\r\n renderPass: null,\r\n renderPassHash: null,\r\n flip: false,\r\n depthFormat,\r\n colorFormat,\r\n drawEnvLight: false,\r\n env: null,\r\n materialFlags: 0,\r\n SSR,\r\n SSRCalcThickness: SSR && camera.ssrCalcThickness,\r\n SSRRoughnessTexture: device.pool.fetchTemporalTexture2D(\r\n true,\r\n 'rgba8unorm',\r\n renderWidth,\r\n renderHeight\r\n ),\r\n SSRNormalTexture: device.pool.fetchTemporalTexture2D(true, 'rgba8unorm', renderWidth, renderHeight),\r\n finalFramebuffer: device.getFramebuffer(),\r\n intermediateFramebuffer: null\r\n };\r\n this._renderScene(ctx);\r\n if (tmpFramebuffer) {\r\n device.popDeviceStates();\r\n const oversizedViewport =\r\n renderX < 0 ||\r\n renderY < 0 ||\r\n renderX + renderWidth > device.getDrawingBufferWidth() ||\r\n renderY + renderHeight > device.getDrawingBufferHeight();\r\n const blitter = new CopyBlitter();\r\n if (oversizedViewport) {\r\n blitter.destRect = [renderX, renderY, renderWidth, renderHeight];\r\n } else {\r\n blitter.viewport = camera.viewport ? camera.viewport.slice() : null;\r\n }\r\n blitter.scissor = camera.scissor ? camera.scissor.slice() : null;\r\n blitter.srgbOut = !originFramebuffer;\r\n blitter.blit(\r\n tmpFramebuffer.getColorAttachments()[0],\r\n originFramebuffer ?? null,\r\n fetchSampler('clamp_nearest_nomip')\r\n );\r\n device.pool.releaseFrameBuffer(tmpFramebuffer);\r\n }\r\n }\r\n GlobalBindGroupAllocator.release(globalBindGroupAllocator);\r\n }\r\n private static renderSceneDepth(\r\n ctx: DrawContext,\r\n renderQueue: RenderQueue,\r\n depthFramebuffer: Nullable<FrameBuffer>\r\n ) {\r\n const transmission = !!depthFramebuffer;\r\n if (!depthFramebuffer) {\r\n const format: TextureFormat =\r\n ctx.device.type === 'webgl'\r\n ? ctx.SSRCalcThickness\r\n ? 'rgba16f'\r\n : 'rgba8unorm'\r\n : ctx.SSRCalcThickness\r\n ? 'rg32f'\r\n : 'r32f';\r\n const mvFormat: TextureFormat = 'rgba16f';\r\n if (!ctx.finalFramebuffer) {\r\n depthFramebuffer = ctx.device.pool.fetchTemporalFramebuffer(\r\n true,\r\n ctx.renderWidth,\r\n ctx.renderHeight,\r\n ctx.motionVectors ? [format, mvFormat] : format,\r\n ctx.depthFormat,\r\n false\r\n );\r\n } else {\r\n const originDepth = ctx.finalFramebuffer?.getDepthAttachment();\r\n depthFramebuffer = originDepth?.isTexture2D()\r\n ? ctx.device.pool.fetchTemporalFramebuffer(\r\n true,\r\n originDepth.width,\r\n originDepth.height,\r\n ctx.motionVectors ? [format, mvFormat] : format,\r\n originDepth,\r\n false\r\n )\r\n : ctx.device.pool.fetchTemporalFramebuffer(\r\n true,\r\n ctx.renderWidth,\r\n ctx.renderHeight,\r\n ctx.motionVectors ? [format, mvFormat] : format,\r\n ctx.depthFormat,\r\n false\r\n );\r\n }\r\n }\r\n ctx.device.pushDeviceStates();\r\n ctx.device.setFramebuffer(depthFramebuffer);\r\n this._depthPass.encodeDepth = depthFramebuffer.getColorAttachments()[0].format === 'rgba8unorm';\r\n this._depthPass.clearColor = transmission\r\n ? null\r\n : this._depthPass.encodeDepth\r\n ? new Vector4(0, 0, 0, 1)\r\n : new Vector4(1, 1, 1, 1);\r\n this._depthPass.clearDepth = transmission ? null : 1;\r\n this._depthPass.clearStencil = null;\r\n this._depthPass.transmission = transmission;\r\n if (ctx.SSRCalcThickness && !transmission) {\r\n if (!this._backDepthColorState) {\r\n this._backDepthColorState = ctx.device.createColorState().setColorMask(false, true, false, false);\r\n }\r\n if (!this._frontDepthColorState) {\r\n this._frontDepthColorState = ctx.device.createColorState().setColorMask(true, false, false, false);\r\n }\r\n ctx.forceColorState = this._backDepthColorState;\r\n ctx.forceCullMode = 'front';\r\n this._depthPass.renderBackface = true;\r\n this._depthPass.transmission = false;\r\n this._depthPass.render(ctx, null, null, renderQueue);\r\n this._depthPass.clearColor = null;\r\n this._depthPass.renderBackface = false;\r\n ctx.forceColorState = this._frontDepthColorState;\r\n ctx.forceCullMode = null;\r\n }\r\n this._depthPass.render(ctx, null, null, renderQueue);\r\n ctx.forceColorState = null;\r\n ctx.device.popDeviceStates();\r\n\r\n if (!transmission) {\r\n ctx.motionVectorTexture = ctx.motionVectors\r\n ? (depthFramebuffer.getColorAttachments()[1] as Texture2D)\r\n : null;\r\n ctx.linearDepthTexture = depthFramebuffer.getColorAttachments()[0] as Texture2D;\r\n ctx.depthTexture = depthFramebuffer.getDepthAttachment() as Texture2D;\r\n if (ctx.motionVectorTexture) {\r\n this.renderSkyMotionVectors(ctx);\r\n }\r\n if (ctx.HiZ) {\r\n let w = isPowerOf2(ctx.linearDepthTexture.width)\r\n ? ctx.linearDepthTexture.width\r\n : nextPowerOf2(ctx.linearDepthTexture.width);\r\n let h = isPowerOf2(ctx.linearDepthTexture.height)\r\n ? ctx.linearDepthTexture.height\r\n : nextPowerOf2(ctx.linearDepthTexture.height);\r\n w = Math.max(1, w >> 1);\r\n h = Math.max(1, h >> 1);\r\n w = ctx.linearDepthTexture.width;\r\n h = ctx.linearDepthTexture.height;\r\n const HiZFrameBuffer = ctx.device.pool.fetchTemporalFramebuffer(\r\n true,\r\n w,\r\n h,\r\n ctx.linearDepthTexture.format,\r\n null,\r\n true\r\n );\r\n buildHiZ(ctx.depthTexture, HiZFrameBuffer);\r\n ctx.HiZTexture = HiZFrameBuffer.getColorAttachments()[0] as Texture2D;\r\n }\r\n }\r\n return depthFramebuffer;\r\n }\r\n /** @internal */\r\n protected static _renderScene(ctx: DrawContext) {\r\n const device = ctx.device;\r\n\r\n // Cull scene\r\n const renderQueue = this._scenePass.cullScene(ctx, ctx.camera);\r\n\r\n // Update sky\r\n const sunLightColor = ctx.scene.env.sky.update(ctx);\r\n\r\n // Gather lights\r\n ctx.clusteredLight = this.getClusteredLight();\r\n ctx.clusteredLight.calculateLightIndex(ctx.camera, renderQueue);\r\n\r\n // Do GPU ray picking if required\r\n const pickResolveFunc = ctx.camera.getPickResultResolveFunc();\r\n if (pickResolveFunc) {\r\n this.renderObjectColors(ctx, pickResolveFunc, renderQueue);\r\n }\r\n\r\n // Render shadow maps\r\n this.renderShadowMaps(ctx, renderQueue.shadowedLights);\r\n\r\n // Render scene depth first\r\n const depthFramebuffer = this.renderSceneDepth(ctx, renderQueue, null);\r\n if (ctx.depthTexture === ctx.finalFramebuffer?.getDepthAttachment()) {\r\n ctx.intermediateFramebuffer = ctx.finalFramebuffer;\r\n } else {\r\n // TODO: fetch resizable framebuffer if ctx.defaultViewport is true\r\n ctx.intermediateFramebuffer = device.pool.fetchTemporalFramebuffer(\r\n false,\r\n ctx.depthTexture!.width,\r\n ctx.depthTexture!.height,\r\n ctx.colorFormat!,\r\n ctx.depthTexture\r\n );\r\n }\r\n if (ctx.intermediateFramebuffer && ctx.intermediateFramebuffer !== ctx.finalFramebuffer) {\r\n device.pushDeviceStates();\r\n device.setFramebuffer(ctx.intermediateFramebuffer);\r\n } else {\r\n device.setViewport(null);\r\n device.setScissor(null);\r\n }\r\n this._scenePass.transmission = false; // transmission\r\n this._scenePass.clearDepth = ctx.depthTexture ? null : 1;\r\n this._scenePass.clearStencil = ctx.depthTexture ? null : 0;\r\n if (ctx.SSR && !renderQueue.needSceneColor()) {\r\n ctx.materialFlags |= MaterialVaryingFlags.SSR_STORE_ROUGHNESS;\r\n }\r\n ctx.compositor?.begin(ctx);\r\n if (renderQueue.needSceneColor()) {\r\n const compositor = ctx.compositor;\r\n ctx.compositor = null;\r\n const sceneColorFramebuffer = device.pool.fetchTemporalFramebuffer(\r\n true,\r\n ctx.depthTexture!.width,\r\n ctx.depthTexture!.height,\r\n ctx.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS\r\n ? [\r\n ctx.colorFormat!,\r\n device.getFramebuffer()!.getColorAttachments()[1]!,\r\n device.getFramebuffer()!.getColorAttachments()[2]!\r\n ]\r\n : ctx.colorFormat!,\r\n ctx.depthTexture,\r\n false\r\n );\r\n device.pushDeviceStates();\r\n device.setFramebuffer(sceneColorFramebuffer);\r\n this._scenePass.transmission = false;\r\n this._scenePass.render(ctx, null, null, renderQueue);\r\n device.popDeviceStates();\r\n ctx.sceneColorTexture = sceneColorFramebuffer.getColorAttachments()[0] as Texture2D;\r\n new CopyBlitter().blit(\r\n ctx.sceneColorTexture,\r\n device.getFramebuffer() ?? null,\r\n fetchSampler('clamp_nearest_nomip')\r\n );\r\n this._scenePass.transmission = true;\r\n this._scenePass.clearColor = null;\r\n this._scenePass.clearDepth = null;\r\n this._scenePass.clearStencil = null;\r\n ctx.compositor = compositor;\r\n }\r\n this._scenePass.render(ctx, null, null, renderQueue);\r\n if (renderQueue.needSceneColor()) {\r\n this.renderSceneDepth(ctx, renderQueue, depthFramebuffer);\r\n }\r\n ctx.compositor?.drawPostEffects(ctx, PostEffectLayer.end, ctx.linearDepthTexture!);\r\n ctx.compositor?.end(ctx);\r\n renderQueue.dispose();\r\n ctx.materialFlags &= ~MaterialVaryingFlags.SSR_STORE_ROUGHNESS;\r\n\r\n if (ctx.intermediateFramebuffer && ctx.intermediateFramebuffer !== ctx.finalFramebuffer) {\r\n const blitter = new CopyBlitter();\r\n blitter.srgbOut = !ctx.finalFramebuffer;\r\n const srcTex = ctx.intermediateFramebuffer.getColorAttachments()[0] as Texture2D;\r\n blitter.blit(srcTex, ctx.finalFramebuffer ?? null, fetchSampler('clamp_nearest_nomip'));\r\n device.popDeviceStates();\r\n device.pool.releaseFrameBuffer(ctx.intermediateFramebuffer);\r\n }\r\n //ShadowMapper.releaseTemporalResources(ctx);\r\n this.freeClusteredLight(ctx.clusteredLight);\r\n\r\n // Restore sun color\r\n if (sunLightColor) {\r\n ctx.sunLight!.color = sunLightColor;\r\n }\r\n }\r\n private static _getSkyMotionVectorProgram(ctx: DrawContext) {\r\n if (!this._skyMotionVectorProgram) {\r\n this._skyMotionVectorProgram = ctx.device.buildRenderProgram({\r\n vertex(pb) {\r\n this.$inputs.pos = pb.vec3().attrib('position');\r\n this.VPMatrix = pb.mat4().uniform(0);\r\n this.prevVPMatrix = pb.mat4().uniform(0);\r\n this.cameraPos = pb.vec3().uniform(0);\r\n this.prevCameraPos = pb.vec3().uniform(0);\r\n pb.main(function () {\r\n this.$l.worldPos = pb.add(this.$inputs.pos, this.cameraPos);\r\n this.$l.prevWorldPos = pb.add(this.$inputs.pos, this.prevCameraPos);\r\n this.$l.clipPos = pb.mul(this.VPMatrix, pb.vec4(this.worldPos, 1));\r\n this.$l.prevClipPos = pb.mul(this.prevVPMatrix, pb.vec4(this.prevWorldPos, 1));\r\n this.clipPos.z = this.clipPos.w;\r\n this.$builtins.position = this.clipPos;\r\n this.$outputs.currentPos = this.clipPos;\r\n this.$outputs.prevPos = this.prevClipPos;\r\n });\r\n },\r\n fragment(pb) {\r\n this.$outputs.color = pb.vec4();\r\n pb.main(function () {\r\n this.$l.motionVector = pb.mul(\r\n pb.sub(\r\n pb.div(this.$inputs.currentPos.xy, this.$inputs.currentPos.w),\r\n pb.div(this.$inputs.prevPos.xy, this.$inputs.prevPos.w)\r\n ),\r\n 0.5\r\n );\r\n this.$outputs.color = pb.vec4(this.motionVector, 0, 1);\r\n });\r\n }\r\n })!;\r\n this._skyMotionVectorProgram.name = '@TAA_SkyMotionVector';\r\n }\r\n return this._skyMotionVectorProgram;\r\n }\r\n private static _getBox(_ctx: DrawContext) {\r\n if (!this._box) {\r\n this._box = new BoxShape({\r\n size: 2,\r\n needNormal: false,\r\n needUV: false\r\n });\r\n }\r\n return this._box;\r\n }\r\n /** @internal */\r\n private static renderSkyMotionVectors(ctx: DrawContext) {\r\n if (!ctx.motionVectorTexture) {\r\n return;\r\n }\r\n const fb = ctx.device.pool.fetchTemporalFramebuffer(\r\n false,\r\n 0,\r\n 0,\r\n ctx.motionVectorTexture,\r\n ctx.depthTexture\r\n );\r\n const program = this._getSkyMotionVectorProgram(ctx);\r\n if (!this._skyMotionVectorBindGroup) {\r\n this._skyMotionVectorBindGroup = ctx.device.createBindGroup(program.bindGroupLayouts[0]);\r\n }\r\n const box = this._getBox(ctx);\r\n this._skyMotionVectorBindGroup.setValue('VPMatrix', ctx.camera.viewProjectionMatrix);\r\n this._skyMotionVectorBindGroup.setValue('prevVPMatrix', ctx.camera.prevVPMatrix!);\r\n this._skyMotionVectorBindGroup.setValue('cameraPos', ctx.camera.getWorldPosition());\r\n this._skyMotionVectorBindGroup.setValue('prevCameraPos', ctx.camera.prevPosition!);\r\n ctx.device.pushDeviceStates();\r\n ctx.device.setProgram(program);\r\n ctx.device.setBindGroup(0, this._skyMotionVectorBindGroup);\r\n ctx.device.setRenderStates(AbstractPostEffect.getDefaultRenderState(ctx, 'le'));\r\n ctx.device.setFramebuffer(fb);\r\n box.draw();\r\n ctx.device.popDeviceStates();\r\n ctx.device.pool.releaseFrameBuffer(fb);\r\n }\r\n /** @internal */\r\n private static renderShadowMaps(ctx: DrawContext, lights: PunctualLight[]) {\r\n ctx.renderPass = this._shadowMapPass;\r\n ctx.device.pushDeviceStates();\r\n for (const light of lights) {\r\n light.shadow.render(ctx, this._shadowMapPass);\r\n }\r\n ctx.device.popDeviceStates();\r\n }\r\n /** @internal */\r\n private static decodeNormalizedFloat(rgba: Uint8Array<ArrayBuffer>) {\r\n const a = rgba[0] / 255;\r\n const b = rgba[1] / 255;\r\n const c = rgba[2] / 255;\r\n const d = rgba[3] / 255;\r\n return a / (256 * 256 * 256) + b / (256 * 256) + c / 256 + d;\r\n }\r\n /** @internal */\r\n private static renderObjectColors(\r\n ctx: DrawContext,\r\n pickResolveFunc: (result: Nullable<PickResult>) => void,\r\n renderQueue: RenderQueue\r\n ) {\r\n const camera = ctx.camera;\r\n const isWebGL1 = ctx.device.type === 'webgl';\r\n ctx.renderPass = this._objectColorPass;\r\n ctx.device.pushDeviceStates();\r\n const fb = ctx.device.pool.fetchTemporalFramebuffer(\r\n false,\r\n 1,\r\n 1,\r\n isWebGL1 ? ['rgba8unorm', 'rgba8unorm'] : ['rgba8unorm', 'rgba32f'],\r\n ctx.depthFormat,\r\n false\r\n );\r\n ctx.device.setViewport(camera.viewport);\r\n const vp = ctx.device.getViewport();\r\n const windowX = camera.getPickPosX() / vp.width;\r\n const windowY = (vp.height - camera.getPickPosY() - 1) / vp.height;\r\n const windowW = 1 / vp.width;\r\n const windowH = 1 / vp.height;\r\n const pickCamera = this._pickCamera;\r\n camera.worldMatrix.decompose(pickCamera.scale, pickCamera.rotation, pickCamera.position);\r\n let left = camera.getProjectionMatrix().getLeftPlane();\r\n let right = camera.getProjectionMatrix().getRightPlane();\r\n let bottom = camera.getProjectionMatrix().getBottomPlane();\r\n let top = camera.getProjectionMatrix().getTopPlane();\r\n const near = camera.getProjectionMatrix().getNearPlane();\r\n const far = camera.getProjectionMatrix().getFarPlane();\r\n const width = right - left;\r\n const height = top - bottom;\r\n left += width * windowX;\r\n bottom += height * windowY;\r\n right = left + width * windowW;\r\n top = bottom + height * windowH;\r\n pickCamera.setProjectionMatrix(\r\n camera.isPerspective()\r\n ? Matrix4x4.frustum(left, right, bottom, top, near, far)\r\n : Matrix4x4.ortho(left, right, bottom, top, near, far)\r\n );\r\n const cameraPos = isWebGL1 ? new Vector3(pickCamera.position) : null;\r\n const ray = isWebGL1 ? camera.constructRay(camera.getPickPosX(), camera.getPickPosY()) : null;\r\n ctx.device.setFramebuffer(fb);\r\n this._objectColorPass.clearColor = Vector4.zero();\r\n this._objectColorPass.clearDepth = 1;\r\n const rq = this._objectColorPass.cullScene(ctx, pickCamera);\r\n this._objectColorPass.render(ctx, pickCamera, null, rq);\r\n rq.dispose();\r\n ctx.device.popDeviceStates();\r\n const colorTex = fb.getColorAttachments()[0];\r\n const distanceTex = fb.getColorAttachments()[1];\r\n const colorPixels = new Uint8Array(4);\r\n const distancePixels = isWebGL1 ? new Uint8Array(4) : new Float32Array(4);\r\n const device = ctx.device;\r\n let fence: Promise<void[]>;\r\n if (ctx.device.type === 'webgl') {\r\n fence = Promise.all([\r\n ctx.device.runNextFrameAsync(() => colorTex.readPixels(0, 0, 1, 1, 0, 0, colorPixels)),\r\n ctx.device.runNextFrameAsync(() => distanceTex.readPixels(0, 0, 1, 1, 0, 0, distancePixels))\r\n ]);\r\n } else {\r\n fence = Promise.all([\r\n colorTex.readPixels(0, 0, 1, 1, 0, 0, colorPixels),\r\n distanceTex.readPixels(0, 0, 1, 1, 0, 0, distancePixels)\r\n ]);\r\n }\r\n fence\r\n .then(() => {\r\n const drawable = renderQueue.getDrawableByColor(colorPixels);\r\n let d = isWebGL1\r\n ? this.decodeNormalizedFloat(distancePixels as Uint8Array<ArrayBuffer>) * far\r\n : distancePixels[0];\r\n const intersectedPoint = new Vector3(distancePixels[0], distancePixels[1], distancePixels[2]);\r\n if (isWebGL1) {\r\n intersectedPoint.x = cameraPos!.x + ray!.direction.x * d;\r\n intersectedPoint.y = cameraPos!.y + ray!.direction.y * d;\r\n intersectedPoint.z = cameraPos!.z + ray!.direction.z * d;\r\n d = Vector3.distance(intersectedPoint, cameraPos!);\r\n }\r\n pickResolveFunc(\r\n drawable\r\n ? {\r\n distance: d,\r\n intersectedPoint,\r\n drawable,\r\n target: drawable.getPickTarget()\r\n }\r\n : null\r\n );\r\n device.pool.releaseFrameBuffer(fb);\r\n })\r\n .catch((_err) => {\r\n camera.getPickResultResolveFunc()?.(null);\r\n device.pool.releaseFrameBuffer(fb);\r\n });\r\n }\r\n}\r\n"],"names":["SceneRenderer","_skyMotionVectorProgram","_skyMotionVectorBindGroup","_box","_pickCamera","Camera","_scenePass","LightPass","_depthPass","DepthPass","_shadowMapPass","ShadowMapPass","_objectColorPass","ObjectColorPass","_frontDepthColorState","_backDepthColorState","_clusters","sceneRenderPass","depthRenderPass","shadowMapRenderPass","getClusteredLight","length","pop","ClusteredLight","freeClusteredLight","clusteredLight","push","renderScene","scene","camera","device","getDevice","colorFormat","HDR","getDeviceCaps","textureCaps","supportHalfFloatColorBuffer","depthFormat","framebufferCaps","supportDepth32floatStencil8","globalBindGroupAllocator","GlobalBindGroupAllocator","get","frameUpdate","frameUpdatePerCamera","isContextLost","defaultViewport","viewport","scissor","renderX","screenXToDevice","renderY","screenYToDevice","renderWidth","getDrawingBufferWidth","renderHeight","getDrawingBufferHeight","getPickResultResolveFunc","tmpFramebuffer","pool","fetchTemporalFramebuffer","originFramebuffer","getFramebuffer","pushDeviceStates","setFramebuffer","clearFrameBuffer","clearColor","clearDepth","clearStencil","SSR","env","light","envLight","hasRadiance","ctx","oit","motionVectors","type","TAA","motionBlur","HiZ","HiZTexture","compositor","queue","lightBlending","renderPass","renderPassHash","flip","drawEnvLight","materialFlags","SSRCalcThickness","ssrCalcThickness","SSRRoughnessTexture","fetchTemporalTexture2D","SSRNormalTexture","finalFramebuffer","intermediateFramebuffer","_renderScene","popDeviceStates","oversizedViewport","blitter","CopyBlitter","destRect","slice","srgbOut","blit","getColorAttachments","fetchSampler","releaseFrameBuffer","release","renderSceneDepth","renderQueue","depthFramebuffer","transmission","format","mvFormat","originDepth","getDepthAttachment","isTexture2D","width","height","encodeDepth","Vector4","createColorState","setColorMask","forceColorState","forceCullMode","renderBackface","render","motionVectorTexture","linearDepthTexture","depthTexture","renderSkyMotionVectors","w","isPowerOf2","nextPowerOf2","h","Math","max","HiZFrameBuffer","buildHiZ","cullScene","sunLightColor","sky","update","calculateLightIndex","pickResolveFunc","renderObjectColors","renderShadowMaps","shadowedLights","setViewport","setScissor","needSceneColor","MaterialVaryingFlags","SSR_STORE_ROUGHNESS","begin","sceneColorFramebuffer","sceneColorTexture","drawPostEffects","PostEffectLayer","end","dispose","srcTex","sunLight","color","_getSkyMotionVectorProgram","buildRenderProgram","vertex","pb","$inputs","pos","vec3","attrib","VPMatrix","mat4","uniform","prevVPMatrix","cameraPos","prevCameraPos","main","$l","worldPos","add","prevWorldPos","clipPos","mul","vec4","prevClipPos","z","$builtins","position","$outputs","currentPos","prevPos","fragment","motionVector","sub","div","xy","name","_getBox","_ctx","BoxShape","size","needNormal","needUV","fb","program","createBindGroup","bindGroupLayouts","box","setValue","viewProjectionMatrix","getWorldPosition","prevPosition","setProgram","setBindGroup","setRenderStates","AbstractPostEffect","getDefaultRenderState","draw","lights","shadow","decodeNormalizedFloat","rgba","a","b","c","d","isWebGL1","vp","getViewport","windowX","getPickPosX","windowY","getPickPosY","windowW","windowH","pickCamera","worldMatrix","decompose","scale","rotation","left","getProjectionMatrix","getLeftPlane","right","getRightPlane","bottom","getBottomPlane","top","getTopPlane","near","getNearPlane","far","getFarPlane","setProjectionMatrix","isPerspective","Matrix4x4","frustum","ortho","Vector3","ray","constructRay","zero","rq","colorTex","distanceTex","colorPixels","Uint8Array","distancePixels","Float32Array","fence","Promise","all","runNextFrameAsync","readPixels","then","drawable","getDrawableByColor","intersectedPoint","x","direction","y","distance","target","getPickTarget","catch","_err"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6BA;;;AAGC,IACM,MAAMA,aAAAA,CAAAA;qBAEX,OAAeC,uBAAAA,GAAgD,IAAK;qBAEpE,OAAeC,yBAAAA,GAAiD,IAAK;AACrE,IAAA,OAAeC,OAA4B,IAAK;AAChD,qBACA,OAAwBC,WAAc,GAAA,IAAIC,OAAO,IAAM,CAAA;AACvD,qBACA,OAAwBC,UAAa,GAAA,IAAIC,SAAY,EAAA;AACrD,qBACA,OAAwBC,UAAa,GAAA,IAAIC,SAAY,EAAA;AACrD,qBACA,OAAwBC,cAAiB,GAAA,IAAIC,aAAgB,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AA,IAAA,CAAA;YACpC3B,MAAO6B,CAAAA,IAAI,CAACiD,kBAAkB,CAACkG,EAAAA,CAAAA;AACjC,SAAA,CAAA;AACJ;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"renderer.js","sources":["../../src/render/renderer.ts"],"sourcesContent":["import { CopyBlitter } from '../blitter';\r\nimport type { DrawContext } from './drawable';\r\nimport type { Scene } from '../scene';\r\nimport type { Camera } from '../camera';\r\nimport { GlobalBindGroupAllocator } from './globalbindgroup_allocator';\r\nimport { fetchSampler } from '../utility/misc';\r\nimport { getDevice } from '../app/api';\r\nimport { executeForwardPlusGraph } from './rendergraph/forward_plus_builder';\r\n\r\n/**\r\n * Forward render scheme\r\n * @internal\r\n */\r\nexport class SceneRenderer {\r\n /**\r\n * Renders a scene by given camera\r\n * @param scene - The scene to render\r\n * @param camera - The camera that will be used to render the scene\r\n */\r\n static renderScene(scene: Scene, camera: Camera): void {\r\n const device = getDevice();\r\n const colorFormat =\r\n camera.HDR && device.getDeviceCaps().textureCaps.supportHalfFloatColorBuffer ? 'rgba16f' : 'rgba8unorm';\r\n const depthFormat = device.getDeviceCaps().framebufferCaps.supportDepth32floatStencil8\r\n ? 'd32fs8'\r\n : 'd24s8';\r\n const globalBindGroupAllocator = GlobalBindGroupAllocator.get();\r\n scene.frameUpdate();\r\n scene.frameUpdatePerCamera(camera);\r\n if (camera && !device.isContextLost()) {\r\n const defaultViewport = (!camera.TAA || device.type === 'webgl') && !camera.viewport && !camera.scissor;\r\n const renderX = camera.viewport ? device.screenXToDevice(camera.viewport[0]) : 0;\r\n const renderY = camera.viewport ? device.screenYToDevice(camera.viewport[1]) : 0;\r\n const renderWidth = camera.viewport\r\n ? device.screenXToDevice(camera.viewport[2])\r\n : device.getDrawingBufferWidth();\r\n const renderHeight = camera.viewport\r\n ? device.screenYToDevice(camera.viewport[3])\r\n : device.getDrawingBufferHeight();\r\n if (renderWidth <= 0 || renderHeight <= 0) {\r\n camera.getPickResultResolveFunc()?.(null);\r\n return;\r\n }\r\n const tmpFramebuffer = defaultViewport\r\n ? null\r\n : device.pool.fetchTemporalFramebuffer(false, renderWidth, renderHeight, colorFormat, depthFormat);\r\n const originFramebuffer = device.getFramebuffer();\r\n if (tmpFramebuffer) {\r\n device.pushDeviceStates();\r\n device.setFramebuffer(tmpFramebuffer);\r\n }\r\n device.clearFrameBuffer(camera.clearColor, camera.clearDepth, camera.clearStencil);\r\n const SSR = camera.SSR && scene.env.light.envLight && scene.env.light.envLight.hasRadiance();\r\n const ctx: DrawContext = {\r\n device,\r\n scene,\r\n renderWidth,\r\n renderHeight,\r\n oit: null,\r\n motionVectors: device.type !== 'webgl' && (camera.TAA || camera.motionBlur),\r\n HiZ: camera.HiZ && device.type !== 'webgl',\r\n HiZTexture: null,\r\n globalBindGroupAllocator,\r\n camera,\r\n compositor: camera.compositor,\r\n queue: 0,\r\n lightBlending: false,\r\n renderPass: null,\r\n renderPassHash: null,\r\n flip: false,\r\n depthFormat,\r\n colorFormat,\r\n drawEnvLight: false,\r\n env: null,\r\n materialFlags: 0,\r\n SSR,\r\n SSRCalcThickness: SSR && camera.ssrCalcThickness,\r\n SSRRoughnessTexture: device.pool.fetchTemporalTexture2D(\r\n true,\r\n 'rgba8unorm',\r\n renderWidth,\r\n renderHeight\r\n ),\r\n SSRNormalTexture: device.pool.fetchTemporalTexture2D(true, 'rgba8unorm', renderWidth, renderHeight),\r\n finalFramebuffer: device.getFramebuffer(),\r\n intermediateFramebuffer: null\r\n };\r\n this._renderScene(ctx);\r\n if (tmpFramebuffer) {\r\n device.popDeviceStates();\r\n const oversizedViewport =\r\n renderX < 0 ||\r\n renderY < 0 ||\r\n renderX + renderWidth > device.getDrawingBufferWidth() ||\r\n renderY + renderHeight > device.getDrawingBufferHeight();\r\n const blitter = new CopyBlitter();\r\n if (oversizedViewport) {\r\n blitter.destRect = [renderX, renderY, renderWidth, renderHeight];\r\n } else {\r\n blitter.viewport = camera.viewport ? camera.viewport.slice() : null;\r\n }\r\n blitter.scissor = camera.scissor ? camera.scissor.slice() : null;\r\n blitter.srgbOut = !originFramebuffer;\r\n blitter.blit(\r\n tmpFramebuffer.getColorAttachments()[0],\r\n originFramebuffer ?? null,\r\n fetchSampler('clamp_nearest_nomip')\r\n );\r\n device.pool.releaseFrameBuffer(tmpFramebuffer);\r\n }\r\n }\r\n GlobalBindGroupAllocator.release(globalBindGroupAllocator);\r\n }\r\n /** @internal */\r\n protected static _renderScene(ctx: DrawContext) {\r\n executeForwardPlusGraph(ctx);\r\n }\r\n}\r\n"],"names":["SceneRenderer","renderScene","scene","camera","device","getDevice","colorFormat","HDR","getDeviceCaps","textureCaps","supportHalfFloatColorBuffer","depthFormat","framebufferCaps","supportDepth32floatStencil8","globalBindGroupAllocator","GlobalBindGroupAllocator","get","frameUpdate","frameUpdatePerCamera","isContextLost","defaultViewport","TAA","type","viewport","scissor","renderX","screenXToDevice","renderY","screenYToDevice","renderWidth","getDrawingBufferWidth","renderHeight","getDrawingBufferHeight","getPickResultResolveFunc","tmpFramebuffer","pool","fetchTemporalFramebuffer","originFramebuffer","getFramebuffer","pushDeviceStates","setFramebuffer","clearFrameBuffer","clearColor","clearDepth","clearStencil","SSR","env","light","envLight","hasRadiance","ctx","oit","motionVectors","motionBlur","HiZ","HiZTexture","compositor","queue","lightBlending","renderPass","renderPassHash","flip","drawEnvLight","materialFlags","SSRCalcThickness","ssrCalcThickness","SSRRoughnessTexture","fetchTemporalTexture2D","SSRNormalTexture","finalFramebuffer","intermediateFramebuffer","_renderScene","popDeviceStates","oversizedViewport","blitter","CopyBlitter","destRect","slice","srgbOut","blit","getColorAttachments","fetchSampler","releaseFrameBuffer","release","executeForwardPlusGraph"],"mappings":";;;;;;;;;AASA;;;AAGC,IACM,MAAMA,aAAAA,CAAAA;AACX;;;;AAIC,MACD,OAAOC,WAAAA,CAAYC,KAAY,EAAEC,MAAc,EAAQ;AACrD,QAAA,MAAMC,MAASC,GAAAA,SAAAA,EAAAA;QACf,MAAMC,WAAAA,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AA,OAAAA;AAASE,wBAAAA,WAAAA;AAAaE,wBAAAA;AAAa,qBAAA;iBAC3D,MAAA;oBACL2C,OAAQnD,CAAAA,QAAQ,GAAGpB,MAAOoB,CAAAA,QAAQ,GAAGpB,MAAOoB,CAAAA,QAAQ,CAACsD,KAAK,EAAK,GAAA,IAAA;AACjE;gBACAH,OAAQlD,CAAAA,OAAO,GAAGrB,MAAOqB,CAAAA,OAAO,GAAGrB,MAAOqB,CAAAA,OAAO,CAACqD,KAAK,EAAK,GAAA,IAAA;gBAC5DH,OAAQI,CAAAA,OAAO,GAAG,CAACzC,iBAAAA;gBACnBqC,OAAQK,CAAAA,IAAI,CACV7C,cAAAA,CAAe8C,mBAAmB,EAAE,CAAC,CAAE,CAAA,EACvC3C,iBAAqB,IAAA,IAAA,EACrB4C,YAAa,CAAA,qBAAA,CAAA,CAAA;gBAEf7E,MAAO+B,CAAAA,IAAI,CAAC+C,kBAAkB,CAAChD,cAAAA,CAAAA;AACjC;AACF;AACAnB,QAAAA,wBAAAA,CAAyBoE,OAAO,CAACrE,wBAAAA,CAAAA;AACnC;AACA,qBACA,OAAiByD,YAAarB,CAAAA,GAAgB,EAAE;QAC9CkC,uBAAwBlC,CAAAA,GAAAA,CAAAA;AAC1B;AACF;;;;"}
|
|
@@ -77,18 +77,21 @@
|
|
|
77
77
|
this._allocatedTextures.set(resId, texture);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
// Execute the pass
|
|
81
|
-
|
|
82
|
-
pass.executeFn
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this.
|
|
91
|
-
|
|
80
|
+
// Execute the pass with exception safety for resource cleanup
|
|
81
|
+
try {
|
|
82
|
+
if (pass.executeFn) {
|
|
83
|
+
pass.executeFn(ctx, pass.data);
|
|
84
|
+
}
|
|
85
|
+
} finally{
|
|
86
|
+
// Release resources that end at this pass (always runs even if pass throws)
|
|
87
|
+
const toRelease = releaseAt.get(i);
|
|
88
|
+
if (toRelease) {
|
|
89
|
+
for (const resId of toRelease){
|
|
90
|
+
const texture = this._allocatedTextures.get(resId);
|
|
91
|
+
if (texture !== undefined) {
|
|
92
|
+
this._allocator.release(texture);
|
|
93
|
+
this._allocatedTextures.delete(resId);
|
|
94
|
+
}
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sources":["../../../src/render/rendergraph/executor.ts"],"sourcesContent":["import type {\r\n CompiledRenderGraph,\r\n RGTextureAllocator,\r\n RGTextureDesc,\r\n RGResolvedSize,\r\n RGExecuteContext,\r\n RGExecuteFn\r\n} from './types';\r\nimport type { RGHandle } from './types';\r\n\r\n/**\r\n * Executes a compiled render graph with automatic resource lifecycle management.\r\n *\r\n * The executor allocates transient textures before their first use and releases\r\n * them after their last use, using the provided {@link RGTextureAllocator}.\r\n *\r\n * Usage:\r\n * ```ts\r\n * const executor = new RenderGraphExecutor(myAllocator, backbufferWidth, backbufferHeight);\r\n * executor.setImportedTexture(backbufferHandle, actualBackbufferTexture);\r\n * executor.execute(compiledGraph);\r\n * ```\r\n *\r\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\r\n * @public\r\n */\r\nexport class RenderGraphExecutor<TTexture = unknown> {\r\n /** @internal */\r\n private _allocator: RGTextureAllocator<TTexture>;\r\n /** @internal */\r\n private _backbufferWidth: number;\r\n /** @internal */\r\n private _backbufferHeight: number;\r\n /** @internal */\r\n private _importedTextures: Map<number, TTexture> = new Map();\r\n /** @internal */\r\n private _allocatedTextures: Map<number, TTexture> = new Map();\r\n\r\n constructor(allocator: RGTextureAllocator<TTexture>, backbufferWidth: number, backbufferHeight: number) {\r\n this._allocator = allocator;\r\n this._backbufferWidth = backbufferWidth;\r\n this._backbufferHeight = backbufferHeight;\r\n }\r\n\r\n /**\r\n * Update the backbuffer dimensions used for 'backbuffer-relative' sizing.\r\n */\r\n setBackbufferSize(width: number, height: number): void {\r\n this._backbufferWidth = width;\r\n this._backbufferHeight = height;\r\n }\r\n\r\n /**\r\n * Register an imported (external) texture so it can be resolved during execution.\r\n *\r\n * @param handle - The handle returned from {@link RenderGraph.importTexture}.\r\n * @param texture - The actual GPU texture object.\r\n */\r\n setImportedTexture(handle: RGHandle, texture: TTexture): void {\r\n this._importedTextures.set(handle._id, texture);\r\n }\r\n\r\n /**\r\n * Execute the compiled graph with full resource lifecycle management.\r\n *\r\n * For each pass in topological order:\r\n * 1. Allocate any transient resources whose lifetime begins at this pass\r\n * 2. Invoke the pass's execute callback with a context that resolves handles\r\n * 3. Release any transient resources whose lifetime ends at this pass\r\n *\r\n * @param compiled - The compiled graph from {@link RenderGraph.compile}.\r\n */\r\n execute(compiled: CompiledRenderGraph): void {\r\n // Build per-pass allocation and release schedules\r\n const allocateAt = new Map<number, number[]>(); // passIndex -> resourceIds to allocate\r\n const releaseAt = new Map<number, number[]>(); // passIndex -> resourceIds to release\r\n\r\n for (const [resId, lifetime] of compiled.lifetimes) {\r\n if (lifetime.resource.kind === 'transient') {\r\n if (!allocateAt.has(lifetime.firstUse)) {\r\n allocateAt.set(lifetime.firstUse, []);\r\n }\r\n allocateAt.get(lifetime.firstUse)!.push(resId);\r\n\r\n if (!releaseAt.has(lifetime.lastUse)) {\r\n releaseAt.set(lifetime.lastUse, []);\r\n }\r\n releaseAt.get(lifetime.lastUse)!.push(resId);\r\n }\r\n }\r\n\r\n const ctx = this._createContext();\r\n\r\n for (let i = 0; i < compiled.orderedPasses.length; i++) {\r\n const pass = compiled.orderedPasses[i];\r\n\r\n // Allocate resources that start at this pass\r\n const toAllocate = allocateAt.get(i);\r\n if (toAllocate) {\r\n for (const resId of toAllocate) {\r\n const lifetime = compiled.lifetimes.get(resId)!;\r\n const desc = lifetime.resource.desc!;\r\n const size = this._resolveSize(desc);\r\n const texture = this._allocator.allocate(desc, size);\r\n this._allocatedTextures.set(resId, texture);\r\n }\r\n }\r\n\r\n // Execute the pass\r\n if (pass.executeFn) {\r\n (pass.executeFn as RGExecuteFn<unknown>)(ctx, pass.data);\r\n }\r\n\r\n // Release resources that end at this pass\r\n const toRelease = releaseAt.get(i);\r\n if (toRelease) {\r\n for (const resId of toRelease) {\r\n const texture = this._allocatedTextures.get(resId);\r\n if (texture !== undefined) {\r\n this._allocator.release(texture);\r\n this._allocatedTextures.delete(resId);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clear imported texture registrations and any leftover allocated textures.\r\n * Call this after execution or when resetting for a new frame.\r\n */\r\n reset(): void {\r\n // Release any textures that weren't released (shouldn't happen in normal flow)\r\n for (const texture of this._allocatedTextures.values()) {\r\n this._allocator.release(texture);\r\n }\r\n this._allocatedTextures.clear();\r\n this._importedTextures.clear();\r\n }\r\n\r\n // ─── Private ────────────────────────────────────────────────────────\r\n\r\n /** @internal */\r\n private _resolveSize(desc: RGTextureDesc): RGResolvedSize {\r\n const mode = desc.sizeMode ?? 'backbuffer-relative';\r\n if (mode === 'absolute') {\r\n return {\r\n width: desc.width ?? 1,\r\n height: desc.height ?? 1\r\n };\r\n }\r\n // backbuffer-relative: width/height are scale factors (default 1.0)\r\n const scaleX = desc.width ?? 1.0;\r\n const scaleY = desc.height ?? 1.0;\r\n return {\r\n width: Math.max(1, Math.floor(this._backbufferWidth * scaleX)),\r\n height: Math.max(1, Math.floor(this._backbufferHeight * scaleY))\r\n };\r\n }\r\n\r\n /** @internal */\r\n private _createContext(): RGExecuteContext {\r\n const self = this;\r\n return {\r\n getTexture<T>(handle: RGHandle): T {\r\n // Check imported first\r\n const imported = self._importedTextures.get(handle._id);\r\n if (imported !== undefined) {\r\n return imported as unknown as T;\r\n }\r\n // Check allocated transient\r\n const allocated = self._allocatedTextures.get(handle._id);\r\n if (allocated !== undefined) {\r\n return allocated as unknown as T;\r\n }\r\n throw new Error(\r\n `RenderGraphExecutor: cannot resolve resource \"${handle.name}\" (id=${handle._id}). ` +\r\n `It may not have been allocated yet or was already released.`\r\n );\r\n }\r\n };\r\n }\r\n}\r\n"],"names":["RenderGraphExecutor","_importedTextures","Map","_allocatedTextures","allocator","backbufferWidth","backbufferHeight","_allocator","_backbufferWidth","_backbufferHeight","setBackbufferSize","width","height","setImportedTexture","handle","texture","set","_id","execute","compiled","allocateAt","releaseAt","resId","lifetime","lifetimes","resource","kind","has","firstUse","get","push","lastUse","ctx","_createContext","i","orderedPasses","length","pass","toAllocate","desc","size","_resolveSize","allocate","executeFn","data","toRelease","undefined","release","delete","reset","values","clear","mode","sizeMode","scaleX","scaleY","Math","max","floor","self","getTexture","imported","allocated","Error","name"],"mappings":"AAUA;;;;;;;;;;;;;;;AAeC,IACM,MAAMA,mBAAAA,CAAAA;qBAEX,UAAiD;qBAEjD,gBAAiC;qBAEjC,iBAAkC;AAClC,qBACQC,iBAA2C,GAAA,IAAIC,GAAM,EAAA;AAC7D,qBACQC,kBAA4C,GAAA,IAAID,GAAM,EAAA;AAE9D,IAAA,WAAA,CAAYE,SAAuC,EAAEC,eAAuB,EAAEC,gBAAwB,CAAE;QACtG,IAAI,CAACC,UAAU,GAAGH,SAAAA;QAClB,IAAI,CAACI,gBAAgB,GAAGH,eAAAA;QACxB,IAAI,CAACI,iBAAiB,GAAGH,gBAAAA;AAC3B;AAEA;;AAEC,MACDI,iBAAkBC,CAAAA,KAAa,EAAEC,MAAc,EAAQ;QACrD,IAAI,CAACJ,gBAAgB,GAAGG,KAAAA;QACxB,IAAI,CAACF,iBAAiB,GAAGG,MAAAA;AAC3B;AAEA;;;;;AAKC,MACDC,kBAAmBC,CAAAA,MAAgB,EAAEC,OAAiB,EAAQ;AAC5D,QAAA,IAAI,CAACd,iBAAiB,CAACe,GAAG,CAACF,MAAAA,CAAOG,GAAG,EAAEF,OAAAA,CAAAA;AACzC;AAEA;;;;;;;;;MAUAG,OAAAA,CAAQC,QAA6B,EAAQ;;QAE3C,MAAMC,UAAAA,GAAa,IAAIlB,GAAAA,EAAAA,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AAAA,CAAOG,GAAG,CAAC,GAAG,CAAC,GAClF,CAAC,2DAA2D,CAAC,CAAA;AAEnE;AACF,SAAA;AACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"executor.js","sources":["../../../src/render/rendergraph/executor.ts"],"sourcesContent":["import type {\r\n CompiledRenderGraph,\r\n RGTextureAllocator,\r\n RGTextureDesc,\r\n RGResolvedSize,\r\n RGExecuteContext,\r\n RGExecuteFn\r\n} from './types';\r\nimport type { RGHandle } from './types';\r\n\r\n/**\r\n * Executes a compiled render graph with automatic resource lifecycle management.\r\n *\r\n * The executor allocates transient textures before their first use and releases\r\n * them after their last use, using the provided {@link RGTextureAllocator}.\r\n *\r\n * Usage:\r\n * ```ts\r\n * const executor = new RenderGraphExecutor(myAllocator, backbufferWidth, backbufferHeight);\r\n * executor.setImportedTexture(backbufferHandle, actualBackbufferTexture);\r\n * executor.execute(compiledGraph);\r\n * ```\r\n *\r\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\r\n * @public\r\n */\r\nexport class RenderGraphExecutor<TTexture = unknown> {\r\n /** @internal */\r\n private _allocator: RGTextureAllocator<TTexture>;\r\n /** @internal */\r\n private _backbufferWidth: number;\r\n /** @internal */\r\n private _backbufferHeight: number;\r\n /** @internal */\r\n private _importedTextures: Map<number, TTexture> = new Map();\r\n /** @internal */\r\n private _allocatedTextures: Map<number, TTexture> = new Map();\r\n\r\n constructor(allocator: RGTextureAllocator<TTexture>, backbufferWidth: number, backbufferHeight: number) {\r\n this._allocator = allocator;\r\n this._backbufferWidth = backbufferWidth;\r\n this._backbufferHeight = backbufferHeight;\r\n }\r\n\r\n /**\r\n * Update the backbuffer dimensions used for 'backbuffer-relative' sizing.\r\n */\r\n setBackbufferSize(width: number, height: number): void {\r\n this._backbufferWidth = width;\r\n this._backbufferHeight = height;\r\n }\r\n\r\n /**\r\n * Register an imported (external) texture so it can be resolved during execution.\r\n *\r\n * @param handle - The handle returned from {@link RenderGraph.importTexture}.\r\n * @param texture - The actual GPU texture object.\r\n */\r\n setImportedTexture(handle: RGHandle, texture: TTexture): void {\r\n this._importedTextures.set(handle._id, texture);\r\n }\r\n\r\n /**\r\n * Execute the compiled graph with full resource lifecycle management.\r\n *\r\n * For each pass in topological order:\r\n * 1. Allocate any transient resources whose lifetime begins at this pass\r\n * 2. Invoke the pass's execute callback with a context that resolves handles\r\n * 3. Release any transient resources whose lifetime ends at this pass\r\n *\r\n * @param compiled - The compiled graph from {@link RenderGraph.compile}.\r\n */\r\n execute(compiled: CompiledRenderGraph): void {\r\n // Build per-pass allocation and release schedules\r\n const allocateAt = new Map<number, number[]>(); // passIndex -> resourceIds to allocate\r\n const releaseAt = new Map<number, number[]>(); // passIndex -> resourceIds to release\r\n\r\n for (const [resId, lifetime] of compiled.lifetimes) {\r\n if (lifetime.resource.kind === 'transient') {\r\n if (!allocateAt.has(lifetime.firstUse)) {\r\n allocateAt.set(lifetime.firstUse, []);\r\n }\r\n allocateAt.get(lifetime.firstUse)!.push(resId);\r\n\r\n if (!releaseAt.has(lifetime.lastUse)) {\r\n releaseAt.set(lifetime.lastUse, []);\r\n }\r\n releaseAt.get(lifetime.lastUse)!.push(resId);\r\n }\r\n }\r\n\r\n const ctx = this._createContext();\r\n\r\n for (let i = 0; i < compiled.orderedPasses.length; i++) {\r\n const pass = compiled.orderedPasses[i];\r\n\r\n // Allocate resources that start at this pass\r\n const toAllocate = allocateAt.get(i);\r\n if (toAllocate) {\r\n for (const resId of toAllocate) {\r\n const lifetime = compiled.lifetimes.get(resId)!;\r\n const desc = lifetime.resource.desc!;\r\n const size = this._resolveSize(desc);\r\n const texture = this._allocator.allocate(desc, size);\r\n this._allocatedTextures.set(resId, texture);\r\n }\r\n }\r\n\r\n // Execute the pass with exception safety for resource cleanup\r\n try {\r\n if (pass.executeFn) {\r\n (pass.executeFn as RGExecuteFn<unknown>)(ctx, pass.data);\r\n }\r\n } finally {\r\n // Release resources that end at this pass (always runs even if pass throws)\r\n const toRelease = releaseAt.get(i);\r\n if (toRelease) {\r\n for (const resId of toRelease) {\r\n const texture = this._allocatedTextures.get(resId);\r\n if (texture !== undefined) {\r\n this._allocator.release(texture);\r\n this._allocatedTextures.delete(resId);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clear imported texture registrations and any leftover allocated textures.\r\n * Call this after execution or when resetting for a new frame.\r\n */\r\n reset(): void {\r\n // Release any textures that weren't released (shouldn't happen in normal flow)\r\n for (const texture of this._allocatedTextures.values()) {\r\n this._allocator.release(texture);\r\n }\r\n this._allocatedTextures.clear();\r\n this._importedTextures.clear();\r\n }\r\n\r\n // ─── Private ────────────────────────────────────────────────────────\r\n\r\n /** @internal */\r\n private _resolveSize(desc: RGTextureDesc): RGResolvedSize {\r\n const mode = desc.sizeMode ?? 'backbuffer-relative';\r\n if (mode === 'absolute') {\r\n return {\r\n width: desc.width ?? 1,\r\n height: desc.height ?? 1\r\n };\r\n }\r\n // backbuffer-relative: width/height are scale factors (default 1.0)\r\n const scaleX = desc.width ?? 1.0;\r\n const scaleY = desc.height ?? 1.0;\r\n return {\r\n width: Math.max(1, Math.floor(this._backbufferWidth * scaleX)),\r\n height: Math.max(1, Math.floor(this._backbufferHeight * scaleY))\r\n };\r\n }\r\n\r\n /** @internal */\r\n private _createContext(): RGExecuteContext {\r\n const self = this;\r\n return {\r\n getTexture<T>(handle: RGHandle): T {\r\n // Check imported first\r\n const imported = self._importedTextures.get(handle._id);\r\n if (imported !== undefined) {\r\n return imported as unknown as T;\r\n }\r\n // Check allocated transient\r\n const allocated = self._allocatedTextures.get(handle._id);\r\n if (allocated !== undefined) {\r\n return allocated as unknown as T;\r\n }\r\n throw new Error(\r\n `RenderGraphExecutor: cannot resolve resource \"${handle.name}\" (id=${handle._id}). ` +\r\n `It may not have been allocated yet or was already released.`\r\n );\r\n }\r\n };\r\n }\r\n}\r\n"],"names":["RenderGraphExecutor","_importedTextures","Map","_allocatedTextures","allocator","backbufferWidth","backbufferHeight","_allocator","_backbufferWidth","_backbufferHeight","setBackbufferSize","width","height","setImportedTexture","handle","texture","set","_id","execute","compiled","allocateAt","releaseAt","resId","lifetime","lifetimes","resource","kind","has","firstUse","get","push","lastUse","ctx","_createContext","i","orderedPasses","length","pass","toAllocate","desc","size","_resolveSize","allocate","executeFn","data","toRelease","undefined","release","delete","reset","values","clear","mode","sizeMode","scaleX","scaleY","Math","max","floor","self","getTexture","imported","allocated","Error","name"],"mappings":"AAUA;;;;;;;;;;;;;;;AAeC,IACM,MAAMA,mBAAAA,CAAAA;qBAEX,UAAiD;qBAEjD,gBAAiC;qBAEjC,iBAAkC;AAClC,qBACQC,iBAA2C,GAAA,IAAIC,GAAM,EAAA;AAC7D,qBACQC,kBAA4C,GAAA,IAAID,GAAM,EAAA;AAE9D,IAAA,WAAA,CAAYE,SAAuC,EAAEC,eAAuB,EAAEC,gBAAwB,CAAE;QACtG,IAAI,CAACC,UAAU,GAAGH,SAAAA;QAClB,IAAI,CAACI,gBAAgB,GAAGH,eAAAA;QACxB,IAAI,CAACI,iBAAiB,GAAGH,gBAAAA;AAC3B;AAEA;;AAEC,MACDI,iBAAkBC,CAAAA,KAAa,EAAEC,MAAc,EAAQ;QACrD,IAAI,CAACJ,gBAAgB,GAAGG,KAAAA;QACxB,IAAI,CAACF,iBAAiB,GAAGG,MAAAA;AAC3B;AAEA;;;;;AAKC,MACDC,kBAAmBC,CAAAA,MAAgB,EAAEC,OAAiB,EAAQ;AAC5D,QAAA,IAAI,CAACd,iBAAiB,CAACe,GAAG,CAACF,MAAAA,CAAOG,GAAG,EAAEF,OAAAA,CAAAA;AACzC;AAEA;;;;;;;;;MAUAG,OAAAA,CAAQC,QAA6B,EAAQ;;QAE3C,MAAMC,UAAAA,GAAa,IAAIlB,GAAAA,EAAAA,CAAAA;QACvB,MAAMmB,SAAAA,GAAY,IAAInB,GAAAA,EAAAA,CAAAA;AAEtB,QAAA,KAAK,MAAM,CAACoB,KAAAA,EAAOC,SAAS,IAAIJ,QAAAA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"}
|
|
@@ -11,8 +11,12 @@ import { fetchSampler } from '../../utility/misc.js';
|
|
|
11
11
|
import { MaterialVaryingFlags } from '../../values.js';
|
|
12
12
|
import { AbstractPostEffect, PostEffectLayer } from '../../posteffect/posteffect.js';
|
|
13
13
|
import { RenderGraph } from './rendergraph.js';
|
|
14
|
+
import { RenderGraphExecutor } from './executor.js';
|
|
15
|
+
import { DevicePoolAllocator } from './device_pool_allocator.js';
|
|
16
|
+
import { HistoryResourceManager } from './history_resource_manager.js';
|
|
14
17
|
import { renderObjectColors } from '../gpu_picking.js';
|
|
15
18
|
import { BoxShape } from '../../shapes/box.js';
|
|
19
|
+
import '../../shapes/capsule.js';
|
|
16
20
|
import '../../shapes/cylinder.js';
|
|
17
21
|
import '../../shapes/torus.js';
|
|
18
22
|
import '../../shapes/plane.js';
|
|
@@ -24,6 +28,7 @@ const _scenePass = new LightPass();
|
|
|
24
28
|
const _depthPass = new DepthPass();
|
|
25
29
|
const _shadowMapPass = new ShadowMapPass();
|
|
26
30
|
const _clusters = [];
|
|
31
|
+
const _devicePoolAllocator = new DevicePoolAllocator();
|
|
27
32
|
let _backDepthColorState = null;
|
|
28
33
|
let _frontDepthColorState = null;
|
|
29
34
|
function getClusteredLight() {
|
|
@@ -32,9 +37,9 @@ function getClusteredLight() {
|
|
|
32
37
|
function freeClusteredLight(cl) {
|
|
33
38
|
_clusters.push(cl);
|
|
34
39
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Derive pipeline options from the current scene/camera state.
|
|
37
|
-
* @internal
|
|
40
|
+
/**
|
|
41
|
+
* Derive pipeline options from the current scene/camera state.
|
|
42
|
+
* @internal
|
|
38
43
|
*/ function deriveForwardPlusOptions(scene, camera, deviceType, renderQueue) {
|
|
39
44
|
const ssr = camera.SSR && scene.env.light.envLight && scene.env.light.envLight.hasRadiance();
|
|
40
45
|
return {
|
|
@@ -48,22 +53,21 @@ function freeClusteredLight(cl) {
|
|
|
48
53
|
};
|
|
49
54
|
}
|
|
50
55
|
// ─── Forward+ Graph Builder ─────────────────────────────────────────
|
|
51
|
-
/**
|
|
52
|
-
* Constructs a render graph representing the forward+ pipeline.
|
|
53
|
-
*
|
|
54
|
-
* Each step in the existing `SceneRenderer._renderScene` becomes a graph pass.
|
|
55
|
-
* Execute callbacks delegate to the existing rendering code, sharing a mutable
|
|
56
|
-
* {@link FrameState}.
|
|
57
|
-
*
|
|
58
|
-
* @param graph - The render graph to populate.
|
|
59
|
-
* @param ctx - The draw context for this frame.
|
|
60
|
-
* @param renderQueue - The culled render queue.
|
|
61
|
-
* @param options - Pipeline feature toggles.
|
|
62
|
-
* @returns The backbuffer handle (graph output).
|
|
63
|
-
*
|
|
64
|
-
* @public
|
|
56
|
+
/**
|
|
57
|
+
* Constructs a render graph representing the forward+ pipeline.
|
|
58
|
+
*
|
|
59
|
+
* Each step in the existing `SceneRenderer._renderScene` becomes a graph pass.
|
|
60
|
+
* Execute callbacks delegate to the existing rendering code, sharing a mutable
|
|
61
|
+
* {@link FrameState}.
|
|
62
|
+
*
|
|
63
|
+
* @param graph - The render graph to populate.
|
|
64
|
+
* @param ctx - The draw context for this frame.
|
|
65
|
+
* @param renderQueue - The culled render queue.
|
|
66
|
+
* @param options - Pipeline feature toggles.
|
|
67
|
+
* @returns The backbuffer handle (graph output).
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
65
70
|
*/ function buildForwardPlusGraph(graph, ctx, renderQueue, options) {
|
|
66
|
-
const device = ctx.device;
|
|
67
71
|
const backbuffer = graph.importTexture('backbuffer');
|
|
68
72
|
// Shared mutable frame state
|
|
69
73
|
const frame = {
|
|
@@ -101,36 +105,40 @@ function freeClusteredLight(cl) {
|
|
|
101
105
|
});
|
|
102
106
|
}
|
|
103
107
|
// ── 4. Shadow Maps ────────────────────────────────────────────────
|
|
104
|
-
|
|
108
|
+
// Shadow maps are managed internally by lights, mark as side effect
|
|
105
109
|
if (renderQueue.shadowedLights.length > 0) {
|
|
106
110
|
graph.addPass('ShadowMaps', (builder)=>{
|
|
107
|
-
|
|
108
|
-
format: 'r32f',
|
|
109
|
-
label: 'shadowMaps'
|
|
110
|
-
});
|
|
111
|
+
builder.sideEffect();
|
|
111
112
|
builder.setExecute(()=>{
|
|
112
113
|
renderShadowMaps(ctx, renderQueue.shadowedLights);
|
|
113
114
|
});
|
|
114
115
|
});
|
|
115
116
|
}
|
|
116
117
|
// ── 5. Depth Prepass ──────────────────────────────────────────────
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
// Declare transient depth and motion vector textures
|
|
119
|
+
const depthPassResult = graph.addPass('DepthPrepass', (builder)=>{
|
|
120
|
+
const format = ctx.device.type === 'webgl' ? ctx.SSRCalcThickness ? 'rgba16f' : 'rgba8unorm' : ctx.SSRCalcThickness ? 'rg32f' : 'r32f';
|
|
121
|
+
const mvFormat = 'rgba16f';
|
|
122
|
+
const depthHandle = builder.createTexture({
|
|
123
|
+
format,
|
|
122
124
|
label: 'linearDepth'
|
|
123
125
|
});
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
frame.depthFramebuffer = renderSceneDepth(frame, null);
|
|
126
|
+
const motionVectorHandle = options.motionVectors ? builder.createTexture({
|
|
127
|
+
format: mvFormat,
|
|
128
|
+
label: 'motionVector'
|
|
129
|
+
}) : undefined;
|
|
130
|
+
builder.setExecute((rgCtx)=>{
|
|
131
|
+
const depthTex = rgCtx.getTexture(depthHandle);
|
|
132
|
+
const mvTex = motionVectorHandle ? rgCtx.getTexture(motionVectorHandle) : null;
|
|
133
|
+
frame.depthFramebuffer = renderSceneDepth(frame, null, depthTex, mvTex);
|
|
132
134
|
});
|
|
135
|
+
return {
|
|
136
|
+
depthHandle,
|
|
137
|
+
motionVectorHandle
|
|
138
|
+
};
|
|
133
139
|
});
|
|
140
|
+
const depthHandle = depthPassResult.depthHandle;
|
|
141
|
+
const motionVectorHandle = depthPassResult.motionVectorHandle;
|
|
134
142
|
// ── 6. Hi-Z (optional) ───────────────────────────────────────────
|
|
135
143
|
let hiZHandle;
|
|
136
144
|
if (options.hiZ) {
|
|
@@ -141,30 +149,53 @@ function freeClusteredLight(cl) {
|
|
|
141
149
|
label: 'hiZ',
|
|
142
150
|
mipLevels: 10
|
|
143
151
|
});
|
|
144
|
-
builder.setExecute(()=>{
|
|
145
|
-
|
|
146
|
-
|
|
152
|
+
builder.setExecute((rgCtx)=>{
|
|
153
|
+
const ctx = frame.ctx;
|
|
154
|
+
// Use the depth texture from the framebuffer (which contains the RenderGraph texture)
|
|
155
|
+
const depthTex = frame.depthFramebuffer?.getDepthAttachment();
|
|
156
|
+
if (depthTex) {
|
|
157
|
+
// Get the HiZ texture allocated by the executor
|
|
158
|
+
const hiZTex = rgCtx.getTexture(hiZHandle);
|
|
159
|
+
const w = hiZTex.width;
|
|
160
|
+
const h = hiZTex.height;
|
|
161
|
+
const HiZFrameBuffer = ctx.device.pool.fetchTemporalFramebuffer(false, w, h, hiZTex, null, false);
|
|
162
|
+
buildHiZ(depthTex, HiZFrameBuffer);
|
|
163
|
+
ctx.HiZTexture = hiZTex;
|
|
164
|
+
ctx.device.pool.releaseFrameBuffer(HiZFrameBuffer);
|
|
165
|
+
}
|
|
147
166
|
});
|
|
148
167
|
});
|
|
149
168
|
}
|
|
150
169
|
// ── 7. Main Light Pass ────────────────────────────────────────────
|
|
151
|
-
|
|
152
|
-
graph.addPass('LightPass', (builder)=>{
|
|
170
|
+
const lightPassResult = graph.addPass('LightPass', (builder)=>{
|
|
153
171
|
builder.read(depthHandle);
|
|
154
|
-
if (shadowMapsHandle) {
|
|
155
|
-
builder.read(shadowMapsHandle);
|
|
156
|
-
}
|
|
157
172
|
if (hiZHandle) {
|
|
158
173
|
builder.read(hiZHandle);
|
|
159
174
|
}
|
|
160
|
-
|
|
175
|
+
// Create scene color texture (intermediate render target)
|
|
176
|
+
const sceneColorHandle = builder.createTexture({
|
|
161
177
|
format: ctx.colorFormat,
|
|
162
178
|
label: 'sceneColor'
|
|
163
179
|
});
|
|
164
|
-
|
|
165
|
-
|
|
180
|
+
// Create optional sceneColorCopy for transmission/refraction materials
|
|
181
|
+
let sceneColorCopyHandle;
|
|
182
|
+
if (options.needSceneColor) {
|
|
183
|
+
sceneColorCopyHandle = builder.createTexture({
|
|
184
|
+
format: ctx.colorFormat,
|
|
185
|
+
label: 'sceneColorCopy'
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
builder.setExecute((rgCtx)=>{
|
|
189
|
+
const sceneColorTex = rgCtx.getTexture(sceneColorHandle);
|
|
190
|
+
const sceneColorCopyTex = sceneColorCopyHandle ? rgCtx.getTexture(sceneColorCopyHandle) : null;
|
|
191
|
+
renderMainLightPass(frame, sceneColorTex, sceneColorCopyTex);
|
|
166
192
|
});
|
|
193
|
+
return {
|
|
194
|
+
sceneColorHandle,
|
|
195
|
+
sceneColorCopyHandle
|
|
196
|
+
};
|
|
167
197
|
});
|
|
198
|
+
const sceneColorHandle = lightPassResult.sceneColorHandle;
|
|
168
199
|
// ── 8. Post Effects + Final Composite ─────────────────────────────
|
|
169
200
|
graph.addPass('Composite', (builder)=>{
|
|
170
201
|
builder.read(sceneColorHandle);
|
|
@@ -190,28 +221,40 @@ function freeClusteredLight(cl) {
|
|
|
190
221
|
}
|
|
191
222
|
ctx.device.popDeviceStates();
|
|
192
223
|
}
|
|
193
|
-
/** @internal */ function renderSceneDepth(frame, existingDepthFb) {
|
|
224
|
+
/** @internal */ function renderSceneDepth(frame, existingDepthFb, depthTex, motionVectorTex) {
|
|
194
225
|
const ctx = frame.ctx;
|
|
195
226
|
const renderQueue = frame.renderQueue;
|
|
196
227
|
const transmission = !!existingDepthFb;
|
|
197
228
|
let depthFramebuffer = existingDepthFb;
|
|
198
229
|
if (!depthFramebuffer) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
230
|
+
// Use RenderGraph-allocated textures if provided
|
|
231
|
+
if (depthTex) {
|
|
232
|
+
const colorAttachments = motionVectorTex ? [
|
|
233
|
+
depthTex,
|
|
234
|
+
motionVectorTex
|
|
235
|
+
] : depthTex;
|
|
236
|
+
const depthAttachment = ctx.finalFramebuffer?.getDepthAttachment();
|
|
237
|
+
const depthTexOrFormat = depthAttachment?.isTexture2D() ? depthAttachment : ctx.depthFormat;
|
|
238
|
+
depthFramebuffer = ctx.device.pool.fetchTemporalFramebuffer(true, depthTex.width, depthTex.height, colorAttachments, depthTexOrFormat, false);
|
|
206
239
|
} else {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
240
|
+
// Fallback: allocate from pool (legacy path)
|
|
241
|
+
const format = ctx.device.type === 'webgl' ? ctx.SSRCalcThickness ? 'rgba16f' : 'rgba8unorm' : ctx.SSRCalcThickness ? 'rg32f' : 'r32f';
|
|
242
|
+
const mvFormat = 'rgba16f';
|
|
243
|
+
if (!ctx.finalFramebuffer) {
|
|
244
|
+
depthFramebuffer = ctx.device.pool.fetchTemporalFramebuffer(true, ctx.renderWidth, ctx.renderHeight, ctx.motionVectors ? [
|
|
245
|
+
format,
|
|
246
|
+
mvFormat
|
|
247
|
+
] : format, ctx.depthFormat, false);
|
|
248
|
+
} else {
|
|
249
|
+
const originDepth = ctx.finalFramebuffer?.getDepthAttachment();
|
|
250
|
+
depthFramebuffer = originDepth?.isTexture2D() ? ctx.device.pool.fetchTemporalFramebuffer(true, originDepth.width, originDepth.height, ctx.motionVectors ? [
|
|
251
|
+
format,
|
|
252
|
+
mvFormat
|
|
253
|
+
] : format, originDepth, false) : ctx.device.pool.fetchTemporalFramebuffer(true, ctx.renderWidth, ctx.renderHeight, ctx.motionVectors ? [
|
|
254
|
+
format,
|
|
255
|
+
mvFormat
|
|
256
|
+
] : format, ctx.depthFormat, false);
|
|
257
|
+
}
|
|
215
258
|
}
|
|
216
259
|
}
|
|
217
260
|
ctx.device.pushDeviceStates();
|
|
@@ -249,13 +292,7 @@ function freeClusteredLight(cl) {
|
|
|
249
292
|
// Sky motion vectors rendering is handled inline
|
|
250
293
|
renderSkyMotionVectors(ctx);
|
|
251
294
|
}
|
|
252
|
-
|
|
253
|
-
const w = ctx.linearDepthTexture.width;
|
|
254
|
-
const h = ctx.linearDepthTexture.height;
|
|
255
|
-
const HiZFrameBuffer = ctx.device.pool.fetchTemporalFramebuffer(true, w, h, ctx.linearDepthTexture.format, null, true);
|
|
256
|
-
buildHiZ(ctx.depthTexture, HiZFrameBuffer);
|
|
257
|
-
ctx.HiZTexture = HiZFrameBuffer.getColorAttachments()[0];
|
|
258
|
-
}
|
|
295
|
+
// HiZ is now built in the dedicated HiZ pass
|
|
259
296
|
}
|
|
260
297
|
return depthFramebuffer;
|
|
261
298
|
}
|
|
@@ -321,13 +358,15 @@ let _skyMVBox = null;
|
|
|
321
358
|
device.popDeviceStates();
|
|
322
359
|
device.pool.releaseFrameBuffer(fb);
|
|
323
360
|
}
|
|
324
|
-
/** @internal */ function renderMainLightPass(frame) {
|
|
361
|
+
/** @internal */ function renderMainLightPass(frame, sceneColorTex, sceneColorCopyTex) {
|
|
325
362
|
const { ctx, renderQueue } = frame;
|
|
326
363
|
const device = ctx.device;
|
|
327
|
-
|
|
364
|
+
// Use RenderGraph-allocated scene color texture
|
|
365
|
+
const depthTex = frame.depthFramebuffer?.getDepthAttachment();
|
|
366
|
+
if (depthTex === ctx.finalFramebuffer?.getDepthAttachment()) {
|
|
328
367
|
ctx.intermediateFramebuffer = ctx.finalFramebuffer;
|
|
329
368
|
} else {
|
|
330
|
-
ctx.intermediateFramebuffer = device.pool.fetchTemporalFramebuffer(false,
|
|
369
|
+
ctx.intermediateFramebuffer = device.pool.fetchTemporalFramebuffer(false, sceneColorTex.width, sceneColorTex.height, sceneColorTex, depthTex);
|
|
331
370
|
}
|
|
332
371
|
if (ctx.intermediateFramebuffer && ctx.intermediateFramebuffer !== ctx.finalFramebuffer) {
|
|
333
372
|
device.pushDeviceStates();
|
|
@@ -337,26 +376,27 @@ let _skyMVBox = null;
|
|
|
337
376
|
device.setScissor(null);
|
|
338
377
|
}
|
|
339
378
|
_scenePass.transmission = false;
|
|
340
|
-
_scenePass.clearDepth =
|
|
341
|
-
_scenePass.clearStencil =
|
|
379
|
+
_scenePass.clearDepth = depthTex ? null : 1;
|
|
380
|
+
_scenePass.clearStencil = depthTex ? null : 0;
|
|
342
381
|
if (ctx.SSR && !renderQueue.needSceneColor()) {
|
|
343
382
|
ctx.materialFlags |= MaterialVaryingFlags.SSR_STORE_ROUGHNESS;
|
|
344
383
|
}
|
|
345
384
|
ctx.compositor?.begin(ctx);
|
|
346
|
-
if (renderQueue.needSceneColor()) {
|
|
385
|
+
if (renderQueue.needSceneColor() && sceneColorCopyTex) {
|
|
347
386
|
const compositor = ctx.compositor;
|
|
348
387
|
ctx.compositor = null;
|
|
349
|
-
|
|
350
|
-
|
|
388
|
+
// Use RenderGraph-allocated sceneColorCopy texture
|
|
389
|
+
const sceneColorFramebuffer = device.pool.fetchTemporalFramebuffer(true, sceneColorCopyTex.width, sceneColorCopyTex.height, ctx.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS ? [
|
|
390
|
+
sceneColorCopyTex,
|
|
351
391
|
device.getFramebuffer().getColorAttachments()[1],
|
|
352
392
|
device.getFramebuffer().getColorAttachments()[2]
|
|
353
|
-
] :
|
|
393
|
+
] : sceneColorCopyTex, depthTex, false);
|
|
354
394
|
device.pushDeviceStates();
|
|
355
395
|
device.setFramebuffer(sceneColorFramebuffer);
|
|
356
396
|
_scenePass.transmission = false;
|
|
357
397
|
_scenePass.render(ctx, null, null, renderQueue);
|
|
358
398
|
device.popDeviceStates();
|
|
359
|
-
ctx.sceneColorTexture =
|
|
399
|
+
ctx.sceneColorTexture = sceneColorCopyTex;
|
|
360
400
|
new CopyBlitter().blit(ctx.sceneColorTexture, device.getFramebuffer() ?? null, fetchSampler('clamp_nearest_nomip'));
|
|
361
401
|
_scenePass.transmission = true;
|
|
362
402
|
_scenePass.clearColor = null;
|
|
@@ -390,24 +430,40 @@ let _skyMVBox = null;
|
|
|
390
430
|
}
|
|
391
431
|
}
|
|
392
432
|
// ─── Convenience: Execute Full Pipeline ─────────────────────────────
|
|
393
|
-
/**
|
|
394
|
-
* Build, compile, and execute the forward+ pipeline as a render graph.
|
|
395
|
-
*
|
|
396
|
-
* This is the drop-in replacement for `SceneRenderer._renderScene`.
|
|
397
|
-
*
|
|
398
|
-
* @param ctx - The draw context for this frame.
|
|
399
|
-
* @public
|
|
433
|
+
/**
|
|
434
|
+
* Build, compile, and execute the forward+ pipeline as a render graph.
|
|
435
|
+
*
|
|
436
|
+
* This is the drop-in replacement for `SceneRenderer._renderScene`.
|
|
437
|
+
*
|
|
438
|
+
* @param ctx - The draw context for this frame.
|
|
439
|
+
* @public
|
|
400
440
|
*/ function executeForwardPlusGraph(ctx) {
|
|
401
441
|
const device = ctx.device;
|
|
402
442
|
const graph = new RenderGraph();
|
|
403
443
|
// Cull scene first (needed to derive options)
|
|
404
444
|
const renderQueue = _scenePass.cullScene(ctx, ctx.camera);
|
|
405
445
|
const options = deriveForwardPlusOptions(ctx.scene, ctx.camera, device.type, renderQueue);
|
|
446
|
+
// Ensure the camera has a history resource manager for temporal effects (TAA, motion blur)
|
|
447
|
+
let historyManager = ctx.camera.getHistoryResourceManager();
|
|
448
|
+
if (!historyManager) {
|
|
449
|
+
historyManager = new HistoryResourceManager(_devicePoolAllocator);
|
|
450
|
+
ctx.camera.setHistoryResourceManager(historyManager);
|
|
451
|
+
}
|
|
406
452
|
const backbuffer = buildForwardPlusGraph(graph, ctx, renderQueue, options);
|
|
407
453
|
const compiled = graph.compile([
|
|
408
454
|
backbuffer
|
|
409
455
|
]);
|
|
410
|
-
|
|
456
|
+
// Use RenderGraphExecutor for automatic resource management
|
|
457
|
+
const executor = new RenderGraphExecutor(_devicePoolAllocator, ctx.renderWidth, ctx.renderHeight);
|
|
458
|
+
// Register imported backbuffer (if using finalFramebuffer)
|
|
459
|
+
if (ctx.finalFramebuffer) {
|
|
460
|
+
const backbufferTex = ctx.finalFramebuffer.getColorAttachments()[0];
|
|
461
|
+
executor.setImportedTexture(backbuffer, backbufferTex);
|
|
462
|
+
}
|
|
463
|
+
executor.execute(compiled);
|
|
464
|
+
executor.reset();
|
|
465
|
+
// Swap history buffers at frame end (ping-pong)
|
|
466
|
+
historyManager.swap();
|
|
411
467
|
}
|
|
412
468
|
|
|
413
469
|
export { buildForwardPlusGraph, deriveForwardPlusOptions, executeForwardPlusGraph };
|