Files
frameledger/FrameLedger.NvapiBridge.targets
T
poli0981andClaude Fable 5.1 222dd10083 feat(telemetry): the NVAPI bridge -- FrameLedger.NvapiBridge.dll, L3 NvapiTelemetrySource, and the NGX probe in-process (P2 PR-E2) (#149)
A new native target, src/native/FrameLedger.NvapiBridge/, is the C ABI the
managed side reaches NVAPI through: refcounted FlNvInit/FlNvShutdown,
FlNvReadSample into a fixed struct with a present bit per field, FlNvNgxState
for one pid, FlNvDriverVersion, and size / ABI-version / build-id queries so a
drifted mirror is refused (FL_NV_BAD_SIZE) rather than read. It is the only
shipped binary that links nvapi64.lib, read-only by construction, loaded by the
Agent into its own process by absolute path (FrameLedger.NvapiBridge.targets)
and never into a game.

Infrastructure.Telemetry: NativeNvapiBridge (the second P/Invoke facade after
the guard's, same absolute-path rule), NvapiTelemetrySource (L3: a clear bit is
null, never 0; an Init that does not answer 0 disables the layer with zero
faults; two throws disable it for the session; VRAM is not read because the
vendored nvapi.h declares no non-deprecated memory-info call, so L1's PDH
counter keeps it), and NvapiNgxStateProbe, the INgxDriverProbe in-process.
The capture host composes L1 + L2 + L3 under the composite and no longer
spawns fl-probe-nvapi.exe; the probe is no longer staged beside it.

Infrastructure.Native.BesideThisAssembly is the assembly's one DllImport
resolver. The runtime allows one per assembly and the guard's static
constructor already set it, which the first real-hardware run of the mirror
test found (TypeInitializationException: a resolver is already set). The
guard claims its name as required (absent throws); the bridge as optional
(absent is a missing layer that reports itself).

Tests: ctest fl_nvapi_bridge (every export, BRANCH: line required);
NvapiBridgeMirrorTests (both mirrors' sizes against the DLL's answers, fails
rather than skips when the DLL is not staged); NvapiTelemetrySourceTests and
NvapiNgxStateProbeTests over a scripted bridge. versioninfo-check.ps1
requires the new DLL's version block.

Measured on the dev box (RTX 5080, 616.64 r616_41), written into
18_GPU_VENDOR_APIS §L3: core 35 °C, GPU domain 0 %, 2670 / 15001 MHz,
throttle mask 0, PCIe x16; memory-temperature and fan bits clear at an idle
desktop.

Docs: 18_GPU_VENDOR_APIS (§Abstraction, §L3 built note, function table,
measured matrix), 12_BUILD (§Targets, the .targets list), 03_METRICS and
20_OPEN_QUESTIONS §H5 (probe in-process), CLAUDE.md (pinned stack, the two
facades), legal/THIRD_PARTY_NOTICES (NVAPI row), CHANGELOG.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-10 08:18:23 +07:00

41 lines
2.1 KiB
XML

<Project>
<!--
Ships FrameLedger.NvapiBridge.dll beside the importing project's output (P2 PR-E2).
The second P/Invoke facade after the guard's (docs/18_GPU_VENDOR_APIS.md §L3):
NativeNvapiBridge loads it BY ABSOLUTE PATH from AppContext.BaseDirectory and
never falls back to a search, so it has to actually be there. Read-only, and
NEVER loaded into a game — the Agent (and the unshipped capture host) load it
into their own process for the 1 Hz telemetry read and the NGX per-process word.
Imported by exactly three projects, for the same reasons the guard's is:
- FrameLedger.Agent — the host of the telemetry stack.
- FrameLedger.CaptureHost — the unshipped driver, same stack, own ledger.
- FrameLedger.Infrastructure.Tests — NvapiBridgeLayoutTests and the real-hardware
case P/Invoke into the real DLL.
Warn rather than fail when absent: build.ps1 runs the native build first, so by
the time this evaluates the DLL exists; a hard error would fail `dotnet build`
on a fresh clone for a reason that has nothing to do with the managed code.
Unlike the guard, an absent bridge is NOT a safety hole — L3 disables cleanly
and the session records `telemetry_source` without `nvapi`.
-->
<PropertyGroup>
<FlNvapiBridgeOutDir>$(MSBuildThisFileDirectory)build\native\x64-release\FrameLedger.NvapiBridge\</FlNvapiBridgeOutDir>
</PropertyGroup>
<ItemGroup>
<None Include="$(FlNvapiBridgeOutDir)FrameLedger.NvapiBridge.dll" Condition="Exists('$(FlNvapiBridgeOutDir)FrameLedger.NvapiBridge.dll')">
<Link>FrameLedger.NvapiBridge.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="FlWarnOnMissingNvapiBridge" AfterTargets="Build"
Condition="!Exists('$(FlNvapiBridgeOutDir)FrameLedger.NvapiBridge.dll')">
<Warning Text="FrameLedger.NvapiBridge.dll was not found at $(FlNvapiBridgeOutDir). Run build.ps1 native first; L3 telemetry will report itself unavailable." />
</Target>
</Project>