From bcb85468c8072691a77db1f0be4a63cf9223b1e1 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 29 May 2026 23:51:13 +0100 Subject: [PATCH] Document D3D12 stereo depth provenance --- docs/implementation-plan.md | 13 ++ docs/perfect-machine-domain-index.md | 18 +- notes/current-system-map.md | 8 + notes/fresh-workspace-handoff.md | 5 + research/README.md | 9 +- ...3d12-stereo-depth-provenance-2026-05-29.md | 170 ++++++++++++++++++ state/evidence.jsonl | 1 + state/map.yaml | 6 + 8 files changed, 226 insertions(+), 4 deletions(-) create mode 100644 research/d3d12-stereo-depth-provenance-2026-05-29.md diff --git a/docs/implementation-plan.md b/docs/implementation-plan.md index c049626..2dafe69 100644 --- a/docs/implementation-plan.md +++ b/docs/implementation-plan.md @@ -34,6 +34,14 @@ deterministic local visibility generation before reservoir reuse. Reservoir resolve owns temporal antialiasing and reconstruction; TAA is not a separate hidden owner of field identity. +The first depth-compute target should be a D3D12 stereo disparity lane modeled +on permissive SGM provenance, with `libSGM` as the current north-star reference. +The research ledger is +[[research/d3d12-stereo-depth-provenance-2026-05-29|D3D12 Stereo Depth Provenance]]. +That note is not a dependency grant: CUDA implementations, TensorRT ports, and +monocular model demos are provenance only. The live owner is Fensalir D3D12 +compute over Mimir-declared texture resources and calibration state. + Those claims are not inherently pixel-sized. Pixel-level resolve consumes the reservoir, but claim support is chosen from the represented field. Smooth surfaces should stay broad. Aquarium-style heightfields should be quadtree @@ -506,6 +514,11 @@ a named invariant that the native runtime cannot protect yet. the blocker; TubeField now occupies the first generated-mesh lowering lane. The next renderer decisions are how to expose additional generated mesh producers and which camera/page/volume/material lowering should follow. + The first depth-specific cut should be a Fensalir-owned D3D12 stereo SGM + lane over rectified synchronized camera texture pairs, emitting + GPU-resident disparity/depth/confidence resources and FieldEvidence claims. + Keep `libSGM` as provenance for algorithm shape and benchmark pressure, not + as imported CUDA authority. 9. Move mic alignment, room suppression, voice separation, spatialization, and stem generation into Faust/native DSP. 10. Keep the OBS bridge witness ledger as evidence before expanding receiver diff --git a/docs/perfect-machine-domain-index.md b/docs/perfect-machine-domain-index.md index be42ae4..b4a822c 100644 --- a/docs/perfect-machine-domain-index.md +++ b/docs/perfect-machine-domain-index.md @@ -30,6 +30,10 @@ Read this with: - [[fensalir-rendering-rebuild-migration|Fensalir Rendering Rebuild Migration]] for the current teardown/rebuild plan that keeps Mimir on physical evidence and pushes field rendering authority into Fensalir's evidence machine. +- [[research/d3d12-stereo-depth-provenance-2026-05-29|D3D12 Stereo Depth Provenance]] + for the current fast GPU depth search. `libSGM` is the permissive north-star + reference for a future Fensalir-owned D3D12 compute stereo disparity lane; + CUDA/TensorRT projects remain provenance, not live dependencies. - [[research/perfect-machine-study-2026-05-23/calibration-session-spec|Calibration Session Spec]] for the planned physical-path calibration command. - [[perfect-machine-module-library|Perfect Machine Module Library]] for the @@ -168,6 +172,10 @@ Likely shape: - Native capture pushes typed frame handles and timestamps. - Fensalir extracts features/depth/optical flow on GPU. +- Stereo depth starts as a Fensalir-owned D3D12 compute lane modeled on + permissive SGM provenance, especially `libSGM`: rectified texture pairs plus + calibration produce GPU-resident disparity/depth/confidence resources, which + then lower into FieldEvidence claims. - Native reservoir preserves rolling evidence. - Fusion emits surface/material/render claims. - Program video publishes via Spout2. @@ -176,6 +184,8 @@ Pressure: - Do not build a CPU image pipeline because it is easy to inspect. Six cameras make that path collapse into a pile of excuses. +- Do not import CUDA or TensorRT as live depth authority. External depth + projects may guide kernel shape, benchmarks, and failure probes only. ## Hot Loop Budget @@ -254,6 +264,8 @@ Six optical sensors with high-rate Eyes and Leap IR mean: 3. Reduced alphabet/high-order codebook physical proof. 4. Fractional delay/SRO actuator proof. 5. Direct Leap/PS3/Kiyo runtime drivers. -6. Native reservoir integration with Fensalir/Faust. -7. Raven/phone receiver codebook/schedule local decode. -8. GPU visual fusion and Spout2 program video. +6. D3D12 stereo disparity/depth compute lane, with `libSGM` as provenance and + Fensalir as live owner. +7. Native reservoir integration with Fensalir/Faust. +8. Raven/phone receiver codebook/schedule local decode. +9. GPU visual fusion and Spout2 program video. diff --git a/notes/current-system-map.md b/notes/current-system-map.md index 355f304..ee3345c 100644 --- a/notes/current-system-map.md +++ b/notes/current-system-map.md @@ -381,6 +381,14 @@ Visual fusion belongs in Fensalir over current reservoir claims. Native capture workers provide frames; Fensalir owns feature extraction, matching, material fitting, render budgeting, and publication. +Fast stereo depth is now mapped as a future Fensalir D3D12 compute lane, not an +external library dependency. The provenance note +`research/d3d12-stereo-depth-provenance-2026-05-29.md` records `libSGM` as the +current permissive north-star reference: Mimir/Fensalir should rebuild the SGM +shape over synchronized rectified texture pairs, calibration state, typed GPU +resources, and explicit fences. CUDA, TensorRT, and monocular depth demos remain +research references only. + Fensalir must not be treated as a traditional rendering pipeline. Mimir does not ask it to "draw a thing" and hope post-processing makes the result true. Mimir submits evidence, buffers, constraints, and surface intent; Fensalir diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 3f48781..4fcd851 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -78,6 +78,11 @@ Get-Content .\state\evidence.jsonl -Tail 8 physical observations, calibration constraints, and surface intent; Fensalir turns those into field claims, selected lowerings, reusable evidence, temporal guide lanes, and presentation. +- Fast depth provenance now lives at + [[research/d3d12-stereo-depth-provenance-2026-05-29|D3D12 Stereo Depth + Provenance]]. `libSGM` is the current permissive north-star reference for a + future Fensalir-owned D3D12 stereo SGM compute lane. Do not import CUDA or + TensorRT as live depth authority. - Fensalir also owns the EVE-facing dashboard pixels through `Global\MimirFensalirProgramTexture`. `src/Mimir.EveRelay` opens that shared texture, encodes H.264 Annex-B with NVENC by default, and serves EveCanvas diff --git a/research/README.md b/research/README.md index dd76103..9b7a246 100644 --- a/research/README.md +++ b/research/README.md @@ -11,11 +11,18 @@ Use it to shape native implementation decisions: - direct camera and audio drivers; - pinned/native buffers; -- GPU feature extraction, flow, matching, and fusion; +- GPU feature extraction, flow, matching, depth, and fusion; - Fensalir D3D12 compute/render paths; - Faust/native DSP; - OBS-facing program outputs. +Visual/GPU research entry points: + +- [[d3d12-stereo-depth-provenance-2026-05-29|D3D12 Stereo Depth Provenance]]: + libSGM is the current permissive north-star reference for a future + Fensalir-owned D3D12 compute stereo-disparity lane. External CUDA/TensorRT + projects are provenance only, not runtime authority. + Audio timing research entry points: - [[chirplet-sync-decoder/summary|Chirplet Sync Decoder Summary]]: chirplet diff --git a/research/d3d12-stereo-depth-provenance-2026-05-29.md b/research/d3d12-stereo-depth-provenance-2026-05-29.md new file mode 100644 index 0000000..0c5644c --- /dev/null +++ b/research/d3d12-stereo-depth-provenance-2026-05-29.md @@ -0,0 +1,170 @@ +# D3D12 Stereo Depth Provenance + +Date: 2026-05-29 + +## Purpose + +This note records the current fast GPU depth-estimation search as provenance for +a future Mimir/Fensalir D3D12 compute implementation. + +The north star is `libSGM`: not as a dependency, not as a CUDA bridge, and not +as a permission slip to add an adapter. The useful shape is a fast, +deterministic stereo disparity pipeline whose ownership can be rebuilt inside +Fensalir's D3D12 resource model. + +## Authority Map + +Owner: + +- Fensalir owns the live D3D12 compute kernels, GPU resources, fences, + scheduling, and depth/surface claim lowering. + +Inputs: + +- Rectified synchronized camera texture pairs from Mimir-declared + `Texture2D` resources. +- Camera calibration: intrinsics, extrinsics, baseline, rectification map, and + valid-time/version metadata. +- Rolling-window timing chosen by `MimirSynchronizedBufferPlanner`. + +Outputs: + +- GPU-resident disparity/depth resources, preferably fixed format and size per + calibrated camera pair. +- FieldEvidence claims for depth support, confidence, invalid/occluded pixels, + and later surface/material lowerings. +- Diagnostics: kernel timings, disparity range, confidence histogram, invalid + ratio, calibration version, and source texture fence values. + +Derived State: + +- Depth is derived from synchronized stereo textures plus calibration. +- Per-frame disparity confidence is derived evidence, not a clock or camera + authority. +- Monocular model depth remains optional reference/assistive evidence unless a + later invariant gives it a named role. + +Forbidden Writers: + +- CUDA runtime code must not become the live path. +- TensorRT/ONNX monocular demos must not own visual geometry. +- CPU image copies/readback must not be inserted for convenience. +- OBS, EVE, or bridge utilities must not decide depth or synchronization. + +Shared Paths: + +- Direct user capture, replayed rolling-window frames, future Raven/phone + camera feeds, and calibration-session frames must all enter through typed + resources and use the same depth compute/claim path once they are calibrated + stereo pairs. + +Deletion Line: + +- If a prototype requires persistent CPU depth images, a side transport daemon, + or a CUDA compatibility layer, it is research-only and does not graduate into + the live machine. + +## Reference Shape: libSGM + +Repository: https://github.com/fixstars/libSGM + +License: Apache-2.0. + +Why it matters: + +- It is a CUDA implementation of Semi-Global Matching for stereo disparity. +- It was built by the Fixstars/adaskit ADAS effort, so it is pointed at the + same autonomous-driving pressure field rather than generic image demos. +- Reported benchmark in the upstream README: `1024 x 440`, disparity `128`, + four SGM paths, subpixel enabled: + - GTX 1080 Ti: `2.0 ms` / `495.1 FPS` + - RTX 3080: `1.5 ms` / `651.3 FPS` + - Tegra X2: `28.5 ms` / `35.1 FPS` + - Xavier MAXN: `9.0 ms` / `110.7 FPS` + +Port lesson: + +- Use the pipeline and data movement as a model: matching cost, path + aggregation, winner/subpixel selection, confidence/invalid handling. +- Rebuild the kernels in HLSL/D3D12 compute against Fensalir-owned resources. +- Preserve the ADAS-style assumption that calibrated stereo gives metric depth + when baseline and rectification are real. + +## Secondary References + +Fast-ACVNet: https://github.com/gangweiX/Fast-ACVNet + +- License: MIT. +- Learned real-time stereo matching; useful for quality and failure-mode + comparison. +- Upstream reports `45 ms` for Fast-ACVNet+ in its KITTI/Scene Flow table. +- Not the first Mimir implementation target because it brings model training, + weights, and framework deployment complexity. + +UniMatch / GMStereo: https://github.com/autonomousvision/unimatch + +- License: MIT. +- Unified flow/stereo/depth research code. +- Useful as a modern learned-stereo comparison point and possible later + confidence/feature guide, not a kernel blueprint. + +Depth Anything V2 Small: https://github.com/DepthAnything/Depth-Anything-V2 + +- License caveat: V2 Small is Apache-2.0; Base/Large/Giant are CC-BY-NC-4.0. +- Excellent monocular relative-depth reference, especially through TensorRT + ports, but monocular output is not metric scene truth by itself. + +Depth Anything TensorRT CLI: +https://github.com/spacewalk01/depth-anything-tensorrt + +- License: MIT. +- Reports fast RTX 4090 inference for Depth-Anything-S/B/L. +- Useful as performance context only. It must not displace calibrated stereo + geometry or Fensalir's D3D12 ownership. + +Fast-FoundationStereo: +https://github.com/NVlabs/Fast-FoundationStereo + +- Important research reference for real-time zero-shot stereo. +- License is research/non-commercial only, so it is not a permissive live + dependency candidate. + +## D3D12 Compute Implementation Sketch + +First implementation should stay boring and inspectable: + +1. Rectify or require pre-rectified stereo pairs. +2. Convert sampled luma/feature texture into a compact matching domain. +3. Build per-pixel disparity matching costs over a fixed disparity range. +4. Aggregate along a small fixed path set, starting with four directions to + match the `libSGM` reference benchmark shape. +5. Select winner disparity and subpixel refinement. +6. Emit disparity, confidence, and invalid/occlusion masks as GPU resources. +7. Lower those resources into FieldEvidence depth/support claims. + +Important D3D12 resource notes: + +- Prefer persistent UAV/SRV resources sized by camera pair profile. +- Use explicit producer/consumer fences already established for camera texture + leases and program-output publication. +- Keep disparity range and path count as profile-level cost levers, not + per-frame mode flags scattered through the renderer. +- Do not read back depth except for gated diagnostics and receipts. + +## Initial Verification Targets + +- Synthetic rectified stereo pair with known constant disparity. +- Slanted plane with known disparity gradient. +- Occlusion edge where invalid/confidence behavior is visible. +- Real Leap stereo IR pair once calibration is pinned. +- Full rolling-window path: camera textures -> depth compute -> FieldEvidence + claim -> Fensalir debug overlay/resource receipt. + +Negative checks: + +- No CUDA runtime loaded. +- No CPU disparity image in the live path. +- No monocular model output accepted as metric depth without a named scale + authority. +- No untyped texture handle accepted without resource declaration and fence + provenance. diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 8c92471..91748ee 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -227,3 +227,4 @@ {"ts": "2026-05-28T22:05:00+01:00", "type": "decision", "status": "ok", "note": "For many-hundreds-spline rendering, Fensalir stays on cheap segmented TubeField proxies rather than spline-wide SDF evaluation. The current cut fixes segment continuity by carrying consistent start/end radius pairs through generated proxy vertices and storing true start/end radii in compute segment packets. Verified with Fensalir/Mimir builds, --mimir-spectrum-upload-smoke, and headless capture artifacts/runtime/tubefield-cheap-continuity-spectrum.png."} {"timestamp":"2026-05-29T01:46:00+01:00","type":"decision","status":"ok","note":"Fensalir TubeField spectrum rendering now uses rolling-buffer column packets as reservoir candidate authority rather than generated segment packets. Expansion emits one GPU-resident column packet per logical history/source column, ReSTIR evaluates Catmull-Rom SDF/material samples directly from the source buffer, and generated mesh draw args are zeroed for the live path. Verified through Mimir.App headless synthetic spectrum capture artifacts/runtime/mimir-column-packet-final-headless.png."} {"ts": "2026-05-29T22:23:04+01:00", "type": "decision", "status": "ok", "note": "Raven display/audio sync uses shared clock-domain correction: Raven display frames can be tagged raven-sync, while Raven audio routed into Scarlett earns the timing offset applied by MimirSynchronizedBufferPlanner; network arrival timestamps remain metadata."} +{"ts": "2026-05-29T23:50:56+01:00", "type": "decision", "status": "ok", "note": "Fast stereo depth is mapped as a future Fensalir-owned D3D12 compute lane, with libSGM as permissive SGM provenance rather than a CUDA dependency. External TensorRT/monocular depth projects remain reference evidence only; live depth must consume Mimir-declared texture resources, calibration, and fences, then emit GPU disparity/depth/confidence resources and FieldEvidence claims."} diff --git a/state/map.yaml b/state/map.yaml index 872f9db..3e7ff76 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -51,6 +51,12 @@ invariants: - Mimir publishes physical observations, calibration constraints, and surface intent. Fensalir owns field claims, selected lowerings, evidence reservoirs, temporal guide lanes, and program presentation. + - Fast stereo depth belongs to Fensalir's D3D12 compute/resource authority. + `research/d3d12-stereo-depth-provenance-2026-05-29.md` records libSGM as + the permissive north-star reference for a future SGM-shaped stereo + disparity lane over synchronized rectified texture pairs and calibration + state. CUDA, TensorRT, and monocular depth demos are provenance only, not + live dependencies or geometry authority. - Fensalir packet payload handles are not authority. Live payload references must resolve through declared typed GPU/native resources with shape, residency, shader access, validity, version, and handle metadata before