Compare commits

...
Author SHA1 Message Date
poli0981andClaude Fable 5.1 80755048d9 feat(capturehost): the super-resolution identity from the NVIDIA driver where no hook can see it -- the driver-reported rung
Owner decision 2026-09-06 ("noi probe de bat dau"). Three NGX-direct titles printed
`upscaler: N/A` on every capture while the driver's per-process NGX word
(NvAPI_NGX_GetNGXOverrideState) reads CREATED | EVALUATE for them without an override.

- fl-probe-nvapi --ngx-state prints one machine line (NGXSTATE status=... sr=0x... ...)
  after its human output; the capture host stages the probe beside itself.
- NgxDriverProbe spawns it beside every module snapshot (out of process, no injection);
  NgxDriverState parses and merges the readings (last answered word is the state, a
  change between readings is printed, an earlier answer outranks a later silence).
- The report prints `NVIDIA driver NGX state:` in the runtime block; the `upscaler:` line
  reads `Dlss (driver-reported: ... not counted by this hook)` when no hook named one,
  prints agreement or a disagreement (printed, not resolved) beside a hook's Dlss, and
  the driver's attributed negative beside an N/A.
- Identity only, each limit measured: no quality/preset (override fields), no ratio
  (scalingRatio 0 even under an override), no FG mode/multiplier (the FG word is blind
  to Streamline DLSS-G).
- §H5 pre-commits rows N1-N4; N3 (DLSS OFF) withdraws the rung if the bit stays set.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-06 10:16:40 +07:00
21 changed files with 814 additions and 11 deletions

No files matched your search

+17
View File
@@ -17,6 +17,23 @@ GitHub release body, so a missing section will mean an empty release note.
## [Unreleased]
### Added
- **The super-resolution identity from the NVIDIA driver, where no hook can see it — the driver-reported
rung (owner decision 2026-09-06).** Three NGX-direct titles printed `upscaler: N/A` on every capture
while the driver's per-process NGX word (`NvAPI_NGX_GetNGXOverrideState`, R570+, MIT NVAPI) reads
`CREATED | EVALUATE` for them — measured 2026-09-06 without an NVIDIA-app override. The capture host now
spawns `fl-probe-nvapi --ngx-state <pid>` beside every module snapshot (the probe gained one machine line,
`NGXSTATE status=… sr=0x… …`, and is staged beside the host), merges the readings (`NgxDriverState`: the
last answered word is the state, a change between readings is printed), prints `NVIDIA driver NGX state:`
in the runtime block, and the `upscaler:` line reads `Dlss (driver-reported: … not counted by this hook)`
when no hook named one. Identity only, each limit measured: no quality or preset (override fields), no
ratio (`scalingRatio` is 0 even under an override), no frame-generation mode or multiplier (the FG word is
blind to Streamline DLSS-G). Beside a hook's `Dlss` the driver's word prints as agreement or as a
disagreement printed rather than resolved; beside an `N/A` with the bit clear it prints the driver's
negative. `20_OPEN_QUESTIONS` §H5 pre-commits rows N1–N4, and N3 — DLSS switched off — withdraws the rung
if the bit stays set. `03_METRICS` §Upscaling, `05_DETECTION`, `18_GPU_VENDOR_APIS` carry it.
### Changed
- **The withheld `none` is narrowed to sessions where DXGI's counter was not read (§H5 Leg 0 landed).**
+27
View File
@@ -467,6 +467,33 @@ From the upscaler hooks we get, per frame:
Tier 2 has none of this: `upscaler = unknown`, ratio `N/A`.
> ### The driver-reported rung — owner decision 2026-09-06, identity only
>
> Three NGX-direct titles (Lies of P, Hell Is Us, Expedition 33) evaluate DLSS super resolution through
> a path no hook of this build sees, and printed `upscaler: N/A` on every capture. The NVIDIA driver
> keeps per-process bookkeeping of the feature — `NvAPI_NGX_GetNGXOverrideState` (R570+, MIT NVAPI,
> `18_GPU_VENDOR_APIS` L3) returns a feedback word per feature — and **measured 2026-09-06 (driver
> 616.64) its `CREATED | EVALUATE` bits are set for a process with NO NVIDIA-app override** on both
> no-override titles (`20_OPEN_QUESTIONS` §H5). So the capture host probes it out of process beside
> each module snapshot (`fl-probe-nvapi --ngx-state <pid>`, no injection, no consent), and the
> `upscaler:` line has a rung between the hooks and `N/A`:
>
> ```
> upscaler: Dlss (driver-reported: the NVIDIA driver reports an NGX super-resolution feature created
> and evaluated in this process - not counted by this hook)
> ```
>
> **What it may claim: the vendor and the feature, attributed to the driver.** What it may NOT claim,
> each one measured: a quality (`performanceMode` / `renderPreset` are populated only under an
> NVIDIA-app override and are then the OVERRIDE's values), a ratio or render size (`scalingRatio` is
> 0 even under the override), a frame-generation mode or multiplier (the FG word read
> `INITIALIZED | DLL_EXISTS` beside a ×4 DLSS-G session, and `frameGenerationCount` is the override
> target). Frame generation stays with the tags and the count. A hook's name always outranks it, and
> beside a hook's name the driver's word is printed as agreement, or as a disagreement *printed rather
> than resolved*. Beside an `N/A` with the bit clear it prints the driver's negative, attributed, which
> says nothing about FSR or XeSS. **The negative is owed** (§H5): a title with DLSS switched off should
> read the bit clear; if it does not, the rung is withdrawn.
## RT / PT / RR — evidence-based tri-state
Tri-state `Yes | No | N/A` per session with `source` (`measured | manual | inherited`).
+1 -1
View File
@@ -18,7 +18,7 @@ Derived in the Agent from the record stream; the mapping is in `03_METRICS`. Sum
| Graphics API + swapchain format, buffer count, swap effect, flags | `CreateSwapChain*` / present hooks |
| Present mode (flip / blt / independent flip) | swapchain desc + `presentFlags` + `syncInterval` |
| HDR output | `SetColorSpace1` |
| Upscaler identity + quality preset | NGX / Streamline / FFX / XeSS create+evaluate calls |
| Upscaler identity + quality preset | NGX / Streamline / FFX / XeSS create+evaluate calls — **or, when no hook saw one, the NVIDIA driver's per-process NGX word, out of process and attributed (`03_METRICS` §Upscaling, the driver-reported rung, 2026-09-06): identity only, never the preset** |
| Render resolution vs output resolution (incl. mid-session changes) | upscaler parameter reads + `ResizeBuffers` |
| Frame Generation mode + factor | NGX/SL/FFX FG feature evaluation, then cadence — **Tier 1 only**. ~~then (Tier 2 only) PresentMon `FrameType`~~ retired (§S31 row P2), and Tier 2 no longer produces frames to run cadence over either |
| Ray Tracing active | AS builds + `DispatchRays` (both, to catch inline RayQuery) |
+1
View File
@@ -105,6 +105,7 @@ Still resolve **entry points defensively at runtime**: `nvapi64.dll` may be abse
| Memory | `NvAPI_GPU_GetMemoryInfoEx` — **not `NvAPI_GPU_GetMemoryInfo`**, which this table named until 2026-08-05. The vendored headers mark it `__nvapi_deprecated_function` ("deprecated in release 520"), so under `/W4 /WX` a call to it fails the native build |
| **Throttle reasons** | `NvAPI_GPU_GetPerfDecreaseInfo` — not available from L1 or L2 |
| Driver version | `NvAPI_SYS_GetDriverAndBranchVersion` |
| **NGX per-process state** | `NvAPI_NGX_GetNGXOverrideState` (R570+) — the driver's feedback word per DLSS feature for a PID, read OUT OF PROCESS by `fl-probe-nvapi --ngx-state` and, since 2026-09-06, by the capture host beside each module snapshot. Measured: the SR word's `CREATED \| EVALUATE` is set without an NVIDIA-app override; the FG word is blind to Streamline DLSS-G; `scalingRatio` is 0 even under an override. Identity only (`03_METRICS` §Upscaling) |
| **Reflex / PC latency** | `NvAPI_D3D_GetLatency` → per-frame sim/render/present/driver/GPU timestamps; hooking `NvAPI_D3D_SetSleepMode` / `SetLatencyMarker` in the Overlay tells us the game enabled Reflex (`17_HOOK_ENGINE`) |
Reflex latency is the single strongest reason L3 exists — it is genuinely unavailable anywhere else.
+17
View File
@@ -3277,6 +3277,23 @@ probe never showed a deadlock.
> beside each module snapshot (out of process, no consent needed) or, if it goes in-process, through
> `Infrastructure` only (CLAUDE.md: no P/Invoke elsewhere).
>
> **BUILT 2026-09-06, on the owner's decision ("nối probe để bắt đầu").** The capture host spawns
> `fl-probe-nvapi --ngx-state <pid>` beside every module snapshot (the probe prints one machine line,
> `NGXSTATE status=… sr=0x… …`, and is staged beside the host by the project file), merges the readings
> (the last answered word is the state; a change between readings is printed, never averaged) and
> prints `NVIDIA driver NGX state:` in the runtime block. `03_METRICS` §Upscaling carries the rung and
> its limits. **Pre-committed, read off the next run:**
>
> | Row | Title / setting | Expected | Else |
> |---|---|---|---|
> | **N1** | Lies of P, Hell Is Us, Expedition 33 at DLSS | `upscaler: Dlss (driver-reported: …)` | a `CREATED \| EVALUATE` word beside `N/A` is a parser or plumbing defect — localise |
> | **N2** | Cyberpunk, DL:TB, Onimusha (hooked `Dlss`) | `upscaler: Dlss — the NVIDIA driver agrees …` | a disagreement WARNING is printed as such; it is not resolved by preferring either |
> | **N3** | **the negative, still owed:** Lies of P with DLSS switched OFF in the menu | `CREATED` clear → `upscaler: N/A (…) — the NVIDIA driver reports no NGX super-resolution feature created …` | `CREATED \| EVALUATE` still set with DLSS off → **the rung is withdrawn** (the bit is a session-lifetime latch, not a state) and the line goes back to N/A |
> | **N4** | a title at FSR / XeSS with no NGX feature | `Fsr3` / `N/A` with the driver's negative beside it | `CREATED` set on a title with no DLSS in its menu → withdraw |
>
> Lies of P has no DLSS Frame Generation (owner, 2026-09-06), which is why its FG word reads
> `ERR_FAILED ERR_NOT_FOUND`: nothing to load.
>
> ### THE STREAMLINE DOCS, READ 2026-09-05 (v2.8.0 and main), AND WHAT THEY CHANGED
>
> The owner asked for the vendor's own guides before any rewrite. Three things in them decide this item.
+5 -2
View File
@@ -763,10 +763,13 @@ Cyberpunk 2077 never chains `sl::DLSSOptions`, so 0xFF there is the title's trut
gap the tags cannot close.~~ **RAN 2026-09-06 on Hell Is Us, Expedition 33 and Lies of P (§H5, `spike-notes`
§9): `CREATED | EVALUATE` on the SR word without an override on both no-override titles — the identity
exists in the driver's bookkeeping; the FG word does not see DLSS-G at ×4; `frameGenerationCount` is the
override target, `scalingRatio` is 0 even under an override.** **START HERE next: the owner decides the
override target, `scalingRatio` is 0 even under an override.** ~~**START HERE next: the owner decides the
driver-reported rung (§H5 says exactly what it may claim: `Dlss (driver-reported …)` on a session where
every hook says N/A, nothing about quality, ratio or FG), and the negative is owed first — the probe on
Lies of P with DLSS switched OFF, expected `CREATED` clear.** **The tag route LANDED on the owner's evening run (`spike-notes` §9): `DlssG` on
Lies of P with DLSS switched OFF, expected `CREATED` clear.**~~ **Decided and BUILT 2026-09-06: the capture
host probes the driver beside every module snapshot and the `upscaler:` line has the driver-reported rung
(`03_METRICS` §Upscaling). START HERE next: the owner's run — §H5 rows N1–N4, and N3 (Lies of P with DLSS
OFF) is the one that keeps or withdraws the rung.** **The tag route LANDED on the owner's evening run (`spike-notes` §9): `DlssG` on
six of six Streamline titles, and DL:TB's census shows its scaling-input tag arrives with no size, which
closes 7a's last question.** If the driver's per-process NGX feedback is
populated without an NVIDIA-app override, the identity question has a producer that is not a
@@ -30,7 +30,8 @@ internal sealed class CaptureLoop(
Func<int, ITargetLiveness?> liveness,
Func<int, (ICaptureSink? Sink, ShmAttachRefusal Refusal)> attach,
CaptureOptions options,
Func<int, RuntimeModuleSet>? modules = null)
Func<int, RuntimeModuleSet>? modules = null,
Func<int, NgxDriverState>? ngx = null)
{
/// <summary>Start one session, or say why not.</summary>
/// <remarks>
@@ -160,13 +161,14 @@ internal sealed class CaptureLoop(
var records = new List<FlFrameRecord>();
var gaps = new List<ulong>();
var focus = new FocusTally();
var loaded = new ModuleTally(modules);
var loaded = new ModuleTally(modules, ngx);
SessionEndReason end = await SuperviseAsync(pid, alive, sink, supervisor, records, gaps, focus, loaded, ct)
.ConfigureAwait(false);
return new CaptureResult
{
RuntimeModules = loaded.Set,
NgxDriver = loaded.Ngx,
TouchQpc = loaded.TouchQpc,
Reason = end,
Verdict = verdict,
@@ -297,11 +299,17 @@ internal sealed class CaptureLoop(
return mayContinue;
}
/// <summary>Accumulates module snapshots; a loop built without a source takes none.</summary>
private sealed class ModuleTally(Func<int, RuntimeModuleSet>? source)
/// <summary>
/// Accumulates module snapshots and the driver's NGX word; a loop built without a source takes none.
/// The NGX probe rides on the same touch as the snapshot: out of process, and the moment a title that
/// enabled DLSS from its menu is caught by the next scan, exactly as a late-loading module is.
/// </summary>
private sealed class ModuleTally(Func<int, RuntimeModuleSet>? source, Func<int, NgxDriverState>? ngxSource)
{
public RuntimeModuleSet Set { get; private set; } = RuntimeModuleSet.Empty;
public NgxDriverState Ngx { get; private set; } = NgxDriverState.NotRun;
/// <summary>
/// When this host touched the target — a guard scan just completed, and the module snapshot
/// is about to run — as QPC ticks (<see cref="System.Diagnostics.Stopwatch.GetTimestamp"/> is
@@ -317,6 +325,11 @@ internal sealed class CaptureLoop(
{
Set = Set.Merge(source(pid));
}
if (ngxSource is not null)
{
Ngx = Ngx.Merge(ngxSource(pid));
}
}
}
@@ -53,6 +53,12 @@ internal sealed record CaptureResult
/// </summary>
public RuntimeModuleSet RuntimeModules { get; init; } = RuntimeModuleSet.Empty;
/// <summary>
/// The NVIDIA driver's per-process NGX word, probed out of process beside each module snapshot and merged.
/// <see cref="NgxDriverState.NotRun"/> when the loop had no probe.
/// </summary>
public NgxDriverState NgxDriver { get; init; } = NgxDriverState.NotRun;
/// <summary>
/// QPC timestamps of every moment this host touched the target's process — a guard scan
/// completing, followed by the module snapshot — in the records' own clock, so a stall in the
@@ -0,0 +1,66 @@
using System.ComponentModel;
using System.Diagnostics;
using FrameLedger.CaptureHost.Consume;
namespace FrameLedger.CaptureHost.Capture;
/// <summary>
/// Runs <c>fl-probe-nvapi --ngx-state &lt;pid&gt;</c> beside this host and parses its machine line.
/// </summary>
/// <remarks>
/// <para>
/// <b>Out of process, on purpose.</b> The probe links <c>nvapi64.lib</c> (MIT, vendored) and asks the driver about
/// a pid; nothing is injected, nothing in the target is touched, no consent is involved. Spawning the tool this
/// repo already builds keeps the native layer reachable only through what is already there (CLAUDE.md: no
/// P/Invoke outside <c>Infrastructure</c>) — the day the shipped Agent wants this fact, it goes through
/// <c>Infrastructure</c> as a native call, not through a child process.
/// </para>
/// <para>
/// The probe is staged beside the host by the project file the way the Overlay payload is; a missing binary is
/// an outcome the report prints, never an exception the loop sees.
/// </para>
/// </remarks>
internal static class NgxDriverProbe
{
private const string _probeFileName = "fl-probe-nvapi.exe";
private static readonly TimeSpan _budget = TimeSpan.FromSeconds(5);
public static string ProbePath => Path.Combine(AppContext.BaseDirectory, _probeFileName);
public static NgxDriverState Run(int pid) => Run(pid, ProbePath);
public static NgxDriverState Run(int pid, string probePath)
{
if (!File.Exists(probePath))
{
return NgxDriverState.Of(NgxProbeOutcome.ProbeMissing, probePath);
}
try
{
using var probe = new Process();
probe.StartInfo = new ProcessStartInfo(probePath)
{
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true,
};
probe.StartInfo.ArgumentList.Add("--ngx-state");
probe.StartInfo.ArgumentList.Add(pid.ToString(System.Globalization.CultureInfo.InvariantCulture));
probe.Start();
string output = probe.StandardOutput.ReadToEnd();
if (!probe.WaitForExit((int)_budget.TotalMilliseconds))
{
probe.Kill();
return NgxDriverState.Of(NgxProbeOutcome.ProbeFailed, "the probe did not exit within " + _budget.TotalSeconds + " s");
}
return NgxDriverState.Parse(output);
}
catch (Exception e) when (e is Win32Exception or InvalidOperationException or IOException)
{
return NgxDriverState.Of(NgxProbeOutcome.ProbeFailed, e.Message);
}
}
}
@@ -190,6 +190,65 @@ internal sealed record MeasuredFacts
/// </remarks>
public bool UpscalerHookRan { get; init; }
/// <summary>The driver's per-process NGX word, merged over the session; <see cref="NgxDriverState.NotRun"/> without a probe.</summary>
public NgxDriverState NgxDriver { get; init; } = NgxDriverState.NotRun;
/// <summary>The string the <c>upscaler:</c> line carries when the identity is the driver's word and not a hook's.</summary>
public const string UpscalerDlssDriverReported =
"Dlss (driver-reported: the NVIDIA driver reports an NGX super-resolution feature created and evaluated in "
+ "this process - not counted by this hook; 03_METRICS §Upscaling, the driver-reported rung)";
/// <summary>
/// <c>03_METRICS</c> §Upscaling, the driver-reported rung (owner decision 2026-09-06): when NO hook named an
/// upscaler and the driver says an NGX super-resolution feature was created and evaluated in this process,
/// the identity is DLSS, attributed to the driver. Null whenever a hook answered, or the driver did not.
/// </summary>
/// <remarks>
/// Identity and nothing else. Measured 2026-09-06 on Hell Is Us, Expedition 33 and Lies of P: the bits are
/// set without an NVIDIA-app override; <c>scalingRatio</c> is 0 even with one; <c>performanceMode</c> and
/// <c>renderPreset</c> are the override's values; the FG word is blind to Streamline DLSS-G. So this may name
/// the vendor and the feature and may not state a quality, a ratio, a render size or a frame-generation mode.
/// The negative is owed: a title with DLSS switched off should read the bit clear, and until it is measured
/// this rung has only ever seen the positive — §H5 pre-commits its withdrawal if the bit stays set.
/// </remarks>
public string? UpscalerDriverReported => Upscaler is null && NgxDriver.SrCreatedAndEvaluated ? UpscalerDlssDriverReported : null;
/// <summary>
/// What the driver's word adds beside a hook's identity — agreement, a disagreement printed rather than
/// resolved, or the driver's negative beside an N/A — or null when the driver did not answer.
/// </summary>
public string? UpscalerDriverNote
{
get
{
if (NgxDriver.Outcome != NgxProbeOutcome.Answered)
{
return null;
}
bool created = NgxDriver.SrCreatedAndEvaluated;
if (Upscaler is null)
{
return created
? null
: "the NVIDIA driver reports no NGX super-resolution feature created in this process (driver-reported; "
+ "it says nothing about FSR or XeSS)";
}
if (string.Equals(Upscaler, nameof(FlUpscaler.Dlss), StringComparison.Ordinal))
{
return created
? "the NVIDIA driver agrees: an NGX super-resolution feature was created and evaluated in this process"
: "WARNING: the NVIDIA driver reports NO NGX super-resolution feature created in this process while the "
+ "hook named DLSS - a disagreement, printed rather than resolved";
}
return created
? "the NVIDIA driver also reports an NGX super-resolution feature created and evaluated in this process"
: null;
}
}
/// <summary>Whether a hook capable of naming the frame-generation mode was live.</summary>
public bool FgHookRan { get; init; }
@@ -272,7 +331,8 @@ internal sealed record MeasuredFacts
/// overstates the factor. <see cref="FgWindow"/> owns that decision and its refusals.
/// </remarks>
public static MeasuredFacts From(IReadOnlyList<FlFrameRecord> stream, FlWriterState writer,
long qpcFrequency, long totalGaps, long totalDropped, FgWindow? fg = null, RuntimeModuleSet? modules = null)
long qpcFrequency, long totalGaps, long totalDropped, FgWindow? fg = null, RuntimeModuleSet? modules = null,
NgxDriverState? ngx = null)
{
ArgumentNullException.ThrowIfNull(stream);
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(qpcFrequency);
@@ -313,6 +373,7 @@ internal sealed record MeasuredFacts
Extent = UpscaleExtent.From(stream),
Upscaler = UpscalerOf(stream),
NgxDriver = ngx ?? NgxDriverState.NotRun,
RayTracing = RayTracingOf(stream, writer),
RayReconstruction = RayReconstructionOf(stream),
Hdr = HdrOf(stream),
@@ -0,0 +1,160 @@
using System.Globalization;
namespace FrameLedger.CaptureHost.Consume;
/// <summary>
/// The NVIDIA driver's own per-process NGX bookkeeping — <c>NvAPI_NGX_GetNGXOverrideState</c>, read out of
/// process by <c>fl-probe-nvapi --ngx-state</c> beside each module snapshot — merged over a session.
/// </summary>
/// <remarks>
/// <para>
/// <b>A driver-reported fact, and the report says so wherever it uses one.</b> It is neither a hooked argument
/// (CLAUDE.md rule 4) nor a static hint (<c>05_DETECTION</c>): the driver says a feature was created and
/// evaluated in this process, and this host repeats that with the attribution. What it may stand in for is
/// the super-resolution IDENTITY on a session where no hook saw an evaluation (<c>03_METRICS</c> §Upscaling,
/// the driver-reported rung, owner decision 2026-09-06). What it may not stand in for: a quality, a ratio, a
/// render size, a frame-generation mode or a multiplier — measured 2026-09-06 to be override fields or blind.
/// </para>
/// <para>
/// The last ANSWERED reading is the state; <see cref="Readings"/> counts probe runs, <see cref="Answered"/> the
/// ones the driver answered, and <see cref="Changed"/> whether two answered readings disagreed on a mask — a
/// title switching DLSS on mid-session would show as a change, and the report prints it rather than averaging.
/// </para>
/// </remarks>
internal sealed record NgxDriverState(
NgxProbeOutcome Outcome,
ulong Sr,
ulong Rr,
ulong Fg,
double ScalingRatio,
uint PerformanceMode,
uint RenderPreset,
uint FgCount,
uint FgPreset,
uint FgMode,
uint Driver,
int Readings,
int Answered,
bool Changed,
string? Detail)
{
/// <summary>The loop was built without a probe.</summary>
public static readonly NgxDriverState NotRun = new(NgxProbeOutcome.NotRun, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, null);
/// <summary>The one reading this host acts on: the driver says an NGX super-resolution feature ran here.</summary>
public bool SrCreatedAndEvaluated =>
Outcome == NgxProbeOutcome.Answered && (Sr & NgxOverrideFlags.CreatedAndEvaluated) == NgxOverrideFlags.CreatedAndEvaluated;
/// <summary>One outcome with no masks — a probe that did not answer, and why.</summary>
public static NgxDriverState Of(NgxProbeOutcome outcome, string? detail) =>
NotRun with { Outcome = outcome, Readings = 1, Detail = detail };
/// <summary>
/// The machine line the probe prints (<c>NGXSTATE status=… sr=0x… …</c>), or a <see cref="NgxProbeOutcome.ProbeFailed"/>
/// when nothing in <paramref name="output"/> is one. Every other line of the probe's output is for a human.
/// </summary>
public static NgxDriverState Parse(string output)
{
ArgumentNullException.ThrowIfNull(output);
foreach (string raw in output.Split('\n'))
{
string line = raw.Trim();
if (!line.StartsWith("NGXSTATE ", StringComparison.Ordinal))
{
continue;
}
Dictionary<string, string> kv = new(StringComparer.Ordinal);
foreach (string token in line.Split(' ', StringSplitOptions.RemoveEmptyEntries).Skip(1))
{
int eq = token.IndexOf('=', StringComparison.Ordinal);
if (eq > 0)
{
kv[token[..eq]] = token[(eq + 1)..];
}
}
return FromFields(kv, line);
}
return Of(NgxProbeOutcome.ProbeFailed, "the probe printed no NGXSTATE line");
}
private static NgxDriverState FromFields(Dictionary<string, string> kv, string line)
{
string status = kv.GetValueOrDefault("status", "");
if (string.Equals(status, "ANSWERED", StringComparison.Ordinal))
{
try
{
return new NgxDriverState(NgxProbeOutcome.Answered, Hex(kv["sr"]), Hex(kv["rr"]), Hex(kv["fg"]),
double.Parse(kv["ratio"], CultureInfo.InvariantCulture), U(kv["mode"]), U(kv["preset"]),
U(kv["fgcount"]), U(kv["fgpreset"]), U(kv["fgmode"]), U(kv["driver"]), 1, 1, false, null);
}
catch (Exception e) when (e is KeyNotFoundException or FormatException or OverflowException)
{
return Of(NgxProbeOutcome.ProbeFailed, "an NGXSTATE line this host could not read: " + line);
}
}
return status switch
{
"UNANSWERED" => Of(NgxProbeOutcome.Unanswered, "NvAPI " + kv.GetValueOrDefault("nvapi", "?")),
"DEGRADED" => Of(NgxProbeOutcome.Degraded, "NvAPI_Initialize " + kv.GetValueOrDefault("nvapi", "?")),
_ => Of(NgxProbeOutcome.ProbeFailed, "an NGXSTATE status this host does not know: " + status),
};
}
private static ulong Hex(string v) =>
ulong.Parse(v.StartsWith("0x", StringComparison.OrdinalIgnoreCase) ? v[2..] : v, NumberStyles.HexNumber,
CultureInfo.InvariantCulture);
private static uint U(string v) => uint.Parse(v, CultureInfo.InvariantCulture);
/// <summary>Fold a later reading in: an answered one becomes the state, any one counts.</summary>
public NgxDriverState Merge(NgxDriverState later)
{
ArgumentNullException.ThrowIfNull(later);
if (Outcome == NgxProbeOutcome.NotRun)
{
return later;
}
int readings = Readings + later.Readings;
int answered = Answered + later.Answered;
if (later.Outcome != NgxProbeOutcome.Answered)
{
// An earlier answer outranks a later silence: the driver's words do not expire, and a
// probe that failed once mid-session says nothing about what it had already read.
return Outcome == NgxProbeOutcome.Answered
? this with { Readings = readings }
: later with { Readings = readings, Answered = answered };
}
bool changed = Changed || (Outcome == NgxProbeOutcome.Answered && (Sr != later.Sr || Rr != later.Rr || Fg != later.Fg));
return later with { Readings = readings, Answered = answered, Changed = changed };
}
/// <summary>The report's line: the three words decoded, the override fields named as such, the caveats measured.</summary>
public string Describe()
{
string head = " NVIDIA driver NGX state (NvAPI_NGX_GetNGXOverrideState, out of process): ";
return Outcome switch
{
NgxProbeOutcome.NotRun => head + "not probed",
NgxProbeOutcome.ProbeMissing => head + "probe not found - " + Detail,
NgxProbeOutcome.ProbeFailed => head + "probe failed - " + Detail,
NgxProbeOutcome.Degraded => head + "no usable NVIDIA driver on this machine (" + Detail + ")",
NgxProbeOutcome.Unanswered => head + $"the driver did not answer for this process over {Readings} probe(s) ({Detail}) - "
+ "not an NVIDIA-rendered process, a driver older than R570, or the API refusing the caller",
_ => head + $"answered {Answered} of {Readings} probe(s){(Changed ? ", and the words CHANGED between readings" : "")}"
+ $"; driver {Driver / 100}.{Driver % 100:00}\n"
+ $" SR 0x{Sr:X} [{NgxOverrideFlags.Describe(Sr)}] RR 0x{Rr:X} [{NgxOverrideFlags.Describe(Rr)}] "
+ $"FG 0x{Fg:X} [{NgxOverrideFlags.Describe(Fg)}]\n"
+ $" override fields: scalingRatio={ScalingRatio.ToString("0.0000", CultureInfo.InvariantCulture)} "
+ $"performanceMode={PerformanceMode} renderPreset={RenderPreset} fgCount={FgCount} fgPreset={FgPreset} fgMode={FgMode} "
+ "- the OVERRIDE's values when an NVIDIA-app override is set, zero otherwise (measured 2026-09-06); "
+ "the FG word does not reflect Streamline DLSS-G (INITIALIZED DLL_EXISTS beside a x4 session) - frame generation stays with the tags and the count",
};
}
}
@@ -0,0 +1,76 @@
namespace FrameLedger.CaptureHost.Consume;
/// <summary>
/// The bits of <c>NV_NGX_DLSS_OVERRIDE_BITFIELD</c> (vendored <c>nvapi.h</c>, R570+), as the driver reports them per
/// process through <c>NvAPI_NGX_GetNGXOverrideState</c>. Constants rather than a <c>[Flags]</c> enum because the
/// masks are 64-bit words the probe prints raw, and a word is what the parser keeps.
/// </summary>
/// <remarks>
/// <b>Measured 2026-09-06 (driver 616.64, <c>20_OPEN_QUESTIONS</c> §H5):</b> <see cref="Created"/> and
/// <see cref="Evaluate"/> on the super-resolution word are set for a process with NO NVIDIA-app override
/// (Hell Is Us, Lies of P). The frame-generation word does NOT reflect Streamline DLSS-G — it read
/// <see cref="Initialized"/> | <see cref="DllExists"/> beside a ×4 session — and <c>frameGenerationCount</c> is the
/// override target, not the title's multiplier. So the word this host reads is SR, for identity, and nothing else.
/// </remarks>
internal static class NgxOverrideFlags
{
public const ulong Initialized = 1UL << 0;
public const ulong Enabled = 1UL << 1;
public const ulong DllExists = 1UL << 2;
public const ulong DllLoaded = 1UL << 3;
public const ulong DllSelected = 1UL << 4;
public const ulong Preset = 1UL << 5;
public const ulong PerfMode = 1UL << 6;
public const ulong ScalingRatio = 1UL << 7;
public const ulong OptimalSettings = 1UL << 8;
public const ulong Created = 1UL << 9;
public const ulong Evaluate = 1UL << 10;
public const ulong FgMode = 1UL << 13;
public const ulong SrDlaaMode = 1UL << 14;
public const ulong FgMultiFrame = 1UL << 15;
public const ulong ErrFailed = 1UL << 16;
public const ulong ErrDenied = 1UL << 17;
public const ulong ErrDrs = 1UL << 18;
public const ulong ErrNotFound = 1UL << 19;
public const ulong ErrDllLoad = 1UL << 20;
/// <summary>The two bits that together say "this feature ran in this process": created, and evaluated.</summary>
public const ulong CreatedAndEvaluated = Created | Evaluate;
private static readonly (ulong Bit, string Name)[] _names =
[
(Initialized, "INITIALIZED"), (Enabled, "ENABLED"), (DllExists, "DLL_EXISTS"), (DllLoaded, "DLL_LOADED"),
(DllSelected, "DLL_SELECTED"), (Preset, "PRESET"), (PerfMode, "PERF_MODE"), (ScalingRatio, "SCALING_RATIO"),
(OptimalSettings, "OPTIMAL_SETTINGS"), (Created, "CREATED"), (Evaluate, "EVALUATE"), (FgMode, "FG_MODE"),
(SrDlaaMode, "SR_DLAA_MODE"), (FgMultiFrame, "FG_MULTI_FRAME"), (ErrFailed, "ERR_FAILED"),
(ErrDenied, "ERR_DENIED"), (ErrDrs, "ERR_DRS"), (ErrNotFound, "ERR_NOT_FOUND"), (ErrDllLoad, "ERR_DLL_LOAD"),
];
/// <summary>The probe's own spelling of a word's bits, unknown bits printed as hex so nothing is dropped.</summary>
public static string Describe(ulong mask)
{
if (mask == 0)
{
return "-";
}
List<string> parts = [];
ulong seen = 0;
foreach ((ulong bit, string name) in _names)
{
if ((mask & bit) != 0)
{
parts.Add(name);
seen |= bit;
}
}
ulong unknown = mask & ~seen;
if (unknown != 0)
{
parts.Add("0x" + unknown.ToString("X", System.Globalization.CultureInfo.InvariantCulture));
}
return string.Join(' ', parts);
}
}
@@ -0,0 +1,23 @@
namespace FrameLedger.CaptureHost.Consume;
/// <summary>What one run of <c>fl-probe-nvapi --ngx-state</c> came back with.</summary>
internal enum NgxProbeOutcome
{
/// <summary>The loop was built without a probe, or the probe never ran.</summary>
NotRun,
/// <summary>The driver answered for this pid; the masks are the driver's.</summary>
Answered,
/// <summary>NvAPI answered but not for this pid: not NVIDIA-rendered, an old driver, or the API refusing the caller.</summary>
Unanswered,
/// <summary>No usable NVIDIA driver on this machine.</summary>
Degraded,
/// <summary>The probe binary was not beside this host.</summary>
ProbeMissing,
/// <summary>The probe could not be started, timed out, or printed nothing this host understands.</summary>
ProbeFailed,
}
@@ -205,13 +205,22 @@ internal static class SessionReport
// can tell that apart from a title driving DLSS through a path we do not hook — Black Myth:
// Wukong loads sl.interposer.dll, runs DLSS-G, and calls it never — so the line names all
// three rather than picking the one that flatters the hook.
sb.Append(" upscaler: ").AppendLine(facts.Upscaler
// A hook's name first; else the driver's word, attributed (03_METRICS §Upscaling, the
// driver-reported rung); else the two N/As. The driver's note rides beside whichever printed.
sb.Append(" upscaler: ").Append(facts.Upscaler
?? facts.UpscalerDriverReported
?? (facts.UpscalerHookRan
? "N/A (an upscaler hook ran — Streamline's slEvaluateFeature and/or an ffx-api leaf's ffxDispatch — "
+ "and no evaluation this build decodes arrived: "
+ "upscaling is off in this title's settings, or it runs through a path this build does not "
+ "hook — measured on 3 of 5 Streamline titles — or a vendor this build does not decode)"
: NoHookRan("upscaler", facts.CensusRan, facts.UpscalerRuntimesLoaded)));
if (facts.UpscalerDriverNote is string driver)
{
sb.Append(" — ").Append(driver);
}
sb.AppendLine();
sb.Append(" render -> output: ").AppendLine(RenderToOutput(facts.Extent));
sb.Append(" frame generation: ").AppendLine(facts.FgMode
?? (facts.FgHookRan
@@ -83,4 +83,21 @@
<Import Project="$(MSBuildThisFileDirectory)..\..\FrameLedger.Rules.targets" />
<Import Project="$(MSBuildThisFileDirectory)..\..\FrameLedger.Overlay.targets" />
<!--
fl-probe-nvapi.exe beside the host, the way the Overlay is: NgxDriverProbe spawns it
by absolute path from AppContext.BaseDirectory and reports ProbeMissing rather than
searching. Warn-not-fail for the same reason the Overlay targets do: build.ps1 runs
the native build first. UNSHIPPED with this host; the Agent would call NVAPI through
Infrastructure, not a child process.
-->
<PropertyGroup>
<FlNativeProbeDir>$(MSBuildThisFileDirectory)..\..\build\native\x64-release\tools\fl-probe-nvapi\</FlNativeProbeDir>
</PropertyGroup>
<ItemGroup>
<None Include="$(FlNativeProbeDir)fl-probe-nvapi.exe" Condition="Exists('$(FlNativeProbeDir)fl-probe-nvapi.exe')">
<Link>fl-probe-nvapi.exe</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
+6 -2
View File
@@ -185,7 +185,7 @@ internal static class Program
FgWindow fg = FgWindow.From(result.Records, Stopwatch.Frequency);
MeasuredFacts facts = MeasuredFacts.From(
dominant, result.WriterState, Stopwatch.Frequency, result.TotalGaps, result.TotalDropped, fg,
result.RuntimeModules);
result.RuntimeModules, result.NgxDriver);
HostConsole.Line($" guard ticks published: {result.GuardTicksPublished}");
HostConsole.Line($" records: {result.Records.Count} ({dominant.Count} on the dominant stream), " +
@@ -246,6 +246,9 @@ internal static class Program
$"fg=[{CensusNames.Describe(census & FlRuntimeCensusFamilies.Fg)}] " +
$"upscaler=[{CensusNames.Describe(census & FlRuntimeCensusFamilies.Upscaler)}]");
PrintRuntimeModules(result.RuntimeModules);
// The driver's own word on this process, out of process: the super-resolution identity the
// hooks cannot see on NGX-direct titles (03_METRICS §Upscaling, the driver-reported rung).
HostConsole.Line(result.NgxDriver.Describe());
// Which Streamline buffer types the title tagged, on which route: the identity half of
// frame generation (fl_shm.h §slTagCensus). A DLSS-G title tags hudless and UI every
// frame; a super-resolution-only title tags neither.
@@ -328,7 +331,8 @@ internal static class Program
// already honoured MaxDuration -- nothing could set it.
MaxDuration = seconds > 0 ? TimeSpan.FromSeconds(seconds) : TimeSpan.Zero,
},
pid => RuntimeModuleSnapshot.Take(pid, CensusNames.ModuleFileNames));
pid => RuntimeModuleSnapshot.Take(pid, CensusNames.ModuleFileNames),
NgxDriverProbe.Run);
}
/// <summary>
+12
View File
@@ -124,6 +124,7 @@ int NgxState(unsigned long pid) {
NvAPI_GetErrorMessage(init, desc);
std::printf(" NvAPI_Initialize -> %d (%s)\n BRANCH: DEGRADED — no usable NVIDIA driver on this machine.\n",
static_cast<int>(init), desc);
std::printf("NGXSTATE status=DEGRADED nvapi=%d\n", static_cast<int>(init));
return 2;
}
NvU32 driverVersion = 0;
@@ -143,6 +144,7 @@ int NgxState(unsigned long pid) {
std::printf(" BRANCH: UNANSWERED — the driver did not answer for pid %lu (not an NVIDIA-rendered process, a "
"driver older than R570, or the API refusing this caller).\n",
pid);
std::printf("NGXSTATE status=UNANSWERED nvapi=%d\n", static_cast<int>(status));
NvAPI_Unload();
return 3;
}
@@ -160,6 +162,16 @@ int NgxState(unsigned long pid) {
std::printf(" frameGenerationPreset %u\n", params.frameGenerationPreset);
std::printf(" frameGenerationMode %u\n", params.frameGenerationMode);
std::printf(" reserved %u %u\n", params.reserved[0], params.reserved[1]);
// THE MACHINE LINE. FrameLedger.CaptureHost spawns this probe beside each module snapshot
// (NgxDriverProbe) and reads exactly this line; everything above is for a human. One line,
// key=value, hex masks, so a parser cannot mistake a decoded name for a field.
std::printf(
"NGXSTATE status=ANSWERED sr=0x%016llX rr=0x%016llX fg=0x%016llX ratio=%.4f mode=%u preset=%u fgcount=%u "
"fgpreset=%u fgmode=%u driver=%u\n",
static_cast<unsigned long long>(params.feedbackMaskSR), static_cast<unsigned long long>(params.feedbackMaskRR),
static_cast<unsigned long long>(params.feedbackMaskFG), static_cast<double>(params.scalingRatio),
params.performanceMode, params.renderPreset, params.frameGenerationCount, params.frameGenerationPreset,
params.frameGenerationMode, driverVersion);
NvAPI_Unload();
return 0;
}
@@ -277,6 +277,56 @@ public sealed class CaptureLoopTests : IDisposable
CaptureResult r = await loop.RunAsync(_exe, Fingerprint, "payload.dll", TestContext.Current.CancellationToken);
r.RuntimeModules.Should().BeSameAs(RuntimeModuleSet.Empty);
r.NgxDriver.Should().BeSameAs(NgxDriverState.NotRun, "no probe was given to the loop");
}
[Fact]
public async Task TheDriverProbeRidesOnTheSameTouchAsTheModuleSnapshotAndIsMergedOntoTheResult()
{
// The probe is out of process and answers per pid; it rides the scan's cadence exactly as the
// module snapshot does, and a later answer that differs is reported as a CHANGE, not averaged.
var guard = new CountingGuard();
using var sink = new FakeSink();
int probes = 0;
var loop = new CaptureLoop(
await StoreWithAsync(), new HookedCaptureGate(guard), guard, new FixedResolver(_pid, SessionEndReason.Running),
_ => new FakeLiveness(),
_ => (sink, ShmAttachRefusal.Ok),
new CaptureOptions
{
DrainInterval = TimeSpan.FromMilliseconds(1),
ScanInterval = TimeSpan.FromMilliseconds(5),
AttachBudget = TimeSpan.FromMilliseconds(50),
MaxDuration = TimeSpan.FromMilliseconds(120),
},
modules: null,
ngx: pid =>
{
pid.Should().Be(_pid);
probes++;
sink.Events.Add("ngx");
// The first reading has DLSS not yet created; every later one has it created and evaluated.
ulong sr = probes == 1 ? NgxOverrideFlags.Initialized | NgxOverrideFlags.DllExists
: NgxOverrideFlags.Initialized | NgxOverrideFlags.DllExists | NgxOverrideFlags.CreatedAndEvaluated;
return NgxDriverState.Parse($"NGXSTATE status=ANSWERED sr=0x{sr:X16} rr=0x1 fg=0x5 ratio=0.0000 mode=0 preset=0 fgcount=0 fgpreset=0 fgmode=0 driver=61664");
});
CaptureResult r = await loop.RunAsync(_exe, Fingerprint, "payload.dll", TestContext.Current.CancellationToken);
probes.Should().Be(sink.Published.Count + 1, "one per scan, plus the one before the last drain");
r.NgxDriver.Outcome.Should().Be(NgxProbeOutcome.Answered);
r.NgxDriver.Readings.Should().Be(probes);
r.NgxDriver.Answered.Should().Be(probes);
r.NgxDriver.SrCreatedAndEvaluated.Should().BeTrue("the last answered reading is the state");
r.NgxDriver.Changed.Should().BeTrue("the first reading differed from the later ones");
r.NgxDriver.Driver.Should().Be(61664u);
for (int i = 0; i < sink.Events.Count; i++)
{
if (string.Equals(sink.Events[i], "publish", StringComparison.Ordinal))
{
sink.Events[i + 1].Should().Be("ngx", "the probe follows the publish directly, on the snapshot's touch");
}
}
}
[Fact]
@@ -0,0 +1,36 @@
using FluentAssertions;
using FrameLedger.CaptureHost.Capture;
using FrameLedger.CaptureHost.Consume;
namespace FrameLedger.CaptureHost.Tests.Capture;
/// <summary>
/// The out-of-process probe as the loop calls it: every way it can fail is an outcome on the result, never a throw.
/// </summary>
public sealed class NgxDriverProbeTests
{
[Fact]
public void AMissingProbeIsAnOutcomeThatNamesThePath()
{
NgxDriverState s = NgxDriverProbe.Run(Environment.ProcessId, @"C:\nowhere\fl-probe-nvapi.exe");
s.Outcome.Should().Be(NgxProbeOutcome.ProbeMissing);
s.Detail.Should().Contain("fl-probe-nvapi.exe");
s.SrCreatedAndEvaluated.Should().BeFalse();
}
[Fact]
public void RunAgainstThisTestProcessNeverThrowsAndNeverClaimsAFeature()
{
// The real binary is staged beside the host by the project file when the native build ran
// first (CI does; a fresh clone may not). Whichever it is, this process renders nothing
// through NGX, so the only honest outcomes are the ones that say so.
NgxDriverState s = NgxDriverProbe.Run(Environment.ProcessId);
s.Outcome.Should().BeOneOf(NgxProbeOutcome.Unanswered, NgxProbeOutcome.Degraded, NgxProbeOutcome.ProbeMissing,
NgxProbeOutcome.ProbeFailed);
s.SrCreatedAndEvaluated.Should().BeFalse();
s.Readings.Should().Be(1);
s.Describe().Should().StartWith(" NVIDIA driver NGX state");
}
}
@@ -0,0 +1,119 @@
using System.Diagnostics;
using FluentAssertions;
using FrameLedger.CaptureHost.Consume;
using FrameLedger.Shared;
namespace FrameLedger.CaptureHost.Tests.Consume;
/// <summary>
/// <c>03_METRICS</c> §Upscaling, the driver-reported rung: the driver's word names DLSS only where no hook did,
/// stands beside a hook's name as agreement or a printed disagreement, and never claims more than an identity.
/// </summary>
public sealed class DriverReportedUpscalerTests
{
private const FlHookFamily _hooks =
FlHookFamily.Present | FlHookFamily.UpscalerIdentity | FlHookFamily.UpscalerParams | FlHookFamily.FgEvaluations;
private static readonly NgxDriverState _created = NgxDriverState.Parse(
"NGXSTATE status=ANSWERED sr=0x605 rr=0x90001 fg=0x90001 ratio=0.0000 mode=0 preset=0 fgcount=0 fgpreset=0 fgmode=0 driver=61664");
private static readonly NgxDriverState _notCreated = NgxDriverState.Parse(
"NGXSTATE status=ANSWERED sr=0x5 rr=0x1 fg=0x1 ratio=0.0000 mode=0 preset=0 fgcount=0 fgpreset=0 fgmode=0 driver=61664");
/// <summary>Records with, or without, a hooked upscaler identity; the hook family is installed either way.</summary>
private static List<FlFrameRecord> Stream(FlUpscaler identity)
{
List<FlFrameRecord> stream = [];
ulong qpc = 1_000_000;
ulong step = (ulong)(Stopwatch.Frequency / 60);
for (int f = 0; f < 120; f++)
{
stream.Add(new FlFrameRecord
{
Qpc = qpc,
SwapchainId = 1,
OutputW = 2560,
OutputH = 1440,
MeasuredMask = (ushort)(FlMeasured.OutputRes | FlMeasured.PresentArgs | FlMeasured.Upscaler),
Upscaler = (byte)identity,
});
qpc += step;
}
return stream;
}
private static (MeasuredFacts Facts, string Text) Render(FlUpscaler identity, NgxDriverState? ngx)
{
List<FlFrameRecord> stream = Stream(identity);
var writer = new FlWriterState { HooksInstalledMask = (uint)_hooks, RuntimeCensus = (uint)FlRuntimeCensus.Ran };
MeasuredFacts facts = MeasuredFacts.From(stream, writer, Stopwatch.Frequency, 0, 0, ngx: ngx);
return (facts, SessionReport.Render(facts));
}
[Fact]
public void LiesOfPShapeNoHookNamedAnUpscalerAndTheDriverSaysCreatedIsDlssDriverReported()
{
(MeasuredFacts facts, string text) = Render(FlUpscaler.Unknown, _created);
facts.Upscaler.Should().BeNull("the hook ran and decoded nothing on an NGX-direct title");
facts.UpscalerDriverReported.Should().Be(MeasuredFacts.UpscalerDlssDriverReported);
facts.UpscalerDriverNote.Should().BeNull("the identity line already carries the attribution");
text.Should().Contain("upscaler: Dlss (driver-reported:");
text.Should().Contain("not counted by this hook");
text.Should().NotContain("upscaler: N/A");
}
[Fact]
public void AHookedDlssBesideTheDriversCreatedWordPrintsAgreement()
{
(MeasuredFacts facts, string text) = Render(FlUpscaler.Dlss, _created);
facts.Upscaler.Should().Be("Dlss");
facts.UpscalerDriverReported.Should().BeNull("a hook's name always outranks the driver's word");
text.Should().Contain("upscaler: Dlss — the NVIDIA driver agrees");
text.Should().NotContain("driver-reported:");
}
[Fact]
public void AHookedDlssBesideTheDriversNegativeIsADisagreementPrintedNotResolved()
{
(MeasuredFacts facts, string text) = Render(FlUpscaler.Dlss, _notCreated);
facts.Upscaler.Should().Be("Dlss");
text.Should().Contain("upscaler: Dlss — WARNING: the NVIDIA driver reports NO NGX super-resolution feature created");
text.Should().Contain("printed rather than resolved");
}
[Fact]
public void NoHookNameAndTheDriversNegativeKeepsNaWithTheNegativeAttributed()
{
(MeasuredFacts facts, string text) = Render(FlUpscaler.Unknown, _notCreated);
facts.UpscalerDriverReported.Should().BeNull();
text.Should().Contain("upscaler: N/A (an upscaler hook ran");
text.Should().Contain("— the NVIDIA driver reports no NGX super-resolution feature created in this process (driver-reported; it says nothing about FSR or XeSS)");
}
[Fact]
public void AnFsrIdentityBesideTheDriversCreatedWordIsPrintedAsAlso()
{
(_, string text) = Render(FlUpscaler.Fsr3, _created);
text.Should().Contain("upscaler: Fsr3 — the NVIDIA driver also reports an NGX super-resolution feature");
}
[Fact]
public void WithoutAProbeOrWithoutAnAnswerTheLineIsByteIdenticalToBefore()
{
(_, string none) = Render(FlUpscaler.Unknown, null);
(_, string unanswered) = Render(FlUpscaler.Unknown, NgxDriverState.Parse("NGXSTATE status=UNANSWERED nvapi=-160"));
(_, string missing) = Render(FlUpscaler.Unknown, NgxDriverState.Of(NgxProbeOutcome.ProbeMissing, @"C:\nowhere\fl-probe-nvapi.exe"));
foreach (string text in new[] { none, unanswered, missing })
{
text.Should().Contain("upscaler: N/A (an upscaler hook ran");
text.Should().NotContain("NVIDIA driver");
}
}
}
@@ -0,0 +1,86 @@
using FluentAssertions;
using FrameLedger.CaptureHost.Consume;
namespace FrameLedger.CaptureHost.Tests.Consume;
/// <summary>
/// The probe's machine line, parsed and merged: the words the owner measured on 2026-09-06 are the fixtures.
/// </summary>
public sealed class NgxDriverStateTests
{
private const string _hellIsUs =
"NGXSTATE status=ANSWERED sr=0x0000000000080605 rr=0x0000000000080005 fg=0x0000000000000005 ratio=0.0000 mode=0 preset=0 fgcount=0 fgpreset=0 fgmode=0 driver=61664";
private const string _expedition33Override =
"NGXSTATE status=ANSWERED sr=0x000000000008067F rr=0x0000000000080005 fg=0x000000000000001F ratio=0.0000 mode=2 preset=11 fgcount=0 fgpreset=0 fgmode=0 driver=61664";
[Fact]
public void TheAnsweredLineIsReadWholeAndTheHumanLinesAreIgnored()
{
string output = "fl-probe-nvapi --ngx-state 12468 — the driver's NGX feedback for one process\r\n\r\n"
+ " driver 616.64 (r616_41)\r\n SR feedback 0x0000000000080605 : INITIALIZED DLL_EXISTS CREATED EVALUATE ERR_NOT_FOUND\r\n"
+ _hellIsUs + "\r\n";
NgxDriverState s = NgxDriverState.Parse(output);
s.Outcome.Should().Be(NgxProbeOutcome.Answered);
s.Sr.Should().Be(0x80605UL);
s.Rr.Should().Be(0x80005UL);
s.Fg.Should().Be(0x5UL);
s.Driver.Should().Be(61664u);
s.SrCreatedAndEvaluated.Should().BeTrue("CREATED and EVALUATE are both set on Hell Is Us without an override");
s.Readings.Should().Be(1);
s.Answered.Should().Be(1);
NgxOverrideFlags.Describe(s.Sr).Should().Be("INITIALIZED DLL_EXISTS CREATED EVALUATE ERR_NOT_FOUND");
NgxOverrideFlags.Describe(s.Fg).Should().Be("INITIALIZED DLL_EXISTS");
NgxOverrideFlags.Describe(0).Should().Be("-");
NgxOverrideFlags.Describe(1UL << 40).Should().Be("0x10000000000", "an unknown bit is printed, never dropped");
}
[Fact]
public void TheOverrideFieldsAreCarriedAndNamedAsOverrideFields()
{
NgxDriverState s = NgxDriverState.Parse(_expedition33Override);
s.PerformanceMode.Should().Be(2u);
s.RenderPreset.Should().Be(11u);
s.ScalingRatio.Should().Be(0.0);
s.SrCreatedAndEvaluated.Should().BeTrue();
s.Describe().Should().Contain("performanceMode=2 renderPreset=11").And.Contain("the OVERRIDE's values")
.And.Contain("the FG word does not reflect Streamline DLSS-G");
}
[Fact]
public void UnansweredDegradedAndGarbageAreOutcomesNotExceptions()
{
NgxDriverState.Parse("NGXSTATE status=UNANSWERED nvapi=-160").Outcome.Should().Be(NgxProbeOutcome.Unanswered);
NgxDriverState.Parse("NGXSTATE status=DEGRADED nvapi=-2").Outcome.Should().Be(NgxProbeOutcome.Degraded);
NgxDriverState.Parse("nothing here").Outcome.Should().Be(NgxProbeOutcome.ProbeFailed);
NgxDriverState.Parse("NGXSTATE status=ANSWERED sr=zz").Outcome.Should().Be(NgxProbeOutcome.ProbeFailed);
NgxDriverState.Parse("NGXSTATE status=WHAT").Outcome.Should().Be(NgxProbeOutcome.ProbeFailed);
NgxDriverState.Parse("NGXSTATE status=UNANSWERED nvapi=-160").SrCreatedAndEvaluated.Should().BeFalse();
NgxDriverState.Parse("NGXSTATE status=UNANSWERED nvapi=-160").Describe().Should().Contain("did not answer").And.Contain("NvAPI -160");
}
[Fact]
public void MergeKeepsTheLastAnswerCountsEveryReadingAndFlagsAChange()
{
NgxDriverState before = NgxDriverState.Parse(
"NGXSTATE status=ANSWERED sr=0x5 rr=0x1 fg=0x5 ratio=0.0000 mode=0 preset=0 fgcount=0 fgpreset=0 fgmode=0 driver=61664");
NgxDriverState after = NgxDriverState.Parse(_hellIsUs);
NgxDriverState silent = NgxDriverState.Parse("NGXSTATE status=UNANSWERED nvapi=-160");
NgxDriverState merged = NgxDriverState.NotRun.Merge(before).Merge(after).Merge(silent);
merged.Outcome.Should().Be(NgxProbeOutcome.Answered, "an earlier answer outranks a later silence");
merged.Sr.Should().Be(0x80605UL, "the last ANSWERED reading is the state");
merged.Readings.Should().Be(3);
merged.Answered.Should().Be(2);
merged.Changed.Should().BeTrue("the SR word gained CREATED | EVALUATE between readings");
merged.Describe().Should().Contain("answered 2 of 3 probe(s), and the words CHANGED between readings");
NgxDriverState same = NgxDriverState.NotRun.Merge(after).Merge(after);
same.Changed.Should().BeFalse();
same.Describe().Should().Contain("answered 2 of 2 probe(s); driver 616.64");
}
}