@forgeax/engine-render 0.1.29 → 0.1.31
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 +248 -21
- package/dist/assembly/atmosphere-shader-prewarm.d.ts +1 -1
- package/dist/assembly/atmosphere-shader-prewarm.d.ts.map +1 -1
- package/dist/assembly/device-feature-admission.d.ts +4 -3
- package/dist/assembly/device-feature-admission.d.ts.map +1 -1
- package/dist/assembly/dynamic-geometry-host.d.ts +6 -0
- package/dist/assembly/dynamic-geometry-host.d.ts.map +1 -1
- package/dist/assembly/host-contract.d.ts +6 -0
- package/dist/assembly/host-contract.d.ts.map +1 -1
- package/dist/assembly/material/assembly.d.ts +26 -3
- package/dist/assembly/material/assembly.d.ts.map +1 -1
- package/dist/assembly/material/pipeline-helpers.d.ts +24 -0
- package/dist/assembly/material/pipeline-helpers.d.ts.map +1 -0
- package/dist/assembly/material-shader-policy.d.ts.map +1 -1
- package/dist/assembly/recovery/device-loss-fanout.d.ts.map +1 -1
- package/dist/assembly/recovery/recovery-attempt.d.ts +1 -6
- package/dist/assembly/recovery/recovery-attempt.d.ts.map +1 -1
- package/dist/assembly/recovery/renderer-recover.d.ts +1 -0
- package/dist/assembly/recovery/renderer-recover.d.ts.map +1 -1
- package/dist/assembly/renderer-facade.d.ts.map +1 -1
- package/dist/assembly/shader-prewarm-policy.d.ts +1 -1
- package/dist/assembly/shader-prewarm-policy.d.ts.map +1 -1
- package/dist/assembly/webgpu-ready.d.ts +1 -1
- package/dist/assembly/webgpu-ready.d.ts.map +1 -1
- package/dist/assembly/webgpu-renderer.d.ts.map +1 -1
- package/dist/capture/scene-projection.d.ts +41 -0
- package/dist/capture/scene-projection.d.ts.map +1 -0
- package/dist/{chunk-BQVQOQJH.mjs → chunk-7MQ3XBSP.mjs} +20 -14
- package/dist/chunk-7MQ3XBSP.mjs.map +1 -0
- package/dist/{chunk-S4DNKQYQ.mjs → chunk-C3DDSXYK.mjs} +86 -33
- package/dist/chunk-C3DDSXYK.mjs.map +1 -0
- package/dist/{chunk-BTWH7BP4.mjs → chunk-FUUO4UND.mjs} +73 -29
- package/dist/chunk-FUUO4UND.mjs.map +1 -0
- package/dist/{chunk-NRNXBLIJ.mjs → chunk-JRBDO2KB.mjs} +46 -6
- package/dist/chunk-JRBDO2KB.mjs.map +1 -0
- package/dist/{chunk-NICXSHAT.mjs → chunk-MDQJPY3T.mjs} +8 -6
- package/dist/chunk-MDQJPY3T.mjs.map +1 -0
- package/dist/{chunk-JQTSEI3Z.mjs → chunk-NO4WZCAH.mjs} +3 -3
- package/dist/chunk-NO4WZCAH.mjs.map +1 -0
- package/dist/{chunk-FUODTTIA.mjs → chunk-PSEQ6QPH.mjs} +621 -108
- package/dist/chunk-PSEQ6QPH.mjs.map +1 -0
- package/dist/{chunk-33XZFTQU.mjs → chunk-S5UE2T5P.mjs} +48 -6
- package/dist/chunk-S5UE2T5P.mjs.map +1 -0
- package/dist/components/directional-light.d.ts +2 -2
- package/dist/components/dynamic-resolution.d.ts +15 -0
- package/dist/components/dynamic-resolution.d.ts.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/light-helpers.d.ts.map +1 -1
- package/dist/components/reflection-probe.d.ts +1 -0
- package/dist/components/reflection-probe.d.ts.map +1 -1
- package/dist/components/skylight.d.ts +4 -1
- package/dist/components/skylight.d.ts.map +1 -1
- package/dist/construct-renderer.mjs +2172 -796
- package/dist/construct-renderer.mjs.map +1 -1
- package/dist/device/device-scope.d.ts +2 -0
- package/dist/device/device-scope.d.ts.map +1 -1
- package/dist/device/gpu-residency.d.ts +2 -2
- package/dist/device/gpu-residency.d.ts.map +1 -1
- package/dist/dynamic-geometry.d.ts.map +1 -1
- package/dist/environment/background.d.ts +3 -2
- package/dist/environment/background.d.ts.map +1 -1
- package/dist/environment/ibl.d.ts +11 -0
- package/dist/environment/ibl.d.ts.map +1 -0
- package/dist/environment/storage.d.ts +14 -0
- package/dist/environment/storage.d.ts.map +1 -0
- package/dist/errors/gpu-driven.d.ts +2 -2
- package/dist/errors/gpu-driven.d.ts.map +1 -1
- package/dist/errors/render.d.ts +35 -1
- package/dist/errors/render.d.ts.map +1 -1
- package/dist/extract/camera.d.ts.map +1 -1
- package/dist/extract/contracts.d.ts +7 -0
- package/dist/extract/contracts.d.ts.map +1 -1
- package/dist/extract/gpu-driven.d.ts +18 -1
- package/dist/extract/gpu-driven.d.ts.map +1 -1
- package/dist/gpu-driven/batch-topology.d.ts.map +1 -1
- package/dist/gpu-driven/material-artifacts.d.ts +24 -0
- package/dist/gpu-driven/material-artifacts.d.ts.map +1 -0
- package/dist/gpu-driven/material-bindings.d.ts +7 -0
- package/dist/gpu-driven/material-bindings.d.ts.map +1 -0
- package/dist/gpu-driven/prepared-draw.d.ts +2 -0
- package/dist/gpu-driven/prepared-draw.d.ts.map +1 -1
- package/dist/gpu-driven/production-raster.d.ts +27 -6
- package/dist/gpu-driven/production-raster.d.ts.map +1 -1
- package/dist/gpu-resource.d.ts +5 -2
- package/dist/gpu-resource.d.ts.map +1 -1
- package/dist/gpu-scene-schema.d.ts.map +1 -1
- package/dist/gpu-scene.d.ts.map +1 -1
- package/dist/hdrp-buffers.d.ts +3 -0
- package/dist/hdrp-buffers.d.ts.map +1 -1
- package/dist/ibl/IblPipelineCache.d.ts +2 -0
- package/dist/ibl/IblPipelineCache.d.ts.map +1 -1
- package/dist/ibl/skylight-bind-group.d.ts +3 -1
- package/dist/ibl/skylight-bind-group.d.ts.map +1 -1
- package/dist/index.d.ts +83 -81
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +7 -5
- package/dist/index.mjs.map +1 -1
- package/dist/inspection-types.d.ts +16 -1
- package/dist/inspection-types.d.ts.map +1 -1
- package/dist/internal.mjs +6 -6
- package/dist/material-row.d.ts +10 -0
- package/dist/material-row.d.ts.map +1 -1
- package/dist/pbr-pipeline.d.ts +3 -1
- package/dist/pbr-pipeline.d.ts.map +1 -1
- package/dist/pipeline/render-extent.d.ts +51 -0
- package/dist/pipeline/render-extent.d.ts.map +1 -0
- package/dist/pipeline/standard-build-context.d.ts +7 -0
- package/dist/pipeline/standard-build-context.d.ts.map +1 -0
- package/dist/pipeline/standard-forward-lane.d.ts +3 -2
- package/dist/pipeline/standard-forward-lane.d.ts.map +1 -1
- package/dist/pipeline/standard-pipeline.d.ts.map +1 -1
- package/dist/pipeline/standard-post.d.ts +1 -1
- package/dist/pipeline/standard-post.d.ts.map +1 -1
- package/dist/pipeline/standard-profile.d.ts +2 -1
- package/dist/pipeline/standard-profile.d.ts.map +1 -1
- package/dist/pipeline-builder.d.ts +3 -1
- package/dist/pipeline-builder.d.ts.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/post-process-errors.d.ts +9 -2
- package/dist/post-process-errors.d.ts.map +1 -1
- package/dist/prepare/extended-lighting/resources.d.ts +3 -3
- package/dist/record/frame-lighting.d.ts.map +1 -1
- package/dist/record/frame-snapshot.d.ts +3 -8
- package/dist/record/frame-snapshot.d.ts.map +1 -1
- package/dist/record/frame.d.ts +3 -2
- package/dist/record/frame.d.ts.map +1 -1
- package/dist/record/main-pass-geometry.d.ts +7 -2
- package/dist/record/main-pass-geometry.d.ts.map +1 -1
- package/dist/record/main-pass-material.d.ts +6 -3
- package/dist/record/main-pass-material.d.ts.map +1 -1
- package/dist/record/main-pass.d.ts +2 -0
- package/dist/record/main-pass.d.ts.map +1 -1
- package/dist/record/prepared-material-bindings.d.ts.map +1 -1
- package/dist/record/recovery-pipeline.d.ts +9 -1
- package/dist/record/recovery-pipeline.d.ts.map +1 -1
- package/dist/record/render-context.d.ts +34 -3
- package/dist/record/render-context.d.ts.map +1 -1
- package/dist/record/shadow-pass.d.ts +2 -2
- package/dist/record/shadow-pass.d.ts.map +1 -1
- package/dist/record/typed-frame-graph.d.ts +5 -2
- package/dist/record/typed-frame-graph.d.ts.map +1 -1
- package/dist/recovery/render-system-candidate.d.ts.map +1 -1
- package/dist/reflection/background.d.ts +14 -0
- package/dist/reflection/background.d.ts.map +1 -0
- package/dist/reflection/filter.d.ts.map +1 -1
- package/dist/reflection/projection.d.ts +1 -0
- package/dist/reflection/projection.d.ts.map +1 -1
- package/dist/reflection/record-owner.d.ts +4 -2
- package/dist/reflection/record-owner.d.ts.map +1 -1
- package/dist/render-contract.d.ts +47 -32
- 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 +17 -1
- package/dist/render-pipeline.d.ts.map +1 -1
- package/dist/render-system-extract-tail.d.ts +9 -2
- package/dist/render-system-extract-tail.d.ts.map +1 -1
- package/dist/render-system-extract.d.ts +29 -2
- package/dist/render-system-extract.d.ts.map +1 -1
- package/dist/render-system.d.ts.map +1 -1
- package/dist/scene/render-scene.d.ts +2 -0
- package/dist/scene/render-scene.d.ts.map +1 -1
- package/dist/ssao-config.d.ts +8 -6
- package/dist/ssao-config.d.ts.map +1 -1
- package/dist/ssr/graph.d.ts.map +1 -1
- package/dist/temporal/gpu.d.ts.map +1 -1
- package/dist/temporal/index.mjs +5 -5
- package/dist/temporal/standard-scene-data.d.ts +2 -1
- package/dist/temporal/standard-scene-data.d.ts.map +1 -1
- package/dist/temporal/target-coverage-attachment.d.ts +15 -0
- package/dist/temporal/target-coverage-attachment.d.ts.map +1 -0
- package/dist/temporal/temporal-view.d.ts +6 -2
- package/dist/temporal/temporal-view.d.ts.map +1 -1
- package/dist/temporal/view.d.ts +6 -0
- package/dist/temporal/view.d.ts.map +1 -1
- package/dist/typed-render-graph-primitives.d.ts +6 -0
- package/dist/typed-render-graph-primitives.d.ts.map +1 -1
- package/dist/volume/component.d.ts +1 -0
- package/dist/volume/component.d.ts.map +1 -1
- package/package.json +21 -21
- package/src/__tests__/capture-scene-projection.unit.test.ts +24 -0
- package/src/__tests__/device-feature-admission.unit.test.ts +15 -24
- package/src/__tests__/device-loss-fanout.unit.test.ts +43 -0
- package/src/__tests__/dynamic-geometry-batch.unit.test.ts +157 -0
- package/src/__tests__/dynamic-geometry.unit.test.ts +36 -0
- package/src/__tests__/dynamic-resolution-plugin.integration.test.ts +81 -0
- package/src/__tests__/factory-contract.integration.test.ts +164 -1
- package/src/__tests__/frame-observation.contract.test.ts +21 -0
- package/src/__tests__/gpu-driven-baseline.characterization.test.ts +1 -1
- package/src/__tests__/gpu-driven-batch-topology-pbr.unit.test.ts +20 -1
- package/src/__tests__/gpu-driven-lod-cache.unit.test.ts +0 -3
- package/src/__tests__/gpu-driven-mesh-world-identity.unit.test.ts +0 -3
- package/src/__tests__/gpu-driven-pbr.dawn.test.ts +11 -6
- package/src/__tests__/gpu-driven-production.integration.test.ts +13 -25
- package/src/__tests__/gpu-driven-view.unit.test.ts +1 -0
- package/src/__tests__/gpu-pass-timing-browser-runner.ts +15 -0
- package/src/__tests__/gpu-pass-timing.browser.test.ts +14 -1
- package/src/__tests__/gpu-resource-scope.unit.test.ts +71 -0
- package/src/__tests__/gpu-scene.unit.test.ts +55 -1
- package/src/__tests__/materials-standard-contract.unit.test.ts +5 -1
- package/src/__tests__/mesh-submission-lifetime.unit.test.ts +8 -0
- package/src/__tests__/morph-neutral-admission.unit.test.ts +19 -0
- package/src/__tests__/physical-clearcoat.integration.test.ts +6 -1
- package/src/__tests__/post-process-error-policy-owner.unit.test.ts +6 -5
- package/src/__tests__/prepared-gpu-driven-pbr.integration.test.ts +216 -5
- package/src/__tests__/reflection-fallback-async-publication.unit.test.ts +68 -1
- package/src/__tests__/reflection-probe-authoring.unit.test.ts +12 -10
- package/src/__tests__/reflection-probe-box.dawn.test.ts +71 -0
- package/src/__tests__/reflection-probe-filter.unit.test.ts +9 -0
- package/src/__tests__/reflection-probe-orientation.dawn.test.ts +294 -0
- package/src/__tests__/reflection-probe-record-owner.characterization.unit.test.ts +5 -15
- package/src/__tests__/reflection-probe-updates.unit.test.ts +129 -0
- package/src/__tests__/render-error-code-owner.test-d.ts +3 -0
- package/src/__tests__/render-error-detail-ssot.test-d.ts +5 -1
- package/src/__tests__/render-extent.unit.test.ts +63 -0
- package/src/__tests__/render-scene-projection.unit.test.ts +3 -2
- package/src/__tests__/renderer-factory-material-contract.unit.test.ts +173 -9
- package/src/__tests__/shader-manifest-fixture.ts +6 -0
- package/src/__tests__/skinned-shadow-caster.test.ts +8 -1
- package/src/__tests__/specular-environment-scale.dawn.test.ts +4 -2
- package/src/__tests__/ssao-config.unit.test.ts +7 -0
- package/src/__tests__/ssao-surface.dawn.test.ts +252 -0
- package/src/__tests__/ssr-cube-silhouette.dawn.test.ts +270 -0
- package/src/__tests__/ssr-gpu-dispatch.browser.test.ts +51 -43
- package/src/__tests__/ssr-gpu-dispatch.dawn.test.ts +4 -0
- package/src/__tests__/ssr-gpu-dispatch.ts +10 -5
- package/src/__tests__/ssr-graph-topology.unit.test.ts +2 -2
- package/src/__tests__/ssr-hiz.browser.test.ts +1 -1
- package/src/__tests__/ssr-hiz.dawn.test.ts +1 -1
- package/src/__tests__/ssr-spatial.integration.test.ts +1 -1
- package/src/__tests__/standard-cluster-variant-resolution.unit.test.ts +40 -0
- package/src/__tests__/standard-pbr-artifact-assembly.unit.test.ts +238 -1
- package/src/__tests__/standard-profile-oracle.unit.test.ts +27 -0
- package/src/__tests__/taa-coverage-edge.dawn.test.ts +6 -0
- package/src/__tests__/taa-neighborhood-equivalence.dawn.test.ts +5 -1
- package/src/__tests__/taa-stability-feedback.ts +1 -0
- package/src/__tests__/temporal-reset-matrix.unit.test.ts +2 -2
- package/src/__tests__/temporal-view.unit.test.ts +17 -0
- package/src/__tests__/transmission-prewarm.unit.test.ts +57 -0
- package/src/__tests__/volumetric-fog-stage-readback.dawn.test.ts +62 -13
- package/src/__tests__/volumetric-fog-topology.unit.test.ts +7 -7
- package/src/assembly/atmosphere-shader-prewarm.ts +3 -2
- package/src/assembly/device-feature-admission.ts +9 -4
- package/src/assembly/dynamic-geometry-host.ts +236 -163
- package/src/assembly/host-contract.ts +9 -0
- package/src/assembly/material/assembly.ts +350 -6
- package/src/assembly/material/pipeline-helpers.ts +100 -0
- package/src/assembly/material-shader-policy.ts +39 -18
- package/src/assembly/recovery/device-loss-fanout.ts +5 -0
- package/src/assembly/recovery/recovery-attempt.ts +2 -29
- package/src/assembly/recovery/renderer-recover.ts +6 -9
- package/src/assembly/renderer-facade.ts +22 -1
- package/src/assembly/shader-prewarm-policy.ts +14 -1
- package/src/assembly/webgpu-ready.ts +28 -19
- package/src/assembly/webgpu-renderer.ts +95 -95
- package/src/capture/scene-projection.ts +37 -0
- package/src/components/__tests__/dynamic-resolution-schema.unit.test.ts +65 -0
- package/src/components/__tests__/light-radius.integration.test.ts +59 -0
- package/src/components/directional-light.ts +3 -3
- package/src/components/dynamic-resolution.ts +67 -0
- package/src/components/index.ts +1 -0
- package/src/components/light-helpers.ts +6 -1
- package/src/components/reflection-probe.ts +1 -0
- package/src/components/skylight.ts +4 -1
- package/src/device/device-scope.ts +13 -7
- package/src/device/gpu-residency.ts +11 -11
- package/src/dynamic-geometry.ts +13 -8
- package/src/environment/background.ts +30 -12
- package/src/environment/ibl.ts +211 -0
- package/src/environment/storage.ts +63 -0
- package/src/errors/gpu-driven.ts +10 -3
- package/src/errors/render.ts +64 -0
- package/src/extract/camera.ts +12 -1
- package/src/extract/contracts.ts +10 -0
- package/src/extract/gpu-driven.ts +72 -17
- package/src/gpu-driven/batch-topology.ts +33 -11
- package/src/gpu-driven/material-artifacts.ts +179 -0
- package/src/gpu-driven/material-bindings.ts +41 -0
- package/src/gpu-driven/prepared-draw.ts +13 -2
- package/src/gpu-driven/production-raster.ts +681 -164
- package/src/gpu-resource.ts +21 -2
- package/src/gpu-scene-schema.ts +11 -2
- package/src/gpu-scene.ts +14 -3
- package/src/hdrp-buffers.ts +69 -0
- package/src/ibl/IblPipelineCache.ts +5 -0
- package/src/ibl/skylight-bind-group.ts +27 -17
- package/src/index.ts +92 -81
- package/src/inspection-types.ts +16 -1
- package/src/material-row.ts +60 -11
- package/src/pbr-pipeline.ts +13 -2
- package/src/pipeline/render-extent.ts +111 -0
- package/src/pipeline/standard-build-context.ts +7 -0
- package/src/pipeline/standard-forward-lane.ts +41 -24
- package/src/pipeline/standard-pipeline.ts +47 -18
- package/src/pipeline/standard-post.ts +4 -0
- package/src/pipeline/standard-profile.ts +2 -1
- package/src/pipeline-builder.ts +12 -3
- package/src/plugin.ts +4 -0
- package/src/post-process-errors.ts +26 -18
- package/src/prepare/__tests__/extended-lighting-capability.unit.test.ts +2 -2
- package/src/prepare/extended-lighting/resources.ts +3 -3
- package/src/record/__tests__/main-pass-geometry.unit.test.ts +68 -0
- package/src/record/__tests__/material-bg-cache.unit.test.ts +45 -0
- package/src/record/__tests__/material-slot-plan.unit.test.ts +9 -0
- package/src/record/__tests__/recovery-pipeline.unit.test.ts +47 -1
- package/src/record/__tests__/sprite-material-abi.unit.test.ts +7 -3
- package/src/record/__tests__/temporal-payload.unit.test.ts +2 -0
- package/src/record/frame-lighting.ts +3 -1
- package/src/record/frame-snapshot.ts +13 -11
- package/src/record/frame.ts +150 -74
- package/src/record/main-pass-geometry.ts +60 -9
- package/src/record/main-pass-material.ts +47 -19
- package/src/record/main-pass.ts +63 -4
- package/src/record/prepared-material-bindings.ts +4 -0
- package/src/record/recovery-pipeline.ts +56 -0
- package/src/record/render-context.ts +34 -3
- package/src/record/shadow-pass.ts +187 -50
- package/src/record/typed-frame-graph.ts +60 -3
- package/src/record/view-ubo.ts +1 -1
- package/src/recovery/render-system-candidate.ts +54 -11
- package/src/reflection/background.ts +151 -0
- package/src/reflection/filter.ts +3 -0
- package/src/reflection/projection.ts +16 -6
- package/src/reflection/record-owner.ts +282 -86
- package/src/render-contract.ts +50 -32
- package/src/render-graph-primitives.ts +28 -3
- package/src/render-pipeline.ts +20 -1
- package/src/render-system-extract-tail.ts +23 -3
- package/src/render-system-extract.ts +127 -42
- package/src/render-system.ts +35 -7
- package/src/scene/render-scene.ts +8 -0
- package/src/ssao-config.ts +25 -8
- package/src/ssr/graph.ts +78 -58
- package/src/temporal/gpu.ts +5 -0
- package/src/temporal/standard-scene-data.ts +7 -1
- package/src/temporal/target-coverage-attachment.ts +72 -0
- package/src/temporal/temporal-view.ts +10 -4
- package/src/temporal/view.ts +12 -2
- package/src/transmission/__tests__/standard-transmission.dawn.test.ts +24 -9
- package/src/typed-render-graph-primitives.ts +38 -0
- package/src/volume/component.ts +1 -0
- package/src/volume/passes.ts +3 -3
- package/dist/chunk-33XZFTQU.mjs.map +0 -1
- package/dist/chunk-BQVQOQJH.mjs.map +0 -1
- package/dist/chunk-BTWH7BP4.mjs.map +0 -1
- package/dist/chunk-FUODTTIA.mjs.map +0 -1
- package/dist/chunk-JQTSEI3Z.mjs.map +0 -1
- package/dist/chunk-NICXSHAT.mjs.map +0 -1
- package/dist/chunk-NRNXBLIJ.mjs.map +0 -1
- package/dist/chunk-S4DNKQYQ.mjs.map +0 -1
package/src/gpu-resource.ts
CHANGED
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
// introduced in feat-20260612 M1 / w1).
|
|
53
53
|
|
|
54
54
|
import type { Buffer, Result, RhiDevice, RhiError, Texture } from '@forgeax/engine-rhi';
|
|
55
|
+
import type { DeviceScope } from './device/device-scope';
|
|
55
56
|
|
|
56
57
|
/**
|
|
57
58
|
* Runtime wrapper around an RHI `Buffer` opaque handle that exposes
|
|
@@ -81,10 +82,17 @@ export class GpuBuffer {
|
|
|
81
82
|
// BUFFER_META_MAP. This local flag is a derived view written only on
|
|
82
83
|
// the success branch of `device.destroyBuffer(...)`; charter §F1.
|
|
83
84
|
private destroyed = false;
|
|
85
|
+
private releaseScope: (() => void) | undefined;
|
|
84
86
|
|
|
85
|
-
constructor(device: RhiDevice, handle: Buffer) {
|
|
87
|
+
constructor(device: RhiDevice, handle: Buffer, scope?: DeviceScope) {
|
|
86
88
|
this.device = device;
|
|
87
89
|
this.handle = handle;
|
|
90
|
+
if (scope !== undefined) {
|
|
91
|
+
const ref = scope._adopt('buffer', this, (value) => {
|
|
92
|
+
if (!value.isDestroyed) value.destroy();
|
|
93
|
+
});
|
|
94
|
+
this.releaseScope = () => scope._release(ref);
|
|
95
|
+
}
|
|
88
96
|
}
|
|
89
97
|
|
|
90
98
|
get isDestroyed(): boolean {
|
|
@@ -101,6 +109,8 @@ export class GpuBuffer {
|
|
|
101
109
|
const r = this.device.destroyBuffer(this.handle);
|
|
102
110
|
if (r.ok) {
|
|
103
111
|
this.destroyed = true;
|
|
112
|
+
this.releaseScope?.();
|
|
113
|
+
this.releaseScope = undefined;
|
|
104
114
|
}
|
|
105
115
|
return r;
|
|
106
116
|
}
|
|
@@ -126,10 +136,17 @@ export class GpuTexture {
|
|
|
126
136
|
readonly device: RhiDevice;
|
|
127
137
|
readonly handle: Texture;
|
|
128
138
|
private destroyed = false;
|
|
139
|
+
private releaseScope: (() => void) | undefined;
|
|
129
140
|
|
|
130
|
-
constructor(device: RhiDevice, handle: Texture) {
|
|
141
|
+
constructor(device: RhiDevice, handle: Texture, scope?: DeviceScope) {
|
|
131
142
|
this.device = device;
|
|
132
143
|
this.handle = handle;
|
|
144
|
+
if (scope !== undefined) {
|
|
145
|
+
const ref = scope._adopt('texture', this, (value) => {
|
|
146
|
+
if (!value.isDestroyed) value.destroy();
|
|
147
|
+
});
|
|
148
|
+
this.releaseScope = () => scope._release(ref);
|
|
149
|
+
}
|
|
133
150
|
}
|
|
134
151
|
|
|
135
152
|
get isDestroyed(): boolean {
|
|
@@ -144,6 +161,8 @@ export class GpuTexture {
|
|
|
144
161
|
const r = this.device.destroyTexture(this.handle);
|
|
145
162
|
if (r.ok) {
|
|
146
163
|
this.destroyed = true;
|
|
164
|
+
this.releaseScope?.();
|
|
165
|
+
this.releaseScope = undefined;
|
|
147
166
|
}
|
|
148
167
|
return r;
|
|
149
168
|
}
|
package/src/gpu-scene-schema.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
GPU_DRIVEN_MATERIAL_ROW_BYTES,
|
|
3
|
+
STANDARD_PIPELINE_PARAM_SCHEMA,
|
|
4
|
+
} from '@forgeax/engine-shader';
|
|
2
5
|
import { derive, type NumericParamType } from '@forgeax/engine-types';
|
|
3
6
|
|
|
4
7
|
export type GpuSceneScalar = 'u32' | 'i32' | 'f32';
|
|
@@ -109,7 +112,13 @@ function deriveStandardMaterialFields(): readonly GpuSceneField[] {
|
|
|
109
112
|
]),
|
|
110
113
|
];
|
|
111
114
|
fields.sort((left, right) => left.offset - right.offset);
|
|
112
|
-
return
|
|
115
|
+
return [
|
|
116
|
+
...fields.map(({ field }) => field),
|
|
117
|
+
...Array.from(
|
|
118
|
+
{ length: (GPU_DRIVEN_MATERIAL_ROW_BYTES - derived.totalBytes) / 16 },
|
|
119
|
+
(_, index) => ({ name: `_gpuDrivenPadding${index}`, type: 'vec4<f32>' as const }),
|
|
120
|
+
),
|
|
121
|
+
];
|
|
113
122
|
}
|
|
114
123
|
|
|
115
124
|
export const GPU_SCENE_SCHEMAS = Object.freeze({
|
package/src/gpu-scene.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
GPU_BUFFER_USAGE_STORAGE,
|
|
13
13
|
} from './gpu-usage';
|
|
14
14
|
import type { GpuSceneInspection } from './inspection-types';
|
|
15
|
-
import { packStandardPbrMaterialRow } from './material-row';
|
|
15
|
+
import { packMaterialProgramRow, packStandardPbrMaterialRow } from './material-row';
|
|
16
16
|
import type { RenderSceneApplyResult, RenderSceneSlot } from './scene/render-scene-types';
|
|
17
17
|
|
|
18
18
|
export type { GpuSceneInspection } from './inspection-types';
|
|
@@ -719,8 +719,19 @@ export class GpuScene {
|
|
|
719
719
|
const materialIndex = allocation.materialStart + ordinal;
|
|
720
720
|
const materialOffset = materialIndex * MATERIAL.stride;
|
|
721
721
|
const snapshot = record.snapshot.materials[ordinal] ?? record.snapshot.material;
|
|
722
|
-
const
|
|
723
|
-
|
|
722
|
+
const shaderId = snapshot.materialShaderId;
|
|
723
|
+
const schema = snapshot.materialParamSchema;
|
|
724
|
+
const row =
|
|
725
|
+
shaderId !== undefined &&
|
|
726
|
+
shaderId !== 'forgeax::default-standard-pbr' &&
|
|
727
|
+
shaderId !== 'forgeax::pbr-skin' &&
|
|
728
|
+
shaderId !== 'forgeax::default-standard-pbr-skin' &&
|
|
729
|
+
schema !== undefined
|
|
730
|
+
? packMaterialProgramRow(schema, snapshot, MATERIAL.stride)
|
|
731
|
+
: packStandardPbrMaterialRow(STANDARD_PBR_RECEIPT, snapshot);
|
|
732
|
+
const destination = new Uint8Array(this.tableBytes.material, materialOffset, MATERIAL.stride);
|
|
733
|
+
destination.fill(0);
|
|
734
|
+
if (row !== undefined) destination.set(row.subarray(0, MATERIAL.stride));
|
|
724
735
|
writes.material.push(materialIndex);
|
|
725
736
|
}
|
|
726
737
|
}
|
package/src/hdrp-buffers.ts
CHANGED
|
@@ -58,6 +58,7 @@ import {
|
|
|
58
58
|
import { createHdrpBindGroupLayoutDescriptor } from './pipeline-spec';
|
|
59
59
|
import { MESH_PER_ENTITY_STRIDE } from './record/mesh-ssbo';
|
|
60
60
|
import type { RenderSystemRuntime } from './record/render-context';
|
|
61
|
+
import type { GpuDrivenSceneMeshBinding } from './render-pipeline';
|
|
61
62
|
import { getOrCreateSsaoFallbackTexture } from './ssao-buffers';
|
|
62
63
|
|
|
63
64
|
export { getOrCreateSsaoFallbackTexture } from './ssao-buffers';
|
|
@@ -459,6 +460,74 @@ function standardLightingEntries(
|
|
|
459
460
|
];
|
|
460
461
|
}
|
|
461
462
|
|
|
463
|
+
const sceneLightingBindings = new WeakMap<
|
|
464
|
+
HdrpBuffers,
|
|
465
|
+
WeakMap<
|
|
466
|
+
Buffer,
|
|
467
|
+
{
|
|
468
|
+
readonly layout: BindGroupLayout;
|
|
469
|
+
readonly palette: Buffer | undefined;
|
|
470
|
+
readonly ssao: TextureView;
|
|
471
|
+
readonly bindGroup: BindGroup;
|
|
472
|
+
}
|
|
473
|
+
>
|
|
474
|
+
>();
|
|
475
|
+
|
|
476
|
+
/** Bind a complete GPU scene-row projection alongside the current lighting/AO resources. */
|
|
477
|
+
export function createGpuDrivenLightingBindGroup(
|
|
478
|
+
runtime: RenderSystemRuntime,
|
|
479
|
+
buffers: HdrpBuffers,
|
|
480
|
+
layout: BindGroupLayout,
|
|
481
|
+
binding: GpuDrivenSceneMeshBinding,
|
|
482
|
+
ssaoView?: TextureView,
|
|
483
|
+
): BindGroup | null {
|
|
484
|
+
const fallback = getOrCreateSsaoFallbackTexture(runtime);
|
|
485
|
+
if (fallback === null) return null;
|
|
486
|
+
const ssao = ssaoView ?? fallback.view;
|
|
487
|
+
let cache = sceneLightingBindings.get(buffers);
|
|
488
|
+
if (cache === undefined) {
|
|
489
|
+
cache = new WeakMap();
|
|
490
|
+
sceneLightingBindings.set(buffers, cache);
|
|
491
|
+
}
|
|
492
|
+
const cached = cache.get(binding.meshBuffer);
|
|
493
|
+
if (cached?.layout === layout && cached.palette === binding.paletteBuffer && cached.ssao === ssao)
|
|
494
|
+
return cached.bindGroup;
|
|
495
|
+
const result = runtime.device.createBindGroup({
|
|
496
|
+
label: 'gpu-driven-scene-lighting',
|
|
497
|
+
layout,
|
|
498
|
+
entries: [
|
|
499
|
+
{
|
|
500
|
+
binding: 0,
|
|
501
|
+
resource: {
|
|
502
|
+
kind: 'buffer',
|
|
503
|
+
value: { buffer: binding.meshBuffer, size: binding.meshBytes },
|
|
504
|
+
},
|
|
505
|
+
},
|
|
506
|
+
...(binding.paletteBuffer === undefined
|
|
507
|
+
? []
|
|
508
|
+
: [1, 2].map((index) => ({
|
|
509
|
+
binding: index,
|
|
510
|
+
resource: {
|
|
511
|
+
kind: 'buffer' as const,
|
|
512
|
+
value: { buffer: binding.paletteBuffer as Buffer },
|
|
513
|
+
},
|
|
514
|
+
}))),
|
|
515
|
+
...standardLightingEntries(buffers, ssao, fallback.sampler),
|
|
516
|
+
],
|
|
517
|
+
});
|
|
518
|
+
if (!result.ok) {
|
|
519
|
+
runtime.errorRegistry.fire(result.error);
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
cache.set(binding.meshBuffer, {
|
|
523
|
+
layout,
|
|
524
|
+
palette: binding.paletteBuffer,
|
|
525
|
+
ssao,
|
|
526
|
+
bindGroup: result.value,
|
|
527
|
+
});
|
|
528
|
+
return result.value;
|
|
529
|
+
}
|
|
530
|
+
|
|
462
531
|
/** Standard surface resources without scene geometry tables. */
|
|
463
532
|
export function createStandardSurfaceLightingBindGroup(
|
|
464
533
|
runtime: RenderSystemRuntime,
|
|
@@ -192,10 +192,15 @@ export interface IblComposedShaders {
|
|
|
192
192
|
readonly prefilter: string;
|
|
193
193
|
/** ibl-brdf-lut composed (fullscreen_vs + brdfLutBake_fs). */
|
|
194
194
|
readonly brdfLut: string;
|
|
195
|
+
readonly probeBackground?: string;
|
|
195
196
|
}
|
|
196
197
|
|
|
197
198
|
let iblComposedShadersCache: IblComposedShaders | undefined;
|
|
198
199
|
|
|
200
|
+
export function getIblProbeBackgroundSource(): string | undefined {
|
|
201
|
+
return iblComposedShadersCache?.probeBackground;
|
|
202
|
+
}
|
|
203
|
+
|
|
199
204
|
/**
|
|
200
205
|
* Inject the composed ibl-* shader sources used by createIblPipelines.
|
|
201
206
|
* Called once by the engine bootstrap (createRenderer step "shader-load")
|
|
@@ -126,6 +126,8 @@ export interface SkylightBindGroupResources {
|
|
|
126
126
|
readonly irradianceView: TextureView;
|
|
127
127
|
readonly irradianceSampler: Sampler;
|
|
128
128
|
readonly prefilterView: TextureView;
|
|
129
|
+
/** Present only when the per-draw prefilter slot was replaced by a local probe. */
|
|
130
|
+
readonly skylightPrefilterView?: TextureView;
|
|
129
131
|
readonly prefilterSampler: Sampler;
|
|
130
132
|
readonly brdfLutView: TextureView;
|
|
131
133
|
readonly brdfLutSampler: Sampler;
|
|
@@ -254,7 +256,7 @@ export interface TextureInjectionResource {
|
|
|
254
256
|
export function assembleMaterialWithSkylightEntries(
|
|
255
257
|
materialEntries: readonly BindGroupEntry[],
|
|
256
258
|
skylight: SkylightBindGroupResources,
|
|
257
|
-
transmission?: TransmissionBindGroupResources | undefined,
|
|
259
|
+
transmission?: TransmissionBindGroupResources | null | undefined,
|
|
258
260
|
textureInjections: readonly TextureInjectionResource[] = [],
|
|
259
261
|
): BindGroupEntry[] {
|
|
260
262
|
// IBL injection start = end of the user-region. The user-region IS
|
|
@@ -295,22 +297,23 @@ export function assembleMaterialWithSkylightEntries(
|
|
|
295
297
|
resource: { kind: 'buffer', value: { buffer: skylight.intensityBuffer } },
|
|
296
298
|
},
|
|
297
299
|
];
|
|
298
|
-
//
|
|
299
|
-
//
|
|
300
|
-
//
|
|
300
|
+
// A null transmission omits the unavailable backdrop slots. Otherwise the
|
|
301
|
+
// existing Skylight resources fill unused slots without changing their ABI.
|
|
302
|
+
// Physical injections below keep their fixed binding numbers in either case.
|
|
301
303
|
const transmissionSampler = transmission?.sampler ?? skylight.irradianceSampler;
|
|
302
304
|
const transmissionView = transmission?.backdropView ?? skylight.brdfLutView;
|
|
303
305
|
const transmissionStart = result.length;
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
306
|
+
if (transmission !== null)
|
|
307
|
+
result.push(
|
|
308
|
+
{
|
|
309
|
+
binding: transmissionStart,
|
|
310
|
+
resource: { kind: 'sampler', value: transmissionSampler },
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
binding: transmissionStart + 1,
|
|
314
|
+
resource: { kind: 'textureView', value: transmissionView },
|
|
315
|
+
},
|
|
316
|
+
);
|
|
314
317
|
// Standard physical maps occupy fixed bindings 26..45. The `slot` value
|
|
315
318
|
// is the canonical index from STANDARD_PHYSICAL_TEXTURE_FIELDS; preserve
|
|
316
319
|
// gaps for omitted authored maps instead of compacting this tail.
|
|
@@ -330,6 +333,13 @@ export function assembleMaterialWithSkylightEntries(
|
|
|
330
333
|
},
|
|
331
334
|
);
|
|
332
335
|
}
|
|
336
|
+
result.push({
|
|
337
|
+
binding: 47,
|
|
338
|
+
resource: {
|
|
339
|
+
kind: 'textureView',
|
|
340
|
+
value: skylight.skylightPrefilterView ?? skylight.prefilterView,
|
|
341
|
+
},
|
|
342
|
+
});
|
|
333
343
|
return result;
|
|
334
344
|
}
|
|
335
345
|
|
|
@@ -508,11 +518,11 @@ export function createSkylightFallback(
|
|
|
508
518
|
if (!brdfLutViewResult.ok) throw brdfLutViewResult.error;
|
|
509
519
|
const brdfLutView = brdfLutViewResult.value;
|
|
510
520
|
|
|
511
|
-
//
|
|
512
|
-
//
|
|
521
|
+
// The 64-byte Standard environment payload reserves two extra vec4 lanes
|
|
522
|
+
// for probe-mode diffuse color and rotation. Ordinary Skylight leaves them zero.
|
|
513
523
|
const intensityBufResult = device.createBuffer({
|
|
514
524
|
label: 'skylight-fallback-intensity',
|
|
515
|
-
size:
|
|
525
|
+
size: 64,
|
|
516
526
|
usage: GPU_BUFFER_USAGE_UNIFORM | GPU_BUFFER_USAGE_COPY_DST,
|
|
517
527
|
});
|
|
518
528
|
if (!intensityBufResult.ok) throw intensityBufResult.error;
|