@zephyr3d/scene 0.9.18 → 0.9.20
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/joint_dynamics/convex_collider.js +320 -0
- package/dist/animation/joint_dynamics/convex_collider.js.map +1 -0
- package/dist/app/scriptregistry.js +124 -6
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +1 -0
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/camera/camera.js +240 -201
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +458 -9
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/material/meshmaterial.js +2 -2
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +11 -5
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lit.js +10 -0
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/shader/helper.js +138 -10
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/skin.js +4 -6
- package/dist/material/skin.js.map +1 -1
- package/dist/material/water.js +1 -1
- package/dist/material/water.js.map +1 -1
- package/dist/posteffect/bloom.js +177 -29
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/compositor.js +111 -204
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/motionblur.js +3 -0
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/posteffect.js +79 -0
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/skinsss.js.map +1 -1
- package/dist/posteffect/ssr.js +238 -7
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +16 -15
- package/dist/posteffect/sss.js.map +1 -1
- package/dist/posteffect/taa.js +121 -19
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/posteffect/tonemap.js +1 -1
- package/dist/posteffect/tonemap.js.map +1 -1
- package/dist/render/abuffer_oit.js +7 -1
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js +52 -8
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/dualdepthpeeling_oit.js +331 -0
- package/dist/render/dualdepthpeeling_oit.js.map +1 -0
- package/dist/render/envlight.js +6 -3
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/hzb.js +11 -4
- package/dist/render/hzb.js.map +1 -1
- package/dist/render/lightpass.js +21 -12
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/renderer.js +7 -3
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/blackboard.js +79 -0
- package/dist/render/rendergraph/blackboard.js.map +1 -0
- package/dist/render/rendergraph/device_pool_allocator.js +10 -1
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/render/rendergraph/executor.js +41 -11
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +551 -201
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/rendergraph.js +29 -0
- package/dist/render/rendergraph/rendergraph.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/renderpass.js +12 -2
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/shadow_mask_pass.js +297 -0
- package/dist/render/shadow_mask_pass.js.map +1 -0
- package/dist/render/weightedblended_oit.js +5 -0
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +1 -0
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +1 -0
- 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/msdftext.js +1 -0
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +1 -0
- package/dist/scene/msdftextsprite.js.map +1 -1
- 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/terrain-cm/grass.js +1 -0
- package/dist/scene/terrain-cm/grass.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/water.js +1 -0
- package/dist/scene/water.js.map +1 -1
- package/dist/shaders/ssr.js +52 -21
- package/dist/shaders/ssr.js.map +1 -1
- package/dist/utility/misc.js +10 -1
- package/dist/utility/misc.js.map +1 -1
- package/dist/utility/serialization/manager.js +1 -0
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +1 -0
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +1 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +35 -2
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +1 -0
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +1 -0
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +1 -0
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +1 -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/sprite.js +1 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +1 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +1 -0
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +1 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/values.js +11 -1
- package/dist/values.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","sources":["../../src/render/renderer.ts"],"sourcesContent":["import type { TextureFormat } from '@zephyr3d/device';\r\nimport { 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 halfFloatColorBuffer = device.getDeviceCaps().textureCaps.supportHalfFloatColorBuffer;\r\n const colorFormat = camera.HDR && halfFloatColorBuffer ? '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 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 SSS = camera.SSS;\r\n const glossySurfaceFormat: TextureFormat = halfFloatColorBuffer ? 'rgba16f' : 'rgba8unorm';\r\n const ctx: DrawContext = {\r\n device,\r\n scene,\r\n renderWidth,\r\n renderHeight,\r\n oit: null,\r\n motionVectors:\r\n device.type !== 'webgl' && (camera.TAA || camera.motionBlur || (SSR && camera.ssrTemporal)),\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 sunLight: null,\r\n primaryDirectionalLight: null,\r\n primaryTransmissionLight: null,\r\n materialFlags: 0,\r\n SSR,\r\n SSS,\r\n SSRCalcThickness: SSR && camera.ssrCalcThickness,\r\n SSRRoughnessTexture: SSR\r\n ? device.pool.fetchTemporalTexture2D(true, glossySurfaceFormat, renderWidth, renderHeight)\r\n : null,\r\n SSRNormalTexture: SSR\r\n ? device.pool.fetchTemporalTexture2D(true, glossySurfaceFormat, renderWidth, renderHeight)\r\n : null,\r\n SSSProfileTexture: null,\r\n SSSParamTexture: null,\r\n SSSDiffuseTexture: null,\r\n SSSTransmissionTexture: null,\r\n SkinSSSTexture: null,\r\n ssrSDFBoxBuffer: null,\r\n ssrSDFBoxCount: 0,\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 } else {\r\n camera.getPickResultResolveFunc()?.(null);\r\n return;\r\n }\r\n }\r\n GlobalBindGroupAllocator.release(globalBindGroupAllocator);\r\n }\r\n\r\n /** @internal */\r\n protected static _renderScene(ctx: DrawContext): void {\r\n executeForwardPlusGraph(ctx);\r\n }\r\n}\r\n"],"names":["SceneRenderer","renderScene","scene","camera","device","getDevice","halfFloatColorBuffer","getDeviceCaps","textureCaps","supportHalfFloatColorBuffer","colorFormat","HDR","depthFormat","framebufferCaps","supportDepth32floatStencil8","globalBindGroupAllocator","GlobalBindGroupAllocator","get","frameUpdate","frameUpdatePerCamera","isContextLost","defaultViewport","TAA","type","viewport","scissor","renderX","screenXToDevice","renderY","screenYToDevice","renderWidth","getDrawingBufferWidth","renderHeight","getDrawingBufferHeight","tmpFramebuffer","pool","fetchTemporalFramebuffer","originFramebuffer","getFramebuffer","pushDeviceStates","setFramebuffer","clearFrameBuffer","clearColor","clearDepth","clearStencil","SSR","env","light","envLight","hasRadiance","SSS","glossySurfaceFormat","ctx","oit","motionVectors","motionBlur","ssrTemporal","HiZ","HiZTexture","compositor","queue","lightBlending","renderPass","renderPassHash","flip","drawEnvLight","sunLight","primaryDirectionalLight","primaryTransmissionLight","materialFlags","SSRCalcThickness","ssrCalcThickness","SSRRoughnessTexture","fetchTemporalTexture2D","SSRNormalTexture","SSSProfileTexture","SSSParamTexture","SSSDiffuseTexture","SSSTransmissionTexture","SkinSSSTexture","ssrSDFBoxBuffer","ssrSDFBoxCount","finalFramebuffer","intermediateFramebuffer","_renderScene","popDeviceStates","oversizedViewport","blitter","CopyBlitter","destRect","slice","srgbOut","blit","getColorAttachments","fetchSampler","releaseFrameBuffer","getPickResultResolveFunc","release","executeForwardPlusGraph"],"mappings":";;;;;;;;;AAUA;;;AAGC,IACM,MAAMA,aAAAA,CAAAA;AACX;;;;AAIC,MACD,OAAOC,WAAAA,CAAYC,KAAY,EAAEC,MAAc,EAAQ;AACrD,QAAA,MAAMC,MAASC,GAAAA,SAAAA,EAAAA;AACf,QAAA,MAAMC,uBAAuBF,MAAOG,CAAAA,aAAa,EAAGC,CAAAA,WAAW,CAACC,2BAA2B;AAC3F,QAAA,MAAMC,WAAcP,GAAAA,MAAAA,CAAOQ,GAAG,IAAIL,uBAAuB,SAAY,GAAA,YAAA;QACrE,MAAMM,WAAAA,GAAcR,OAAOG,aAAa,EAAA,CAAGM,eAAe,CAACC,2BAA2B,GAClF,QACA,GAAA,OAAA;QACJ,MAAMC,wBAAAA,GAA2BC,yBAAyBC,GAAG,EAAA;AAC7Df,QAAAA,KAAAA,CAAMgB,WAAW,EAAA;AACjBhB,QAAAA,KAAAA,CAAMiB,oBAAoB,CAAChB,MAAAA,CAAAA;AAC3B,QAAA,IAAIA,MAAU,IAAA,CAACC,MAAOgB,CAAAA,aAAa,EAAI,EAAA;AACrC,YAAA,MAAMC,kBAAkB,CAAC,CAAClB,MAAOmB,CAAAA,GAAG,IAAIlB,MAAOmB,CAAAA,IAAI,KAAK,OAAM,KAAM,CAACpB,MAAAA,CAAOqB,QAAQ,IAAI,CAACrB,OAAOsB,OAAO;YACvG,MAAMC,OAAAA,GAAUvB,MAAOqB,CAAAA,QAAQ,GAAGpB,MAAAA,CAAOuB,eAAe,CAACxB,MAAOqB,CAAAA,Q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OsB,CAAAA,OAAO,GAAGtB,MAAOsB,CAAAA,OAAO,CAACiE,KAAK,EAAK,GAAA,IAAA;oBAC5DH,OAAQI,CAAAA,OAAO,GAAG,CAACtD,iBAAAA;oBACnBkD,OAAQK,CAAAA,IAAI,CACV1D,cAAAA,CAAe2D,mBAAmB,EAAE,CAAC,CAAE,CAAA,EACvCxD,iBAAqB,IAAA,IAAA,EACrByD,YAAa,CAAA,qBAAA,CAAA,CAAA;oBAEf1F,MAAO+B,CAAAA,IAAI,CAAC4D,kBAAkB,CAAC7D,cAAAA,CAAAA;AACjC;aACK,MAAA;AACL/B,gBAAAA,MAAAA,CAAO6F,wBAAwB,EAAK,GAAA,IAAA,CAAA;AACpC,gBAAA;AACF;AACF;AACAhF,QAAAA,wBAAAA,CAAyBiF,OAAO,CAAClF,wBAAAA,CAAAA;AACnC;AAEA,qBACA,OAAiBqE,YAAahC,CAAAA,GAAgB,EAAQ;QACpD8C,uBAAwB9C,CAAAA,GAAAA,CAAAA;AAC1B;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 halfFloatColorBuffer = device.getDeviceCaps().textureCaps.supportHalfFloatColorBuffer;\r\n const colorFormat = camera.HDR && halfFloatColorBuffer ? '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 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 SSS = camera.SSS;\r\n const ctx: DrawContext = {\r\n device,\r\n scene,\r\n renderWidth,\r\n renderHeight,\r\n oit: null,\r\n motionVectors:\r\n device.type !== 'webgl' && (camera.TAA || camera.motionBlur || (SSR && camera.ssrTemporal)),\r\n HiZ: camera.HiZ && device.type !== 'webgl',\r\n HiZTexture: null,\r\n // WebGL1 has no 2D array textures; degrade gracefully to the legacy\r\n // per-light additive shadow path (mirrors the HiZ gating above).\r\n screenSpaceShadowMask: camera.screenSpaceShadowMask && device.type !== 'webgl',\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 sunLight: null,\r\n primaryDirectionalLight: null,\r\n primaryTransmissionLight: null,\r\n materialFlags: 0,\r\n SSR,\r\n SSS,\r\n SSRCalcThickness: SSR && camera.ssrCalcThickness,\r\n // SSR roughness/normal MRT textures are render graph resources\r\n // created by the LightPass; resolved into these fields at execution.\r\n SSRRoughnessTexture: null,\r\n SSRNormalTexture: null,\r\n SSSProfileTexture: null,\r\n SSSParamTexture: null,\r\n SSSDiffuseTexture: null,\r\n SSSTransmissionTexture: null,\r\n SkinSSSTexture: null,\r\n ssrSDFBoxBuffer: null,\r\n ssrSDFBoxCount: 0,\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 } else {\r\n camera.getPickResultResolveFunc()?.(null);\r\n return;\r\n }\r\n }\r\n GlobalBindGroupAllocator.release(globalBindGroupAllocator);\r\n }\r\n\r\n /** @internal */\r\n protected static _renderScene(ctx: DrawContext): void {\r\n executeForwardPlusGraph(ctx);\r\n }\r\n}\r\n"],"names":["SceneRenderer","renderScene","scene","camera","device","getDevice","halfFloatColorBuffer","getDeviceCaps","textureCaps","supportHalfFloatColorBuffer","colorFormat","HDR","depthFormat","framebufferCaps","supportDepth32floatStencil8","globalBindGroupAllocator","GlobalBindGroupAllocator","get","frameUpdate","frameUpdatePerCamera","isContextLost","defaultViewport","TAA","type","viewport","scissor","renderX","screenXToDevice","renderY","screenYToDevice","renderWidth","getDrawingBufferWidth","renderHeight","getDrawingBufferHeight","tmpFramebuffer","pool","fetchTemporalFramebuffer","originFramebuffer","getFramebuffer","pushDeviceStates","setFramebuffer","clearFrameBuffer","clearColor","clearDepth","clearStencil","SSR","env","light","envLight","hasRadiance","SSS","ctx","oit","motionVectors","motionBlur","ssrTemporal","HiZ","HiZTexture","screenSpaceShadowMask","compositor","queue","lightBlending","renderPass","renderPassHash","flip","drawEnvLight","sunLight","primaryDirectionalLight","primaryTransmissionLight","materialFlags","SSRCalcThickness","ssrCalcThickness","SSRRoughnessTexture","SSRNormalTexture","SSSProfileTexture","SSSParamTexture","SSSDiffuseTexture","SSSTransmissionTexture","SkinSSSTexture","ssrSDFBoxBuffer","ssrSDFBoxCount","finalFramebuffer","intermediateFramebuffer","_renderScene","popDeviceStates","oversizedViewport","blitter","CopyBlitter","destRect","slice","srgbOut","blit","getColorAttachments","fetchSampler","releaseFrameBuffer","getPickResultResolveFunc","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;AACf,QAAA,MAAMC,uBAAuBF,MAAOG,CAAAA,aAAa,EAAGC,CAAAA,WAAW,CAACC,2BAA2B;AAC3F,QAAA,MAAMC,WAAcP,GAAAA,MAAAA,CAAOQ,GAAG,IAAIL,uBAAuB,SAAY,GAAA,YAAA;QACrE,MAAMM,WAAAA,GAAcR,OAAOG,aAAa,EAAA,C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IAAIF,iBAAmB,EAAA;AACrBC,wBAAAA,OAAAA,CAAQE,QAAQ,GAAG;AAAC9D,4BAAAA,OAAAA;AAASE,4BAAAA,OAAAA;AAASE,4BAAAA,WAAAA;AAAaE,4BAAAA;AAAa,yBAAA;qBAC3D,MAAA;wBACLsD,OAAQ9D,CAAAA,QAAQ,GAAGrB,MAAOqB,CAAAA,QAAQ,GAAGrB,MAAOqB,CAAAA,QAAQ,CAACiE,KAAK,EAAK,GAAA,IAAA;AACjE;oBACAH,OAAQ7D,CAAAA,OAAO,GAAGtB,MAAOsB,CAAAA,OAAO,GAAGtB,MAAOsB,CAAAA,OAAO,CAACgE,KAAK,EAAK,GAAA,IAAA;oBAC5DH,OAAQI,CAAAA,OAAO,GAAG,CAACrD,iBAAAA;oBACnBiD,OAAQK,CAAAA,IAAI,CACVzD,cAAAA,CAAe0D,mBAAmB,EAAE,CAAC,CAAE,CAAA,EACvCvD,iBAAqB,IAAA,IAAA,EACrBwD,YAAa,CAAA,qBAAA,CAAA,CAAA;oBAEfzF,MAAO+B,CAAAA,IAAI,CAAC2D,kBAAkB,CAAC5D,cAAAA,CAAAA;AACjC;aACK,MAAA;AACL/B,gBAAAA,MAAAA,CAAO4F,wBAAwB,EAAK,GAAA,IAAA,CAAA;AACpC,gBAAA;AACF;AACF;AACA/E,QAAAA,wBAAAA,CAAyBgF,OAAO,CAACjF,wBAAAA,CAAAA;AACnC;AAEA,qBACA,OAAiBoE,YAAahC,CAAAA,GAAgB,EAAQ;QACpD8C,uBAAwB9C,CAAAA,GAAAA,CAAAA;AAC1B;AACF;;;;"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical names for well-known per-frame resources shared through {@link RGBlackboard}.
|
|
3
|
+
*
|
|
4
|
+
* Producer passes register their output handles under these names so that
|
|
5
|
+
* consumers (e.g. post effects) can declare reads without hard-coupling to
|
|
6
|
+
* the pass that produced them.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/ const FrameResources = {
|
|
10
|
+
SceneColor: 'sceneColor',
|
|
11
|
+
SceneColorCopy: 'sceneColorCopy',
|
|
12
|
+
LinearDepth: 'linearDepth',
|
|
13
|
+
SceneDepthAttachment: 'sceneDepthAttachment',
|
|
14
|
+
MotionVector: 'motionVector',
|
|
15
|
+
HiZ: 'hiZ',
|
|
16
|
+
SSRRoughness: 'ssrRoughness',
|
|
17
|
+
SSRNormal: 'ssrNormal',
|
|
18
|
+
SSSProfile: 'sssProfile',
|
|
19
|
+
SSSParam: 'sssParam',
|
|
20
|
+
SSSDiffuse: 'sssDiffuse',
|
|
21
|
+
SSSTransmission: 'sssTransmission',
|
|
22
|
+
SkinSSS: 'skinSSS',
|
|
23
|
+
ShadowMask: 'shadowMask'
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Named registry of render graph resource handles for the current frame.
|
|
27
|
+
*
|
|
28
|
+
* The blackboard decouples resource producers from consumers: passes that
|
|
29
|
+
* create shared resources register the returned handles by name, and later
|
|
30
|
+
* passes look them up to declare read dependencies. This replaces passing
|
|
31
|
+
* textures through mutable `DrawContext` fields.
|
|
32
|
+
*
|
|
33
|
+
* A blackboard instance is valid for a single graph build; create a new one
|
|
34
|
+
* (or clear it) every frame together with the graph.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/ class RGBlackboard {
|
|
38
|
+
/** @internal */ _handles = new Map();
|
|
39
|
+
/**
|
|
40
|
+
* Register a resource handle under a name, replacing any previous entry.
|
|
41
|
+
* @param name - Resource name, typically one of {@link FrameResources}.
|
|
42
|
+
* @param handle - The handle to register.
|
|
43
|
+
*/ set(name, handle) {
|
|
44
|
+
this._handles.set(name, handle);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Look up a resource handle by name.
|
|
48
|
+
* @param name - Resource name, typically one of {@link FrameResources}.
|
|
49
|
+
* @returns The registered handle, or null if not present this frame.
|
|
50
|
+
*/ get(name) {
|
|
51
|
+
return this._handles.get(name) ?? null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Check whether a resource is registered.
|
|
55
|
+
* @param name - Resource name.
|
|
56
|
+
* @returns true if a handle is registered under the name.
|
|
57
|
+
*/ has(name) {
|
|
58
|
+
return this._handles.has(name);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Look up a resource handle that must exist.
|
|
62
|
+
* @param name - Resource name.
|
|
63
|
+
* @returns The registered handle.
|
|
64
|
+
*/ expect(name) {
|
|
65
|
+
const handle = this._handles.get(name);
|
|
66
|
+
if (!handle) {
|
|
67
|
+
throw new Error(`RGBlackboard: required frame resource "${name}" was not registered`);
|
|
68
|
+
}
|
|
69
|
+
return handle;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Remove all registered handles.
|
|
73
|
+
*/ clear() {
|
|
74
|
+
this._handles.clear();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { FrameResources, RGBlackboard };
|
|
79
|
+
//# sourceMappingURL=blackboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blackboard.js","sources":["../../../src/render/rendergraph/blackboard.ts"],"sourcesContent":["import type { Nullable } from '@zephyr3d/base';\r\nimport type { RGHandle } from './types';\r\n\r\n/**\r\n * Canonical names for well-known per-frame resources shared through {@link RGBlackboard}.\r\n *\r\n * Producer passes register their output handles under these names so that\r\n * consumers (e.g. post effects) can declare reads without hard-coupling to\r\n * the pass that produced them.\r\n *\r\n * @public\r\n */\r\nexport const FrameResources = {\r\n SceneColor: 'sceneColor',\r\n SceneColorCopy: 'sceneColorCopy',\r\n LinearDepth: 'linearDepth',\r\n SceneDepthAttachment: 'sceneDepthAttachment',\r\n MotionVector: 'motionVector',\r\n HiZ: 'hiZ',\r\n SSRRoughness: 'ssrRoughness',\r\n SSRNormal: 'ssrNormal',\r\n SSSProfile: 'sssProfile',\r\n SSSParam: 'sssParam',\r\n SSSDiffuse: 'sssDiffuse',\r\n SSSTransmission: 'sssTransmission',\r\n SkinSSS: 'skinSSS',\r\n ShadowMask: 'shadowMask'\r\n} as const;\r\n\r\n/**\r\n * Named registry of render graph resource handles for the current frame.\r\n *\r\n * The blackboard decouples resource producers from consumers: passes that\r\n * create shared resources register the returned handles by name, and later\r\n * passes look them up to declare read dependencies. This replaces passing\r\n * textures through mutable `DrawContext` fields.\r\n *\r\n * A blackboard instance is valid for a single graph build; create a new one\r\n * (or clear it) every frame together with the graph.\r\n *\r\n * @public\r\n */\r\nexport class RGBlackboard {\r\n /** @internal */\r\n private _handles: Map<string, RGHandle> = new Map();\r\n /**\r\n * Register a resource handle under a name, replacing any previous entry.\r\n * @param name - Resource name, typically one of {@link FrameResources}.\r\n * @param handle - The handle to register.\r\n */\r\n set(name: string, handle: RGHandle): void {\r\n this._handles.set(name, handle);\r\n }\r\n /**\r\n * Look up a resource handle by name.\r\n * @param name - Resource name, typically one of {@link FrameResources}.\r\n * @returns The registered handle, or null if not present this frame.\r\n */\r\n get(name: string): Nullable<RGHandle> {\r\n return this._handles.get(name) ?? null;\r\n }\r\n /**\r\n * Check whether a resource is registered.\r\n * @param name - Resource name.\r\n * @returns true if a handle is registered under the name.\r\n */\r\n has(name: string): boolean {\r\n return this._handles.has(name);\r\n }\r\n /**\r\n * Look up a resource handle that must exist.\r\n * @param name - Resource name.\r\n * @returns The registered handle.\r\n */\r\n expect(name: string): RGHandle {\r\n const handle = this._handles.get(name);\r\n if (!handle) {\r\n throw new Error(`RGBlackboard: required frame resource \"${name}\" was not registered`);\r\n }\r\n return handle;\r\n }\r\n /**\r\n * Remove all registered handles.\r\n */\r\n clear(): void {\r\n this._handles.clear();\r\n }\r\n}\r\n"],"names":["FrameResources","SceneColor","SceneColorCopy","LinearDepth","SceneDepthAttachment","MotionVector","HiZ","SSRRoughness","SSRNormal","SSSProfile","SSSParam","SSSDiffuse","SSSTransmission","SkinSSS","ShadowMask","RGBlackboard","_handles","Map","set","name","handle","get","has","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,CAACS,KAAK,EAAA;AACrB;AACF;;;;"}
|
|
@@ -32,7 +32,16 @@ import { getDevice } from '../../app/api.js';
|
|
|
32
32
|
*/ allocate(desc, size) {
|
|
33
33
|
const device = this._device ?? getDevice();
|
|
34
34
|
const mipmapping = (desc.mipLevels ?? 1) > 1;
|
|
35
|
-
const
|
|
35
|
+
const arrayLayers = desc.arrayLayers;
|
|
36
|
+
// A defined arrayLayers (even 1) requests a 2D array texture — a single-layer
|
|
37
|
+
// array is a distinct texture type from a plain 2D texture, and the two are
|
|
38
|
+
// not interchangeable when bound to a tex2DArray sampler. Array textures are
|
|
39
|
+
// fetched as Texture2DArray. The render graph's TTexture channel is nominally
|
|
40
|
+
// Texture2D (see forward_plus_builder's executor annotation); TS types are
|
|
41
|
+
// erased at runtime, every pool op below accepts BaseTexture, so the cast is
|
|
42
|
+
// safe. Passes resolve the real type via getTexture<Texture2DArray>().
|
|
43
|
+
// Individual layers are targeted through RGFramebufferDesc.attachmentLayer.
|
|
44
|
+
const texture = arrayLayers !== undefined ? device.pool.fetchTemporalTexture2DArray(false, desc.format, size.width, size.height, arrayLayers, mipmapping) : device.pool.fetchTemporalTexture2D(false, desc.format, size.width, size.height, mipmapping);
|
|
36
45
|
if (desc.mipLevels && texture.mipLevelCount < desc.mipLevels) {
|
|
37
46
|
device.pool.releaseTexture(texture);
|
|
38
47
|
throw new Error(`DevicePoolAllocator: texture "${desc.label ?? '<unnamed>'}" requested ${desc.mipLevels} ` + `mip levels, but only ${texture.mipLevelCount} were allocated.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device_pool_allocator.js","sources":["../../../src/render/rendergraph/device_pool_allocator.ts"],"sourcesContent":["import type { FrameBuffer, Texture2D, TextureFormat, AbstractDevice } from '@zephyr3d/device';\r\nimport type { RGFramebufferDesc, RGTextureAllocator, RGTextureDesc, RGResolvedSize } from './types';\r\nimport { getDevice } from '../../app/api';\r\nimport type { Nullable } from '@zephyr3d/base';\r\n\r\n/**\r\n * Bridges the render graph's {@link RGTextureAllocator} interface to the\r\n * engine's device resource pool (`device.pool`).\r\n *\r\n * Transient textures are fetched from the pool on `allocate()` and\r\n * returned to the pool on `release()`, enabling automatic reuse\r\n * across frames without manual lifecycle management.\r\n *\r\n * Usage:\r\n * ```ts\r\n * const allocator = new DevicePoolAllocator();\r\n * const executor = new RenderGraphExecutor(allocator, width, height);\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class DevicePoolAllocator implements RGTextureAllocator<Texture2D, FrameBuffer> {\r\n private _device: Nullable<AbstractDevice>;\r\n /**\r\n * Creates a new instance of the DevicePoolAllocator.\r\n * @param device - Optional device instance to use for resource allocation. If not provided, the global device will be used.\r\n */\r\n constructor(device?: AbstractDevice) {\r\n this._device = device ?? null;\r\n }\r\n /**\r\n * Allocate a transient texture from the device pool.\r\n *\r\n * @param desc - Texture descriptor from the render graph pass.\r\n * @param size - Resolved pixel dimensions.\r\n * @returns A pooled Texture2D instance.\r\n */\r\n allocate(desc: RGTextureDesc, size: RGResolvedSize): Texture2D {\r\n const device = this._device ?? getDevice();\r\n const mipmapping = (desc.mipLevels ?? 1) > 1;\r\n const
|
|
1
|
+
{"version":3,"file":"device_pool_allocator.js","sources":["../../../src/render/rendergraph/device_pool_allocator.ts"],"sourcesContent":["import type { FrameBuffer, Texture2D, TextureFormat, AbstractDevice } from '@zephyr3d/device';\r\nimport type { RGFramebufferDesc, RGTextureAllocator, RGTextureDesc, RGResolvedSize } from './types';\r\nimport { getDevice } from '../../app/api';\r\nimport type { Nullable } from '@zephyr3d/base';\r\n\r\n/**\r\n * Bridges the render graph's {@link RGTextureAllocator} interface to the\r\n * engine's device resource pool (`device.pool`).\r\n *\r\n * Transient textures are fetched from the pool on `allocate()` and\r\n * returned to the pool on `release()`, enabling automatic reuse\r\n * across frames without manual lifecycle management.\r\n *\r\n * Usage:\r\n * ```ts\r\n * const allocator = new DevicePoolAllocator();\r\n * const executor = new RenderGraphExecutor(allocator, width, height);\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class DevicePoolAllocator implements RGTextureAllocator<Texture2D, FrameBuffer> {\r\n private _device: Nullable<AbstractDevice>;\r\n /**\r\n * Creates a new instance of the DevicePoolAllocator.\r\n * @param device - Optional device instance to use for resource allocation. If not provided, the global device will be used.\r\n */\r\n constructor(device?: AbstractDevice) {\r\n this._device = device ?? null;\r\n }\r\n /**\r\n * Allocate a transient texture from the device pool.\r\n *\r\n * @param desc - Texture descriptor from the render graph pass.\r\n * @param size - Resolved pixel dimensions.\r\n * @returns A pooled Texture2D instance.\r\n */\r\n allocate(desc: RGTextureDesc, size: RGResolvedSize): Texture2D {\r\n const device = this._device ?? getDevice();\r\n const mipmapping = (desc.mipLevels ?? 1) > 1;\r\n const arrayLayers = desc.arrayLayers;\r\n // A defined arrayLayers (even 1) requests a 2D array texture — a single-layer\r\n // array is a distinct texture type from a plain 2D texture, and the two are\r\n // not interchangeable when bound to a tex2DArray sampler. Array textures are\r\n // fetched as Texture2DArray. The render graph's TTexture channel is nominally\r\n // Texture2D (see forward_plus_builder's executor annotation); TS types are\r\n // erased at runtime, every pool op below accepts BaseTexture, so the cast is\r\n // safe. Passes resolve the real type via getTexture<Texture2DArray>().\r\n // Individual layers are targeted through RGFramebufferDesc.attachmentLayer.\r\n const texture =\r\n arrayLayers !== undefined\r\n ? (device.pool.fetchTemporalTexture2DArray(\r\n false,\r\n desc.format,\r\n size.width,\r\n size.height,\r\n arrayLayers,\r\n mipmapping\r\n ) as unknown as Texture2D)\r\n : device.pool.fetchTemporalTexture2D(false, desc.format, size.width, size.height, mipmapping);\r\n if (desc.mipLevels && texture.mipLevelCount < desc.mipLevels) {\r\n device.pool.releaseTexture(texture);\r\n throw new Error(\r\n `DevicePoolAllocator: texture \"${desc.label ?? '<unnamed>'}\" requested ${desc.mipLevels} ` +\r\n `mip levels, but only ${texture.mipLevelCount} were allocated.`\r\n );\r\n }\r\n return texture;\r\n }\r\n\r\n /**\r\n * Release a transient texture back to the device pool.\r\n *\r\n * @param texture - The texture to release.\r\n */\r\n release(texture: Texture2D): void {\r\n const device = this._device ?? getDevice();\r\n device.pool.releaseTexture(texture);\r\n }\r\n\r\n /**\r\n * Retain a pooled texture so it can be owned outside the graph lifetime.\r\n *\r\n * @param texture - The texture to retain.\r\n */\r\n retain(texture: Texture2D): void {\r\n const device = this._device ?? getDevice();\r\n device.pool.retainTexture(texture);\r\n }\r\n\r\n /**\r\n * Allocate a temporary framebuffer from the device pool.\r\n *\r\n * @param desc - Framebuffer descriptor from the render graph pass.\r\n * @returns A pooled FrameBuffer instance.\r\n */\r\n allocateFramebuffer(desc: RGFramebufferDesc): FrameBuffer {\r\n const device = this._device ?? getDevice();\r\n const colors = Array.isArray(desc.colorAttachments)\r\n ? (desc.colorAttachments as Array<Texture2D | TextureFormat>)\r\n : desc.colorAttachments\r\n ? [desc.colorAttachments as Texture2D | TextureFormat]\r\n : [];\r\n const depthAttachment = (desc.depthAttachment ?? null) as Texture2D | TextureFormat | null;\r\n return device.pool.fetchTemporalFramebuffer(\r\n false,\r\n desc.width ?? 0,\r\n desc.height ?? 0,\r\n colors,\r\n depthAttachment,\r\n desc.mipmapping ?? false,\r\n desc.sampleCount ?? 1,\r\n desc.ignoreDepthStencil ?? true,\r\n desc.attachmentMipLevel ?? 0,\r\n desc.attachmentCubeface ?? 0,\r\n desc.attachmentLayer ?? 0\r\n );\r\n }\r\n\r\n /**\r\n * Release a temporary framebuffer back to the device pool.\r\n *\r\n * @param framebuffer - The framebuffer to release.\r\n */\r\n releaseFramebuffer(framebuffer: FrameBuffer): void {\r\n const device = this._device ?? getDevice();\r\n device.pool.releaseFrameBuffer(framebuffer);\r\n }\r\n}\r\n"],"names":["DevicePoolAllocator","_device","device","allocate","desc","size","getDevice","mipmapping","mipLevels","arrayLayers","texture","undefined","pool","fetchTemporalTexture2DArray","format","width","height","fetchTemporalTexture2D","mipLevelCount","releaseTexture","Error","label","release","retain","retainTexture","allocateFramebuffer","colors","Array","isArray","colorAttachments","depthAttachment","fetchTemporalFramebuffer","sampleCount","ignoreDepthStencil","attachmentMipLevel","attachmentCubeface","attachmentLayer","releaseFramebuffer","framebuffer","releaseFrameBuffer"],"mappings":";;AAKA;;;;;;;;;;;;;;;AAeC,IACM,MAAMA,mBAAAA,CAAAA;IACHC,OAAkC;AAC1C;;;MAIA,WAAA,CAAYC,MAAuB,CAAE;QACnC,IAAI,CAACD,OAAO,GAAGC,MAAU,IAAA,IAAA;AAC3B;AACA;;;;;;AAMC,MACDC,QAASC,CAAAA,IAAmB,EAAEC,IAAoB,EAAa;AAC7D,QAAA,MAAMH,MAAS,GAAA,IAAI,CAACD,OAAO,IAAIK,SAAAA,EAAAA;AAC/B,QAAA,MAAMC,aAAa,CAACH,KAAKI,SAAS,IAAI,CAAA,IAAK,CAAA;QAC3C,MAAMC,WAAAA,GAAcL,KAAKK,WAAW;;;;;;;;;AASpC,QAAA,MAAMC,OACJD,GAAAA,WAAAA,KAAgBE,SACXT,GAAAA,MAAAA,CAAOU,IAAI,CAACC,2BAA2B,CACtC,KAAA,EACAT,KAAKU,MAAM,EACXT,IAAKU,CAAAA,KAAK,EACVV,IAAKW,CAAAA,MAAM,EACXP,WAAAA,EACAF,UAEFL,CAAAA,GAAAA,MAAAA,CAAOU,IAAI,CAACK,sBAAsB,CAAC,KAAA,EAAOb,IAAKU,CAAAA,MAAM,EAAET,IAAKU,CAAAA,KAAK,EAAEV,IAAAA,CAAKW,MAAM,EAAET,UAAAA,CAAAA;QACtF,IAAIH,IAAAA,CAAKI,SAAS,IAAIE,OAAAA,CAAQQ,aAAa,GAAGd,IAAAA,CAAKI,SAAS,EAAE;YAC5DN,MAAOU,CAAAA,IAAI,CAACO,cAAc,CAACT,OAAAA,CAAAA;YAC3B,MAAM,IAAIU,KACR,CAAA,CAAC,8BAA8B,EAAEhB,KAAKiB,KAAK,IAAI,WAAY,CAAA,YAAY,EAAEjB,IAAAA,CAAKI,SAAS,CAAC,CAAC,CAAC,GACxF,CAAC,qBAA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IAAAA,CAAKgC,eAAe,IAAI,CAAA,CAAA;AAE5B;AAEA;;;;MAKAC,kBAAAA,CAAmBC,WAAwB,EAAQ;AACjD,QAAA,MAAMpC,MAAS,GAAA,IAAI,CAACD,OAAO,IAAIK,SAAAA,EAAAA;QAC/BJ,MAAOU,CAAAA,IAAI,CAAC2B,kBAAkB,CAACD,WAAAA,CAAAA;AACjC;AACF;;;;"}
|
|
@@ -39,6 +39,7 @@ const DEFAULT_PROFILING_OPTIONS = {
|
|
|
39
39
|
/** @internal */ _allocatedTextures = new Map();
|
|
40
40
|
/** @internal */ _allocatedFramebuffers = new Map();
|
|
41
41
|
/** @internal */ _importedTextureAliases = new Map();
|
|
42
|
+
/** @internal */ _transientTextureAliases = new Map();
|
|
42
43
|
/** @internal */ _resolvedImportedTextures = new Map();
|
|
43
44
|
/** @internal */ _cleanupCallbacks = [];
|
|
44
45
|
/** @internal */ _profilingOptions;
|
|
@@ -113,16 +114,27 @@ const DEFAULT_PROFILING_OPTIONS = {
|
|
|
113
114
|
const releaseAt = new Map(); // passIndex -> transient texture resourceIds to release
|
|
114
115
|
const allocateFramebufferAt = new Map(); // passIndex -> framebuffer resourceIds to allocate
|
|
115
116
|
const releaseFramebufferAt = new Map(); // passIndex -> framebuffer resourceIds to release
|
|
117
|
+
// Transient write-versions (builder.write on a transient) alias the same
|
|
118
|
+
// physical texture as the original resource: merge their lifetimes by
|
|
119
|
+
// physicalId so one texture is allocated at the first use of any version
|
|
120
|
+
// and released after the last use of any version.
|
|
121
|
+
this._transientTextureAliases.clear();
|
|
122
|
+
const transientSchedules = new Map();
|
|
116
123
|
for (const [resId, lifetime] of compiled.lifetimes){
|
|
117
124
|
if (lifetime.resource.kind === 'transient') {
|
|
118
|
-
|
|
119
|
-
|
|
125
|
+
const physicalId = lifetime.resource.physicalId;
|
|
126
|
+
this._transientTextureAliases.set(resId, physicalId);
|
|
127
|
+
const merged = transientSchedules.get(physicalId);
|
|
128
|
+
if (merged) {
|
|
129
|
+
merged.firstUse = Math.min(merged.firstUse, lifetime.firstUse);
|
|
130
|
+
merged.lastUse = Math.max(merged.lastUse, lifetime.lastUse);
|
|
131
|
+
} else {
|
|
132
|
+
transientSchedules.set(physicalId, {
|
|
133
|
+
firstUse: lifetime.firstUse,
|
|
134
|
+
lastUse: lifetime.lastUse,
|
|
135
|
+
desc: lifetime.resource.desc
|
|
136
|
+
});
|
|
120
137
|
}
|
|
121
|
-
allocateAt.get(lifetime.firstUse).push(resId);
|
|
122
|
-
if (!releaseAt.has(lifetime.lastUse)) {
|
|
123
|
-
releaseAt.set(lifetime.lastUse, []);
|
|
124
|
-
}
|
|
125
|
-
releaseAt.get(lifetime.lastUse).push(resId);
|
|
126
138
|
} else if (lifetime.resource.kind === 'framebuffer') {
|
|
127
139
|
if (!allocateFramebufferAt.has(lifetime.firstUse)) {
|
|
128
140
|
allocateFramebufferAt.set(lifetime.firstUse, []);
|
|
@@ -134,6 +146,16 @@ const DEFAULT_PROFILING_OPTIONS = {
|
|
|
134
146
|
releaseFramebufferAt.get(lifetime.lastUse).push(resId);
|
|
135
147
|
}
|
|
136
148
|
}
|
|
149
|
+
for (const [physicalId, schedule] of transientSchedules){
|
|
150
|
+
if (!allocateAt.has(schedule.firstUse)) {
|
|
151
|
+
allocateAt.set(schedule.firstUse, []);
|
|
152
|
+
}
|
|
153
|
+
allocateAt.get(schedule.firstUse).push(physicalId);
|
|
154
|
+
if (!releaseAt.has(schedule.lastUse)) {
|
|
155
|
+
releaseAt.set(schedule.lastUse, []);
|
|
156
|
+
}
|
|
157
|
+
releaseAt.get(schedule.lastUse).push(physicalId);
|
|
158
|
+
}
|
|
137
159
|
let completed = false;
|
|
138
160
|
let executionError = null;
|
|
139
161
|
try {
|
|
@@ -143,10 +165,9 @@ const DEFAULT_PROFILING_OPTIONS = {
|
|
|
143
165
|
const toAllocate = allocateAt.get(i);
|
|
144
166
|
if (toAllocate) {
|
|
145
167
|
for (const resId of toAllocate){
|
|
146
|
-
const
|
|
147
|
-
const
|
|
148
|
-
const
|
|
149
|
-
const texture = this._allocator.allocate(desc, size);
|
|
168
|
+
const schedule = transientSchedules.get(resId);
|
|
169
|
+
const size = this._resolveSize(schedule.desc);
|
|
170
|
+
const texture = this._allocator.allocate(schedule.desc, size);
|
|
150
171
|
this._allocatedTextures.set(resId, texture);
|
|
151
172
|
}
|
|
152
173
|
}
|
|
@@ -268,6 +289,7 @@ const DEFAULT_PROFILING_OPTIONS = {
|
|
|
268
289
|
this._allocatedTextures.clear();
|
|
269
290
|
this._importedTextures.clear();
|
|
270
291
|
this._importedTextureAliases.clear();
|
|
292
|
+
this._transientTextureAliases.clear();
|
|
271
293
|
this._resolvedImportedTextures.clear();
|
|
272
294
|
}
|
|
273
295
|
// ─── Private ────────────────────────────────────────────────────────
|
|
@@ -593,6 +615,14 @@ const DEFAULT_PROFILING_OPTIONS = {
|
|
|
593
615
|
if (allocated !== undefined) {
|
|
594
616
|
return allocated;
|
|
595
617
|
}
|
|
618
|
+
// Transient write-versions resolve to the physical texture of the original.
|
|
619
|
+
const transientAlias = this._transientTextureAliases.get(handle._id);
|
|
620
|
+
if (transientAlias !== undefined) {
|
|
621
|
+
const aliased = this._allocatedTextures.get(transientAlias);
|
|
622
|
+
if (aliased !== undefined) {
|
|
623
|
+
return aliased;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
596
626
|
throw new Error(`RenderGraphExecutor: cannot resolve resource "${handle.name}" (id=${handle._id}). ` + `It may not have been allocated yet or was already released.`);
|
|
597
627
|
}
|
|
598
628
|
/** @internal */ _createAccessScope(pass) {
|