Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a14330059
|
||
|
|
96cb45605d | ||
|
|
283e8b632e | ||
|
|
37c013e5e9 | ||
|
|
b875be8f0d | ||
|
|
a6b95e8bc2 | ||
|
|
d46a32c166 |
No files matched your search
+1
-1
@@ -9,7 +9,7 @@ barrier. It is written for the person who has just met one; the details for deve
|
||||
FrameLedger is a desktop program: its own window, its dialogs, its document windows, the icon by the clock and the
|
||||
notices Windows shows for it. It draws nothing inside a game, so it cannot make a game itself any easier to use.
|
||||
|
||||
*Beta software: this page describes version 0.1.0-beta.40. In the app: Help ▸ Accessibility.*
|
||||
*Beta software: this page describes version 0.1.0-beta.41. In the app: Help ▸ Accessibility.*
|
||||
|
||||
## What FrameLedger aims for
|
||||
|
||||
|
||||
+15
-3
@@ -37,9 +37,20 @@ numeric core and does not move; the heading is the full version — corrected 20
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Two comparisons in the Advanced-metrics code say what they mean.** Whether a game gave FSR one field of view or
|
||||
a range of them was decided by comparing two decimal numbers for equality; it is now decided by comparing the two
|
||||
stored values bit for bit. Nothing you see changes. (Found by SonarCloud after 0.1.0-beta.40 was merged.)
|
||||
- **The part inside the game can no longer leave a hook in after it has stopped.** Two gaps in how the Overlay keeps
|
||||
track of its own patches, found by reading the code and not by a failure: a patch made while the table of patches
|
||||
was full would have been made anyway and never taken out, and a stop that arrived at the exact moment a hook was
|
||||
going in could miss it. A patch now takes its place in the table before it is made — no place, no patch — and is
|
||||
recorded before it can run, so the stop either removes it or the installer does. A patch that could not be made
|
||||
is written to the Overlay's log with the reason, where it used to be silent. No hook's own code changed.
|
||||
|
||||
- **A session that saw two upscalers is named after the one it ran, with that one's quality and render size.** The
|
||||
session's upscaler used to be the first one FrameLedger saw named, while the quality mode and the render size
|
||||
came from whichever frames carried them. A game that evaluated DLSS briefly and then ran FSR was stored as "DLSS"
|
||||
with FSR's quality and FSR's render size. The name is now the technology named on the most frames, the quality
|
||||
and the size are read from that technology's frames only, and such a session is marked "settings changed during
|
||||
session". What that technology did not say reads N/A rather than borrowing the other's value. Sessions already
|
||||
stored are not rewritten.
|
||||
|
||||
## Releases
|
||||
|
||||
@@ -47,6 +58,7 @@ Newest first. Each file holds that release's section exactly as it stood here.
|
||||
|
||||
| Version | Date | Notes |
|
||||
|---|---|---|
|
||||
| `0.1.0-beta.41` | 2026-11-12 | [`docs/changelog/0.1.0-beta.41.md`](docs/changelog/0.1.0-beta.41.md) |
|
||||
| `0.1.0-beta.40` | 2026-11-12 | [`docs/changelog/0.1.0-beta.40.md`](docs/changelog/0.1.0-beta.40.md) |
|
||||
| `0.1.0-beta.39` | 2026-11-11 | [`docs/changelog/0.1.0-beta.39.md`](docs/changelog/0.1.0-beta.39.md) |
|
||||
| `0.1.0-beta.38` | 2026-11-11 | [`docs/changelog/0.1.0-beta.38.md`](docs/changelog/0.1.0-beta.38.md) |
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ hooking on for — and reading the graphics calls the game makes. That is why it
|
||||
resolution, the upscaler, frame generation and ray tracing apart. It is also where its limits come from. This
|
||||
page lists them in plain words; each item links to the document that has the details.
|
||||
|
||||
*Beta software: this page describes version 0.1.0-beta.40.*
|
||||
*Beta software: this page describes version 0.1.0-beta.41.*
|
||||
|
||||
## Games it will not measure
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ app too (Help ▸ User guide, Help ▸ Limitations, Help ▸ Accessibility), and
|
||||
|
||||
<!-- accuracy-block:begin -->
|
||||
> ⚠ **What FrameLedger actually measures today — 2026-11-11.** The software is a beta; its latest
|
||||
> **beta is `0.1.0-beta.40`** (2026-11-12), an unsigned installer built from that tag with its
|
||||
> **beta is `0.1.0-beta.41`** (2026-11-12), an unsigned installer built from that tag with its
|
||||
> checksums published beside it (alphas — experimental builds that try a newer .NET — are published apart). The source holds the desktop app
|
||||
> (library, store import, charts, settings) and the background Agent, which records a session when a
|
||||
> game in the library runs (unless you switched its recording off), injects only into games you enabled
|
||||
@@ -191,7 +191,7 @@ Elevation is **optional — for everything.** Hooked capture is the normal path
|
||||
|
||||
## Install
|
||||
|
||||
> **The latest beta is `v0.1.0-beta.40` (2026-11-12); before it `v0.1.0-beta.39` (2026-11-11), `v0.1.0-beta.38` (2026-11-11), `v0.1.0-beta.37` (2026-11-11), `v0.1.0-beta.36` (2026-11-10), `v0.1.0-beta.35` (2026-11-09), `v0.1.0-beta.34` (2026-11-06), `v0.1.0-beta.33` (2026-11-03), `v0.1.0-beta.32` (2026-10-31), `v0.1.0-beta.31` (2026-10-26), `v0.1.0-beta.30` (2026-10-26), `v0.1.0-beta.29` (2026-10-25), `v0.1.0-beta.28` (2026-10-20), `v0.1.0-beta.27` (2026-10-20), `v0.1.0-beta.26` (2026-10-19), `v0.1.0-beta.25` (2026-10-19), `v0.1.0-beta.24` (2026-10-19), `v0.1.0-beta.23` (2026-10-14), `v0.1.0-beta.22` (2026-10-13), `v0.1.0-beta.21` (2026-10-13), `v0.1.0-beta.20` (2026-10-12), `v0.1.0-beta.19` (2026-10-12), `v0.1.0-beta.18` (2026-10-07), `v0.1.0-beta.17` (2026-10-07), `v0.1.0-beta.16` (2026-10-06), `v0.1.0-beta.15` (2026-10-06), `v0.1.0-beta.14` (2026-10-06), `v0.1.0-beta.13` (2026-10-04), `v0.1.0-beta.12` (2026-10-04), `v0.1.0-beta.11` (2026-10-03), `v0.1.0-beta.10` (2026-09-28), `v0.1.0-beta.9` (2026-09-26), `v0.1.0-beta.8` (2026-09-25), `v0.1.0-beta.7` (2026-09-23), `v0.1.0-beta.6` (2026-09-23), `v0.1.0-beta.5` (2026-09-22), `v0.1.0-beta.4` (2026-09-21), `v0.1.0-beta.3` (2026-09-21), `v0.1.0-beta.2` (2026-09-17) and `v0.1.0-beta.1` (2026-09-16).** They are pre-releases: read the notes of the one you install — `CHANGELOG.md` links each release's own file under `docs/changelog/` — for what it measures, what it does not yet, and how to update, before installing. A source build is `docs/12_BUILD.md`.
|
||||
> **The latest beta is `v0.1.0-beta.41` (2026-11-12); before it `v0.1.0-beta.40` (2026-11-12), `v0.1.0-beta.39` (2026-11-11), `v0.1.0-beta.38` (2026-11-11), `v0.1.0-beta.37` (2026-11-11), `v0.1.0-beta.36` (2026-11-10), `v0.1.0-beta.35` (2026-11-09), `v0.1.0-beta.34` (2026-11-06), `v0.1.0-beta.33` (2026-11-03), `v0.1.0-beta.32` (2026-10-31), `v0.1.0-beta.31` (2026-10-26), `v0.1.0-beta.30` (2026-10-26), `v0.1.0-beta.29` (2026-10-25), `v0.1.0-beta.28` (2026-10-20), `v0.1.0-beta.27` (2026-10-20), `v0.1.0-beta.26` (2026-10-19), `v0.1.0-beta.25` (2026-10-19), `v0.1.0-beta.24` (2026-10-19), `v0.1.0-beta.23` (2026-10-14), `v0.1.0-beta.22` (2026-10-13), `v0.1.0-beta.21` (2026-10-13), `v0.1.0-beta.20` (2026-10-12), `v0.1.0-beta.19` (2026-10-12), `v0.1.0-beta.18` (2026-10-07), `v0.1.0-beta.17` (2026-10-07), `v0.1.0-beta.16` (2026-10-06), `v0.1.0-beta.15` (2026-10-06), `v0.1.0-beta.14` (2026-10-06), `v0.1.0-beta.13` (2026-10-04), `v0.1.0-beta.12` (2026-10-04), `v0.1.0-beta.11` (2026-10-03), `v0.1.0-beta.10` (2026-09-28), `v0.1.0-beta.9` (2026-09-26), `v0.1.0-beta.8` (2026-09-25), `v0.1.0-beta.7` (2026-09-23), `v0.1.0-beta.6` (2026-09-23), `v0.1.0-beta.5` (2026-09-22), `v0.1.0-beta.4` (2026-09-21), `v0.1.0-beta.3` (2026-09-21), `v0.1.0-beta.2` (2026-09-17) and `v0.1.0-beta.1` (2026-09-16).** They are pre-releases: read the notes of the one you install — `CHANGELOG.md` links each release's own file under `docs/changelog/` — for what it measures, what it does not yet, and how to update, before installing. A source build is `docs/12_BUILD.md`.
|
||||
|
||||
1. Download the latest `FrameLedger.App-win-Setup.exe` from [Releases](https://github.com/poli0981/frameledger/releases). It installs into `%LOCALAPPDATA%\FrameLedger.App`; your data stays in `%LOCALAPPDATA%\FrameLedger`, and uninstalling asks before touching it.
|
||||
2. SmartScreen may warn — releases are not code-signed (free, open-source project). Verify the SHA-256 checksum published with each release, then **More info → Run anyway**.
|
||||
|
||||
@@ -687,6 +687,18 @@ From the upscaler hooks we get, per frame:
|
||||
> Measured on the hook harness with the vendor stub answering as the SDK documents (`fl_guard` "FSR's quality
|
||||
> mode", by size through the SDK 2.x loader and by ratio through the 1.1.x monolith); a real title is owner-only
|
||||
> item 21 (Lies of P at Quality, then Performance).
|
||||
- **One technology's name, quality and size** *(2026-11-12, owner decision D120)*. A session's — and a segment's —
|
||||
upscaler is **the technology named on the most samples of the dominant stream** (a tie goes to the lower value, as
|
||||
the quality byte's does), not the first one any record names. While a session names one technology, its quality
|
||||
and render size are read from the whole stream as before: under frame generation the name sits on one present in
|
||||
N. When it names **more than one**, the quality and the size are read **only from the samples that name the
|
||||
chosen one**, a quality byte of the other family is withheld (`UpscalerChoice.QualityFor`), and the session is
|
||||
marked "settings changed during session". The session this was found on (Dying Light: The Beast, 81 seconds:
|
||||
DLSS evaluated for most of it, an FSR dispatch for a few seconds) had been stored as "DLSS" with FSR's Balanced
|
||||
byte and FSR's render size — three true readings of two technologies under one name. What the chosen technology
|
||||
did not say stays N/A (rule 7). `Domain.Metrics.UpscalerChoice`; the live card still names the first technology
|
||||
the session saw (`FgLadder.UpscalerIdentity`), which for a session in progress is a different question and was
|
||||
not changed.
|
||||
- Resolution changes mid-session (user changed settings, or dynamic resolution scaling) produce **segments**: the session stores a segment list `(startFrame, renderW/H, outputW/H, upscaler, quality)`. Aggregates report the dominant segment plus a "settings changed during session" flag — averaging across a settings change is the classic way benchmark numbers become meaningless.
|
||||
|
||||
> **Two segmentation axes exist, they compose in ONE order, and neither document said so until
|
||||
|
||||
+4
-2
@@ -129,8 +129,10 @@ What the region is, as a contract between the two sides:
|
||||
the detour and never reach the region; a size of 0 is "not given".
|
||||
- **A per-frame value is summarised where it is seen**: a flag is an "ever seen" mask, a jitter the largest magnitude,
|
||||
a field of view its lowest and highest (D114), the reported frame time a count and a sum the watchdog drains.
|
||||
- **Sized once for the train's three releases.** The members 0.1.0-beta.41 and beta.42 fill (`ffxFg*`, `sl*`,
|
||||
`features`) are declared now and stay zero until then, so those releases bump no layout.
|
||||
- **Sized once for the train's three releases.** The members ~~0.1.0-beta.41 and beta.42~~ 0.1.0-beta.42 and
|
||||
beta.43 fill *(renumbered 2026-11-12, D118: a fix release took beta.41; the comments in `fl_shm.h` and
|
||||
`ShmLayout.cs` still carry the old numbers until the release that fills each member rewrites them)* (`ffxFg*`,
|
||||
`sl*`, `features`) are declared now and stay zero until then, so those releases bump no layout.
|
||||
- The Vulkan layer never writes it. `ShmLayoutMirrorTests.TheAdvancedStateMirrorMatches` checks every member's
|
||||
offset against `fl-layout-dump`; `ShmRingReaderTests` the three reads and that the request is stored either way.
|
||||
|
||||
|
||||
+30
-2
@@ -714,6 +714,33 @@ Every hook body is wrapped:
|
||||
> foreign one in ctest `fl_unhook_inline` (the vtable form stays in `fl_unhook_preserves_foreign`), and
|
||||
> against the injected Overlay in ctest `fl_guard` `[log]`, where every patch reads `UNHOOK_RESTORED`
|
||||
> because the harness is alone in its process.
|
||||
>
|
||||
> **The registry refuses what it cannot hold, and a patch is registered before it can run (0.1.0-beta.42,
|
||||
> `fl_patch_registry.h`).** The registry was an array and a counter, and two things were wrong with it — found by
|
||||
> reading the code for the plan of the next two hooks, not by a failure. **Full meant silent:** `RegisterPatch`
|
||||
> wrote its entry only while it fitted, after `PatchTarget` had already enabled the hook, so a 49th patch would
|
||||
> have been live and unknown to the stop, with no line anywhere. (Twenty patch sites exist; the rule no longer
|
||||
> depends on that count being right, and a `static_assert` now checks the capacity against the inventory's own row
|
||||
> count plus the seven sites that are not rows.) **Enabled before registered:** `PatchTarget` enabled the hook,
|
||||
> re-read `g_observing`, and registered last; a stop between the re-read and the registration walked a table
|
||||
> that did not hold the patch yet, and the patch stayed in after "stopped". The DXGI three and the loader detour
|
||||
> registered after enabling too, with no re-read at all.
|
||||
>
|
||||
> One sequence now, `fl::patch::Install`: **take a slot — no slot, no patch, nothing created — create, enable,
|
||||
> commit the slot, then re-read the flag.** The stop clears the flag and then walks the committed slots. Each side
|
||||
> writes and then reads what the other wrote, sequentially consistent, so at least one sees the other: the walk
|
||||
> restores the patch, or the installer finds the flag clear and takes its own patch out (and retires the slot,
|
||||
> so the walk does not report it as somebody else's). A slot whose patch failed is free again; one that was ever
|
||||
> live is never reused — the walk reads it without a lock. Nothing is created once observing is off. A patch
|
||||
> that did not go in is logged once per target and reason, `PATCH_FAILED a=<reason>` (`2` stopped, `3` registry
|
||||
> full, `4` create failed, `5` enable failed, `6` the stop arrived meanwhile); until now every such failure was
|
||||
> silent. The three DXGI patches are still enabled together and keep the same rules by hand; when any step of
|
||||
> theirs fails, whatever a partial enable left in is taken out — it used to stay, unregistered, with init
|
||||
> reporting failure. And two stores that could overwrite a stop's reason no longer do: `READY` is written only
|
||||
> over `INIT`, and init's failure path stores nothing. No hook body changed. ctest `fl_unhook_inline` drives
|
||||
> the shipped sequence against real MinHook patches: a full registry leaves the target's bytes untouched and
|
||||
> MinHook unasked; a stop arranged between the enable and the re-read ends with the function unpatched; a failed
|
||||
> patch gives its slot back; a slot is invisible to the walk until committed.
|
||||
|
||||
~~`FlRequestUnhook()` (or the control flag) ⇒ `MH_DisableHook(MH_ALL_HOOKS)`, restore vtable entries **only where they are still ours**, flush the ring, set status.~~ *(Corrected 2026-10-04: both reach `StopObserving` — compare-and-restore per patch as the note above says, then the status; there is no `MH_ALL_HOOKS`, no vtable entry and no ring flush. The watchdog flushes the native log on its way out.)* **The DLL is not `FreeLibrary`'d from the live process** — a thread could still be inside a trampoline. It goes dormant and unloads with the process. This is deliberate and documented.
|
||||
|
||||
@@ -758,8 +785,9 @@ No logging in hook bodies. A small fixed-size in-memory ring of structured event
|
||||
> `__func__` — never from a hook body. Codes: `RING_CREATED`, `PRESENT_HOOKS`, `HOOK_INSTALLED` (one per
|
||||
> patch, with the target address), `SYMBOL_MISSING` (once per pair, and only when the module IS mapped),
|
||||
> `FAULT`, `STOP` (the reason), `UNHOOK_RESTORED` / `UNHOOK_DECLINED` (one per patch), `LOADER_DETOUR`,
|
||||
> `SUPERVISION_LOST`, and since beta.24 `STOP_FLUSHED` (the last line after a stop: `a=1` when the stop had finished
|
||||
> writing). **Three flush points, none on a present path:** the end of `InitThread` (so the
|
||||
> `SUPERVISION_LOST`, since beta.24 `STOP_FLUSHED` (the last line after a stop: `a=1` when the stop had finished
|
||||
> writing), and since beta.42 `PATCH_FAILED` (a patch that did not go in, once per target and reason — §Unhooking).
|
||||
> **Three flush points, none on a present path:** the end of `InitThread` (so the
|
||||
> file exists from the start of the session and a crash mid-session still leaves it), the watchdog when
|
||||
> `FlControlBlock.logFlushRequested` changes (a counter the Agent bumps at session end; nothing clears it),
|
||||
> and the watchdog on its way out after any stop. Appended, never recreated; events overwritten before a
|
||||
|
||||
@@ -632,6 +632,17 @@ and labelled with the hardware's words. A sensor with no family is not read.
|
||||
`RecorderOptions.AdvancedMetrics` through `SettingsRecorderPolicy`, at each session's start like the other recording
|
||||
settings; exactly `1` is on. From there:
|
||||
|
||||
- **The process has one sensor library** *(2026-11-12)*. One *reader* was never the whole of it: a session's L2
|
||||
source and its CPU-temperature reader each open a LibreHardwareMonitor `Computer` of their own beside the
|
||||
Advanced reader's, and the library keeps part of its state — the driver it reads the processor through, its bus
|
||||
mutexes — per process. `Computer.Close()` lets go of that part whoever else is still reading. The first sessions
|
||||
recorded as administrator with PawnIO showed it (`20_OPEN_QUESTIONS` §M13): a processor device that faulted out
|
||||
some seconds after each session's sources closed, and one session whose reader could not open at all. Every
|
||||
`Computer` is now opened and closed through `Infrastructure.Telemetry.LhmLibrary` (`LhmComputerAdapter` is its
|
||||
user): opens and closes never run at once, and a `Computer` closed while another is in use is **parked** — left
|
||||
open, read by nobody, handed to the next user of the same groups — until the last user lets go, when all are
|
||||
closed. The reads are not serialised: the readers keep their own threads, so a sensor that hangs in one still
|
||||
holds up neither the other nor the pipe.
|
||||
- **The Agent has one reader** — `AgentServices` registers `AdvancedHardwareHub` as `IAdvancedHardware`, a tick a
|
||||
second and a linger of ten — and nothing starts it but a holder. `SessionRecorder` holds it for a session's length
|
||||
**only when the option is on**, and `AgentRecording` gives the session's `TelemetryPoller` the reader on the same
|
||||
@@ -704,9 +715,9 @@ every `nvapi.` row; nothing is estimated in its place (FR-4.9).
|
||||
| Train | Release | What | Its gate |
|
||||
|---|---|---|---|
|
||||
| A | 0.1.0-beta.39 | read by the Agent only — NVAPI and LibreHardwareMonitor — storage, the page. **Nothing changes in code loaded into a game** | this section |
|
||||
| B | 0.1.0-beta.40, .41, .42 *(three releases since D113, 2026-11-11; one was planned)* | inside the game: more fields of the Streamline and FidelityFX calls already hooked, and new hooks on functions `sl.interposer.dll` **exports** (`17_HOOK_ENGINE` §Hook inventory's ⏳ rows); shared-memory layout 5 — §Train B below | a plan of its own; overhead measured; each release after the first waits for the owner's run of the one before |
|
||||
| C | ~~0.1.0-beta.41~~ 0.1.0-beta.43 | Reflex latency per frame | a spike, then the owner's go or no |
|
||||
| D | ~~0.1.0-beta.42~~ 0.1.0-beta.44 | the Streamline feature state behind `slGetFeatureFunction` — DLSS frame generation's, DLSS's, Reflex's | a spike, then the owner's go or no |
|
||||
| B | 0.1.0-beta.40, ~~.41, .42~~ ~~.42, .43~~ .42, .43, .44 *(three releases since D113, 2026-11-11; one was planned. Renumbered 2026-11-12, D118: 0.1.0-beta.41 is a fix release for the sensor library, not part of the train. **Four since D122, the same day**: the second step is beta.42 — no new patch site — and beta.43, the two new hooks; the third step is beta.44)* | inside the game: more fields of the Streamline and FidelityFX calls already hooked, and new hooks on functions `sl.interposer.dll` **exports** (`17_HOOK_ENGINE` §Hook inventory's ⏳ rows); shared-memory layout 5 — §Train B below | a plan of its own; overhead measured; each release after the first waits for the owner's run of the one before |
|
||||
| C | ~~0.1.0-beta.41~~ ~~0.1.0-beta.43~~ ~~0.1.0-beta.44~~ 0.1.0-beta.45 *(D118, D122)* | Reflex latency per frame | a spike, then the owner's go or no |
|
||||
| D | ~~0.1.0-beta.42~~ ~~0.1.0-beta.44~~ ~~0.1.0-beta.45~~ 0.1.0-beta.46 *(D118, D122)* | the Streamline feature state behind `slGetFeatureFunction` — DLSS frame generation's, DLSS's, Reflex's | a spike, then the owner's go or no |
|
||||
|
||||
Rules 4 and 5, the hook inventory, the measured overhead and the anti-cheat guard bind B, C and D exactly as they bind
|
||||
every hook. `sl::Constants` is read without its camera position, axes and matrices: where the camera is, is where the
|
||||
@@ -757,9 +768,24 @@ planning, the design reviewed against the code before it was approved.
|
||||
anti-cheat exception's trial ends that exception for good (D38), and every release already means restarting the
|
||||
game. **beta.40**: more fields of calls *already* hooked — `sl::DLSSOptions` where the game chains it into
|
||||
`slEvaluateFeature`, the FSR upscale dispatch, the FSR memory query — shared-memory layout 5, the Agent and the
|
||||
page; **no new patch site**. **beta.41**: `slSetConstants` and `ffxConfigure`. **beta.42**:
|
||||
`slGetFeatureVersion` and `slGetFeatureRequirements` — the owner's words: a release of their own, still hooked.
|
||||
Each starts when the owner says the one before passed its owner-only item.
|
||||
page; **no new patch site**. **~~beta.41~~ beta.42**: `slSetConstants` and `ffxConfigure`. **~~beta.42~~
|
||||
beta.43**: `slGetFeatureVersion` and `slGetFeatureRequirements` — the owner's words: a release of their own, still
|
||||
hooked. Each starts when the owner says the one before passed its owner-only item.
|
||||
- **D122 — the second step is two releases** (owner decision 2026-11-12, after the owner's sessions on beta.40
|
||||
and beta.41 and a review of the draft against the code). **0.1.0-beta.42 adds no patch site**: the session's
|
||||
upscaler label (D120, `03_METRICS` §Upscaling), a patch registry that refuses what it cannot register, a native
|
||||
log that survives the game's exit and says which descriptor types each ffx module saw — because Cyberpunk 2077,
|
||||
set to FSR upscaling, was named "unknown" and nothing in the field could say why (D121) — and FSR's infinite depth
|
||||
plane (D119). **0.1.0-beta.43 is `slSetConstants` and `ffxConfigure`**, begun only when that log was read. The
|
||||
third step (`slGetFeatureVersion`, `slGetFeatureRequirements`) is beta.44, train C beta.45, train D beta.46.
|
||||
- **D118 — 0.1.0-beta.41 is a fix release, and the train's numbers move by one** (owner decision 2026-11-12). The
|
||||
owner's first evening with beta.40 showed the sensor library being closed under its other users (the paragraph on
|
||||
`LhmLibrary` below; `20_OPEN_QUESTIONS` §M13); told that the fix would take the number D113 had given the train's
|
||||
second release, the owner chose to release it at once. So: second release beta.42, third beta.43, train C
|
||||
beta.44, train D beta.45. Text written before that day says beta.41 and beta.42 for the second and third — in
|
||||
the released changelogs and the moved HANDOFF sections, which are not edited, and in the comments of `fl_shm.h`
|
||||
and `ShmLayout.cs`, which the release that fills each member rewrites (they were left so that the code loaded
|
||||
into a game stayed 0.1.0-beta.40's, line for line, in a release that fixes something else).
|
||||
- **D112 — `slInit` is not hooked in train B.** A game calls it before FrameLedger attaches, so its preferences
|
||||
would almost never be seen. If it is ever hooked: `applicationId`, `projectId` and the paths are never read.
|
||||
- **D114 — the field of view is a session's range**, lowest to highest, never a series: a series would say when the
|
||||
|
||||
@@ -1861,7 +1861,7 @@ Moved verbatim, in this order.
|
||||
| M10 ❓ | **§CPU — is the CPU temperature this build reads the right sensor, and does it read at all on the owner's machine?** `LhmCpuTemperatureReader` (2026-09-21) opens a CPU-only LibreHardwareMonitor `Computer` when the Agent is elevated AND `PawnIo.IsInstalled`, takes the package sensor (`CPU Package` / `Core (Tctl/Tdie)`) and falls back to the hottest core. It was written against LHM's sensor names and a fake `ILhmComputer`; **no elevated run with PawnIO has been taken.** | **The measurement is one session:** Agent elevated, PawnIO installed, a five-minute capture with HWiNFO or Ryzen Master open beside it. Pre-committed: `max_cpu_temp` within 3 °C of the reference's package peak → keep; a core sensor picked where a package sensor exists, or a reading tens of degrees off (a distance-to-TjMax sensor mistaken for a temperature) → fix `Pick` and re-run; nothing read at all → `cpu_temp` stays N/A and `legal/ACCURACY.md` says processor temperature is not measured. CPU **load** and memory are not in question: `TheRealCountersAnswerOnThisMachine` reads them on every gate run. |
|
||||
| M11 🅓 | **The game's VRAM budget and `budget_exceeded_pct` (FR-4.5's second half), 2026-10-03.** D43 reads the game's usage from outside (the `GPU Process Memory` counters); the budget the OS grants the process is what DXGI's `QueryVideoMemoryInfo` returns to the *calling* process (§M7), so only an in-process call — the Overlay's background thread, which today only checks for a stop — or `D3DKMTQueryStatistics`' `PROCESS_SEGMENT_GROUP` query (documented "Reserved for system use") could read it. **Deferred by decision:** neither is built; `vram_budget_exceeded_pct` stays NULL and the budget N/A, and the in-process route would change what the Disclaimer says the Overlay's thread does. Reopening it needs that decision, not a measurement. | — |
|
||||
| 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). |
|
||||
| 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. |
|
||||
| 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. |
|
||||
|
||||
+122
-130
@@ -79,131 +79,143 @@ owner-only items stay below; the history of every train, the passed owner-only i
|
||||
| `§beta.37` | [`handoff/history/0.1.0-beta.37.md`](handoff/history/0.1.0-beta.37.md) |
|
||||
| `§beta.38`, `§NEXT` (the owner's request of 2026-11-11, the four trains) | [`handoff/history/0.1.0-beta.38.md`](handoff/history/0.1.0-beta.38.md) |
|
||||
| `§beta.39`, train B's plan as approved (its `§NEXT`) | [`handoff/history/0.1.0-beta.39.md`](handoff/history/0.1.0-beta.39.md) |
|
||||
| `§beta.40`, what the owner's first sessions with it showed, train B's traps | [`handoff/history/0.1.0-beta.40.md`](handoff/history/0.1.0-beta.40.md) |
|
||||
| `§Owner-only`, an open item | [§Owner-only](#owner-only--no-pr-can-close-these) below |
|
||||
| `§Owner-only`, a passed item (3, 12, 14–19) | [`handoff/owner-only-passed.md`](handoff/owner-only-passed.md) |
|
||||
| `§Owner-only`, a passed item (3, 12, 14–19, 38, 39) | [`handoff/owner-only-passed.md`](handoff/owner-only-passed.md) |
|
||||
| `§Traps`, `§Two corrections carried forward` | [`handoff/traps.md`](handoff/traps.md) |
|
||||
| `Dnn` | [§Decisions index](#decisions-index) below |
|
||||
|
||||
---
|
||||
|
||||
## **START HERE** — 2026-11-12, 0.1.0-beta.40: Advanced metrics inside the game, the first of train B's three releases
|
||||
## **START HERE** — 2026-11-12, 0.1.0-beta.41: one fix — the sensor library is no longer closed under its other users
|
||||
|
||||
*Status is `docs/changelog/0.1.0-beta.40.md`; this is what no other file carries.* Train B of the owner's
|
||||
"Thông số nâng cao" was planned and approved on 2026-11-11 (D110–D117) as **three releases**, and this is the first:
|
||||
what a hooked game tells its upscaler, read from **calls the Overlay already hooked — no new patch site** — only
|
||||
while the session records Advanced metrics. Four pull requests and this one: #395 (the decisions, the struct-version
|
||||
table, §M16 measured, NFR-2 amended), #396 (shared-memory layout 5, region 5), #397 (the Overlay's reads, the
|
||||
`overlay-fields-check` gate, the overhead measured), #398 (the Agent's sampler, the catalog's reach `Game`, the
|
||||
page's words, Privacy Policy 2.16). **The design is [`18_GPU_VENDOR_APIS.md`](18_GPU_VENDOR_APIS.md) §Train B; the
|
||||
contract of the new region is [`07_IPC.md`](07_IPC.md) §Region 5; what each hooked call reads is
|
||||
[`17_HOOK_ENGINE.md`](17_HOOK_ENGINE.md) §Hook inventory.** The plan as approved, the review that changed it and the
|
||||
order of the trains are [`handoff/history/0.1.0-beta.39.md`](handoff/history/0.1.0-beta.39.md) §NEXT.
|
||||
*Status is `docs/changelog/0.1.0-beta.41.md`; this is what no other file carries.* 0.1.0-beta.40 was released in the
|
||||
small hours of 2026-11-12 and the owner ran it that same night on eight games, as administrator with PawnIO — the
|
||||
first elevated run there has been. A copy of the ledger and the Agent's log showed the in-game readings working
|
||||
(Lies of P, the first real game read) and **a defect of train A that only that elevation can show**: three
|
||||
LibreHardwareMonitor `Computer`s in one Agent, and the library's per-process state closed by one under the others.
|
||||
This release is that fix and nothing else: #400 (0.1.0-beta.40's release facts; two comparisons SonarCloud flagged),
|
||||
#401 (`LhmLibrary`), and this one. **Everything about train B — what was built, what the owner's sessions showed,
|
||||
the traps — is [`handoff/history/0.1.0-beta.40.md`](handoff/history/0.1.0-beta.40.md)**; the fix is
|
||||
[`18_GPU_VENDOR_APIS.md`](18_GPU_VENDOR_APIS.md) §Advanced metrics and [`20_OPEN_QUESTIONS.md`](20_OPEN_QUESTIONS.md)
|
||||
§M13.
|
||||
|
||||
### What this train decided that the plan had not
|
||||
### What this release decided
|
||||
|
||||
None of these is an owner decision; each was found while building, and is written where it binds.
|
||||
|
||||
- **"On" is a request of the session's own, not a 1** (#397, `07_IPC` §Region 5). The plan had the control word as
|
||||
0 or 1. A game outlives a session, and the Overlay's summaries with it — a second session of a game that kept
|
||||
running would have read the first one's field-of-view range and counts. The Agent now writes a value no session of
|
||||
that ring used, the watchdog starts its summaries afresh at a value it has not seen and names it in every
|
||||
publication, and the reader keeps only a publication that names its own. Found while writing the injected test,
|
||||
before anything shipped; layout 5 was changed in place (`reserved0` became `request`), which was possible only
|
||||
because no release had carried it.
|
||||
- **One module's calls are counted**, for the memory query as for the dispatch: a loader that passes a call on to a
|
||||
leaf's export is seen at two hooks.
|
||||
- **Five of the thirteen entries are tables**, not text (`sl.dlss.presets`, `sl.dlss.exposure`,
|
||||
`ffx.upscale.sharpening`, `.jitter`, `.depth`): a row's name is the vendor's own member name, so nothing but a
|
||||
switch's on/off and a flag's name needs translating. The catalog's unit and two summaries changed; no id did.
|
||||
- **What became of the in-game entries is stored with the session** (`AdvancedSources.InGame`): read, nothing seen,
|
||||
not hooked. Without it a session whose game set its DLSS options through `slDLSSSetOptions` would look like a
|
||||
game with no upscaler.
|
||||
- **The Disclaimer stays 2.15.** The accuracy statement gained an item, as in beta.19, beta.20 and beta.25, none of
|
||||
which moved it; the Privacy Policy went to 2.16 with the content the plan approved.
|
||||
- **A crash dump is tried three times** (#398). Not this train's subject: `CrashDumpHelperTests` failed under the
|
||||
full gate for the third time in two days, and the cause — `MiniDumpWriteDump` of a running process that changes
|
||||
under it — costs a real crash its only dump in exactly the same way.
|
||||
- **D118 — the fix is released at once as 0.1.0-beta.41, and train B's numbers move by one.** D113 had named
|
||||
beta.41 for the train's second release. Told so, the owner chose to release the fix now. The train's second
|
||||
release is **beta.42**, its third **beta.43**, train C **beta.44**, train D **beta.45**. Released changelogs and
|
||||
moved HANDOFF sections keep the numbers of their day; so do the comments in `fl_shm.h` and `ShmLayout.cs` (the
|
||||
members "0.1.0-beta.41" and "beta.42" fill), **deliberately**: touching them would have changed source that is
|
||||
loaded into a game in a release that says the game-side code is beta.40's line for line. The release that fills
|
||||
a member rewrites its comment.
|
||||
- **The reads of the sensor library are not put under one lock**, only its opens and closes. A lock around every
|
||||
read would have put a session's once-a-second poll behind the Advanced reader's, undoing the separate threads
|
||||
that keep a hanging sensor from holding up the other reader.
|
||||
|
||||
### NEXT
|
||||
|
||||
1. **The owner runs item 38** — this release on real games. **Nothing of train B is begun before that**: the wait
|
||||
is what the split into three releases is for (D113).
|
||||
2. **0.1.0-beta.41, when the owner says item 38 passed**: two new hooks, `slSetConstants` and `ffxConfigure`. The
|
||||
design is in `18` §Train B and the plan in [`handoff/history/0.1.0-beta.39.md`](handoff/history/0.1.0-beta.39.md)
|
||||
§NEXT; region 5 already has their members (`sl*`, `ffxFg*`), so no layout changes. What to settle first, in a
|
||||
plan of its own: `kMaxPatches = 48` against the patch count with the new rows; the window of `sl::Constants` that
|
||||
is read, pinned by `static_assert` so that the camera members stay outside it; the overhead of a call made every
|
||||
frame for every viewport, measured before the merge; `overlay-fields-check`'s list and its parameters for the two
|
||||
new structs.
|
||||
3. **0.1.0-beta.42, when the owner says the one before passed**: `slGetFeatureVersion` and
|
||||
`slGetFeatureRequirements` — calls a game makes while starting, so most sessions will say the game did not make
|
||||
them after FrameLedger attached. The release notes and the page say so.
|
||||
4. **Trains C and D** (Reflex latency → beta.43; the Streamline state behind `slGetFeatureFunction` → beta.44) each
|
||||
begin with a spike and end in the owner's go or no. D needs an amendment of rule 4 if it goes ahead.
|
||||
1. ~~**The owner runs item 39** (this fix, on the PC that showed the fault) **and the rest of item 38** (an FSR 3.1+
|
||||
title; two sessions of one running game; the cost; the values of Lies of P against the game's own settings).~~
|
||||
**Both passed on 2026-11-12, on the owner's word** ("Bạn có thể đánh dấu là pass và tiếp tục") after the thirteen
|
||||
sessions below; [`handoff/owner-only-passed.md`](handoff/owner-only-passed.md) says what those sessions covered and
|
||||
what they did not.
|
||||
2. **Planned and approved 2026-11-12 (D119–D122): the second step is two releases.** **0.1.0-beta.42 has no new
|
||||
patch site** — five pull requests: (1) the session's upscaler label (D120); (2) the Overlay's patch registry
|
||||
refuses a patch it cannot register, and registers before it enables; (3) the native log is flushed whenever
|
||||
something new was logged, every inventory row's install line names its module and symbol, a failed patch says
|
||||
why, and the first sight of each ffx descriptor type on each module is logged — so that one Cyberpunk session on
|
||||
beta.42 says where its upscale goes (D121); (4) FSR's infinite depth plane (D119); (5) the release, owner-only
|
||||
item 40. **0.1.0-beta.43 is the two new hooks** and begins only when that log was read; its design — reviewed
|
||||
against the code, which changed it — is in the plan of that day and below. What the review found that the first
|
||||
draft had wrong: there is no "dominant segment" (segments split on output size only), so the label is the modal
|
||||
name over the dominant stream; the patch table drops a patch silently when full; the init thread's flush runs
|
||||
after the watchdog starts; a second NaN pattern for "infinite" would have been dropped by the Agent — real
|
||||
+infinity is stored instead; the new rows must be gated before `ResolveScoped`, which takes a module reference a
|
||||
call; `slSetConstants` needs the struct's GUID checked on every call; `ffxConfigure` needs an owner slot of its
|
||||
own; summaries across viewports must come from the first viewport seen.
|
||||
~~**0.1.0-beta.42 — train B's second release — when the owner says item 38 passed begins now, with its plan**~~: `slSetConstants` and
|
||||
`ffxConfigure`. A plan of its own first. What it must settle, beside what
|
||||
[`handoff/history/0.1.0-beta.40.md`](handoff/history/0.1.0-beta.40.md) §NEXT lists (`kMaxPatches = 48`, the window
|
||||
of `sl::Constants` pinned outside the camera members, the per-call overhead, the gate's list for the two new
|
||||
structs):
|
||||
- **`FLT_MAX` in an FSR depth plane.** Lies of P gave `cameraFar = 10` and no `cameraNear`; most likely the
|
||||
plane at infinity is `FLT_MAX`, which the Overlay refuses as "nobody set this". Decide whether it is stored as
|
||||
"infinite" — an Overlay change, with its overhead stated.
|
||||
- ~~**Valor Mortis.** One exit by access violation 51 seconds after injection under beta.40, none under an earlier
|
||||
build, not attributed. Its crash count is 1; a second such end switches its hooking off. Before adding a hook
|
||||
to that game's process, ask the owner whether it happened again.~~ **Answered by the owner, 2026-11-12: it was
|
||||
the game's own — a shader-compilation error on entering the game, shown in the game's own crash dialog.** Not
|
||||
FrameLedger's. It ran normally under beta.41 afterwards. Its crash count still stands at 1, because the crash
|
||||
policy counts an abnormal end within 60 seconds of injection whoever caused it: a second one, from any cause,
|
||||
switches its hooking off, and the owner then switches it on again from the game's page.
|
||||
- **The release numbers in the comments** of `fl_shm.h`, `ShmLayout.cs`, `hook-harness` and `guard_test.cpp` for
|
||||
the members that release fills (D118).
|
||||
3. **0.1.0-beta.43 — the third — when the owner says the one before passed**: `slGetFeatureVersion` and
|
||||
`slGetFeatureRequirements`.
|
||||
4. **Trains C and D** (beta.44, beta.45) each begin with a spike and end in the owner's go or no.
|
||||
|
||||
### Left open by this session
|
||||
|
||||
- ~~**This release's own facts** — the tag's run, the digests, the delta — are not in any file yet: the release is cut
|
||||
after this text. Record them in the next pull request, as beta.39's were in #395.~~ **Recorded 2026-11-12, in the
|
||||
pull request after the release: 0.1.0-beta.40 was released 2026-11-11T19:30:13Z** (02:30 on the 12th in the
|
||||
owner's time zone, which is the date the changelog carries; the legal documents' *Effective* date is the UTC one,
|
||||
2026-11-11 — the fifth release to straddle midnight that way, after beta.9, .10, .12 and .14) from the signed tag
|
||||
on `5268332` (#399), by run 43085044822 — green at the first attempt, one run for the one tag push. Eight assets;
|
||||
the seven digests of `SHA256SUMS.txt` equal the ones GitHub computed; the shipped natives carry `FL_BUILD_ID
|
||||
v0.1.0-beta.40`. The delta from beta.39 is 2,413,166 bytes beside a full package of 110,707,319 — "Delta processed
|
||||
0452 files. 0025 patched, 0427 unchanged". The wiki was published by run 43087844607. The rehearsal on the release
|
||||
branch (run 43082208739) had made a delta of 2,426,184 bytes with the same file counts.
|
||||
- **Nothing here was read from a real game, and nothing was seen in the running App.** The values come from
|
||||
`hook-harness --advanced` and the FidelityFX stub; the page's new rows were loaded by its tests and looked at by
|
||||
nobody. All of it is owner-only item 38.
|
||||
- **Whether any shipping title chains `sl::DLSSOptions` into `slEvaluateFeature`** is not known. If none of the
|
||||
owner's games does, the six `sl.dlss.*` entries read N/A everywhere until train D, and the page already says why.
|
||||
- **The aliasable part of FSR's memory** is read and published and not shown: the catalog has one memory entry.
|
||||
- ~~**SonarCloud on #398** had not answered when this was written; #397's three findings are fixed in #398.~~
|
||||
**It answered after the merge, with three findings on new code**, handled in the pull request after the release:
|
||||
two `csharpsquid:S1244` in `InGameAdvancedSampler` — a lowest and a highest float compared with `==` to tell one
|
||||
value from a range; they are now told apart by their bits, which is what was meant — and one
|
||||
`csharpsquid:S3869`, a blocker, on `ParentDump`'s `DangerousGetHandle`. That one is **not new and not fixed**: the
|
||||
owner accepted it in beta.24 (`13_CI_CD` §SonarCloud), #398 moved the same expression into a new method, and
|
||||
SonarCloud tracks an issue by its place. It needs the owner's *Accept* again — item 38 (j).
|
||||
- **The `vi` strings were written by the assistant and the `ja` ones are marked `review`** — fourteen more keys and
|
||||
the reworded Settings text.
|
||||
- **`LogNoteW`** is still there (owner-only item 36 (d)), item 37 is still unrun, and the alpha line still rests
|
||||
(D98): no alpha follows this release.
|
||||
after this text. Record them in the next pull request.~~ **Recorded 2026-11-12: 0.1.0-beta.41 was released
|
||||
2026-11-11T22:38:39Z** (05:38 on the 12th in the owner's time zone) from the signed tag on `a6b95e8` (#402), by
|
||||
run 43111028661 — green at the first attempt, one run for the one tag push. Eight assets; the seven digests of
|
||||
`SHA256SUMS.txt` equal the ones GitHub computed; the shipped natives carry `FL_BUILD_ID v0.1.0-beta.41`. The delta
|
||||
from beta.40 is 807,692 bytes beside a full package of 110,708,416 — "Delta processed 0452 files. 0022 patched,
|
||||
0430 unchanged". The wiki was published by run 43113525941. The rehearsal on the release branch (run 43108189693)
|
||||
had made a delta of 841,038 bytes with the same file counts.
|
||||
- ~~**The fix has not been seen to work.** It was written from the log's timing; the fault needs an elevated Agent with
|
||||
PawnIO. Item 39 is the check, and `20_OPEN_QUESTIONS` §M13 stays open until then.~~ **The owner's first seven
|
||||
sessions on beta.41 show no fault** (2026-11-12, 06:38–07:01, read from the Agent's log and a copy of the ledger):
|
||||
not one `advanced:` line, and every session with the option on stored its 212 or 213 series, the processor's 119
|
||||
among them. On beta.40 the same morning the processor device faulted out after **each** of the six sessions
|
||||
recorded between 04:34 and 05:07. The rarer fault — the reader failing to open — was one session in sixteen, so
|
||||
seven clean ones do not yet say it is gone. ~~Whether item 39 has passed is the owner's to say.~~ The owner
|
||||
marked it passed the same day.
|
||||
- **What those sessions say of train B's first release** (the same log and ledger; the owner named which games are
|
||||
first-person — Kingdom Come: Deliverance II, Cyberpunk 2077, Dying Light: The Beast, Valor Mortis — the rest
|
||||
third-person, and Psycho-Sleuth 2D):
|
||||
- **The first FSR 3.1 title read: Kingdom Come: Deliverance II** (FSR 3.1 chosen in the game;
|
||||
`amd_fidelityfx_upscaler_dx12.dll` 4.0.2 behind the loader). Performance mode, 1280×720 to 2560×1440;
|
||||
sharpening on at 0.5; `cameraNear` 0.05 and `cameraFar` 8000 — **both planes, the only title that gives both**;
|
||||
one vertical field of view for the whole session, 63.1°; a reported frame time of 16.67 ms. A 41-second session
|
||||
of the same game that never left its menu read nothing and says so.
|
||||
- **Dying Light: The Beast** upscaling with FSR: sharpening off, 75.4°–78° vertical, 7.5 ms. **Clair Obscur**:
|
||||
sharpening off, 5.7°–90.7° over four minutes. So far the two first-person titles hold a narrow range and the
|
||||
two third-person ones a wide one (Lies of P 21.6°–73.7°) — what one would expect of cutscene and aiming
|
||||
cameras, and no more than that: four titles.
|
||||
- **Three engines give `cameraFar` alone, as a small number** — 10 (Lies of P), 1 (Clair Obscur), 0.1 (Dying
|
||||
Light) — which is the near plane of an inverted, infinite depth with the other plane at `FLT_MAX`. That is the
|
||||
case beta.42's plan has to decide.
|
||||
- **Clair Obscur reports a frame time of 0.001 ms in some seconds.** It is what the game hands FSR, stored as it
|
||||
was said; the lowest value of that series is not a frame time anyone saw.
|
||||
- **Cyberpunk 2077 read nothing**, with FSR frame generation running and the render size known: its upscaling did
|
||||
not come through an ffx-api upscale dispatch in those sessions. Which upscaler it was set to is the owner's to
|
||||
say; `ffxConfigure` (beta.42) is where its frame generation would be read.
|
||||
- **One session of Dying Light names DLSS as its upscaler and carries FSR's quality byte and render size** (81
|
||||
seconds, both an FSR dispatch and a DLSS evaluation seen, "settings changed" not set). Not this train's code —
|
||||
the session summary's choice between two upscalers seen in one session — and not looked into. **The owner,
|
||||
2026-11-12: Dying Light and Expedition 33 were set, in the game, to FSR upscaling with DLSS frame generation.**
|
||||
So "FSR beside DLSS frame generation" in their other sessions is the setting, not a misreading; in this one the
|
||||
summary picked the wrong one of the two for its upscaler line, which is still to be looked at.
|
||||
- **A session without consent says so**: two Cyberpunk sessions before its consent dialog was accepted are
|
||||
Tier 2, and their Advanced row says *not measured inside the game*. **The option off stored nothing** again,
|
||||
this time on a title that upscales with FSR 3.1 (Dying Light, beta.41).
|
||||
- **`LIMITATIONS.md` and the accuracy statement still say the processor's, the memory's and the motherboard's
|
||||
sensors "have never been read on real hardware".** They have been read on one PC and compared with nothing. The
|
||||
owner's to reword.
|
||||
- **SonarCloud's `csharpsquid:S3869` on `ParentDump.cs`** is open on `main` until the owner accepts it again (it was item
|
||||
38 (j), the one part of that item not done; the owner said on 2026-11-12 that they will). Until then `main`'s `sonarcloud` job is red on that one line.
|
||||
- **Items 36 (d) (`LogNoteW`) and 37 are still open**; the ledger shows part of 37 (e) happened — the elevated
|
||||
groups opened and read — and nothing of it was compared with another tool. The alpha line still rests (D98).
|
||||
|
||||
### Traps this train paid for
|
||||
|
||||
- **A heredoc in the tool's shell breaks on an odd number of apostrophes** — a script with `game's` in it fails with
|
||||
"unexpected EOF while looking for matching `'`" before Python ever runs. Write the script to a file and run the
|
||||
file.
|
||||
- **A region that outlives its reader needs to say whose data it holds.** Region 4 never had the problem — it is
|
||||
the swap chain's state, the same for any session. Region 5 holds summaries, and a summary has a beginning. Ask of
|
||||
any new shared state: what does the second session of the same process read in its first second?
|
||||
- **SonarCloud's engine does not see a Catch2 `REQUIRE` end a path**: `REQUIRE(OpenRingFor(pid, r))` followed by
|
||||
`r.st->…` is a null dereference to it (`cpp:S2259`, a failed gate on new code). An explicit `return` after the
|
||||
`REQUIRE` is what it follows. And a `LARGE_INTEGER` read through `QuadPart` is initialised through `QuadPart`
|
||||
(`cpp:S6232`) — `13_CI_CD` §SonarCloud has had the rule since #336; new code still forgot it.
|
||||
- **SonarCloud fails after the merge.** Its job is advisory and slower than the required checks, so auto-merge lands
|
||||
the pull request first. Read its result on the merged pull request before building on it.
|
||||
- **`MA0051` counts sixty lines, comments included**, and `CaptureSession.SuperviseAsync` was at fifty-nine: one
|
||||
line more is a build error. What a session asks once belongs where the session's state is made, not in the loop.
|
||||
- **`RCS1242` refuses `in` for a struct that is not `readonly`** — the mirror structs are not. Pass the object that
|
||||
holds the struct and take `ref readonly` inside.
|
||||
- **`/W4 /WX` refuses `alignas` on a struct it then has to pad** (C4324): align the variable, not the type.
|
||||
- **The `.resx` files hold a literal apostrophe**, not `'`: an edit script that searches for the entity finds
|
||||
nothing and stops half-way through.
|
||||
- **`ISessionRepository.FindAdvancedSensorsAsync` returns `t_ms` too**: "no advanced series" is "no series under
|
||||
`adv.`", not an empty list.
|
||||
- **PowerShell reads a backtick in a double-quoted string as an escape** (`` `r `` is a carriage return) and
|
||||
`"$name: text"` as a scoped variable: in a gate's messages, quote names with apostrophes and write `${name}:`.
|
||||
|
||||
**Owner-only:** item 38 — beta.40 on real games: the update and the Privacy Policy 2.16, a game that was running
|
||||
across the update, an FSR 3.1+ title and a DLSS title with the option on, the same with it off, a second session of
|
||||
a game that kept running, a game under the user-mode anti-cheat exception, and what the Agent costs.
|
||||
**Owner-only:** ~~item 39~~ passed 2026-11-12, with item 38. Nothing new is open from this release; items 36 (d)
|
||||
and 37 still are.
|
||||
|
||||
## Owner-only — no PR can close these
|
||||
|
||||
*The items that passed — 3, 12, 14–19 — moved verbatim to [`handoff/owner-only-passed.md`](handoff/owner-only-passed.md) on 2026-10-19 (D66); the numbers are kept, and a number is never reused.*
|
||||
*The items that passed — 3, 12, 14–19, and 38 and 39 on 2026-11-12 — moved verbatim to [`handoff/owner-only-passed.md`](handoff/owner-only-passed.md) (the first eight on 2026-10-19, D66); the numbers are kept, and a number is never reused.*
|
||||
|
||||
1. **§S23-2 — branch protection.** `Rules / validate` is not a required status check on
|
||||
`main`, so the gate that makes the anti-cheat blocklist un-removable is advisory.
|
||||
@@ -502,31 +514,6 @@ a game that kept running, a game under the user-mode anti-cheat exception, and w
|
||||
answered on 2026-11-11; what is left for a real game is the hooked session and the elevated one. (g) **The words**: the `vi` strings read as a Vietnamese
|
||||
speaker would write them; the `ja` strings marked `review`. (h) **A copy of the ledger** (`--data-dir`) that holds
|
||||
such a session: the page is there, opens on *Session*, and *This PC* says it is a copy.
|
||||
38. **beta.40, Advanced metrics inside a real game** (D111–D116; train B's first release — beta.41 is not begun
|
||||
until this passes). (a) **The update from beta.39**: the terms window shows the **Privacy Policy 2.16** once, and
|
||||
not the Disclaimer; a game that was **running across the update** is refused until it is restarted, with the
|
||||
reason, and measured normally after. (b) **The option off, a hooked game that uses DLSS or FSR**: the game runs
|
||||
and is measured as in beta.39; the session is not on the Advanced page's list; nothing in the Agent's or the
|
||||
Overlay's log mentions the upscaler's options. (c) **The option on, a title that upscales through FSR 3.1 or
|
||||
later** (AMD's `amd_fidelityfx_*.dll` in its folder; a title on the older FSR 3.0 interface, such as one that
|
||||
ships `ffx_fsr3_x64.dll` alone, is expected to show none): on *Session*, under Upscaling, sharpening on or off
|
||||
and its strength against the game's own setting; the field of view as a range, against the game's slider (it is
|
||||
the **vertical** angle, in radians with degrees beside it) — and wider after zooming or aiming; the near and far
|
||||
planes; the flags; the chart of the frame time the game reported beside the session's own frame time; FSR's
|
||||
memory only if the game asks for it. (d) **The option on, a DLSS title**: most are expected to say *the game made
|
||||
none of the calls these are read from*. If one shows rows, this is the first sight of them anywhere: the output
|
||||
size against the display resolution, the preset letters against the NVIDIA app's override or the DLSS
|
||||
indicator, HDR input against the game's HDR setting. Write down which title did. (e) **The sentence under the
|
||||
session** says which of the three it was, and the session's summary still names the upscaler and its quality as
|
||||
before. (f) **Two sessions of one game that kept running**, both with the option on: the second one's field-of-
|
||||
view range and counts are its own, not the first one's carried over. (g) **A game under the user-mode anti-cheat
|
||||
exception**, the option on: it runs, the session is hooked, and its trial is not ended by anything new. (h) **What
|
||||
it costs**: the game's own frame rate with the option on and off, and the Agent's processor time in a hooked
|
||||
session (NFR-2: 2.5 % of one core). (i) **The words**: the fourteen new `vi` strings and the Settings text; the
|
||||
`ja` ones are marked `review`. (j) **SonarCloud**: accept `csharpsquid:S3869` on
|
||||
`src/FrameLedger.Infrastructure/Diagnostics/ParentDump.cs` again — the same call the acceptance of beta.24 covers,
|
||||
raised anew because #398 moved it (`13_CI_CD` §SonarCloud says why it is safe); until then `main`'s reliability
|
||||
rating on new code shows E for that one line.
|
||||
**Answered 2026-08-05, do not re-ask:** remove `gameguard` and keep `guard` (approved
|
||||
over a red `Rules` gate, with the reasoning recorded in the merge commit); vendor NVAPI
|
||||
headers **and** `amd64/nvapi64.lib`; Windows 11 is the **measurement scope** only —
|
||||
@@ -657,6 +644,11 @@ Where each owner decision is recorded — the file and its section, and a label
|
||||
| D114 | [`18_GPU_VENDOR_APIS.md`](18_GPU_VENDOR_APIS.md) §Train B | the field of view is stored as a session's range, never as a series |
|
||||
| D115 | [`17_HOOK_ENGINE.md`](17_HOOK_ENGINE.md) §Which struct version carries which field | a tail member of a vendor struct is read only where the upstream tags prove it is there |
|
||||
| D116 | [`18_GPU_VENDOR_APIS.md`](18_GPU_VENDOR_APIS.md) §Train B | "never the camera" is a build gate: `tools/overlay-fields-check.ps1` |
|
||||
| D118 | [`18_GPU_VENDOR_APIS.md`](18_GPU_VENDOR_APIS.md) §Train B | told that the sensor-library fix would take the number D113 gave train B's second release, the owner chose to release it at once as 0.1.0-beta.41: the train's second and third releases are beta.42 and beta.43, train C beta.44, train D beta.45 |
|
||||
| D119 | [`07_IPC.md`](07_IPC.md) §Region 5 | `FLT_MAX` (or +infinity) in an FSR depth plane is stored and shown as "infinite" — three engines pass it for the plane at infinity; for FSR only: for Streamline `FLT_MAX` is the "not set" sentinel and stays absent |
|
||||
| D120 | [`03_METRICS.md`](03_METRICS.md) §Upscaling | a session's upscaler is the technology named on the most samples, and its quality and render size are read from that technology's samples — not the first one named, with the others' values beside it |
|
||||
| D121 | [`HANDOFF.md`](HANDOFF.md) §NEXT | Cyberpunk 2077 was set to FSR upscaling and FrameLedger named none: a detection gap, to be investigated — which first needs a native log that survives the game's exit |
|
||||
| D122 | [`18_GPU_VENDOR_APIS.md`](18_GPU_VENDOR_APIS.md) §Train B | train B's second step is split: **beta.42** has no new patch site (D119–D121 and the patch registry's hardening); **beta.43** is the two new hooks, begun only after the owner has run Cyberpunk on beta.42 and its log was read. The third release is beta.44, train C beta.45, train D beta.46 |
|
||||
| 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`) |
|
||||
|
||||
---
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<!-- Moved from CHANGELOG.md's [Unreleased] when 0.1.0-beta.41 was cut, 2026-11-12 (D66). CHANGELOG.md lists every release. -->
|
||||
|
||||
## [0.1.0-beta.41] - 2026-11-12
|
||||
|
||||
**The forty-first pre-release: one fix, for Advanced metrics with the agent as administrator.** If you run the
|
||||
capture agent as administrator with PawnIO installed and have **Advanced metrics** on, 0.1.0-beta.40 and
|
||||
0.1.0-beta.39, which has the same code and where it was not looked for, could lose sensors: after most sessions the Advanced page stopped showing the processor's readings
|
||||
until it was reopened, and now and then a whole session was stored with the graphics driver's seventeen readings
|
||||
and none of the two hundred from the sensor library. The agent was closing the sensor library in one place while
|
||||
another place was still reading it. It now opens and closes it in one place only, and never while something is
|
||||
reading. If you do not use that combination, nothing changes for you. The same unsigned installer: verify its hash
|
||||
against `SHA256SUMS.txt`, then *More info → Run anyway*.
|
||||
|
||||
**What it is not, yet.** The fix was made from the agent's log of ten real sessions; the fault needs an
|
||||
administrator's agent with PawnIO to show, and has not been seen to be gone on such a PC yet. After a few sessions
|
||||
the agent's log (Logs page) should no longer say *a device is left alone* or *the sensor library did not open*.
|
||||
Everything 0.1.0-beta.40's notes say is not yet done still stands.
|
||||
|
||||
**Updating from `0.1.0-beta.40`:** Help ▸ Check for updates, then *Restart to update* with no game running. No
|
||||
terms to read again, no change to the ledger (schema 23), the detection rules stay at `2026.11.2`. **The code
|
||||
FrameLedger loads into a game — the overlay, the Vulkan layer, the shared-memory layout, the injector — is
|
||||
0.1.0-beta.40's, line for line**; as after every update, a game that was running across it must be restarted
|
||||
before it is measured again.
|
||||
|
||||
**A note on numbers.** The plan for Advanced metrics had named 0.1.0-beta.41 for its next step inside the game (two
|
||||
new hooks). This fix took the number; that step is now 0.1.0-beta.42, and the ones after it move by one as well.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Advanced metrics: the processor's sensors no longer drop out after a session, and a session no longer loses its
|
||||
sensors at the start.** With the agent running as administrator and PawnIO installed, the sensor library was being
|
||||
closed by one part of the agent while another part was still reading it. After most sessions the Advanced page
|
||||
lost the processor's readings until it was reopened, and one session in ten stored only the graphics driver's
|
||||
seventeen series instead of two hundred and twelve. The agent now opens and closes the sensor library in one
|
||||
place, and does not close it while anything is still reading. Found in the first sessions recorded that way; the
|
||||
cause was read from the log and could not be reproduced without that setup, so the next sessions will show
|
||||
whether it is gone — the agent's log should no longer say *a device is left alone* or *the sensor library did not
|
||||
open*. Nothing changes in the code loaded into a game.
|
||||
- **Two comparisons in the Advanced-metrics code say what they mean.** Whether a game gave FSR one field of view or
|
||||
a range of them was decided by comparing two decimal numbers for equality; it is now decided by comparing the two
|
||||
stored values bit for bit. Nothing you see changes. (Found by SonarCloud after 0.1.0-beta.40 was merged.)
|
||||
@@ -0,0 +1,148 @@
|
||||
# HANDOFF history — 0.1.0-beta.40
|
||||
|
||||
*Moved verbatim from `docs/HANDOFF.md` when 0.1.0-beta.41 was cut, 2026-11-12 (owner decision D66); `docs/HANDOFF.md` §How this file is split lists every part. Nothing below was edited, so its "below" and "above" mean HANDOFF.md as it stood then, and a path it writes is relative to `docs/`. **Its release numbers are those of the day it was written**: what it calls beta.41 and beta.42 are train B's second and third releases, now beta.42 and beta.43 (D118).*
|
||||
|
||||
## **START HERE** — 2026-11-12, 0.1.0-beta.40: Advanced metrics inside the game, the first of train B's three releases
|
||||
|
||||
*Status is `docs/changelog/0.1.0-beta.40.md`; this is what no other file carries.* Train B of the owner's
|
||||
"Thông số nâng cao" was planned and approved on 2026-11-11 (D110–D117) as **three releases**, and this is the first:
|
||||
what a hooked game tells its upscaler, read from **calls the Overlay already hooked — no new patch site** — only
|
||||
while the session records Advanced metrics. Four pull requests and this one: #395 (the decisions, the struct-version
|
||||
table, §M16 measured, NFR-2 amended), #396 (shared-memory layout 5, region 5), #397 (the Overlay's reads, the
|
||||
`overlay-fields-check` gate, the overhead measured), #398 (the Agent's sampler, the catalog's reach `Game`, the
|
||||
page's words, Privacy Policy 2.16). **The design is [`18_GPU_VENDOR_APIS.md`](18_GPU_VENDOR_APIS.md) §Train B; the
|
||||
contract of the new region is [`07_IPC.md`](07_IPC.md) §Region 5; what each hooked call reads is
|
||||
[`17_HOOK_ENGINE.md`](17_HOOK_ENGINE.md) §Hook inventory.** The plan as approved, the review that changed it and the
|
||||
order of the trains are [`handoff/history/0.1.0-beta.39.md`](handoff/history/0.1.0-beta.39.md) §NEXT.
|
||||
|
||||
### What this train decided that the plan had not
|
||||
|
||||
None of these is an owner decision; each was found while building, and is written where it binds.
|
||||
|
||||
- **"On" is a request of the session's own, not a 1** (#397, `07_IPC` §Region 5). The plan had the control word as
|
||||
0 or 1. A game outlives a session, and the Overlay's summaries with it — a second session of a game that kept
|
||||
running would have read the first one's field-of-view range and counts. The Agent now writes a value no session of
|
||||
that ring used, the watchdog starts its summaries afresh at a value it has not seen and names it in every
|
||||
publication, and the reader keeps only a publication that names its own. Found while writing the injected test,
|
||||
before anything shipped; layout 5 was changed in place (`reserved0` became `request`), which was possible only
|
||||
because no release had carried it.
|
||||
- **One module's calls are counted**, for the memory query as for the dispatch: a loader that passes a call on to a
|
||||
leaf's export is seen at two hooks.
|
||||
- **Five of the thirteen entries are tables**, not text (`sl.dlss.presets`, `sl.dlss.exposure`,
|
||||
`ffx.upscale.sharpening`, `.jitter`, `.depth`): a row's name is the vendor's own member name, so nothing but a
|
||||
switch's on/off and a flag's name needs translating. The catalog's unit and two summaries changed; no id did.
|
||||
- **What became of the in-game entries is stored with the session** (`AdvancedSources.InGame`): read, nothing seen,
|
||||
not hooked. Without it a session whose game set its DLSS options through `slDLSSSetOptions` would look like a
|
||||
game with no upscaler.
|
||||
- **The Disclaimer stays 2.15.** The accuracy statement gained an item, as in beta.19, beta.20 and beta.25, none of
|
||||
which moved it; the Privacy Policy went to 2.16 with the content the plan approved.
|
||||
- **A crash dump is tried three times** (#398). Not this train's subject: `CrashDumpHelperTests` failed under the
|
||||
full gate for the third time in two days, and the cause — `MiniDumpWriteDump` of a running process that changes
|
||||
under it — costs a real crash its only dump in exactly the same way.
|
||||
|
||||
### NEXT
|
||||
|
||||
1. **The owner runs item 38** — this release on real games. **Nothing of train B is begun before that**: the wait
|
||||
is what the split into three releases is for (D113).
|
||||
2. **0.1.0-beta.41, when the owner says item 38 passed**: two new hooks, `slSetConstants` and `ffxConfigure`. The
|
||||
design is in `18` §Train B and the plan in [`handoff/history/0.1.0-beta.39.md`](handoff/history/0.1.0-beta.39.md)
|
||||
§NEXT; region 5 already has their members (`sl*`, `ffxFg*`), so no layout changes. What to settle first, in a
|
||||
plan of its own: `kMaxPatches = 48` against the patch count with the new rows; the window of `sl::Constants` that
|
||||
is read, pinned by `static_assert` so that the camera members stay outside it; the overhead of a call made every
|
||||
frame for every viewport, measured before the merge; `overlay-fields-check`'s list and its parameters for the two
|
||||
new structs.
|
||||
3. **0.1.0-beta.42, when the owner says the one before passed**: `slGetFeatureVersion` and
|
||||
`slGetFeatureRequirements` — calls a game makes while starting, so most sessions will say the game did not make
|
||||
them after FrameLedger attached. The release notes and the page say so.
|
||||
4. **Trains C and D** (Reflex latency → beta.43; the Streamline state behind `slGetFeatureFunction` → beta.44) each
|
||||
begin with a spike and end in the owner's go or no. D needs an amendment of rule 4 if it goes ahead.
|
||||
|
||||
### Left open by this session
|
||||
|
||||
- ~~**This release's own facts** — the tag's run, the digests, the delta — are not in any file yet: the release is cut
|
||||
after this text. Record them in the next pull request, as beta.39's were in #395.~~ **Recorded 2026-11-12, in the
|
||||
pull request after the release: 0.1.0-beta.40 was released 2026-11-11T19:30:13Z** (02:30 on the 12th in the
|
||||
owner's time zone, which is the date the changelog carries; the legal documents' *Effective* date is the UTC one,
|
||||
2026-11-11 — the fifth release to straddle midnight that way, after beta.9, .10, .12 and .14) from the signed tag
|
||||
on `5268332` (#399), by run 43085044822 — green at the first attempt, one run for the one tag push. Eight assets;
|
||||
the seven digests of `SHA256SUMS.txt` equal the ones GitHub computed; the shipped natives carry `FL_BUILD_ID
|
||||
v0.1.0-beta.40`. The delta from beta.39 is 2,413,166 bytes beside a full package of 110,707,319 — "Delta processed
|
||||
0452 files. 0025 patched, 0427 unchanged". The wiki was published by run 43087844607. The rehearsal on the release
|
||||
branch (run 43082208739) had made a delta of 2,426,184 bytes with the same file counts.
|
||||
- **Nothing here was read from a real game, and nothing was seen in the running App.** The values come from
|
||||
`hook-harness --advanced` and the FidelityFX stub; the page's new rows were loaded by its tests and looked at by
|
||||
nobody. All of it is owner-only item 38.
|
||||
- **Whether any shipping title chains `sl::DLSSOptions` into `slEvaluateFeature`** is not known. If none of the
|
||||
owner's games does, the six `sl.dlss.*` entries read N/A everywhere until train D, and the page already says why.
|
||||
- **The aliasable part of FSR's memory** is read and published and not shown: the catalog has one memory entry.
|
||||
- **What the owner's first evening with it showed** (2026-11-12, read from a copy of the ledger and the Agent's log;
|
||||
ten hooked sessions on eight games, no fault in any, the Overlay `Ready` at every end):
|
||||
- **Read from a real game for the first time: Lies of P** (FSR 3 through `amd_fidelityfx_dx12.dll` 1.0.1, the
|
||||
SDK 1.1.x monolith) — sharpening on at 0.5, jitter up to 0.48 / 0.49 of a pixel, pre-exposure 0.25–1, a vertical
|
||||
field of view from 21.6° to 73.7°, no flag, and a reported frame time whose median is 16.67 ms beside a native
|
||||
rate of 55.6 FPS. The series starts 83 seconds in and has no gap after. Whether these match the game's own
|
||||
settings is still the owner's to say (item 38 (c)).
|
||||
- **`cameraNear` is absent there and `cameraFar` is 10.** Most likely the game runs an inverted, infinite depth
|
||||
and passes `FLT_MAX` for the plane at infinity, which the Overlay refuses as a value nobody set. "Infinite" would
|
||||
be the true answer. It is a change in code loaded into a game: decide it in beta.41's plan, not before.
|
||||
- **Every other game said *the game made none of the calls***, as expected: all ran DLSS. Dying Light: The Beast
|
||||
evaluates DLSS through Streamline and chains no `DLSSOptions` — the first evidence on that open question, and
|
||||
it is a no. Valor Mortis, Phantom Blade Zero, Clair Obscur and Kingdom Come: Deliverance II ship AMD's FSR 3.1+
|
||||
libraries and did not upscale through them in these sessions, so **no FSR 3.1+ title has been read yet**.
|
||||
- **The option off stored nothing** (Black Myth: Wukong, one session each way), and **a game under the user-mode
|
||||
anti-cheat exception ran with it on** (Girls' Frontline 2, trial 1 of 2).
|
||||
- **Valor Mortis ended with an access violation 51 seconds after injection, once**; the next launch ran fourteen
|
||||
minutes on the same build. The Overlay counted no fault and Windows logged no application error. Not attributed
|
||||
and not ruled out; its crash count stands at 1, and a second such end switches its hooking off.
|
||||
- **The sensor library was closed under its other users** — a defect of train A that only an elevated Agent with
|
||||
PawnIO can show. `20_OPEN_QUESTIONS` §M13 has what was seen; `LhmLibrary` is the fix; the owner's next sessions
|
||||
say whether it holds.
|
||||
- **`LIMITATIONS.md` and the accuracy statement still say the processor's, the memory's and the motherboard's
|
||||
sensors "have never been read on real hardware".** They have now been read on one PC and compared with nothing.
|
||||
The sentence is the owner's to reword.
|
||||
- ~~**SonarCloud on #398** had not answered when this was written; #397's three findings are fixed in #398.~~
|
||||
**It answered after the merge, with three findings on new code**, handled in the pull request after the release:
|
||||
two `csharpsquid:S1244` in `InGameAdvancedSampler` — a lowest and a highest float compared with `==` to tell one
|
||||
value from a range; they are now told apart by their bits, which is what was meant — and one
|
||||
`csharpsquid:S3869`, a blocker, on `ParentDump`'s `DangerousGetHandle`. That one is **not new and not fixed**: the
|
||||
owner accepted it in beta.24 (`13_CI_CD` §SonarCloud), #398 moved the same expression into a new method, and
|
||||
SonarCloud tracks an issue by its place. It needs the owner's *Accept* again — item 38 (j).
|
||||
- **The `vi` strings were written by the assistant and the `ja` ones are marked `review`** — fourteen more keys and
|
||||
the reworded Settings text.
|
||||
- **`LogNoteW`** is still there (owner-only item 36 (d)), item 37 is still unrun, and the alpha line still rests
|
||||
(D98): no alpha follows this release.
|
||||
|
||||
### Traps this train paid for
|
||||
|
||||
- **A library that is "one object per user" may still be one per process underneath.** Three `Computer`s of
|
||||
LibreHardwareMonitor shared a driver handle and mutexes; each was tested alone, unelevated, where the shared part
|
||||
is never opened. Before composing a second instance of anything that talks to a driver, ask what its `Close`
|
||||
closes. And `first ??= TryClose(x)` in a loop stops closing at the first throw — the test for "all are closed
|
||||
even when one throws" caught it in the fix itself.
|
||||
- **A heredoc in the tool's shell breaks on an odd number of apostrophes** — a script with `game's` in it fails with
|
||||
"unexpected EOF while looking for matching `'`" before Python ever runs. Write the script to a file and run the
|
||||
file.
|
||||
- **A region that outlives its reader needs to say whose data it holds.** Region 4 never had the problem — it is
|
||||
the swap chain's state, the same for any session. Region 5 holds summaries, and a summary has a beginning. Ask of
|
||||
any new shared state: what does the second session of the same process read in its first second?
|
||||
- **SonarCloud's engine does not see a Catch2 `REQUIRE` end a path**: `REQUIRE(OpenRingFor(pid, r))` followed by
|
||||
`r.st->…` is a null dereference to it (`cpp:S2259`, a failed gate on new code). An explicit `return` after the
|
||||
`REQUIRE` is what it follows. And a `LARGE_INTEGER` read through `QuadPart` is initialised through `QuadPart`
|
||||
(`cpp:S6232`) — `13_CI_CD` §SonarCloud has had the rule since #336; new code still forgot it.
|
||||
- **SonarCloud fails after the merge.** Its job is advisory and slower than the required checks, so auto-merge lands
|
||||
the pull request first. Read its result on the merged pull request before building on it.
|
||||
- **`MA0051` counts sixty lines, comments included**, and `CaptureSession.SuperviseAsync` was at fifty-nine: one
|
||||
line more is a build error. What a session asks once belongs where the session's state is made, not in the loop.
|
||||
- **`RCS1242` refuses `in` for a struct that is not `readonly`** — the mirror structs are not. Pass the object that
|
||||
holds the struct and take `ref readonly` inside.
|
||||
- **`/W4 /WX` refuses `alignas` on a struct it then has to pad** (C4324): align the variable, not the type.
|
||||
- **The `.resx` files hold a literal apostrophe**, not `'`: an edit script that searches for the entity finds
|
||||
nothing and stops half-way through.
|
||||
- **`ISessionRepository.FindAdvancedSensorsAsync` returns `t_ms` too**: "no advanced series" is "no series under
|
||||
`adv.`", not an empty list.
|
||||
- **PowerShell reads a backtick in a double-quoted string as an escape** (`` `r `` is a carriage return) and
|
||||
`"$name: text"` as a scoped variable: in a gate's messages, quote names with apostrophes and write `${name}:`.
|
||||
|
||||
**Owner-only:** item 38 — beta.40 on real games: the update and the Privacy Policy 2.16, a game that was running
|
||||
across the update, an FSR 3.1+ title and a DLSS title with the option on, the same with it off, a second session of
|
||||
a game that kept running, a game under the user-mode anti-cheat exception, and what the Agent costs.
|
||||
@@ -1,6 +1,6 @@
|
||||
# Owner-only items that passed
|
||||
|
||||
*Moved verbatim from `docs/HANDOFF.md` §Owner-only on 2026-10-19 (beta.24, owner decision D66): the items the owner reported passed or took, numbers kept — a number is never reused. The open ones stay in `docs/HANDOFF.md`.*
|
||||
*Moved verbatim from `docs/HANDOFF.md` §Owner-only on 2026-10-19 (beta.24, owner decision D66): the items the owner reported passed or took, numbers kept — a number is never reused. The open ones stay in `docs/HANDOFF.md`. Items that passed later are added below as they pass (38 and 39 on 2026-11-12).*
|
||||
|
||||
3. ~~**Which titles** go in `blockedExecutables` — a product decision with false-refusal
|
||||
consequences. The list ships empty until it is taken.~~ **Taken 2026-09-25 (D30):** per-title
|
||||
@@ -66,4 +66,40 @@
|
||||
page and choose its longest session, switch the page's tabs; visit the Dashboard a few times, then end a session —
|
||||
one "Session saved". (e) The Privacy Policy 2.11 is shown once after the update. (f) The `ja` strings marked
|
||||
`review`.
|
||||
|
||||
38. ~~**beta.40, Advanced metrics inside a real game**~~ **Passed 2026-11-12** — the owner ran it on ten games over one night (beta.40, then beta.41), was shown what a copy of the ledger and the Agent's log said of those sessions, and answered: "Bạn có thể đánh dấu là pass và tiếp tục." What the sessions covered: (b) the option off storing nothing, on a DLSS title and on an FSR 3.1 one; (c) three titles upscaling through FSR 3.1 — Kingdom Come: Deliverance II (chosen in the game), Dying Light: The Beast and Clair Obscur: Expedition 33, the last two with **FSR upscaling beside DLSS frame generation, which is how the owner had set them in the game** — and Lies of P through FSR 3; (d) every DLSS title saying *the game made none of the calls*, none chaining its options into the evaluation; (e) the sentence under the session in each of its three forms; (g) Girls' Frontline 2 under the user-mode exception. **Not exercised, and passed on the owner's word**: (f) two sessions of one game that kept running; (h) the cost; (i) the words. **(j) is not done**: the SonarCloud acceptance is still the owner's to click, and stands in HANDOFF §Left open. Valor Mortis's one crash was the game's own (a shader-compilation error, its own crash dialog — the owner). *(The item as written:)* (D111–D116; train B's first release — beta.41 is not begun
|
||||
until this passes). (a) **The update from beta.39**: the terms window shows the **Privacy Policy 2.16** once, and
|
||||
not the Disclaimer; a game that was **running across the update** is refused until it is restarted, with the
|
||||
reason, and measured normally after. (b) **The option off, a hooked game that uses DLSS or FSR**: the game runs
|
||||
and is measured as in beta.39; the session is not on the Advanced page's list; nothing in the Agent's or the
|
||||
Overlay's log mentions the upscaler's options. (c) **The option on, a title that upscales through FSR 3.1 or
|
||||
later** (AMD's `amd_fidelityfx_*.dll` in its folder; a title on the older FSR 3.0 interface, such as one that
|
||||
ships `ffx_fsr3_x64.dll` alone, is expected to show none): on *Session*, under Upscaling, sharpening on or off
|
||||
and its strength against the game's own setting; the field of view as a range, against the game's slider (it is
|
||||
the **vertical** angle, in radians with degrees beside it) — and wider after zooming or aiming; the near and far
|
||||
planes; the flags; the chart of the frame time the game reported beside the session's own frame time; FSR's
|
||||
memory only if the game asks for it. (d) **The option on, a DLSS title**: most are expected to say *the game made
|
||||
none of the calls these are read from*. If one shows rows, this is the first sight of them anywhere: the output
|
||||
size against the display resolution, the preset letters against the NVIDIA app's override or the DLSS
|
||||
indicator, HDR input against the game's HDR setting. Write down which title did. (e) **The sentence under the
|
||||
session** says which of the three it was, and the session's summary still names the upscaler and its quality as
|
||||
before. (f) **Two sessions of one game that kept running**, both with the option on: the second one's field-of-
|
||||
view range and counts are its own, not the first one's carried over. (g) **A game under the user-mode anti-cheat
|
||||
exception**, the option on: it runs, the session is hooked, and its trial is not ended by anything new. (h) **What
|
||||
it costs**: the game's own frame rate with the option on and off, and the Agent's processor time in a hooked
|
||||
session (NFR-2: 2.5 % of one core). (i) **The words**: the fourteen new `vi` strings and the Settings text; the
|
||||
`ja` ones are marked `review`. (j) **SonarCloud**: accept `csharpsquid:S3869` on
|
||||
`src/FrameLedger.Infrastructure/Diagnostics/ParentDump.cs` again — the same call the acceptance of beta.24 covers,
|
||||
raised anew because #398 moved it (`13_CI_CD` §SonarCloud says why it is safe); until then `main`'s reliability
|
||||
rating on new code shows E for that one line.
|
||||
39. ~~**beta.41, the sensor library on the PC that showed the fault**~~ **Passed 2026-11-12** — the same answer. Seven sessions on beta.41 as administrator with PawnIO, no `advanced:` line in the Agent's log, 212 or 213 series in each session with the option on; on beta.40 the same morning the processor device faulted out after each of six sessions. **Not exercised**: (c) the page after a session was not looked at by anyone but the owner; (d) the unelevated run; (e) no value beside HWiNFO — that stays item 37 (e). The rarer fault, the reader failing to open, was one session in sixteen; `20_OPEN_QUESTIONS` §M13 keeps the count. *(The item as written:)* (D118; `20_OPEN_QUESTIONS` §M13). (a) **The
|
||||
update from beta.40**: no terms window, the ledger opens as before; a game running across the update is refused
|
||||
until restarted, as after every update. (b) **As administrator with PawnIO, Advanced metrics on**: five or more
|
||||
sessions of different games, some with the Advanced page left open on *This PC* throughout, some with it closed,
|
||||
one started within a few seconds of another ending. **Afterwards the Agent's log (Logs page, or
|
||||
`agent-<date>.log`) holds no `advanced: a device is left alone` and no `advanced: the sensor library did not
|
||||
open`**, and every one of those sessions has its processor, memory and motherboard readings on *Session* (about
|
||||
two hundred series; a session with seventeen is the fault). (c) **The page after a session ends**: the
|
||||
processor's rows on *This PC* are still there and still moving, without reopening the page. (d) **Not as
|
||||
administrator**: nothing differs from beta.40 — the card's sensors and the driver's figures, and *Sources* says
|
||||
why the rest is not read. (e) While there, the part of item 37 (e) nobody has done: a few of the processor's and
|
||||
the motherboard's values beside HWiNFO.
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
HTML comments are not part of the block.
|
||||
-->
|
||||
> ⚠ **What FrameLedger actually measures today — 2026-11-11.** The software is a beta; its latest
|
||||
> **beta is `0.1.0-beta.40`** (2026-11-12), an unsigned installer built from that tag with its
|
||||
> **beta is `0.1.0-beta.41`** (2026-11-12), an unsigned installer built from that tag with its
|
||||
> checksums published beside it (alphas — experimental builds that try a newer .NET — are published apart). The source holds the desktop app
|
||||
> (library, store import, charts, settings) and the background Agent, which records a session when a
|
||||
> game in the library runs (unless you switched its recording off), injects only into games you enabled
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ Frame timing is derived from high-resolution timestamps taken at the moment the
|
||||
|
||||
<!-- accuracy-block:begin -->
|
||||
> ⚠ **What FrameLedger actually measures today — 2026-11-11.** The software is a beta; its latest
|
||||
> **beta is `0.1.0-beta.40`** (2026-11-12), an unsigned installer built from that tag with its
|
||||
> **beta is `0.1.0-beta.41`** (2026-11-12), an unsigned installer built from that tag with its
|
||||
> checksums published beside it (alphas — experimental builds that try a newer .NET — are published apart). The source holds the desktop app
|
||||
> (library, store import, charts, settings) and the background Agent, which records a session when a
|
||||
> game in the library runs (unless you switched its recording off), injects only into games you enabled
|
||||
|
||||
@@ -179,14 +179,22 @@ public static class SessionAggregator
|
||||
|
||||
private static SessionRow ApplyUpscaler(SessionRow row, Context c)
|
||||
{
|
||||
UpscaleExtent? extent = UpscaleExtent.From(c.Dominant);
|
||||
FlUpscaler? identity = FgLadder.UpscalerIdentity(c.Input.Records);
|
||||
// ONE TECHNOLOGY'S NAME, QUALITY AND SIZE (D120, 2026-11-12): the technology named on the most samples of
|
||||
// the dominant stream, and - when the session names more than one - only the samples that name it. The name
|
||||
// used to be the first one any record carried, beside a quality byte and a render size taken from whichever
|
||||
// records had them: a session that saw DLSS briefly and then ran FSR was "DLSS" with FSR's byte and size.
|
||||
UpscalerChoice choice = UpscalerChoice.From(c.Dominant);
|
||||
UpscaleExtent? extent = UpscaleExtent.From(choice.Samples);
|
||||
// A dominant stream that names nothing leaves the name to any other stream that does, as before.
|
||||
string? named = choice.Kind is { } kind
|
||||
? Vocabulary.Upscaler(kind)
|
||||
: FgLadder.UpscalerIdentity(c.Input.Records) is { } elsewhere ? Vocabulary.Upscaler(elsewhere) : null;
|
||||
bool hookRan = FgLadder.UpscalerHookRan(c.Input.Records);
|
||||
IReadOnlyList<FrameSample> withParams = [.. c.Dominant.Where(static s => s.Claims(MeasuredFields.UpscalerParams))];
|
||||
IReadOnlyList<FrameSample> withParams = [.. choice.Samples.Where(static s => s.Claims(MeasuredFields.UpscalerParams))];
|
||||
return row with
|
||||
{
|
||||
Upscaler = identity is { } u ? Vocabulary.Upscaler(u) : hookRan ? "unknown" : null,
|
||||
UpscalerQuality = QualityByte.Of(withParams)?.ToString(CultureInfo.InvariantCulture),
|
||||
Upscaler = named ?? (hookRan ? "unknown" : null),
|
||||
UpscalerQuality = choice.QualityFor(QualityByte.Of(withParams))?.ToString(CultureInfo.InvariantCulture),
|
||||
UpscalerSharpness = Modal(withParams, static s => s.UpscalerSharpness),
|
||||
UpscalerDriverReported = c.Input.Ngx.SrCreatedAndEvaluated ? "dlss" : null,
|
||||
RenderW = extent?.RenderW,
|
||||
@@ -194,7 +202,9 @@ public static class SessionAggregator
|
||||
OutputW = extent?.OutputW,
|
||||
OutputH = extent?.OutputH,
|
||||
UpscaleRatio = extent?.Ratio,
|
||||
SettingsChangedMidSession = c.Segments.Count(s => s.Samples.Count > 0) > c.All.Select(static s => s.SwapchainId).Distinct().Count(),
|
||||
// A second technology named in one session is a setting changed mid-session, as a changed output size is.
|
||||
SettingsChangedMidSession = choice.Named > 1
|
||||
|| c.Segments.Count(s => s.Samples.Count > 0) > c.All.Select(static s => s.SwapchainId).Distinct().Count(),
|
||||
HdrFlag = Vocabulary.Tri(c.Hdr),
|
||||
HdrSource = c.Hdr == Tri.NotApplicable ? null : Vocabulary.Measured,
|
||||
};
|
||||
@@ -408,10 +418,9 @@ public static class SessionAggregator
|
||||
FrameStatistics stats = c.Generating
|
||||
? FrameStatistics.From(FrameTimeSeries.ApplicationFrames(seg.Samples, null, c.Input.QpcFrequency).FrameTimesMs, presented: false)
|
||||
: FrameStatistics.From(series.FrameTimesMs, presented: true);
|
||||
UpscaleExtent? extent = UpscaleExtent.From(seg.Samples);
|
||||
UpscalerKind? upscaler = seg.Samples.Where(static s => s.Claims(MeasuredFields.Upscaler))
|
||||
.Select(static s => s.Upscaler)
|
||||
.FirstOrDefault(static u => u is not UpscalerKind.NotReported and not UpscalerKind.Unknown and not UpscalerKind.RetiredRayReconstruction, UpscalerKind.NotReported);
|
||||
// The segment's upscaler is chosen as the session's is (D120): one technology's name, quality and size.
|
||||
UpscalerChoice choice = UpscalerChoice.From(seg.Samples);
|
||||
UpscaleExtent? extent = UpscaleExtent.From(choice.Samples);
|
||||
rows.Add(new SegmentRow
|
||||
{
|
||||
SwapchainId = seg.SwapchainId,
|
||||
@@ -421,8 +430,8 @@ public static class SessionAggregator
|
||||
RenderH = extent?.RenderH,
|
||||
OutputW = seg.OutputW == 0 ? null : seg.OutputW,
|
||||
OutputH = seg.OutputH == 0 ? null : seg.OutputH,
|
||||
Upscaler = upscaler is { } u && u != UpscalerKind.NotReported ? Vocabulary.Upscaler(u) : null,
|
||||
UpscalerQuality = QualityByte.Of([.. seg.Samples.Where(static s => s.Claims(MeasuredFields.UpscalerParams))])?.ToString(CultureInfo.InvariantCulture),
|
||||
Upscaler = choice.Kind is { } u ? Vocabulary.Upscaler(u) : null,
|
||||
UpscalerQuality = choice.QualityFor(QualityByte.Of([.. choice.Samples.Where(static s => s.Claims(MeasuredFields.UpscalerParams))]))?.ToString(CultureInfo.InvariantCulture),
|
||||
FgMode = null,
|
||||
NativeFps = null,
|
||||
DisplayedFps = series.AverageFps,
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
namespace FrameLedger.Domain.Metrics;
|
||||
|
||||
/// <summary>
|
||||
/// Which upscaler a stream of samples names, and the samples its quality and render size are to be read from - so
|
||||
/// that the name, the quality and the size a session shows are those of ONE technology (owner decision D120,
|
||||
/// 2026-11-12; <c>03_METRICS</c> §Upscaling).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// <b>WHY.</b> The session's name used to be the FIRST technology any record named, while its quality byte and its
|
||||
/// render size came from whichever records carried them. A real session of 81 seconds (Dying Light: The Beast, an FSR
|
||||
/// dispatch and a DLSS evaluation both seen) was stored as "DLSS" with FSR's quality byte and FSR's render size: three
|
||||
/// true readings, of two technologies, under one name.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <b>THE RULE.</b> The technology named on the most samples; a tie goes to the lower value, as
|
||||
/// <see cref="QualityByte.Of"/> breaks its own. While only one technology is named the samples are the whole stream,
|
||||
/// exactly as before - under frame generation a name sits on one present in N, and the render size of the presents
|
||||
/// between must still count. When more than one is named, the samples are those that name the chosen one, and
|
||||
/// nothing of the other is carried under its name.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public sealed record UpscalerChoice
|
||||
{
|
||||
private UpscalerChoice(UpscalerKind? kind, int named, IReadOnlyList<FrameSample> samples)
|
||||
{
|
||||
Kind = kind;
|
||||
Named = named;
|
||||
Samples = samples;
|
||||
}
|
||||
|
||||
/// <summary>The technology named on the most samples; null when no sample names one.</summary>
|
||||
public UpscalerKind? Kind { get; }
|
||||
|
||||
/// <summary>How many different technologies the stream names. More than one is a setting changed mid-session.</summary>
|
||||
public int Named { get; }
|
||||
|
||||
/// <summary>The samples the quality and the render size are read from.</summary>
|
||||
public IReadOnlyList<FrameSample> Samples { get; }
|
||||
|
||||
/// <summary>True for a value that names a technology: not "not reported", not "unknown", not the retired value.</summary>
|
||||
public static bool IsNamed(UpscalerKind kind) =>
|
||||
kind is not (UpscalerKind.NotReported or UpscalerKind.Unknown or UpscalerKind.RetiredRayReconstruction);
|
||||
|
||||
/// <summary>True for FSR in any of its versions, the family <see cref="QualityByte.IsFsr"/>'s bytes belong to.</summary>
|
||||
public static bool IsFsr(UpscalerKind kind) =>
|
||||
kind is UpscalerKind.Fsr2 or UpscalerKind.Fsr3 or UpscalerKind.Fsr4 or UpscalerKind.FsrUnversioned;
|
||||
|
||||
/// <summary>
|
||||
/// A quality byte that belongs to the named technology's family, or null: FSR's bytes under an FSR name, any
|
||||
/// other byte under any other name. A byte of the other family is withheld rather than shown under a name it
|
||||
/// was not measured for.
|
||||
/// </summary>
|
||||
public byte? QualityFor(byte? quality) =>
|
||||
quality is byte value && Kind is { } kind && QualityByte.IsFsr(value) != IsFsr(kind) ? null : quality;
|
||||
|
||||
public static UpscalerChoice From(IReadOnlyList<FrameSample> stream)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(stream);
|
||||
(UpscalerKind Kind, int Count)[] named =
|
||||
[
|
||||
.. stream
|
||||
.Where(static s => s.Claims(MeasuredFields.Upscaler) && IsNamed(s.Upscaler))
|
||||
.GroupBy(static s => s.Upscaler)
|
||||
.Select(static g => (g.Key, g.Count()))
|
||||
.OrderByDescending(static g => g.Item2)
|
||||
.ThenBy(static g => g.Key),
|
||||
];
|
||||
if (named.Length == 0)
|
||||
{
|
||||
return new UpscalerChoice(kind: null, named: 0, stream);
|
||||
}
|
||||
|
||||
UpscalerKind chosen = named[0].Kind;
|
||||
return named.Length == 1
|
||||
? new UpscalerChoice(chosen, named: 1, stream)
|
||||
: new UpscalerChoice(chosen, named.Length, [.. stream.Where(s => s.Claims(MeasuredFields.Upscaler) && s.Upscaler == chosen)]);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,12 @@ namespace FrameLedger.Infrastructure.Telemetry;
|
||||
/// reader that opens them counts faults per device and reads on a thread of its own.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <b>Amended 2026-11-12: a user of <see cref="LhmLibrary"/>, not the owner of a <c>Computer</c>.</b> The library keeps
|
||||
/// part of its state per process, and closing one <c>Computer</c> took it from under the others — found in the first
|
||||
/// sessions recorded as administrator with PawnIO. Opening and closing now go through the process's one
|
||||
/// <see cref="LhmLibrary"/>, which serialises them and parks a closed <c>Computer</c> while another is in use.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Consumed <b>unmodified</b>, as an ordinary NuGet package reference. MPL-2.0 §3.3 is what
|
||||
/// makes that combinable with GPLv3; modifying a file of it would change the obligation
|
||||
/// (<c>legal/THIRD_PARTY_NOTICES.md</c> §GPL-3.0 compatibility).
|
||||
@@ -31,35 +37,43 @@ namespace FrameLedger.Infrastructure.Telemetry;
|
||||
/// </remarks>
|
||||
public sealed class LhmComputerAdapter : ILhmComputer
|
||||
{
|
||||
private readonly Computer _computer;
|
||||
private readonly LhmLibrary _library;
|
||||
private readonly LhmGroups _groups;
|
||||
private ILhmComputer? _computer;
|
||||
|
||||
public LhmComputerAdapter(bool enableCpuAndMemory, bool enableGpu = true)
|
||||
: this((enableGpu ? LhmGroups.Gpu : LhmGroups.None) | (enableCpuAndMemory ? LhmGroups.Cpu | LhmGroups.Memory : LhmGroups.None))
|
||||
{
|
||||
_computer = new Computer
|
||||
{
|
||||
IsGpuEnabled = enableGpu,
|
||||
IsCpuEnabled = enableCpuAndMemory,
|
||||
IsMemoryEnabled = enableCpuAndMemory,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The groups <paramref name="groups"/> names, and no other (D103).</summary>
|
||||
public LhmComputerAdapter(LhmGroups groups)
|
||||
: this(groups, LhmLibrary.Process)
|
||||
{
|
||||
_computer = new Computer
|
||||
{
|
||||
IsGpuEnabled = groups.HasFlag(LhmGroups.Gpu),
|
||||
IsCpuEnabled = groups.HasFlag(LhmGroups.Cpu),
|
||||
IsMemoryEnabled = groups.HasFlag(LhmGroups.Memory),
|
||||
IsMotherboardEnabled = groups.HasFlag(LhmGroups.Motherboard),
|
||||
};
|
||||
}
|
||||
|
||||
public IReadOnlyList<IHardware> Hardware => [.. _computer.Hardware];
|
||||
/// <summary>The same, over a library of the caller's: the tests', which opens no driver.</summary>
|
||||
public LhmComputerAdapter(LhmGroups groups, LhmLibrary library)
|
||||
{
|
||||
_groups = groups;
|
||||
_library = library ?? throw new ArgumentNullException(nameof(library));
|
||||
}
|
||||
|
||||
public void Open() => _computer.Open();
|
||||
/// <summary>The tree of the open <c>Computer</c>; empty before <see cref="Open"/> and after <see cref="Close"/>.</summary>
|
||||
public IReadOnlyList<IHardware> Hardware => _computer?.Hardware ?? [];
|
||||
|
||||
public void Update() => _computer.Accept(new UpdateVisitor());
|
||||
/// <summary>Opens once: a second call while open changes nothing.</summary>
|
||||
public void Open() => _computer ??= _library.Open(_groups);
|
||||
|
||||
public void Close() => _computer.Close();
|
||||
public void Update() => _computer?.Update();
|
||||
|
||||
/// <summary>Lets go once: the library decides whether the <c>Computer</c> is closed now or parked.</summary>
|
||||
public void Close()
|
||||
{
|
||||
if (_computer is { } computer)
|
||||
{
|
||||
_computer = null;
|
||||
_library.Close(_groups, computer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Runtime.ExceptionServices;
|
||||
using LibreHardwareMonitor.Hardware;
|
||||
|
||||
namespace FrameLedger.Infrastructure.Telemetry;
|
||||
|
||||
/// <summary>
|
||||
/// The one LibreHardwareMonitor a process has: every <c>Computer</c> this product opens is opened and closed
|
||||
/// through here, one at a time, and none is really closed while another is still in use.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// <b>WHY (2026-11-12, the first sessions recorded as administrator with PawnIO).</b> The Agent holds up to three
|
||||
/// <c>Computer</c>s at once — a session's L2 source, its CPU-temperature reader, and the shared reader of Advanced
|
||||
/// metrics — each opened and closed on its own schedule, from its own thread. LibreHardwareMonitorLib keeps part of
|
||||
/// its state per process, not per <c>Computer</c>: the driver it reads the processor through and the mutexes it
|
||||
/// guards the buses with. <c>Computer.Close()</c> lets go of that shared part whoever else still has a
|
||||
/// <c>Computer</c> open. On the owner's PC, with an i7-14700KF:
|
||||
/// </para>
|
||||
/// <list type="bullet">
|
||||
/// <item>after seven sessions of ten, some seconds after the session's own sources closed, the Advanced reader's
|
||||
/// processor device threw <c>NullReferenceException</c> on two updates running and was left alone — the page lost
|
||||
/// the processor's sensors until the reader was opened again;</item>
|
||||
/// <item>once, a session's start and another instance's close met: the Advanced reader's <c>Open</c> threw
|
||||
/// <c>ObjectDisposedException</c> on a wait handle, and that session stored the NVIDIA driver's seventeen series
|
||||
/// and none of the sensor library's hundred and ninety-five.</item>
|
||||
/// </list>
|
||||
/// <para>
|
||||
/// Neither can be seen unelevated — without PawnIO the processor group reads nothing through a driver — which is why
|
||||
/// no test met it before a real run did. The cause is read from the timing in the Agent's log, not reproduced: the
|
||||
/// tests here hold the two rules below, and whether they end the faults is the owner's next sessions to show.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <b>THE TWO RULES.</b> (1) <c>Open</c> and <c>Close</c> are serialised: no two run at once. (2) A <c>Computer</c>
|
||||
/// closed by its user while another is open is <b>parked</b> — left open, read by nobody — and handed to the next user
|
||||
/// who asks for the same groups; the library is closed for real when its last user lets go, and then every parked
|
||||
/// one is closed with it. So the shared part goes only when nobody is reading.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <b>WHAT IS NOT SERIALISED: the reads.</b> A reader updates its devices on its own thread, as before. A lock around
|
||||
/// every read would put the session's once-a-second L2 poll behind the Advanced reader's — the two were put on
|
||||
/// separate threads so that a sensor that hangs in one holds up neither the other nor the pipe
|
||||
/// (<c>18_GPU_VENDOR_APIS</c> §Advanced metrics). Two <c>Computer</c>s reading side by side is what ten real sessions
|
||||
/// did without a fault; it is one closing under the other that failed.
|
||||
/// </para>
|
||||
/// <para>Parked instances are bounded by how many users were ever open at once — three in the Agent.</para>
|
||||
/// </remarks>
|
||||
public sealed class LhmLibrary
|
||||
{
|
||||
private readonly Func<LhmGroups, ILhmComputer> _create;
|
||||
private readonly Lock _gate = new();
|
||||
private readonly List<(LhmGroups Groups, ILhmComputer Computer)> _parked = [];
|
||||
private int _users;
|
||||
|
||||
/// <summary>A library over <paramref name="create"/>; the process has one (<see cref="Process"/>), a test makes its own.</summary>
|
||||
/// <param name="create">Makes a <c>Computer</c> with exactly these groups, not yet opened.</param>
|
||||
public LhmLibrary(Func<LhmGroups, ILhmComputer> create) => _create = create ?? throw new ArgumentNullException(nameof(create));
|
||||
|
||||
/// <summary>The process's own: every <see cref="LhmComputerAdapter"/> goes through it.</summary>
|
||||
public static LhmLibrary Process { get; } = new(static groups => new RealComputer(groups));
|
||||
|
||||
/// <summary>How many users hold a <c>Computer</c> now.</summary>
|
||||
public int Users
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
return _users;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>How many <c>Computer</c>s are open with no user, waiting for the next one or for the last close.</summary>
|
||||
public int Parked
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
return _parked.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An open <c>Computer</c> with these groups: a parked one where there is one, else a new one, opened here. An
|
||||
/// open that throws leaves nothing behind and counts no user.
|
||||
/// </summary>
|
||||
public ILhmComputer Open(LhmGroups groups)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
int at = _parked.FindIndex(p => p.Groups == groups);
|
||||
ILhmComputer computer;
|
||||
if (at >= 0)
|
||||
{
|
||||
computer = _parked[at].Computer;
|
||||
_parked.RemoveAt(at);
|
||||
}
|
||||
else
|
||||
{
|
||||
computer = _create(groups);
|
||||
computer.Open();
|
||||
}
|
||||
|
||||
_users++;
|
||||
return computer;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lets go of a <c>Computer</c> that <see cref="Open"/> returned. While another user remains it is parked, still
|
||||
/// open; the last user's close closes it and every parked one — all of them, even when one throws, and then the
|
||||
/// first exception is thrown on.
|
||||
/// </summary>
|
||||
public void Close(LhmGroups groups, ILhmComputer computer)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(computer);
|
||||
lock (_gate)
|
||||
{
|
||||
if (_users > 0)
|
||||
{
|
||||
_users--;
|
||||
}
|
||||
|
||||
if (_users > 0)
|
||||
{
|
||||
_parked.Add((groups, computer));
|
||||
return;
|
||||
}
|
||||
|
||||
// Every one is closed whatever the one before it did: `first ??= TryClose(...)` would stop closing at the
|
||||
// first throw, which is the one outcome this method exists to rule out.
|
||||
ExceptionDispatchInfo? first = null;
|
||||
foreach ((LhmGroups _, ILhmComputer parked) in _parked)
|
||||
{
|
||||
ExceptionDispatchInfo? thrown = TryClose(parked);
|
||||
first ??= thrown;
|
||||
}
|
||||
|
||||
_parked.Clear();
|
||||
ExceptionDispatchInfo? last = TryClose(computer);
|
||||
(first ?? last)?.Throw();
|
||||
}
|
||||
}
|
||||
|
||||
private static ExceptionDispatchInfo? TryClose(ILhmComputer computer)
|
||||
{
|
||||
try
|
||||
{
|
||||
computer.Close();
|
||||
return null;
|
||||
}
|
||||
catch (Exception e) when (e is not OperationCanceledException)
|
||||
{
|
||||
// Kept, not thrown here: the others are still to be closed, and the shared part of the library with them.
|
||||
return ExceptionDispatchInfo.Capture(e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The real <c>Computer</c>, with the groups asked for and no other (D103).</summary>
|
||||
private sealed class RealComputer(LhmGroups groups) : ILhmComputer
|
||||
{
|
||||
private readonly Computer _computer = new()
|
||||
{
|
||||
IsGpuEnabled = groups.HasFlag(LhmGroups.Gpu),
|
||||
IsCpuEnabled = groups.HasFlag(LhmGroups.Cpu),
|
||||
IsMemoryEnabled = groups.HasFlag(LhmGroups.Memory),
|
||||
IsMotherboardEnabled = groups.HasFlag(LhmGroups.Motherboard),
|
||||
};
|
||||
|
||||
public IReadOnlyList<IHardware> Hardware => [.. _computer.Hardware];
|
||||
|
||||
public void Open() => _computer.Open();
|
||||
|
||||
public void Update() => _computer.Accept(new UpdateVisitor());
|
||||
|
||||
public void Close() => _computer.Close();
|
||||
}
|
||||
}
|
||||
@@ -376,6 +376,13 @@ inline int FfxLeafOf(const wchar_t* moduleName) noexcept {
|
||||
X(L"amd_fidelityfx_loader_dx12.dll", "ffxQuery", fl::inventory::kFamilyFfxQuery) \
|
||||
X(L"ffx_fsr3_x64.dll", "ffxFsr3ContextDispatchUpscale", fl::inventory::kFamilyFsr3Host)
|
||||
|
||||
// How many rows the table has: one inline patch each at most. dllmain's patch registry is sized against it, so a
|
||||
// row added here cannot outgrow the registry without a compile error (0.1.0-beta.42).
|
||||
#define FL_COUNT_ROW(mod, sym, family) +1u
|
||||
inline constexpr uint32_t kRowCount = 0u FL_HOOK_INVENTORY(FL_COUNT_ROW);
|
||||
#undef FL_COUNT_ROW
|
||||
static_assert(kRowCount == 13u, "a row was added or removed: say so here, and in 17_HOOK_ENGINE §Hook inventory");
|
||||
|
||||
// The FSR 3.0 host module and the one symbol dllmain's ffx arm keys on for it. Named
|
||||
// constants HERE, for the reason kModuleSlInterposer gives below, and bound to the
|
||||
// table so the row and the arm cannot drift apart.
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
// The patch registry (17_HOOK_ENGINE §Unhooking): every inline patch the Overlay
|
||||
// makes, so that the stop can take each one out again -- and the ONE sequence a
|
||||
// patch goes in by, so that a patch the stop cannot see is never made.
|
||||
//
|
||||
// WHAT THIS REPLACES, AND WHY (0.1.0-beta.42, found by reviewing the plan for the
|
||||
// next two hooks against the code). The registry was an array and a counter:
|
||||
//
|
||||
// 1. FULL MEANT SILENT. RegisterPatch advanced the counter and wrote the entry
|
||||
// only while it fitted; PatchTarget had already created and enabled the
|
||||
// hook. A 49th patch would have been live and unknown to the stop -- "the
|
||||
// part inside the game stops" (legal/DISCLAIMER.md §2) with one patch left
|
||||
// in, and no line anywhere saying so. Unreachable with the 20 patch sites
|
||||
// of today; the rule now does not depend on counting them right.
|
||||
// 2. ENABLED BEFORE REGISTERED. PatchTarget enabled the hook, re-read
|
||||
// g_observing, and registered last. A stop that ran between the re-read and
|
||||
// the registration walked a table that did not hold the patch yet.
|
||||
//
|
||||
// THE SEQUENCE NOW (Install below): take a slot -- no slot, no patch -- create,
|
||||
// enable, COMMIT the slot, and only then re-read the flag. The stop clears the
|
||||
// flag and only then walks the committed slots. Both are a write followed by a
|
||||
// read of what the other wrote, in the one total order sequentially consistent
|
||||
// operations have, so at least one of the two sees the other: either the walk
|
||||
// finds the committed slot and restores it, or the installer finds the flag
|
||||
// clear and takes its own patch out. There is no interleaving in which neither
|
||||
// does. (On x86-64 the only instruction this costs is the commit's XCHG, on an
|
||||
// install path that runs a handful of times per process.)
|
||||
//
|
||||
// A SLOT IS Free -> Claimed -> Live, and from Live only to Retired. A claimed slot
|
||||
// whose patch failed goes back to Free -- the walk never saw it. A slot that was
|
||||
// ever Live is never handed out again: the walk reads a Live slot's three fields
|
||||
// without a lock, and a slot refilled under it would be a target paired with
|
||||
// another patch's detour. Retiring costs a slot only for a patch that raced the
|
||||
// stop, and after the stop nothing is installed at all.
|
||||
//
|
||||
// Header-only, MinHook-free and allocation-free: the Overlay passes MinHook in as
|
||||
// the `hooker`, and ctest fl_unhook_inline drives this same sequence against real
|
||||
// MinHook patches -- the shipped sequence, not a copy of it.
|
||||
|
||||
#ifndef FRAMELEDGER_FL_PATCH_REGISTRY_H
|
||||
#define FRAMELEDGER_FL_PATCH_REGISTRY_H
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
||||
namespace fl::patch {
|
||||
|
||||
// Why Install did or did not patch. The values are written to the native log (PATCH_FAILED a=<value>), so they
|
||||
// are fixed: append, never renumber.
|
||||
enum class InstallResult : std::uint32_t {
|
||||
Installed = 0,
|
||||
NoTarget = 1, // nothing to patch
|
||||
Stopped = 2, // observing was already off: nothing was created
|
||||
Full = 3, // every slot is taken: nothing was created
|
||||
CreateFailed =
|
||||
4, // the hooker could not create the hook (MinHook: already created, unsupported prologue, memory)
|
||||
EnableFailed = 5, // created, not enabled: no patch at the target
|
||||
StoppedDuring = 6, // the stop ran while this patch went in; the installer took it out again
|
||||
};
|
||||
|
||||
template <std::uint32_t Capacity>
|
||||
class Registry {
|
||||
public:
|
||||
// A free slot for a patch that does not exist yet, or -1: the caller must not patch.
|
||||
int Claim(void* target, void* detour, const char* name) noexcept {
|
||||
for (std::uint32_t i = 0; i < Capacity; ++i) {
|
||||
std::uint32_t expected = kFree;
|
||||
if (slots_[i].state.compare_exchange_strong(expected, kClaimed, std::memory_order_acq_rel,
|
||||
std::memory_order_relaxed)) {
|
||||
slots_[i].target = target;
|
||||
slots_[i].detour = detour;
|
||||
slots_[i].name = name;
|
||||
return static_cast<int>(i);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// The patch is enabled; the stop's walk restores it from here on. Sequentially consistent ON PURPOSE: it is the
|
||||
// write of the write-then-read pair described at the top of this file.
|
||||
void Commit(int slot) noexcept {
|
||||
if (Valid(slot)) {
|
||||
slots_[static_cast<std::uint32_t>(slot)].state.store(kLive, std::memory_order_seq_cst);
|
||||
}
|
||||
}
|
||||
|
||||
// The patch was never made. Only for a slot that was claimed and not committed.
|
||||
void Release(int slot) noexcept {
|
||||
if (Valid(slot)) {
|
||||
std::uint32_t expected = kClaimed;
|
||||
slots_[static_cast<std::uint32_t>(slot)].state.compare_exchange_strong(
|
||||
expected, kFree, std::memory_order_acq_rel, std::memory_order_relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
// The installer took a committed patch out itself. The slot is never handed out again.
|
||||
void Retire(int slot) noexcept {
|
||||
if (Valid(slot)) {
|
||||
slots_[static_cast<std::uint32_t>(slot)].state.store(kRetired, std::memory_order_seq_cst);
|
||||
}
|
||||
}
|
||||
|
||||
// Every committed patch: visit(target, detour, name). The read of the write-then-read pair, on the stop's side.
|
||||
template <class Visit>
|
||||
void ForEachLive(Visit&& visit) const noexcept {
|
||||
for (std::uint32_t i = 0; i < Capacity; ++i) {
|
||||
if (slots_[i].state.load(std::memory_order_seq_cst) == kLive) {
|
||||
visit(slots_[i].target, slots_[i].detour, slots_[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::uint32_t LiveCount() const noexcept {
|
||||
std::uint32_t n = 0;
|
||||
ForEachLive([&n](void*, void*, const char*) noexcept { ++n; });
|
||||
return n;
|
||||
}
|
||||
|
||||
static constexpr std::uint32_t kCapacity = Capacity;
|
||||
|
||||
private:
|
||||
static constexpr std::uint32_t kFree = 0;
|
||||
static constexpr std::uint32_t kClaimed = 1;
|
||||
static constexpr std::uint32_t kLive = 2;
|
||||
static constexpr std::uint32_t kRetired = 3;
|
||||
|
||||
static bool Valid(int slot) noexcept { return slot >= 0 && static_cast<std::uint32_t>(slot) < Capacity; }
|
||||
|
||||
struct Slot {
|
||||
std::atomic<std::uint32_t> state{kFree};
|
||||
void* target = nullptr;
|
||||
void* detour = nullptr;
|
||||
const char* name = nullptr;
|
||||
};
|
||||
Slot slots_[Capacity]{};
|
||||
};
|
||||
|
||||
// Patch ONE address, registered before it can run and never left in after a stop.
|
||||
//
|
||||
// `hooker` is the inline-hook engine: Create(target, detour, original) -> bool, Enable(target) -> bool,
|
||||
// Disable(target). The Overlay passes MinHook; so does the test.
|
||||
//
|
||||
// A hook that was created and could not be enabled stays created in the engine, as it always has: a later attempt
|
||||
// then fails at Create, and nothing is at the target either way.
|
||||
template <std::uint32_t Capacity, class Hooker>
|
||||
InstallResult Install(Registry<Capacity>& registry, const std::atomic<std::uint32_t>& observing, Hooker&& hooker,
|
||||
void* target, void* detour, void** original, const char* name) noexcept {
|
||||
if (target == nullptr) {
|
||||
return InstallResult::NoTarget;
|
||||
}
|
||||
if (observing.load(std::memory_order_seq_cst) == 0u) {
|
||||
return InstallResult::Stopped;
|
||||
}
|
||||
const int slot = registry.Claim(target, detour, name);
|
||||
if (slot < 0) {
|
||||
return InstallResult::Full;
|
||||
}
|
||||
if (!hooker.Create(target, detour, original)) {
|
||||
registry.Release(slot);
|
||||
return InstallResult::CreateFailed;
|
||||
}
|
||||
if (!hooker.Enable(target)) {
|
||||
registry.Release(slot);
|
||||
return InstallResult::EnableFailed;
|
||||
}
|
||||
registry.Commit(slot);
|
||||
if (observing.load(std::memory_order_seq_cst) == 0u) {
|
||||
// The stop ran while the patch went in. Its walk either saw the committed slot and restored the patch -- then
|
||||
// this disable finds it disabled already -- or it had passed the slot, and this is what takes the patch out.
|
||||
hooker.Disable(target);
|
||||
registry.Retire(slot);
|
||||
return InstallResult::StoppedDuring;
|
||||
}
|
||||
return InstallResult::Installed;
|
||||
}
|
||||
|
||||
} // namespace fl::patch
|
||||
|
||||
#endif // FRAMELEDGER_FL_PATCH_REGISTRY_H
|
||||
@@ -52,6 +52,7 @@
|
||||
#include <fl_dxgi_vtable.h>
|
||||
#include <fl_hook_inventory.h>
|
||||
#include <fl_patch_check.h>
|
||||
#include <fl_patch_registry.h>
|
||||
#include <fl_ring.h>
|
||||
#include <fl_rt_accum.h>
|
||||
#include <fl_shm.h>
|
||||
@@ -147,6 +148,7 @@ enum FlLogCode : uint32_t {
|
||||
kLogSupervisionLost,
|
||||
kLogTolerance,
|
||||
kLogStopFlushed,
|
||||
kLogPatchFailed,
|
||||
};
|
||||
|
||||
const char* LogCodeName(uint32_t code) noexcept {
|
||||
@@ -175,6 +177,8 @@ const char* LogCodeName(uint32_t code) noexcept {
|
||||
return "TOLERANCE";
|
||||
case kLogStopFlushed:
|
||||
return "STOP_FLUSHED";
|
||||
case kLogPatchFailed:
|
||||
return "PATCH_FAILED";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
@@ -334,23 +338,55 @@ void FlushLog(bool lastFlush = false) noexcept {
|
||||
// patch this DLL installs is recorded here so the stop can ask, per patch,
|
||||
// whether the bytes at the target are still OUR jump before writing the saved
|
||||
// prologue back -- the inline-patch form of §H7's compare-and-restore.
|
||||
//
|
||||
// fl_patch_registry.h since 0.1.0-beta.42: a patch takes its slot BEFORE it is
|
||||
// created -- no slot, no patch -- and is committed before the flag is re-read,
|
||||
// so no patch can be live and unknown to the stop. The header says what the
|
||||
// array and counter this replaces let through.
|
||||
//
|
||||
// THE CAPACITY IS CHECKED AGAINST WHAT CAN BE INSTALLED: every inventory row,
|
||||
// counted by the table itself, and the seven sites that are not rows -- DXGI's
|
||||
// Present, Present1 and ResizeBuffers, kernelbase!LoadLibraryExW,
|
||||
// opengl32!wglSwapBuffers, and the two ray-tracing command-list methods. A site
|
||||
// added without raising kPatchSitesOutsideTheInventory is not caught here; it is
|
||||
// caught at run time, where a full registry refuses the patch and says so.
|
||||
// ---------------------------------------------------------------------------
|
||||
struct PatchEntry {
|
||||
void* target = nullptr;
|
||||
void* detour = nullptr;
|
||||
const char* name = nullptr;
|
||||
};
|
||||
constexpr uint32_t kMaxPatches = 48;
|
||||
PatchEntry g_patches[kMaxPatches]{};
|
||||
std::atomic<uint32_t> g_patchCount{0};
|
||||
constexpr uint32_t kMaxPatches = 48;
|
||||
constexpr uint32_t kPatchSitesOutsideTheInventory = 7;
|
||||
static_assert(fl::inventory::kRowCount + kPatchSitesOutsideTheInventory <= kMaxPatches,
|
||||
"the patch registry cannot hold every patch this DLL may install -- raise kMaxPatches with the table");
|
||||
fl::patch::Registry<kMaxPatches> g_patches;
|
||||
|
||||
void RegisterPatch(void* target, void* detour, const char* name) noexcept {
|
||||
const uint32_t i = g_patchCount.fetch_add(1u, std::memory_order_acq_rel);
|
||||
if (i < kMaxPatches) {
|
||||
g_patches[i].target = target;
|
||||
g_patches[i].detour = detour;
|
||||
g_patches[i].name = name;
|
||||
LogNote(kLogHookInstalled, name, 0, reinterpret_cast<uint64_t>(target));
|
||||
// MinHook, as the engine fl::patch::Install drives.
|
||||
struct MinHookEngine {
|
||||
static bool Create(void* target, void* detour, void** original) noexcept {
|
||||
return MH_CreateHook(target, detour, original) == MH_OK;
|
||||
}
|
||||
static bool Enable(void* target) noexcept { return MH_EnableHook(target) == MH_OK; }
|
||||
static void Disable(void* target) noexcept { MH_DisableHook(target); }
|
||||
};
|
||||
|
||||
// A patch that did not go in, said ONCE per target and reason: the lazy installers retry every second, and a line a
|
||||
// second would push everything else out of a 256-event ring. Init and watchdog threads only, which never install at
|
||||
// the same time (the watchdog starts after the init thread's last install), so a plain table.
|
||||
struct PatchFailure {
|
||||
const void* target = nullptr;
|
||||
uint32_t result = 0;
|
||||
};
|
||||
PatchFailure g_patchFailuresSeen[16]{};
|
||||
|
||||
void NotePatchFailedOnce(const void* target, fl::patch::InstallResult result, const char* name) noexcept {
|
||||
const auto code = static_cast<uint32_t>(result);
|
||||
for (PatchFailure& seen : g_patchFailuresSeen) {
|
||||
if (seen.target == target && seen.result == code) {
|
||||
return;
|
||||
}
|
||||
if (seen.target == nullptr) {
|
||||
seen.target = target;
|
||||
seen.result = code;
|
||||
LogNote(kLogPatchFailed, name, code, reinterpret_cast<uint64_t>(target));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -850,8 +886,11 @@ void StopObserving(uint32_t reason) noexcept {
|
||||
// reason wins -- a self-disable already in flight is not overwritten by a
|
||||
// safety stop that arrives a millisecond later, or the record of WHY we
|
||||
// stopped would depend on thread scheduling.
|
||||
//
|
||||
// Sequentially consistent, and the walk below reads the registry the same way: this write and that read are one
|
||||
// half of the pair fl_patch_registry.h describes, and an installer's commit and re-read are the other.
|
||||
uint32_t expected = 1;
|
||||
if (!g_observing.compare_exchange_strong(expected, 0, std::memory_order_acq_rel, std::memory_order_acquire)) {
|
||||
if (!g_observing.compare_exchange_strong(expected, 0, std::memory_order_seq_cst, std::memory_order_seq_cst)) {
|
||||
return;
|
||||
}
|
||||
LogNote(kLogStop, "observing stopped", reason);
|
||||
@@ -862,16 +901,14 @@ void StopObserving(uint32_t reason) noexcept {
|
||||
// is restored only while the bytes at its target are still the jump MinHook
|
||||
// wrote for us; otherwise it is left in place and our detour stays in the
|
||||
// other overlay's chain doing nothing -- g_observing is 0, every body forwards.
|
||||
const uint32_t n = g_patchCount.load(std::memory_order_acquire);
|
||||
for (uint32_t i = 0; i < n && i < kMaxPatches; ++i) {
|
||||
const PatchEntry& p = g_patches[i];
|
||||
if (fl::patch::StillOurs(p.target, p.detour)) {
|
||||
const bool ok = MH_DisableHook(p.target) == MH_OK;
|
||||
LogNote(kLogUnhookRestored, p.name, ok ? 1u : 0u, reinterpret_cast<uint64_t>(p.target));
|
||||
g_patches.ForEachLive([](void* target, void* detour, const char* name) noexcept {
|
||||
if (fl::patch::StillOurs(target, detour)) {
|
||||
const bool ok = MH_DisableHook(target) == MH_OK;
|
||||
LogNote(kLogUnhookRestored, name, ok ? 1u : 0u, reinterpret_cast<uint64_t>(target));
|
||||
} else {
|
||||
LogNote(kLogUnhookDeclined, p.name, 0u, reinterpret_cast<uint64_t>(p.target));
|
||||
LogNote(kLogUnhookDeclined, name, 0u, reinterpret_cast<uint64_t>(target));
|
||||
}
|
||||
}
|
||||
});
|
||||
if (g_state != nullptr) {
|
||||
std::atomic_ref<uint32_t> status{g_state->status};
|
||||
status.store(reason, std::memory_order_release);
|
||||
@@ -882,6 +919,35 @@ void StopObserving(uint32_t reason) noexcept {
|
||||
WakeWatchdog();
|
||||
}
|
||||
|
||||
// Patch ONE address, and close the install-after-stop window.
|
||||
//
|
||||
// STOPPING IS ONE-WAY, and fl::patch::Install is what keeps it so. StopObserving can
|
||||
// run between a caller's g_observing check and the patch, and its walk would then
|
||||
// have run BEFORE this hook existed -- leaving a hook patched in after we promised
|
||||
// the Agent there were none. Nothing false would be recorded (every body consults
|
||||
// MayObserve), but legal/DISCLAIMER.md §2 promises the part inside the game stops,
|
||||
// and a hook installed after the stop is not that. So the patch is registered
|
||||
// before the flag is re-read, and a full registry refuses it (fl_patch_registry.h).
|
||||
//
|
||||
// ONE FUNCTION ON PURPOSE, and the reason has now happened three times. It was first
|
||||
// inline in the single installer, so a second lazy installer that forgot it would
|
||||
// reopen the window silently; the ray-tracing installer WAS that second one, and it
|
||||
// cannot reuse InstallRow because its targets come from a VTABLE rather than from a
|
||||
// name; the LoadLibrary detour was the third, and until 0.1.0-beta.42 it carried a
|
||||
// copy of the sequence with the re-check left out.
|
||||
bool PatchTarget(void* target, void* detour, void** original, const char* name = "hook") noexcept {
|
||||
const fl::patch::InstallResult result =
|
||||
fl::patch::Install(g_patches, g_observing, MinHookEngine{}, target, detour, original, name);
|
||||
if (result == fl::patch::InstallResult::Installed) {
|
||||
LogNote(kLogHookInstalled, name, 0, reinterpret_cast<uint64_t>(target));
|
||||
return true;
|
||||
}
|
||||
if (result != fl::patch::InstallResult::NoTarget) {
|
||||
NotePatchFailedOnce(target, result, name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns false when we must not record this present.
|
||||
//
|
||||
// The supervision deadline is NOT here any more -- it is the watchdog's, which
|
||||
@@ -1522,13 +1588,11 @@ bool InstallLoaderHook() noexcept {
|
||||
if (target == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (MH_CreateHook(target, reinterpret_cast<void*>(&Hook_LoadLibraryExW),
|
||||
reinterpret_cast<void**>(&g_origLoadLibraryExW)) != MH_OK ||
|
||||
MH_EnableHook(target) != MH_OK) {
|
||||
if (!PatchTarget(target, reinterpret_cast<void*>(&Hook_LoadLibraryExW),
|
||||
reinterpret_cast<void**>(&g_origLoadLibraryExW), "kernelbase!LoadLibraryExW")) {
|
||||
LogNote(kLogLoaderDetour, "kernelbase!LoadLibraryExW", 0);
|
||||
return false;
|
||||
}
|
||||
RegisterPatch(target, reinterpret_cast<void*>(&Hook_LoadLibraryExW), "kernelbase!LoadLibraryExW");
|
||||
g_loaderSignals.fetch_or(kLoaderInstalledBit, std::memory_order_release);
|
||||
LogNote(kLogLoaderDetour, "kernelbase!LoadLibraryExW", 1);
|
||||
return true;
|
||||
@@ -2141,36 +2205,6 @@ void STDMETHODCALLTYPE Hook_BuildRtAs(ID3D12GraphicsCommandList4*
|
||||
// slSetTag would have been detoured by the slEvaluateFeature body, which reads
|
||||
// argument 1 as a feature id. Same class of defect as the SL1 ABI break (#71),
|
||||
// reached from the other direction.
|
||||
// Patch ONE address, and close the install-after-stop window.
|
||||
//
|
||||
// STOPPING IS ONE-WAY, and the check below is what keeps it so. StopObserving can
|
||||
// run between a caller's g_observing check and here, and MH_DisableHook(MH_ALL_HOOKS)
|
||||
// would then have run BEFORE this hook existed -- leaving a hook patched in after
|
||||
// we promised the Agent there were none. Nothing false would be recorded (every
|
||||
// body consults MayObserve), but legal/DISCLAIMER.md §2 promises the part inside
|
||||
// the game stops, and a hook installed after the stop is not that.
|
||||
//
|
||||
// FACTORED OUT OF InstallRow ON PURPOSE, and the reason has now happened twice.
|
||||
// It was first inline in the single installer, so a second lazy installer that
|
||||
// forgot it would reopen the window silently; the ray-tracing installer IS that
|
||||
// second one, and it cannot reuse InstallRow because its targets come from a
|
||||
// VTABLE rather than from a name. Sharing this is what keeps the window closed in
|
||||
// one place rather than in two that can drift.
|
||||
bool PatchTarget(void* target, void* detour, void** original, const char* name = "hook") noexcept {
|
||||
if (target == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (MH_CreateHook(target, detour, original) != MH_OK || MH_EnableHook(target) != MH_OK) {
|
||||
return false;
|
||||
}
|
||||
if (g_observing.load(std::memory_order_acquire) == 0) {
|
||||
MH_DisableHook(target);
|
||||
return false;
|
||||
}
|
||||
RegisterPatch(target, detour, name);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Publish the family bit and latch. Separate from PatchTarget because a hook that
|
||||
// spans several targets must not claim its family until every one of them is in.
|
||||
void PublishHookFamily(uint32_t family, std::atomic<uint32_t>& live) noexcept {
|
||||
@@ -3544,20 +3578,55 @@ bool InstallPresentHooks() noexcept {
|
||||
// so ctest fl_vtable_indices proved a fact about dxgi.dll rather
|
||||
// than about this DLL: changing an 8 here left it green
|
||||
// (20_OPEN_QUESTIONS §S29(b)).
|
||||
ok = MH_CreateHook(vtbl[fl::dxgi::kPresentIndex], reinterpret_cast<void*>(&Hook_Present),
|
||||
reinterpret_cast<void**>(&g_origPresent)) == MH_OK &&
|
||||
MH_CreateHook(vtbl[fl::dxgi::kResizeBuffersIndex], reinterpret_cast<void*>(&Hook_ResizeBuffers),
|
||||
reinterpret_cast<void**>(&g_origResizeBuffers)) == MH_OK &&
|
||||
MH_CreateHook(vtbl[fl::dxgi::kPresent1Index], reinterpret_cast<void*>(&Hook_Present1),
|
||||
reinterpret_cast<void**>(&g_origPresent1)) == MH_OK &&
|
||||
MH_EnableHook(MH_ALL_HOOKS) == MH_OK;
|
||||
//
|
||||
// THREE PATCHES, ENABLED TOGETHER -- one pass over the process's threads rather than three, and no
|
||||
// moment in which Present is hooked and ResizeBuffers is not -- so they do not go through PatchTarget,
|
||||
// and keep its rules by hand: a slot each BEFORE anything is created, committed before the flag is
|
||||
// re-read, and nothing left enabled when any step fails (a partial MH_EnableHook(MH_ALL_HOOKS) used to
|
||||
// leave what it had enabled in place, unregistered, with init reporting failure).
|
||||
struct PresentPatch {
|
||||
void* target;
|
||||
void* detour;
|
||||
void** original;
|
||||
const char* name;
|
||||
int slot;
|
||||
};
|
||||
PresentPatch patches[] = {
|
||||
{vtbl[fl::dxgi::kPresentIndex], reinterpret_cast<void*>(&Hook_Present),
|
||||
reinterpret_cast<void**>(&g_origPresent), "dxgi!IDXGISwapChain::Present", -1},
|
||||
{vtbl[fl::dxgi::kResizeBuffersIndex], reinterpret_cast<void*>(&Hook_ResizeBuffers),
|
||||
reinterpret_cast<void**>(&g_origResizeBuffers), "dxgi!IDXGISwapChain::ResizeBuffers", -1},
|
||||
{vtbl[fl::dxgi::kPresent1Index], reinterpret_cast<void*>(&Hook_Present1),
|
||||
reinterpret_cast<void**>(&g_origPresent1), "dxgi!IDXGISwapChain1::Present1", -1},
|
||||
};
|
||||
ok = true;
|
||||
for (PresentPatch& p : patches) {
|
||||
p.slot = g_patches.Claim(p.target, p.detour, p.name);
|
||||
ok = ok && p.slot >= 0;
|
||||
}
|
||||
for (const PresentPatch& p : patches) {
|
||||
ok = ok && MH_CreateHook(p.target, p.detour, p.original) == MH_OK;
|
||||
}
|
||||
ok = ok && MH_EnableHook(MH_ALL_HOOKS) == MH_OK;
|
||||
if (ok) {
|
||||
RegisterPatch(vtbl[fl::dxgi::kPresentIndex], reinterpret_cast<void*>(&Hook_Present),
|
||||
"dxgi!IDXGISwapChain::Present");
|
||||
RegisterPatch(vtbl[fl::dxgi::kResizeBuffersIndex], reinterpret_cast<void*>(&Hook_ResizeBuffers),
|
||||
"dxgi!IDXGISwapChain::ResizeBuffers");
|
||||
RegisterPatch(vtbl[fl::dxgi::kPresent1Index], reinterpret_cast<void*>(&Hook_Present1),
|
||||
"dxgi!IDXGISwapChain1::Present1");
|
||||
for (const PresentPatch& p : patches) {
|
||||
g_patches.Commit(p.slot);
|
||||
LogNote(kLogHookInstalled, p.name, 0, reinterpret_cast<uint64_t>(p.target));
|
||||
}
|
||||
if (g_observing.load(std::memory_order_seq_cst) == 0u) {
|
||||
// A stop arrived while they went in (FlRequestUnhook, or a present that read the Agent's
|
||||
// request): out again, here, whether or not its walk saw them.
|
||||
for (const PresentPatch& p : patches) {
|
||||
MH_DisableHook(p.target);
|
||||
g_patches.Retire(p.slot);
|
||||
}
|
||||
ok = false;
|
||||
}
|
||||
} else {
|
||||
for (const PresentPatch& p : patches) {
|
||||
MH_DisableHook(p.target); // a no-op for one never created or never enabled
|
||||
g_patches.Release(p.slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3628,8 +3697,10 @@ DWORD WINAPI InitThread(LPVOID) noexcept {
|
||||
// Hooking failed, so nothing will ever be recorded. Staying at INIT says
|
||||
// exactly that; READY would be a claim about a capture side that does not
|
||||
// exist, and the Agent's degradation path is what should run instead.
|
||||
//
|
||||
// NOTHING IS STORED: the status is INIT already -- unless a stop arrived while the present hooks went in, and
|
||||
// then it holds the stop's reason, which a store of INIT here would overwrite (0.1.0-beta.42).
|
||||
LogNote(kLogPresentHooks, "MinHook init or the DXGI present hooks FAILED", 0);
|
||||
status.store(FL_STATUS_INIT, std::memory_order_release);
|
||||
FlushLog();
|
||||
return 1;
|
||||
}
|
||||
@@ -3658,7 +3729,11 @@ DWORD WINAPI InitThread(LPVOID) noexcept {
|
||||
// for one that maps it later.
|
||||
InstallOpenGlHook();
|
||||
|
||||
status.store(FL_STATUS_READY, std::memory_order_release);
|
||||
// INIT -> READY and nothing else -> READY. The present hooks are live from InstallPresentHooks on, so a stop can
|
||||
// already have written its reason here (a present that read the Agent's request, FlRequestUnhook); a plain
|
||||
// store would put READY over it, and the Agent would read a capture side with no hook in as ready.
|
||||
uint32_t stillInit = FL_STATUS_INIT;
|
||||
status.compare_exchange_strong(stillInit, FL_STATUS_READY, std::memory_order_acq_rel, std::memory_order_acquire);
|
||||
|
||||
// AFTER the hooks, deliberately. The watchdog's only job is to take them out
|
||||
// again, so starting it earlier would create a window in which it could
|
||||
|
||||
@@ -17,10 +17,12 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <fl_patch_check.h>
|
||||
#include <fl_patch_registry.h>
|
||||
#include <MinHook.h>
|
||||
|
||||
namespace {
|
||||
@@ -93,6 +95,92 @@ void RepointJump(void* target, const void* relay, std::int32_t* savedRel) {
|
||||
FlushInstructionCache(GetCurrentProcess(), p, 5);
|
||||
}
|
||||
|
||||
// --- the registry's cases (0.1.0-beta.42) ---------------------------------------------------------------------------
|
||||
// Three more real functions, each with a body of its own so the linker cannot fold them into one address.
|
||||
__declspec(noinline) int First(int x) {
|
||||
volatile int acc = x;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
acc = acc * 5 + i;
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
__declspec(noinline) int Second(int x) {
|
||||
volatile int acc = x;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
acc = acc * 7 - i;
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
__declspec(noinline) int Third(int x) {
|
||||
volatile int acc = x;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
acc = acc * 11 + 2 * i;
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
TargetFn g_origFirst = nullptr;
|
||||
TargetFn g_origSecond = nullptr;
|
||||
TargetFn g_origThird = nullptr;
|
||||
|
||||
int DetourFirst(int x) {
|
||||
return g_origFirst(x) + 1000000;
|
||||
}
|
||||
int DetourSecond(int x) {
|
||||
return g_origSecond(x) + 2000000;
|
||||
}
|
||||
int DetourThird(int x) {
|
||||
return g_origThird(x) + 3000000;
|
||||
}
|
||||
|
||||
// MinHook, exactly as the Overlay hands it to fl::patch::Install (dllmain.cpp's MinHookEngine).
|
||||
struct RealMinHook {
|
||||
static bool Create(void* target, void* detour, void** original) noexcept {
|
||||
return MH_CreateHook(target, detour, original) == MH_OK;
|
||||
}
|
||||
static bool Enable(void* target) noexcept { return MH_EnableHook(target) == MH_OK; }
|
||||
static void Disable(void* target) noexcept { MH_DisableHook(target); }
|
||||
};
|
||||
|
||||
// The same engine with one thing arranged: a stop that arrives between the enable and the installer's re-read.
|
||||
struct StopArrivesWhileEnabling {
|
||||
std::atomic<std::uint32_t>* observing;
|
||||
static bool Create(void* target, void* detour, void** original) noexcept {
|
||||
return RealMinHook::Create(target, detour, original);
|
||||
}
|
||||
bool Enable(void* target) const noexcept {
|
||||
const bool ok = RealMinHook::Enable(target);
|
||||
observing->store(0u);
|
||||
return ok;
|
||||
}
|
||||
static void Disable(void* target) noexcept { RealMinHook::Disable(target); }
|
||||
};
|
||||
|
||||
// An engine that fails at a chosen step and counts what it was asked: nothing may be created once a patch is refused.
|
||||
struct FailingEngine {
|
||||
bool createOk;
|
||||
bool enableOk;
|
||||
int* created;
|
||||
bool Create(void*, void*, void**) const noexcept {
|
||||
++*created;
|
||||
return createOk;
|
||||
}
|
||||
bool Enable(void*) const noexcept { return enableOk; }
|
||||
static void Disable(void*) noexcept {}
|
||||
};
|
||||
|
||||
// The stop's walk, as StopObserving writes it: restore each patch that is still ours.
|
||||
template <std::uint32_t N>
|
||||
int RestoreEveryLivePatch(const fl::patch::Registry<N>& registry) {
|
||||
int restored = 0;
|
||||
registry.ForEachLive([&restored](void* target, void* detour, const char*) noexcept {
|
||||
if (fl::patch::StillOurs(target, detour) && MH_DisableHook(target) == MH_OK) {
|
||||
++restored;
|
||||
}
|
||||
});
|
||||
return restored;
|
||||
}
|
||||
|
||||
void RestoreJump(void* target, std::int32_t savedRel) {
|
||||
auto* p = static_cast<std::uint8_t*>(target);
|
||||
DWORD old = 0;
|
||||
@@ -160,3 +248,122 @@ TEST_CASE("garbage at the target is 'not ours', never a fault", "[unhook][inline
|
||||
CHECK_FALSE(fl::patch::StillOurs(page, nullptr));
|
||||
VirtualFree(page, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
TEST_CASE("a full registry refuses the patch: nothing is created and the target's bytes are untouched",
|
||||
"[unhook][registry]") {
|
||||
using fl::patch::InstallResult;
|
||||
fl::patch::Registry<2> registry;
|
||||
std::atomic<std::uint32_t> observing{1u};
|
||||
void* first = reinterpret_cast<void*>(&First);
|
||||
void* second = reinterpret_cast<void*>(&Second);
|
||||
void* third = reinterpret_cast<void*>(&Third);
|
||||
const int firstPlain = First(3);
|
||||
const int secondPlain = Second(3);
|
||||
const int thirdPlain = Third(3);
|
||||
|
||||
std::uint8_t before[16]{};
|
||||
std::memcpy(before, third, sizeof(before));
|
||||
|
||||
REQUIRE(MH_Initialize() == MH_OK);
|
||||
CHECK(fl::patch::Install(registry, observing, RealMinHook{}, first, reinterpret_cast<void*>(&DetourFirst),
|
||||
reinterpret_cast<void**>(&g_origFirst), "first") == InstallResult::Installed);
|
||||
CHECK(fl::patch::Install(registry, observing, RealMinHook{}, second, reinterpret_cast<void*>(&DetourSecond),
|
||||
reinterpret_cast<void**>(&g_origSecond), "second") == InstallResult::Installed);
|
||||
CHECK(First(3) == firstPlain + 1000000);
|
||||
CHECK(Second(3) == secondPlain + 2000000);
|
||||
CHECK(registry.LiveCount() == 2u);
|
||||
|
||||
// The third has no slot. The array and counter this replaced patched it anyway and forgot it.
|
||||
g_origThird = nullptr;
|
||||
CHECK(fl::patch::Install(registry, observing, RealMinHook{}, third, reinterpret_cast<void*>(&DetourThird),
|
||||
reinterpret_cast<void**>(&g_origThird), "third") == InstallResult::Full);
|
||||
CHECK(std::memcmp(before, third, sizeof(before)) == 0);
|
||||
CHECK(Third(3) == thirdPlain);
|
||||
CHECK(g_origThird == nullptr); // MinHook was never asked: no trampoline exists for it
|
||||
CHECK(MH_EnableHook(third) == MH_ERROR_NOT_CREATED);
|
||||
CHECK(registry.LiveCount() == 2u);
|
||||
|
||||
// And the stop takes out every patch that did go in -- which is now every patch there is.
|
||||
observing.store(0u);
|
||||
CHECK(RestoreEveryLivePatch(registry) == 2);
|
||||
CHECK(First(3) == firstPlain);
|
||||
CHECK(Second(3) == secondPlain);
|
||||
|
||||
// Stopping is one-way: after it, nothing is created at all.
|
||||
CHECK(fl::patch::Install(registry, observing, RealMinHook{}, third, reinterpret_cast<void*>(&DetourThird),
|
||||
reinterpret_cast<void**>(&g_origThird), "third") == InstallResult::Stopped);
|
||||
CHECK(MH_EnableHook(third) == MH_ERROR_NOT_CREATED);
|
||||
MH_Uninitialize();
|
||||
}
|
||||
|
||||
TEST_CASE("a patch that goes in while the stop runs is taken out by its installer, and its slot is never reused",
|
||||
"[unhook][registry]") {
|
||||
using fl::patch::InstallResult;
|
||||
fl::patch::Registry<1> registry;
|
||||
std::atomic<std::uint32_t> observing{1u};
|
||||
void* first = reinterpret_cast<void*>(&First);
|
||||
const int firstPlain = First(4);
|
||||
|
||||
REQUIRE(MH_Initialize() == MH_OK);
|
||||
// The window the old order left open: the flag read 1, the stop ran -- its walk found nothing, the patch was not
|
||||
// registered yet -- and the patch was then enabled and registered, live after "stopped".
|
||||
CHECK(fl::patch::Install(registry, observing, StopArrivesWhileEnabling{&observing}, first,
|
||||
reinterpret_cast<void*>(&DetourFirst), reinterpret_cast<void**>(&g_origFirst),
|
||||
"first") == InstallResult::StoppedDuring);
|
||||
CHECK(First(4) == firstPlain); // not left in
|
||||
CHECK_FALSE(fl::patch::StillOurs(first, reinterpret_cast<void*>(&DetourFirst)));
|
||||
CHECK(registry.LiveCount() == 0u); // and not left for a walk to report as somebody else's
|
||||
CHECK(registry.Claim(first, first, "again") == -1);
|
||||
MH_Uninitialize();
|
||||
}
|
||||
|
||||
TEST_CASE("a patch that failed gives its slot back, and a slot is not seen by the walk until it is committed",
|
||||
"[unhook][registry]") {
|
||||
using fl::patch::InstallResult;
|
||||
fl::patch::Registry<1> registry;
|
||||
std::atomic<std::uint32_t> observing{1u};
|
||||
int target = 0;
|
||||
int detour = 0;
|
||||
void* original = nullptr;
|
||||
int created = 0;
|
||||
|
||||
CHECK(fl::patch::Install(registry, observing, FailingEngine{false, true, &created}, &target, &detour, &original,
|
||||
"x") == InstallResult::CreateFailed);
|
||||
CHECK(fl::patch::Install(registry, observing, FailingEngine{true, false, &created}, &target, &detour, &original,
|
||||
"x") == InstallResult::EnableFailed);
|
||||
CHECK(created == 2);
|
||||
CHECK(registry.LiveCount() == 0u);
|
||||
CHECK(fl::patch::Install(registry, observing, FailingEngine{true, true, &created}, nullptr, &detour, &original,
|
||||
"x") == InstallResult::NoTarget);
|
||||
CHECK(created == 2);
|
||||
|
||||
// Both failures gave the one slot back, so it can still be claimed -- and a claimed slot is nobody's yet.
|
||||
const int slot = registry.Claim(&target, &detour, "x");
|
||||
REQUIRE(slot == 0);
|
||||
CHECK(registry.LiveCount() == 0u);
|
||||
CHECK(registry.Claim(&target, &detour, "y") == -1);
|
||||
CHECK(fl::patch::Install(registry, observing, FailingEngine{true, true, &created}, &target, &detour, &original,
|
||||
"x") == InstallResult::Full);
|
||||
CHECK(created == 2); // refused before the engine was asked for anything
|
||||
|
||||
registry.Commit(slot);
|
||||
const void* seenTarget = nullptr;
|
||||
const char* seenName = nullptr;
|
||||
registry.ForEachLive([&seenTarget, &seenName](void* t, void*, const char* name) noexcept {
|
||||
seenTarget = t;
|
||||
seenName = name;
|
||||
});
|
||||
CHECK(seenTarget == &target);
|
||||
CHECK(seenName != nullptr);
|
||||
CHECK(registry.LiveCount() == 1u);
|
||||
|
||||
// Release is for a slot that was never committed: on a live one it changes nothing.
|
||||
registry.Release(slot);
|
||||
CHECK(registry.LiveCount() == 1u);
|
||||
registry.Retire(slot);
|
||||
CHECK(registry.LiveCount() == 0u);
|
||||
registry.Commit(-1);
|
||||
registry.Release(7);
|
||||
registry.Retire(-3);
|
||||
CHECK(registry.LiveCount() == 0u);
|
||||
}
|
||||
@@ -239,6 +239,78 @@ public sealed class SessionAggregatorTests
|
||||
r.Segments[0].OutputW.Should().Be(2560);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ASessionThatSawDlssFirstAndThenRanFsrIsFsrWithFsrsQualityAndSize()
|
||||
{
|
||||
// D120. The name used to be the FIRST technology any record carried: this session was "dlss" with the quality
|
||||
// byte and the render size of the FSR that ran for four fifths of it.
|
||||
FlMeasured claims = _presentOnly | FlMeasured.Upscaler | FlMeasured.UpscalerParams;
|
||||
var writer = new FlWriterState { Status = 1, HooksInstalledMask = 0x7 };
|
||||
List<FlFrameRecord> records =
|
||||
[
|
||||
.. SessionFixtures.Stream(500, claims, upscaler: FlUpscaler.Dlss).Select(static (r, i) => i < 100
|
||||
? r with { UpscalerQuality = 0xFF, RenderW = 1485, RenderH = 835 }
|
||||
: r with { Upscaler = (byte)FlUpscaler.FsrUnversioned, UpscalerQuality = 0x12, RenderW = 1505, RenderH = 847 }),
|
||||
];
|
||||
|
||||
AggregationResult r = SessionAggregator.Aggregate(SessionFixtures.Skeleton(), SessionFixtures.Hooked(records, writer));
|
||||
|
||||
r.Row.Upscaler.Should().Be("fsr", "named on four hundred records, against a hundred");
|
||||
r.Row.UpscalerQuality.Should().Be("18");
|
||||
r.Row.RenderW.Should().Be(1505);
|
||||
r.Row.RenderH.Should().Be(847);
|
||||
r.Row.SettingsChangedMidSession.Should().BeTrue("a second technology named in one session is a setting changed mid-session");
|
||||
r.Segments.Should().ContainSingle("the output size never changed").Which.Upscaler.Should().Be("fsr");
|
||||
r.Segments[0].UpscalerQuality.Should().Be("18");
|
||||
r.Segments[0].RenderW.Should().Be(1505);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ASessionThatRanDlssAndSawFsrBrieflyKeepsNothingOfFsrUnderDlssName()
|
||||
{
|
||||
// The real one (Dying Light: The Beast, 81 s): DLSS for most of it, which does not tell its mode; FSR for a few
|
||||
// seconds, which does. Stored as "dlss" with FSR's Balanced byte and FSR's render size - three true readings of
|
||||
// two technologies under one name. What DLSS did not say is N/A, never the neighbour's value (rule 7).
|
||||
FlMeasured claims = _presentOnly | FlMeasured.Upscaler | FlMeasured.UpscalerParams;
|
||||
var writer = new FlWriterState { Status = 1, HooksInstalledMask = 0x7 };
|
||||
List<FlFrameRecord> records =
|
||||
[
|
||||
.. SessionFixtures.Stream(500, claims, upscaler: FlUpscaler.Dlss).Select(static (r, i) => i is >= 200 and < 260
|
||||
? r with { Upscaler = (byte)FlUpscaler.FsrUnversioned, UpscalerQuality = 0x12, RenderW = 1505, RenderH = 847 }
|
||||
: r with { UpscalerQuality = 0xFF, RenderW = 1485, RenderH = 835 }),
|
||||
];
|
||||
|
||||
AggregationResult r = SessionAggregator.Aggregate(SessionFixtures.Skeleton(), SessionFixtures.Hooked(records, writer));
|
||||
|
||||
r.Row.Upscaler.Should().Be("dlss");
|
||||
r.Row.UpscalerQuality.Should().BeNull("DLSS did not tell its mode, and FSR's byte is not DLSS's");
|
||||
r.Row.RenderW.Should().Be(1485, "the size DLSS rendered at, not the one FSR did for sixty frames");
|
||||
r.Row.RenderH.Should().Be(835);
|
||||
r.Row.SettingsChangedMidSession.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ANameOnOnePresentInFourStillNamesTheSessionAndChangesNothingElse()
|
||||
{
|
||||
// Under frame generation the writer names the upscaler only on the presents that drained an evaluation. One
|
||||
// technology, named rarely: the whole stream still counts, and nothing is "changed mid-session".
|
||||
FlMeasured claims = _presentOnly | FlMeasured.Upscaler | FlMeasured.UpscalerParams;
|
||||
var writer = new FlWriterState { Status = 1, HooksInstalledMask = 0x7 };
|
||||
List<FlFrameRecord> records =
|
||||
[
|
||||
.. SessionFixtures.Stream(500, claims, upscaler: FlUpscaler.Unknown).Select(static (r, i) => i % 4 == 0
|
||||
? r with { Upscaler = (byte)FlUpscaler.Fsr3, UpscalerQuality = 0x11, RenderW = 1707, RenderH = 960 }
|
||||
: r with { UpscalerQuality = 0xFF, RenderW = 1707, RenderH = 960 }),
|
||||
];
|
||||
|
||||
AggregationResult r = SessionAggregator.Aggregate(SessionFixtures.Skeleton(), SessionFixtures.Hooked(records, writer));
|
||||
|
||||
r.Row.Upscaler.Should().Be("fsr3");
|
||||
r.Row.UpscalerQuality.Should().Be("17");
|
||||
r.Row.RenderW.Should().Be(1707);
|
||||
r.Row.SettingsChangedMidSession.Should().BeFalse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <c>0xFF</c> is the Overlay's "a hook ran and could not tell" for the quality byte, and every AMD dispatch carries it.
|
||||
/// Aggregated as a number it became the text "255", which the game page appends to the upscaler's name ("FSR 255").
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using FluentAssertions;
|
||||
using FrameLedger.Domain.Metrics;
|
||||
|
||||
namespace FrameLedger.Domain.Tests.Metrics;
|
||||
|
||||
/// <summary>
|
||||
/// One technology's name, quality and size (owner decision D120): which upscaler a stream names, and which samples
|
||||
/// its quality and render size may be read from.
|
||||
/// </summary>
|
||||
public sealed class UpscalerChoiceTests
|
||||
{
|
||||
private static FrameSample Sample(UpscalerKind upscaler, MeasuredFields measured = MeasuredFields.Upscaler | MeasuredFields.UpscalerParams) => new()
|
||||
{
|
||||
SwapchainId = 1,
|
||||
Upscaler = upscaler,
|
||||
UpscalerQuality = FrameSample.QualityNotTold,
|
||||
Measured = measured,
|
||||
};
|
||||
|
||||
private static List<FrameSample> Of(params (UpscalerKind Kind, int Count)[] runs) =>
|
||||
[.. runs.SelectMany(static r => Enumerable.Repeat(r.Kind, r.Count)).Select(static k => Sample(k))];
|
||||
|
||||
[Fact]
|
||||
public void AStreamThatNamesNothingChoosesNothingAndKeepsEverySample()
|
||||
{
|
||||
List<FrameSample> stream = Of((UpscalerKind.Unknown, 40), (UpscalerKind.NotReported, 10), (UpscalerKind.RetiredRayReconstruction, 5));
|
||||
|
||||
UpscalerChoice choice = UpscalerChoice.From(stream);
|
||||
|
||||
choice.Kind.Should().BeNull("unknown, not reported and the retired value name no technology");
|
||||
choice.Named.Should().Be(0);
|
||||
choice.Samples.Should().BeSameAs(stream);
|
||||
UpscalerChoice.From([]).Kind.Should().BeNull();
|
||||
FluentActions.Invoking(static () => UpscalerChoice.From(null!)).Should().Throw<ArgumentNullException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OneTechnologyNamedOnAFewPresentsIsTheChoiceAndEverySampleStillCounts()
|
||||
{
|
||||
// Under frame generation a name sits on one present in N: the others say "unknown" and still carry the
|
||||
// render size of the frame they belong to.
|
||||
List<FrameSample> stream = Of((UpscalerKind.Unknown, 3), (UpscalerKind.FsrUnversioned, 1), (UpscalerKind.Unknown, 3), (UpscalerKind.FsrUnversioned, 1));
|
||||
|
||||
UpscalerChoice choice = UpscalerChoice.From(stream);
|
||||
|
||||
choice.Kind.Should().Be(UpscalerKind.FsrUnversioned);
|
||||
choice.Named.Should().Be(1);
|
||||
choice.Samples.Should().BeSameAs(stream, "with one technology named nothing is left out, exactly as before");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WithTwoTechnologiesNamedTheOneOnTheMostSamplesIsChosenAndOnlyItsSamplesAreRead()
|
||||
{
|
||||
// The session this exists for: DLSS seen first, briefly, then FSR for the rest. First-named said "DLSS".
|
||||
List<FrameSample> stream = Of((UpscalerKind.Dlss, 20), (UpscalerKind.Unknown, 15), (UpscalerKind.FsrUnversioned, 60));
|
||||
|
||||
UpscalerChoice choice = UpscalerChoice.From(stream);
|
||||
|
||||
choice.Kind.Should().Be(UpscalerKind.FsrUnversioned);
|
||||
choice.Named.Should().Be(2, "which is a setting changed mid-session");
|
||||
choice.Samples.Should().HaveCount(60).And.OnlyContain(static s => s.Upscaler == UpscalerKind.FsrUnversioned,
|
||||
"nothing of the other technology, and nothing unnamed, is carried under the chosen name");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ATieGoesToTheLowerValueAndASampleThatDoesNotClaimTheFieldNamesNothing()
|
||||
{
|
||||
UpscalerChoice.From(Of((UpscalerKind.Fsr3, 10), (UpscalerKind.Dlss, 10))).Kind.Should().Be(UpscalerKind.Dlss, "as QualityByte.Of breaks its own ties");
|
||||
|
||||
// A value set while its bit is clear is the writer's defect: it is not a name.
|
||||
List<FrameSample> unclaimed = [.. Enumerable.Repeat(Sample(UpscalerKind.Dlss, MeasuredFields.None), 50), Sample(UpscalerKind.Fsr3)];
|
||||
UpscalerChoice choice = UpscalerChoice.From(unclaimed);
|
||||
choice.Kind.Should().Be(UpscalerKind.Fsr3);
|
||||
choice.Named.Should().Be(1);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(UpscalerKind.Dlss, true)]
|
||||
[InlineData(UpscalerKind.Nis, true)]
|
||||
[InlineData(UpscalerKind.None, true)]
|
||||
[InlineData(UpscalerKind.FsrUnversioned, true)]
|
||||
[InlineData(UpscalerKind.Unknown, false)]
|
||||
[InlineData(UpscalerKind.NotReported, false)]
|
||||
[InlineData(UpscalerKind.RetiredRayReconstruction, false)]
|
||||
public void ATechnologyIsNamedByEveryValueButTheThreeThatSayNothing(UpscalerKind kind, bool named) =>
|
||||
UpscalerChoice.IsNamed(kind).Should().Be(named);
|
||||
|
||||
[Theory]
|
||||
[InlineData(UpscalerKind.Fsr2, true)]
|
||||
[InlineData(UpscalerKind.Fsr3, true)]
|
||||
[InlineData(UpscalerKind.Fsr4, true)]
|
||||
[InlineData(UpscalerKind.FsrUnversioned, true)]
|
||||
[InlineData(UpscalerKind.Dlss, false)]
|
||||
[InlineData(UpscalerKind.XeSS, false)]
|
||||
public void FsrIsAFamilyOfFour(UpscalerKind kind, bool fsr) => UpscalerChoice.IsFsr(kind).Should().Be(fsr);
|
||||
|
||||
[Fact]
|
||||
public void AQualityByteOfTheOtherFamilyIsWithheldRatherThanShownUnderTheName()
|
||||
{
|
||||
UpscalerChoice dlss = UpscalerChoice.From(Of((UpscalerKind.Dlss, 5)));
|
||||
UpscalerChoice fsr = UpscalerChoice.From(Of((UpscalerKind.Fsr3, 5)));
|
||||
UpscalerChoice none = UpscalerChoice.From(Of((UpscalerKind.Unknown, 5)));
|
||||
|
||||
dlss.QualityFor(0x12).Should().BeNull("0x12 is FSR's Balanced; under DLSS it is not a mode anyone measured");
|
||||
dlss.QualityFor(3).Should().Be(3);
|
||||
fsr.QualityFor(0x12).Should().Be(0x12);
|
||||
fsr.QualityFor(3).Should().BeNull("a DLSS mode under an FSR name");
|
||||
fsr.QualityFor(null).Should().BeNull();
|
||||
none.QualityFor(0x12).Should().Be(0x12, "with no technology named there is no name to contradict");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using FluentAssertions;
|
||||
using FrameLedger.Infrastructure.Telemetry;
|
||||
using LibreHardwareMonitor.Hardware;
|
||||
|
||||
namespace FrameLedger.Infrastructure.Tests.Telemetry;
|
||||
|
||||
/// <summary>
|
||||
/// The two rules of <see cref="LhmLibrary"/> (2026-11-12): opens and closes never run at once, and a <c>Computer</c>
|
||||
/// is not really closed while another is in use. The fault they exist for - one instance's close taking the
|
||||
/// library's per-process state from under another - needs an elevated Agent with PawnIO and was met on the owner's
|
||||
/// PC; here the rules are held on scripted instances, which is what can be held without a driver.
|
||||
/// </summary>
|
||||
public sealed class LhmLibraryTests
|
||||
{
|
||||
private const LhmGroups _session = LhmGroups.Gpu;
|
||||
private const LhmGroups _advanced = LhmGroups.Gpu | LhmGroups.Cpu | LhmGroups.Memory | LhmGroups.Motherboard;
|
||||
|
||||
/// <summary>A library whose instances are scripted, each remembered with the groups it was made for.</summary>
|
||||
private sealed class Script
|
||||
{
|
||||
public List<(LhmGroups Groups, FakeLhmComputer Computer)> Made { get; } = [];
|
||||
|
||||
public bool NextOpenThrows { get; set; }
|
||||
|
||||
public bool EveryCloseThrows { get; set; }
|
||||
|
||||
public LhmLibrary Library => field ??= new LhmLibrary(groups =>
|
||||
{
|
||||
var computer = new FakeLhmComputer { OpenThrows = NextOpenThrows, CloseThrows = EveryCloseThrows };
|
||||
NextOpenThrows = false;
|
||||
Made.Add((groups, computer));
|
||||
return computer;
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OneUserOpensItsComputerAndClosingItClosesIt()
|
||||
{
|
||||
var script = new Script();
|
||||
var only = new LhmComputerAdapter(_session, script.Library);
|
||||
|
||||
only.Hardware.Should().BeEmpty("nothing is open yet");
|
||||
only.Open();
|
||||
only.Open();
|
||||
|
||||
script.Made.Should().ContainSingle("a second Open while open changes nothing").Which.Computer.Opens.Should().Be(1);
|
||||
script.Library.Users.Should().Be(1);
|
||||
|
||||
only.Close();
|
||||
only.Close();
|
||||
|
||||
script.Made[0].Computer.Closes.Should().Be(1, "and it lets go once");
|
||||
script.Library.Users.Should().Be(0);
|
||||
script.Library.Parked.Should().Be(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AComputerIsNotClosedWhileAnotherIsInUse()
|
||||
{
|
||||
// THE DEFECT. A session ends and closes its source while the Advanced reader - held by the page - reads on.
|
||||
// The session's Computer must stay open: closing it lets go of what the reader's processor device reads through.
|
||||
var script = new Script();
|
||||
var reader = new LhmComputerAdapter(_advanced, script.Library);
|
||||
var session = new LhmComputerAdapter(_session, script.Library);
|
||||
reader.Open();
|
||||
session.Open();
|
||||
|
||||
session.Close();
|
||||
|
||||
script.Made.Should().HaveCount(2);
|
||||
script.Made.Should().OnlyContain(static m => m.Computer.Closes == 0, "nothing is closed while the reader is open");
|
||||
script.Library.Users.Should().Be(1);
|
||||
script.Library.Parked.Should().Be(1);
|
||||
session.Hardware.Should().BeEmpty("the session's user has let go, whatever the library keeps");
|
||||
|
||||
// The last user closes the library: its own Computer and the parked one, then there is nothing left.
|
||||
reader.Close();
|
||||
|
||||
script.Made.Should().OnlyContain(static m => m.Computer.Closes == 1);
|
||||
script.Library.Users.Should().Be(0);
|
||||
script.Library.Parked.Should().Be(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheNextSessionTakesTheParkedComputerOfItsGroupsSoNothingPilesUp()
|
||||
{
|
||||
// The page stays open all evening and ten sessions come and go: one parked Computer, handed on, not ten.
|
||||
var script = new Script();
|
||||
var reader = new LhmComputerAdapter(_advanced, script.Library);
|
||||
reader.Open();
|
||||
|
||||
for (int n = 0; n < 10; n++)
|
||||
{
|
||||
var session = new LhmComputerAdapter(_session, script.Library);
|
||||
session.Open();
|
||||
session.Close();
|
||||
}
|
||||
|
||||
script.Made.Should().HaveCount(2, "the reader's, and one for every session after the first found it parked");
|
||||
script.Made[1].Computer.Opens.Should().Be(1, "a parked Computer is still open: it is handed over, not opened again");
|
||||
script.Library.Parked.Should().Be(1);
|
||||
|
||||
// Another set of groups is another Computer: a parked GPU-only one cannot stand in for the processor's.
|
||||
var temperature = new LhmComputerAdapter(LhmGroups.Cpu | LhmGroups.Memory, script.Library);
|
||||
temperature.Open();
|
||||
script.Made.Should().HaveCount(3);
|
||||
script.Made[2].Groups.Should().Be(LhmGroups.Cpu | LhmGroups.Memory);
|
||||
|
||||
temperature.Close();
|
||||
reader.Close();
|
||||
script.Made.Should().OnlyContain(static m => m.Computer.Closes == 1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnOpenThatThrowsCountsNoUserAndLeavesNothingBehind()
|
||||
{
|
||||
var script = new Script { NextOpenThrows = true };
|
||||
var failing = new LhmComputerAdapter(_advanced, script.Library);
|
||||
|
||||
failing.Invoking(static a => a.Open()).Should().Throw<InvalidOperationException>();
|
||||
|
||||
script.Library.Users.Should().Be(0);
|
||||
script.Library.Parked.Should().Be(0);
|
||||
failing.Close();
|
||||
script.Made[0].Computer.Closes.Should().Be(0, "what never opened is not closed");
|
||||
|
||||
// And the next user is the first: its close is the last close.
|
||||
var next = new LhmComputerAdapter(_session, script.Library);
|
||||
next.Open();
|
||||
next.Close();
|
||||
script.Made[1].Computer.Closes.Should().Be(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheLastCloseClosesEveryComputerEvenWhenOneThrowsAndThenSaysSo()
|
||||
{
|
||||
var script = new Script { EveryCloseThrows = true };
|
||||
var reader = new LhmComputerAdapter(_advanced, script.Library);
|
||||
var session = new LhmComputerAdapter(_session, script.Library);
|
||||
reader.Open();
|
||||
session.Open();
|
||||
session.Close();
|
||||
|
||||
reader.Invoking(static a => a.Close()).Should().Throw<InvalidOperationException>("the caller is told, as it was before");
|
||||
|
||||
script.Made.Should().OnlyContain(static m => m.Computer.Closes == 1, "a throw from one does not leave the other open");
|
||||
script.Library.Users.Should().Be(0);
|
||||
script.Library.Parked.Should().Be(0, "and the library starts afresh for the next user");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task OpensAndClosesFromManyThreadsNeverRunAtOnce()
|
||||
{
|
||||
// Rule 1. Each scripted instance says so if it is entered while another Open or Close is inside.
|
||||
int inside = 0;
|
||||
int overlaps = 0;
|
||||
var library = new LhmLibrary(_ => new Probe(() =>
|
||||
{
|
||||
if (Interlocked.Increment(ref inside) != 1)
|
||||
{
|
||||
Interlocked.Increment(ref overlaps);
|
||||
}
|
||||
|
||||
Thread.SpinWait(200);
|
||||
Interlocked.Decrement(ref inside);
|
||||
}));
|
||||
|
||||
Task[] users = [.. Enumerable.Range(0, 8).Select(n => Task.Run(() =>
|
||||
{
|
||||
LhmGroups groups = (n % 2 == 0) ? _session : _advanced;
|
||||
for (int i = 0; i < 200; i++)
|
||||
{
|
||||
var user = new LhmComputerAdapter(groups, library);
|
||||
user.Open();
|
||||
user.Close();
|
||||
}
|
||||
}, TestContext.Current.CancellationToken))];
|
||||
await Task.WhenAll(users);
|
||||
|
||||
overlaps.Should().Be(0);
|
||||
library.Users.Should().Be(0);
|
||||
library.Parked.Should().Be(0);
|
||||
}
|
||||
|
||||
/// <summary>An instance that runs <paramref name="entered"/> inside every Open and Close.</summary>
|
||||
private sealed class Probe(Action entered) : ILhmComputer
|
||||
{
|
||||
public IReadOnlyList<IHardware> Hardware => [];
|
||||
|
||||
public void Open() => entered();
|
||||
|
||||
public void Update()
|
||||
{
|
||||
}
|
||||
|
||||
public void Close() => entered();
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,49 @@ namespace FrameLedger.Infrastructure.Tests.Telemetry;
|
||||
[Collection(LibreHardwareMonitorCollection.Name)]
|
||||
public sealed class LhmRealHardwareTests
|
||||
{
|
||||
[Fact]
|
||||
public void TwoUsersOfTheRealLibraryOneLetsGoAndTheOtherStillReads()
|
||||
{
|
||||
// The shape that failed on the owner's PC (2026-11-12): a session's source closes while the Advanced reader
|
||||
// reads on. Unelevated this cannot show the fault itself - that needs PawnIO and the processor group - so it
|
||||
// asserts what LhmLibrary promises of the real Computer: the second user's tree is still there and still
|
||||
// updates, the first one's Computer is parked and handed to the next user, and the last close leaves nothing.
|
||||
LhmLibrary library = LhmLibrary.Process;
|
||||
int usersBefore = library.Users;
|
||||
int parkedBefore = library.Parked;
|
||||
var reader = new LhmComputerAdapter(LhmGroups.Gpu);
|
||||
var session = new LhmComputerAdapter(LhmGroups.Gpu);
|
||||
try
|
||||
{
|
||||
reader.Open();
|
||||
session.Open();
|
||||
int devices = reader.Hardware.Count;
|
||||
|
||||
session.Close();
|
||||
|
||||
library.Users.Should().Be(usersBefore + 1);
|
||||
reader.Invoking(static r => r.Update()).Should().NotThrow("its library was not closed under it");
|
||||
reader.Hardware.Should().HaveCount(devices);
|
||||
|
||||
var next = new LhmComputerAdapter(LhmGroups.Gpu);
|
||||
next.Open();
|
||||
library.Parked.Should().Be(parkedBefore, "the next session took the parked Computer rather than opening another");
|
||||
next.Hardware.Should().HaveCount(devices);
|
||||
next.Close();
|
||||
}
|
||||
finally
|
||||
{
|
||||
session.Close();
|
||||
reader.Close();
|
||||
}
|
||||
|
||||
library.Users.Should().Be(usersBefore);
|
||||
if (usersBefore == 0)
|
||||
{
|
||||
library.Parked.Should().Be(0, "the last user's close closes every parked Computer with its own");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheRealLibraryEitherSamplesOrDisablesAndNeverClaimsAFieldItDidNotRead()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user