Make camera ingest device-direct first
This commit is contained in:
parent
7202d30ef1
commit
9147fcd626
8 changed files with 62 additions and 29 deletions
|
|
@ -50,7 +50,9 @@ preferred authority is Fensalir-owned texture leasing: Mimir asks the engine
|
|||
broker for a keyed `Texture2D` lease, writes decoded frames into the returned
|
||||
shared D3D12 texture, signals the returned fence, and commits that fence value
|
||||
before the resource key is sampled by shader lowerings. Foreign shared handles
|
||||
remain import edges only.
|
||||
remain import edges only. Camera producers must choose the closest-to-device
|
||||
path available for each sensor and report the unavoidable copy count; convenient
|
||||
managed/process middlemen are diagnostic witnesses, not hot-path owners.
|
||||
|
||||
The old script stack is gone. Do not add a compatibility edge unless it protects
|
||||
a named invariant that the native runtime cannot protect yet.
|
||||
|
|
@ -357,8 +359,8 @@ a named invariant that the native runtime cannot protect yet.
|
|||
## Next
|
||||
|
||||
1. Replace the frame-event diagnostic bridge with concrete direct capture
|
||||
drivers for Leap stereo IR first, then the
|
||||
other cameras.
|
||||
drivers for Leap stereo IR first, then the other cameras. Each driver must
|
||||
state its device API, destination resource, and unavoidable copy count.
|
||||
2. Feed those drivers into `MimirVideoCaptureDriverSource` and prove sustained
|
||||
frame cadence in the rolling buffers.
|
||||
3. Promote the packet-song physical calibration receipt into the runtime
|
||||
|
|
|
|||
|
|
@ -36,9 +36,13 @@ The app-level runtime initializes one rolling buffer per configured audio or
|
|||
video stream, defaulting to five seconds. The lower native reservoir keeps the
|
||||
single-edge typed-handle invariant for Fensalir/Faust integration.
|
||||
|
||||
Payload memory belongs to the producing domain. The reservoir and runtime own
|
||||
timing, identity, ordering, retention, and lookup. They do not pretend to own
|
||||
camera driver buffers, GPU textures, or DSP audio memory.
|
||||
Payload memory belongs to the producing domain, but rendering inputs should be
|
||||
Fensalir-owned GPU resources whenever the device path allows it. The camera hot
|
||||
path is: ask Fensalir for a keyed `Texture2D` lease, speak to the device stack
|
||||
as directly as possible, populate that lease, signal the producer fence, and
|
||||
publish the resource key through Mimir's rolling buffers and FieldEvidence. The
|
||||
reservoir and runtime own timing, identity, ordering, retention, and lookup.
|
||||
They do not become pixel middlemen.
|
||||
|
||||
## Authoritative Boundaries
|
||||
|
||||
|
|
@ -62,7 +66,10 @@ camera driver buffers, GPU textures, or DSP audio memory.
|
|||
|
||||
1. Keep the C# app/runtime as the public Mimir surface.
|
||||
2. Implement Leap stereo IR direct ingest first and measure sustained cadence.
|
||||
3. Add the remaining local camera drivers through the same source seam.
|
||||
Record the unavoidable copy count; do not hide CPU upload behind a friendly
|
||||
adapter name.
|
||||
3. Add the remaining local camera drivers through the same source seam,
|
||||
preferring device-direct producers that populate Fensalir texture leases.
|
||||
4. Add native audio capture workers and feed aligned blocks to Faust/native DSP.
|
||||
5. Bind Fensalir UI to stream health, buffer depth, source timestamps, settings,
|
||||
and output management.
|
||||
|
|
|
|||
|
|
@ -107,11 +107,14 @@ The first cut should be deliberately boring:
|
|||
- `MimirNativeIngestStreamSource` is the low-overhead push seam for native
|
||||
camera/audio adapters that already own buffers or handles.
|
||||
- `MimirVideoFrameDescriptor` carries video shape, pixel format, device
|
||||
timestamp, stride, and optional native/GPU handle metadata. Leap stereo IR
|
||||
should enter here through a native driver path.
|
||||
timestamp, stride, resource key, producer fence value, and native/GPU handle
|
||||
metadata. Leap stereo IR should enter here through a native driver path that
|
||||
reports any unavoidable system-memory copy.
|
||||
- `IMimirVideoCaptureDriver` and `MimirVideoCaptureDriverSource` are the
|
||||
driver-facing seam for polling/pushing frames from LeapUVC/libusb, LeapC image
|
||||
APIs, Media Foundation, DirectShow, or a future GPU shared-texture capture.
|
||||
APIs, Media Foundation, DirectShow, or GPU decode/capture paths. Drivers that
|
||||
can produce render inputs should implement `IMimirFensalirTextureLeaseReceiver`
|
||||
and populate Fensalir-owned texture leases directly.
|
||||
- `MimirProcessStreamSource` is a compatibility adapter for network or
|
||||
diagnostic command sources. It is not the six-camera local capture foundation.
|
||||
|
||||
|
|
@ -129,10 +132,10 @@ environment variables:
|
|||
These create buffers immediately. Capture adapters still need to register
|
||||
`IMimirStreamSource` implementations to feed live samples into those buffers.
|
||||
|
||||
For local cameras, prefer native adapters that push sample handles directly
|
||||
through `MimirNativeIngestStreamSource`. Process-backed FFmpeg ingest is allowed
|
||||
for remote SRT/diagnostic edges, but local six-camera ingest should stay close
|
||||
to the driver, GPU, and capture APIs.
|
||||
For local cameras, prefer native adapters that talk to the device stack directly
|
||||
and push only typed sample/resource handles through `MimirNativeIngestStreamSource`.
|
||||
Process-backed FFmpeg ingest is allowed for remote SRT/diagnostic edges, but
|
||||
local six-camera ingest should stay close to the device, GPU, and capture APIs.
|
||||
|
||||
Leap should be treated as the timing-camera candidate only when the native
|
||||
adapter preserves device timestamps or captures a monotonic timestamp
|
||||
|
|
|
|||
|
|
@ -336,6 +336,9 @@ foreign texture handles remain an import edge, not the primary camera authority.
|
|||
`MimirVideoCaptureDriverSource` propagates the lease client to drivers that
|
||||
implement `IMimirFensalirTextureLeaseReceiver`, so direct camera drivers can
|
||||
request the destination texture before emitting a frame descriptor.
|
||||
Each camera backend must use the closest-to-device path available and expose
|
||||
its unavoidable copy count. Managed/process wrappers are diagnostic bring-up
|
||||
surfaces, not the production camera hot path.
|
||||
Metadata-only cadence frames do not create camera surface intents or fake
|
||||
payload requests. The old direct `AquariumGpuSensorFrame` bridge proof has been
|
||||
removed from Mimir's active proof path. Camera image claims currently defer
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ Get-Content .\state\evidence.jsonl -Tail 8
|
|||
producer fence value, and lowers the same resource key through FieldEvidence.
|
||||
`MimirVideoCaptureDriverSource` forwards that lease client to direct drivers
|
||||
that implement `IMimirFensalirTextureLeaseReceiver`.
|
||||
Camera backends must use the closest-to-device path available and report
|
||||
unavoidable copies; process or managed convenience layers are diagnostics.
|
||||
Foreign shared texture handles are import edges, not the primary hot path.
|
||||
- The current Mimir/Fensalir rendering teardown map is
|
||||
[[docs/fensalir-rendering-rebuild-migration|Fensalir Rendering Rebuild
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ public enum MimirCameraIngestStrategy
|
|||
JsonCadenceProbe,
|
||||
ManagedNativeWrapper,
|
||||
NativeSpscFrameRing,
|
||||
SharedGpuTexture
|
||||
FensalirTextureLease,
|
||||
DeviceDirectTextureProducer
|
||||
}
|
||||
|
||||
public sealed record MimirCameraIngestConfiguration(
|
||||
|
|
@ -34,34 +35,44 @@ public static class MimirCameraIngestConfigurations
|
|||
|
||||
public static MimirCameraIngestConfiguration ManagedWrapper { get; } = new(
|
||||
"managed-native-wrapper",
|
||||
"First real driver integration shape through IMimirVideoCaptureDriver.",
|
||||
"Managed polling seam for bring-up only; useful for proving timing and descriptor shape.",
|
||||
MimirCameraIngestStrategy.ManagedNativeWrapper,
|
||||
"Mimir.Runtime + native worker",
|
||||
CarriesPixels: true,
|
||||
HotPathCandidate: true,
|
||||
DeviceProfiles: ["leap-left-ir", "leap-right-ir"],
|
||||
RequiredProofs: ["one-camera sustained cadence", "bounded allocation", "device timestamp preserved"],
|
||||
"Good first cut for Leap because observability matters while the ABI is still moving.");
|
||||
RequiredProofs: ["one-camera sustained cadence", "bounded allocation", "device timestamp preserved", "copy count reported"],
|
||||
"This is a diagnostic bring-up seam, not the destination. Promote only when it is the shortest path to evidence.");
|
||||
|
||||
public static MimirCameraIngestConfiguration NativeSpscRing { get; } = new(
|
||||
"native-spsc-frame-ring",
|
||||
"Production local-camera ingest: native producer rings with typed payload handles.",
|
||||
"Native producer ring for device APIs that must expose system-memory frames.",
|
||||
MimirCameraIngestStrategy.NativeSpscFrameRing,
|
||||
"native capture + native/reservoir",
|
||||
CarriesPixels: true,
|
||||
HotPathCandidate: true,
|
||||
DeviceProfiles: MimirNativeCaptureConfigurations.LocalSixCameraProfiles.Select(profile => profile.Id).ToArray(),
|
||||
RequiredProofs: ["all six cameras sustained", "no stdout transport", "bounded memory", "consumer lag telemetry"],
|
||||
"This is the six-camera throughput answer.");
|
||||
RequiredProofs: ["all six cameras sustained", "no stdout transport", "bounded memory", "consumer lag telemetry", "unavoidable-copy ledger"],
|
||||
"Use only when the device stack cannot write or decode into the Fensalir texture path directly.");
|
||||
|
||||
public static MimirCameraIngestConfiguration SharedTexture { get; } = NativeSpscRing with
|
||||
public static MimirCameraIngestConfiguration FensalirTextureLease { get; } = NativeSpscRing with
|
||||
{
|
||||
Id = "shared-gpu-texture",
|
||||
Description = "Final copy-avoidance target: native capture provides importable GPU handles for Fensalir.",
|
||||
Strategy = MimirCameraIngestStrategy.SharedGpuTexture,
|
||||
Owner = "native capture + Fensalir",
|
||||
RequiredProofs = ["Fensalir imports frames", "rendered pixels match source cadence", "handle lifetime is explicit"],
|
||||
Notes = "Promote only when driver/API friction is paid down; Fensalir owns GPU lifetime."
|
||||
Id = "fensalir-texture-lease",
|
||||
Description = "Preferred render-input path: device/decode producer writes into a Fensalir-owned Texture2D lease.",
|
||||
Strategy = MimirCameraIngestStrategy.FensalirTextureLease,
|
||||
Owner = "native capture/decode producer + Fensalir",
|
||||
RequiredProofs = ["producer receives Fensalir lease", "producer signals fence", "Fensalir waits before sampling", "copy count is zero or justified"],
|
||||
Notes = "This is the hot path for decoded camera images. Imported foreign handles are fallback edges."
|
||||
};
|
||||
|
||||
public static MimirCameraIngestConfiguration DeviceDirectTextureProducer { get; } = FensalirTextureLease with
|
||||
{
|
||||
Id = "device-direct-texture-producer",
|
||||
Description = "Closest-to-zero-copy target: speak to the device stack directly and populate the Fensalir lease without middlemen.",
|
||||
Strategy = MimirCameraIngestStrategy.DeviceDirectTextureProducer,
|
||||
Owner = "device-specific native producer + Fensalir",
|
||||
RequiredProofs = ["device API path identified", "no process bridge", "no convenience transcode", "GPU/system copy count measured", "cadence survives full camera set"],
|
||||
Notes = "Backend choice is device-specific: KS/WinUSB raw sources may still land in system memory; GPU-decodable compressed sources should avoid CPU decode."
|
||||
};
|
||||
|
||||
public static IReadOnlyList<MimirCameraIngestConfiguration> BuiltIn { get; } =
|
||||
|
|
@ -69,6 +80,7 @@ public static class MimirCameraIngestConfigurations
|
|||
CadenceProbe,
|
||||
ManagedWrapper,
|
||||
NativeSpscRing,
|
||||
SharedTexture
|
||||
FensalirTextureLease,
|
||||
DeviceDirectTextureProducer
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,3 +175,4 @@
|
|||
{"ts": "2026-05-27T12:54:07+01:00", "type": "implementation", "status": "ok", "note": "Mimir's proof path no longer uses the direct AquariumAcousticFieldFrame builder. Sync states lower into FieldEvidence calibration constraints through MapCalibrationConstraints, and the profile/benchmark smokes now measure the claim/defer path until Fensalir owns a selected acoustic visualization/fusion lowering."}
|
||||
{"ts": "2026-05-27T13:26:42+01:00", "type": "decision", "status": "ok", "note": "Fensalir-owned Texture2D leases are the preferred live camera payload authority: Mimir receives AquariumRuntimeServices, requests keyed D3D12 texture/fence leases, writes decoded frames into the engine-owned shared texture, commits producer fence values, and lowers the resource key through FieldEvidence. Imported shared texture handles remain fallback/import edges."}
|
||||
{"ts": "2026-05-27T13:32:24+01:00", "type": "decision", "status": "ok", "note": "Texture lease services now propagate from MimirRuntime into direct video capture sources. MimirVideoCaptureDriverSource forwards a MimirFensalirTextureLeaseClient to drivers that implement IMimirFensalirTextureLeaseReceiver, so a direct camera driver can request its Fensalir-owned destination texture before it emits the frame descriptor and producer fence value."}
|
||||
{"ts": "2026-05-27T13:37:42+01:00", "type": "decision", "status": "ok", "note": "Camera ingest policy is now closest-to-device first. Fensalir-owned Texture2D leases remain the render-input authority, but each native camera backend must choose the most direct device path available and report unavoidable copy count. Managed wrappers, process bridges, and system-memory rings are diagnostics or fallbacks, not production hot-path owners."}
|
||||
|
|
|
|||
|
|
@ -314,6 +314,9 @@ accepted_design:
|
|||
producer fence, and commits that fence value before the resource key reaches
|
||||
shader sampling. `MimirVideoCaptureDriverSource` forwards that lease client
|
||||
to direct camera drivers that implement `IMimirFensalirTextureLeaseReceiver`.
|
||||
Camera backends must use the closest-to-device path available and report
|
||||
unavoidable copies; process or managed convenience layers are diagnostics,
|
||||
not production camera hot-path owners.
|
||||
`Mimir.BufferSmoke --fensalir-camera-observation-smoke`
|
||||
verifies the split, and `--fensalir-texture-lease-smoke` verifies the
|
||||
engine-owned lease path. Camera image claims currently defer until Fensalir
|
||||
|
|
|
|||
Loading…
Reference in a new issue