@forgeax/engine-render 0.1.33 → 0.1.35
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/README.md +1062 -127
- package/dist/assembly/backend-contract.d.ts +2 -0
- package/dist/assembly/backend-contract.d.ts.map +1 -1
- package/dist/assembly/barrel-distortion-inspection.d.ts +3 -0
- package/dist/assembly/barrel-distortion-inspection.d.ts.map +1 -0
- package/dist/assembly/canvas-draw-guard.d.ts +3 -0
- package/dist/assembly/canvas-draw-guard.d.ts.map +1 -0
- package/dist/assembly/cloud-shadow-entry.d.ts +4 -0
- package/dist/assembly/cloud-shadow-entry.d.ts.map +1 -0
- package/dist/assembly/device-feature-admission.d.ts +2 -2
- package/dist/assembly/dynamic-geometry-host.d.ts +4 -1
- package/dist/assembly/dynamic-geometry-host.d.ts.map +1 -1
- package/dist/assembly/dynamic-geometry-runtime.d.ts +1 -1
- package/dist/assembly/dynamic-geometry-runtime.d.ts.map +1 -1
- package/dist/assembly/factory.d.ts +1 -1
- package/dist/assembly/factory.d.ts.map +1 -1
- package/dist/assembly/host-contract.d.ts +6 -5
- package/dist/assembly/host-contract.d.ts.map +1 -1
- package/dist/assembly/material/assembly.d.ts.map +1 -1
- package/dist/assembly/material/pipeline-helpers.d.ts +5 -0
- package/dist/assembly/material/pipeline-helpers.d.ts.map +1 -1
- package/dist/assembly/material-shader-policy.d.ts +16 -2
- package/dist/assembly/material-shader-policy.d.ts.map +1 -1
- package/dist/assembly/material-shader-prewarm.d.ts.map +1 -1
- package/dist/assembly/recovery/device-loss-fanout.d.ts.map +1 -1
- package/dist/assembly/recovery/renderer-recover.d.ts +2 -0
- package/dist/assembly/recovery/renderer-recover.d.ts.map +1 -1
- package/dist/assembly/render-feature-post-processes.d.ts +6 -0
- package/dist/assembly/render-feature-post-processes.d.ts.map +1 -0
- package/dist/assembly/render-target-host.d.ts +5 -0
- package/dist/assembly/render-target-host.d.ts.map +1 -1
- package/dist/assembly/renderer-facade.d.ts.map +1 -1
- package/dist/assembly/renderer-feature-inspection.d.ts +1 -1
- package/dist/assembly/renderer-feature-inspection.d.ts.map +1 -1
- package/dist/assembly/renderer-frame-transaction.d.ts +12 -0
- package/dist/assembly/renderer-frame-transaction.d.ts.map +1 -1
- package/dist/assembly/renderer-inspection.d.ts +11 -0
- package/dist/assembly/renderer-inspection.d.ts.map +1 -1
- package/dist/assembly/webgpu-pbr-ready.d.ts +1 -0
- package/dist/assembly/webgpu-pbr-ready.d.ts.map +1 -1
- package/dist/assembly/webgpu-ready-per-pass.d.ts +39 -0
- package/dist/assembly/webgpu-ready-per-pass.d.ts.map +1 -0
- package/dist/assembly/webgpu-ready.d.ts +1 -1
- package/dist/assembly/webgpu-ready.d.ts.map +1 -1
- package/dist/assembly/webgpu-renderer-bootstrap.d.ts.map +1 -1
- package/dist/assembly/webgpu-renderer-observation-owner.d.ts +35 -0
- package/dist/assembly/webgpu-renderer-observation-owner.d.ts.map +1 -0
- package/dist/assembly/webgpu-renderer.d.ts +2 -1
- package/dist/assembly/webgpu-renderer.d.ts.map +1 -1
- package/dist/authoring.mjs +2 -4
- package/dist/authoring.mjs.map +1 -1
- package/dist/barrel-distortion.d.ts +47 -0
- package/dist/barrel-distortion.d.ts.map +1 -0
- package/dist/chunk-3XUBWRY2.mjs +1842 -0
- package/dist/chunk-3XUBWRY2.mjs.map +1 -0
- package/dist/{chunk-OO3DRYK7.mjs → chunk-G6HDNGY7.mjs} +2400 -1767
- package/dist/chunk-G6HDNGY7.mjs.map +1 -0
- package/dist/{chunk-ZDQWGQW7.mjs → chunk-LM5IE7GF.mjs} +4 -4
- package/dist/{chunk-ZDQWGQW7.mjs.map → chunk-LM5IE7GF.mjs.map} +1 -1
- package/dist/{chunk-VOZWDM3L.mjs → chunk-LNIUIKQ7.mjs} +1514 -498
- package/dist/chunk-LNIUIKQ7.mjs.map +1 -0
- package/dist/chunk-MXTWKZO4.mjs +3268 -0
- package/dist/chunk-MXTWKZO4.mjs.map +1 -0
- package/dist/chunk-MZ4C7EHF.mjs +6942 -0
- package/dist/chunk-MZ4C7EHF.mjs.map +1 -0
- package/dist/chunk-RIPAEGI6.mjs +48 -0
- package/dist/chunk-RIPAEGI6.mjs.map +1 -0
- package/dist/{chunk-LEAXOMYJ.mjs → chunk-SGPUJW3F.mjs} +117 -5
- package/dist/chunk-SGPUJW3F.mjs.map +1 -0
- package/dist/{chunk-PA5DRJNI.mjs → chunk-X2KA6WHM.mjs} +29 -4
- package/dist/chunk-X2KA6WHM.mjs.map +1 -0
- package/dist/{chunk-BLXGONR2.mjs → chunk-XSFB7XXQ.mjs} +51 -4
- package/dist/chunk-XSFB7XXQ.mjs.map +1 -0
- package/dist/cloud/density.d.ts +55 -0
- package/dist/cloud/density.d.ts.map +1 -0
- package/dist/cloud/extract.d.ts +25 -0
- package/dist/cloud/extract.d.ts.map +1 -0
- package/dist/cloud/feature.d.ts +57 -0
- package/dist/cloud/feature.d.ts.map +1 -0
- package/dist/cloud/frame-context.d.ts +8 -0
- package/dist/cloud/frame-context.d.ts.map +1 -0
- package/dist/cloud/inspection.d.ts +59 -0
- package/dist/cloud/inspection.d.ts.map +1 -0
- package/dist/cloud/optics.d.ts +56 -0
- package/dist/cloud/optics.d.ts.map +1 -0
- package/dist/cloud/parameters.d.ts +73 -0
- package/dist/cloud/parameters.d.ts.map +1 -0
- package/dist/cloud/resources.d.ts +60 -0
- package/dist/cloud/resources.d.ts.map +1 -0
- package/dist/cloud/shadow.d.ts +42 -0
- package/dist/cloud/shadow.d.ts.map +1 -0
- package/dist/cloud/temporal.d.ts +74 -0
- package/dist/cloud/temporal.d.ts.map +1 -0
- package/dist/components/barrel-distortion.d.ts +13 -0
- package/dist/components/barrel-distortion.d.ts.map +1 -0
- package/dist/components/cloud-layer.d.ts +29 -0
- package/dist/components/cloud-layer.d.ts.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/instances.d.ts +20 -6
- package/dist/components/instances.d.ts.map +1 -1
- package/dist/construct-renderer.d.ts +1 -1
- package/dist/construct-renderer.d.ts.map +1 -1
- package/dist/construct-renderer.mjs +8406 -5785
- package/dist/construct-renderer.mjs.map +1 -1
- package/dist/device/gpu-residency.d.ts +19 -19
- package/dist/device/gpu-residency.d.ts.map +1 -1
- package/dist/dynamic-geometry.d.ts +5 -1
- package/dist/dynamic-geometry.d.ts.map +1 -1
- package/dist/errors/cloud.d.ts +59 -0
- package/dist/errors/cloud.d.ts.map +1 -0
- package/dist/errors/render.d.ts +20 -5
- package/dist/errors/render.d.ts.map +1 -1
- package/dist/examples/single-layer-medium-surface.d.ts +47 -0
- package/dist/examples/single-layer-medium-surface.d.ts.map +1 -0
- package/dist/extract/camera.d.ts.map +1 -1
- package/dist/extract/contracts.d.ts +5 -1
- package/dist/extract/contracts.d.ts.map +1 -1
- package/dist/extract/material-context.d.ts +7 -0
- package/dist/extract/material-context.d.ts.map +1 -0
- package/dist/features/barrel-distortion.d.ts +29 -0
- package/dist/features/barrel-distortion.d.ts.map +1 -0
- package/dist/features/error-reporting.d.ts +6 -2
- package/dist/features/error-reporting.d.ts.map +1 -1
- package/dist/features/host.d.ts +15 -0
- package/dist/features/host.d.ts.map +1 -1
- package/dist/features/plan.d.ts +10 -0
- package/dist/features/plan.d.ts.map +1 -1
- package/dist/features/render-graph-contribution.d.ts +5 -0
- package/dist/features/render-graph-contribution.d.ts.map +1 -1
- package/dist/features/render-graph-raster.d.ts +1 -0
- package/dist/features/render-graph-raster.d.ts.map +1 -1
- package/dist/features/targets.d.ts +2 -0
- package/dist/features/targets.d.ts.map +1 -1
- package/dist/features/types.d.ts +48 -0
- package/dist/features/types.d.ts.map +1 -1
- package/dist/fullscreen-post-process-pass.d.ts +15 -7
- package/dist/fullscreen-post-process-pass.d.ts.map +1 -1
- package/dist/glyph-text-layout-system.d.ts +1 -1
- package/dist/glyph-text-layout-system.d.ts.map +1 -1
- package/dist/gpu-dirty-ranges.d.ts +11 -0
- package/dist/gpu-dirty-ranges.d.ts.map +1 -0
- package/dist/gpu-driven/batch-topology.d.ts +17 -0
- package/dist/gpu-driven/batch-topology.d.ts.map +1 -1
- package/dist/gpu-driven/material-artifacts.d.ts +6 -0
- package/dist/gpu-driven/material-artifacts.d.ts.map +1 -1
- package/dist/gpu-driven/prepared-draw.d.ts.map +1 -1
- package/dist/gpu-driven/production-raster-material.d.ts +178 -0
- package/dist/gpu-driven/production-raster-material.d.ts.map +1 -0
- package/dist/gpu-driven/production-raster.d.ts +47 -3
- package/dist/gpu-driven/production-raster.d.ts.map +1 -1
- package/dist/gpu-driven/resource-allocation.d.ts +31 -0
- package/dist/gpu-driven/resource-allocation.d.ts.map +1 -0
- package/dist/gpu-driven/shadow-ownership.d.ts +14 -0
- package/dist/gpu-driven/shadow-ownership.d.ts.map +1 -0
- package/dist/gpu-driven/view-gpu.d.ts +26 -2
- package/dist/gpu-driven/view-gpu.d.ts.map +1 -1
- package/dist/gpu-scene.d.ts +5 -0
- package/dist/gpu-scene.d.ts.map +1 -1
- package/dist/hdrp-buffers.d.ts +2 -2
- package/dist/hdrp-buffers.d.ts.map +1 -1
- package/dist/ibl/frame-resources.d.ts.map +1 -1
- package/dist/ibl/skylight-bind-group.d.ts +14 -5
- package/dist/ibl/skylight-bind-group.d.ts.map +1 -1
- package/dist/index.d.ts +30 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +780 -9
- package/dist/index.mjs.map +1 -1
- package/dist/inspection-types.d.ts +135 -1
- package/dist/inspection-types.d.ts.map +1 -1
- package/dist/instance-buffer-cache.d.ts +4 -4
- package/dist/instance-buffer-cache.d.ts.map +1 -1
- package/dist/instances.d.ts +47 -100
- package/dist/instances.d.ts.map +1 -1
- package/dist/internal.mjs +7 -8
- package/dist/internal.mjs.map +1 -1
- package/dist/pbr-pipeline.d.ts +22 -4
- package/dist/pbr-pipeline.d.ts.map +1 -1
- package/dist/pipeline/single-layer-medium-passes.d.ts +73 -0
- package/dist/pipeline/single-layer-medium-passes.d.ts.map +1 -0
- package/dist/pipeline/standard-forward-lane.d.ts.map +1 -1
- package/dist/pipeline/standard-output/graph.d.ts.map +1 -1
- package/dist/pipeline/standard-output/lut-gpu.d.ts +2 -2
- package/dist/pipeline/standard-output/lut-gpu.d.ts.map +1 -1
- package/dist/pipeline/standard-output/resources.d.ts +2 -2
- package/dist/pipeline/standard-output/resources.d.ts.map +1 -1
- package/dist/pipeline/standard-output/types.d.ts +4 -2
- package/dist/pipeline/standard-output/types.d.ts.map +1 -1
- package/dist/pipeline/standard-pipeline.d.ts.map +1 -1
- package/dist/pipeline/standard-post.d.ts.map +1 -1
- package/dist/pipeline-builder.d.ts +1 -1
- package/dist/pipeline-builder.d.ts.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/prepare/prepared-graphics-resolver.d.ts +2 -0
- package/dist/prepare/prepared-graphics-resolver.d.ts.map +1 -1
- package/dist/publication/contract.d.ts +77 -0
- package/dist/publication/contract.d.ts.map +1 -0
- package/dist/publication/dependencies.d.ts +7 -0
- package/dist/publication/dependencies.d.ts.map +1 -0
- package/dist/publication/prepare-geometry.d.ts +9 -0
- package/dist/publication/prepare-geometry.d.ts.map +1 -0
- package/dist/publication/programs.d.ts +5 -0
- package/dist/publication/programs.d.ts.map +1 -0
- package/dist/publication/publisher.d.ts +33 -0
- package/dist/publication/publisher.d.ts.map +1 -0
- package/dist/publication/receiver.d.ts +29 -0
- package/dist/publication/receiver.d.ts.map +1 -0
- package/dist/publication/resource-scope.d.ts +18 -0
- package/dist/publication/resource-scope.d.ts.map +1 -0
- package/dist/publication/targets.d.ts +33 -0
- package/dist/publication/targets.d.ts.map +1 -0
- package/dist/publication/video.d.ts +5 -0
- package/dist/publication/video.d.ts.map +1 -0
- package/dist/record/barrel-distortion-frame.d.ts +15 -0
- package/dist/record/barrel-distortion-frame.d.ts.map +1 -0
- package/dist/record/dynamic-geometry-consumption.d.ts +10 -2
- package/dist/record/dynamic-geometry-consumption.d.ts.map +1 -1
- package/dist/record/fold-buckets.d.ts +95 -0
- package/dist/record/fold-buckets.d.ts.map +1 -0
- package/dist/record/fold-instance-buffer.d.ts +6 -0
- package/dist/record/fold-instance-buffer.d.ts.map +1 -0
- package/dist/record/frame-lighting.d.ts +1 -0
- package/dist/record/frame-lighting.d.ts.map +1 -1
- package/dist/record/frame-snapshot.d.ts +43 -9
- package/dist/record/frame-snapshot.d.ts.map +1 -1
- package/dist/record/frame.d.ts +15 -65
- package/dist/record/frame.d.ts.map +1 -1
- package/dist/record/gpu-draw-receipts.d.ts +11 -0
- package/dist/record/gpu-draw-receipts.d.ts.map +1 -0
- package/dist/record/gpu-timing.d.ts +8 -0
- package/dist/record/gpu-timing.d.ts.map +1 -1
- package/dist/record/helpers.d.ts +2 -2
- package/dist/record/helpers.d.ts.map +1 -1
- package/dist/record/main-pass-geometry.d.ts +22 -6
- package/dist/record/main-pass-geometry.d.ts.map +1 -1
- package/dist/record/main-pass-material.d.ts +14 -10
- package/dist/record/main-pass-material.d.ts.map +1 -1
- package/dist/record/main-pass-sprite-draws.d.ts +3 -16
- package/dist/record/main-pass-sprite-draws.d.ts.map +1 -1
- package/dist/record/main-pass.d.ts +13 -2
- package/dist/record/main-pass.d.ts.map +1 -1
- package/dist/record/motion-blur-receipt.d.ts +11 -0
- package/dist/record/motion-blur-receipt.d.ts.map +1 -0
- package/dist/record/prepared-material-bindings.d.ts +3 -3
- package/dist/record/prepared-material-bindings.d.ts.map +1 -1
- package/dist/record/probe-blend-buffer.d.ts +16 -0
- package/dist/record/probe-blend-buffer.d.ts.map +1 -0
- package/dist/record/recovery-pipeline.d.ts.map +1 -1
- package/dist/record/render-context.d.ts +24 -5
- package/dist/record/render-context.d.ts.map +1 -1
- package/dist/record/shadow-pass.d.ts +2 -0
- package/dist/record/shadow-pass.d.ts.map +1 -1
- package/dist/record/skybox-post-pass.d.ts +1 -1
- package/dist/record/skybox-post-pass.d.ts.map +1 -1
- package/dist/record/sprite-instance-buffer.d.ts +31 -0
- package/dist/record/sprite-instance-buffer.d.ts.map +1 -0
- package/dist/record/target-capture-graph.d.ts +19 -0
- package/dist/record/target-capture-graph.d.ts.map +1 -0
- package/dist/record/typed-frame-graph.d.ts +24 -15
- package/dist/record/typed-frame-graph.d.ts.map +1 -1
- package/dist/record/view-ubo.d.ts +11 -3
- package/dist/record/view-ubo.d.ts.map +1 -1
- package/dist/record/volume-params.d.ts +9 -0
- package/dist/record/volume-params.d.ts.map +1 -0
- package/dist/recovery/render-system-candidate.d.ts +14 -4
- package/dist/recovery/render-system-candidate.d.ts.map +1 -1
- package/dist/reflection/record-owner.d.ts.map +1 -1
- package/dist/render-contract.d.ts +46 -5
- package/dist/render-contract.d.ts.map +1 -1
- package/dist/render-graph-primitives.d.ts.map +1 -1
- package/dist/render-pipeline.d.ts +103 -2
- package/dist/render-pipeline.d.ts.map +1 -1
- package/dist/render-system-extract-tail.d.ts +3 -2
- package/dist/render-system-extract-tail.d.ts.map +1 -1
- package/dist/render-system-extract.d.ts +18 -9
- package/dist/render-system-extract.d.ts.map +1 -1
- package/dist/render-system-presentation.d.ts +23 -0
- package/dist/render-system-presentation.d.ts.map +1 -0
- package/dist/render-system-producer-roots.d.ts +10 -0
- package/dist/render-system-producer-roots.d.ts.map +1 -0
- package/dist/render-system-projections.d.ts +3 -2
- package/dist/render-system-projections.d.ts.map +1 -1
- package/dist/render-system-residency.d.ts +12 -0
- package/dist/render-system-residency.d.ts.map +1 -0
- package/dist/render-system.d.ts +22 -21
- package/dist/render-system.d.ts.map +1 -1
- package/dist/scene/probe-blend.d.ts +27 -0
- package/dist/scene/probe-blend.d.ts.map +1 -1
- package/dist/scene/render-scene.d.ts +18 -7
- package/dist/scene/render-scene.d.ts.map +1 -1
- package/dist/scene/render-source.d.ts +42 -0
- package/dist/scene/render-source.d.ts.map +1 -0
- package/dist/scene/source-systems.d.ts +6 -0
- package/dist/scene/source-systems.d.ts.map +1 -0
- package/dist/ssao-buffers.d.ts +9 -0
- package/dist/ssao-buffers.d.ts.map +1 -1
- package/dist/surface/dynamic-input.d.ts +133 -0
- package/dist/surface/dynamic-input.d.ts.map +1 -0
- package/dist/surface/gpu-driven.d.ts +41 -0
- package/dist/surface/gpu-driven.d.ts.map +1 -0
- package/dist/surface/submission-observation.d.ts +136 -0
- package/dist/surface/submission-observation.d.ts.map +1 -0
- package/dist/systems/skin-palette-allocator.d.ts.map +1 -1
- package/dist/systems/skin-palette-types.d.ts +10 -0
- package/dist/systems/skin-palette-types.d.ts.map +1 -1
- package/dist/systems/transparent-dispatch.d.ts +2 -2
- package/dist/systems/transparent-dispatch.d.ts.map +1 -1
- package/dist/systems/transparent-sort-config.d.ts +2 -1
- package/dist/systems/transparent-sort-config.d.ts.map +1 -1
- package/dist/temporal/gpu.d.ts +13 -1
- package/dist/temporal/gpu.d.ts.map +1 -1
- package/dist/temporal/index.mjs +6 -7
- package/dist/temporal/inspection.d.ts.map +1 -1
- package/dist/temporal/standard-scene-data.d.ts.map +1 -1
- package/dist/temporal/target-coverage-attachment.d.ts.map +1 -1
- package/dist/transmission/single-layer-medium.d.ts +89 -0
- package/dist/transmission/single-layer-medium.d.ts.map +1 -0
- package/dist/typed-render-graph-primitives.d.ts +14 -2
- package/dist/typed-render-graph-primitives.d.ts.map +1 -1
- package/dist/volume/component.d.ts +9 -4
- package/dist/volume/component.d.ts.map +1 -1
- package/dist/volume/extract.d.ts +1 -1
- package/dist/volume/extract.d.ts.map +1 -1
- package/dist/volume/inspection.d.ts +2 -0
- package/dist/volume/inspection.d.ts.map +1 -1
- package/dist/volume/passes.d.ts +4 -1
- package/dist/volume/passes.d.ts.map +1 -1
- package/dist/volume/resources.d.ts.map +1 -1
- package/package.json +22 -21
- package/src/__tests__/atmosphere-daylight.dawn.test.ts +72 -0
- package/src/__tests__/auto-exposure-transaction.integration.test.ts +4 -9
- package/src/__tests__/barrel-distortion-lkg.integration.test.ts +353 -0
- package/src/__tests__/barrel-distortion.dawn.test.ts +41 -0
- package/src/__tests__/barrel-distortion.unit.test.ts +364 -0
- package/src/__tests__/construct-renderer-identity.unit.test.ts +49 -0
- package/src/__tests__/detached-recovery-graph.unit.test.ts +277 -0
- package/src/__tests__/device-feature-admission.unit.test.ts +3 -2
- package/src/__tests__/device-loss-fanout.unit.test.ts +36 -1
- package/src/__tests__/docs-gate-green.unit.test.ts +112 -1
- package/src/__tests__/factory-contract.integration.test.ts +295 -45
- package/src/__tests__/feature-depth-input.dawn.test.ts +129 -2
- package/src/__tests__/fullscreen-feature-plan.unit.test.ts +14 -3
- package/src/__tests__/gpu-dirty-ranges.unit.test.ts +22 -0
- package/src/__tests__/gpu-driven-baseline.characterization.test.ts +16 -3
- package/src/__tests__/gpu-driven-batch-topology-pbr.unit.test.ts +12 -0
- package/src/__tests__/gpu-driven-material-artifacts.unit.test.ts +143 -0
- package/src/__tests__/gpu-driven-pbr.dawn.test.ts +5 -6
- package/src/__tests__/gpu-driven-production.integration.test.ts +482 -3
- package/src/__tests__/gpu-driven-shadow-views.dawn.test.ts +6 -5
- package/src/__tests__/gpu-driven-view-gpu-evidence.ts +94 -6
- package/src/__tests__/gpu-driven-view-graph.integration.test.ts +18 -2
- package/src/__tests__/gpu-driven-view.browser.test.ts +5 -8
- package/src/__tests__/gpu-driven-view.dawn.test.ts +6 -2
- package/src/__tests__/gpu-driven-view.unit.test.ts +1 -1
- package/src/__tests__/gpu-pass-timing-lifecycle.integration.test.ts +1 -0
- package/src/__tests__/gpu-pass-timing.browser.test.ts +6 -4
- package/src/__tests__/gpu-pass-timing.rhi-null.unit.test.ts +1 -0
- package/src/__tests__/gpu-scene.unit.test.ts +119 -9
- package/src/__tests__/instance-allocation-failure.unit.test.ts +57 -0
- package/src/__tests__/instances-culling.integration.test.ts +10 -36
- package/src/__tests__/instances-store.unit.test.ts +97 -305
- package/src/__tests__/instances-world-ownership.integration.test.ts +62 -0
- package/src/__tests__/ktx2-basis-gpu-consumer.dawn.test.ts +4 -1
- package/src/__tests__/main-pass-material-medium-selection.unit.test.ts +145 -0
- package/src/__tests__/material-shader-prewarm.unit.test.ts +59 -0
- package/src/__tests__/material-snapshot-mutation.integration.test.ts +39 -1
- package/src/__tests__/materials-standard-contract.unit.test.ts +0 -1
- package/src/__tests__/morph-culling-reentry.dawn.test.ts +5 -5
- package/src/__tests__/morph-visual-evidence.integration.test.ts +8 -7
- package/src/__tests__/motion-blur-compute.dawn.test.ts +13 -7
- package/src/__tests__/motion-blur.pixel.integration.test.ts +2 -2
- package/src/__tests__/nineslice-handle-surface.unit.test.ts +4 -4
- package/src/__tests__/pbr-view-layout.unit.test.ts +9 -0
- package/src/__tests__/physical-clearcoat.integration.test.ts +66 -8
- package/src/__tests__/physical-material-budget.unit.test.ts +40 -0
- package/src/__tests__/prepared-graphics-capability.unit.test.ts +66 -2
- package/src/__tests__/probe-bindings.unit.test.ts +582 -1
- package/src/__tests__/probe-scene-dirty.integration.test.ts +28 -1
- package/src/__tests__/receipt-observation-retirement.unit.test.ts +65 -0
- package/src/__tests__/recovery-candidate-prepare.contract.test.ts +69 -0
- package/src/__tests__/render-error-code-owner.test-d.ts +8 -0
- package/src/__tests__/render-feature-diagnostics.unit.test.ts +15 -2
- package/src/__tests__/render-feature-error-reporting.unit.test.ts +21 -1
- package/src/__tests__/render-feature-prepared-diagnostics.unit.test.ts +10 -1
- package/src/__tests__/render-feature-retry.unit.test.ts +12 -1
- package/src/__tests__/render-scene-mixed-updates.integration.test.ts +145 -19
- package/src/__tests__/render-scene-projection.unit.test.ts +36 -11
- package/src/__tests__/render-scene-temporal-retry.unit.test.ts +20 -20
- package/src/__tests__/render-target-probe-soak.perf.test.ts +2 -2
- package/src/__tests__/render-temporal-environment-consumer.browser.test.ts +3 -3
- package/src/__tests__/render-temporal-environment-consumer.dawn.test.ts +5 -2
- package/src/__tests__/renderer-factory-material-contract.unit.test.ts +42 -8
- package/src/__tests__/renderer-frame-generation-fence.integration.test.ts +16 -0
- package/src/__tests__/renderer-frame-transaction.integration.test.ts +26 -10
- package/src/__tests__/resource-allocation.unit.test.ts +123 -0
- package/src/__tests__/single-layer-medium-passes.unit.test.ts +275 -0
- package/src/__tests__/skin-motion-regression.unit.test.ts +70 -1
- package/src/__tests__/skin-palette-recycling.dawn.test.ts +97 -0
- package/src/__tests__/skinned-shadow-caster.test.ts +15 -0
- package/src/__tests__/ssr-carrier-public-contract.unit.test.ts +21 -0
- package/src/__tests__/ssr-gpu-dispatch.browser.test.ts +4 -4
- package/src/__tests__/ssr-gpu-dispatch.dawn.test.ts +2 -2
- package/src/__tests__/ssr-gpu-dispatch.ts +1 -1
- package/src/__tests__/ssr-receiver-coverage.dawn.test.ts +6 -2
- package/src/__tests__/standard-output-chain-contract.unit.test.ts +28 -0
- package/src/__tests__/standard-pbr-artifact-assembly.unit.test.ts +46 -1
- package/src/__tests__/standard-pipeline.integration.test.ts +182 -1
- package/src/__tests__/surface-dynamic-buffer-lifecycle.unit.test.ts +506 -0
- package/src/__tests__/surface-submission-observation.unit.test.ts +812 -0
- package/src/__tests__/temporal-history-lifecycle.unit.test.ts +32 -0
- package/src/__tests__/temporal-performance.integration.test.ts +3 -3
- package/src/__tests__/visibility-instances.integration.test.ts +7 -19
- package/src/__tests__/visibility-producer-matrix.integration.test.ts +9 -20
- package/src/__tests__/volume-optics-oracle.unit.test.ts +4 -2
- package/src/__tests__/volumetric-fog-budget-recovery.integration.test.ts +30 -20
- package/src/__tests__/volumetric-fog-errors.unit.test.ts +4 -3
- package/src/__tests__/volumetric-fog-multiple.unit.test.ts +55 -0
- package/src/__tests__/volumetric-fog-spot-frame-optics.integration.test.ts +1 -1
- package/src/__tests__/volumetric-fog-stage-readback.dawn.test.ts +113 -9
- package/src/__tests__/volumetric-fog-topology.unit.test.ts +5 -3
- package/src/assembly/backend-contract.ts +30 -0
- package/src/assembly/barrel-distortion-inspection.ts +22 -0
- package/src/assembly/canvas-draw-guard.ts +11 -0
- package/src/assembly/cloud-shadow-entry.ts +22 -0
- package/src/assembly/device-feature-admission.ts +2 -2
- package/src/assembly/dynamic-geometry-host.ts +65 -37
- package/src/assembly/dynamic-geometry-runtime.ts +7 -1
- package/src/assembly/factory.ts +2 -30
- package/src/assembly/host-contract.ts +8 -5
- package/src/assembly/material/assembly.ts +25 -13
- package/src/assembly/material/pipeline-helpers.ts +53 -12
- package/src/assembly/material-shader-policy.ts +55 -0
- package/src/assembly/material-shader-prewarm.ts +21 -10
- package/src/assembly/recovery/device-loss-fanout.ts +13 -0
- package/src/assembly/recovery/renderer-recover.ts +50 -18
- package/src/assembly/render-feature-post-processes.ts +54 -0
- package/src/assembly/render-target-host.ts +57 -47
- package/src/assembly/renderer-facade.ts +7 -2
- package/src/assembly/renderer-feature-inspection.ts +8 -2
- package/src/assembly/renderer-frame-transaction.ts +23 -0
- package/src/assembly/renderer-inspection.ts +28 -0
- package/src/assembly/skin-palette-owner.ts +1 -1
- package/src/assembly/temporal-post-process-prewarm.ts +3 -3
- package/src/assembly/webgpu-pbr-ready.ts +9 -1
- package/src/assembly/webgpu-ready-per-pass.ts +104 -0
- package/src/assembly/webgpu-ready.ts +116 -62
- package/src/assembly/webgpu-renderer-bootstrap.ts +0 -12
- package/src/assembly/webgpu-renderer-observation-owner.ts +222 -0
- package/src/assembly/webgpu-renderer.ts +303 -313
- package/src/assembly/webgpu-vertex-layouts.ts +1 -1
- package/src/barrel-distortion.ts +247 -0
- package/src/cloud/__tests__/cloud-density-parity.dawn.test.ts +173 -0
- package/src/cloud/__tests__/cloud-layer-framebuffer-y.dawn.test.ts +265 -0
- package/src/cloud/__tests__/cloud-layer.browser.test.ts +432 -0
- package/src/cloud/__tests__/cloud-layer.unit.test.ts +634 -0
- package/src/cloud/density.ts +600 -0
- package/src/cloud/extract.ts +110 -0
- package/src/cloud/feature.ts +1810 -0
- package/src/cloud/frame-context.ts +42 -0
- package/src/cloud/inspection.ts +130 -0
- package/src/cloud/optics.ts +285 -0
- package/src/cloud/parameters.ts +255 -0
- package/src/cloud/resources.ts +122 -0
- package/src/cloud/shadow.ts +167 -0
- package/src/cloud/temporal.ts +226 -0
- package/src/components/barrel-distortion.ts +46 -0
- package/src/components/cloud-layer.ts +47 -0
- package/src/components/index.ts +2 -0
- package/src/components/instances.ts +18 -45
- package/src/components/sprite-instances.ts +1 -1
- package/src/construct-renderer.ts +1 -1
- package/src/device/gpu-residency.ts +26 -25
- package/src/dynamic-geometry.ts +12 -1
- package/src/errors/cloud.ts +103 -0
- package/src/errors/render.ts +47 -8
- package/src/examples/single-layer-medium-surface.ts +59 -0
- package/src/extract/camera.ts +15 -1
- package/src/extract/contracts.ts +5 -0
- package/src/extract/material-context.ts +21 -0
- package/src/features/barrel-distortion.ts +172 -0
- package/src/features/error-reporting.ts +26 -6
- package/src/features/host.ts +128 -19
- package/src/features/plan.ts +10 -0
- package/src/features/render-graph-contribution.ts +9 -0
- package/src/features/render-graph-raster.ts +45 -3
- package/src/features/targets.ts +66 -0
- package/src/features/types.ts +51 -0
- package/src/fullscreen-post-process-pass.ts +41 -9
- package/src/glyph-text-layout-system.ts +2 -2
- package/src/gpu-dirty-ranges.ts +48 -0
- package/src/gpu-driven/batch-topology.ts +53 -0
- package/src/gpu-driven/material-artifacts.ts +33 -25
- package/src/gpu-driven/prepared-draw.ts +12 -4
- package/src/gpu-driven/production-raster-material.ts +1894 -0
- package/src/gpu-driven/production-raster.ts +825 -784
- package/src/gpu-driven/resource-allocation.ts +142 -0
- package/src/gpu-driven/shadow-ownership.ts +71 -0
- package/src/gpu-driven/view-gpu.ts +164 -10
- package/src/gpu-scene.ts +75 -84
- package/src/hdrp-buffers.ts +4 -3
- package/src/ibl/frame-resources.ts +0 -1
- package/src/ibl/skylight-bind-group.ts +62 -32
- package/src/index.ts +205 -9
- package/src/inspection-types.ts +162 -0
- package/src/instance-buffer-cache.ts +4 -4
- package/src/instances.ts +152 -569
- package/src/pbr-pipeline.ts +230 -30
- package/src/pipeline/single-layer-medium-passes.ts +267 -0
- package/src/pipeline/standard-forward-lane.ts +313 -57
- package/src/pipeline/standard-output/graph.ts +8 -2
- package/src/pipeline/standard-output/lut-gpu.ts +3 -3
- package/src/pipeline/standard-output/resources.ts +2 -2
- package/src/pipeline/standard-output/types.ts +12 -1
- package/src/pipeline/standard-pipeline.ts +291 -18
- package/src/pipeline/standard-post.ts +90 -24
- package/src/pipeline-builder.ts +1 -1
- package/src/plugin.ts +4 -0
- package/src/points-lines/__tests__/points-lines.bench.ts +17 -8
- package/src/prepare/prepared-graphics-resolver.ts +2 -0
- package/src/publication/__tests__/derived-geometry.integration.test.ts +177 -0
- package/src/publication/__tests__/features.integration.test.ts +122 -0
- package/src/publication/__tests__/programs.unit.test.ts +25 -0
- package/src/publication/__tests__/publication.integration.test.ts +370 -0
- package/src/publication/__tests__/targets.integration.test.ts +120 -0
- package/src/publication/__tests__/video.browser.test.ts +50 -0
- package/src/publication/contract.ts +104 -0
- package/src/publication/dependencies.ts +54 -0
- package/src/publication/prepare-geometry.ts +94 -0
- package/src/publication/programs.ts +45 -0
- package/src/publication/publisher.ts +618 -0
- package/src/publication/receiver.ts +297 -0
- package/src/publication/resource-scope.ts +31 -0
- package/src/publication/targets.ts +182 -0
- package/src/publication/video.ts +33 -0
- package/src/record/__tests__/main-pass-geometry.unit.test.ts +30 -0
- package/src/record/__tests__/material-bg-cache.unit.test.ts +15 -1
- package/src/record/__tests__/sprite-material-abi.unit.test.ts +9 -11
- package/src/record/__tests__/temporal-payload.unit.test.ts +1 -1
- package/src/record/__tests__/transparent-group2-selection.unit.test.ts +11 -0
- package/src/record/__tests__/typed-frame-graph-plan.unit.test.ts +1 -0
- package/src/record/__tests__/video-texture-view.unit.test.ts +9 -9
- package/src/record/__tests__/view-ubo-layout.unit.test.ts +4 -3
- package/src/record/barrel-distortion-frame.ts +110 -0
- package/src/record/dynamic-geometry-consumption.ts +39 -9
- package/src/record/fold-buckets.ts +855 -0
- package/src/record/fold-instance-buffer.ts +51 -0
- package/src/record/frame-lighting.ts +36 -2
- package/src/record/frame-snapshot.ts +45 -9
- package/src/record/frame.ts +258 -1105
- package/src/record/gpu-draw-receipts.ts +38 -0
- package/src/record/gpu-timing.ts +48 -5
- package/src/record/helpers.ts +2 -2
- package/src/record/main-pass-geometry.ts +272 -84
- package/src/record/main-pass-material.ts +102 -36
- package/src/record/main-pass-sprite-draws.ts +13 -217
- package/src/record/main-pass.ts +164 -27
- package/src/record/motion-blur-receipt.ts +91 -0
- package/src/record/prepared-material-bindings.ts +11 -6
- package/src/record/probe-blend-buffer.ts +180 -0
- package/src/record/recovery-pipeline.ts +35 -3
- package/src/record/render-context.ts +41 -5
- package/src/record/shadow-pass.ts +30 -4
- package/src/record/skybox-post-pass.ts +28 -4
- package/src/record/sprite-instance-buffer.ts +155 -0
- package/src/record/target-capture-graph.ts +258 -0
- package/src/record/typed-frame-graph.ts +776 -340
- package/src/record/view-ubo.ts +27 -4
- package/src/record/volume-params.ts +225 -0
- package/src/recovery/render-system-candidate.ts +243 -50
- package/src/reflection/record-owner.ts +7 -3
- package/src/render-contract.ts +54 -5
- package/src/render-graph-primitives.ts +7 -1
- package/src/render-pipeline.ts +130 -0
- package/src/render-system-extract-tail.ts +90 -78
- package/src/render-system-extract.ts +76 -76
- package/src/render-system-presentation.ts +56 -0
- package/src/render-system-producer-roots.ts +96 -0
- package/src/render-system-projections.ts +3 -2
- package/src/render-system-residency.ts +159 -0
- package/src/render-system.ts +421 -408
- package/src/scene/probe-blend.ts +96 -4
- package/src/scene/render-scene.ts +416 -337
- package/src/scene/render-source.ts +90 -0
- package/src/scene/source-systems.ts +33 -0
- package/src/ssao-buffers.ts +95 -2
- package/src/surface/__tests__/dynamic-input.unit.test.ts +374 -0
- package/src/surface/__tests__/gpu-driven.unit.test.ts +87 -0
- package/src/surface/dynamic-input.ts +658 -0
- package/src/surface/gpu-driven.ts +147 -0
- package/src/surface/submission-observation.ts +517 -0
- package/src/systems/skin-palette-allocator.ts +5 -1
- package/src/systems/skin-palette-types.ts +11 -0
- package/src/systems/transparent-dispatch.ts +2 -2
- package/src/systems/transparent-sort-config.ts +3 -1
- package/src/temporal/gpu.ts +101 -17
- package/src/temporal/inspection.ts +7 -1
- package/src/temporal/standard-scene-data.ts +5 -0
- package/src/temporal/target-coverage-attachment.ts +4 -0
- package/src/transmission/__tests__/single-layer-medium.unit.test.ts +149 -0
- package/src/transmission/__tests__/standard-transmission.dawn.test.ts +12 -11
- package/src/transmission/single-layer-medium.ts +322 -0
- package/src/typed-render-graph-primitives.ts +70 -2
- package/src/volume/component.ts +10 -9
- package/src/volume/extract.ts +11 -5
- package/src/volume/inspection.ts +3 -0
- package/src/volume/passes.ts +87 -4
- package/src/volume/resources.ts +2 -1
- package/dist/chunk-3RTCJTH4.mjs +0 -1610
- package/dist/chunk-3RTCJTH4.mjs.map +0 -1
- package/dist/chunk-BLXGONR2.mjs.map +0 -1
- package/dist/chunk-ILQ5MEZF.mjs +0 -32
- package/dist/chunk-ILQ5MEZF.mjs.map +0 -1
- package/dist/chunk-LEAXOMYJ.mjs.map +0 -1
- package/dist/chunk-NB2S7ZRX.mjs +0 -1783
- package/dist/chunk-NB2S7ZRX.mjs.map +0 -1
- package/dist/chunk-NNQL7CB3.mjs +0 -1713
- package/dist/chunk-NNQL7CB3.mjs.map +0 -1
- package/dist/chunk-OO3DRYK7.mjs.map +0 -1
- package/dist/chunk-PA5DRJNI.mjs.map +0 -1
- package/dist/chunk-PLAXOOX5.mjs +0 -1907
- package/dist/chunk-PLAXOOX5.mjs.map +0 -1
- package/dist/chunk-RXZ3RGOU.mjs +0 -53
- package/dist/chunk-RXZ3RGOU.mjs.map +0 -1
- package/dist/chunk-VOZWDM3L.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ssr/hiz.ts","../src/ssr/resources.ts","../src/inspection-types.ts","../src/prepare/extended-lighting/state.ts","../src/ssr/history.ts","../src/scene/visibility/occlusion-query-pool.ts","../src/scene/visibility/occlusion-pass.ts","../src/scene/visibility/types.ts","../src/scene/visibility/occlusion-runtime.ts","../src/scene/probe-blend.ts"],"names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A,CAAK,WAAA,GAAc,YAAA;AACnB,IAAA,IAAA,CAAK,0BAAA,GAA6B,gBAAA;AAClC,IAAA,IAAA,CAAK,sBAAA,GAAyB,kBAAA;AAC9B,IAAA,IAAA,CAAK,YAAA,GAAe,aAAA;AACpB,IAAA,IAAA,CAAK,UAAA,GAAa,KAAK,aAAA,CAAc,KAAA;AAAA,MACnC,CAAC,MAAA,KAAW,MAAA,CAAO,KAAA,CAAM,MAAA,KAAW;AAAA,KACtC;AACA,IAAA,IAAA,CAAK,OAAA,GACH,MAAM,GAAA,KACL,KAAA,CAAM,kBAAkB,MAAA,GACrB,EAAE,SAAA,EAAW,KAAA,EAAO,UAAA,EAAY,CAAC,GAAG,CAAA,EAAG,CAAC,CAAA,EAAY,cAAA,EAAgB,aAAA,EAAc,GAClF,EAAE,SAAA,EAAW,IAAA,EAAM,UAAA,EAAY,KAAA,CAAM,aAAA,EAAc,CAAA;AACzD,IAAA,IAAA,CAAK,mBAAA,GAAsB,OAAA;AAC3B,IAAA,IAAA,CAAK,gBAAA,GAAmB,kBAAA;AACxB,IAAA,OAAO,MAAA;AAAA,EACT;AACF","file":"chunk-3XUBWRY2.mjs","sourcesContent":["import type { GraphExtent } from '@forgeax/engine-render-graph';\n\n/** The one depth format owned by the SSR spatial producer. */\nexport const SSR_HIZ_FORMAT = 'r32float' as const;\n\nexport interface SsrHiZExtent {\n readonly width: number;\n readonly height: number;\n}\n\nexport interface SsrHiZLevelPlan extends SsrHiZExtent {\n readonly level: number;\n}\n\nexport interface SsrHiZPlan {\n readonly extent: SsrHiZExtent;\n readonly format: typeof SSR_HIZ_FORMAT;\n readonly mipLevelCount: number;\n readonly levels: readonly SsrHiZLevelPlan[];\n readonly graphSize: GraphExtent;\n}\n\nfunction validExtent(extent: SsrHiZExtent): boolean {\n return (\n Number.isInteger(extent.width) &&\n Number.isInteger(extent.height) &&\n extent.width > 0 &&\n extent.height > 0\n );\n}\n\nfunction requireExtent(extent: SsrHiZExtent): void {\n if (!validExtent(extent)) {\n throw new RangeError('SSR Hi-Z extent must contain positive integer width and height');\n }\n}\n\n/** Derive the physical WebGPU floor-halved mip extent, clamped to one texel. */\nexport function nextSsrHiZMipExtent(extent: SsrHiZExtent): SsrHiZExtent {\n requireExtent(extent);\n return {\n width: Math.max(1, Math.floor(extent.width / 2)),\n height: Math.max(1, Math.floor(extent.height / 2)),\n };\n}\n\n/** Derive the complete current-view Hi-Z descriptor without allocating a resource. */\nexport function buildSsrHiZPlan(extent: SsrHiZExtent): SsrHiZPlan {\n requireExtent(extent);\n const levels: SsrHiZLevelPlan[] = [];\n let current = { width: extent.width, height: extent.height };\n let level = 0;\n while (true) {\n levels.push({ level, ...current });\n if (current.width === 1 && current.height === 1) break;\n current = nextSsrHiZMipExtent(current);\n level += 1;\n }\n return Object.freeze({\n extent: Object.freeze({ width: extent.width, height: extent.height }),\n format: SSR_HIZ_FORMAT,\n mipLevelCount: levels.length,\n levels: Object.freeze(levels.map((entry) => Object.freeze(entry))),\n graphSize: Object.freeze({ width: extent.width, height: extent.height }),\n });\n}\n\n/** Map an invalid or empty depth sample to the Hi-Z empty-pixel sentinel. */\nexport function normalizeSsrHiZDepth(value: number): number {\n return Number.isFinite(value) && value > 0 ? value : Number.POSITIVE_INFINITY;\n}\n\nfunction ssrHiZCoverageStart(index: number, sourceSize: number, destinationSize: number): number {\n return Math.floor((index * sourceSize) / destinationSize);\n}\n\nfunction ssrHiZCoverageEnd(index: number, sourceSize: number, destinationSize: number): number {\n return Math.min(\n sourceSize,\n Math.floor(((index + 1) * sourceSize + destinationSize - 1) / destinationSize),\n );\n}\n\n/**\n * Reduce one mip level with the physical mip's complete coverage footprint.\n *\n * WebGPU mip dimensions are floor-halved, so a 3-wide source has a 1-wide\n * destination. The destination cells therefore use integer normalized\n * boundaries with a conservative ceil on the end boundary instead of\n * assuming a fixed 2x2 footprint. Adjacent cells overlap at odd boundaries;\n * this keeps boundary and trailing source columns/rows in the hierarchy.\n * The empty sentinel is infinity and therefore never wins over a finite\n * positive view-space depth. Invalid input samples are treated as empty so a\n * malformed depth cannot introduce NaN into the hierarchy.\n */\nexport function reduceSsrHiZLevel(\n source: ArrayLike<number>,\n sourceExtent: SsrHiZExtent,\n): Float32Array {\n requireExtent(sourceExtent);\n const expectedLength = sourceExtent.width * sourceExtent.height;\n if (source.length !== expectedLength) {\n throw new RangeError(`SSR Hi-Z source length must equal ${expectedLength}`);\n }\n const destination = nextSsrHiZMipExtent(sourceExtent);\n const reduced = new Float32Array(destination.width * destination.height);\n for (let y = 0; y < destination.height; y += 1) {\n for (let x = 0; x < destination.width; x += 1) {\n let minimum = Number.POSITIVE_INFINITY;\n const startY = ssrHiZCoverageStart(y, sourceExtent.height, destination.height);\n const endY = ssrHiZCoverageEnd(y, sourceExtent.height, destination.height);\n const startX = ssrHiZCoverageStart(x, sourceExtent.width, destination.width);\n const endX = ssrHiZCoverageEnd(x, sourceExtent.width, destination.width);\n for (let sampleY = startY; sampleY < endY; sampleY += 1) {\n for (let sampleX = startX; sampleX < endX; sampleX += 1) {\n const sample = normalizeSsrHiZDepth(source[sampleY * sourceExtent.width + sampleX] ?? 0);\n minimum = Math.min(minimum, sample);\n }\n }\n reduced[y * destination.width + x] = minimum;\n }\n }\n return reduced;\n}\n","import type {\n GraphTexture,\n GraphTextureView,\n RenderGraphBuilder,\n RenderGraphError,\n RenderGraphFrame,\n} from '@forgeax/engine-render-graph';\nimport { ok, type Result } from '@forgeax/engine-types';\nimport { buildSsrHiZPlan, SSR_HIZ_FORMAT, type SsrHiZExtent, type SsrHiZPlan } from './hiz';\n\nexport { SSR_HIZ_FORMAT } from './hiz';\n\nexport const SSR_TRACE_FORMAT = 'rgba16float' as const;\nexport const SSR_R32FLOAT_BYTES_PER_PIXEL = 4 as const;\nexport const SSR_RGBA16FLOAT_BYTES_PER_PIXEL = 8 as const;\nexport const SSR_TEMPORAL_PARAMS_BYTES = 32 as const;\nexport const SSR_SPATIAL_MEMORY_BUDGET_BYTES = 45_088_768 as const;\n\nexport interface SsrHiZResources {\n readonly plan: SsrHiZPlan;\n readonly texture: GraphTexture;\n readonly levels: readonly GraphTextureView[];\n}\n\nexport interface SsrSpatialTexture {\n readonly texture: GraphTexture;\n readonly view: GraphTextureView;\n readonly width: number;\n readonly height: number;\n readonly format: typeof SSR_TRACE_FORMAT;\n}\n\nexport interface SsrSpatialResources {\n readonly hiz: SsrHiZResources;\n readonly trace: SsrSpatialTexture;\n /** Half-resolution reactivity of the admitted reflection source taps. */\n readonly hitReactivity: GraphTextureView;\n /** Half-resolution resolved radiance/confidence when temporal resolve is active. */\n readonly resolved?: SsrSpatialTexture;\n /** Sampled view of all resolved reflection levels; mip 0 remains sharp. */\n readonly radiancePyramid?: GraphTextureView;\n}\n\nexport interface SsrSpatialMemoryEstimate {\n readonly width: number;\n readonly height: number;\n readonly halfWidth: number;\n readonly halfHeight: number;\n readonly hizBytes: number;\n readonly traceBytes: number;\n readonly hitReactivityBytes: number;\n readonly resolvedBytes: number;\n readonly historyBytes: number;\n readonly temporalParamsBytes: number;\n /** Full-resolution fallback output allocated only for SSR; included in the total. */\n readonly fallbackInputBytes: number;\n /** Total additional descriptor bytes, including the lighting-owned fallback, before aliasing. */\n readonly ssrOwnedBytes: number;\n readonly budgetBytes: typeof SSR_SPATIAL_MEMORY_BUDGET_BYTES;\n readonly withinBudget: boolean;\n}\n\nfunction halfExtent(extent: SsrHiZExtent): SsrHiZExtent {\n return {\n width: Math.max(1, Math.floor(extent.width / 2)),\n height: Math.max(1, Math.floor(extent.height / 2)),\n };\n}\n\nfunction byteCount(width: number, height: number, bytesPerPixel: number): number {\n const bytes = width * height * bytesPerPixel;\n if (!Number.isSafeInteger(bytes)) {\n throw new RangeError('SSR spatial descriptor byte count exceeds safe integer range');\n }\n return bytes;\n}\n\n/** Derive descriptor bytes for one admitted half-resolution SSR frame. */\nexport function estimateSsrSpatialMemory(\n extent: SsrHiZExtent,\n options: { readonly temporal?: boolean } = {},\n): SsrSpatialMemoryEstimate {\n const half = halfExtent(extent);\n const plan = buildSsrHiZPlan(half);\n const temporal = options.temporal !== false;\n const hizBytes = plan.levels.reduce(\n (sum, level) => sum + byteCount(level.width, level.height, SSR_R32FLOAT_BYTES_PER_PIXEL),\n 0,\n );\n const traceBytes = byteCount(half.width, half.height, SSR_RGBA16FLOAT_BYTES_PER_PIXEL);\n const hitReactivityBytes = byteCount(half.width, half.height, SSR_R32FLOAT_BYTES_PER_PIXEL);\n const resolvedBytes = temporal\n ? plan.levels.reduce(\n (sum, level) => sum + byteCount(level.width, level.height, SSR_RGBA16FLOAT_BYTES_PER_PIXEL),\n 0,\n )\n : 0;\n const historyBytes = temporal ? half.width * half.height * 12 * 2 : 0;\n const temporalParamsBytes = temporal ? SSR_TEMPORAL_PARAMS_BYTES : 0;\n const fallbackInputBytes = byteCount(\n extent.width,\n extent.height,\n SSR_RGBA16FLOAT_BYTES_PER_PIXEL,\n );\n const ssrOwnedBytes =\n hizBytes +\n traceBytes +\n hitReactivityBytes +\n resolvedBytes +\n historyBytes +\n temporalParamsBytes +\n fallbackInputBytes;\n return Object.freeze({\n width: extent.width,\n height: extent.height,\n halfWidth: half.width,\n halfHeight: half.height,\n hizBytes,\n traceBytes,\n hitReactivityBytes,\n resolvedBytes,\n historyBytes,\n temporalParamsBytes,\n fallbackInputBytes,\n ssrOwnedBytes,\n budgetBytes: SSR_SPATIAL_MEMORY_BUDGET_BYTES,\n withinBudget: ssrOwnedBytes <= SSR_SPATIAL_MEMORY_BUDGET_BYTES,\n });\n}\n\nfunction texture(\n graph: RenderGraphBuilder<RenderGraphFrame>,\n label: string,\n format: typeof SSR_TRACE_FORMAT,\n extent: SsrHiZExtent,\n): Result<SsrSpatialTexture, RenderGraphError> {\n const created = graph.createTexture(label, {\n format,\n size: { width: extent.width, height: extent.height },\n domain: 'linear-hdr',\n });\n if (!created.ok) return created;\n const view = graph.view(created.value, { label: `${label}.view`, dimension: '2d' });\n if (!view.ok) return view;\n return ok({\n texture: created.value,\n view: view.value,\n width: extent.width,\n height: extent.height,\n format,\n });\n}\n\n/** Create the renderer-owned Hi-Z texture and one typed view per mip. */\nexport function createSsrHiZResources(\n graph: RenderGraphBuilder<RenderGraphFrame>,\n extent: SsrHiZExtent,\n): Result<SsrHiZResources, RenderGraphError> {\n // Full-resolution depth already exists. Store only its reduced hierarchy.\n const plan = buildSsrHiZPlan(halfExtent(extent));\n const created = graph.createTexture('ssr-hiz', {\n format: SSR_HIZ_FORMAT,\n size: plan.graphSize,\n mipLevelCount: plan.mipLevelCount,\n });\n if (!created.ok) return created;\n const levels: GraphTextureView[] = [];\n for (const entry of plan.levels) {\n const view = graph.view(created.value, {\n label: `ssr-hiz.mip-${entry.level}.view`,\n dimension: '2d',\n baseMipLevel: entry.level,\n mipLevelCount: 1,\n });\n if (!view.ok) return view;\n levels.push(view.value);\n }\n return ok({ plan, texture: created.value, levels: Object.freeze(levels) });\n}\n\n/** Allocate only the transient resources required by an admitted spatial path. */\nexport function createSsrSpatialResources(\n graph: RenderGraphBuilder<RenderGraphFrame>,\n extent: SsrHiZExtent,\n): Result<SsrSpatialResources, RenderGraphError> {\n const hiz = createSsrHiZResources(graph, extent);\n if (!hiz.ok) return hiz;\n const traceExtent = halfExtent(extent);\n const trace = texture(graph, 'ssr-trace', SSR_TRACE_FORMAT, traceExtent);\n if (!trace.ok) return trace;\n const hitTexture = graph.createTexture('ssr-hit-reactivity', {\n format: 'r32float',\n size: traceExtent,\n });\n if (!hitTexture.ok) return hitTexture;\n const hitReactivity = graph.view(hitTexture.value, {\n label: 'ssr-hit-reactivity.view',\n dimension: '2d',\n });\n if (!hitReactivity.ok) return hitReactivity;\n return ok({ hiz: hiz.value, trace: trace.value, hitReactivity: hitReactivity.value });\n}\n","/**\n * Renderer-owned inspection PODs. Keeping these projections free of renderer\n * implementation imports prevents the observation contract from reopening the\n * extract/record dependency graph.\n */\n\nimport { type BarrelDistortionMapping, freezeBarrelDistortionMapping } from './barrel-distortion';\nimport type { DirectionalShadowFilterLabel } from './components/directional-shadow-filter';\nimport type {\n GpuDrivenPreparationErrorCode,\n GpuDrivenPreparationErrorDetail,\n} from './errors/gpu-driven';\nimport type { DepthOfFieldRequestFailure } from './features/depth-of-field/depth-of-field-params';\nimport type { PointsLinesInspection } from './points-lines/inspection';\nimport type { LodOcclusionInspection } from './scene/visibility/inspection';\nimport type { SsrAdmissionIdentity } from './ssr/identity';\nimport type { SurfaceGpuIndirectParameters } from './surface/submission-observation';\n\nexport type {\n LodOcclusionInspection,\n LodOcclusionInspectionRow,\n LodOcclusionWorldAttribution,\n LodOcclusionWorldInspection,\n} from './scene/visibility/inspection';\n\nexport interface LodOcclusionInspectionSummary extends LodOcclusionInspection {\n readonly timing?: {\n readonly medianUs: number;\n readonly p95Us: number;\n readonly samples: number;\n };\n}\n\n/**\n * SSR M0 inspection is a detached projection of the consumer admission\n * result. The admission owner remains in `ssr/admission`; this re-export\n * keeps inspection callers on the same typed identity and status vocabulary.\n */\nexport type {\n SsrAdmissionBudget,\n SsrAdmissionResult,\n SsrAdmissionWork,\n SsrDependenciesInspection,\n SsrFormatReceipt,\n SsrReflectionFallbackReceipt,\n SsrTemporalReceipt,\n} from './ssr/admission';\nexport type {\n SsrAdmissionError,\n SsrAdmissionErrorCode,\n SsrAdmissionErrorDetail,\n SsrOwnerRecoveryAction,\n} from './ssr/errors';\nexport type { SsrAdmissionIdentity } from './ssr/identity';\nexport type {\n SsrSpatialHistoryInspection,\n SsrSpatialInspection,\n SsrSpatialInspectionFailure,\n SsrSpatialInspectionProjection,\n} from './ssr/inspection';\n\nexport interface LightInspectionInput {\n readonly generation: number;\n readonly candidate: string | undefined;\n readonly accepted: string | undefined;\n readonly lastKnownGood: string | undefined;\n readonly failure: string | undefined;\n readonly failureKeys: readonly string[];\n readonly resourceCount: number;\n readonly uploadBytes: number;\n}\n\nexport type LightInspection = Readonly<LightInspectionInput>;\n\nexport function projectLightInspection(input: LightInspectionInput): LightInspection {\n return Object.freeze({\n generation: input.generation,\n candidate: input.candidate,\n accepted: input.accepted,\n lastKnownGood: input.lastKnownGood,\n failure: input.failure,\n failureKeys: [...input.failureKeys],\n resourceCount: input.resourceCount,\n uploadBytes: input.uploadBytes,\n });\n}\n\nexport function lightInspectionIdentity(topology: string, generation: number): string {\n return `${topology}:generation-${generation}`;\n}\n\nexport type BloomGraphStatus = 'empty' | 'valid' | 'invalid';\n\nexport interface BloomInspection {\n readonly graphStatus: BloomGraphStatus;\n readonly enabled: boolean;\n readonly levelCount: number;\n readonly levelDimensions: readonly { readonly width: number; readonly height: number }[];\n readonly downsamplePassCount: number;\n readonly upsamplePassCount: number;\n readonly targetCount: number;\n readonly targetBytes: number;\n readonly resourceCount: number;\n readonly passCount: number;\n readonly encodeCount: number;\n readonly bindGroupCount: number;\n readonly uploadCount: number;\n /** Descriptor-derived bytes for the active Bloom target child in the compiled graph. */\n readonly residentChildBytes: number;\n readonly generation: number;\n readonly state: 'off' | 'active' | 'retiring';\n}\n\nexport const emptyBloomInspection = (): BloomInspection => ({\n graphStatus: 'empty',\n enabled: false,\n levelCount: 0,\n levelDimensions: [],\n downsamplePassCount: 0,\n upsamplePassCount: 0,\n targetCount: 0,\n targetBytes: 0,\n resourceCount: 0,\n passCount: 0,\n encodeCount: 0,\n bindGroupCount: 0,\n uploadCount: 0,\n residentChildBytes: 0,\n generation: 0,\n state: 'off',\n});\nexport type { TransmissionInspection } from './transmission/inspection';\n\nexport interface BatchTopologyInspection {\n readonly revision: number;\n readonly batchCount: number;\n readonly candidateCount: number;\n readonly rebuilds: number;\n readonly patches: number;\n readonly ineligible: number;\n /** Payload-only candidate updates that preserved batch topology. */\n readonly payloadPatches?: number;\n /** Number of retained-slot descriptor comparisons. */\n readonly membershipChecks?: number;\n /** Candidate membership records materialized by the owner. */\n readonly membershipAllocations?: number;\n readonly candidateAdds?: number;\n readonly candidateRemoves?: number;\n /** Distinct resource classes represented by this topology. */\n readonly resourceClassCount?: number;\n /** Resource-class groups; range/page changes do not create a new class. */\n readonly resourceClassSplits?: readonly {\n readonly resourceIdentity: string;\n readonly batchIds: readonly number[];\n readonly candidateCount: number;\n }[];\n /** Reasons emitted only when more than one resource class is present. */\n readonly resourceClassSplitReasons?: readonly string[];\n}\n\n/** Logical Engine allocation facts; physical VRAM residency is intentionally unknown. */\nexport interface GpuResourceAllocationInspection {\n readonly unit: 'engine-allocation-bytes';\n readonly physicalResidency: 'unknown';\n readonly liveBytes: number;\n readonly pendingRetirementBytes: number;\n readonly peakBytes: number;\n readonly successfulAllocationCount: number;\n readonly successfulAllocationBytes: number;\n readonly pendingRetirementCount: number;\n readonly retiredBytes: number;\n readonly failedAllocationRollbacks: number;\n readonly failedAllocationRollbackBytes: number;\n}\n\n/**\n * Detached evidence for the declarative feature host and typed graph. These\n * counters are diagnostic projections only; they do not alter graph admission\n * or prepared-resource retirement semantics.\n */\nexport interface RenderFeatureHostInspection {\n readonly signatures: readonly {\n readonly featureIdentity: string;\n readonly calls: number;\n readonly typedArrayBytes: number;\n readonly outputChars: number;\n readonly cpuMs: number;\n /** Number of exact structural comparisons that reused a detached snapshot. */\n readonly cacheHits: number;\n /** Number of structural changes that allocated a new signature revision. */\n readonly cacheMisses: number;\n }[];\n readonly prepared: {\n readonly retained: number;\n readonly submitted: number;\n readonly released: number;\n readonly releaseFailures: number;\n };\n}\n\nexport interface RenderFeatureGraphInspection {\n /** Monotonic revision of the last completely validated feature plan set. */\n readonly planRevision: number;\n readonly signatureValidationCalls: number;\n readonly signatureValidationBytes: number;\n readonly signatureValidationChars: number;\n readonly signatureValidationCpuMs: number;\n /** Number of plan validations satisfied by detached structural evidence. */\n readonly signatureValidationCacheHits: number;\n /** Number of plan validations that fell back to canonical serialization. */\n readonly signatureValidationCacheMisses: number;\n readonly ensureCalls: number;\n readonly reuseHits: number;\n readonly rebuildAttempts: number;\n readonly compileAttempts: number;\n readonly compileSuccesses: number;\n readonly compileFailures: number;\n readonly validationFailures: number;\n readonly buildFailures: number;\n readonly compileCpuMs: number;\n readonly candidatesWithPreparedBatches: number;\n readonly preparedKeyChanges: number;\n readonly accepted: number;\n readonly rejected: number;\n readonly abandoned: number;\n readonly last: {\n readonly planSignature: string;\n readonly topologyKey: string | undefined;\n readonly preparedResourceKey: string | undefined;\n };\n}\n\n/**\n * Detached output-space barrel facts for the most recently accepted picture.\n * The mapping, extent, and generation fields are one context; consumers must\n * discard the whole projection when its device or frame is retired.\n */\nexport interface BarrelDistortionInspection {\n readonly effectiveMapping: BarrelDistortionMapping | undefined;\n readonly extent: { readonly width: number; readonly height: number } | undefined;\n readonly frameId: number;\n readonly deviceGeneration: number;\n readonly graphGeneration: number;\n readonly lastKnownGood: boolean;\n}\n\nexport interface BarrelDistortionInspectionInput {\n readonly effectiveMapping: BarrelDistortionMapping | undefined;\n readonly frameId: number;\n readonly deviceGeneration: number;\n readonly graphGeneration: number;\n readonly lastKnownGood: boolean;\n}\n\n/** Project one immutable, public barrel frame context. */\nexport function projectBarrelDistortionInspection(\n input: BarrelDistortionInspectionInput,\n): BarrelDistortionInspection {\n const effectiveMapping =\n input.effectiveMapping === undefined\n ? undefined\n : freezeBarrelDistortionMapping(input.effectiveMapping);\n return Object.freeze({\n effectiveMapping,\n extent:\n effectiveMapping === undefined\n ? undefined\n : Object.freeze({ width: effectiveMapping.width, height: effectiveMapping.height }),\n frameId: input.frameId,\n deviceGeneration: input.deviceGeneration,\n graphGeneration: input.graphGeneration,\n lastKnownGood: input.lastKnownGood,\n });\n}\n\n/** Detached material texture-source probe accounting for the last extract. */\nexport interface MaterialTextureSourceInspection {\n readonly sourceFieldsVisited: number;\n readonly numericSharedRefProbes: number;\n readonly sourceCacheHits: number;\n readonly sourceCacheMisses: number;\n readonly producerRoutes: Readonly<Record<string, number>>;\n}\n\nexport interface ProbeBlendRecordInspection {\n readonly objectKey: number;\n readonly generation: number;\n readonly localBlendFraction: number;\n readonly shPreblend: readonly number[];\n readonly byteLength: number;\n readonly candidate: boolean;\n readonly accepted: boolean;\n readonly lastKnownGood: boolean;\n readonly sentinel: string | undefined;\n readonly probeBlendIndex: number;\n readonly contributors: readonly {\n readonly identity: string;\n readonly distance: number;\n readonly radius: number;\n readonly coverage: number;\n readonly q: number;\n readonly qHat: number;\n readonly alpha: number;\n }[];\n readonly qHatSum: number;\n readonly rStar: number;\n readonly fallbackReason: string | undefined;\n}\n\nexport interface ProbeSkyInspection {\n readonly available: boolean;\n readonly identity: string | undefined;\n readonly sourceKey: string | undefined;\n readonly irradiance: readonly [number, number, number];\n readonly fallbackReason: string | undefined;\n}\n\nexport interface ProbeBlendInspection {\n readonly activeContributorCount: number;\n readonly admittedProbeCount: number;\n readonly coverage: number;\n readonly skyResidualFraction: number;\n readonly finite: boolean;\n readonly errorCode: 'capacity-exceeded' | 'invalid-admitted-prefix' | undefined;\n readonly records: readonly ProbeBlendRecordInspection[];\n readonly sky: ProbeSkyInspection;\n readonly dirtyVisitCount: number;\n readonly dirtyReasons: readonly string[];\n readonly receipt: {\n readonly activeIdentities: readonly string[];\n readonly admittedIdentities: readonly string[];\n readonly rejectedIdentities: readonly string[];\n readonly stableOrder: readonly string[];\n readonly capacity: number;\n readonly scaleRadius: number;\n readonly finite: boolean;\n readonly overflowReason: 'active-count-exceeds-capacity' | undefined;\n };\n}\n\nexport interface GpuSceneTableInspection {\n readonly capacity: number;\n readonly bytes: number;\n}\n\ntype GpuSceneTableName = 'primitive' | 'instance' | 'transform' | 'drawTemplate' | 'material';\n\nexport interface GpuSceneInspection {\n readonly capacity: number;\n readonly tables: Readonly<Record<GpuSceneTableName, GpuSceneTableInspection>>;\n readonly uploadRanges: number;\n readonly uploadBytes: number;\n readonly capacityGrows: number;\n readonly fullRebuilds: number;\n readonly clearedSlots: number;\n readonly noChangeFrames: number;\n}\n\n/**\n * Closed GPU-driven execution lanes exposed by the detached inspection\n * surface. `cpu-semantic` keeps the existing material/authoring semantics,\n * while `cpu-deformation` is reserved for skin data that cannot be safely\n * represented by the GPU palette contract. `blocked` means the renderer\n * refused to promote an incomplete candidate instead of silently changing\n * its meaning.\n */\nexport type GpuDrivenLane = 'gpu' | 'cpu-semantic' | 'cpu-deformation' | 'blocked';\n\n/** Closed, machine-readable reasons for a lane decision or recovery state. */\nexport type GpuDrivenLaneReason =\n | 'none'\n | 'reflection-fallback-mrt'\n | 'capability'\n | 'unsupported'\n | 'resource-not-ready'\n | 'shadow-ownership'\n | 'capacity'\n | 'overflow'\n | 'stale-generation'\n | 'device-recovery'\n | 'skin-bounds-missing'\n | 'skin-address-missing';\n\n/**\n * Detached producer failure facts carried by a blocked GPU lane. This keeps\n * owner and recovery machine-readable at the same boundary as the lane\n * decision; callers never need to parse an RhiError hint or shader name.\n */\nexport interface GpuDrivenPreparationFailureInspection {\n readonly code: GpuDrivenPreparationErrorCode;\n readonly expected: string;\n readonly hint: string;\n readonly detail: GpuDrivenPreparationErrorDetail;\n}\n\n/**\n * One bounded aggregate; never includes a per-draw/live renderer object.\n * Every count uses the same concrete `(drawItem, view-pass)` key unit. `drawCount`\n * is the count for this lane; the remaining fields make conservation explicit\n * when a view mixes GPU-owned and CPU-residual work.\n */\nexport interface GpuDrivenLaneSummary {\n readonly viewPass: 'main' | 'directional-shadow' | 'point-shadow' | 'spot-shadow';\n readonly viewIndex: number;\n readonly face?: number;\n readonly lane: GpuDrivenLane;\n readonly reason: GpuDrivenLaneReason;\n readonly drawCount: number;\n readonly totalDrawCount: number;\n readonly claimedDrawCount: number;\n readonly residualDrawCount: number;\n /** First bounded producer failure for a blocked lane, when available. */\n readonly failure?: GpuDrivenPreparationFailureInspection;\n}\n\n/**\n * Per-submission structural work projected by the existing RenderScene/GPU\n * Scene/palette owners. These are frame deltas, not lifetime totals, so a\n * stable GPU-only frame is expected to report zero for every field.\n */\nexport interface GpuDrivenStructureMetrics {\n readonly worldEntitiesScanned: number;\n readonly sceneTableUploadBytes: number;\n readonly paletteUploadBytes: number;\n}\n\nexport interface GpuDrivenProductionInspection {\n /** Exact producer-selected Surface artifact prepared for the last candidate. */\n readonly surfaceArtifact?: {\n readonly material: string;\n readonly specializationKey: string | undefined;\n readonly variantSet: string | undefined;\n readonly layoutIdentity: string;\n readonly receiptIdentity: string;\n readonly receiptGeneration: number;\n readonly directEntry: string;\n readonly sceneIndexEntry: string;\n };\n /** Lifetime count of Surface member-to-frame projections rebuilt after a topology change. */\n readonly surfaceFrameRangeBuilds: number;\n /** Lifetime count of admitted Surface members visited while rebuilding that projection. */\n readonly surfaceFrameMemberScans: number;\n /** Lifetime count of 48-byte Surface frame rows materialized for an actual GPU write. */\n readonly surfaceFrameRowAllocations: number;\n /** Lifetime count of writes to the one renderer-owned shared Surface frame-time value. */\n readonly surfaceFrameTimeWrites: number;\n /** Lifetime count of successful producer-side residency validation scans. */\n readonly residencyValidationScans: number;\n /** Lifetime count of validation rows reused without a CPU residency walk. */\n readonly residencyValidationCacheHits: number;\n /** Lifetime count of CPU fallback telemetry traversals. */\n readonly cpuValidationScans: number;\n /** Lifetime count of CPU fallback telemetry cache hits. */\n readonly cpuValidationCacheHits: number;\n /** RenderScene candidate traversal performed for the last prepared frame. */\n readonly worldEntitiesScanned: number;\n /** GPU Scene table bytes uploaded for the last prepared frame. */\n readonly sceneTableUploadBytes: number;\n /** Skin palette bytes uploaded for the last prepared frame. */\n readonly paletteUploadBytes: number;\n readonly gpuOwnedSnapshotsMaterialized: number;\n readonly filteredPlanBuilds: number;\n readonly gpuOwnedEntityCount: number;\n readonly candidateUploadBytes: number;\n readonly batchUploadBytes: number;\n readonly viewConstantsUploadBytes: number;\n readonly batchBindGroupCreates: number;\n readonly viewBindGroupCreates: number;\n readonly topologyRevision: number | undefined;\n readonly validatedGpuOwnedRows: number;\n readonly cpuFallbackDrawItems: number;\n /** Index work accumulated by the real GPU LOD selector for the last submit. */\n readonly geometryWork: number;\n /** Level-0 index work for the same selected candidates. */\n readonly rootGeometryWork: number;\n /** `1 - geometryWork / rootGeometryWork` when the root denominator is non-zero. */\n readonly geometryWorkReduction: number;\n /** Number of selector batches in the last filtered production plan. */\n readonly batchCount: number;\n /** Number of non-zero-capacity indirect raster commands actually encoded. */\n readonly indirectDrawCount: number;\n /** Legacy name retained for existing GPU-driven evidence consumers. */\n readonly encodedIndirectDraws: number;\n /** Bounded view-pass lane aggregates for AI-readable recovery. */\n readonly channels: readonly GpuDrivenLaneSummary[];\n /** GPU resource generation used by the last prepared view, when resident. */\n readonly resourceGeneration: number | undefined;\n readonly candidateCapacity: number;\n readonly batchCapacity: number;\n readonly indirectCapacity: number;\n /** True when the last selector readback reported an incomplete result. */\n readonly overflow: boolean;\n /** Submission state for the current prepared candidate. */\n readonly submitted: boolean;\n /** Number of renderer-device recovery boundaries observed by this owner. */\n readonly recoveryCount: number;\n /** Number of staged candidates aborted before submit. */\n readonly retryCount: number;\n /** Generation of the last fully submitted GPU candidate, if any. */\n readonly lastKnownGoodGeneration: number | undefined;\n /** Aggregate logical allocation facts from available GPU-driven owners. */\n readonly resourceAllocation?: GpuResourceAllocationInspection;\n /** Per-owner facts; absent owners remain unavailable rather than zero-filled. */\n readonly resourceAllocationOwners?: {\n readonly gpuDrivenView?: GpuResourceAllocationInspection;\n readonly materialRaster?: GpuResourceAllocationInspection;\n readonly skinRaster?: GpuResourceAllocationInspection;\n };\n /** Resource-class split facts derived from batch.key.resourceIdentity. */\n readonly resourceClassCount?: number;\n readonly resourceClassSplitReasons?: readonly string[];\n readonly resourceClassSplits?: readonly {\n readonly resourceIdentity: string;\n readonly batchIds: readonly number[];\n readonly candidateCount: number;\n }[];\n}\n\nexport type DirectionalShadowEffectiveProfile =\n | 'off'\n | DirectionalShadowFilterLabel\n | 'rhi-null-structural';\n\nexport type DirectionalShadowProfile = 'off' | DirectionalShadowFilterLabel;\n\nexport interface DirectionalShadowInspectionError {\n readonly code: string;\n readonly expected: string;\n readonly hint: string;\n readonly detail?: unknown;\n}\n\n/** Bounded, detached Directional shadow facts for AI-readable inspection. */\nexport interface DirectionalShadowInspection {\n readonly requested: DirectionalShadowProfile;\n readonly effective: DirectionalShadowEffectiveProfile;\n readonly status: 'accepted' | 'fallback' | 'rejected';\n readonly fallbackReason?: 'webgl2-unsupported' | 'rhi-null-structural' | 'candidate-failed';\n readonly lastKnownGood: boolean;\n readonly pixelEvidence: 'available' | 'not-available';\n readonly cascadeCount: number;\n readonly mapSize: number;\n readonly atlasBytes: number;\n readonly writerPasses: number;\n readonly blockerTaps: number;\n readonly filterTapUpperBound: number;\n readonly seamTapUpperBound: number;\n readonly shadowAngularRadius: number | undefined;\n readonly maxPenumbraTexels: number | undefined;\n readonly deviceGeneration: number;\n readonly graphGeneration: number;\n readonly error?: DirectionalShadowInspectionError;\n}\n\nexport type ReflectionProbeSelectionInspection =\n | { readonly kind: 'probe'; readonly worldId: number; readonly entityKey: number }\n | { readonly kind: 'skylight' };\n\nexport type ReflectionFallbackSource = 'probe' | 'skylight' | 'neutral';\n\nexport type ReflectionFallbackState = 'candidate' | 'active' | 'lkg' | 'neutral' | 'unavailable';\n\n/** Detached committed fallback facts; never exposes a live GPU handle. */\nexport interface ReflectionFallbackReceipt {\n /** Device-scope owner that identifies the renderer transaction. */\n readonly rendererId?: string;\n /** Stable producer identity for this detached projection. */\n readonly producerId?: string;\n /** Stable main-pass renderable identity, when this is a per-renderable row. */\n readonly renderableKey?: string;\n /** Stable producer source identity, never a physical resource handle. */\n readonly sourceKey?: string;\n /** Frame number that produced this detached receipt. */\n readonly frameId?: number;\n readonly source: ReflectionFallbackSource;\n readonly sourceGeneration: number;\n readonly projectionGeneration: number;\n readonly deviceGeneration: number;\n readonly state: ReflectionFallbackState;\n readonly candidateVisible: false;\n readonly coverage: number;\n readonly extent?: readonly [number, number, number];\n readonly brdfSignature: string;\n /** Exact host identity of the detached producer transaction, when bound. */\n readonly identity?: SsrAdmissionIdentity;\n}\n\n/**\n * Completed fallback attachment proof, available only when the renderer opts\n * into captureReflectionFallbackReadback. Normal rendering publishes source\n * receipts after GPU completion without copying, mapping, or hashing pixels.\n *\n * This is an aggregate attachment fact, not a per-renderable row. Row\n * receipts deliberately carry source/coverage identity only, so one pixel\n * cannot be mistaken for every renderable's BRDF result.\n */\nexport interface ReflectionFallbackReadbackReceipt {\n readonly rendererId: string;\n readonly producerId: string;\n readonly frameId: number;\n readonly deviceGeneration: number;\n readonly graphGeneration: number;\n readonly textureIdentity: number;\n readonly format: string;\n readonly size: { readonly width: number; readonly height: number };\n readonly linearHdr: readonly [number, number, number, number];\n readonly readbackHash: string;\n readonly readbackStatus: 'complete';\n}\n\nexport type ReflectionFallbackFailureStage =\n | 'prepare'\n | 'filter'\n | 'build'\n | 'encode'\n | 'finish'\n | 'submit'\n | 'completion';\n\nexport type ReflectionFallbackRecoveryAction =\n | 'use-LKG'\n | 'use-Skylight'\n | 'use-neutral'\n | 'recapture'\n | 'rebuild'\n | 'retry';\n\nexport interface ReflectionFallbackInspection {\n readonly receipt: ReflectionFallbackReceipt;\n readonly failureStage?: ReflectionFallbackFailureStage;\n readonly failureCode?: string;\n readonly expected?: string;\n readonly detail?: Readonly<Record<string, unknown>>;\n readonly recoveryAction: ReflectionFallbackRecoveryAction;\n}\n\nexport interface ReflectionProbeInspection {\n readonly workBudgetPerFrame?: number;\n readonly updates?: readonly {\n readonly worldId: number;\n readonly entityKey: number;\n readonly intent: 'once' | 'on-change' | 'continuous';\n readonly activeGeneration: number;\n readonly requestedRevision: number;\n readonly capturedRevision: number;\n readonly pending: boolean;\n readonly captureStartedFrame: number;\n readonly lastCompletedFrame: number;\n readonly latencyFrames: number | undefined;\n }[];\n readonly selection: ReflectionProbeSelectionInspection;\n readonly factCount: number;\n readonly acceptedCount: number;\n readonly activeCount: number;\n readonly rawFacesCaptured: number;\n readonly filteredStepsCompleted: number;\n readonly filteredMipLevels: readonly number[];\n readonly scheduledRawFaces: number;\n readonly scheduledFilteredSteps: number;\n readonly pipelineReady: boolean;\n readonly pipelineWarmupAttempts: number;\n readonly pipelineWarmupFailure?: string;\n readonly reflectionFallback: ReflectionFallbackReceipt;\n /** Latest bounded fallback failure and owner-directed recovery action. */\n readonly reflectionFallbackInspection: ReflectionFallbackInspection;\n /** Bounded per-renderable projections; no live graph resources are included. */\n readonly reflectionFallbacks?: readonly ReflectionFallbackReceipt[];\n /** Completed frame attachment readback; separate from per-renderable rows. */\n readonly reflectionFallbackReadback?: ReflectionFallbackReadbackReceipt;\n}\n\n/** Detached semantic descriptor for the Standard scene-temporal producer. */\nexport interface TemporalTargetInspection {\n readonly identity: 'standard-scene-temporal';\n readonly producerId: 'forgeax::standard::scene-data';\n readonly schema: 'forgeax::scene-data::temporal-v1';\n readonly targetCount: 1;\n readonly descriptor: {\n readonly format: 'rgba16float';\n readonly width: number;\n readonly height: number;\n readonly sampleCount: 1;\n readonly bytes: number;\n };\n}\n\n/** Detached, bounded Motion Blur facts; no graph, device, target, or history handle. */\nexport type MotionBlurInspectionStatus = 'off' | 'active' | 'reset' | 'limited' | 'invalid';\nexport type MotionBlurInspectionLane = 'compute' | 'raster-limited';\n\n/**\n * Submission receipt for the admitted compute lane. This is derived from the\n * compiled graph and the resolved feature dispatches after a successful\n * queue submit; capability intent alone never produces this receipt.\n */\nexport interface MotionBlurExecutionPass {\n readonly name: 'motion-blur-tile-summary' | 'motion-blur';\n readonly kind: 'compute';\n readonly entryPoint: 'tile_summary' | 'reconstruct';\n readonly workgroups: readonly [number, number, number];\n}\n\nexport interface MotionBlurExecutionReceipt {\n readonly frameId: number;\n readonly deviceGeneration: number;\n readonly graphGeneration: number;\n readonly program: 'motion-blur-compute';\n readonly outputFormat: 'rgba16float';\n readonly passes: readonly [MotionBlurExecutionPass, MotionBlurExecutionPass];\n}\n\n/** Bounded renderer-owned Depth of Field facts; no graph or GPU handles. */\nexport type DepthOfFieldInspectionStatus = 'off' | 'active' | 'reset' | 'invalid' | 'unsupported';\n\nexport interface DepthOfFieldInspection {\n readonly enabled: boolean;\n readonly status: DepthOfFieldInspectionStatus;\n readonly requested: {\n readonly focusDistance: number;\n readonly fStop: number;\n readonly sensorHeight: number;\n readonly maxRadiusPixels: number;\n readonly quality: 'low' | 'medium' | 'high';\n readonly blurSide: 'both' | 'near' | 'far';\n };\n readonly effective?: DepthOfFieldInspection['requested'];\n readonly focalLength: number;\n readonly outputExtent: { readonly width: number; readonly height: number };\n readonly workExtent: { readonly width: number; readonly height: number };\n readonly tapCount: 0 | 16 | 32 | 64;\n readonly passCount: number;\n readonly textureBytes: number;\n readonly transparentPolicy: 'opaque-depth-approximation';\n readonly graphGeneration: number;\n readonly deviceGeneration: number;\n readonly lastKnownGood: boolean;\n /** Structured authoring validation facts, when admission rejected the request. */\n readonly error?: DepthOfFieldRequestFailure;\n readonly fallbackReason?:\n | 'zero-radius'\n | 'orthographic-unsupported'\n | 'invalid-params'\n | 'shader-not-ready'\n | 'candidate-failed'\n | 'capability-unavailable'\n | undefined;\n}\n\nexport interface MotionBlurInspection {\n readonly enabled: boolean;\n readonly status: MotionBlurInspectionStatus;\n /** Capability-selected implementation lane; raster is explicitly limited. */\n readonly lane: MotionBlurInspectionLane;\n readonly shutterAngle: number;\n readonly maxRadiusPixels: number;\n readonly sampleCount: number;\n /** Target presentation rate used by the accepted exposure calculation. */\n readonly targetFps: number;\n /** Bounded tier selected from the authored sample budget. */\n readonly effectiveSampleCount: 0 | 4 | 8 | 16;\n readonly temporalDemand: 'none' | 'scene-data-temporal-v1';\n readonly passName: 'motion-blur';\n readonly historyWrites: 0;\n /** Zero when demand is disabled; compute uses one summary plus one fused pass. */\n readonly passCount: 0 | 1 | 2;\n readonly tapBudget: 0 | 4 | 8 | 16;\n /** Present only when the current accepted frame executed both compute passes. */\n readonly execution?: MotionBlurExecutionReceipt;\n readonly resetReason?: import('./temporal/view').TemporalResetReason;\n readonly lastFailure?: 'invalid-params' | 'scene-data-unavailable' | 'submit-failure';\n}\n\nexport type RenderSceneResyncReason =\n | 'attach'\n | 'asset-catalog-changed'\n | 'shared-ref-changed'\n | 'unsupported-change'\n | 'non-rigid-lane'\n | 'explicit-invalidate';\n\nexport interface PersistentRenderSceneInspection {\n readonly worldEntitiesScanned: number;\n readonly fullRebuilds: number;\n readonly noChangeFrames: number;\n readonly deltaFrames: number;\n readonly transformUpdates: number;\n readonly lastResyncReason: RenderSceneResyncReason | undefined;\n readonly projectionRecords: number;\n /** Allocation/cache evidence for instance bounds derivation. */\n readonly instanceBoundsCache?: {\n readonly hits: number;\n readonly misses: number;\n readonly derives: number;\n readonly invalidations: number;\n };\n /** Numeric probe ownership facts; no GPU handles or object graph references. */\n readonly probeBlend?: ProbeBlendInspection;\n readonly topology: BatchTopologyInspection;\n readonly gpu:\n | { readonly status: 'inactive' }\n | { readonly status: 'unsupported'; readonly reason: 'storage-buffer-unavailable' }\n | ({ readonly status: 'resident' } & GpuSceneInspection)\n | { readonly status: 'rebuild-pending' }\n | { readonly status: 'error' };\n /** Bounded retained authoring observations; no graph or backend handles. */\n readonly pointsLines: readonly PointsLinesInspection[];\n /** Last actually encoded Surface work, fenced by the renderer submission owner. */\n readonly submission?: {\n readonly sequence: number;\n readonly frameId: number;\n readonly requestedLane: 'direct' | 'gpu-driven';\n readonly actualLane: 'direct' | 'gpu-driven';\n /** Current-frame topology fact when a normal GPU lane was intentionally bypassed. */\n readonly actualLaneReason?: GpuDrivenLaneReason;\n readonly deviceGeneration: number;\n readonly graphGeneration: number;\n readonly viewIdentity: 'main:0';\n readonly resourceGeneration: number | undefined;\n readonly status: 'submitted' | 'completed';\n readonly passes: readonly {\n readonly pass: 'nearest-layer' | 'color';\n /** Total commands actually encoded, including rows beyond the bounded sample. */\n readonly commandCount: number;\n readonly totalCommandCount: number;\n readonly savedCommandCount: number;\n readonly droppedCommandCount: number;\n readonly truncated: boolean;\n readonly memberEvidence:\n | 'direct-command-members'\n | 'direct-command-members-truncated'\n | 'indirect-readback-required'\n | 'indirect-visible-readback'\n | 'indirect-visible-readback-truncated';\n readonly memberIds?: readonly string[];\n /** Decoded GPU command words bound to this submission/readback fence. */\n readonly indirectParameters?: readonly SurfaceGpuIndirectParameters[];\n readonly commands: readonly (\n | {\n readonly kind: 'draw' | 'draw-indexed';\n readonly count: number;\n readonly first: number;\n readonly instanceCount: number;\n readonly firstInstance: number;\n readonly surfaceFrameBase: number;\n readonly memberIds: readonly string[];\n readonly pipelineIdentity: number;\n readonly programEvidence: 'producer-receipt' | 'missing';\n readonly receiptIdentity?: string;\n readonly receiptGeneration?: number;\n }\n | {\n readonly kind: 'draw-indirect' | 'draw-indexed-indirect';\n readonly indirectBufferIdentity: number;\n readonly indirectOffset: number;\n readonly pipelineIdentity: number;\n readonly programEvidence: 'producer-receipt' | 'missing';\n readonly receiptIdentity?: string;\n readonly receiptGeneration?: number;\n }\n )[];\n }[];\n };\n}\n\nexport type RenderSceneInspection = PersistentRenderSceneInspection & {\n readonly gpuDriven: GpuDrivenProductionInspection;\n};\n","import type { LightResourceUnavailableError } from '../../errors/render';\nimport {\n type LightInspection,\n lightInspectionIdentity,\n projectLightInspection,\n} from '../../inspection-types';\nimport type { ExtendedLightingResourceCandidate } from './resources';\n\nexport type ExtendedLightingResourceStatus = 'empty' | 'candidate' | 'accepted';\n\nexport interface ExtendedLightingState {\n readonly enabled: boolean;\n readonly generation: number;\n readonly status: ExtendedLightingResourceStatus;\n readonly candidate: ExtendedLightingResourceCandidate | undefined;\n readonly accepted: ExtendedLightingResourceCandidate | undefined;\n readonly lastKnownGood: ExtendedLightingResourceCandidate | undefined;\n readonly resourceCount: number;\n readonly descriptorBytes: number;\n readonly uploadCount: number;\n readonly passCount: number;\n readonly bindGroupCount: number;\n readonly failure: LightResourceUnavailableError | undefined;\n readonly failureKeys: readonly string[];\n}\n\nexport function createExtendedLightingState(generation: number): ExtendedLightingState {\n return {\n enabled: false,\n generation,\n status: 'empty',\n candidate: undefined,\n accepted: undefined,\n lastKnownGood: undefined,\n resourceCount: 0,\n descriptorBytes: 0,\n uploadCount: 0,\n passCount: 0,\n bindGroupCount: 0,\n failure: undefined,\n failureKeys: [],\n };\n}\n\nexport function promoteExtendedLightingCandidate(\n state: ExtendedLightingState,\n candidate: ExtendedLightingResourceCandidate | undefined,\n): ExtendedLightingState {\n if (candidate === undefined) return state;\n return {\n ...state,\n enabled: true,\n generation: candidate.generation,\n status: 'accepted',\n candidate: undefined,\n accepted: candidate,\n lastKnownGood: candidate,\n resourceCount: 4,\n descriptorBytes: candidate.descriptorBytes,\n uploadCount: candidate.uploadCount,\n };\n}\n\nexport function recordExtendedLightingFailure(\n state: ExtendedLightingState,\n failure: LightResourceUnavailableError,\n): ExtendedLightingState {\n const key = `${failure.detail.entity}:${failure.detail.feature}:${failure.detail.generation}`;\n if (state.failureKeys.includes(key)) return state;\n return {\n ...state,\n failure,\n failureKeys: [...state.failureKeys, key],\n };\n}\n\nexport function projectExtendedLightingInspection(state: ExtendedLightingState): LightInspection {\n const identity = (candidate: ExtendedLightingResourceCandidate | undefined) =>\n candidate === undefined\n ? undefined\n : lightInspectionIdentity(candidate.topology, candidate.generation);\n return projectLightInspection({\n generation: state.generation,\n candidate: identity(state.candidate),\n accepted: identity(state.accepted),\n lastKnownGood: identity(state.lastKnownGood),\n failure: state.failure?.code,\n failureKeys: state.failureKeys,\n resourceCount: state.resourceCount,\n uploadBytes: state.descriptorBytes,\n });\n}\n","import type {\n Buffer,\n RhiDevice,\n RhiError,\n RhiQueue,\n Texture,\n TextureDescriptor,\n TextureView,\n} from '@forgeax/engine-rhi';\nimport { err, ok, type Result } from '@forgeax/engine-types';\nimport type { DeviceScope } from '../device/device-scope';\nimport {\n GPU_TEXTURE_USAGE_COPY_DST,\n GPU_TEXTURE_USAGE_COPY_SRC,\n GPU_TEXTURE_USAGE_RENDER_ATTACHMENT,\n GPU_TEXTURE_USAGE_STORAGE_BINDING,\n GPU_TEXTURE_USAGE_TEXTURE_BINDING,\n} from '../gpu-texture-usage';\nimport { GPU_BUFFER_USAGE_COPY_DST, GPU_BUFFER_USAGE_UNIFORM } from '../gpu-usage';\n\nexport const SSR_HISTORY_FORMAT = 'rgba16float' as const;\nexport type SsrHistoryResetReason =\n | 'first-enable'\n | 'resize'\n | 'camera-cut'\n | 'history-version'\n | 'coverage-loss'\n | 'reflection-generation'\n | 'device-recovery'\n | 'disable';\nexport type SsrHistoryFailureStage = 'build' | 'encode' | 'finish' | 'submit';\nexport type SsrHistoryState =\n | 'first-frame'\n | 'stable'\n | 'reset'\n | 'aborted'\n | 'retiring'\n | 'retired'\n | 'disposed';\n\nexport interface SsrHistorySlot {\n readonly texture: Texture;\n readonly view: TextureView;\n readonly surfaceTexture: Texture;\n readonly surfaceView: TextureView;\n}\nexport interface SsrHistoryResources {\n readonly width: number;\n readonly height: number;\n readonly halfWidth: number;\n readonly halfHeight: number;\n readonly bytes: number;\n readonly descriptor: TextureDescriptor;\n readonly slots: readonly [SsrHistorySlot, SsrHistorySlot];\n /** One renderer-owned parameter block shared by the temporal resolve. */\n readonly paramsBuffer: Buffer;\n readonly childScope: DeviceScope;\n}\nexport interface SsrHistoryCandidate {\n readonly readSlot: 0 | 1 | null;\n readonly writeSlot: 0 | 1;\n readonly historyValid: boolean;\n}\nexport interface SsrHistoryInspection {\n readonly state: SsrHistoryState;\n readonly width: number;\n readonly height: number;\n readonly halfWidth: number;\n readonly halfHeight: number;\n readonly format: typeof SSR_HISTORY_FORMAT;\n readonly historyCount: 0 | 2;\n readonly historyValid: boolean;\n readonly readSlot: 0 | 1 | null;\n readonly writeSlot: 0 | 1;\n readonly activeBytes: number;\n readonly candidateBytes: number;\n readonly retiringBytes: number;\n readonly resetCount: number;\n readonly resetReason: SsrHistoryResetReason | undefined;\n readonly lastFailure: SsrHistoryFailureStage | undefined;\n}\nexport interface SsrHistoryError {\n readonly code:\n | 'ssr-history-unavailable'\n | 'ssr-history-active'\n | 'ssr-history-not-active'\n | 'ssr-history-retired';\n readonly expected: string;\n readonly hint: string;\n readonly detail?: Readonly<{\n readonly stage?: SsrHistoryFailureStage;\n readonly reason?: SsrHistoryResetReason;\n }>;\n}\n\nconst HISTORY_USAGE =\n GPU_TEXTURE_USAGE_COPY_SRC |\n GPU_TEXTURE_USAGE_COPY_DST |\n GPU_TEXTURE_USAGE_TEXTURE_BINDING |\n GPU_TEXTURE_USAGE_STORAGE_BINDING |\n GPU_TEXTURE_USAGE_RENDER_ATTACHMENT;\n\nfunction positiveDimension(value: number, field: string): number {\n if (!Number.isSafeInteger(value) || value <= 0) {\n throw new RangeError(`${field} must be a positive safe integer.`);\n }\n return value;\n}\n\nfunction createResources(\n device: RhiDevice,\n scope: DeviceScope,\n width: number,\n height: number,\n): Result<SsrHistoryResources, RhiError> {\n const halfWidth = Math.max(1, Math.floor(width / 2));\n const halfHeight = Math.max(1, Math.floor(height / 2));\n const descriptor: TextureDescriptor = {\n label: 'ssr-history-rgba16float',\n size: { width: halfWidth, height: halfHeight, depthOrArrayLayers: 1 },\n format: SSR_HISTORY_FORMAT,\n usage: HISTORY_USAGE,\n mipLevelCount: 1,\n sampleCount: 1,\n dimension: '2d',\n viewFormats: undefined,\n textureBindingViewDimension: undefined,\n };\n const childScope = scope.createChild(`${scope.owner}:ssr-history`);\n const slots: SsrHistorySlot[] = [];\n for (const index of [0, 1] as const) {\n const texture = device.createTexture({\n ...descriptor,\n label: `ssr-history-rgba16float-${index}`,\n });\n if (!texture.ok) {\n childScope.abandon();\n return texture;\n }\n childScope._adopt('texture', texture.value, (value) => {\n device.destroyTexture(value);\n });\n const view = device.createTextureView(texture.value, {\n label: `ssr-history-rgba16float-${index}.view`,\n dimension: '2d',\n baseMipLevel: 0,\n mipLevelCount: 1,\n baseArrayLayer: 0,\n arrayLayerCount: 1,\n });\n if (!view.ok) {\n childScope.abandon();\n return view;\n }\n const surfaceTexture = device.createTexture({\n ...descriptor,\n label: `ssr-history-surface-${index}`,\n format: 'rgba8unorm',\n });\n if (!surfaceTexture.ok) {\n childScope.abandon();\n return surfaceTexture;\n }\n childScope._adopt('texture', surfaceTexture.value, (value) => {\n device.destroyTexture(value);\n });\n const surfaceView = device.createTextureView(surfaceTexture.value, { dimension: '2d' });\n if (!surfaceView.ok) {\n childScope.abandon();\n return surfaceView;\n }\n slots.push({\n texture: texture.value,\n view: view.value,\n surfaceTexture: surfaceTexture.value,\n surfaceView: surfaceView.value,\n });\n }\n const params = device.createBuffer({\n label: 'ssr-temporal-params',\n size: 32,\n usage: GPU_BUFFER_USAGE_UNIFORM | GPU_BUFFER_USAGE_COPY_DST,\n mappedAtCreation: false,\n });\n if (!params.ok) {\n childScope.abandon();\n return params;\n }\n childScope._adopt('buffer', params.value, (value) => {\n device.destroyBuffer(value);\n });\n const cleared = device.queue.writeBuffer(params.value, 0, new Uint8Array(32));\n if (!cleared.ok) {\n childScope.abandon();\n return cleared;\n }\n return ok({\n width,\n height,\n halfWidth,\n halfHeight,\n bytes: halfWidth * halfHeight * 12 * 2,\n descriptor,\n slots: slots as [SsrHistorySlot, SsrHistorySlot],\n paramsBuffer: params.value,\n childScope,\n });\n}\n\nfunction failure(\n code: SsrHistoryError['code'],\n expected: string,\n hint: string,\n detail?: SsrHistoryError['detail'],\n): SsrHistoryError {\n return { code, expected, hint, ...(detail === undefined ? {} : { detail }) };\n}\n\n/** Owns only SSR's two physical history slots; the shared coordinator owns epochs. */\nexport class SsrHistoryOwner {\n private activeResources: SsrHistoryResources | undefined;\n private readonly retiringResources = new Set<SsrHistoryResources>();\n private retirementFencePending = false;\n private activeCandidate: SsrHistoryCandidate | undefined;\n private readIndex: 0 | 1 = 0;\n private valid = false;\n private state: SsrHistoryState = 'first-frame';\n private resetReason: SsrHistoryResetReason | undefined = 'first-enable';\n private lastFailure: SsrHistoryFailureStage | undefined;\n private resetCount = 0;\n\n private constructor(\n private readonly device: RhiDevice,\n private readonly scope: DeviceScope,\n resources: SsrHistoryResources,\n ) {\n this.activeResources = resources;\n }\n\n static create(input: {\n readonly device: RhiDevice;\n readonly scope: DeviceScope;\n readonly width: number;\n readonly height: number;\n }): Result<SsrHistoryOwner, RhiError> {\n const width = positiveDimension(input.width, 'width');\n const height = positiveDimension(input.height, 'height');\n const resources = createResources(input.device, input.scope, width, height);\n return resources.ok\n ? ok(new SsrHistoryOwner(input.device, input.scope, resources.value))\n : resources;\n }\n\n get resources(): SsrHistoryResources {\n if (this.activeResources === undefined) throw new Error('SSR history resources are retired.');\n return this.activeResources;\n }\n\n beginFrame(): Result<SsrHistoryCandidate, SsrHistoryError> {\n if (\n this.activeResources === undefined ||\n this.state === 'retired' ||\n this.state === 'disposed'\n ) {\n return err(\n failure(\n 'ssr-history-retired',\n 'SSR history resources are active',\n 'recreate the renderer-owned SSR history after device recovery',\n ),\n );\n }\n if (this.activeCandidate !== undefined) {\n return err(\n failure(\n 'ssr-history-active',\n 'one SSR history candidate is active',\n 'commit or abort the active SSR history candidate before beginning another',\n ),\n );\n }\n const writeSlot: 0 | 1 = this.valid ? (this.readIndex === 0 ? 1 : 0) : 0;\n const candidate = Object.freeze({\n readSlot: this.valid ? this.readIndex : null,\n writeSlot,\n historyValid: this.valid && this.resetReason === undefined,\n }) as SsrHistoryCandidate;\n this.activeCandidate = candidate;\n this.state = this.valid ? 'stable' : this.state === 'aborted' ? 'aborted' : 'first-frame';\n this.lastFailure = undefined;\n return ok(candidate);\n }\n\n commitFrame(candidate: SsrHistoryCandidate): Result<void, SsrHistoryError> {\n if (this.activeCandidate !== candidate) {\n return err(\n failure(\n 'ssr-history-not-active',\n 'commit the candidate returned by beginFrame',\n 'keep one candidate from beginFrame until the shared queue submit succeeds',\n ),\n );\n }\n this.readIndex = candidate.writeSlot;\n this.valid = true;\n this.activeCandidate = undefined;\n this.state = 'stable';\n this.resetReason = undefined;\n this.lastFailure = undefined;\n return ok(undefined);\n }\n\n abortFrame(candidate: SsrHistoryCandidate, stage: SsrHistoryFailureStage): void {\n if (this.activeCandidate !== candidate) return;\n this.activeCandidate = undefined;\n this.state = 'aborted';\n this.lastFailure = stage;\n }\n\n reset(reason: SsrHistoryResetReason): void {\n this.activeCandidate = undefined;\n this.valid = false;\n this.readIndex = 0;\n this.resetReason = reason;\n this.lastFailure = undefined;\n this.resetCount += 1;\n if (this.activeResources !== undefined) this.state = 'reset';\n }\n\n resize(width: number, height: number): Result<void, RhiError> {\n const next = createResources(\n this.device,\n this.scope,\n positiveDimension(width, 'width'),\n positiveDimension(height, 'height'),\n );\n if (!next.ok) return next;\n if (this.activeResources !== undefined) this.retiringResources.add(this.activeResources);\n this.activeResources = next.value;\n this.activeCandidate = undefined;\n this.valid = false;\n this.readIndex = 0;\n this.resetReason = 'resize';\n this.lastFailure = undefined;\n this.resetCount += 1;\n this.state = 'reset';\n return ok(undefined);\n }\n\n /** Retire pending allocations after the queue's already-submitted work. */\n retireAfterFence(queue: RhiQueue, onFailure: (cause: unknown) => void): void {\n if (this.retirementFencePending) return;\n if (this.retiringResources.size === 0 && this.activeResources !== undefined) {\n this.retiringResources.add(this.activeResources);\n this.activeCandidate = undefined;\n this.valid = false;\n this.state = 'retiring';\n }\n const pending = [...this.retiringResources];\n for (const resources of pending) resources.childScope.beginRetire();\n if (pending.length === 0) return;\n this.retirementFencePending = true;\n const finish = (): void => {\n this.retirementFencePending = false;\n for (const resources of pending) {\n this.retiringResources.delete(resources);\n resources.childScope.retire();\n if (this.activeResources === resources) this.activeResources = undefined;\n }\n if (this.activeResources === undefined && this.retiringResources.size === 0) {\n this.state = 'retired';\n }\n // A second resize may have added the then-active resources while this\n // fence was pending. Chain another fence so every retired generation is\n // eventually drained without making the record stage own a retirement\n // ledger.\n if (this.retiringResources.size > 0) this.retireAfterFence(queue, onFailure);\n };\n void queue.onSubmittedWorkDone().then(finish, (cause) => {\n onFailure(cause);\n finish();\n });\n }\n\n retire(): void {\n this.retirementFencePending = false;\n this.activeCandidate = undefined;\n if (this.activeResources !== undefined) {\n this.activeResources.childScope.retire();\n this.activeResources = undefined;\n }\n for (const resources of this.retiringResources) resources.childScope.retire();\n this.retiringResources.clear();\n this.valid = false;\n this.state = 'retired';\n }\n\n dispose(): void {\n if (this.state === 'disposed') return;\n this.retire();\n this.state = 'disposed';\n }\n\n inspect(): SsrHistoryInspection {\n const active = this.activeResources;\n return Object.freeze({\n state: this.state,\n width: active?.width ?? 0,\n height: active?.height ?? 0,\n halfWidth: active?.halfWidth ?? 0,\n halfHeight: active?.halfHeight ?? 0,\n format: SSR_HISTORY_FORMAT,\n historyCount: active === undefined ? 0 : 2,\n historyValid: this.valid,\n readSlot: active === undefined ? null : this.valid ? this.readIndex : null,\n writeSlot: active === undefined ? 0 : this.valid ? (this.readIndex === 0 ? 1 : 0) : 0,\n activeBytes: active?.bytes ?? 0,\n candidateBytes: 0,\n retiringBytes: [...this.retiringResources]\n .filter((entry) => entry !== active)\n .reduce((sum, entry) => sum + entry.bytes, 0),\n resetCount: this.resetCount,\n resetReason: this.resetReason,\n lastFailure: this.lastFailure,\n });\n }\n}\n\nexport function createSsrHistoryOwner(input: {\n readonly device: RhiDevice;\n readonly scope: DeviceScope;\n readonly width: number;\n readonly height: number;\n}): Result<SsrHistoryOwner, RhiError> {\n return SsrHistoryOwner.create(input);\n}\n","export const OCCLUSION_QUERY_PAGE_COUNT = 3;\nexport const OCCLUSION_QUERY_PAGE_INDEX_LIMIT = 4096;\nexport const OCCLUSION_QUERY_RESULT_BYTES = 8;\nexport const OCCLUSION_QUERY_PAGE_BYTES =\n OCCLUSION_QUERY_PAGE_INDEX_LIMIT * OCCLUSION_QUERY_RESULT_BYTES;\n\nexport interface OcclusionQueryIdentity {\n readonly viewKey: string;\n readonly attachmentId: string;\n readonly deviceGeneration: number;\n readonly worldGeneration: number;\n readonly primitiveSlot: number;\n readonly slotGeneration: number;\n}\n\nexport interface OcclusionQueryReservation extends OcclusionQueryIdentity {\n readonly pageIndex: number;\n readonly queryIndex: number;\n readonly reservationId: number;\n}\n\nexport interface OcclusionQueryTicket extends OcclusionQueryIdentity {\n readonly pageIndex: number;\n readonly queryIndex: number;\n readonly reservationId: number;\n readonly submissionGeneration: number;\n}\n\nexport interface OcclusionQueryPoolInspection {\n readonly pageCount: number;\n readonly pageIndexLimit: number;\n readonly resolveBytes: number;\n readonly stagingBytes: number;\n readonly availablePages: number;\n readonly inFlight: number;\n readonly disposed: boolean;\n}\n\nexport interface OcclusionQueryCompletion {\n readonly status: 'accepted' | 'stale';\n /** M3 transport never suppresses a draw; M4 owns confidence policy. */\n readonly visible: true;\n}\n\ninterface PageState {\n readonly index: number;\n nextQueryIndex: number;\n pendingCount: number;\n inFlightCount: number;\n}\n\nfunction identityKey(identity: OcclusionQueryIdentity): string {\n return [\n identity.viewKey,\n identity.attachmentId,\n identity.deviceGeneration,\n identity.worldGeneration,\n identity.primitiveSlot,\n identity.slotGeneration,\n ].join('|');\n}\n\n/** Renderer-owned bounded query transport; it contains no visibility policy. */\nexport class OcclusionQueryPool {\n private readonly pages: PageState[] = Array.from(\n { length: OCCLUSION_QUERY_PAGE_COUNT },\n (_, index) => ({ index, nextQueryIndex: 0, pendingCount: 0, inFlightCount: 0 }),\n );\n private readonly pending = new Map<number, OcclusionQueryReservation>();\n private readonly tickets = new Map<number, OcclusionQueryTicket>();\n private nextReservationId = 1;\n private disposed = false;\n\n reserve(identity: OcclusionQueryIdentity): OcclusionQueryReservation | undefined {\n if (this.disposed) return undefined;\n const page = this.pages.find(\n (candidate) =>\n candidate.inFlightCount === 0 &&\n candidate.nextQueryIndex < OCCLUSION_QUERY_PAGE_INDEX_LIMIT,\n );\n if (page === undefined || page.nextQueryIndex >= OCCLUSION_QUERY_PAGE_INDEX_LIMIT) {\n return undefined;\n }\n const reservation = Object.freeze({\n ...identity,\n pageIndex: page.index,\n queryIndex: page.nextQueryIndex,\n reservationId: this.nextReservationId++,\n });\n page.nextQueryIndex += 1;\n page.pendingCount += 1;\n this.pending.set(reservation.reservationId, reservation);\n return reservation;\n }\n\n publish(\n reservation: OcclusionQueryReservation,\n result: { readonly submitted: boolean; readonly submissionGeneration: number },\n ): OcclusionQueryTicket | undefined {\n const pending = this.pending.get(reservation.reservationId);\n if (pending === undefined || this.disposed) {\n return undefined;\n }\n // A failed shared submit leaves the reservation retryable but does not\n // count as in-flight work and never publishes a completion ticket.\n if (!result.submitted) return undefined;\n this.pending.delete(reservation.reservationId);\n const page = this.pages[pending.pageIndex];\n if (page !== undefined) {\n page.pendingCount = Math.max(0, page.pendingCount - 1);\n page.inFlightCount += 1;\n }\n const ticket = Object.freeze({ ...pending, submissionGeneration: result.submissionGeneration });\n this.tickets.set(ticket.reservationId, ticket);\n return ticket;\n }\n\n /** Return an unsubmitted reservation to its bounded page. */\n cancel(reservation: OcclusionQueryReservation): boolean {\n const pending = this.pending.get(reservation.reservationId);\n if (pending === undefined) return false;\n this.pending.delete(reservation.reservationId);\n const page = this.pages[pending.pageIndex];\n if (page !== undefined) {\n page.pendingCount = Math.max(0, page.pendingCount - 1);\n this.releasePage(pending.pageIndex);\n }\n return true;\n }\n\n complete(ticket: OcclusionQueryTicket, _samples: number): OcclusionQueryCompletion {\n const current = this.tickets.get(ticket.reservationId);\n if (current !== undefined) {\n this.tickets.delete(ticket.reservationId);\n const page = this.pages[current.pageIndex];\n if (page !== undefined) page.inFlightCount = Math.max(0, page.inFlightCount - 1);\n this.releasePage(current.pageIndex);\n }\n if (this.disposed || current === undefined || identityKey(current) !== identityKey(ticket)) {\n return { status: 'stale', visible: true };\n }\n return { status: 'accepted', visible: true };\n }\n\n inspect(): OcclusionQueryPoolInspection {\n return {\n pageCount: OCCLUSION_QUERY_PAGE_COUNT,\n pageIndexLimit: OCCLUSION_QUERY_PAGE_INDEX_LIMIT,\n resolveBytes: OCCLUSION_QUERY_PAGE_BYTES,\n stagingBytes: OCCLUSION_QUERY_PAGE_BYTES,\n availablePages: this.disposed\n ? 0\n : this.pages.filter(\n (page) =>\n page.inFlightCount === 0 && page.nextQueryIndex < OCCLUSION_QUERY_PAGE_INDEX_LIMIT,\n ).length,\n inFlight: this.tickets.size,\n disposed: this.disposed,\n };\n }\n\n dispose(): void {\n this.disposed = true;\n this.pending.clear();\n this.tickets.clear();\n for (const page of this.pages) {\n page.pendingCount = 0;\n page.inFlightCount = 0;\n }\n }\n\n private releasePage(pageIndex: number): void {\n const page = this.pages[pageIndex];\n if (page !== undefined && page.pendingCount === 0 && page.inFlightCount === 0) {\n page.nextQueryIndex = 0;\n }\n }\n}\n","export interface OcclusionBounds {\n readonly min: readonly [number, number, number];\n readonly max: readonly [number, number, number];\n}\n\nexport interface OcclusionPassIdentity {\n readonly primitiveSlot: number;\n readonly slotGeneration: number;\n}\n\nexport interface OcclusionPassPlan {\n readonly after: string;\n readonly depth: { readonly resource: string; readonly usage: 'depth-read-only' };\n readonly color: { readonly resource: string; readonly usage: 'not-written' };\n readonly proxyBounds: OcclusionBounds;\n readonly queryIndex: number;\n readonly identity?: OcclusionPassIdentity;\n readonly resolve: { readonly queryIndex: number; readonly bytes: number };\n readonly copy: { readonly asynchronous: true; readonly bytes: number };\n readonly writesColor: false;\n readonly writesDepth: false;\n readonly submitCount: 1;\n readonly mapSameFrame: false;\n}\n\nexport interface OcclusionPassInput {\n readonly opaquePass: string;\n readonly depthResource: string;\n readonly colorResource: string;\n readonly bounds: OcclusionBounds | undefined;\n readonly queryIndex: number;\n readonly identity?: OcclusionPassIdentity;\n readonly transparent?: boolean;\n readonly deformed?: boolean;\n}\n\nexport interface OcclusionQueryResources {\n readonly pageIndex: number;\n readonly querySet: QuerySet;\n readonly resolveBuffer: Buffer;\n readonly stagingBuffer: Buffer;\n}\n\nexport function createOcclusionQueryResources(\n device: RhiDevice,\n pageIndex: number,\n): Result<OcclusionQueryResources, RhiError> {\n const querySet = device.createQuerySet({\n label: `occlusion-page-${pageIndex}`,\n type: 'occlusion',\n count: OCCLUSION_QUERY_PAGE_INDEX_LIMIT,\n });\n if (!querySet.ok) return querySet;\n const resolveBuffer = device.createBuffer({\n label: `occlusion-page-${pageIndex}-resolve`,\n size: OCCLUSION_QUERY_PAGE_BYTES,\n usage: GPU_BUFFER_USAGE_QUERY_RESOLVE | GPU_BUFFER_USAGE_COPY_SRC,\n });\n if (!resolveBuffer.ok) {\n device.destroyQuerySet(querySet.value);\n return resolveBuffer;\n }\n const stagingBuffer = device.createBuffer({\n label: `occlusion-page-${pageIndex}-staging`,\n size: OCCLUSION_QUERY_PAGE_BYTES,\n usage: GPU_BUFFER_USAGE_MAP_READ | GPU_BUFFER_USAGE_COPY_DST,\n });\n if (!stagingBuffer.ok) {\n device.destroyBuffer(resolveBuffer.value);\n device.destroyQuerySet(querySet.value);\n return stagingBuffer;\n }\n return ok({\n pageIndex,\n querySet: querySet.value,\n resolveBuffer: resolveBuffer.value,\n stagingBuffer: stagingBuffer.value,\n });\n}\n\n/** Records resolve and copy only; caller owns one shared encoder and submit. */\nexport function recordOcclusionResolve(\n encoder: RhiCommandEncoder,\n resources: OcclusionQueryResources,\n firstQuery: number,\n queryCount: number,\n): Result<void, RhiError> {\n if (\n !Number.isSafeInteger(firstQuery) ||\n !Number.isSafeInteger(queryCount) ||\n firstQuery < 0 ||\n queryCount <= 0 ||\n firstQuery + queryCount > OCCLUSION_QUERY_PAGE_INDEX_LIMIT\n ) {\n return err(\n new RhiErrorClass({\n code: 'webgpu-runtime-error',\n expected: 'query range stays within one 4096-index page',\n hint: 'allocate a bounded page before recording occlusion resolve',\n }),\n );\n }\n const resolved = encoder.resolveQuerySet(\n resources.querySet,\n firstQuery,\n queryCount,\n resources.resolveBuffer,\n 0,\n );\n if (!resolved.ok) return resolved;\n encoder.copyBufferToBuffer(resources.resolveBuffer, resources.stagingBuffer, queryCount * 8);\n return ok(undefined);\n}\n\nfunction finiteBounds(bounds: OcclusionBounds | undefined): bounds is OcclusionBounds {\n if (bounds === undefined) return false;\n return [...bounds.min, ...bounds.max].every((value) => Number.isFinite(value));\n}\n\n/** Creates only the transport plan; confidence remains owned by visibility facet/M4. */\nexport function buildOcclusionPassPlan(input: OcclusionPassInput): OcclusionPassPlan | undefined {\n if (\n input.transparent === true ||\n input.deformed === true ||\n !finiteBounds(input.bounds) ||\n !Number.isSafeInteger(input.queryIndex) ||\n input.queryIndex < 0\n ) {\n return undefined;\n }\n return Object.freeze({\n after: input.opaquePass,\n depth: { resource: input.depthResource, usage: 'depth-read-only' as const },\n color: { resource: input.colorResource, usage: 'not-written' as const },\n proxyBounds: input.bounds,\n queryIndex: input.queryIndex,\n ...(input.identity === undefined ? {} : { identity: Object.freeze({ ...input.identity }) }),\n resolve: { queryIndex: input.queryIndex, bytes: 8 },\n copy: { asynchronous: true as const, bytes: 8 },\n writesColor: false as const,\n writesDepth: false as const,\n submitCount: 1 as const,\n mapSameFrame: false as const,\n });\n}\n\nimport type {\n Buffer,\n QuerySet,\n Result,\n RhiCommandEncoder,\n RhiDevice,\n RhiError,\n} from '@forgeax/engine-rhi';\nimport { err, ok, RhiError as RhiErrorClass } from '@forgeax/engine-rhi';\nimport {\n GPU_BUFFER_USAGE_COPY_DST,\n GPU_BUFFER_USAGE_COPY_SRC,\n GPU_BUFFER_USAGE_MAP_READ,\n GPU_BUFFER_USAGE_QUERY_RESOLVE,\n} from '../../gpu-usage';\nimport {\n OCCLUSION_QUERY_PAGE_BYTES,\n OCCLUSION_QUERY_PAGE_INDEX_LIMIT,\n} from './occlusion-query-pool';\n","/** Closed view roles used by the renderer-owned visibility facet. */\nexport type VisibilityViewRole = 'main' | 'shadow' | 'reflection' | 'probe';\n\nexport interface ViewKey {\n readonly attachmentId: string;\n readonly cameraEntity: number;\n readonly viewRole: VisibilityViewRole;\n readonly viewGeneration: number;\n}\n\nexport interface PrimitiveKey {\n readonly attachmentId: string;\n readonly worldGeneration: number;\n readonly primitiveSlot: number;\n readonly slotGeneration: number;\n}\n\nexport interface VisibilityCandidate {\n readonly level: number;\n readonly confidence: number;\n}\n\nexport interface VisibilityFacetInspection {\n readonly owner: 'persistent-render-scene';\n readonly activeViews: number;\n readonly facetRows: number;\n}\n\nexport interface VisibilityFacetInput {\n readonly view: ViewKey;\n readonly primitive: PrimitiveKey;\n readonly epoch: number;\n readonly candidate: VisibilityCandidate;\n}\n\nexport function viewKeyId(key: ViewKey): string {\n return `${key.attachmentId}:${key.cameraEntity}:${key.viewRole}:${key.viewGeneration}`;\n}\n\nexport function primitiveKeyId(key: PrimitiveKey): string {\n return `${key.attachmentId}:${key.worldGeneration}:${key.primitiveSlot}:${key.slotGeneration}`;\n}\n\nexport function viewKey(input: ViewKey): ViewKey {\n return Object.freeze({ ...input });\n}\n\nexport function primitiveKey(input: PrimitiveKey): PrimitiveKey {\n return Object.freeze({ ...input });\n}\n","import type {\n Buffer,\n QuerySet,\n RenderPipeline,\n Result,\n RhiCommandEncoder,\n RhiDevice,\n RhiError,\n RhiRenderPassEncoder,\n} from '@forgeax/engine-rhi';\nimport { err, ok, RhiError as RhiErrorClass } from '@forgeax/engine-rhi';\nimport {\n GPU_BUFFER_USAGE_COPY_DST,\n GPU_BUFFER_USAGE_MAP_READ,\n GPU_BUFFER_USAGE_VERTEX,\n} from '../../gpu-usage';\nimport type { PipelineBuilderShaderModuleFactory } from '../../pipeline-builder';\nimport type { VisibilityBudget } from './budget';\nimport type { VisibilityFacetStore } from './facet';\nimport {\n createOcclusionQueryResources,\n type OcclusionBounds,\n type OcclusionQueryResources,\n recordOcclusionResolve,\n} from './occlusion-pass';\nimport {\n OCCLUSION_QUERY_PAGE_INDEX_LIMIT,\n OcclusionQueryPool,\n type OcclusionQueryReservation,\n type OcclusionQueryTicket,\n} from './occlusion-query-pool';\nimport {\n type PrimitiveKey,\n primitiveKeyId,\n type ViewKey,\n type VisibilityCandidate,\n viewKeyId,\n} from './types';\n\nconst PROXY_VERTEX_FLOATS_PER_CANDIDATE = 36 * 4;\nconst PROXY_GEOMETRY_BYTES =\n OCCLUSION_QUERY_PAGE_INDEX_LIMIT * PROXY_VERTEX_FLOATS_PER_CANDIDATE * 4;\n\n/** @internal Deterministic producer hook; never configured by the player API. */\nexport interface OcclusionRuntimeTestHooks {\n readonly beforeMap?: () => Promise<void>;\n}\n\nlet runtimeTestHooks: OcclusionRuntimeTestHooks | undefined;\n\n/** @internal Used only by the production evidence falsification harness. */\nexport function setOcclusionRuntimeTestHooks(hooks: OcclusionRuntimeTestHooks | undefined): void {\n runtimeTestHooks = hooks;\n}\n\nexport interface OcclusionRuntimeCandidate {\n readonly view: ViewKey;\n readonly primitive: PrimitiveKey;\n readonly epoch: number;\n readonly bounds: OcclusionBounds;\n readonly candidate: VisibilityCandidate;\n readonly deviceGeneration: number;\n /** Clip-space triangles for the conservative bounds proxy. */\n readonly proxyVertices?: Float32Array;\n}\n\nexport interface OcclusionFrameProjection {\n readonly querySet: QuerySet;\n readonly queryIndex: number;\n readonly queryCount: number;\n readonly sampleCount: 1 | 4;\n readonly pageIndex: number;\n readonly reservationId: number;\n readonly encodeProxyBounds: (pass: RhiRenderPassEncoder) => Result<void, RhiError>;\n readonly beginCandidate: (pass: RhiRenderPassEncoder) => Result<void, RhiError>;\n readonly endCandidate: (pass: RhiRenderPassEncoder) => Result<void, RhiError>;\n readonly recordResolve: (encoder: RhiCommandEncoder) => Result<void, RhiError>;\n readonly commit: (\n submitted: boolean,\n submissionGeneration: number,\n profilePhase?: OcclusionProfilePhaseRunner,\n ) => void;\n}\n\nexport type OcclusionProfilePhaseRunner = <T>(\n phase: 'record/occlusion-query-submit' | 'record/occlusion-global-advance',\n action: () => T,\n) => T;\n\ninterface PendingFrame {\n readonly reservations: readonly OcclusionQueryReservation[];\n readonly resources: OcclusionQueryResources;\n readonly candidates: readonly OcclusionRuntimeCandidate[];\n readonly sampleCount: 1 | 4;\n endedCount: number;\n readonly proxyFloatCount: number;\n}\n\n/**\n * RenderSystem-owned query transport. It is deliberately the only bridge\n * between the logical pool, the typed graph raster pass, and facet completion.\n */\nexport class OcclusionRenderRuntime {\n private readonly pool = new OcclusionQueryPool();\n private readonly resources = new Map<number, OcclusionQueryResources>();\n private readonly activeCompletions = new Map<OcclusionQueryResources, Promise<void>>();\n private readonly retiredResources = new Set<OcclusionQueryResources>();\n /** Candidate descriptors are rebuilt only when the extracted frame changes. */\n private candidateSource: readonly OcclusionRuntimeCandidate[] | undefined;\n private validCandidates: readonly OcclusionRuntimeCandidate[] = [];\n private readonly candidateByKey = new Map<string, OcclusionRuntimeCandidate>();\n private lastPrepareUnavailable = false;\n private pendingFrame: PendingFrame | undefined;\n private disposed = false;\n private proxyBuffer: Buffer | undefined;\n private readonly proxyScratch: Float32Array;\n private proxyPipeline: RenderPipeline | undefined;\n private proxyPipelineSampleCount: 1 | 4 | undefined;\n private readonly queryLatencySamplesUs: number[] = [];\n private lastQueryLatencyUs = 0;\n private readonly projection: OcclusionFrameProjection;\n\n constructor(\n private readonly device: RhiDevice,\n private readonly facets: VisibilityFacetStore,\n private readonly shaderModuleFactory?: PipelineBuilderShaderModuleFactory,\n private readonly budget: VisibilityBudget = facets.visibilityBudget(),\n ) {\n const runtime = this;\n this.proxyScratch = new Float32Array(\n Math.min(this.budget.effectiveQueryBudget, OCCLUSION_QUERY_PAGE_INDEX_LIMIT) *\n PROXY_VERTEX_FLOATS_PER_CANDIDATE,\n );\n this.projection = {\n get querySet() {\n return runtime.pendingFrame?.resources.querySet as QuerySet;\n },\n get queryIndex() {\n return runtime.pendingFrame?.reservations[0]?.queryIndex ?? 0;\n },\n get queryCount() {\n return runtime.pendingFrame?.reservations.length ?? 0;\n },\n get sampleCount() {\n return runtime.pendingFrame?.sampleCount ?? 1;\n },\n get pageIndex() {\n return runtime.pendingFrame?.reservations[0]?.pageIndex ?? 0;\n },\n get reservationId() {\n return runtime.pendingFrame?.reservations[0]?.reservationId ?? 0;\n },\n encodeProxyBounds: (pass) => {\n const pending = runtime.pendingFrame;\n return pending === undefined\n ? err(runtimeError('the current RenderSystem frame owns the occlusion candidate'))\n : runtime.encodeProxyBounds(pass, pending);\n },\n beginCandidate: (pass) => {\n const pending = runtime.pendingFrame;\n if (pending === undefined || pending.endedCount >= pending.reservations.length) {\n return err(runtimeError('the current RenderSystem frame owns the occlusion candidate'));\n }\n return pass.beginOcclusionQuery(pending.reservations[pending.endedCount]?.queryIndex ?? 0);\n },\n endCandidate: (pass) => {\n const pending = runtime.pendingFrame;\n if (pending === undefined || pending.endedCount >= pending.reservations.length) {\n return err(runtimeError('the current RenderSystem frame owns the occlusion candidate'));\n }\n const ended = pass.endOcclusionQuery();\n if (ended.ok) pending.endedCount += 1;\n return ended;\n },\n recordResolve: (encoder) => {\n const pending = runtime.pendingFrame;\n if (pending === undefined || pending.endedCount !== pending.reservations.length) {\n return err(runtimeError('the real geometry pass must end its occlusion query first'));\n }\n return recordOcclusionResolve(\n encoder,\n pending.resources,\n pending.reservations[0]?.queryIndex ?? 0,\n pending.reservations.length,\n );\n },\n commit: (submitted, submissionGeneration, profilePhase) => {\n const pending = runtime.pendingFrame;\n if (pending !== undefined)\n runtime.commit(pending, submitted, submissionGeneration, profilePhase);\n },\n };\n }\n\n prepare(candidate: OcclusionRuntimeCandidate): OcclusionFrameProjection | undefined {\n // Keep the single-candidate helper useful for transport unit tests and\n // direct callers. The RenderSystem uses prepareBatch's facet-owned queue.\n return this.prepareBatch([candidate], 1, false);\n }\n\n prepareBatch(\n candidates: readonly OcclusionRuntimeCandidate[],\n sampleCount: 1 | 4 = 1,\n useReadyQueue = true,\n ): OcclusionFrameProjection | undefined {\n this.lastPrepareUnavailable = false;\n if (this.disposed || candidates.length === 0) return undefined;\n if (this.pendingFrame !== undefined) {\n this.lastPrepareUnavailable = true;\n return undefined;\n }\n if (this.candidateSource !== candidates) {\n this.candidateSource = candidates;\n this.candidateByKey.clear();\n const valid: OcclusionRuntimeCandidate[] = [];\n for (const candidate of candidates) {\n this.candidateByKey.set(candidateKey(candidate.view, candidate.primitive), candidate);\n if (finiteBounds(candidate.bounds)) valid.push(candidate);\n }\n this.validCandidates = valid;\n }\n const valid = this.validCandidates;\n if (valid.length === 0) return undefined;\n\n let selectedCandidates: OcclusionRuntimeCandidate[];\n if (!useReadyQueue) {\n selectedCandidates = valid.slice(0, this.budget.effectiveQueryBudget);\n } else {\n const firstView = valid[0]?.view;\n if (firstView === undefined) return undefined;\n selectedCandidates = [];\n for (const entry of this.facets.dequeueQueryCandidates(\n firstView,\n this.budget.effectiveQueryBudget,\n )) {\n const candidate = this.candidateByKey.get(candidateKey(entry.view, entry.primitive));\n if (candidate === undefined || !finiteBounds(candidate.bounds)) {\n this.facets.requeueQueryCandidate(entry.view, entry.primitive);\n continue;\n }\n selectedCandidates.push(candidate);\n }\n // No ready work is a normal bounded-query frame, not a transport error.\n if (selectedCandidates.length === 0) return undefined;\n }\n\n const reservations: OcclusionQueryReservation[] = [];\n let selectedCount = 0;\n while (selectedCount < selectedCandidates.length) {\n const candidate = selectedCandidates[selectedCount];\n if (candidate === undefined) break;\n const reservation = this.pool.reserve({\n viewKey: viewKeyId(candidate.view),\n attachmentId: candidate.view.attachmentId,\n deviceGeneration: candidate.deviceGeneration,\n worldGeneration: candidate.primitive.worldGeneration,\n primitiveSlot: candidate.primitive.primitiveSlot,\n slotGeneration: candidate.primitive.slotGeneration,\n });\n if (reservation === undefined) {\n this.lastPrepareUnavailable = true;\n break;\n }\n if (reservations.length > 0 && reservation.pageIndex !== reservations[0]?.pageIndex) {\n this.pool.cancel(reservation);\n this.lastPrepareUnavailable = true;\n break;\n }\n reservations.push(reservation);\n selectedCount += 1;\n if (reservations.length >= this.budget.effectiveQueryBudget) break;\n }\n if (reservations.length === 0) {\n for (const candidate of selectedCandidates) {\n if (useReadyQueue) this.facets.requeueQueryCandidate(candidate.view, candidate.primitive);\n }\n return undefined;\n }\n if (reservations.length < selectedCandidates.length) {\n for (const reservation of reservations) this.pool.cancel(reservation);\n for (const candidate of selectedCandidates) {\n if (useReadyQueue) this.facets.requeueQueryCandidate(candidate.view, candidate.primitive);\n }\n return undefined;\n }\n const resources = this.ensureResources(reservations[0]?.pageIndex ?? 0);\n if (resources === undefined) {\n for (const reservation of reservations) this.pool.cancel(reservation);\n this.lastPrepareUnavailable = true;\n for (const candidate of selectedCandidates) {\n if (useReadyQueue) this.facets.requeueQueryCandidate(candidate.view, candidate.primitive);\n }\n return undefined;\n }\n const selected = selectedCandidates;\n let proxyFloatCount = 0;\n for (const candidate of selected) {\n const vertices = candidate.proxyVertices;\n if (vertices === undefined) continue;\n if (proxyFloatCount + vertices.length > this.proxyScratch.length) {\n for (const reservation of reservations) this.pool.cancel(reservation);\n for (const queuedCandidate of selectedCandidates) {\n if (useReadyQueue) {\n this.facets.requeueQueryCandidate(queuedCandidate.view, queuedCandidate.primitive);\n }\n }\n this.lastPrepareUnavailable = true;\n return undefined;\n }\n this.proxyScratch.set(vertices, proxyFloatCount);\n proxyFloatCount += vertices.length;\n }\n const pending: PendingFrame = {\n reservations,\n resources,\n candidates: selected,\n sampleCount,\n endedCount: 0,\n proxyFloatCount,\n };\n this.pendingFrame = pending;\n return this.projection;\n }\n\n inspect(): ReturnType<OcclusionQueryPool['inspect']> {\n return this.pool.inspect();\n }\n\n get prepareUnavailable(): boolean {\n return this.lastPrepareUnavailable;\n }\n\n /** Map-only latency from the submitted query page; queue wait is excluded. */\n inspectQueryLatency(): { readonly median: number; readonly p95: number; readonly last: number } {\n if (this.queryLatencySamplesUs.length === 0) {\n return { median: 0, p95: 0, last: this.lastQueryLatencyUs };\n }\n const sorted = [...this.queryLatencySamplesUs].sort((left, right) => left - right);\n const rank = (percentile: number): number =>\n sorted[Math.max(0, Math.ceil(sorted.length * percentile) - 1)] ?? 0;\n return {\n median: rank(0.5),\n p95: rank(0.95),\n last: this.lastQueryLatencyUs,\n };\n }\n\n /**\n * Wait until query readbacks submitted before the current observation have\n * settled. The renderer receipt only fences command submission; query\n * completion also includes the asynchronous map/unmap transition. Keeping\n * that fence here makes `renderer.observe()` publish the latest visibility\n * result and measured map latency instead of racing the readback promise.\n */\n async waitForCompletions(): Promise<void> {\n // A submission callback can publish the next page while the previous\n // completion is settling. Drain until the map stays empty so observation\n // cannot return with a newer query still racing the inspection update.\n for (;;) {\n const completions = [...this.activeCompletions.values()];\n if (completions.length === 0) return;\n await Promise.all(completions);\n }\n }\n\n /** Count a successful frame for hidden rows that were not queried this frame. */\n advanceSuccessfulSubmit(submissionGeneration: number): void {\n this.facets.advanceSuccessfulSubmits(submissionGeneration);\n }\n\n dispose(): void {\n if (this.disposed) return;\n this.disposed = true;\n this.pool.dispose();\n for (const resource of this.resources.values()) {\n const completion = this.activeCompletions.get(resource);\n if (completion === undefined) {\n this.destroyResources(resource);\n } else {\n // A completion may still be awaiting mapAsync. Destroying its staging\n // buffer here makes Dawn report a use-after-destroy validation error.\n void completion.then(() => this.destroyResources(resource));\n }\n }\n this.resources.clear();\n if (this.proxyBuffer !== undefined) this.device.destroyBuffer(this.proxyBuffer);\n this.proxyBuffer = undefined;\n this.proxyPipeline = undefined;\n this.proxyPipelineSampleCount = undefined;\n this.candidateSource = undefined;\n this.validCandidates = [];\n this.candidateByKey.clear();\n this.lastPrepareUnavailable = false;\n this.pendingFrame = undefined;\n }\n\n private ensureResources(pageIndex: number): OcclusionQueryResources | undefined {\n const existing = this.resources.get(pageIndex);\n if (existing !== undefined) return existing;\n const created = createOcclusionQueryResources(this.device, pageIndex);\n if (!created.ok) return undefined;\n this.resources.set(pageIndex, created.value);\n return created.value;\n }\n\n private commit(\n pending: PendingFrame,\n submitted: boolean,\n submissionGeneration: number,\n profilePhase?: OcclusionProfilePhaseRunner,\n ): void {\n if (this.pendingFrame !== pending) return;\n this.pendingFrame = undefined;\n const tickets: OcclusionQueryTicket[] = [];\n const accepted =\n profilePhase === undefined\n ? this.publishAndApplySubmit(pending, submitted, submissionGeneration, tickets)\n : profilePhase('record/occlusion-query-submit', () =>\n this.publishAndApplySubmit(pending, submitted, submissionGeneration, tickets),\n );\n if (!accepted) {\n for (const reservation of pending.reservations) this.pool.cancel(reservation);\n for (const candidate of pending.candidates) {\n this.facets.applyConfidence(candidate.view, candidate.primitive, {\n type: 'failure',\n submissionGeneration,\n });\n }\n return;\n }\n\n if (profilePhase === undefined) {\n this.facets.advanceSuccessfulSubmits(submissionGeneration);\n } else {\n profilePhase('record/occlusion-global-advance', () =>\n this.facets.advanceSuccessfulSubmits(submissionGeneration),\n );\n }\n const completion = this.completeAfterSubmit(tickets, pending);\n this.activeCompletions.set(pending.resources, completion);\n void completion.then(() => {\n if (this.activeCompletions.get(pending.resources) === completion) {\n this.activeCompletions.delete(pending.resources);\n }\n });\n }\n\n private publishAndApplySubmit(\n pending: PendingFrame,\n submitted: boolean,\n submissionGeneration: number,\n tickets: OcclusionQueryTicket[],\n ): boolean {\n for (const reservation of pending.reservations) {\n const ticket = this.pool.publish(reservation, { submitted, submissionGeneration });\n if (ticket !== undefined) tickets.push(ticket);\n }\n if (!submitted || tickets.length !== pending.reservations.length) return false;\n const submitEvent = Object.freeze({ type: 'submit' as const, submissionGeneration });\n for (const candidate of pending.candidates) {\n this.facets.applyConfidence(candidate.view, candidate.primitive, submitEvent);\n }\n return true;\n }\n\n private destroyResources(resource: OcclusionQueryResources): void {\n if (this.retiredResources.has(resource)) return;\n this.retiredResources.add(resource);\n this.device.destroyBuffer(resource.resolveBuffer);\n this.device.destroyBuffer(resource.stagingBuffer);\n this.device.destroyQuerySet(resource.querySet);\n }\n\n private async completeAfterSubmit(\n tickets: readonly OcclusionQueryTicket[],\n pending: PendingFrame,\n ): Promise<void> {\n try {\n await this.device.queue.onSubmittedWorkDone();\n const mapStart = performance.now();\n await runtimeTestHooks?.beforeMap?.();\n const mapped = await pending.resources.stagingBuffer.mapAsync(\n GPU_BUFFER_USAGE_MAP_READ,\n 0,\n pending.reservations.length * 8,\n );\n if (!mapped.ok) throw mapped.error;\n // Inspection is a bounded integer POD; keep the real map-only duration\n // while rounding sub-microsecond timer noise at the transport boundary.\n this.lastQueryLatencyUs = Math.max(0, Math.round((performance.now() - mapStart) * 1000));\n this.queryLatencySamplesUs.push(this.lastQueryLatencyUs);\n if (this.queryLatencySamplesUs.length > 64) this.queryLatencySamplesUs.shift();\n const bytes = mapped.value.getMappedRange(0, pending.reservations.length * 8);\n if (!bytes.ok) throw bytes.error;\n // WebGPU detaches the mapped range when unmap() is called. Copy the\n // bounded query payload while it is still mapped, then release the\n // staging buffer before applying any facet mutations. Reading the view\n // after unmap would throw on real Dawn and turn every result into the\n // fail-open failure path (leaving candidates permanently visible).\n const data = new Uint8Array(bytes.value.slice(0));\n const dataView = new DataView(data.buffer);\n const firstQuery = pending.reservations[0]?.queryIndex ?? 0;\n mapped.value.unmap();\n for (let ticketIndex = tickets.length - 1; ticketIndex >= 0; ticketIndex -= 1) {\n const ticket = tickets[ticketIndex];\n if (ticket === undefined) continue;\n const candidateIndex = ticket.queryIndex - firstQuery;\n const samples = dataView.getUint32(candidateIndex * 8, true);\n const completion = this.pool.complete(ticket, samples);\n if (completion.status !== 'accepted') continue;\n const candidate = pending.candidates[candidateIndex];\n if (candidate === undefined) continue;\n this.facets.applyConfidence(candidate.view, candidate.primitive, {\n type: 'result',\n samples,\n submissionGeneration: ticket.submissionGeneration,\n });\n this.facets.applyCompletion(\n candidate.view,\n candidate.primitive,\n candidate.epoch,\n candidate.candidate,\n );\n }\n } catch {\n for (const ticket of tickets) {\n this.pool.complete(ticket, Number.NaN);\n const candidate =\n pending.candidates[ticket.queryIndex - (pending.reservations[0]?.queryIndex ?? 0)];\n if (candidate !== undefined) {\n this.facets.applyConfidence(candidate.view, candidate.primitive, {\n type: 'failure',\n submissionGeneration: ticket.submissionGeneration,\n });\n }\n }\n }\n }\n\n private encodeProxyBounds(\n pass: RhiRenderPassEncoder,\n pending: PendingFrame,\n ): Result<void, RhiError> {\n if (pending.proxyFloatCount === 0) {\n return err(runtimeError('every occlusion candidate needs conservative proxy geometry'));\n }\n const pipeline = this.ensureProxyPipeline(pending.sampleCount);\n if (pipeline === undefined) {\n // RhiNull has no shader-module factory. It still records the complete\n // query fan-out structurally so lifecycle and identity tests exercise\n // the same bounded transport; real backends take the mesh path below.\n for (const reservation of pending.reservations) {\n const began = pass.beginOcclusionQuery(reservation.queryIndex);\n if (!began.ok) return began;\n const ended = pass.endOcclusionQuery();\n if (!ended.ok) return ended;\n }\n pending.endedCount = pending.reservations.length;\n return ok(undefined);\n }\n const buffer = this.ensureProxyBuffer(pending.proxyFloatCount * Float32Array.BYTES_PER_ELEMENT);\n if (buffer === undefined) {\n return err(runtimeError('the backend must allocate the bounded proxy geometry buffer'));\n }\n const uploaded = this.device.queue.writeBuffer(\n buffer,\n 0,\n this.proxyScratch.subarray(0, pending.proxyFloatCount),\n );\n if (!uploaded.ok) return uploaded;\n pass.setPipeline(pipeline);\n pass.setVertexBuffer(0, buffer);\n let vertexOffset = 0;\n for (let index = 0; index < pending.reservations.length; index += 1) {\n const vertices = pending.candidates[index]?.proxyVertices;\n if (vertices === undefined || vertices.length === 0) continue;\n const began = pass.beginOcclusionQuery(pending.reservations[index]?.queryIndex ?? 0);\n if (!began.ok) return began;\n pass.draw(vertices.length / 4, 1, vertexOffset / 4, 0);\n const ended = pass.endOcclusionQuery();\n if (!ended.ok) return ended;\n vertexOffset += vertices.length;\n }\n pending.endedCount = pending.reservations.length;\n return ok(undefined);\n }\n\n private ensureProxyBuffer(byteLength: number): Buffer | undefined {\n if (this.proxyBuffer !== undefined) return this.proxyBuffer;\n const created = this.device.createBuffer({\n label: 'occlusion-bounds-proxy-geometry',\n size: Math.max(16, PROXY_GEOMETRY_BYTES, byteLength),\n usage: GPU_BUFFER_USAGE_VERTEX | GPU_BUFFER_USAGE_COPY_DST,\n });\n if (!created.ok) return undefined;\n this.proxyBuffer = created.value;\n return created.value;\n }\n\n private ensureProxyPipeline(sampleCount: 1 | 4): RenderPipeline | undefined {\n if (this.proxyPipelineSampleCount === sampleCount && this.proxyPipeline !== undefined) {\n return this.proxyPipeline;\n }\n if (this.shaderModuleFactory === undefined) return undefined;\n const module = this.shaderModuleFactory.createShaderModule({\n label: 'occlusion-bounds-proxy',\n code: PROXY_BOUNDS_WGSL,\n });\n if (!module.ok) return undefined;\n const created = this.device.createRenderPipeline({\n label: 'occlusion-bounds-proxy',\n layout: 'auto',\n vertex: {\n module: module.value,\n entryPoint: 'vs_main',\n buffers: [\n {\n arrayStride: 16,\n stepMode: 'vertex',\n attributes: [{ shaderLocation: 0, offset: 0, format: 'float32x4' }],\n },\n ],\n },\n // The proxy is recorded in the typed main pass, whose color attachment\n // remains RGBA16Float. Keep the pass compatible while suppressing all\n // color writes; occlusion only consumes depth samples.\n fragment: {\n module: module.value,\n entryPoint: 'fs_main',\n targets: [{ format: 'rgba16float', writeMask: 0 }],\n },\n primitive: { topology: 'triangle-list' },\n depthStencil: {\n format: 'depth24plus-stencil8',\n depthWriteEnabled: false,\n depthCompare: 'less-equal',\n },\n multisample: { count: sampleCount },\n });\n if (!created.ok) return undefined;\n this.proxyPipeline = created.value;\n this.proxyPipelineSampleCount = sampleCount;\n return created.value;\n }\n}\n\nconst PROXY_BOUNDS_WGSL = `\n@vertex\nfn vs_main(@location(0) position: vec4f) -> @builtin(position) vec4f {\n return position;\n}\n@fragment\nfn fs_main() -> @location(0) vec4f {\n return vec4f(0.0);\n}\n`;\n\nfunction candidateKey(view: ViewKey, primitive: PrimitiveKey): string {\n return `${viewKeyId(view)}|${primitiveKeyId(primitive)}`;\n}\n\nfunction finiteBounds(bounds: OcclusionBounds): boolean {\n return [...bounds.min, ...bounds.max].every((value) => Number.isFinite(value));\n}\n\nfunction runtimeError(hint: string): RhiError {\n return new RhiErrorClass({\n code: 'webgpu-runtime-error',\n expected: 'RenderSystem owns one active occlusion candidate for the shared frame',\n hint,\n });\n}\n","import { R_MIN } from '@forgeax/engine-types';\nimport type { ProbeBlendInspection } from '../inspection-types';\nimport {\n PROBE_BLEND_RECORD_BYTE_SIZE,\n PROBE_BLEND_RECORD_CAPACITY,\n type ProbeBlendRecord,\n type ProbeBlendRecordSentinel,\n} from './probe-blend-record';\n\nexport const PROBE_R_MIN = R_MIN;\nexport const PROBE_MAX_CONTRIBUTORS = PROBE_BLEND_RECORD_CAPACITY;\n\nexport interface ProbeBlendContributor {\n readonly identity: string;\n readonly admitted: boolean;\n readonly distance: number;\n readonly radius: number;\n readonly irradiance: ArrayLike<number>;\n}\n\nexport interface ProbeBlendInput {\n readonly contributors: readonly ProbeBlendContributor[];\n readonly normal: readonly [number, number, number];\n readonly skyIrradiance: readonly [number, number, number];\n readonly radiusMinimum?: number;\n}\n\nexport interface ProbeSceneObjectInput {\n readonly objectKey: number;\n readonly generation: number;\n readonly position: readonly [number, number, number];\n}\n\nexport interface ProbeBlendBufferProjection {\n /** Stable producer identity; dirty evidence is never portable across producers. */\n readonly sourceIdentity: object;\n readonly revision: number;\n /** Exact accepted revision from which dirty/removed evidence was derived. */\n readonly baseRevision: number;\n /** Producer-computed lane capacity, including the slot-zero sentinel. */\n readonly capacity: number;\n readonly records: readonly {\n readonly cacheKey: number;\n readonly record: ProbeBlendRecord;\n }[];\n /** Records whose generation or payload changed at this revision. */\n readonly dirtyRecords: readonly {\n readonly cacheKey: number;\n readonly record: ProbeBlendRecord;\n }[];\n /** Cache keys retired at this revision. */\n readonly removedCacheKeys: readonly number[];\n}\n\nexport interface ProbeSceneProbeInput {\n readonly identity: string;\n readonly position: readonly [number, number, number];\n readonly radius: number;\n readonly irradiance: ArrayLike<number>;\n readonly admitted: boolean;\n}\n\nexport interface ProbeAdmissionReceipt {\n readonly activeIdentities: readonly string[];\n readonly admittedIdentities: readonly string[];\n readonly rejectedIdentities: readonly string[];\n readonly stableOrder: readonly string[];\n readonly capacity: number;\n readonly overflowReason?: 'active-count-exceeds-capacity';\n readonly scaleRadius: number;\n readonly finite: boolean;\n}\n\nexport type ProbeAdmissionError = {\n readonly code: 'capacity-exceeded' | 'invalid-admitted-prefix';\n readonly activeCount: number;\n readonly capacity: number;\n readonly receipt: ProbeAdmissionReceipt;\n};\n\nexport interface ProbeAdmissionResult {\n readonly admitted: readonly ProbeBlendContributor[];\n readonly active: readonly ProbeBlendContributor[];\n readonly rejected: readonly ProbeBlendContributor[];\n readonly receipt: ProbeAdmissionReceipt;\n readonly error?: ProbeAdmissionError;\n}\n\nexport interface ProbeSceneProjectionInput {\n readonly objects: readonly ProbeSceneObjectInput[];\n readonly probes: readonly ProbeSceneProbeInput[];\n /** Keep explicit zero-local rows for consumers whose published ABI always reads this page. */\n readonly retainSkyResidualRecords?: boolean;\n /** Optional analytic oracle input; records never store or replace Sky. */\n readonly skyIrradiance?: readonly [number, number, number];\n readonly sky?: {\n readonly available: boolean;\n readonly identity?: string;\n readonly sourceKey?: string;\n readonly irradiance: readonly [number, number, number];\n readonly fallbackReason?: string;\n };\n readonly worldRevision?: number;\n readonly lastKnownGood?: boolean;\n}\n\nexport interface ProbeSceneProjectionResult {\n readonly records: readonly ProbeBlendRecord[];\n readonly contributors: readonly ProbeBlendTerm[];\n readonly activeContributorCount: number;\n readonly admittedProbeCount: number;\n readonly coverage: number;\n readonly skyResidualFraction: number;\n readonly dirtyReasons: readonly ProbeSceneDirtyReason[];\n readonly affectedObjectKeys: readonly number[];\n readonly visits: number;\n readonly allocations: number;\n readonly uploads: number;\n readonly receipt: ProbeAdmissionReceipt;\n readonly error?: ProbeAdmissionError;\n}\n\nexport type ProbeSceneDirtyReason =\n | 'object-boundary'\n | 'probe-fact'\n | 'sky'\n | 'object-position'\n | 'world'\n | 'generation';\n\nexport interface ProbeBlendTerm {\n readonly identity: string;\n readonly distance: number;\n readonly radius: number;\n readonly coverage: number;\n readonly q: number;\n readonly scaledQ: number;\n readonly qHat: number;\n readonly alpha: number;\n}\n\nexport interface ProbeBlendResult {\n readonly terms: readonly ProbeBlendTerm[];\n readonly rStar: number;\n readonly Q: number;\n readonly C: number;\n readonly S: number;\n readonly SHPreblend: readonly number[];\n readonly skyIrradiance: readonly [number, number, number];\n readonly diffuse: readonly [number, number, number];\n readonly finite: boolean;\n readonly receipt: ProbeAdmissionReceipt;\n readonly error?: ProbeAdmissionError;\n readonly scaledQLogOffset: number;\n}\n\nconst SH_C0 = 0.28209479177387814;\nconst SH_C1 = 0.4886025119029199;\nconst SH_C2 = 1.0925484305920792;\nconst SH_C20 = 0.31539156525252005;\nconst SH_C22 = 0.5462742152960396;\n\nfunction finiteVector(values: ArrayLike<number>, length: number): boolean {\n if (values.length !== length) return false;\n for (let index = 0; index < values.length; index += 1) {\n if (!Number.isFinite(values[index])) return false;\n }\n return true;\n}\n\nfunction contributorIsActive(probe: ProbeBlendContributor, radiusMinimum: number): boolean {\n return (\n probe.admitted &&\n Number.isFinite(probe.distance) &&\n probe.distance >= 0 &&\n Number.isFinite(probe.radius) &&\n probe.radius >= radiusMinimum &&\n probe.distance < probe.radius &&\n finiteVector(probe.irradiance, 27)\n );\n}\n\nfunction emptyReceipt(radiusMinimum: number): ProbeAdmissionReceipt {\n return {\n activeIdentities: [],\n admittedIdentities: [],\n rejectedIdentities: [],\n stableOrder: [],\n capacity: PROBE_MAX_CONTRIBUTORS,\n scaleRadius: radiusMinimum,\n finite: true,\n };\n}\n\n/** Admission is the only owner allowed to order and bound probe candidates. */\nexport function admitProbeContributors(\n candidates: readonly ProbeBlendContributor[],\n radiusMinimum = PROBE_R_MIN,\n): ProbeAdmissionResult {\n const active = candidates.filter((candidate) => contributorIsActive(candidate, radiusMinimum));\n const overflowed = active.length > PROBE_MAX_CONTRIBUTORS;\n // Admission is a deterministic stable prefix, not an all-or-nothing gate.\n // Sort the complete active set by identity before clipping so query order\n // cannot change the selected contributors.\n const stableActive = active\n .slice()\n .sort((left, right) => left.identity.localeCompare(right.identity));\n const admitted = stableActive.slice(0, PROBE_MAX_CONTRIBUTORS);\n const rejected = stableActive.slice(PROBE_MAX_CONTRIBUTORS);\n const scaleRadius = active.reduce(\n (minimum, candidate) => Math.min(minimum, candidate.radius),\n active[0]?.radius ?? radiusMinimum,\n );\n const receipt: ProbeAdmissionReceipt = {\n activeIdentities: stableActive.map((candidate) => candidate.identity),\n admittedIdentities: admitted.map((candidate) => candidate.identity),\n rejectedIdentities: rejected.map((candidate) => candidate.identity),\n stableOrder: admitted.map((candidate) => candidate.identity),\n capacity: PROBE_MAX_CONTRIBUTORS,\n ...(overflowed ? { overflowReason: 'active-count-exceeds-capacity' as const } : {}),\n scaleRadius,\n finite: stableActive.every((candidate) => Number.isFinite(candidate.radius)),\n };\n return {\n active: stableActive,\n admitted,\n rejected,\n receipt,\n ...(overflowed\n ? {\n error: {\n code: 'capacity-exceeded' as const,\n activeCount: active.length,\n capacity: PROBE_MAX_CONTRIBUTORS,\n receipt,\n },\n }\n : {}),\n };\n}\n\nfunction invalidInputResult(\n radiusMinimum: number,\n code: ProbeAdmissionError['code'],\n): ProbeBlendResult {\n const receipt = emptyReceipt(radiusMinimum);\n return {\n terms: [],\n rStar: radiusMinimum,\n Q: 0,\n C: 0,\n S: 1,\n SHPreblend: new Array<number>(27).fill(0),\n skyIrradiance: [0, 0, 0],\n diffuse: [0, 0, 0],\n finite: false,\n receipt,\n scaledQLogOffset: 0,\n error: { code, activeCount: 0, capacity: PROBE_MAX_CONTRIBUTORS, receipt },\n };\n}\n\n/** Neumaier compensated sum in JavaScript's IEEE-754 binary64 number type. */\nexport function neumaierSum(values: readonly number[]): number {\n let sum = 0;\n let correction = 0;\n for (const value of values) {\n const next = sum + value;\n if (Math.abs(sum) >= Math.abs(value)) correction += sum - next + value;\n else correction += value - next + sum;\n sum = next;\n }\n return sum + correction;\n}\n\n/** Round a finite analytic value at the single f32 boundary. */\nexport function roundProbeToF32(value: number): number | undefined {\n return Number.isFinite(value) ? new Float32Array([value])[0] : undefined;\n}\n\nexport function scaledProbeWeight(\n distance: number,\n radius: number,\n radiusMinimum = PROBE_R_MIN,\n): { readonly coverage: number; readonly q: number } {\n if (\n !Number.isFinite(distance) ||\n distance < 0 ||\n !Number.isFinite(radius) ||\n radius < radiusMinimum ||\n distance >= radius\n ) {\n return { coverage: 0, q: 0 };\n }\n const ratio = distance / radius;\n const coverage = 1 - ratio * ratio;\n // q is intentionally diagnostic only. The kernel consumes scaledQ below.\n return { coverage, q: coverage / (radius * radius) };\n}\n\nfunction sh9Irradiance(\n coefficients: readonly number[],\n normal: readonly [number, number, number],\n): number[] {\n const x = normal[0];\n const y = normal[1];\n const z = normal[2];\n const basis = [\n SH_C0,\n SH_C1 * y,\n SH_C1 * z,\n SH_C1 * x,\n SH_C2 * x * y,\n SH_C2 * y * z,\n SH_C20 * (3 * z * z - 1),\n SH_C2 * x * z,\n SH_C22 * (x * x - y * y),\n ];\n const result = [0, 0, 0];\n for (let band = 0; band < basis.length; band += 1) {\n const factor = basis[band] ?? 0;\n const offset = band * 3;\n result[0] = (result[0] ?? 0) + (coefficients[offset] ?? 0) * factor;\n result[1] = (result[1] ?? 0) + (coefficients[offset + 1] ?? 0) * factor;\n result[2] = (result[2] ?? 0) + (coefficients[offset + 2] ?? 0) * factor;\n }\n return result;\n}\n\nfunction vectorNeumaierSum(values: readonly (readonly number[])[], width: number): number[] {\n return Array.from({ length: width }, (_, channel) =>\n neumaierSum(values.map((value) => value[channel] ?? 0)),\n );\n}\n\ninterface ProbeBlendCoefficients {\n readonly terms: readonly ProbeBlendTerm[];\n readonly rStar: number;\n readonly Q: number;\n readonly C: number;\n readonly S: number;\n readonly SHPreblend: readonly number[];\n readonly receipt: ProbeAdmissionReceipt;\n readonly finite: boolean;\n readonly scaledQLogOffset: number;\n}\n\nfunction blendProbeCoefficients(\n contributors: readonly ProbeBlendContributor[],\n radiusMinimum: number,\n): ProbeBlendCoefficients | undefined {\n if (\n contributors.length > PROBE_MAX_CONTRIBUTORS ||\n contributors.some((contributor) => !contributorIsActive(contributor, radiusMinimum))\n ) {\n return undefined;\n }\n const rStar = contributors.reduce(\n (minimum, contributor) => Math.min(minimum, contributor.radius),\n contributors[0]?.radius ?? radiusMinimum,\n );\n const rawTerms = contributors.map((contributor) => {\n const { coverage } = scaledProbeWeight(contributor.distance, contributor.radius, radiusMinimum);\n const scaledRatio = rStar / contributor.radius;\n return {\n contributor,\n coverage,\n // Diagnostic q is never used for Q, alpha, C, or SH accumulation.\n q: coverage / (contributor.radius * contributor.radius),\n scaledQ: coverage * scaledRatio * scaledRatio,\n };\n });\n // The frozen minimum radius bounds rStar/r_i by one. The kernel consumes\n // only scaledQ, never diagnostic q or a reciprocal-square value.\n const scaledQLogOffset = 0;\n const finiteTerms = rawTerms;\n if (finiteTerms.some((term) => !Number.isFinite(term.scaledQ))) return undefined;\n const Q = neumaierSum(finiteTerms.map((term) => term.scaledQ));\n const terms = finiteTerms.map((term) => ({\n identity: term.contributor.identity,\n distance: term.contributor.distance,\n radius: term.contributor.radius,\n coverage: term.coverage,\n q: term.q,\n scaledQ: term.scaledQ,\n qHat: term.scaledQ,\n alpha: Q > 0 ? term.scaledQ / Q : 0,\n }));\n let product = 1;\n for (const term of finiteTerms) product *= 1 - term.coverage;\n const C = 1 - product;\n const S = 1 - C;\n const weightedSh = finiteTerms.map((term) =>\n Array.from(term.contributor.irradiance, (value) => value * (Q > 0 ? term.scaledQ / Q : 0)),\n );\n const SHPreblend = vectorNeumaierSum(weightedSh, 27).map((value) => value * C);\n const finite =\n Number.isFinite(Q) &&\n Number.isFinite(C) &&\n Number.isFinite(S) &&\n SHPreblend.every(Number.isFinite) &&\n finiteTerms.every((term) => Number.isFinite(term.scaledQ));\n const receipt: ProbeAdmissionReceipt = {\n activeIdentities: contributors.map((contributor) => contributor.identity),\n admittedIdentities: contributors.map((contributor) => contributor.identity),\n rejectedIdentities: [],\n stableOrder: contributors.map((contributor) => contributor.identity),\n capacity: PROBE_MAX_CONTRIBUTORS,\n scaleRadius: rStar,\n finite,\n };\n return {\n terms,\n rStar,\n Q,\n C,\n S,\n SHPreblend,\n finite,\n receipt,\n scaledQLogOffset,\n };\n}\n\n/**\n * Evaluate the CPU analytic oracle. Sky is deliberately an explicit residual\n * input and never becomes a contributor or a q/Q term.\n */\nexport function blendLightProbes(input: ProbeBlendInput): ProbeBlendResult {\n const radiusMinimum = input.radiusMinimum ?? PROBE_R_MIN;\n const normal = input.normal;\n const sky = input.skyIrradiance;\n if (!finiteVector(normal, 3) || !finiteVector(sky, 3)) {\n return invalidInputResult(radiusMinimum, 'invalid-admitted-prefix');\n }\n const coefficients = blendProbeCoefficients(input.contributors, radiusMinimum);\n if (coefficients === undefined)\n return invalidInputResult(radiusMinimum, 'invalid-admitted-prefix');\n const shIrradiance = sh9Irradiance(coefficients.SHPreblend, normal);\n const diffuse = [0, 1, 2].map(\n (channel) => Math.max(shIrradiance[channel] ?? 0, 0) + coefficients.S * (sky[channel] ?? 0),\n ) as [number, number, number];\n return {\n ...coefficients,\n skyIrradiance: [sky[0], sky[1], sky[2]],\n diffuse,\n finite: coefficients.finite && diffuse.every(Number.isFinite),\n };\n}\n\nfunction vectorDistance(\n left: readonly [number, number, number],\n right: readonly [number, number, number],\n): number {\n const dx = left[0] - right[0];\n const dy = left[1] - right[1];\n const dz = left[2] - right[2];\n return Math.hypot(dx, dy, dz);\n}\n\nfunction encodeProbeRecord(\n objectKey: number,\n generation: number,\n localBlendFraction: number,\n shPreblend: readonly number[],\n candidate: boolean,\n accepted: boolean,\n lastKnownGood: boolean,\n sentinel: ProbeBlendRecordSentinel | undefined,\n): ProbeBlendRecord {\n const values = new Float32Array(PROBE_BLEND_RECORD_BYTE_SIZE / Float32Array.BYTES_PER_ELEMENT);\n values[0] = objectKey;\n values[1] = generation;\n values[2] = roundProbeToF32(localBlendFraction) ?? 0;\n values[3] = (candidate ? 1 : 0) | (accepted ? 2 : 0) | (lastKnownGood ? 4 : 0);\n for (let band = 0; band < 9; band += 1) {\n const lane = 4 + band * 4;\n values[lane] = roundProbeToF32(shPreblend[band * 3] ?? 0) ?? 0;\n values[lane + 1] = roundProbeToF32(shPreblend[band * 3 + 1] ?? 0) ?? 0;\n values[lane + 2] = roundProbeToF32(shPreblend[band * 3 + 2] ?? 0) ?? 0;\n values[lane + 3] = 0;\n }\n const packedSh = new Array<number>(27);\n for (let band = 0; band < 9; band += 1) {\n packedSh[band * 3] = values[4 + band * 4] ?? 0;\n packedSh[band * 3 + 1] = values[5 + band * 4] ?? 0;\n packedSh[band * 3 + 2] = values[6 + band * 4] ?? 0;\n }\n return {\n objectKey,\n generation,\n localBlendFraction: values[2] ?? 0,\n shPreblend: packedSh,\n bytes: new Uint8Array(values.buffer),\n byteLength: values.byteLength,\n candidate,\n accepted,\n lastKnownGood,\n ...(sentinel === undefined ? {} : { sentinel }),\n };\n}\n\nfunction sameList(left: readonly string[], right: readonly string[]): boolean {\n return left.length === right.length && left.every((value, index) => value === right[index]);\n}\n\nfunction sameVector3(\n left: readonly [number, number, number],\n right: readonly [number, number, number],\n): boolean {\n return left[0] === right[0] && left[1] === right[1] && left[2] === right[2];\n}\n\nfunction sameProbeFacts(\n left: readonly ProbeSceneProbeInput[],\n right: readonly ProbeSceneProbeInput[],\n): boolean {\n if (left.length !== right.length) return false;\n return left.every((probe, index) => {\n const other = right[index];\n if (\n other === undefined ||\n probe.identity !== other.identity ||\n probe.radius !== other.radius ||\n probe.admitted !== other.admitted ||\n !sameVector3(probe.position, other.position) ||\n probe.irradiance.length !== other.irradiance.length\n )\n return false;\n for (let value = 0; value < probe.irradiance.length; value += 1) {\n if (probe.irradiance[value] !== other.irradiance[value]) return false;\n }\n return true;\n });\n}\n\nfunction sameSkyFacts(left: ProbeSceneProjectionInput, right: ProbeSceneProjectionInput): boolean {\n const leftSky = left.sky;\n const rightSky = right.sky;\n if ((leftSky === undefined) !== (rightSky === undefined)) return false;\n if (\n leftSky !== undefined &&\n rightSky !== undefined &&\n (leftSky.available !== rightSky.available ||\n leftSky.identity !== rightSky.identity ||\n leftSky.sourceKey !== rightSky.sourceKey ||\n leftSky.fallbackReason !== rightSky.fallbackReason ||\n !sameVector3(leftSky.irradiance, rightSky.irradiance))\n )\n return false;\n if ((left.skyIrradiance === undefined) !== (right.skyIrradiance === undefined)) return false;\n return (\n left.skyIrradiance === undefined ||\n (right.skyIrradiance !== undefined && sameVector3(left.skyIrradiance, right.skyIrradiance))\n );\n}\n\n/** Renderer-owned bounded projection; admission is explicit and fail-closed. */\nexport class ProbeBlendSceneProjection {\n private previous?: ProbeSceneProjectionInput;\n private records = new Map<number, ProbeBlendRecord>();\n private lastError: ProbeAdmissionError | undefined;\n private lastReceipt = emptyReceipt(PROBE_R_MIN);\n private lastActiveContributorCount = 0;\n private lastAdmittedProbeCount = 0;\n private lastCoverage = 0;\n private lastFinite = true;\n private lastSky: ProbeSceneProjectionInput['sky'] = {\n available: false,\n irradiance: [0, 0, 0],\n fallbackReason: 'no-skylight',\n };\n private lastDirtyVisitCount = 0;\n private lastDirtyReasons: readonly ProbeSceneDirtyReason[] = [];\n private readonly bufferProjectionSource = Object.freeze({});\n private bufferProjection: ProbeBlendBufferProjection = Object.freeze({\n sourceIdentity: this.bufferProjectionSource,\n revision: 0,\n baseRevision: 0,\n capacity: 1,\n records: Object.freeze([]),\n dirtyRecords: Object.freeze([]),\n removedCacheKeys: Object.freeze([]),\n });\n private resultRecords: readonly ProbeBlendRecord[] = Object.freeze([]);\n private recordFacts = new Map<\n number,\n {\n readonly contributors: readonly ProbeBlendTerm[];\n readonly qHatSum: number;\n readonly rStar: number;\n readonly fallbackReason: string | undefined;\n }\n >();\n\n getRecord(objectKey: number): ProbeBlendRecord | undefined {\n return this.records.get(objectKey);\n }\n\n hasRecords(): boolean {\n return this.records.size > 0;\n }\n\n /** Stable upload projection; rebuilt only when probe/object facts change. */\n recordBufferProjection(): ProbeBlendBufferProjection {\n return this.bufferProjection;\n }\n\n inspect(): ProbeBlendInspection {\n return {\n activeContributorCount: this.lastActiveContributorCount,\n admittedProbeCount: this.lastAdmittedProbeCount,\n coverage: this.lastCoverage,\n skyResidualFraction: 1 - this.lastCoverage,\n finite: this.lastFinite,\n errorCode: this.lastError?.code,\n records: [...this.records.values()].map((record) => {\n const facts = this.recordFacts.get(record.objectKey);\n return {\n objectKey: record.objectKey,\n generation: record.generation,\n localBlendFraction: record.localBlendFraction,\n shPreblend: [...record.shPreblend],\n byteLength: record.byteLength,\n candidate: record.candidate,\n accepted: record.accepted,\n lastKnownGood: record.lastKnownGood,\n sentinel: record.sentinel,\n probeBlendIndex: record.objectKey,\n contributors: (facts?.contributors ?? []).map((term) => ({\n identity: term.identity,\n distance: term.distance,\n radius: term.radius,\n coverage: term.coverage,\n q: term.q,\n qHat: term.qHat,\n alpha: term.alpha,\n })),\n qHatSum: facts?.qHatSum ?? 0,\n rStar: facts?.rStar ?? PROBE_R_MIN,\n fallbackReason: facts?.fallbackReason,\n };\n }),\n sky: {\n available: this.lastSky?.available ?? false,\n identity: this.lastSky?.identity,\n sourceKey: this.lastSky?.sourceKey,\n irradiance: [...(this.lastSky?.irradiance ?? [0, 0, 0])] as [number, number, number],\n fallbackReason: this.lastSky?.fallbackReason,\n },\n dirtyVisitCount: this.lastDirtyVisitCount,\n dirtyReasons: [...this.lastDirtyReasons],\n receipt: {\n activeIdentities: [...this.lastReceipt.activeIdentities],\n admittedIdentities: [...this.lastReceipt.admittedIdentities],\n rejectedIdentities: [...this.lastReceipt.rejectedIdentities],\n stableOrder: [...this.lastReceipt.stableOrder],\n capacity: this.lastReceipt.capacity,\n scaleRadius: this.lastReceipt.scaleRadius,\n finite: this.lastReceipt.finite,\n overflowReason: this.lastReceipt.overflowReason,\n },\n };\n }\n\n apply(input: ProbeSceneProjectionInput): ProbeSceneProjectionResult {\n const dirtyReasons: ProbeSceneDirtyReason[] = [];\n const affectedObjectKeys = new Set<number>();\n const previous = this.previous;\n if (\n previous !== undefined &&\n previous.objects === input.objects &&\n input.worldRevision === previous.worldRevision &&\n input.retainSkyResidualRecords === previous.retainSkyResidualRecords &&\n sameProbeFacts(input.probes, previous.probes) &&\n sameSkyFacts(input, previous)\n ) {\n return {\n records: this.resultRecords,\n contributors: [],\n activeContributorCount: this.lastActiveContributorCount,\n admittedProbeCount: this.lastAdmittedProbeCount,\n coverage: this.lastCoverage,\n skyResidualFraction: 1 - this.lastCoverage,\n dirtyReasons: [],\n affectedObjectKeys: [],\n visits: 0,\n allocations: 0,\n uploads: 0,\n receipt: this.lastReceipt,\n ...(this.lastError === undefined ? {} : { error: this.lastError }),\n };\n }\n const objectKeys = input.objects.map((object) => String(object.objectKey)).sort();\n const previousObjectKeys =\n previous?.objects.map((object) => String(object.objectKey)).sort() ?? [];\n if (previous === undefined || !sameList(objectKeys, previousObjectKeys)) {\n dirtyReasons.push('object-boundary');\n for (const object of input.objects) affectedObjectKeys.add(object.objectKey);\n }\n if (previous !== undefined && input.worldRevision !== previous.worldRevision)\n dirtyReasons.push('world');\n if (\n previous !== undefined &&\n (!sameProbeFacts(input.probes, previous.probes) ||\n input.retainSkyResidualRecords !== previous.retainSkyResidualRecords)\n )\n dirtyReasons.push('probe-fact');\n if (previous !== undefined && !sameSkyFacts(input, previous)) dirtyReasons.push('sky');\n const previousObjects = new Map(previous?.objects.map((object) => [object.objectKey, object]));\n for (const object of input.objects) {\n const oldObject = previousObjects.get(object.objectKey);\n if (oldObject === undefined) {\n affectedObjectKeys.add(object.objectKey);\n continue;\n }\n if (!sameVector3(object.position, oldObject.position)) {\n dirtyReasons.push('object-position');\n affectedObjectKeys.add(object.objectKey);\n }\n if (object.generation !== oldObject.generation) {\n dirtyReasons.push('generation');\n affectedObjectKeys.add(object.objectKey);\n }\n }\n if (\n dirtyReasons.includes('world') ||\n dirtyReasons.includes('probe-fact') ||\n dirtyReasons.includes('sky')\n )\n for (const object of input.objects) affectedObjectKeys.add(object.objectKey);\n const uniqueDirtyReasons = [...new Set(dirtyReasons)];\n if (previous !== undefined && uniqueDirtyReasons.length === 0) {\n return {\n records: [...this.records.values()],\n contributors: [],\n activeContributorCount: this.lastActiveContributorCount,\n admittedProbeCount: this.lastAdmittedProbeCount,\n coverage: this.lastCoverage,\n skyResidualFraction: 1 - this.lastCoverage,\n dirtyReasons: [],\n affectedObjectKeys: [],\n visits: 0,\n allocations: 0,\n uploads: 0,\n receipt: this.lastReceipt,\n ...(this.lastError === undefined ? {} : { error: this.lastError }),\n };\n }\n const nextRecords = new Map(this.records);\n const currentObjectKeys = new Set(input.objects.map((object) => object.objectKey));\n for (const objectKey of nextRecords.keys()) {\n if (!currentObjectKeys.has(objectKey)) {\n nextRecords.delete(objectKey);\n this.recordFacts.delete(objectKey);\n }\n }\n let firstTerms: readonly ProbeBlendTerm[] = [];\n let firstReceipt = emptyReceipt(PROBE_R_MIN);\n let firstError: ProbeAdmissionError | undefined;\n let firstActiveCount = 0;\n let firstAdmittedCount = 0;\n let firstCoverage = 0;\n let firstObjectSeen = false;\n let visited = 0;\n for (const object of input.objects) {\n if (!affectedObjectKeys.has(object.objectKey)) continue;\n visited += 1;\n const candidates = input.probes.map((probe) => ({\n identity: probe.identity,\n admitted: probe.admitted,\n distance: vectorDistance(object.position, probe.position),\n radius: probe.radius,\n irradiance: probe.irradiance,\n }));\n const admission = admitProbeContributors(candidates);\n if (!firstObjectSeen) {\n firstObjectSeen = true;\n firstActiveCount = admission.active.length;\n firstAdmittedCount = admission.admitted.length;\n firstReceipt = admission.receipt;\n }\n const previousRecord = this.records.get(object.objectKey);\n const lastKnownGood = input.lastKnownGood ?? previousRecord?.lastKnownGood ?? false;\n let record: ProbeBlendRecord;\n if (admission.error !== undefined) firstError ??= admission.error;\n if (admission.admitted.length === 0) {\n if (input.probes.length === 0 && input.retainSkyResidualRecords !== true) {\n nextRecords.delete(object.objectKey);\n this.recordFacts.delete(object.objectKey);\n continue;\n }\n const sentinel: ProbeBlendRecordSentinel = lastKnownGood ? 'no-active' : 'no-lkg';\n record = encodeProbeRecord(\n object.objectKey,\n object.generation,\n 0,\n new Array(27).fill(0),\n true,\n false,\n lastKnownGood,\n sentinel,\n );\n this.recordFacts.set(object.objectKey, {\n contributors: [],\n qHatSum: 0,\n rStar: PROBE_R_MIN,\n fallbackReason: admission.error?.code ?? sentinel,\n });\n } else {\n const blend = blendProbeCoefficients(admission.admitted, PROBE_R_MIN);\n if (blend === undefined) {\n firstError ??= {\n code: 'invalid-admitted-prefix',\n activeCount: admission.active.length,\n capacity: PROBE_MAX_CONTRIBUTORS,\n receipt: admission.receipt,\n };\n firstReceipt = admission.receipt;\n continue;\n }\n record = encodeProbeRecord(\n object.objectKey,\n object.generation,\n blend.C,\n blend.SHPreblend,\n true,\n true,\n true,\n undefined,\n );\n this.recordFacts.set(object.objectKey, {\n contributors: blend.terms,\n qHatSum: blend.Q,\n rStar: blend.rStar,\n fallbackReason:\n admission.error === undefined ? undefined : 'capacity-exceeded-stable-prefix',\n });\n if (firstTerms.length === 0) firstTerms = blend.terms;\n firstCoverage = blend.C;\n }\n nextRecords.set(object.objectKey, record);\n firstError ??= admission.error;\n }\n const allocations = previous === undefined ? nextRecords.size : 0;\n const resultRecords = Object.freeze([...nextRecords.values()]);\n const result = {\n records: resultRecords,\n contributors: firstTerms,\n activeContributorCount: firstActiveCount,\n admittedProbeCount: firstAdmittedCount,\n coverage: firstCoverage,\n skyResidualFraction: 1 - firstCoverage,\n dirtyReasons: uniqueDirtyReasons,\n affectedObjectKeys: [...affectedObjectKeys].sort((left, right) => left - right),\n visits: visited,\n allocations,\n uploads: nextRecords.size,\n receipt: firstReceipt,\n ...(firstError === undefined ? {} : { error: firstError }),\n };\n const projectedRecords = Object.freeze(\n [...nextRecords].map(([objectKey, record]) => Object.freeze({ cacheKey: objectKey, record })),\n );\n const dirtyRecords = Object.freeze(\n projectedRecords.filter(({ record }) => affectedObjectKeys.has(record.objectKey)),\n );\n const removedCacheKeys = Object.freeze(\n [...this.records.keys()].filter((objectKey) => !nextRecords.has(objectKey)),\n );\n const capacity = projectedRecords.reduce(\n (value, { record }) => Math.max(value, record.objectKey + 2),\n 1,\n );\n this.previous = input;\n this.records = nextRecords;\n this.resultRecords = resultRecords;\n const baseRevision = this.bufferProjection.revision;\n this.bufferProjection = Object.freeze({\n sourceIdentity: this.bufferProjectionSource,\n revision: baseRevision + 1,\n baseRevision,\n capacity,\n records: projectedRecords,\n dirtyRecords,\n removedCacheKeys,\n });\n this.lastError = firstError;\n this.lastReceipt = firstReceipt;\n this.lastActiveContributorCount = firstActiveCount;\n this.lastAdmittedProbeCount = firstAdmittedCount;\n this.lastCoverage = firstCoverage;\n this.lastFinite = this.resultRecords.every(\n (record) => record.bytes.length === PROBE_BLEND_RECORD_BYTE_SIZE,\n );\n this.lastSky =\n input.sky ??\n (input.skyIrradiance === undefined\n ? { available: false, irradiance: [0, 0, 0] as const, fallbackReason: 'no-skylight' }\n : { available: true, irradiance: input.skyIrradiance });\n this.lastDirtyVisitCount = visited;\n this.lastDirtyReasons = uniqueDirtyReasons;\n return result;\n }\n}\n"]}
|