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>
67 lines
1.8 KiB
C#
67 lines
1.8 KiB
C#
using FrameLedger.Infrastructure.Telemetry;
|
|
|
|
namespace FrameLedger.Infrastructure.Tests.Telemetry;
|
|
|
|
/// <summary>A scripted <see cref="INvapiBridge"/>: what Init answers, what each read answers.</summary>
|
|
internal sealed class FakeNvapiBridge : INvapiBridge
|
|
{
|
|
public int InitResult { get; set; }
|
|
|
|
public Func<NvapiSample>? Sample { get; set; }
|
|
|
|
public Func<int, NvapiNgxWords>? Ngx { get; set; }
|
|
|
|
public uint Driver { get; set; } = 61664;
|
|
|
|
public int Inits { get; private set; }
|
|
|
|
public int Shutdowns { get; private set; }
|
|
|
|
public int Reads { get; private set; }
|
|
|
|
public bool Disposed { get; private set; }
|
|
|
|
public int Init()
|
|
{
|
|
Inits++;
|
|
return InitResult;
|
|
}
|
|
|
|
public int ReadSample(out NvapiSample sample)
|
|
{
|
|
Reads++;
|
|
sample = Sample is null ? default : Sample();
|
|
return Sample is null ? -1 : 0;
|
|
}
|
|
|
|
public int NgxState(uint pid, out NvapiNgxWords words)
|
|
{
|
|
words = Ngx is null ? new NvapiNgxWords { Status = NvapiNgxWords.Unanswered, NvapiStatus = -121 } : Ngx((int)pid);
|
|
return 0;
|
|
}
|
|
|
|
public int DriverVersion(out uint version, out string branch)
|
|
{
|
|
version = Driver;
|
|
branch = "r616_00";
|
|
return 0;
|
|
}
|
|
|
|
public void Shutdown() => Shutdowns++;
|
|
|
|
public void Dispose() => Disposed = true;
|
|
|
|
public static NvapiSample Full() => new()
|
|
{
|
|
Present = (uint)(NvapiField.TempCore | NvapiField.Load | NvapiField.CoreClock | NvapiField.MemClock | NvapiField.Fan | NvapiField.Throttle | NvapiField.PcieWidth | NvapiField.Name),
|
|
TempCoreC = 62,
|
|
LoadPct = 57,
|
|
CoreClockMhz = 2610,
|
|
MemClockMhz = 15001,
|
|
FanRpm = 1200,
|
|
ThrottleReasons = 0x2,
|
|
PcieWidth = 16,
|
|
Name = "NVIDIA GeForce RTX 5080",
|
|
};
|
|
}
|