Carry stereo depth SGM constants

This commit is contained in:
Meta Vens 2026-05-30 00:48:10 +01:00
commit d6823245c2
8 changed files with 47 additions and 6 deletions

View file

@ -48,7 +48,9 @@ textures, emits a GPU-resident compute-writable R16F disparity `SurfacePage`,
an R8 confidence texture, a Height FieldEvidence claim planned to the
`SurfacePage` backend, and an `AquariumFieldStereoDepthLowering` sidecar tying
profile, calibration, camera pair, inputs, disparity output, disparity
settings, and depth range together. This is the socket for the kernel, not the
settings, SGM constants, and depth range together. The libSGM-provenance profile
currently publishes min disparity 0, 128 disparities, four aggregation paths,
census radius 2, P1 8, and P2 96. This is the socket for the kernel, not the
kernel. Fensalir's renderer now reports whether those lowerings are
dispatch-ready after planning/resource resolution, without writing placeholder
depth values.

View file

@ -181,7 +181,8 @@ Likely shape:
FieldEvidence socket. The synthetic Leap stereo pair uses caller-declared
shader-readable left/right texture declarations, an R16F compute-writable disparity
`SurfacePage`, an R8 confidence `Texture2D`, one Height claim, one
`AquariumFieldStereoDepthLowering` sidecar, and one planned `SurfacePage`
`AquariumFieldStereoDepthLowering` sidecar with min disparity 0, 128
disparities, four paths, census radius 2, P1 8, and P2 96, and one planned `SurfacePage`
packet. It is not yet a live compute kernel.
- Native reservoir preserves rolling evidence.
- Fusion emits surface/material/render claims.

View file

@ -414,8 +414,10 @@ left/right input textures, then emitting a GPU-resident compute-writable
disparity SurfacePage, confidence texture, Height FieldEvidence claim, and
`AquariumFieldStereoDepthLowering` sidecar. The lowering sidecar is the dispatch contract: it binds the
libSGM-provenance profile, calibration id, camera pair, inputs, disparity
output, disparity levels, aggregation paths, and depth range. The kernel itself
is still future work. Fensalir's D3D12 renderer now counts stereo-depth
output, min disparity, disparity levels, aggregation paths, census radius,
P1/P2 smoothness penalties, and depth range. The current D3D12 SGM profile
publishes min disparity 0, 128 disparities, four paths, census radius 2, P1 8,
and P2 96. The kernel itself is still future work. Fensalir's D3D12 renderer now counts stereo-depth
lowerings as dispatch-ready only when the Height claim is planned and the
left/right input textures plus UAV disparity `SurfacePage` resolve through its
field resource registry; it logs that readiness separately from the absent

View file

@ -2300,8 +2300,12 @@ static AquariumFieldEvidenceFrame BuildSyntheticStereoDepthFrame(MimirFensalirFi
ConfidenceResourceKey: "mimir:resource:stereo-depth:leap-confidence-r8",
Width: 640,
Height: 240,
MinDisparity: profile.MinDisparity,
DisparityLevels: profile.DisparityLevels,
AggregationPathCount: profile.AggregationPathCount,
CensusRadius: profile.CensusRadius,
SmoothnessPenaltySmall: profile.SmoothnessPenaltySmall,
SmoothnessPenaltyLarge: profile.SmoothnessPenaltyLarge,
MinDepthMeters: 0.20,
MaxDepthMeters: 4.0,
Confidence: 0.93,
@ -2353,7 +2357,7 @@ static int RunStereoDepthContractSmoke()
var confidence = frame.Resources.FirstOrDefault(resource => resource.ResourceKey == "mimir:resource:stereo-depth:leap-confidence-r8");
Console.WriteLine(
$"stereo-depth-contract profile={profile.Id} provenance={profile.Provenance} liveDependency={profile.LiveDependency} disparityLevels={profile.DisparityLevels} paths={profile.AggregationPathCount}");
$"stereo-depth-contract profile={profile.Id} provenance={profile.Provenance} liveDependency={profile.LiveDependency} minDisparity={profile.MinDisparity} disparityLevels={profile.DisparityLevels} paths={profile.AggregationPathCount} censusRadius={profile.CensusRadius} p1={profile.SmoothnessPenaltySmall:0.###} p2={profile.SmoothnessPenaltyLarge:0.###}");
Console.WriteLine(
$"stereo-depth-field resources={frame.Resources.Count} claims={frame.Claims.Count} planned={plan.Packets.Count} deferred={plan.DeferredRequests.Count} errors={validation.HasErrors}");
Console.WriteLine(
@ -2369,6 +2373,10 @@ static int RunStereoDepthContractSmoke()
frame.Resources.Count == 4 &&
frame.StereoDepthLowerings.Count == 1 &&
stereoLowering.ProfileKey == profile.Id &&
stereoLowering.MinDisparity == profile.MinDisparity &&
stereoLowering.CensusRadius == profile.CensusRadius &&
Math.Abs(stereoLowering.SmoothnessPenaltySmall - profile.SmoothnessPenaltySmall) < 0.001 &&
Math.Abs(stereoLowering.SmoothnessPenaltyLarge - profile.SmoothnessPenaltyLarge) < 0.001 &&
stereoLowering.LeftResourceKey == "mimir:resource:texture2d:leap-left-ir" &&
stereoLowering.RightResourceKey == "mimir:resource:texture2d:leap-right-ir" &&
stereoLowering.DisparityResourceKey == disparity.ResourceKey &&

View file

@ -768,8 +768,12 @@ public sealed class MimirFensalirFieldLowering(MimirFensalirLoweringOptions? opt
ConfidenceResourceKey: depthCandidate.ConfidenceResourceKey,
Width: Math.Max(1, depthCandidate.Width),
Height: Math.Max(1, depthCandidate.Height),
MinDisparity: Math.Max(0, depthCandidate.MinDisparity),
DisparityLevels: Math.Max(1, depthCandidate.DisparityLevels),
AggregationPathCount: Math.Max(1, depthCandidate.AggregationPathCount),
CensusRadius: Math.Max(1, depthCandidate.CensusRadius),
SmoothnessPenaltySmall: (float)depthCandidate.SmoothnessPenaltySmall,
SmoothnessPenaltyLarge: (float)depthCandidate.SmoothnessPenaltyLarge,
MinDepthMeters: (float)depthCandidate.MinDepthMeters,
MaxDepthMeters: (float)depthCandidate.MaxDepthMeters);

View file

@ -28,6 +28,10 @@ public sealed record MimirStereoDepthKernelProfile(
bool RequiresCalibration,
string[] RequiredInputResources,
string[] OutputResources,
int MinDisparity,
int CensusRadius,
double SmoothnessPenaltySmall,
double SmoothnessPenaltyLarge,
string[] NegativeChecks);
public sealed record MimirStereoDepthFieldCandidate(
@ -44,8 +48,12 @@ public sealed record MimirStereoDepthFieldCandidate(
string ConfidenceResourceKey,
int Width,
int Height,
int MinDisparity,
int DisparityLevels,
int AggregationPathCount,
int CensusRadius,
double SmoothnessPenaltySmall,
double SmoothnessPenaltyLarge,
double MinDepthMeters,
double MaxDepthMeters,
double Confidence,
@ -67,6 +75,10 @@ public static class MimirStereoDepthConfigurations
RequiresCalibration: true,
RequiredInputResources: ["left Texture2D", "right Texture2D", "stereo calibration"],
OutputResources: ["R16Float disparity SurfacePage", "R8_UNorm confidence Texture2D"],
MinDisparity: 0,
CensusRadius: 2,
SmoothnessPenaltySmall: 8.0,
SmoothnessPenaltyLarge: 96.0,
NegativeChecks:
[
"no CUDA runtime dependency",
@ -89,6 +101,10 @@ public static class MimirStereoDepthConfigurations
RequiresCalibration: true,
RequiredInputResources: ["left Texture2D", "right Texture2D", "model weights"],
OutputResources: ["learned disparity/depth reference"],
MinDisparity: 0,
CensusRadius: 0,
SmoothnessPenaltySmall: 0.0,
SmoothnessPenaltyLarge: 0.0,
NegativeChecks: ["does not own live geometry", "does not introduce model runtime before D3D12 SGM socket exists"]);
public static MimirStereoDepthKernelProfile DepthAnythingSmallReference { get; } = new(
@ -105,6 +121,10 @@ public static class MimirStereoDepthConfigurations
RequiresCalibration: false,
RequiredInputResources: ["single camera Texture2D", "model weights"],
OutputResources: ["relative depth reference"],
MinDisparity: 0,
CensusRadius: 0,
SmoothnessPenaltySmall: 0.0,
SmoothnessPenaltyLarge: 0.0,
NegativeChecks: ["does not own metric scene geometry", "does not bypass calibrated stereo"]);
public static IReadOnlyList<MimirStereoDepthKernelProfile> BuiltIn { get; } =

View file

@ -235,3 +235,4 @@
{"ts":"2026-05-30T00:38:19+01:00","type":"implementation","status":"ok","note":"Stereo-depth FieldEvidence now emits dispatch metadata, not just an output page. MimirFensalirFieldLowering declares synthetic rectified left/right Texture2D inputs, the UAV R16F disparity SurfacePage, the confidence texture, the Height claim, and an AquariumFieldStereoDepthLowering sidecar carrying profile, calibration, camera pair, inputs, output, disparity settings, and depth range. Verified with Mimir build, --stereo-depth-contract-smoke, --perfect-machine-profile-smoke, and Fensalir StereoDepth contract tests. The SGM HLSL kernel remains future work."}
{"ts":"2026-05-30T00:39:40+01:00","type":"decision","status":"ok","note":"Stereo-depth lowerer does not fabricate shared input handles. BuildStereoDepthCandidateFrame accepts caller-declared input resources, then emits the UAV disparity SurfacePage, confidence texture, Height claim, and AquariumFieldStereoDepthLowering sidecar that references those real texture resource keys. The BufferSmoke proof supplies synthetic input declarations only for contract validation."}
{"ts":"2026-05-30T00:44:38+01:00","type":"decision","status":"ok","note":"Fensalir now owns stereo-depth dispatch readiness accounting before the SGM kernel exists: it only counts a lowering ready when the Height claim is planned and left/right textures plus the UAV disparity SurfacePage resolve. Mimir remains responsible for real input texture resource identity; no placeholder depth output is written."}
{"ts":"2026-05-30T00:48:04+01:00","type":"implementation","status":"ok","note":"Stereo-depth profile/candidate/lowering now carries SGM constants through Mimir into the Fensalir sidecar: min disparity 0, 128 disparities, four aggregation paths, census radius 2, P1 8, and P2 96 for the libSGM-provenance D3D12 profile. Verified Mimir build, --stereo-depth-contract-smoke, and --perfect-machine-profile-smoke."}

View file

@ -64,7 +64,10 @@ invariants:
then lowers synthetic rectified stereo depth into a compute-writable R16F
disparity SurfacePage, R8 confidence Texture2D, a Height FieldEvidence claim, and an
`AquariumFieldStereoDepthLowering` sidecar tying profile, calibration,
camera pair, inputs, disparity output, and depth range together. The actual
camera pair, inputs, disparity output, SGM constants, and depth range
together. The current libSGM-provenance D3D12 SGM profile publishes min
disparity 0, 128 disparities, four aggregation paths, census radius 2, P1
8, and P2 96. The actual
SGM HLSL/D3D12 kernel is still future work. Fensalir now reports
stereo-depth dispatch readiness only after the planned claim and all input/
output resources resolve, without writing placeholder depth.