Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf22731150 | ||
|
|
0c2deb6c53 | ||
|
|
7aa03f5509 |
No files matched your search
+13
-3
@@ -35,6 +35,15 @@ numeric core and does not move; the heading is the full version — corrected 20
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- **The log of the part inside a game says how a group of hooks went in or came out** (owner decision D137). Since
|
||||
0.1.0-beta.46 hooks are put into a game in groups, the game's threads stopped once for a group. In the owner's
|
||||
first sessions two groups took much longer than the others (0.6 s and 1.3 s against 0.1-0.3 s), and the log
|
||||
could not tell one long stop from a group that had to be finished one hook at a time. The `PATCH_BATCH` line now
|
||||
reads `install` or `restore` for a group that went in one go, and `install singly` or `restore singly`, with a
|
||||
count, for one that did not. Nothing else about hooking changed, and what a game is measured by is the same.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **For developers: a native test that is cut short no longer counts as passed.** The quality gate's native tests
|
||||
@@ -48,9 +57,10 @@ numeric core and does not move; the heading is the full version — corrected 20
|
||||
- **For developers, nothing a user installs: a probe for NVIDIA Reflex latency** (owner decision D132). An
|
||||
unshipped tool, `fl-probe-reflex`, and a stand-in `nvapi64.dll` among the test fixtures measure what it would take
|
||||
to read the driver's latency report from inside a game - on FrameLedger's own test program and against the
|
||||
installed driver, never in a game. What it found is `docs/spike-notes/31-reflex-route-d-harness.md`; whether a
|
||||
real game is tried next is the owner's decision. Nothing in the App, the Agent or the part that runs inside a
|
||||
game changed.
|
||||
installed driver, never in a game. What it found is `docs/spike-notes/31-reflex-route-d-harness.md`. A further
|
||||
leg (owner decision D139) measured the same reads while the probe itself used Reflex's sleep, as a game does:
|
||||
the reads do not wait behind it. The owner has said to go on to a real game (D136); that work is not in any
|
||||
release yet. Nothing in the App, the Agent or the part that runs inside a game changed.
|
||||
|
||||
## Releases
|
||||
|
||||
|
||||
@@ -812,7 +812,7 @@ Every hook body is wrapped:
|
||||
> **1.26 s**. That last one and a batch of three in Cyberpunk 2077 (**0.61 s**) are not explained: the cost does
|
||||
> not follow the count — sixteen patches in 93 ms, three in 609 ms — and **the log cannot tell one long stop from an
|
||||
> apply that failed part-way and was finished one patch at a time**, because a batch writes a line only for a patch
|
||||
> that fails for good (**to be added with the next release, owner decision D137**). **Still not measured: the restore in a real game** — no session has been stopped while its
|
||||
> that fails for good. **Since the release after 0.1.0-beta.46 the line says which** (owner decision D137): `install` or `restore` is a batch that went under its one apply; `install singly` or `restore singly` is one whose apply said it had failed, and the high half of `b` then counts the patches handed to MinHook one at a time (`b=0x0003000d`: thirteen in, three of them singly) — attempts, not stops: MinHook makes no stop for a patch the failed apply had already done. So a long `a=` on a plain `install` line is one long stop of the threads. **Still not measured: the restore in a real game** — no session has been stopped while its
|
||||
> game ran (owner-only item 44 (d)). One more thing the
|
||||
> queue changes for the better: MinHook's single-target disable does not move a thread that is suspended inside
|
||||
> the patched bytes (`hook.c` passes the enable action to its thread fix-up in both directions); the queued apply
|
||||
|
||||
@@ -1873,7 +1873,7 @@ Moved verbatim, in this order.
|
||||
| M12 ❓ | **Advanced metrics — which NVAPI rows answer on real hardware (D101, 2026-11-11).** `18_GPU_VENDOR_APIS` §The inventory lists sixty `nvapi.` rows whose reach is `Agent`. They are declared in the vendored headers; **none has been called on a GPU**, and CI has no driver, so it never takes that branch. Unknown per row: whether the RTX 5080 on the current driver answers or returns `NVAPI_NOT_SUPPORTED` (the memory-temperature target already does not exist on that card). | **The measurement is the bridge's probe on the owner's PC**, then the page itself (the release's owner-only item). Pre-committed: a call that does not answer → that row is N/A with NVAPI's own status as the reason, and nothing is put in its place; a call that hangs or faults twice → the row is off for the session (§Runtime policy); a value that contradicts the vendor's own tool → the row is withheld until it is explained. **Half answered the same day, by the bridge's own test on the dev box** (ctest `fl_nvapi_bridge`, AVAILABLE branch; RTX 5080): every fact answers (`present = 0xFFFFF`), eight of ten live groups answer (`0x33F` — no board and no power-supply temperature sensor on this card: N/A, by the first pre-committed outcome), the display answers its four groups, the global profile lists 24 settings; figures in `18_GPU_VENDOR_APIS` §L3. **Still open**: the same values on the page beside the vendor's own tool, and the session rows (`nvapi.session.*`), which need a game. **And one thing seen once and not explained**: in one test run of about a dozen that day, `FlNvReadLive` came back with no field at all although `FlNvReadFacts`, a moment earlier in the same process, had answered everything; nine further runs did not show it. A handle the driver invalidated is the usual cause of that shape, and nothing here re-enumerates after `FlNvInit`. Pre-committed for the reader that owns the thread: two readings in a row with no field → release and initialise the bridge again, once, and say so in the log; if that does not bring the fields back the layer is off for the session, as any layer that fails twice is. |
|
||||
| M13 ❓ | **Advanced metrics — LibreHardwareMonitor's CPU, memory, motherboard and storage groups, elevated, with PawnIO (D103, 2026-11-11).** Never opened by any build: §M10's elevated run has not been taken either, and this is a larger surface — a sensor chip on the LPC bus, the embedded controller, SPD over SMBus, SMART. Unknown: whether each group opens on the owner's board, what a refresh costs, whether opening the storage group touches removable drives (this PC once had a failing USB drive), and whether any group enables a privilege (`PrivilegeFootprintTests`). | **One elevated run with the probe verb, before the option exists.** Pre-committed: the storage group cannot be opened without touching removable drives → `lhm.storage.*` stays N/A in beta.39 and its reach reads `Deferred`; a node that throws twice → skipped for the session; the Agent above 1% of one core or 150 MB with the option on (NFR-2) → the slow groups are read less often or dropped before the release; a privilege enabled by a group → that group is not opened, and the owner is asked. **Two of the four answered 2026-11-11, before the option exists.** (1) **Storage: not opened, by the first outcome.** LibreHardwareMonitor 0.9.6's `StorageGroup` lists every drive through DiskInfoToolkit's `ReloadStorages` with no filter by bus and follows drives plugged in later — it cannot be opened without touching removable drives. `lhm.storage.*` reads `Deferred`, and `LhmGroups` has no member for it. (2) **Cost, unelevated, measured with `probe-advanced`** on the dev box: one refresh of the graphics-card group alone is 14 ms of processor time (62 ms elapsed) — 1.4% of one core at one a second, above NFR-2 — and one NVAPI read 0.4 ms. By the third outcome the sensor library is read every fifth tick (0.28%). **Still open, and the owner's**: the same probe as administrator with PawnIO — whether the processor, memory and motherboard groups open on this board, what they cost, and `PrivilegeFootprintTests`' new case on a token that holds the privileges (CI's does; the dev box's unelevated run passes by construction). **The first run was taken on 2026-11-12, by the owner, in ordinary use** (0.1.0-beta.40, the Agent as administrator with PawnIO, an i7-14700KF on a board with an IT8689E chip, an RTX 5080), and read here from a copy of the ledger and the Agent's log, not from a probe. **The groups open and read**: nine of ten sessions stored 119 processor series (a clock and a load per thread, temperatures, powers, voltages), 14 memory series and 21 motherboard series (six fans, six temperatures, nine voltages) beside the card's 41 — 195 from the sensor library in all. **No value was compared with another tool**; that is still the owner's. **Two faults, one cause** (`Infrastructure.Telemetry.LhmLibrary`): the Agent held up to three `Computer`s at once, and the library keeps the driver it reads the processor through and its bus mutexes per process — closing one `Computer` let go of them under the others. After seven sessions the Advanced reader's processor device threw `NullReferenceException` twice and was left alone (the page lost the processor until the reader reopened); once a session's start met another instance's close, the reader's `Open` threw `ObjectDisposedException`, and that session stored 17 series instead of 212. **Fixed 2026-11-12**: opens and closes are serialised and a `Computer` is parked, not closed, while another is in use. The cause is read from the log's timing and was not reproduced — it needs this elevation — so **whether the faults are gone is the owner's next sessions to show**: no `advanced: a device is left alone` and no `did not open` in the Agent's log. **First evidence, 2026-11-12, 0.1.0-beta.41, the same PC:** seven sessions between 06:38 and 07:01 with no `advanced:` line at all, each with the option on storing 212 or 213 series; on beta.40 that morning the processor device faulted out after each of six sessions (04:34–05:07) — thirteen of sixteen over the night. The reader failing to open was seen once in sixteen, so this is not yet enough to call that one gone. Still open: any value beside another tool. |
|
||||
| M16 ✅ | **The L2 telemetry layer's cost — the first number, and it is above NFR-2 (found 2026-11-11, measuring something else).** `LhmTelemetrySource` refreshes LibreHardwareMonitor's graphics-card group once a second in every recorded session. `probe-advanced` measured that refresh, through the same library and the same group, at **14 ms of processor time** on the dev box (RTX 5080, 41 mapped sensors, about twenty of them the Direct3D engine nodes the library enumerates per card) — 1.4% of one core, where NFR-2 allows the whole Agent 1% during capture and `14_TESTING` §Hook overhead's Agent figure has never been measured. This is a measurement of the call, not yet of a session: L2's own poller was not instrumented. | **Measure L2 in a session** (the Agent's processor time over a ten-minute capture, telemetry at 1000 ms and at 2000 ms). Pre-committed: at or under 1% → this row closes with the number; above → the owner chooses between a slower default for `telemetry.interval_ms`, reading the sensors the layer keeps from NVAPI on NVIDIA cards (L3 already has most, at 0.4 ms), or amending NFR-2 to what is measured. Not decided here, and nothing about L2 changes in the Advanced-metrics train. **Measured in a real Agent, 2026-11-11 (owner decision D110), and answered (D117).** `tools/agent-cost.ps1` runs the shipped `FrameLedger.Agent.exe --console capture` against a copy of hook-harness in a scratch data folder — a session that is not hooked, so the telemetry poller runs as in every session and nothing drains frames — and reads the Agent process's own processor time at exit; the cost per second is the slope between a 45 s and a 165 s session, two runs of each. Dev box (RTX 5080, not elevated, layers `l1+lhm+nvapi`): **19.3 ms of processor time per second of session = 1.93 % of one core with Advanced metrics off** (2,312 and 2,312 ms over 45 s; 4,594 and 4,656 ms over 165 s), **20.4 ms = 2.04 % with it on** (2,984 and 3,000; 5,547 and 5,344); peak working set 113 MiB and 119 MiB. A first pass with 30 s and 90 s sessions gave 1.56 % and 2.21 % — its two short runs differed by 670 ms, which is why the lengths were raised. So the probe's number holds in a session: the Agent's steady cost is about twice NFR-2's 1 %, nearly all of it the layer every session has always used, and the new option adds about a tenth of a percent. **The owner's answer: NFR-2 is amended to ≤ 2.5 % of one core** — the limit had never been measured, the sensors keep their one reading a second, and nothing in the code changes. Not measured: a hooked session (the drain's cost on top), a session with the Agent elevated and PawnIO's groups open, another PC. |
|
||||
| M14 ❓ | **Reflex latency per frame — is there a route within rules 4 and 5? (Train C, 2026-11-11.)** `17_HOOK_ENGINE` §Memory / latency names hooks on `NvAPI_D3D_SetSleepMode` / `SetLatencyMarker` and a call to `NvAPI_D3D_GetLatency`. NVAPI resolves all three through `nvapi_QueryInterface` by id — they are not exports, so a hook on them is a patch at an address learned at run time, the class refused on 2026-08-09. The route to try first needs no hook: the Overlay's own background thread **calls** `GetLatency` with the device of the swap chain it already hooks, once a second (the call returns the last 64 frames' reports). Unknown: whether calling into the driver from that thread is safe on every device kind, what it costs, what it returns when the game never enabled Reflex, and what it means for the Disclaimer's sentence about that thread. | **A spike on `hook-harness` and a stub first, then one real title.** Pre-committed: no route without a patch at a run-time address or a loader-lock call on the game's thread → Reflex stays N/A and the page says why; overhead above NFR-1 → the same. The owner says go or no on the spike's result. **2026-11-12 — the reading that comes before that spike is `spike-notes` §30** (owner decision D130: a document first, beside 0.1.0-beta.45; nothing was run). It finds: a hook on NVAPI's latency functions is the refused class, and a hook on Streamline's Reflex and PCL functions is train D's wrapper (§M15) — and would miss a game that fetched them before the attach, as `slInit` is missed (D129); the Overlay calling `slReflexGetState` itself breaks the thread contract the vendor's header states; **what remains is the route named in this row**, the Overlay calling two driver getters with the game's device, and a no-injection ETW route that gives the game-side markers only and makes the game post messages to its own window. Corrected there: `nvapi64.dll` exports **two** functions on the dev box (`nvapi_Direct_GetMethod` beside `nvapi_QueryInterface`), not one. The go or no is the owner's, and a go needs the owner's ruling that calling a driver getter with the game's device is inside rule 4. **2026-11-13 — the owner answered (D132, D133).** Route D goes to the spike this row names, on `hook-harness` and a stub `nvapi64.dll`, with the ruling: a driver's read-only getter called with the device of the swap chain the Overlay hooks is inside rule 4 (`CLAUDE.md`, the rule's note of that day). No real game before the owner has seen the result, and nothing shipped changes for the spike (`spike-notes` §31, written after 0.1.0-beta.46). Route C is **refused**; the ETW route **stays closed**, and §G is not reopened. **2026-11-13 — the harness spike is done (`spike-notes` §31), and none of its stop conditions fired.** With a stand-in module: nothing is called or loaded when `nvapi64.dll` is absent, a missing getter is refused whole, an error and a report of nothing read as what they are, and a call the driver holds for seconds stops only the thread that made it — so not the watchdog. With the installed driver (32.0.16.2114, RTX 5080), in the probe's own process and with the probe setting the markers a game would: no fault before `NvAPI_Initialize`, without markers, or across 38 million reads beside a marker-setting thread; a call costs half a microsecond to a microsecond and a half; the report is readable from markers alone, in microseconds; and the Direct3D 12 **device** — the object the Overlay already holds — is what the driver takes. What only a game can say is unanswered: a game's own device, a real report, another driver. **The owner's next word is go or no for one real title**; a go is a plan of its own first. **2026-11-13, the same evening — go (D136)**: a plan for one title, Cyberpunk 2077; no code before the plan is approved, and no release carrying it before a stop while a game runs has been exercised on 0.1.0-beta.46 (owner-only item 44 (d)). |
|
||||
| M14 ❓ | **Reflex latency per frame — is there a route within rules 4 and 5? (Train C, 2026-11-11.)** `17_HOOK_ENGINE` §Memory / latency names hooks on `NvAPI_D3D_SetSleepMode` / `SetLatencyMarker` and a call to `NvAPI_D3D_GetLatency`. NVAPI resolves all three through `nvapi_QueryInterface` by id — they are not exports, so a hook on them is a patch at an address learned at run time, the class refused on 2026-08-09. The route to try first needs no hook: the Overlay's own background thread **calls** `GetLatency` with the device of the swap chain it already hooks, once a second (the call returns the last 64 frames' reports). Unknown: whether calling into the driver from that thread is safe on every device kind, what it costs, what it returns when the game never enabled Reflex, and what it means for the Disclaimer's sentence about that thread. | **A spike on `hook-harness` and a stub first, then one real title.** Pre-committed: no route without a patch at a run-time address or a loader-lock call on the game's thread → Reflex stays N/A and the page says why; overhead above NFR-1 → the same. The owner says go or no on the spike's result. **2026-11-12 — the reading that comes before that spike is `spike-notes` §30** (owner decision D130: a document first, beside 0.1.0-beta.45; nothing was run). It finds: a hook on NVAPI's latency functions is the refused class, and a hook on Streamline's Reflex and PCL functions is train D's wrapper (§M15) — and would miss a game that fetched them before the attach, as `slInit` is missed (D129); the Overlay calling `slReflexGetState` itself breaks the thread contract the vendor's header states; **what remains is the route named in this row**, the Overlay calling two driver getters with the game's device, and a no-injection ETW route that gives the game-side markers only and makes the game post messages to its own window. Corrected there: `nvapi64.dll` exports **two** functions on the dev box (`nvapi_Direct_GetMethod` beside `nvapi_QueryInterface`), not one. The go or no is the owner's, and a go needs the owner's ruling that calling a driver getter with the game's device is inside rule 4. **2026-11-13 — the owner answered (D132, D133).** Route D goes to the spike this row names, on `hook-harness` and a stub `nvapi64.dll`, with the ruling: a driver's read-only getter called with the device of the swap chain the Overlay hooks is inside rule 4 (`CLAUDE.md`, the rule's note of that day). No real game before the owner has seen the result, and nothing shipped changes for the spike (`spike-notes` §31, written after 0.1.0-beta.46). Route C is **refused**; the ETW route **stays closed**, and §G is not reopened. **2026-11-13 — the harness spike is done (`spike-notes` §31), and none of its stop conditions fired.** With a stand-in module: nothing is called or loaded when `nvapi64.dll` is absent, a missing getter is refused whole, an error and a report of nothing read as what they are, and a call the driver holds for seconds stops only the thread that made it — so not the watchdog. With the installed driver (32.0.16.2114, RTX 5080), in the probe's own process and with the probe setting the markers a game would: no fault before `NvAPI_Initialize`, without markers, or across 38 million reads beside a marker-setting thread; a call costs half a microsecond to a microsecond and a half; the report is readable from markers alone, in microseconds; and the Direct3D 12 **device** — the object the Overlay already holds — is what the driver takes. What only a game can say is unanswered: a game's own device, a real report, another driver. **The owner's next word is go or no for one real title**; a go is a plan of its own first. **2026-11-13, the same evening — go (D136)**: a plan for one title, Cyberpunk 2077; no code before the plan is approved, and no release carrying it before a stop while a game runs has been exercised on 0.1.0-beta.46 (owner-only item 44 (d)). **2026-11-13, the plan and four more answers (D138–D141).** The read has **no switch of its own**: it is part of Advanced metrics, so after the release it reaches every Direct3D 12 game that loaded the driver's `nvapi64.dll`, for everyone who switched Advanced metrics on — "one title" is the order of the owner's first runs, not a limit in code (D138). The probe ran a leg with a sleep mode first (D139; `spike-notes` §31, *The leg with a sleep*): **the getters do not wait behind `NvAPI_D3D_Sleep`** — thirty-one million reads beside a thread that slept 97 % of the time, none of a millisecond; a read after a sleeping frame costs about 2.6 µs. An `nvapi64.dll` loaded from the game's own folder is refused with the reason (D140). One call of 2 ms or more switches the read off until the game exits (D141). The plan's design, as reviewed against the source, is in `HANDOFF.md` §The train after 0.1.0-beta.46. |
|
||||
| M15 ❓ | **The Streamline state behind `slGetFeatureFunction` — re-examined, not reopened (Train D, 2026-11-11).** The owner asked for the refusal in `handoff/history/p0-queue-1-6.md` to be looked at again. `18_GPU_VENDOR_APIS` §The trains states the route to try (hook the export, hand back a wrapper for a fixed list of names) and what it raises: the wrapper is a write to what the game receives, which rule 4 forbids as written; a wrapper must outlive the Overlay's unhook; a game that fetched its functions before the hook existed is never seen. | **A written design against each of the five grounds, then a spike.** Pre-committed: any ground unanswered → the route stays refused, and `sl.dlssg.*`, `sl.reflex.*` and the rest of that block read N/A with "refused" as the reason. Proceeding needs the owner's amendment of rule 4, asked with the rule quoted. |
|
||||
| M10 ✅ | ~~PDH `\GPU Engine(*)\Utilization Percentage` summed across engines does not reproduce the Task Manager figure the doc invokes. Decide what we actually report and label it accordingly~~ **Decided 2026-09-09 (PR-E1): L1 does not read the engine counters at all.** `LoadPct` is L2's vendor-reported `GPU Core` load (measured ✓ on NVIDIA, §M5 row R1) and is labelled *GPU load (vendor)* wherever it is shown; on a machine without L2 the field is N/A, never a sum that is not the number the user expects. What L1 does read from PDH is one counter, `\GPU Adapter Memory(luid_…_phys_0)\Dedicated Usage`, bound by LUID — the figure Task Manager labels "Dedicated GPU memory", measured 1301 MB at an idle desktop on the RTX 5080. Reopening this needs a measurement of `max(engine)` against Task Manager's own number, not a decision |
|
||||
|
||||
|
||||
+55
-1
@@ -202,6 +202,52 @@ and the logs, and from Windows' application log. None of the five is under the u
|
||||
nor (g), off means off: `telemetry.advanced` was on throughout. (c), how a game's start feels, is the owner's to
|
||||
say. (a) held: the terms window did not show.
|
||||
|
||||
### The train after 0.1.0-beta.46: Reflex route D in a game, and D137 (plan approved 2026-11-13)
|
||||
|
||||
*Nothing of this is in a release. The release pull request is not opened before the owner has run item 44 (d).*
|
||||
The owner approved the plan the evening item 44 was read. Its order: **PR-0** the decisions and the probe's leg
|
||||
with a sleep (done: `spike-notes` §31 — no stop condition) → **PR-1** D137 → **PR-2** the words in region 5, written
|
||||
by nobody → **PR-3** the Overlay, the gates, the fixtures → **PR-4** the Agent, the App, strings, documents, legal
|
||||
texts and owner-only item 45 → **the release, held**. What the plan's review against the source decided — a draft
|
||||
of mine was wrong in six places — and that no other file carries yet:
|
||||
|
||||
- **Resolve on the watchdog, once for the process; call on the presenting thread.** The watchdog asks Windows for
|
||||
an `nvapi64.dll` that is *already loaded* (never loads it), only while a session asks for Advanced metrics and a
|
||||
Direct3D 12 device is held; it keeps one reference and never releases it; it refuses a module in the executable's
|
||||
own folder (D140); it fetches `nvapi_QueryInterface` and the two ids under a guard and checks with `VirtualQuery`
|
||||
that both addresses lie inside that module. "No module", "no getter" and "refused" are final for the process.
|
||||
- **One atomic gate with four states** — idle, armed, reading, off — not a busy flag beside accumulators (two
|
||||
presenting threads could read back to back, and the watchdog could drain half a read). The watchdog drains only
|
||||
when it sees *idle* and arms at most once a second by its own clock (the loader detour wakes it more often); a
|
||||
present does one relaxed load, takes *armed* to *reading*, reads into a static buffer (the report is 15.4 KB: never
|
||||
on a game thread's stack), and stores *idle* or *off*. A request that goes off takes *armed* back.
|
||||
- **After the record is published, and only for a swap chain whose device is the one held** (`g_d3d12Device` is the
|
||||
first device seen, not "this chain's": a flag in the chain's slot, set in `ResolveApi`).
|
||||
- **The latches, each until the game exits**: a fault in a getter (its own guard with `FlFilter`; counted once
|
||||
through `NoteFault`, so the session shows it and it cannot reach the three that self-disable); one call of 2 ms or
|
||||
more (D141); the watchdog finding *reading* on two ticks running — logged and flushed at once, published as
|
||||
stalled, and **nothing can stop a call that does not return**. An error status or an empty report is recorded and
|
||||
reading goes on.
|
||||
- **The summary**: only frames newer than the last one summed; the two newest of a report skipped (§31: not final);
|
||||
a zero end point is "span not reported" (published as all ones), not a refused frame; a frame is refused for a
|
||||
span that runs backwards, one over a second, or no total; frame ids that go backwards restart the sequence.
|
||||
- **Layout 5 stays**: the ten reserved words of region 5's first line take it (`slShutdowns` is the precedent; the
|
||||
handshake compares the build id anyway, and a trial must be removable without a layout 7). The sleep interval is
|
||||
not stored. No new request word (D138). `FL_HOOK_REFLEX`, `FL_MEASURED_LATENCY` and `reflexLatencyUs` stay unset:
|
||||
there is no hook, and the numbers are a series beside the frames; `sessions.reflex_active` stays NULL.
|
||||
- **Managed side**: a new reach, `GameDriver`, not a relaxed test of `Game` (whose meaning is "the arguments of a
|
||||
call the Overlay hooks"); `nvapi.reflex.frame_report` as seven series, `nvapi.reflex.sleep_status` as a table of
|
||||
switches *seen on / seen off*; `nvapi.reflex.mode`, `sl.reflex.state` and `sl.pcl.markers` become *refused* with
|
||||
the reason; `InGameAdvancedSampler.Take` must read the latency state when the mask is zero and keep the new bit
|
||||
out of `SawAnything`.
|
||||
- **The gates**: `overlay-fields-check` learns the two NVAPI structs (`frameID` joins the shared members; `version`
|
||||
is written outside the header); `nvapi-readonly-check` gets a pass over the Overlay — no `NvAPI_*(` token, every
|
||||
id that equals one of `nvapi_interface.h`'s on a list of exactly two, `Sleep` a writer verb; `hookinventory-check`
|
||||
refuses an `nvapi` import. The injected tests prove nothing about Control Flow Guard (the harness does not enforce
|
||||
it): the probe includes the header that ships, so `fl_reflex_probe_stub` tests the shipped sequence under it.
|
||||
- **The legal texts change in PR-4** (Disclaimer 2.16, Privacy Policy 2.20, the accuracy statement): the part
|
||||
inside the game now *makes a call of its own*, once a second, on the game's presenting thread.
|
||||
|
||||
### NEXT
|
||||
|
||||
1. ~~**The owner runs item 44**~~ **Read 2026-11-13** (§What the owner's five sessions on beta.46 showed): the
|
||||
@@ -210,7 +256,10 @@ and the logs, and from Windows' application log. None of the five is under the u
|
||||
no Streamline; (g) off means off. Not first on a game under the user-mode exception's trial (D38).
|
||||
~~**Proposed, not done: `PATCH_BATCH` says how the batch ended**~~ **Decided the same evening (D137):
|
||||
`PATCH_BATCH` says how the batch ended** — under one apply, or finished one patch at a time, and how many — so
|
||||
that a long `a=` can be read. It goes with the next release, not in one of its own.
|
||||
that a long `a=` can be read. It goes with the next release, not in one of its own. **Written 2026-11-13**:
|
||||
`install` / `restore` for one apply, `install singly` / `restore singly` with the count in the high half of `b`
|
||||
(`17_HOOK_ENGINE` §Unhooking, *Batches*). It explains nothing about the two long batches already seen; it makes
|
||||
the next one readable.
|
||||
2. ~~**The spike of Reflex route D on `hook-harness`**~~ **Done 2026-11-13** (`spike-notes` §31): on the harness
|
||||
and against the installed driver the two getters are harmless, cost about a microsecond and return a readable
|
||||
report, and the Direct3D 12 device the Overlay holds is what the driver takes. **The owner's next word is go or no
|
||||
@@ -218,6 +267,7 @@ and the logs, and from Windows' application log. None of the five is under the u
|
||||
Privacy Policy's wording, `nvapi-readonly-check` over the Overlay). Routes C and E are closed (D133).
|
||||
**The owner said go on 2026-11-13 (D136): a plan first, for Cyberpunk 2077.** No code before the plan is
|
||||
approved, and no release that carries it before item 44 (d) — the stop while a game runs — has been run.
|
||||
**The plan was approved the same evening, with D138–D141** (§The train after 0.1.0-beta.46).
|
||||
3. **`slAllocateResources`** keeps its patch (D135); looked at again when there are more sessions.
|
||||
4. **Train D** after train C, the same way: a spike first — and §30 found its hook would miss a game that fetched
|
||||
its functions before the attach.
|
||||
@@ -912,6 +962,10 @@ Where each owner decision is recorded — the file and its section, and a label
|
||||
| D135 | [`17_HOOK_ENGINE.md`](17_HOOK_ENGINE.md) §Hook inventory | `slAllocateResources` keeps its patch although no game called it in the first six sessions; looked at again when there are more |
|
||||
| D136 | [`20_OPEN_QUESTIONS.md`](20_OPEN_QUESTIONS.md) §M14, [`spike-notes/31-reflex-route-d-harness.md`](spike-notes/31-reflex-route-d-harness.md) §The question for the owner | Reflex route D goes on to one real title, Cyberpunk 2077 — a plan of its own first, no code before it is approved, and no release carrying it before item 44 (d) has been run |
|
||||
| D137 | [`17_HOOK_ENGINE.md`](17_HOOK_ENGINE.md) §Unhooking, *Batches* | the `PATCH_BATCH` line says how a batch ended — one apply, or finished one patch at a time — after two batches in real games took 0.61 s and 1.26 s and the log could not say which; with the next release, not one of its own |
|
||||
| D138 | [`20_OPEN_QUESTIONS.md`](20_OPEN_QUESTIONS.md) §M14, `HANDOFF.md` §The train after 0.1.0-beta.46 | the Reflex read has no switch of its own: it is part of Advanced metrics — so it reaches every Direct3D 12 game that loaded the driver's `nvapi64.dll`, for everyone who switched Advanced metrics on; "one title" is the order of the owner's first runs (item 45), not a limit in code |
|
||||
| D139 | [`spike-notes/31-reflex-route-d-harness.md`](spike-notes/31-reflex-route-d-harness.md) §The leg with a sleep | before any Overlay code the probe runs a leg with `NvAPI_D3D_SetSleepMode` and `NvAPI_D3D_Sleep` — writes, in the probe's own process, on its own device, in no shipped binary |
|
||||
| D140 | [`20_OPEN_QUESTIONS.md`](20_OPEN_QUESTIONS.md) §M14 | an `nvapi64.dll` loaded from the game's own folder — a replacement, not the driver's — is refused, and the session says why |
|
||||
| D141 | [`20_OPEN_QUESTIONS.md`](20_OPEN_QUESTIONS.md) §M14 | one call into the driver of 2 ms or more switches the Reflex read off until the game exits |
|
||||
| D109 | [`../legal/DISCLAIMER.md`](../legal/DISCLAIMER.md) §5, §5A | asked on 2026-11-11 with both sentences quoted: the Disclaimer goes to 2.15 with the Privacy Policy — PawnIO and the admin mode are no longer "for the CPU temperature" alone; with Advanced metrics on they also read the processor's, the memory's and the motherboard's sensors. The admin mode's disclosure follows (`agent-admin-dialog/2`) |
|
||||
|
||||
---
|
||||
|
||||
@@ -98,3 +98,37 @@ the record of why it was within reach.
|
||||
**Answered 2026-11-13 (owner decision D136): go, to a plan.** The title is Cyberpunk 2077. No code before the plan
|
||||
is approved, and no release that carries the calls before a stop while a game runs has been exercised on
|
||||
0.1.0-beta.46 (owner-only item 44 (d)).
|
||||
|
||||
### The leg with a sleep (owner decision D139) — the table, written before the run
|
||||
|
||||
The plan's review found the largest thing the runs above never touched: **no run set a sleep mode or called
|
||||
`NvAPI_D3D_Sleep`**, and a game that uses Reflex does both, every frame. If the driver makes a getter wait behind
|
||||
the game's sleep, a read on the presenting thread holds a present for as long as the sleep lasts. The owner said:
|
||||
measure it in the probe first (D139). The probe plays the game's part once more — `NvAPI_D3D_SetSleepMode` (low
|
||||
latency on, a minimum interval of 4 166 µs, markers used) and `NvAPI_D3D_Sleep` at the start of every frame, on its
|
||||
own Direct3D 12 device, in its own process. **Both are writes**, as the markers were; no shipped binary contains
|
||||
either, and the sleep mode is switched back off before the device is released.
|
||||
|
||||
| # | What is measured | What it decides |
|
||||
|---|---|---|
|
||||
| S1 | The sleep mode takes: `SetSleepMode` returns OK, the sleep status then reads low-latency on, and a frame takes about the interval | Not OK, or the status does not change → the leg did not exercise a sleep; said so, nothing concluded from S2–S4. |
|
||||
| S2 | The two getters on the thread that sleeps and presents: one `GetLatency` after each of 2000 frames, and 2000 calls back to back | **Median above 60 µs → stop** (NFR-1 at 60 presents a second). **Any call of 2 ms or more → stop**: on a presenting thread that is the latch of D141, in every game that uses Reflex. |
|
||||
| S3 | The getters on **another** thread four times a second for 20 s, and without a pause for 10 s, while the first thread sleeps and presents — against the same two runs on the same device **before** the sleep mode was set | **A fault → stop** (§30). Reads of 2 ms or more that the control does not have → the getter waits behind the sleep: **stop**, and the note says the route reads only games that do not sleep. Reads of 1 ms or more at the same rate as the control → the scheduler, not the sleep. |
|
||||
| S4 | What the report holds once the game sleeps: frames with anything, and the sleep status's fields | Recorded: it is what a real title's report would look like more closely than M5's. An empty report → a sleep mode changes what markers alone gave; recorded, the reader's "nothing reported" covers it. |
|
||||
|
||||
A stop here means no Overlay code is written and the owner is asked again.
|
||||
|
||||
### The leg with a sleep — results
|
||||
|
||||
Three runs of `fl-probe-reflex --real 10` on 2026-11-13 (RTX 5080, driver 32.0.16.2114), the leg after R5.
|
||||
**No stop condition fired.**
|
||||
|
||||
| # | What was seen | Reading |
|
||||
|---|---|---|
|
||||
| S1 | `SetSleepMode` returned OK in all three runs. A frame then took 4 159 µs (the interval asked for is 4 166), 4 037–4 041 of them inside `NvAPI_D3D_Sleep`; no sleep error. The sleep status afterwards: interval 4 166 µs, `bUseGameSleep` 1 — and **`bLowLatencyMode` 0**, although the mode was set with it on. | The sleep was exercised: the thread stood inside it 97 % of the time. **The status's low-latency field is not the flag the game set**, on this driver; why is not known. It is shown as the driver's word, never as "the game switched Reflex on". |
|
||||
| S2 | One `GetLatency` after each of 2000 sleeping frames, on the thread that sleeps and presents: median **2.5 / 2.6 / 2.6 µs**, mean 2.7–2.8, worst 66.9 / 16.8 / 8.0 µs, none of 2 ms. Back to back: median 0.7 µs (worst 10.2 / 81.6 / 4.1); `GetSleepStatus` median 0.2 µs. | Far inside both limits. A read after a frame that slept costs four or five times a read made back to back — a cold cache, by the look of it — and that is the Overlay's case: **about 2.6 µs, once a second**. |
|
||||
| S3 | From another thread while the first slept and presented at 240 frames a second. Four reads a second for 20 s: 80 reads a run, none not OK, none faulted, worst 64 / 82 / 12 µs (the control before the sleep mode: 92 / 209 / 119 µs). Without a pause for 10 s: **10.26 / 10.26 / 10.43 million reads**, none not OK, none faulted, worst 442 / 635 / 286 µs, **none of a millisecond** (the control: 9.97 / 9.94 / 9.89 million, worst 1 605 / 1 390 / 203 µs, one read of a millisecond in two of the three runs). | **The getter does not wait behind the sleep.** Thirty-one million reads were made while another thread was inside the sleep nearly all the time, and none took a millisecond; the slow reads there are belong to the control. |
|
||||
| S4 | The report: sixty-four frames with content. `driverStartTime` is filled in all sixty-four — it was zero in M5, without a sleep mode; `inputSampleTime` in none (the probe sets no input marker). Simulation start to present end 102–151 µs, to GPU end 150–191 µs; `gpuActiveRenderTimeUs` 0. | With a sleep mode the driver span is reported. A reader that treats a zero end point as "span not reported" covers both shapes. |
|
||||
|
||||
**What it does not say**: a game's own sleep, on a game's own threads, with a real frame's work between the sleep
|
||||
and the present; frame generation's pacer; another driver. Those are what the first real title is for (D136).
|
||||
@@ -210,6 +210,17 @@ InstallResult Install(Registry<Capacity>& registry, const std::atomic<std::uint3
|
||||
// BeginQueue() / EndQueue().
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// HOW A BATCH'S ONE APPLY ENDED (owner decision D137). Two install batches in real games took 0.61 s and 1.26 s on
|
||||
// 0.1.0-beta.46 where sixteen others took 0.08-0.26 s, and the log could not say whether either was one long stop of
|
||||
// the threads or an apply that failed part-way and was finished one patch at a time: the fallback wrote a line only
|
||||
// for a patch that failed for good. The caller logs this. `singly` counts the patches handed to the engine one at a
|
||||
// time after the apply said it had failed -- attempts, not stops: the engine makes no stop for one the apply had
|
||||
// already done.
|
||||
struct BatchOutcome {
|
||||
bool applied = true; // the one apply did all it was asked, or there was nothing to apply
|
||||
std::uint32_t singly = 0; // patches then enabled -- or, in the stop, restored -- one at a time
|
||||
};
|
||||
|
||||
// The stop's walk: every committed patch that is still OURS is restored, under one apply; a patch a foreign overlay
|
||||
// has patched over is left exactly as it is (17_HOOK_ENGINE §Unhooking, §H7). The caller has already cleared the
|
||||
// observing flag -- this is the read half of the pair described at the top of this file.
|
||||
@@ -217,7 +228,7 @@ InstallResult Install(Registry<Capacity>& registry, const std::atomic<std::uint3
|
||||
// `ours(target, detour)` -> bool: the bytes at the target are still the jump made for us (fl_patch_check.h).
|
||||
// `report(name, target, wasOurs, restored)` is called once per committed patch, after the gate is released.
|
||||
template <std::uint32_t Capacity, class Hooker, class Ours, class Report>
|
||||
void RestoreAll(const Registry<Capacity>& registry, Hooker&& hooker, Ours&& ours, Report&& report) noexcept {
|
||||
BatchOutcome RestoreAll(const Registry<Capacity>& registry, Hooker&& hooker, Ours&& ours, Report&& report) noexcept {
|
||||
struct Entry {
|
||||
void* target;
|
||||
const char* name;
|
||||
@@ -242,12 +253,14 @@ void RestoreAll(const Registry<Capacity>& registry, Hooker&& hooker, Ours&& ours
|
||||
anyMarked = anyMarked || marked;
|
||||
entries[count++] = Entry{target, name, mine, marked, false};
|
||||
});
|
||||
const bool applied = !anyMarked || hooker.Apply();
|
||||
const bool applied = !anyMarked || hooker.Apply();
|
||||
BatchOutcome outcome{applied, 0u};
|
||||
for (std::uint32_t i = 0; i < count; ++i) {
|
||||
Entry& e = entries[i];
|
||||
if (!e.marked) {
|
||||
continue;
|
||||
}
|
||||
outcome.singly += applied ? 0u : 1u;
|
||||
// The apply stops at the first hook it cannot restore: the ones after it are taken out one at a time, as
|
||||
// every patch was until 0.1.0-beta.46. One that will not come out at all has its mark removed -- it is
|
||||
// enabled, so marking it "enable" leaves nothing to apply.
|
||||
@@ -261,6 +274,7 @@ void RestoreAll(const Registry<Capacity>& registry, Hooker&& hooker, Ours&& ours
|
||||
for (std::uint32_t i = 0; i < count; ++i) {
|
||||
report(entries[i].name, entries[i].target, entries[i].wasOurs, entries[i].restored);
|
||||
}
|
||||
return outcome;
|
||||
}
|
||||
|
||||
// Several patches, registered before any can run, enabled under ONE stop of the threads, and none left in after a
|
||||
@@ -308,11 +322,13 @@ public:
|
||||
return InstallResult::Pending;
|
||||
}
|
||||
|
||||
// Returns how the apply that put the patches IN ended; the apply that takes them out again after a stop that
|
||||
// landed meanwhile is not reported -- every item then reads StoppedDuring.
|
||||
template <class Hooker, class Ours>
|
||||
void Commit(Registry<Capacity>& registry, const std::atomic<std::uint32_t>& observing, Hooker&& hooker,
|
||||
Ours&& ours) noexcept {
|
||||
BatchOutcome Commit(Registry<Capacity>& registry, const std::atomic<std::uint32_t>& observing, Hooker&& hooker,
|
||||
Ours&& ours) noexcept {
|
||||
if (count_ == 0u) {
|
||||
return;
|
||||
return BatchOutcome{};
|
||||
}
|
||||
hooker.BeginQueue();
|
||||
if (observing.load(std::memory_order_seq_cst) == 0u) {
|
||||
@@ -323,7 +339,7 @@ public:
|
||||
items_[i].result = InstallResult::StoppedDuring;
|
||||
}
|
||||
hooker.EndQueue();
|
||||
return;
|
||||
return BatchOutcome{};
|
||||
}
|
||||
for (std::uint32_t i = 0; i < count_; ++i) {
|
||||
if (!hooker.QueueEnable(items_[i].target)) {
|
||||
@@ -331,12 +347,14 @@ public:
|
||||
items_[i].result = InstallResult::EnableFailed;
|
||||
}
|
||||
}
|
||||
const bool applied = hooker.Apply();
|
||||
const bool applied = hooker.Apply();
|
||||
BatchOutcome outcome{applied, 0u};
|
||||
for (std::uint32_t i = 0; i < count_; ++i) {
|
||||
Item& item = items_[i];
|
||||
if (item.result != InstallResult::Pending) {
|
||||
continue;
|
||||
}
|
||||
outcome.singly += applied ? 0u : 1u;
|
||||
// The ENGINE says whether the hook is enabled, not the bytes at the target: a foreign overlay that
|
||||
// patched over us a moment after the apply would read as "not in", and taking that for a failure would
|
||||
// mark a restore nobody had compared (§H7). The apply stops at the first hook that fails, so the ones
|
||||
@@ -353,7 +371,7 @@ public:
|
||||
hooker.EndQueue();
|
||||
|
||||
if (observing.load(std::memory_order_seq_cst) != 0u) {
|
||||
return;
|
||||
return outcome;
|
||||
}
|
||||
// The stop ran while the batch went in -- the re-read of Install, for the group. Its walk either saw the
|
||||
// committed slots and restored the patches, and then they are no longer ours and nothing is marked, or it had
|
||||
@@ -382,6 +400,7 @@ public:
|
||||
item.result = InstallResult::StoppedDuring;
|
||||
}
|
||||
hooker.EndQueue();
|
||||
return outcome;
|
||||
}
|
||||
|
||||
std::uint32_t Count() const noexcept { return count_; }
|
||||
|
||||
@@ -982,6 +982,12 @@ constexpr DWORD kWatchdogIntervalMs = 1000;
|
||||
std::atomic<uint32_t> g_stopLogged{0};
|
||||
void WakeWatchdog() noexcept;
|
||||
|
||||
// The `b` of a PATCH_BATCH line: the patches the batch put in or took out in the low half, the ones it had to do one
|
||||
// at a time in the high half (0 for a batch that went under its one apply).
|
||||
uint32_t PatchBatchWord(uint32_t done, uint32_t singly) noexcept {
|
||||
return (done & 0xFFFFu) | ((singly & 0xFFFFu) << 16);
|
||||
}
|
||||
|
||||
void StopObserving(uint32_t reason) noexcept {
|
||||
// Compare-exchange, not a plain check-then-set: the watchdog and a game
|
||||
// thread inside a hook body can both arrive here, and the restore must run
|
||||
@@ -1010,9 +1016,9 @@ void StopObserving(uint32_t reason) noexcept {
|
||||
// patch: about 160 ms each, two to three seconds for a Streamline title, possibly on the thread that presents.
|
||||
// RestoreAll marks the patches that are still ours and applies the marks together (fl_patch_registry.h says what
|
||||
// may and may not be marked, and why). The lines below are written after the gate is released.
|
||||
const int64_t began = QpcNow();
|
||||
uint32_t restored = 0;
|
||||
fl::patch::RestoreAll(
|
||||
const int64_t began = QpcNow();
|
||||
uint32_t restored = 0;
|
||||
const fl::patch::BatchOutcome outcome = fl::patch::RestoreAll(
|
||||
g_patches, MinHookEngine{},
|
||||
[](const void* target, const void* detour) noexcept { return fl::patch::StillOurs(target, detour); },
|
||||
[&restored](const char* name, void* target, bool wasOurs, bool ok) noexcept {
|
||||
@@ -1023,8 +1029,10 @@ void StopObserving(uint32_t reason) noexcept {
|
||||
LogNote(kLogUnhookDeclined, name, 0u, reinterpret_cast<uint64_t>(target));
|
||||
}
|
||||
});
|
||||
// a = the microseconds the walk and its one apply took, b = how many patches it restored.
|
||||
LogNote(kLogPatchBatch, "restore", MicrosSince(began), restored);
|
||||
// a = the microseconds the walk and its one apply took; b = how many patches it restored in its low half and, in
|
||||
// its high half, how many had to be restored one at a time because the apply said it had failed (D137).
|
||||
LogNote(kLogPatchBatch, outcome.applied ? "restore" : "restore singly", MicrosSince(began),
|
||||
PatchBatchWord(restored, outcome.singly));
|
||||
if (g_state != nullptr) {
|
||||
std::atomic_ref<uint32_t> status{g_state->status};
|
||||
status.store(reason, std::memory_order_release);
|
||||
@@ -1093,10 +1101,11 @@ void CommitPatchBatch() noexcept {
|
||||
if (count == 0u) {
|
||||
return;
|
||||
}
|
||||
const int64_t began = QpcNow();
|
||||
g_batch.Commit(g_patches, g_observing, MinHookEngine{}, [](const void* target, const void* detour) noexcept {
|
||||
return fl::patch::StillOurs(target, detour);
|
||||
});
|
||||
const int64_t began = QpcNow();
|
||||
const fl::patch::BatchOutcome outcome =
|
||||
g_batch.Commit(g_patches, g_observing, MinHookEngine{}, [](const void* target, const void* detour) noexcept {
|
||||
return fl::patch::StillOurs(target, detour);
|
||||
});
|
||||
const uint32_t micros = MicrosSince(began);
|
||||
uint32_t installed = 0;
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
@@ -1116,8 +1125,11 @@ void CommitPatchBatch() noexcept {
|
||||
}
|
||||
++installed;
|
||||
}
|
||||
// a = the microseconds the one apply took, b = how many patches it put in.
|
||||
LogNote(kLogPatchBatch, "install", micros, installed);
|
||||
// a = the microseconds the one apply took; b = how many patches went in in its low half and, in its high half,
|
||||
// how many were enabled one at a time because the apply said it had failed (D137). "install" is one stop of the
|
||||
// game's threads; "install singly" is that stop and then up to one more for each of those.
|
||||
LogNote(kLogPatchBatch, outcome.applied ? "install" : "install singly", micros,
|
||||
PatchBatchWord(installed, outcome.singly));
|
||||
g_batch.Clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -7620,17 +7620,23 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation,
|
||||
unsigned long long restoreMicros = 0;
|
||||
unsigned long long installedLazily = 0;
|
||||
unsigned long long restoredLines = 0;
|
||||
// `b` holds the patches in its low half; its high half counts the ones a failed apply left to be done one at a
|
||||
// time (owner decision D137), and the line then reads "install singly" / "restore singly". Neither happens here.
|
||||
eachLine("PATCH_BATCH install", [&](const std::string& line) {
|
||||
++installBatches;
|
||||
installedByBatch += field(line, " b=0x", 16);
|
||||
WARN("an install batch put " << field(line, " b=0x", 16) << " patches in, in " << field(line, " a=", 10)
|
||||
<< " us");
|
||||
installedByBatch += field(line, " b=0x", 16) & 0xFFFFull;
|
||||
CHECK((field(line, " b=0x", 16) >> 16) == 0ull);
|
||||
WARN("an install batch put " << (field(line, " b=0x", 16) & 0xFFFFull) << " patches in, in "
|
||||
<< field(line, " a=", 10) << " us");
|
||||
});
|
||||
eachLine("PATCH_BATCH restore", [&](const std::string& line) {
|
||||
++restoreBatches;
|
||||
restoredByBatch += field(line, " b=0x", 16);
|
||||
restoredByBatch += field(line, " b=0x", 16) & 0xFFFFull;
|
||||
CHECK((field(line, " b=0x", 16) >> 16) == 0ull);
|
||||
restoreMicros += field(line, " a=", 10);
|
||||
});
|
||||
CHECK(text.find("install singly") == std::string::npos);
|
||||
CHECK(text.find("restore singly") == std::string::npos);
|
||||
eachLine("HOOK_INSTALLED ", [&](const std::string& line) {
|
||||
if (line.find("dxgi!") == std::string::npos && line.find("kernelbase!") == std::string::npos &&
|
||||
line.find("opengl32!") == std::string::npos) {
|
||||
|
||||
@@ -565,7 +565,9 @@ TEST_CASE("a batch puts three patches in under one apply, and the stop takes the
|
||||
CHECK(Third(3) == thirdPlain);
|
||||
CHECK(registry.LiveCount() == 0u);
|
||||
|
||||
batch.Commit(registry, observing, RealQueue{}, RealOurs);
|
||||
const fl::patch::BatchOutcome in = batch.Commit(registry, observing, RealQueue{}, RealOurs);
|
||||
CHECK(in.applied); // one apply did it (D137: the caller's log line says so)
|
||||
CHECK(in.singly == 0u);
|
||||
for (std::uint32_t i = 0; i < batch.Count(); ++i) {
|
||||
CHECK(batch.At(i).result == InstallResult::Installed);
|
||||
}
|
||||
@@ -579,13 +581,15 @@ TEST_CASE("a batch puts three patches in under one apply, and the stop takes the
|
||||
|
||||
// The stop: one walk, one apply, every patch reported as ours and restored.
|
||||
observing.store(0u);
|
||||
int restored = 0;
|
||||
int declined = 0;
|
||||
fl::patch::RestoreAll(registry, RealQueue{}, RealOurs,
|
||||
[&restored, &declined](const char*, void*, bool wasOurs, bool ok) noexcept {
|
||||
restored += (wasOurs && ok) ? 1 : 0;
|
||||
declined += wasOurs ? 0 : 1;
|
||||
});
|
||||
int restored = 0;
|
||||
int declined = 0;
|
||||
const fl::patch::BatchOutcome out = fl::patch::RestoreAll(
|
||||
registry, RealQueue{}, RealOurs, [&restored, &declined](const char*, void*, bool wasOurs, bool ok) noexcept {
|
||||
restored += (wasOurs && ok) ? 1 : 0;
|
||||
declined += wasOurs ? 0 : 1;
|
||||
});
|
||||
CHECK(out.applied);
|
||||
CHECK(out.singly == 0u);
|
||||
CHECK(restored == 3);
|
||||
CHECK(declined == 0);
|
||||
CHECK(First(3) == firstPlain);
|
||||
@@ -664,8 +668,12 @@ TEST_CASE("an apply that fails halfway costs one patch, and leaves no mark for a
|
||||
REQUIRE(batch.Add(registry, observing, engine, &g_c, &g_detour, nullptr, "c", nullptr, 0u) ==
|
||||
InstallResult::Pending);
|
||||
CHECK_FALSE(model.AMarkIsStanding()); // adding marks nothing
|
||||
batch.Commit(registry, observing, engine, ModelOurs{&model});
|
||||
const fl::patch::BatchOutcome outcome = batch.Commit(registry, observing, engine, ModelOurs{&model});
|
||||
|
||||
// D137: the apply said it failed, so all three were handed to the engine one at a time -- a, which the apply had
|
||||
// already put in, among them: the count is of attempts, and the engine makes no stop for a patch that is in.
|
||||
CHECK_FALSE(outcome.applied);
|
||||
CHECK(outcome.singly == 3u);
|
||||
CHECK(batch.At(0).result == InstallResult::Installed);
|
||||
CHECK(batch.At(1).result == InstallResult::EnableFailed);
|
||||
CHECK(batch.At(2).result == InstallResult::Installed); // the apply stopped at b; c went in by itself
|
||||
@@ -700,7 +708,9 @@ TEST_CASE("an apply that does nothing at all still gets every patch in, one at a
|
||||
InstallResult::Pending);
|
||||
REQUIRE(batch.Add(registry, observing, engine, &g_b, &g_detour, nullptr, "b", nullptr, 0u) ==
|
||||
InstallResult::Pending);
|
||||
batch.Commit(registry, observing, engine, ModelOurs{&model});
|
||||
const fl::patch::BatchOutcome in = batch.Commit(registry, observing, engine, ModelOurs{&model});
|
||||
CHECK_FALSE(in.applied); // what the Overlay logs as "install singly", with the two in the line's high half
|
||||
CHECK(in.singly == 2u);
|
||||
CHECK(batch.At(0).result == InstallResult::Installed);
|
||||
CHECK(batch.At(1).result == InstallResult::Installed);
|
||||
CHECK(registry.LiveCount() == 2u);
|
||||
@@ -708,10 +718,12 @@ TEST_CASE("an apply that does nothing at all still gets every patch in, one at a
|
||||
|
||||
// And the stop, with the same failing apply, still takes both out.
|
||||
observing.store(0u);
|
||||
int restored = 0;
|
||||
fl::patch::RestoreAll(
|
||||
int restored = 0;
|
||||
const fl::patch::BatchOutcome out = fl::patch::RestoreAll(
|
||||
registry, engine, ModelOurs{&model},
|
||||
[&restored](const char*, void*, bool wasOurs, bool ok) noexcept { restored += (wasOurs && ok) ? 1 : 0; });
|
||||
CHECK_FALSE(out.applied); // "restore singly"
|
||||
CHECK(out.singly == 2u);
|
||||
CHECK(restored == 2);
|
||||
CHECK_FALSE(model.Enabled(&g_a));
|
||||
CHECK_FALSE(model.Enabled(&g_b));
|
||||
@@ -734,7 +746,9 @@ TEST_CASE("a stop before the batch commits enables nothing; a stop inside its ap
|
||||
REQUIRE(batch.Add(registry, observing, engine, &g_b, &g_detour, nullptr, "b", nullptr, 0u) ==
|
||||
InstallResult::Pending);
|
||||
observing.store(0u);
|
||||
batch.Commit(registry, observing, engine, ModelOurs{&model});
|
||||
const fl::patch::BatchOutcome outcome = batch.Commit(registry, observing, engine, ModelOurs{&model});
|
||||
CHECK(outcome.applied); // nothing was asked of an apply, so nothing failed
|
||||
CHECK(outcome.singly == 0u);
|
||||
CHECK(batch.At(0).result == InstallResult::StoppedDuring);
|
||||
CHECK(batch.At(1).result == InstallResult::StoppedDuring);
|
||||
CHECK(model.applies == 0); // nothing was marked, nothing applied
|
||||
|
||||
@@ -400,6 +400,8 @@ struct Poller {
|
||||
std::uint32_t faults = 0;
|
||||
double worstSeconds = 0.0;
|
||||
std::uint32_t emptyReports = 0;
|
||||
std::uint32_t atLeast1Ms = 0; // reads that took a millisecond or more, and two (R6)
|
||||
std::uint32_t atLeast2Ms = 0;
|
||||
};
|
||||
|
||||
DWORD WINAPI PollerThread(LPVOID p) noexcept {
|
||||
@@ -422,6 +424,8 @@ DWORD WINAPI PollerThread(LPVOID p) noexcept {
|
||||
if (took > poll->worstSeconds) {
|
||||
poll->worstSeconds = took;
|
||||
}
|
||||
poll->atLeast1Ms += took >= 0.001 ? 1u : 0u;
|
||||
poll->atLeast2Ms += took >= 0.002 ? 1u : 0u;
|
||||
const std::uint32_t interval = poll->intervalMs.load(std::memory_order_relaxed);
|
||||
if (interval != 0u) {
|
||||
Sleep(interval);
|
||||
@@ -475,6 +479,208 @@ double FramesPerSecond11(Game& g, Dx11& dx, double seconds) noexcept {
|
||||
return static_cast<double>(frames) / (QpcSeconds() - t0);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// R6 (owner decision D139; spike-notes §31, "The leg with a sleep"): THE GETTERS WHILE THE GAME SLEEPS.
|
||||
// No run above set a sleep mode or called NvAPI_D3D_Sleep, and a game that uses Reflex does both every frame. If the
|
||||
// driver makes a getter wait behind the game's sleep, a read on the presenting thread holds a present for as long as
|
||||
// the sleep lasts. The probe is the game once more: BOTH CALLS BELOW ARE WRITES, made on the probe's own device in its
|
||||
// own process; no shipped binary contains either, and the mode is switched back off before the device goes.
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
constexpr unsigned int kIdSetSleepMode = 0xac1ca9e0u; // nvapi_interface.h: NvAPI_D3D_SetSleepMode -- the game's call
|
||||
constexpr unsigned int kIdSleep = 0x852cd1d2u; // NvAPI_D3D_Sleep -- the game's call
|
||||
constexpr unsigned int kSleepIntervalUs = 4166u; // a 240-a-second limit: every frame really sleeps
|
||||
|
||||
using SetSleepModeFn = NvAPI_Status(__cdecl*)(IUnknown*, NV_SET_SLEEP_MODE_PARAMS*);
|
||||
using SleepFn = NvAPI_Status(__cdecl*)(IUnknown*);
|
||||
|
||||
struct Sleeper {
|
||||
SleepFn sleep = nullptr;
|
||||
IUnknown* device = nullptr;
|
||||
bool on = false;
|
||||
std::uint32_t errors = 0;
|
||||
std::uint32_t calls = 0;
|
||||
double seconds = 0.0; // spent inside NvAPI_D3D_Sleep
|
||||
};
|
||||
|
||||
// One frame of a game that uses Reflex: the sleep first, then the markers and the present.
|
||||
void SleepingFrame12(Game& g, Dx12& dx, Sleeper& s) noexcept {
|
||||
if (s.on) {
|
||||
const double t0 = QpcSeconds();
|
||||
if (s.sleep(s.device) != NVAPI_OK) {
|
||||
++s.errors;
|
||||
}
|
||||
s.seconds += QpcSeconds() - t0;
|
||||
++s.calls;
|
||||
}
|
||||
Frame12(g, dx);
|
||||
}
|
||||
|
||||
struct Beside {
|
||||
std::uint32_t calls = 0;
|
||||
std::uint32_t notOk = 0;
|
||||
std::uint32_t faults = 0;
|
||||
std::uint32_t atLeast1Ms = 0;
|
||||
std::uint32_t atLeast2Ms = 0;
|
||||
double worstUs = 0.0;
|
||||
double framesPerSecond = 0.0;
|
||||
};
|
||||
|
||||
// The getters on another thread every `intervalMs` (0: without a pause) for `seconds`, while this thread is the game.
|
||||
Beside PollBeside(const fl::reflex::Api& api, Game& g, Dx12& dx, Sleeper& s, std::uint32_t intervalMs,
|
||||
double seconds) noexcept {
|
||||
Poller poll{};
|
||||
poll.api = api;
|
||||
poll.device = dx.device;
|
||||
poll.intervalMs.store(intervalMs);
|
||||
HANDLE thread = CreateThread(nullptr, 0, &PollerThread, &poll, 0, nullptr);
|
||||
const double t0 = QpcSeconds();
|
||||
std::uint32_t frames = 0;
|
||||
while (QpcSeconds() - t0 < seconds) {
|
||||
SleepingFrame12(g, dx, s);
|
||||
++frames;
|
||||
}
|
||||
const double took = QpcSeconds() - t0;
|
||||
poll.quit.store(1u);
|
||||
if (thread != nullptr) {
|
||||
WaitForSingleObject(thread, 5000);
|
||||
CloseHandle(thread);
|
||||
}
|
||||
Beside out{};
|
||||
out.calls = poll.calls;
|
||||
out.notOk = poll.notOk;
|
||||
out.faults = poll.faults;
|
||||
out.atLeast1Ms = poll.atLeast1Ms;
|
||||
out.atLeast2Ms = poll.atLeast2Ms;
|
||||
out.worstUs = poll.worstSeconds * 1e6;
|
||||
out.framesPerSecond = static_cast<double>(frames) / took;
|
||||
return out;
|
||||
}
|
||||
|
||||
void PrintBeside(const char* label, const Beside& b) noexcept {
|
||||
std::printf(
|
||||
"%-52s %u reads, %u not OK, %u faulted, worst %.1f us, >= 1 ms: %u, >= 2 ms: %u; %.0f frames a second\n", label,
|
||||
b.calls, b.notOk, b.faults, b.worstUs, b.atLeast1Ms, b.atLeast2Ms, b.framesPerSecond);
|
||||
}
|
||||
|
||||
void RunSleepLeg(IDXGIFactory4* factory, IDXGIAdapter1* adapter, const fl::reflex::Api& api,
|
||||
fl::reflex::QueryInterfaceFn query, SetMarkerFn setMarker) noexcept {
|
||||
const auto setMode = reinterpret_cast<SetSleepModeFn>(query(kIdSetSleepMode));
|
||||
Sleeper sleeper{};
|
||||
sleeper.sleep = reinterpret_cast<SleepFn>(query(kIdSleep));
|
||||
Dx12 dx{};
|
||||
if (setMode == nullptr || sleeper.sleep == nullptr || !MakeDx12(factory, adapter, dx)) {
|
||||
std::printf("R6 SKIPPED: no sleep functions from this nvapi64.dll, or no Direct3D 12 device\n");
|
||||
FreeDx12(dx);
|
||||
return;
|
||||
}
|
||||
sleeper.device = dx.device;
|
||||
Game game{};
|
||||
game.setMarker = setMarker;
|
||||
game.markerDevice = dx.device;
|
||||
game.frame = 300000;
|
||||
static NV_LATENCY_RESULT_PARAMS report;
|
||||
NV_GET_SLEEP_STATUS_PARAMS status{};
|
||||
|
||||
// THE CONTROL: the same device, the same two pollers, before any sleep mode.
|
||||
for (int i = 0; i < 300; ++i) {
|
||||
SleepingFrame12(game, dx, sleeper);
|
||||
}
|
||||
const Beside controlSlow = PollBeside(api, game, dx, sleeper, 250u, 20.0);
|
||||
const Beside controlFast = PollBeside(api, game, dx, sleeper, 0u, 10.0);
|
||||
PrintBeside("R6 control, no sleep mode, 4 reads a second:", controlSlow);
|
||||
PrintBeside("R6 control, no sleep mode, reads without a pause:", controlFast);
|
||||
|
||||
// S1. THE GAME SETS A SLEEP MODE AND SLEEPS EVERY FRAME.
|
||||
NV_SET_SLEEP_MODE_PARAMS mode{};
|
||||
mode.version = NV_SET_SLEEP_MODE_PARAMS_VER1;
|
||||
mode.bLowLatencyMode = 1;
|
||||
mode.minimumIntervalUs = kSleepIntervalUs;
|
||||
mode.bUseMarkersToOptimize = 1;
|
||||
const NvAPI_Status set = setMode(dx.device, &mode);
|
||||
sleeper.on = set == NVAPI_OK;
|
||||
const double began = QpcSeconds();
|
||||
for (int i = 0; i < 600; ++i) {
|
||||
SleepingFrame12(game, dx, sleeper);
|
||||
}
|
||||
const double frameUs = (QpcSeconds() - began) / 600.0 * 1e6;
|
||||
const NvAPI_Status s1 = fl::reflex::ReadSleepStatus(api, dx.device, status);
|
||||
std::printf("S1 SetSleepMode %d; 600 frames: %.1f us a frame, %.1f us of it inside Sleep, %u sleep error(s)\n",
|
||||
static_cast<int>(set), frameUs,
|
||||
sleeper.calls != 0u ? sleeper.seconds / static_cast<double>(sleeper.calls) * 1e6 : 0.0, sleeper.errors);
|
||||
std::printf("S1 sleep status %d: lowLatency %u, fsVrr %u, cplVsync %u, interval %u us, gameSleep %u, iFlip %u, "
|
||||
"fgMultiplier %u\n",
|
||||
static_cast<int>(s1), static_cast<unsigned>(status.bLowLatencyMode),
|
||||
static_cast<unsigned>(status.bFsVrr), static_cast<unsigned>(status.bCplVsyncOn),
|
||||
static_cast<unsigned>(status.sleepIntervalUs), static_cast<unsigned>(status.bUseGameSleep),
|
||||
static_cast<unsigned>(status.bFullscreenIFlip), static_cast<unsigned>(status.fgMultiplier));
|
||||
|
||||
// S4. What the report holds once the game sleeps.
|
||||
PrintDigest("S4 D3D12, sleeping, 600 frames:", fl::reflex::ReadLatency(api, dx.device, report), report);
|
||||
{
|
||||
std::uint32_t input = 0;
|
||||
std::uint32_t driverStart = 0;
|
||||
std::uint32_t gpuEnd = 0;
|
||||
for (const auto& r : report.frameReport) {
|
||||
input += r.inputSampleTime != 0u ? 1u : 0u;
|
||||
driverStart += r.driverStartTime != 0u ? 1u : 0u;
|
||||
gpuEnd += r.gpuRenderEndTime != 0u ? 1u : 0u;
|
||||
}
|
||||
std::printf("S4 of 64 frames: inputSampleTime in %u, driverStartTime in %u, gpuRenderEndTime in %u\n", input,
|
||||
driverStart, gpuEnd);
|
||||
}
|
||||
|
||||
// S2. THE GETTERS ON THE THREAD THAT SLEEPS AND PRESENTS: one read after each frame's present -- where the Overlay
|
||||
// would make it -- and then back to back.
|
||||
{
|
||||
static double samples[2000];
|
||||
double sum = 0.0;
|
||||
double worst = 0.0;
|
||||
std::uint32_t slow = 0;
|
||||
for (double& sample : samples) {
|
||||
SleepingFrame12(game, dx, sleeper);
|
||||
const double t0 = QpcSeconds();
|
||||
fl::reflex::ReadLatency(api, dx.device, report);
|
||||
sample = (QpcSeconds() - t0) * 1e6;
|
||||
sum += sample;
|
||||
worst = sample > worst ? sample : worst;
|
||||
slow += sample >= 2000.0 ? 1u : 0u;
|
||||
}
|
||||
for (int i = 1; i < 2000; ++i) { // insertion sort, as Measure does
|
||||
const double v = samples[i];
|
||||
int j = i - 1;
|
||||
while (j >= 0 && samples[j] > v) {
|
||||
samples[j + 1] = samples[j];
|
||||
--j;
|
||||
}
|
||||
samples[j + 1] = v;
|
||||
}
|
||||
std::printf("S2 GetLatency after each of 2000 sleeping frames, us: mean %.2f, median %.2f, worst %.2f, "
|
||||
">= 2 ms: %u\n",
|
||||
sum / 2000.0, samples[1000], worst, slow);
|
||||
}
|
||||
const Cost latency = Measure(2000, [&]() noexcept { fl::reflex::ReadLatency(api, dx.device, report); });
|
||||
const Cost sleepStatus = Measure(2000, [&]() noexcept { fl::reflex::ReadSleepStatus(api, dx.device, status); });
|
||||
std::printf("S2 GetLatency back to back, us: mean %.2f, median %.2f, worst %.2f (2000 calls)\n", latency.mean,
|
||||
latency.median, latency.worst);
|
||||
std::printf("S2 GetSleepStatus back to back, us: mean %.2f, median %.2f, worst %.2f (2000 calls)\n",
|
||||
sleepStatus.mean, sleepStatus.median, sleepStatus.worst);
|
||||
|
||||
// S3. THE GETTERS ON ANOTHER THREAD WHILE THIS ONE SLEEPS AND PRESENTS -- a game's sleep is often on a thread that
|
||||
// is not the one that presents.
|
||||
const Beside sleepSlow = PollBeside(api, game, dx, sleeper, 250u, 20.0);
|
||||
const Beside sleepFast = PollBeside(api, game, dx, sleeper, 0u, 10.0);
|
||||
PrintBeside("S3 sleeping, 4 reads a second:", sleepSlow);
|
||||
PrintBeside("S3 sleeping, reads without a pause:", sleepFast);
|
||||
std::printf("S3 marker errors %u (last status %d), sleep errors %u\n", game.markerErrors,
|
||||
static_cast<int>(game.lastMarkerStatus), sleeper.errors);
|
||||
|
||||
// The mode goes back off before the device does.
|
||||
NV_SET_SLEEP_MODE_PARAMS off{};
|
||||
off.version = NV_SET_SLEEP_MODE_PARAMS_VER1;
|
||||
std::printf("R6 SetSleepMode back off: %d\n", static_cast<int>(setMode(dx.device, &off)));
|
||||
FreeDx12(dx);
|
||||
}
|
||||
|
||||
int RunReal(int pollSeconds) noexcept {
|
||||
IDXGIFactory4* factory = nullptr;
|
||||
if (FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory4), reinterpret_cast<void**>(&factory)))) {
|
||||
@@ -685,6 +891,9 @@ int RunReal(int pollSeconds) noexcept {
|
||||
std::printf("R5 no Direct3D 12 device on the NVIDIA adapter\n");
|
||||
}
|
||||
|
||||
// R6. The getters while the game sleeps (D139).
|
||||
RunSleepLeg(factory, adapter, api, query, game.setMarker);
|
||||
|
||||
FreeDx11(dx11);
|
||||
if (unload != nullptr) {
|
||||
std::printf("NvAPI_Unload: %d\n", static_cast<int>(unload()));
|
||||
|
||||
Reference in new issue
Block a user