@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
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { mat4, vec3 } from '@forgeax/engine-math';
|
|
4
|
+
import { expect, it } from 'vitest';
|
|
5
|
+
import {
|
|
6
|
+
GPU_TEXTURE_USAGE_COPY_SRC,
|
|
7
|
+
GPU_TEXTURE_USAGE_RENDER_ATTACHMENT,
|
|
8
|
+
GPU_TEXTURE_USAGE_STORAGE_BINDING,
|
|
9
|
+
GPU_TEXTURE_USAGE_TEXTURE_BINDING,
|
|
10
|
+
} from '../gpu-texture-usage';
|
|
11
|
+
import {
|
|
12
|
+
GPU_BUFFER_USAGE_COPY_DST,
|
|
13
|
+
GPU_BUFFER_USAGE_MAP_READ,
|
|
14
|
+
GPU_BUFFER_USAGE_UNIFORM,
|
|
15
|
+
} from '../gpu-usage';
|
|
16
|
+
import { VIEW_UNIFORM_BYTES } from '../record/view-ubo';
|
|
17
|
+
|
|
18
|
+
// Independent analytic raster inputs and mirror-box oracle reproduce the ordinary
|
|
19
|
+
// plane + cube example. No captured GPU handles, pixels or shader outputs are fixtures.
|
|
20
|
+
it.each([
|
|
21
|
+
0, 0.07, -0.07,
|
|
22
|
+
])('keeps the reflected cube silhouette connected without exterior rays (camera offset %f)', async (offset) => {
|
|
23
|
+
const compiler = await import(
|
|
24
|
+
/* @vite-ignore */ new URL('../../../shader-compiler/dist/index.mjs', import.meta.url).href
|
|
25
|
+
);
|
|
26
|
+
const source = (name: string) =>
|
|
27
|
+
readFileSync(resolve(`packages/shader/src/${name}.wgsl`), 'utf8');
|
|
28
|
+
const compile = async (name: string, id: string) => {
|
|
29
|
+
const result = await compiler.compileShader(source(name), {
|
|
30
|
+
id,
|
|
31
|
+
imports: { 'forgeax_view::common': source('common') },
|
|
32
|
+
});
|
|
33
|
+
if (!result.ok) throw result.error;
|
|
34
|
+
return result.value.wgsl;
|
|
35
|
+
};
|
|
36
|
+
const adapter = await navigator.gpu.requestAdapter();
|
|
37
|
+
if (!adapter) throw new Error('Dawn adapter unavailable');
|
|
38
|
+
const device = await adapter.requestDevice();
|
|
39
|
+
device.pushErrorScope('validation');
|
|
40
|
+
try {
|
|
41
|
+
const size = 512,
|
|
42
|
+
half = size / 2;
|
|
43
|
+
const projection = mat4.create(),
|
|
44
|
+
camera = mat4.create(),
|
|
45
|
+
vp = mat4.create(),
|
|
46
|
+
inverse = mat4.create();
|
|
47
|
+
mat4.perspective(projection, Math.PI / 3, 1, 0.1, 20);
|
|
48
|
+
mat4.lookAt(
|
|
49
|
+
camera,
|
|
50
|
+
vec3.create(6 + offset, 3, 6 - offset),
|
|
51
|
+
vec3.create(offset, 0, -offset),
|
|
52
|
+
vec3.create(0, 1, 0),
|
|
53
|
+
);
|
|
54
|
+
mat4.multiply(vp, projection, camera);
|
|
55
|
+
mat4.invert(inverse, vp);
|
|
56
|
+
const values = new Float32Array(VIEW_UNIFORM_BYTES / 4);
|
|
57
|
+
values.set(vp);
|
|
58
|
+
values.set([6 + offset, 3, 6 - offset], 24);
|
|
59
|
+
values.set(inverse, 44);
|
|
60
|
+
values.set([0.1, 20, 0, 0], 228);
|
|
61
|
+
values.set([12, 0.2, 0.65, 1], 236);
|
|
62
|
+
const view = device.createBuffer({
|
|
63
|
+
size: VIEW_UNIFORM_BYTES,
|
|
64
|
+
usage: GPU_BUFFER_USAGE_UNIFORM | GPU_BUFFER_USAGE_COPY_DST,
|
|
65
|
+
});
|
|
66
|
+
device.queue.writeBuffer(view, 0, values);
|
|
67
|
+
const sampled = GPU_TEXTURE_USAGE_TEXTURE_BINDING | GPU_TEXTURE_USAGE_RENDER_ATTACHMENT;
|
|
68
|
+
const depth = device.createTexture({
|
|
69
|
+
size: [size, size],
|
|
70
|
+
format: 'depth32float',
|
|
71
|
+
usage: sampled,
|
|
72
|
+
});
|
|
73
|
+
const color = () =>
|
|
74
|
+
device.createTexture({ size: [size, size], format: 'rgba16float', usage: sampled });
|
|
75
|
+
const normal = color(),
|
|
76
|
+
radiance = color(),
|
|
77
|
+
fallback = color(),
|
|
78
|
+
temporal = color();
|
|
79
|
+
const hiz = device.createTexture({
|
|
80
|
+
size: [half, half],
|
|
81
|
+
mipLevelCount: 9,
|
|
82
|
+
format: 'r32float',
|
|
83
|
+
usage: GPU_TEXTURE_USAGE_TEXTURE_BINDING | GPU_TEXTURE_USAGE_STORAGE_BINDING,
|
|
84
|
+
});
|
|
85
|
+
const traced = device.createTexture({
|
|
86
|
+
size: [half, half],
|
|
87
|
+
format: 'rgba16float',
|
|
88
|
+
usage: GPU_TEXTURE_USAGE_STORAGE_BINDING | GPU_TEXTURE_USAGE_COPY_SRC,
|
|
89
|
+
});
|
|
90
|
+
const reactive = device.createTexture({
|
|
91
|
+
size: [half, half],
|
|
92
|
+
format: 'r32float',
|
|
93
|
+
usage: GPU_TEXTURE_USAGE_STORAGE_BINDING,
|
|
94
|
+
});
|
|
95
|
+
const seed = device.createShaderModule({
|
|
96
|
+
code: `
|
|
97
|
+
@group(0) @binding(0) var<uniform> vp: mat4x4<f32>;
|
|
98
|
+
@vertex fn vs(@builtin(vertex_index) i:u32)->@builtin(position) vec4<f32> {
|
|
99
|
+
let p=array<vec2<f32>,3>(vec2<f32>(-1.0),vec2<f32>(3.0,-1.0),vec2<f32>(-1.0,3.0));return vec4<f32>(p[i],0.0,1.0);
|
|
100
|
+
}
|
|
101
|
+
struct Out { @builtin(frag_depth) depth:f32, @location(0) normal:vec4<f32>, @location(1) color:vec4<f32>, @location(2) fallback:vec4<f32>, @location(3) temporal:vec4<f32> };
|
|
102
|
+
@fragment fn fs(@builtin(position) p:vec4<f32>)->Out {
|
|
103
|
+
let screen=vec2<f32>(p.x/${size}.0*2.0-1.0,1.0-p.y/${size}.0*2.0)/sqrt(3.0);
|
|
104
|
+
let eye=vec3<f32>(${6 + offset},3.0,${6 - offset});
|
|
105
|
+
let d=vec3<f32>(-2.0/3.0,-1.0/3.0,-2.0/3.0)+screen.x*vec3<f32>(sqrt(0.5),0.0,-sqrt(0.5))+screen.y*vec3<f32>(-1.0/sqrt(18.0),sqrt(8.0/9.0),-1.0/sqrt(18.0));
|
|
106
|
+
let lower=min((vec3<f32>(-1.0)-eye)/d,(vec3<f32>(1.0)-eye)/d);
|
|
107
|
+
let upper=max((vec3<f32>(-1.0)-eye)/d,(vec3<f32>(1.0)-eye)/d);
|
|
108
|
+
let enter=max(max(lower.x,lower.y),lower.z);let leave=min(min(upper.x,upper.y),upper.z);
|
|
109
|
+
var t=select(1e6,(-1.0-eye.y)/d.y,d.y<0.0);var n=vec3<f32>(0.0,1.0,0.0);var c=vec3<f32>(0.1,0.2,0.4);var roughness=0.08;
|
|
110
|
+
if (enter>0.0 && enter<leave && enter<t) {
|
|
111
|
+
t=enter;let hit=eye+d*t;let a=abs(hit);n=vec3<f32>(0.0);
|
|
112
|
+
if(a.x>=a.y && a.x>=a.z){n.x=sign(hit.x);}else if(a.y>=a.z){n.y=sign(hit.y);}else{n.z=sign(hit.z);}
|
|
113
|
+
c=vec3<f32>(1.0,0.05,0.02);roughness=0.4;
|
|
114
|
+
}
|
|
115
|
+
let clip=vp*vec4<f32>(eye+d*t,1.0);var out:Out;
|
|
116
|
+
out.depth=clamp(clip.z/clip.w,0.0,1.0);out.normal=vec4<f32>(n*0.5+0.5,roughness);out.color=vec4<f32>(c,1.0);out.fallback=vec4<f32>(0.1,0.1,0.1,1.0);out.temporal=vec4<f32>(0.0);return out;
|
|
117
|
+
}`,
|
|
118
|
+
});
|
|
119
|
+
const seedPipeline = await device.createRenderPipelineAsync({
|
|
120
|
+
layout: 'auto',
|
|
121
|
+
vertex: { module: seed, entryPoint: 'vs' },
|
|
122
|
+
fragment: {
|
|
123
|
+
module: seed,
|
|
124
|
+
entryPoint: 'fs',
|
|
125
|
+
targets: Array.from({ length: 4 }, () => ({ format: 'rgba16float' as const })),
|
|
126
|
+
},
|
|
127
|
+
depthStencil: { format: 'depth32float', depthWriteEnabled: true, depthCompare: 'always' },
|
|
128
|
+
});
|
|
129
|
+
const compute = async (name: string, id: string, entryPoint: string) =>
|
|
130
|
+
device.createComputePipelineAsync({
|
|
131
|
+
layout: 'auto',
|
|
132
|
+
compute: {
|
|
133
|
+
module: device.createShaderModule({ code: await compile(name, id) }),
|
|
134
|
+
entryPoint,
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
const seedHiz = await compute('ssr-hiz', 'forgeax_ssr::hiz', 'ssr_hiz_seed');
|
|
138
|
+
const reduceHiz = await compute('ssr-hiz-reduce', 'forgeax_ssr::hiz_reduce', 'ssr_hiz_reduce');
|
|
139
|
+
const trace = await compute('ssr-trace', 'forgeax_ssr::trace', 'ssr_trace');
|
|
140
|
+
const encoder = device.createCommandEncoder();
|
|
141
|
+
const raster = encoder.beginRenderPass({
|
|
142
|
+
colorAttachments: [normal, radiance, fallback, temporal].map((t) => ({
|
|
143
|
+
view: t.createView(),
|
|
144
|
+
loadOp: 'clear' as const,
|
|
145
|
+
storeOp: 'store' as const,
|
|
146
|
+
clearValue: [0, 0, 0, 0],
|
|
147
|
+
})),
|
|
148
|
+
depthStencilAttachment: {
|
|
149
|
+
view: depth.createView(),
|
|
150
|
+
depthClearValue: 1,
|
|
151
|
+
depthLoadOp: 'clear',
|
|
152
|
+
depthStoreOp: 'store',
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
raster.setPipeline(seedPipeline);
|
|
156
|
+
raster.setBindGroup(
|
|
157
|
+
0,
|
|
158
|
+
device.createBindGroup({
|
|
159
|
+
layout: seedPipeline.getBindGroupLayout(0),
|
|
160
|
+
entries: [{ binding: 0, resource: { buffer: view } }],
|
|
161
|
+
}),
|
|
162
|
+
);
|
|
163
|
+
raster.draw(3);
|
|
164
|
+
raster.end();
|
|
165
|
+
const dispatch = (
|
|
166
|
+
pipeline: GPUComputePipeline,
|
|
167
|
+
entries: GPUBindGroupEntry[],
|
|
168
|
+
extent: number,
|
|
169
|
+
) => {
|
|
170
|
+
const pass = encoder.beginComputePass();
|
|
171
|
+
pass.setPipeline(pipeline);
|
|
172
|
+
pass.setBindGroup(
|
|
173
|
+
0,
|
|
174
|
+
device.createBindGroup({ layout: pipeline.getBindGroupLayout(0), entries }),
|
|
175
|
+
);
|
|
176
|
+
pass.dispatchWorkgroups(Math.ceil(extent / 8), Math.ceil(extent / 8));
|
|
177
|
+
pass.end();
|
|
178
|
+
};
|
|
179
|
+
for (let level = 0; level < 9; level++) {
|
|
180
|
+
dispatch(
|
|
181
|
+
level === 0 ? seedHiz : reduceHiz,
|
|
182
|
+
[
|
|
183
|
+
{
|
|
184
|
+
binding: 0,
|
|
185
|
+
resource:
|
|
186
|
+
level === 0
|
|
187
|
+
? depth.createView()
|
|
188
|
+
: hiz.createView({ baseMipLevel: level - 1, mipLevelCount: 1 }),
|
|
189
|
+
},
|
|
190
|
+
{ binding: 1, resource: hiz.createView({ baseMipLevel: level, mipLevelCount: 1 }) },
|
|
191
|
+
...(level === 0 ? [{ binding: 2, resource: { buffer: view } }] : []),
|
|
192
|
+
],
|
|
193
|
+
half >> level,
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
dispatch(
|
|
197
|
+
trace,
|
|
198
|
+
[depth, normal, radiance, hiz, traced]
|
|
199
|
+
.map<GPUBindGroupEntry>((t, binding) => ({ binding, resource: t.createView() }))
|
|
200
|
+
.concat([
|
|
201
|
+
{ binding: 5, resource: { buffer: view } },
|
|
202
|
+
{ binding: 6, resource: fallback.createView() },
|
|
203
|
+
{ binding: 7, resource: temporal.createView() },
|
|
204
|
+
{ binding: 8, resource: reactive.createView() },
|
|
205
|
+
]),
|
|
206
|
+
half,
|
|
207
|
+
);
|
|
208
|
+
const readback = device.createBuffer({
|
|
209
|
+
size: half * half * 8,
|
|
210
|
+
usage: GPU_BUFFER_USAGE_MAP_READ | GPU_BUFFER_USAGE_COPY_DST,
|
|
211
|
+
});
|
|
212
|
+
encoder.copyTextureToBuffer({ texture: traced }, { buffer: readback, bytesPerRow: half * 8 }, [
|
|
213
|
+
half,
|
|
214
|
+
half,
|
|
215
|
+
]);
|
|
216
|
+
device.queue.submit([encoder.finish()]);
|
|
217
|
+
await readback.mapAsync(GPU_BUFFER_USAGE_MAP_READ);
|
|
218
|
+
const words = new Uint16Array(readback.getMappedRange().slice(0));
|
|
219
|
+
readback.unmap();
|
|
220
|
+
const hits = new Uint8Array(half * half);
|
|
221
|
+
// Mirror-box slab intersections are independent of the GPU march and Hi-Z.
|
|
222
|
+
for (let y = 0; y < half; y++)
|
|
223
|
+
for (let x = 0; x < half; x++) {
|
|
224
|
+
const sx = (((2 * x + 0.5) / size) * 2 - 1) / Math.sqrt(3),
|
|
225
|
+
sy = (1 - ((2 * y + 0.5) / size) * 2) / Math.sqrt(3);
|
|
226
|
+
const d = [
|
|
227
|
+
-2 / 3 + sx * Math.SQRT1_2 - sy / Math.sqrt(18),
|
|
228
|
+
-1 / 3 + sy * Math.sqrt(8 / 9),
|
|
229
|
+
-2 / 3 - sx * Math.SQRT1_2 - sy / Math.sqrt(18),
|
|
230
|
+
] as const;
|
|
231
|
+
let enter = -Infinity,
|
|
232
|
+
leave = Infinity;
|
|
233
|
+
const bounds = [
|
|
234
|
+
[-1, 1],
|
|
235
|
+
[-3, -1],
|
|
236
|
+
[-1, 1],
|
|
237
|
+
] as const;
|
|
238
|
+
const eye = [6 + offset, 3, 6 - offset] as const;
|
|
239
|
+
for (const axis of [0, 1, 2] as const) {
|
|
240
|
+
const [lo, hi] = bounds[axis];
|
|
241
|
+
const a = (lo - eye[axis]) / d[axis],
|
|
242
|
+
b = (hi - eye[axis]) / d[axis];
|
|
243
|
+
enter = Math.max(enter, Math.min(a, b));
|
|
244
|
+
leave = Math.min(leave, Math.max(a, b));
|
|
245
|
+
}
|
|
246
|
+
hits[y * half + x] = Number(enter > 0 && enter < leave);
|
|
247
|
+
}
|
|
248
|
+
let interior = 0,
|
|
249
|
+
misses = 0,
|
|
250
|
+
exteriorHits = 0;
|
|
251
|
+
for (let y = 180; y < half - 1; y++)
|
|
252
|
+
for (let x = 1; x < half - 1; x++) {
|
|
253
|
+
const footprint = [-1, 0, 1].flatMap((dy) =>
|
|
254
|
+
[-1, 0, 1].map((dx) => hits[(y + dy) * half + x + dx] === 1),
|
|
255
|
+
);
|
|
256
|
+
const offset = (y * half + x) * 4;
|
|
257
|
+
const confident = (words[offset + 3] ?? 0) >= 0x3800; // positive half >= 0.5
|
|
258
|
+
if (footprint.every(Boolean)) {
|
|
259
|
+
interior++;
|
|
260
|
+
if (!confident) misses++;
|
|
261
|
+
}
|
|
262
|
+
if (!footprint.some(Boolean) && confident && (words[offset] ?? 0) >= 0x3800) exteriorHits++;
|
|
263
|
+
}
|
|
264
|
+
expect(await device.popErrorScope()).toBeNull();
|
|
265
|
+
expect(interior).toBeGreaterThan(1000);
|
|
266
|
+
expect({ misses, exteriorHits }).toEqual({ misses: 0, exteriorHits: 0 });
|
|
267
|
+
} finally {
|
|
268
|
+
device.destroy();
|
|
269
|
+
}
|
|
270
|
+
}, 30_000);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { RhiDevice } from '@forgeax/engine-rhi';
|
|
1
2
|
import { rhi } from '@forgeax/engine-rhi-webgpu';
|
|
2
|
-
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { beforeAll, describe, expect, it } from 'vitest';
|
|
3
4
|
import {
|
|
4
5
|
admittedSsrSpatial,
|
|
5
6
|
runSsrGpuDispatch,
|
|
@@ -10,31 +11,43 @@ import {
|
|
|
10
11
|
} from './ssr-gpu-dispatch';
|
|
11
12
|
import { runSsrReprojectionProbe } from './ssr-reprojection-probe';
|
|
12
13
|
|
|
14
|
+
const confidence = (values: readonly number[]) => values.filter((_, i) => i % 4 === 3);
|
|
15
|
+
|
|
13
16
|
describe('SSR GPU dispatch Browser WebGPU probe', () => {
|
|
14
|
-
|
|
17
|
+
let device: RhiDevice;
|
|
18
|
+
let sources: ReturnType<typeof sourcesFromManifest>;
|
|
19
|
+
beforeAll(async () => {
|
|
15
20
|
expect(admittedSsrSpatial().status).toBe('admitted');
|
|
16
21
|
const response = await fetch('/shaders/manifest.json');
|
|
17
22
|
expect(response.ok).toBe(true);
|
|
18
|
-
|
|
23
|
+
sources = sourcesFromManifest((await response.json()) as SsrShaderManifest);
|
|
19
24
|
const adapter = (await rhi.requestAdapter()).unwrap();
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
device = (await adapter.requestDevice()).unwrap();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Independent cases identify the failing invariant. The 300-frame case
|
|
29
|
+
// also includes cold software-driver compilation and completed readbacks;
|
|
30
|
+
// its bounded 30-second execution allowance is not a frame-performance gate.
|
|
31
|
+
it('reprojects history and reconstructs perspective and orthographic view distance', async () => {
|
|
32
|
+
expect(await runSsrReprojectionProbe(device, sources.temporal)).toEqual([
|
|
22
33
|
[0.5, 0.5, 0.375, 0.5625],
|
|
23
34
|
[0.5, 0.5, 0.375, 0.5625],
|
|
24
35
|
[0.5, 0.5, 0.375, 0.5625],
|
|
25
36
|
]);
|
|
26
|
-
for (const distances of await runSsrViewDistanceProbe(
|
|
27
|
-
device,
|
|
28
|
-
sourcesFromManifest(manifest).trace,
|
|
29
|
-
)) {
|
|
37
|
+
for (const distances of await runSsrViewDistanceProbe(device, sources.trace)) {
|
|
30
38
|
expect(distances[0]).toBeCloseTo(6.58, 4);
|
|
31
39
|
expect(distances[1]).toBeCloseTo(12, 4);
|
|
32
40
|
}
|
|
33
|
-
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('executes 300 stable Hi-Z, trace and temporal frames with finite visible hits', async () => {
|
|
44
|
+
const hit = await runSsrGpuDispatch(device, sources, 300);
|
|
45
|
+
expect(hit.passNames.filter((name) => name.startsWith('ssr-hiz-reduce'))).toHaveLength(1);
|
|
46
|
+
expect(hit.passNames.filter((name) => name.startsWith('ssr-reflection-mip'))).toHaveLength(1);
|
|
34
47
|
expect(hit.passNames).toContain('ssr-hiz-seed');
|
|
35
48
|
expect(hit.passNames).toContain('ssr-trace');
|
|
36
49
|
expect(hit.passNames).toContain('ssr-temporal');
|
|
37
|
-
expect(hit.passNames
|
|
50
|
+
expect(hit.passNames.filter((name) => name === 'ssr-compose')).toHaveLength(1);
|
|
38
51
|
expect(hit.resourceNames).toContain('ssr-resolved');
|
|
39
52
|
expect(hit.pixels).toHaveLength(300);
|
|
40
53
|
expect(new Set(hit.pixels.map((pixel) => pixel.join(','))).size).toBe(1);
|
|
@@ -45,47 +58,42 @@ describe('SSR GPU dispatch Browser WebGPU probe', () => {
|
|
|
45
58
|
const dx = (((0.5 / 64) * 2 - 1) * 2) / Math.sqrt(3);
|
|
46
59
|
expect(hiz[0]).toBeCloseTo(6 / (1 - dx), 2);
|
|
47
60
|
const trace = hit.tracePixels[0] ?? [];
|
|
48
|
-
const confidence = (values: readonly number[]) => values.filter((_, i) => i % 4 === 3);
|
|
49
61
|
expect(confidence(trace).some((value) => value > 0)).toBe(true);
|
|
50
62
|
expect(confidence(trace).filter((value) => value >= 0x3400).length).toBeGreaterThan(40);
|
|
51
63
|
expect(confidence(trace).every((value) => value <= 0x3c00)).toBe(true);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
}, 30_000);
|
|
65
|
+
|
|
66
|
+
it('rejects back-facing sources', async () => {
|
|
67
|
+
const result = await runSsrGpuDispatch(device, sources, 1, { sourceBackFacing: true });
|
|
68
|
+
expect(confidence(result.tracePixels[0] ?? []).every((value) => value === 0)).toBe(true);
|
|
69
|
+
});
|
|
56
70
|
|
|
57
|
-
|
|
71
|
+
it.each([
|
|
72
|
+
false,
|
|
73
|
+
true,
|
|
74
|
+
])('preserves reflected coordinates (recessed source: %s)', async (recessedSource) => {
|
|
75
|
+
const result = await runSsrGpuDispatch(device, sources, 1, {
|
|
58
76
|
coordinateSource: true,
|
|
77
|
+
recessedSource,
|
|
59
78
|
});
|
|
60
|
-
const errors = ssrCoordinateErrors(
|
|
79
|
+
const errors = ssrCoordinateErrors(result.tracePixels[0] ?? [], recessedSource);
|
|
61
80
|
expect(errors.length).toBeGreaterThan(10);
|
|
62
81
|
expect(errors.filter((error) => error > 0.002).length / errors.length).toBeLessThan(0.05);
|
|
82
|
+
});
|
|
63
83
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
expect(
|
|
70
|
-
|
|
71
|
-
0.05,
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
for (const options of [{ excludedSource: true }, { excludedReceiver: true }]) {
|
|
75
|
-
const excluded = await runSsrGpuDispatch(device, sourcesFromManifest(manifest), 1, options);
|
|
76
|
-
expect(confidence(excluded.tracePixels[0] ?? []).every((value) => value === 0)).toBe(true);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const miss = await runSsrGpuDispatch(device, sourcesFromManifest(manifest), 1, {
|
|
80
|
-
maxDistance: 0.01,
|
|
81
|
-
});
|
|
82
|
-
expect(miss.tracePixels[0]?.[3]).toBe(0);
|
|
83
|
-
expect(miss.tracePixels[0]).not.toEqual(hit.tracePixels[0]);
|
|
84
|
+
it.each([
|
|
85
|
+
{ excludedSource: true },
|
|
86
|
+
{ excludedReceiver: true },
|
|
87
|
+
])('rejects excluded material coverage (%j)', async (options) => {
|
|
88
|
+
const result = await runSsrGpuDispatch(device, sources, 1, options);
|
|
89
|
+
expect(confidence(result.tracePixels[0] ?? []).every((value) => value === 0)).toBe(true);
|
|
90
|
+
});
|
|
84
91
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
it.each([
|
|
93
|
+
{ maxDistance: 0.01 },
|
|
94
|
+
{ enabled: false },
|
|
95
|
+
])('produces zero confidence for an unavailable ray (%j)', async (options) => {
|
|
96
|
+
const result = await runSsrGpuDispatch(device, sources, 1, options);
|
|
97
|
+
expect(confidence(result.tracePixels[0] ?? []).every((value) => value === 0)).toBe(true);
|
|
90
98
|
});
|
|
91
99
|
});
|
|
@@ -39,6 +39,10 @@ describe('SSR GPU dispatch Dawn probe', () => {
|
|
|
39
39
|
expect(distances[1]).toBeCloseTo(12, 4);
|
|
40
40
|
}
|
|
41
41
|
const hit = await runSsrGpuDispatch(device, sourcesFromManifest(manifest), 300);
|
|
42
|
+
// Mip count must not grow CPU pass recording: ordered dispatches share
|
|
43
|
+
// one compute pass per pyramid, with every level still produced below.
|
|
44
|
+
expect(hit.passNames.filter((name) => name.startsWith('ssr-hiz-reduce'))).toHaveLength(1);
|
|
45
|
+
expect(hit.passNames.filter((name) => name.startsWith('ssr-reflection-mip'))).toHaveLength(1);
|
|
42
46
|
expect(hit.passNames).toContain('ssr-hiz-seed');
|
|
43
47
|
expect(hit.passNames).toContain('ssr-trace');
|
|
44
48
|
expect(hit.passNames).toContain('ssr-temporal');
|
|
@@ -887,15 +887,22 @@ export async function runSsrGpuDispatch(
|
|
|
887
887
|
const submitted = device.queue.submit([finished.value]);
|
|
888
888
|
if (!submitted.ok) throw submitted.error;
|
|
889
889
|
await device.queue.onSubmittedWorkDone();
|
|
890
|
-
|
|
890
|
+
// These independent copies share one completed submission. Request all
|
|
891
|
+
// mappings together instead of paying three browser/driver round trips
|
|
892
|
+
// for each of the 300 frames; every buffer is still read and validated.
|
|
893
|
+
const [mapped, traceMapped, hizMapped] = await Promise.all([
|
|
894
|
+
readbackBuffer.mapAsync(GPU_BUFFER_USAGE_MAP_READ),
|
|
895
|
+
traceReadbackBuffer.mapAsync(GPU_BUFFER_USAGE_MAP_READ),
|
|
896
|
+
hizReadbackBuffer.mapAsync(GPU_BUFFER_USAGE_MAP_READ),
|
|
897
|
+
]);
|
|
891
898
|
if (!mapped.ok) throw mapped.error;
|
|
899
|
+
if (!traceMapped.ok) throw traceMapped.error;
|
|
900
|
+
if (!hizMapped.ok) throw hizMapped.error;
|
|
892
901
|
const range = mapped.value.getMappedRange();
|
|
893
902
|
if (!range.ok) throw range.error;
|
|
894
903
|
const readbackWords = new Uint16Array(range.value.slice(0, bytesPerRow * SSR_GPU_PROBE_HEIGHT));
|
|
895
904
|
pixels.push([...readbackWords.slice(0, 4)]);
|
|
896
905
|
mapped.value.unmap();
|
|
897
|
-
const traceMapped = await traceReadbackBuffer.mapAsync(GPU_BUFFER_USAGE_MAP_READ);
|
|
898
|
-
if (!traceMapped.ok) throw traceMapped.error;
|
|
899
906
|
const traceRange = traceMapped.value.getMappedRange();
|
|
900
907
|
if (!traceRange.ok) throw traceRange.error;
|
|
901
908
|
const traceWords = new Uint16Array(
|
|
@@ -903,8 +910,6 @@ export async function runSsrGpuDispatch(
|
|
|
903
910
|
);
|
|
904
911
|
tracePixels.push([...traceWords]);
|
|
905
912
|
traceMapped.value.unmap();
|
|
906
|
-
const hizMapped = await hizReadbackBuffer.mapAsync(GPU_BUFFER_USAGE_MAP_READ);
|
|
907
|
-
if (!hizMapped.ok) throw hizMapped.error;
|
|
908
913
|
const hizRange = hizMapped.value.getMappedRange();
|
|
909
914
|
if (!hizRange.ok) throw hizRange.error;
|
|
910
915
|
const hizWords = new Float32Array(hizRange.value.slice(0, bytesPerRow * SSR_GPU_PROBE_HEIGHT));
|
|
@@ -78,7 +78,7 @@ describe('SSR typed spatial graph', () => {
|
|
|
78
78
|
const compiled = graph.compile({ device, surfaceSize: { width: 5, height: 3 } }).unwrap();
|
|
79
79
|
const info = compiled.inspect();
|
|
80
80
|
const names = info.passes.map((pass) => pass.name);
|
|
81
|
-
expect(names).toEqual(['seed-inputs', 'ssr-hiz-seed', 'ssr-hiz-reduce-
|
|
81
|
+
expect(names).toEqual(['seed-inputs', 'ssr-hiz-seed', 'ssr-hiz-reduce-chain', 'ssr-trace']);
|
|
82
82
|
expect(info.resources.map((resource) => resource.label)).toEqual(
|
|
83
83
|
expect.arrayContaining(['ssr-hiz', 'ssr-trace', 'ssr-hit-reactivity']),
|
|
84
84
|
);
|
|
@@ -88,7 +88,7 @@ describe('SSR typed spatial graph', () => {
|
|
|
88
88
|
{ resource: 'ssr-hit-reactivity', usage: 'storage-write' },
|
|
89
89
|
]),
|
|
90
90
|
);
|
|
91
|
-
expect(info.passes.find((pass) => pass.name === 'ssr-hiz-reduce-
|
|
91
|
+
expect(info.passes.find((pass) => pass.name === 'ssr-hiz-reduce-chain')?.accesses).toEqual([
|
|
92
92
|
{ resource: 'ssr-hiz', usage: 'sampled-read' },
|
|
93
93
|
{ resource: 'ssr-hiz', usage: 'storage-write' },
|
|
94
94
|
]);
|
|
@@ -122,7 +122,7 @@ describe('SSR spatial RhiNull integration', () => {
|
|
|
122
122
|
expect(device.framePassNames).toEqual([
|
|
123
123
|
'seed-inputs',
|
|
124
124
|
'ssr-hiz-seed',
|
|
125
|
-
'ssr-hiz-reduce-
|
|
125
|
+
'ssr-hiz-reduce-chain',
|
|
126
126
|
'ssr-trace',
|
|
127
127
|
]);
|
|
128
128
|
expect(compiled.value.inspect().resources).toEqual(
|
|
@@ -44,6 +44,46 @@ const noColorVariants = [
|
|
|
44
44
|
] as never;
|
|
45
45
|
const noColorManifest = { variants: noColorVariants } as never;
|
|
46
46
|
describe('Standard clustered variant resolution', () => {
|
|
47
|
+
it.each([
|
|
48
|
+
false,
|
|
49
|
+
true,
|
|
50
|
+
])('retains colored clustered geometry when reflection fallback is %s', (fallback) => {
|
|
51
|
+
const projection = deriveVertexLayoutProjection({
|
|
52
|
+
position: new Float32Array(9),
|
|
53
|
+
color: new Float32Array(12),
|
|
54
|
+
});
|
|
55
|
+
const projected = variantSetFromVertexLayoutProjection(
|
|
56
|
+
projection,
|
|
57
|
+
standardTopologyVariantSet({ kind: 'clustered' }, true, true),
|
|
58
|
+
);
|
|
59
|
+
if (!projected.ok) throw projected.error;
|
|
60
|
+
const geometry = projected.value;
|
|
61
|
+
const request =
|
|
62
|
+
geometry === '' && fallback
|
|
63
|
+
? ''
|
|
64
|
+
: `${geometry === '' ? '' : `${geometry}+`}REFLECTION_FALLBACK_AVAILABLE=${fallback}`;
|
|
65
|
+
const resolved = resolveMaterialShaderVariantSet(
|
|
66
|
+
request,
|
|
67
|
+
[
|
|
68
|
+
{
|
|
69
|
+
defines: {
|
|
70
|
+
CLUSTER_FORWARD_AVAILABLE: true,
|
|
71
|
+
STORAGE_BUFFER_AVAILABLE: true,
|
|
72
|
+
VERTEX_COLOR_AVAILABLE: true,
|
|
73
|
+
REFLECTION_FALLBACK_AVAILABLE: false,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
'webgpu',
|
|
78
|
+
true,
|
|
79
|
+
);
|
|
80
|
+
if (fallback) expect(resolved).toBe('');
|
|
81
|
+
else
|
|
82
|
+
expect(resolved).toBe(
|
|
83
|
+
'CLUSTER_FORWARD_AVAILABLE=true+REFLECTION_FALLBACK_AVAILABLE=false+STORAGE_BUFFER_AVAILABLE=true+VERTEX_COLOR_AVAILABLE=true',
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
|
|
47
87
|
it('derives the canonical capability key for every storage/cluster pair', () => {
|
|
48
88
|
expect(standardCapabilityVariantSet(true, true, true)).toBe(
|
|
49
89
|
'CLUSTER_FORWARD_AVAILABLE=true+STORAGE_BUFFER_AVAILABLE=true+VERTEX_COLOR_AVAILABLE=true',
|