Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ff2ffc794
|
||
|
|
ca7d9cb028 | ||
|
|
96cb45605d | ||
|
|
283e8b632e |
No files matched your search
@@ -35,6 +35,35 @@ numeric core and does not move; the heading is the full version — corrected 20
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- **The Overlay's log is whole after a game exits, and says more.** The log FrameLedger's part inside the game
|
||||
writes (`logs\overlay-<pid>-….log`) used to hold only the first half second of a session unless the session
|
||||
ended while the game was still running: a game that exits takes the thread that writes the log with it. It is
|
||||
now written during the session, whenever something new was noted. Each hook that went in is named by its module
|
||||
and function (four AMD modules used to be four identical lines), a hook that could not go in says why, and the
|
||||
log lists which kinds of call each AMD FidelityFX module received and which upscaling and frame-generation
|
||||
modules the game loaded, and when. This is for finding out why a game's upscaler reads "unknown" — nothing in
|
||||
it is a measurement, and nothing from it is stored in a session. Measured cost: about 4 billionths of a second
|
||||
per FidelityFX call.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **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
|
||||
|
||||
Newest first. Each file holds that release's section exactly as it stood here.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -93,7 +93,7 @@ Tails the active files (shared read), level filter, text search, pause autoscrol
|
||||
2. **Bundle builder** creates `FrameLedger-bugreport-YYYYMMDD-HHmm.zip` in a user-chosen location:
|
||||
- `logs/` (last 7 days, redacted copies)
|
||||
- `sysinfo.json` (app + agent + **overlay build id**, OS build, CPU/GPU name, driver version, telemetry source, Vulkan layer state, PawnIO present?, elevation state, locale)
|
||||
- `overlay-<pid>-*.log` for the last hooked sessions, plus hook fault details and the ring's dropped/fault counters — these are what make injection bugs diagnosable at all. *(The file exists since 2026-09-06 — `17_HOOK_ENGINE` §Native logging: written at init, on the Agent's request at session end, and on the stop; `FAULT` lines carry the exception code and the hook's name, `UNHOOK_*` lines say per patch whether it was restored or left to a later hooker.)*
|
||||
- `overlay-<pid>-*.log` for the last hooked sessions, plus hook fault details and the ring's dropped/fault counters — these are what make injection bugs diagnosable at all. *(The file exists since 2026-09-06 — `17_HOOK_ENGINE` §Native logging: written at init, on the Agent's request at session end, and on the stop — and since 0.1.0-beta.42 by the Overlay's watchdog whenever something new was logged, so it is whole after a game that simply exits, with each install named by module and symbol and each descriptor type an ffx module was handed; `FAULT` lines carry the exception code and the hook's name, `UNHOOK_*` lines say per patch whether it was restored or left to a later hooker.)*
|
||||
- `settings.json` (sanitized — no paths)
|
||||
- optional checkbox: last session metadata + aggregates JSON (never raw blobs by default)
|
||||
- crash dumps included only when the user ticks the checkbox (size warning shown)
|
||||
|
||||
+78
-4
@@ -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.
|
||||
|
||||
@@ -753,13 +780,16 @@ compare-and-restore that never restores is not a fix.
|
||||
No logging in hook bodies. A small fixed-size in-memory ring of structured events (hook installed, symbol missing, fault, unhook) is flushed to `logs\overlay-<pid>-*.log` by the init thread at session end, on unhook, or on Agent request — never mid-frame.
|
||||
|
||||
> **Built 2026-09-06 (P1 item 4), as specified, with the details a bug report needs.** A ring of 256 ×
|
||||
> 64-byte events (`qpc`, code, two operands, a 40-char name) appended with one `fetch_add` from init and
|
||||
> ~~64-byte events (`qpc`, code, two operands, a 40-char name)~~ 96-byte events (`qpc`, code, two operands, a
|
||||
> 72-char name — 64 bytes and 40 characters until beta.42) appended with one `fetch_add` from init and
|
||||
> watchdog paths and from a hook's **SEH handler** — `NoteFault` records the exception code and the hook's
|
||||
> `__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)
|
||||
> and `FFX_DISPATCH`, `FFX_QUERY`, `UPSCALE_ROUTE`, `RUNTIME_CENSUS` (the note at the end of this section).
|
||||
> **Three flush points — four since beta.42, the same note —, 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
|
||||
@@ -777,8 +807,52 @@ No logging in hook bodies. A small fixed-size in-memory ring of structured event
|
||||
> line. Nothing on a present path changed. Path: `%LOCALAPPDATA%\FrameLedger\logs\overlay-<pid>-<yyyymmdd-hhmmss>.log`,
|
||||
> resolved by `SHGetKnownFolderPath` (§S21's rule, not the environment). No allocation: static ring,
|
||||
> static 64 KiB format buffer, static path. The CaptureHost prints the file and its `FAULT` / `STOP` /
|
||||
> `UNHOOK_*` / `SYMBOL_MISSING` / `SUPERVISION_LOST` lines at the end of every session
|
||||
> `UNHOOK_*` / `SYMBOL_MISSING` / `PATCH_FAILED` / `SUPERVISION_LOST` lines at the end of every session
|
||||
> (`Consume/OverlayLog.cs`).
|
||||
>
|
||||
> **The log outlives the game, and says what each ffx module was handed (0.1.0-beta.42, owner decision D121).**
|
||||
> Cyberpunk 2077, set to FSR upscaling with FSR frame generation, was recorded with frame generation measured and
|
||||
> the upscaler "unknown": PREPARE and FRAMEGENERATION dispatches arrived and no UPSCALE ever did. The log could
|
||||
> not say why. **It ended half a second into the session** — written at the end of init, then only when the Agent
|
||||
> asked or a stop ran, and a game that exits does neither: the watchdog dies with the process. And **it could not
|
||||
> have said much**: the two one-target rows logged their symbol and every other row the word `hook`, so four ffx
|
||||
> modules were one indistinguishable line each. Four changes, none of them a new patch site:
|
||||
>
|
||||
> 1. **A fourth flush point: the watchdog, on any tick that finds something new in the ring** (`FlushLogIfNew`:
|
||||
> one load on an uneventful tick, no file opened). Events are few and bounded — installs, first sights, three
|
||||
> faults at most — so this is a handful of appends a session. The init thread's flush moved to **before** the
|
||||
> watchdog is created: `FlushLog`'s state belongs to one thread at a time, and with the watchdog flushing on its
|
||||
> first tick the old order could run two at once.
|
||||
> 2. **Every install line names its module and its symbol** — `amd_fidelityfx_dx12.dll!ffxDispatch` — built at
|
||||
> compile time from the inventory row's own two spellings (`fl::inventory::NameOfRow`), so no second list of
|
||||
> names exists. The same name is on the `UNHOOK_*` and `PATCH_FAILED` lines. The event's text grew from 40 to
|
||||
> 72 characters for it (an event is 96 bytes; the ring 24 KiB, static), and `PatchTarget` lost its default
|
||||
> name, so a new call site cannot log `hook`.
|
||||
> 3. **`FFX_DISPATCH` / `FFX_QUERY`: each descriptor type a hooked ffx-api module was handed, once**
|
||||
> (`fl_ffx_types.h`). Text = the module, `b` = the type (`0x10001` UPSCALE, `0x20004` / `0x2000c` PREPARE,
|
||||
> `0x20003` FRAMEGENERATION, …); `a` ≠ 0 with `b=0` says what did not fit (`1` a ninth distinct type, `2` a
|
||||
> type of zero). The detour keeps the value of `type` — the member it reads already to choose an arm — in the
|
||||
> first free of eight slots per module and entry point; the watchdog writes it. A query's type is kept whatever
|
||||
> the vendor answered. `UPSCALE_ROUTE` names each source an UPSCALE came from, once (the FSR 3.0 host has no
|
||||
> descriptor type, so this is the only line that says its export was called), and `RUNTIME_CENSUS` repeats the
|
||||
> census word (`b`) whenever it gains a bit — both from words the detours kept before, at no cost to a hook.
|
||||
> 4. **`PATCH_FAILED`** (§Unhooking) is the fourth: a patch that did not go in used to leave no line at all.
|
||||
>
|
||||
> **This is a diagnostic, not a measurement, and it is not behind the Advanced-metrics switch** — like
|
||||
> `HOOK_INSTALLED`, it reaches the log file and nothing else: no record, no region of the shared memory, no session.
|
||||
> Rule 4: the only thing read is `type`, of a descriptor handed to a hooked call. Rule 5: no allocation, no lock,
|
||||
> no logging in the body; a type already kept costs loads and no write.
|
||||
>
|
||||
> **Measured overhead** (on `fl_ffx_types.h` itself with the Overlay's compile flags — `/O2 /GS /guard:cf
|
||||
> /Qspectre`, 50 million calls a run, three runs, i7-14700KF): a frame's three dispatch types in turn, **+3.8 ns a
|
||||
> dispatch** (3.79 / 3.87 / 3.81); a type in the first slot +0.9 to +1.0 ns; in the eighth, the worst steady
|
||||
> state, +8.1 to +8.4 ns. A new type costs one compare-exchange, once per type and module.
|
||||
>
|
||||
> ctest `fl_ffx_types` (the header, including eight threads meeting the same six types at once: each kept exactly
|
||||
> once) and `fl_guard` `[log]`: a harness on the 1.1.x monolith, generating frames and asking a ratio query, is
|
||||
> supervised and told **nothing else** — no flush request, no stop — and its log holds the two install lines by
|
||||
> module and symbol, the three dispatch types and the query type once each, the route and the census; the process
|
||||
> is then killed and the file is as it was, one header, no `STOP`.
|
||||
|
||||
> **Tests and the real logs folder (2026-09-15).** The injection tests use the shipped Overlay, so their harness
|
||||
> logs land in the user's real `logs\` too: measured that day, 2506 overlay logs, **2492 of them hook-harness's**,
|
||||
|
||||
@@ -715,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~~ .42, .43 *(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)* | 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 *(D118)* | 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 *(D118)* | 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
|
||||
@@ -771,6 +771,13 @@ planning, the design reviewed against the code before it was approved.
|
||||
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
|
||||
|
||||
+36
-48
@@ -81,7 +81,7 @@ owner-only items stay below; the history of every train, the passed owner-only i
|
||||
| `§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 |
|
||||
|
||||
@@ -115,9 +115,26 @@ the traps — is [`handoff/history/0.1.0-beta.40.md`](handoff/history/0.1.0-beta
|
||||
|
||||
### NEXT
|
||||
|
||||
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).
|
||||
2. **0.1.0-beta.42 — train B's second release — when the owner says item 38 passed**: `slSetConstants` and
|
||||
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
|
||||
@@ -154,7 +171,8 @@ the traps — is [`handoff/history/0.1.0-beta.40.md`](handoff/history/0.1.0-beta
|
||||
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.
|
||||
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):
|
||||
@@ -177,24 +195,27 @@ the traps — is [`handoff/history/0.1.0-beta.40.md`](handoff/history/0.1.0-beta
|
||||
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 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 (item 38
|
||||
(j); the owner said on 2026-11-12 that they will). Until then `main`'s `sonarcloud` job is red on that one line.
|
||||
- **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).
|
||||
|
||||
**Owner-only:** item 39 — beta.41 on the PC that showed the fault: several sessions as administrator with PawnIO,
|
||||
the Advanced page open and closed between them, and the Agent's log afterwards.
|
||||
**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.
|
||||
@@ -493,43 +514,6 @@ the Advanced page open and closed between them, and the Agent's log afterwards.
|
||||
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.
|
||||
39. **beta.41, the sensor library on the PC that showed the fault** (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.
|
||||
**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 —
|
||||
@@ -661,6 +645,10 @@ Where each owner decision is recorded — the file and its section, and a label
|
||||
| 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`) |
|
||||
|
||||
---
|
||||
|
||||
@@ -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.
|
||||
@@ -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,
|
||||
|
||||
@@ -75,12 +75,16 @@ internal static class OverlayLog
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Faults, the stop, unhook decisions, a missing symbol, supervision loss — never the routine installs.</summary>
|
||||
/// <summary>
|
||||
/// Faults, the stop, unhook decisions, a missing symbol, a patch that did not go in, supervision loss — never the
|
||||
/// routine installs.
|
||||
/// </summary>
|
||||
private static bool IsWorthPrinting(string line) =>
|
||||
line.StartsWith('+', StringComparison.Ordinal)
|
||||
&& (line.Contains(" FAULT ", StringComparison.Ordinal)
|
||||
|| line.Contains(" STOP ", StringComparison.Ordinal)
|
||||
|| line.Contains(" UNHOOK_", StringComparison.Ordinal)
|
||||
|| line.Contains(" SYMBOL_MISSING ", StringComparison.Ordinal)
|
||||
|| line.Contains(" PATCH_FAILED ", StringComparison.Ordinal)
|
||||
|| line.Contains(" SUPERVISION_LOST ", StringComparison.Ordinal));
|
||||
}
|
||||
@@ -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)]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
// Which descriptor types an ffx-api module was handed, for the native log
|
||||
// (17_HOOK_ENGINE §Native logging; 0.1.0-beta.42, owner decision D121).
|
||||
//
|
||||
// WHY. Cyberpunk 2077, set to FSR upscaling with FSR frame generation, was
|
||||
// recorded with frame generation measured and the upscaler "unknown": the
|
||||
// PREPARE and FRAMEGENERATION dispatches arrived and no UPSCALE dispatch ever
|
||||
// did. Nothing in the field could say where the upscale went -- the record
|
||||
// carries what was decoded, never what was not. This keeps, per hooked module
|
||||
// and per entry point, the distinct values of the one member every ffx-api
|
||||
// descriptor starts with -- its `type`, which the detours read already to choose
|
||||
// an arm -- and the watchdog writes each to the log the first time it is seen.
|
||||
// One session's log then says which module was called with what.
|
||||
//
|
||||
// NOT A MEASUREMENT AND NOT GATED BY ADVANCED METRICS: it is a diagnostic, like
|
||||
// HOOK_INSTALLED. It reaches the log file and nothing else -- no record, no
|
||||
// region of the shared memory, no session.
|
||||
//
|
||||
// THE HOOK'S SHARE IS A FEW LOADS. A type already kept costs one relaxed load
|
||||
// per slot up to its own and no write; a title sends two to four distinct types
|
||||
// per module, so that is two to four loads a call. A NEW type costs one
|
||||
// compare-exchange, once. Slots fill in order and are never cleared, so the
|
||||
// watchdog's "how many have I logged" is a prefix length. No allocation, no
|
||||
// lock, no logging here (rule 5); nothing is read but the value passed in
|
||||
// (rule 4).
|
||||
//
|
||||
// Header-only so the cost is measured on this code itself and ctest fl_ffx_types
|
||||
// drives it without the Overlay.
|
||||
|
||||
#ifndef FRAMELEDGER_FL_FFX_TYPES_H
|
||||
#define FRAMELEDGER_FL_FFX_TYPES_H
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
||||
namespace fl::ffxtypes {
|
||||
|
||||
inline constexpr std::uint32_t kSlots = 8;
|
||||
|
||||
// What did not fit, OR'd into Seen::more.
|
||||
enum More : std::uint32_t {
|
||||
kMoreTypes = 1u << 0, // a ninth distinct type arrived: the eight kept are not all there were
|
||||
kMoreZero = 1u << 1, // a descriptor whose type was 0 arrived (0 is the empty slot, so it has no slot)
|
||||
};
|
||||
|
||||
struct alignas(64) Seen {
|
||||
std::atomic<std::uint64_t> types[kSlots]{};
|
||||
std::atomic<std::uint32_t> more{0};
|
||||
// Filled out to two cache lines by hand, so that the words another module's detour reads are never on a line
|
||||
// this one writes -- and so that the padding is stated rather than left to the compiler (C4324).
|
||||
std::uint8_t reserved[60]{};
|
||||
};
|
||||
static_assert(sizeof(Seen) == 128, "two cache lines: eight types, the More word, and the stated padding");
|
||||
|
||||
namespace detail {
|
||||
|
||||
inline void NoteMore(Seen& seen, std::uint32_t bit) noexcept {
|
||||
// Read first: once the bit is set, a title that sends such a descriptor every frame writes nothing.
|
||||
if ((seen.more.load(std::memory_order_relaxed) & bit) == 0u) {
|
||||
seen.more.fetch_or(bit, std::memory_order_relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// Hook path. Keep `type` if it is new.
|
||||
inline void Note(Seen& seen, std::uint64_t type) noexcept {
|
||||
if (type == 0u) {
|
||||
detail::NoteMore(seen, kMoreZero);
|
||||
return;
|
||||
}
|
||||
for (std::atomic<std::uint64_t>& slot : seen.types) {
|
||||
std::uint64_t kept = slot.load(std::memory_order_relaxed);
|
||||
if (kept == type) {
|
||||
return;
|
||||
}
|
||||
if (kept == 0u) {
|
||||
if (slot.compare_exchange_strong(kept, type, std::memory_order_relaxed)) {
|
||||
return;
|
||||
}
|
||||
if (kept == type) {
|
||||
return; // another thread kept the same type in this slot first
|
||||
}
|
||||
// ...or a different one: this slot is taken, the next is tried.
|
||||
}
|
||||
}
|
||||
detail::NoteMore(seen, kMoreTypes);
|
||||
}
|
||||
|
||||
// Watchdog side: how far one Seen has been written to the log.
|
||||
struct Reported {
|
||||
std::uint32_t types = 0; // slots [0, types) are in the log
|
||||
std::uint32_t more = 0; // More bits already in the log
|
||||
};
|
||||
|
||||
// Calls onType(type) for every kept type not reported yet, in the order they were kept, and onMore(bits) for More
|
||||
// bits not reported yet. One thread per Reported.
|
||||
template <class OnType, class OnMore>
|
||||
void ReportNew(const Seen& seen, Reported& reported, OnType&& onType, OnMore&& onMore) noexcept {
|
||||
while (reported.types < kSlots) {
|
||||
const std::uint64_t type = seen.types[reported.types].load(std::memory_order_relaxed);
|
||||
if (type == 0u) {
|
||||
break;
|
||||
}
|
||||
onType(type);
|
||||
++reported.types;
|
||||
}
|
||||
const std::uint32_t more = seen.more.load(std::memory_order_relaxed);
|
||||
if (const std::uint32_t fresh = more & ~reported.more; fresh != 0u) {
|
||||
onMore(fresh);
|
||||
reported.more |= fresh;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace fl::ffxtypes
|
||||
|
||||
#endif // FRAMELEDGER_FL_FFX_TYPES_H
|
||||
@@ -376,6 +376,59 @@ 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");
|
||||
|
||||
// A row's "module!symbol", for the native log, built at compile time from the row's own two spellings -- so an
|
||||
// install line names the module it patched, and no second list of names exists to drift from the table
|
||||
// (0.1.0-beta.42). The module names are ASCII by the table's own spelling; the assert below keeps every row inside
|
||||
// the text, so no two rows can log the same truncated name.
|
||||
struct RowName {
|
||||
char text[72]{};
|
||||
};
|
||||
constexpr RowName NameOfRow(const wchar_t* moduleName, const char* symbol) noexcept {
|
||||
RowName name{};
|
||||
size_t i = 0;
|
||||
for (; *moduleName != L'\0' && i + 1 < sizeof(name.text); ++moduleName) {
|
||||
name.text[i++] = static_cast<char>(*moduleName);
|
||||
}
|
||||
if (i + 1 < sizeof(name.text)) {
|
||||
name.text[i++] = '!';
|
||||
}
|
||||
for (; *symbol != '\0' && i + 1 < sizeof(name.text); ++symbol) {
|
||||
name.text[i++] = *symbol;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
constexpr size_t LengthW(const wchar_t* text) noexcept {
|
||||
size_t n = 0;
|
||||
while (text[n] != L'\0') {
|
||||
++n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
constexpr size_t LengthA(const char* text) noexcept {
|
||||
size_t n = 0;
|
||||
while (text[n] != '\0') {
|
||||
++n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
constexpr bool EveryRowNameFits() noexcept {
|
||||
#define FL_ROW_NAME_FITS(mod, sym, family) \
|
||||
if (LengthW(mod) + 1 + LengthA(sym) + 1 > sizeof(RowName::text)) { \
|
||||
return false; \
|
||||
}
|
||||
FL_HOOK_INVENTORY(FL_ROW_NAME_FITS)
|
||||
#undef FL_ROW_NAME_FITS
|
||||
return true;
|
||||
}
|
||||
static_assert(EveryRowNameFits(), "a row's module!symbol does not fit RowName::text -- widen it, and the log event's");
|
||||
|
||||
// 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
|
||||
@@ -50,8 +50,10 @@
|
||||
#include <fl_d3d12_vtable.h>
|
||||
#include <fl_dxgi_count.h>
|
||||
#include <fl_dxgi_vtable.h>
|
||||
#include <fl_ffx_types.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>
|
||||
@@ -133,6 +135,15 @@ void PublishHandshake() noexcept {
|
||||
// present path. No allocation anywhere: the ring, the format buffer and the path
|
||||
// are static; the one system call that could allocate (SHGetKnownFolderPath)
|
||||
// runs on the init/watchdog thread and is freed at once.
|
||||
//
|
||||
// AND, SINCE 0.1.0-beta.42, BY THE WATCHDOG WHENEVER SOMETHING NEW WAS LOGGED. A
|
||||
// game that exits takes the watchdog with it: nothing asks for a flush and no
|
||||
// stop runs, so the file held what init wrote and nothing after -- the first
|
||||
// half second of a session. Cyberpunk 2077's upscaler read "unknown" (D121) and
|
||||
// the log that should have said which hooks went in and what they were handed
|
||||
// ended before the game had loaded its upscaler. Events are few and bounded
|
||||
// (installs, a handful of first sights, three faults at most), so this is a few
|
||||
// appends per session, on the watchdog's own tick.
|
||||
// ---------------------------------------------------------------------------
|
||||
enum FlLogCode : uint32_t {
|
||||
kLogRingCreated = 1,
|
||||
@@ -147,6 +158,11 @@ enum FlLogCode : uint32_t {
|
||||
kLogSupervisionLost,
|
||||
kLogTolerance,
|
||||
kLogStopFlushed,
|
||||
kLogPatchFailed,
|
||||
kLogFfxDispatchType,
|
||||
kLogFfxQueryType,
|
||||
kLogUpscaleRoute,
|
||||
kLogRuntimeCensus,
|
||||
};
|
||||
|
||||
const char* LogCodeName(uint32_t code) noexcept {
|
||||
@@ -175,18 +191,33 @@ const char* LogCodeName(uint32_t code) noexcept {
|
||||
return "TOLERANCE";
|
||||
case kLogStopFlushed:
|
||||
return "STOP_FLUSHED";
|
||||
case kLogPatchFailed:
|
||||
return "PATCH_FAILED";
|
||||
case kLogFfxDispatchType:
|
||||
return "FFX_DISPATCH";
|
||||
case kLogFfxQueryType:
|
||||
return "FFX_QUERY";
|
||||
case kLogUpscaleRoute:
|
||||
return "UPSCALE_ROUTE";
|
||||
case kLogRuntimeCensus:
|
||||
return "RUNTIME_CENSUS";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
// 72 characters of text since 0.1.0-beta.42 (40 until then): an install line names its module AND its symbol, and
|
||||
// "amd_fidelityfx_framegeneration_dx12.dll!ffxDispatch" is 51.
|
||||
struct FlLogEvent {
|
||||
uint64_t qpc;
|
||||
uint32_t code;
|
||||
uint32_t a;
|
||||
uint64_t b;
|
||||
char text[40];
|
||||
char text[72];
|
||||
};
|
||||
static_assert(sizeof(FlLogEvent) == 96, "the native log's event: 256 of them are static storage in a game's process");
|
||||
static_assert(sizeof(fl::inventory::RowName::text) <= sizeof(FlLogEvent::text),
|
||||
"a row's module!symbol name must fit an event's text, or two rows could log the same truncated name");
|
||||
|
||||
constexpr uint32_t kLogCapacity = 256;
|
||||
FlLogEvent g_log[kLogCapacity]{};
|
||||
@@ -224,7 +255,7 @@ void LogNote(uint32_t code, const char* text, uint32_t a = 0, uint64_t b = 0) no
|
||||
|
||||
// Narrow ASCII copy of a module name for the log; anything outside ASCII is '?'.
|
||||
void LogNoteW(uint32_t code, const wchar_t* text, uint32_t a = 0, uint64_t b = 0) noexcept {
|
||||
char narrow[40]{};
|
||||
char narrow[sizeof(FlLogEvent::text)]{};
|
||||
size_t i = 0;
|
||||
for (; text != nullptr && i + 1 < sizeof(narrow) && text[i] != L'\0'; ++i) {
|
||||
narrow[i] = (text[i] < 128) ? static_cast<char>(text[i]) : '?';
|
||||
@@ -329,28 +360,68 @@ void FlushLog(bool lastFlush = false) noexcept {
|
||||
CloseHandle(h);
|
||||
}
|
||||
|
||||
// The watchdog's own flush: only when something was logged since the last one, so an uneventful second costs one
|
||||
// load and opens no file. Watchdog thread only -- see FlushLog.
|
||||
void FlushLogIfNew() noexcept {
|
||||
if (g_logNext.load(std::memory_order_acquire) != g_logFlushed) {
|
||||
FlushLog();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// The patch registry (17_HOOK_ENGINE §Unhooking; P1 item 4). Every MinHook
|
||||
// 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 +921,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 +936,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 +954,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) 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 +1623,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;
|
||||
@@ -1814,6 +1913,14 @@ void NoteFfxExtent(const FfxApiDimensions2D& size) noexcept {
|
||||
NoteFfxExtent(size.width, size.height);
|
||||
}
|
||||
|
||||
// Which descriptor types each hooked ffx-api module was handed, per entry point, for the native log (fl_ffx_types.h;
|
||||
// D121). The detours keep a type the first time it is seen; the watchdog writes it. A diagnostic: nothing here reaches
|
||||
// a record or the shared memory.
|
||||
fl::ffxtypes::Seen g_ffxDispatchTypes[fl::inventory::kFfxLeafCount];
|
||||
fl::ffxtypes::Seen g_ffxQueryTypes[fl::inventory::kFfxLeafCount];
|
||||
fl::ffxtypes::Reported g_ffxDispatchTypesLogged[fl::inventory::kFfxLeafCount]; // watchdog only
|
||||
fl::ffxtypes::Reported g_ffxQueryTypesLogged[fl::inventory::kFfxLeafCount]; // watchdog only
|
||||
|
||||
// The answer one query returned, kept for the dispatch arm. Read only after the vendor answered OK; a mode, a size or a
|
||||
// ratio the byte or the match cannot carry is not kept.
|
||||
void ObserveFfxQuery(uint32_t leaf, const ffxQueryDescHeader* desc) noexcept {
|
||||
@@ -1898,6 +2005,7 @@ void ObserveFfxDispatch(uint32_t leaf, const ffxDispatchDescHeader* desc) noexce
|
||||
if (desc == nullptr) {
|
||||
return;
|
||||
}
|
||||
fl::ffxtypes::Note(g_ffxDispatchTypes[leaf], desc->type);
|
||||
switch (desc->type) {
|
||||
case FFX_API_DISPATCH_DESC_TYPE_UPSCALE: {
|
||||
const auto* up = reinterpret_cast<const ffxDispatchDescUpscale*>(desc);
|
||||
@@ -2001,8 +2109,14 @@ ffxReturnCode_t Hook_FfxQueryT(ffxContext* context, ffxQueryDescHeader* desc) {
|
||||
static_assert(Leaf < fl::inventory::kFfxLeafCount, "a trampoline per leaf, and no more");
|
||||
const ffxReturnCode_t rc = g_origFfxQuery[Leaf](context, desc);
|
||||
FL_HOOK_GUARD({
|
||||
if (rc == FFX_API_RETURN_OK && MayObserve()) {
|
||||
ObserveFfxQuery(Leaf, desc);
|
||||
if (MayObserve()) {
|
||||
// The type is kept whatever the vendor answered: a query that was refused is still a query that was made.
|
||||
if (desc != nullptr) {
|
||||
fl::ffxtypes::Note(g_ffxQueryTypes[Leaf], desc->type);
|
||||
}
|
||||
if (rc == FFX_API_RETURN_OK) {
|
||||
ObserveFfxQuery(Leaf, desc);
|
||||
}
|
||||
}
|
||||
})
|
||||
return rc;
|
||||
@@ -2141,36 +2255,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 {
|
||||
@@ -2186,6 +2270,8 @@ void PublishHookFamily(uint32_t family, std::atomic<uint32_t>& live) noexcept {
|
||||
// upscaler runtime in this process" -- which is not the same question as "did the
|
||||
// title generate frames", and fl_shm.h spends a section on why it must not be
|
||||
// read as one.
|
||||
uint32_t g_runtimeCensusLogged = 0; // watchdog only
|
||||
|
||||
void PublishRuntimeCensus() noexcept {
|
||||
if (g_state == nullptr) {
|
||||
return;
|
||||
@@ -2193,6 +2279,42 @@ void PublishRuntimeCensus() noexcept {
|
||||
const uint32_t seen = fl::inventory::ObserveRuntimeModules();
|
||||
std::atomic_ref<uint32_t> census{g_state->runtimeCensus};
|
||||
census.fetch_or(seen, std::memory_order_relaxed);
|
||||
// The same word in the log whenever it gains a bit (0.1.0-beta.42): `b` is the whole census so far, so the last
|
||||
// such line of a session's log is the census the session ended with, and the time of each line is when a
|
||||
// runtime appeared.
|
||||
if ((seen & ~g_runtimeCensusLogged) != 0u) {
|
||||
g_runtimeCensusLogged |= seen;
|
||||
LogNote(kLogRuntimeCensus, "FlRuntimeCensus bits (fl_shm.h)", 0u, g_runtimeCensusLogged);
|
||||
}
|
||||
}
|
||||
|
||||
// The diagnostics the watchdog writes from what the detours kept (0.1.0-beta.42, D121): each descriptor type a hooked
|
||||
// ffx-api module was handed, once -- FFX_DISPATCH / FFX_QUERY, the module, b = the type; a = More bits and b = 0 for
|
||||
// what did not fit -- and each source an UPSCALE came from, once. Watchdog only; nothing here is on a hook path.
|
||||
uint32_t g_upscaleRoutesLogged = 0;
|
||||
|
||||
void LogFfxObservations() noexcept {
|
||||
for (uint32_t leaf = 0; leaf < fl::inventory::kFfxLeafCount; ++leaf) {
|
||||
const wchar_t* moduleName = fl::inventory::kFfxLeafModules[leaf];
|
||||
fl::ffxtypes::ReportNew(
|
||||
g_ffxDispatchTypes[leaf], g_ffxDispatchTypesLogged[leaf],
|
||||
[moduleName](uint64_t type) noexcept { LogNoteW(kLogFfxDispatchType, moduleName, 0u, type); },
|
||||
[moduleName](uint32_t more) noexcept { LogNoteW(kLogFfxDispatchType, moduleName, more, 0u); });
|
||||
fl::ffxtypes::ReportNew(
|
||||
g_ffxQueryTypes[leaf], g_ffxQueryTypesLogged[leaf],
|
||||
[moduleName](uint64_t type) noexcept { LogNoteW(kLogFfxQueryType, moduleName, 0u, type); },
|
||||
[moduleName](uint32_t more) noexcept { LogNoteW(kLogFfxQueryType, moduleName, more, 0u); });
|
||||
}
|
||||
// g_ffxUpscaleLeaf: leaf + 1 for an ffx-api leaf, kFfxUpscaleSourceFsr3Host for the 3.0 host's own export, 0 for
|
||||
// none yet. The host has no descriptor type, so this is the only line that says its export was called.
|
||||
const uint32_t route = g_ffxUpscaleLeaf.load(std::memory_order_relaxed);
|
||||
if (route != 0u && route <= kFfxUpscaleSourceFsr3Host && (g_upscaleRoutesLogged & (1u << route)) == 0u) {
|
||||
g_upscaleRoutesLogged |= 1u << route;
|
||||
LogNoteW(kLogUpscaleRoute,
|
||||
route == kFfxUpscaleSourceFsr3Host ? fl::inventory::kModuleFfxFsr3Host
|
||||
: fl::inventory::kFfxLeafModules[route - 1u],
|
||||
route);
|
||||
}
|
||||
}
|
||||
|
||||
// The tag census, on the same tick and by the same rule: OR-only, from the
|
||||
@@ -2244,7 +2366,7 @@ void NoteSymbolMissingOnce(const wchar_t* moduleName, const char* symbol)
|
||||
}
|
||||
|
||||
bool InstallRow(const wchar_t* moduleName, const char* symbol, uint32_t family, void* detour, void** original,
|
||||
std::atomic<uint32_t>& live) noexcept {
|
||||
std::atomic<uint32_t>& live, const char* name) noexcept {
|
||||
if (live.load(std::memory_order_acquire) != 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -2258,7 +2380,7 @@ bool InstallRow(const wchar_t* moduleName, const char* symbol, uint32_t family,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!PatchTarget(target, detour, original, symbol)) {
|
||||
if (!PatchTarget(target, detour, original, name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2272,14 +2394,17 @@ bool InstallRow(const wchar_t* moduleName, const char* symbol, uint32_t family,
|
||||
// is the safe direction: an unbound row is a table entry somebody added without
|
||||
// writing its hook, and hooking it with a neighbour's body is exactly what this
|
||||
// function exists to stop.
|
||||
bool InstallByFamily(const wchar_t* moduleName, const char* symbol, uint32_t family) noexcept {
|
||||
//
|
||||
// `name` is the row's "module!symbol", for the log (0.1.0-beta.42): until then the two one-target rows logged their
|
||||
// symbol and every other row logged the word "hook", so a log could not say WHICH of four ffx modules was patched.
|
||||
bool InstallByFamily(const wchar_t* moduleName, const char* symbol, uint32_t family, const char* name) noexcept {
|
||||
// EQUALITY AGAINST THE COMPOUND CONSTANT, not `& FL_HOOK_UPSCALER_IDENTITY`. A
|
||||
// bit test would bind any future row that happens to include identity to THIS
|
||||
// detour -- which is the neighbour's-body defect this function exists to stop,
|
||||
// and it would arrive silently because the row would still install.
|
||||
if (family == fl::inventory::kFamilyEvaluateFeature) {
|
||||
return InstallRow(moduleName, symbol, family, reinterpret_cast<void*>(&Hook_SlEvaluateFeature),
|
||||
reinterpret_cast<void**>(&g_origSlEvaluateFeature), g_upscalerIdentityLive);
|
||||
reinterpret_cast<void**>(&g_origSlEvaluateFeature), g_upscalerIdentityLive, name);
|
||||
}
|
||||
if (family == static_cast<uint32_t>(fl::FL_HOOK_UPSCALER_PARAMS)) {
|
||||
// TWO ROWS IN THIS FAMILY WITH DIFFERENT SIGNATURES, so the family alone would
|
||||
@@ -2304,7 +2429,7 @@ bool InstallByFamily(const wchar_t* moduleName, const char* symbol, uint32_t fam
|
||||
frameRow ? reinterpret_cast<void*>(&Hook_SlSetTagForFrame) : reinterpret_cast<void*>(&Hook_SlSetTag);
|
||||
void** original =
|
||||
frameRow ? reinterpret_cast<void**>(&g_origSlSetTagForFrame) : reinterpret_cast<void**>(&g_origSlSetTag);
|
||||
if (!PatchTarget(target, detour, original)) {
|
||||
if (!PatchTarget(target, detour, original, name)) {
|
||||
return false;
|
||||
}
|
||||
patched.store(1, std::memory_order_release);
|
||||
@@ -2312,7 +2437,7 @@ bool InstallByFamily(const wchar_t* moduleName, const char* symbol, uint32_t fam
|
||||
}
|
||||
if (family == static_cast<uint32_t>(fl::FL_HOOK_FG_EVALUATIONS)) {
|
||||
return InstallRow(moduleName, symbol, family, reinterpret_cast<void*>(&Hook_SlGetNewFrameToken),
|
||||
reinterpret_cast<void**>(&g_origSlGetNewFrameToken), g_frameTokensLive);
|
||||
reinterpret_cast<void**>(&g_origSlGetNewFrameToken), g_frameTokensLive, name);
|
||||
}
|
||||
if (family == fl::inventory::kFamilyFfxDispatch) {
|
||||
// FOUR ROWS, ONE ARM: the row's MODULE picks the trampoline and the latch slot,
|
||||
@@ -2345,7 +2470,7 @@ bool InstallByFamily(const wchar_t* moduleName, const char* symbol, uint32_t fam
|
||||
return false; // not loaded, or a module of the name that does not speak the 3.0 host ABI
|
||||
}
|
||||
if (!PatchTarget(target, reinterpret_cast<void*>(&Hook_FfxFsr3ContextDispatchUpscale),
|
||||
reinterpret_cast<void**>(&g_origFfxFsr3DispatchUpscale))) {
|
||||
reinterpret_cast<void**>(&g_origFfxFsr3DispatchUpscale), name)) {
|
||||
return false;
|
||||
}
|
||||
g_fsr3HostPatched.store(1, std::memory_order_release);
|
||||
@@ -2359,7 +2484,7 @@ bool InstallByFamily(const wchar_t* moduleName, const char* symbol, uint32_t fam
|
||||
if (target == nullptr) {
|
||||
return false; // not loaded, or a module of the name that does not speak ffx-api
|
||||
}
|
||||
if (!PatchTarget(target, FfxDispatchDetour(slot), reinterpret_cast<void**>(&g_origFfxDispatch[slot]))) {
|
||||
if (!PatchTarget(target, FfxDispatchDetour(slot), reinterpret_cast<void**>(&g_origFfxDispatch[slot]), name)) {
|
||||
return false;
|
||||
}
|
||||
g_ffxPatched[slot].store(1, std::memory_order_release);
|
||||
@@ -2380,7 +2505,7 @@ bool InstallByFamily(const wchar_t* moduleName, const char* symbol, uint32_t fam
|
||||
if (target == nullptr) {
|
||||
return false; // not loaded, or a module of the name that does not speak ffx-api
|
||||
}
|
||||
if (!PatchTarget(target, FfxQueryDetour(slot), reinterpret_cast<void**>(&g_origFfxQuery[slot]))) {
|
||||
if (!PatchTarget(target, FfxQueryDetour(slot), reinterpret_cast<void**>(&g_origFfxQuery[slot]), name)) {
|
||||
return false;
|
||||
}
|
||||
g_ffxQueryPatched[slot].store(1, std::memory_order_release);
|
||||
@@ -2480,7 +2605,11 @@ void PublishParamsFamilyIfWhole() noexcept {
|
||||
|
||||
bool InstallUpscalerHooks() noexcept {
|
||||
bool any = false;
|
||||
#define FL_INSTALL_ROW(mod, sym, family) any = InstallByFamily(mod, sym, static_cast<uint32_t>(family)) || any;
|
||||
#define FL_INSTALL_ROW(mod, sym, family) \
|
||||
{ \
|
||||
static constexpr fl::inventory::RowName kRowName = fl::inventory::NameOfRow(mod, sym); \
|
||||
any = InstallByFamily(mod, sym, static_cast<uint32_t>(family), kRowName.text) || any; \
|
||||
}
|
||||
FL_HOOK_INVENTORY(FL_INSTALL_ROW)
|
||||
#undef FL_INSTALL_ROW
|
||||
PublishParamsFamilyIfWhole();
|
||||
@@ -2615,13 +2744,15 @@ bool InstallRtHooks() noexcept {
|
||||
|
||||
if (dispatchAgrees && g_rtDispatchLive.load(std::memory_order_acquire) == 0 &&
|
||||
PatchTarget(directVtbl[fl::d3d12::kDispatchRaysIndex], reinterpret_cast<void*>(&Hook_DispatchRays),
|
||||
reinterpret_cast<void**>(&g_origDispatchRays))) {
|
||||
reinterpret_cast<void**>(&g_origDispatchRays),
|
||||
"d3d12!ID3D12GraphicsCommandList4::DispatchRays")) {
|
||||
PublishHookFamily(static_cast<uint32_t>(fl::FL_HOOK_RT_DISPATCH), g_rtDispatchLive);
|
||||
installed = true;
|
||||
}
|
||||
if (buildAgrees && g_rtAsBuildLive.load(std::memory_order_acquire) == 0 &&
|
||||
PatchTarget(directVtbl[fl::d3d12::kBuildRaytracingAccelerationStructureIndex],
|
||||
reinterpret_cast<void*>(&Hook_BuildRtAs), reinterpret_cast<void**>(&g_origBuildRtAs))) {
|
||||
reinterpret_cast<void*>(&Hook_BuildRtAs), reinterpret_cast<void**>(&g_origBuildRtAs),
|
||||
"d3d12!ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure")) {
|
||||
PublishHookFamily(static_cast<uint32_t>(fl::FL_HOOK_RT_AS_BUILD), g_rtAsBuildLive);
|
||||
installed = true;
|
||||
}
|
||||
@@ -2745,6 +2876,11 @@ DWORD WatchdogLoop() noexcept {
|
||||
PublishDxgiPresentCounters();
|
||||
PublishLoaderWords();
|
||||
|
||||
// What the detours kept for the log, then the log itself when this tick -- or a fault in a hook since the
|
||||
// last one -- added to it. BEFORE the supervision check: its healthy branch continues the loop.
|
||||
LogFfxObservations();
|
||||
FlushLogIfNew();
|
||||
|
||||
// Supervision loss. guardTicks counts COMPLETED guard evaluations, not
|
||||
// seconds, so a stalled guard loop stops it advancing even while the
|
||||
// Agent process is alive -- which is exactly the case a timer-driven
|
||||
@@ -3544,20 +3680,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 +3799,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 +3831,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
|
||||
@@ -3668,6 +3845,14 @@ DWORD WINAPI InitThread(LPVOID) noexcept {
|
||||
// fatal: the present-path checks still work, and an Overlay that reacts only
|
||||
// while the game presents is strictly better than none. It is recorded in the
|
||||
// fault counter so the Agent can see it rather than inferring it.
|
||||
//
|
||||
// The first flush: init is over, on the init thread, never mid-frame. The
|
||||
// file therefore exists from the start of the session, which is what makes a
|
||||
// crash mid-session diagnosable at all (10_LOGGING). BEFORE THE WATCHDOG
|
||||
// EXISTS since 0.1.0-beta.42: FlushLog's state belongs to one thread at a
|
||||
// time, and the watchdog now flushes on its own first tick -- placed after
|
||||
// CreateThread, as it was, this flush could run beside that one.
|
||||
FlushLog();
|
||||
HANDLE watchdog = CreateThread(nullptr, 0, WatchdogThread, nullptr, 0, nullptr);
|
||||
if (watchdog == nullptr) {
|
||||
std::atomic_ref<uint32_t> faults{g_state->faultCount};
|
||||
@@ -3675,10 +3860,6 @@ DWORD WINAPI InitThread(LPVOID) noexcept {
|
||||
} else {
|
||||
CloseHandle(watchdog); // fire and forget; it exits on its own once stopped
|
||||
}
|
||||
// The first flush: init is over, on the init thread, never mid-frame. The
|
||||
// file therefore exists from the start of the session, which is what makes a
|
||||
// crash mid-session diagnosable at all (10_LOGGING).
|
||||
FlushLog();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,6 +178,15 @@ target_compile_options(fl_unhook_inline_test PRIVATE /EHsc)
|
||||
target_compile_definitions(fl_unhook_inline_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
|
||||
add_test(NAME fl_unhook_inline COMMAND fl_unhook_inline_test)
|
||||
|
||||
# fl_ffx_types.h (0.1.0-beta.42, D121): the descriptor types an ffx-api module was handed, kept by the detours for
|
||||
# the native log. The header the Overlay compiles, driven without the Overlay -- including from eight threads.
|
||||
add_executable(fl_ffx_types_test ffx_types_test.cpp)
|
||||
target_include_directories(fl_ffx_types_test PRIVATE "${CMAKE_SOURCE_DIR}/FrameLedger.Overlay/include")
|
||||
target_link_libraries(fl_ffx_types_test PRIVATE fl_native_flags Catch2::Catch2WithMain)
|
||||
target_compile_options(fl_ffx_types_test PRIVATE /EHsc)
|
||||
target_compile_definitions(fl_ffx_types_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
|
||||
add_test(NAME fl_ffx_types COMMAND fl_ffx_types_test)
|
||||
|
||||
add_test(NAME fl_vklayer COMMAND fl_vklayer_test "[vklayer]")
|
||||
add_test(NAME fl_vklayer_supervision COMMAND fl_vklayer_test "[vklayer-deadline]")
|
||||
# The real-loader leg SKIPS (Catch2 exit 4) where there is no Vulkan loader or no
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
// fl_ffx_types.h: the descriptor types an ffx-api module was handed, kept by the
|
||||
// detours and written to the native log by the watchdog (0.1.0-beta.42, D121).
|
||||
// The header is what the Overlay compiles, so these cases are about the shipped
|
||||
// code: each type once, in the order it arrived, nothing lost when two threads
|
||||
// meet a new type at the same moment, and what does not fit SAID rather than
|
||||
// dropped.
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <cstdint>
|
||||
#include <fl_ffx_types.h>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
|
||||
std::vector<std::uint64_t> Kept(const fl::ffxtypes::Seen& seen) {
|
||||
std::vector<std::uint64_t> out;
|
||||
for (const auto& slot : seen.types) {
|
||||
if (const std::uint64_t v = slot.load(); v != 0u) {
|
||||
out.push_back(v);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("a type is kept once, in the order it first arrived", "[ffxtypes]") {
|
||||
fl::ffxtypes::Seen seen;
|
||||
for (int frame = 0; frame < 1000; ++frame) {
|
||||
fl::ffxtypes::Note(seen, 0x00020004u); // PREPARE
|
||||
fl::ffxtypes::Note(seen, 0x00020003u); // FRAMEGENERATION
|
||||
if (frame >= 10) {
|
||||
fl::ffxtypes::Note(seen, 0x00010001u); // UPSCALE, from the eleventh frame on
|
||||
}
|
||||
}
|
||||
const std::vector<std::uint64_t> expected{0x00020004u, 0x00020003u, 0x00010001u};
|
||||
CHECK(Kept(seen) == expected);
|
||||
CHECK(seen.more.load() == 0u);
|
||||
}
|
||||
|
||||
TEST_CASE("what does not fit is said: a ninth type, and a type of zero", "[ffxtypes]") {
|
||||
fl::ffxtypes::Seen seen;
|
||||
for (std::uint64_t type = 1; type <= fl::ffxtypes::kSlots; ++type) {
|
||||
fl::ffxtypes::Note(seen, type);
|
||||
}
|
||||
CHECK(Kept(seen).size() == fl::ffxtypes::kSlots);
|
||||
CHECK(seen.more.load() == 0u);
|
||||
|
||||
fl::ffxtypes::Note(seen, 3u); // already kept: still nothing to say
|
||||
CHECK(seen.more.load() == 0u);
|
||||
|
||||
fl::ffxtypes::Note(seen, 99u);
|
||||
CHECK(seen.more.load() == fl::ffxtypes::kMoreTypes);
|
||||
CHECK(Kept(seen).size() == fl::ffxtypes::kSlots); // and none of the eight was displaced
|
||||
|
||||
fl::ffxtypes::Note(seen, 0u);
|
||||
const std::uint32_t both = fl::ffxtypes::kMoreTypes | fl::ffxtypes::kMoreZero;
|
||||
CHECK(seen.more.load() == both);
|
||||
|
||||
fl::ffxtypes::Seen zeroOnly;
|
||||
fl::ffxtypes::Note(zeroOnly, 0u);
|
||||
CHECK(Kept(zeroOnly).empty()); // zero is the empty slot: it takes none
|
||||
CHECK(zeroOnly.more.load() == fl::ffxtypes::kMoreZero);
|
||||
}
|
||||
|
||||
TEST_CASE("the watchdog's report: each kept type once, new ones on a later pass, the rest untouched", "[ffxtypes]") {
|
||||
fl::ffxtypes::Seen seen;
|
||||
fl::ffxtypes::Reported reported;
|
||||
std::vector<std::uint64_t> types;
|
||||
std::vector<std::uint32_t> more;
|
||||
const auto report = [&] {
|
||||
fl::ffxtypes::ReportNew(
|
||||
seen, reported, [&types](std::uint64_t t) noexcept { types.push_back(t); },
|
||||
[&more](std::uint32_t m) noexcept { more.push_back(m); });
|
||||
};
|
||||
|
||||
report();
|
||||
CHECK(types.empty());
|
||||
CHECK(more.empty());
|
||||
|
||||
fl::ffxtypes::Note(seen, 0x20004u);
|
||||
fl::ffxtypes::Note(seen, 0x20003u);
|
||||
report();
|
||||
report(); // nothing new: nothing said again
|
||||
const std::vector<std::uint64_t> firstTwo{0x20004u, 0x20003u};
|
||||
CHECK(types == firstTwo);
|
||||
|
||||
fl::ffxtypes::Note(seen, 0x10001u);
|
||||
fl::ffxtypes::Note(seen, 0u);
|
||||
report();
|
||||
const std::vector<std::uint64_t> allThree{0x20004u, 0x20003u, 0x10001u};
|
||||
CHECK(types == allThree);
|
||||
const std::vector<std::uint32_t> zeroSaid{fl::ffxtypes::kMoreZero};
|
||||
CHECK(more == zeroSaid);
|
||||
|
||||
for (std::uint64_t t = 100; t < 110; ++t) {
|
||||
fl::ffxtypes::Note(seen, t);
|
||||
}
|
||||
report();
|
||||
report();
|
||||
CHECK(types.size() == fl::ffxtypes::kSlots);
|
||||
const std::vector<std::uint32_t> bothSaid{fl::ffxtypes::kMoreZero, fl::ffxtypes::kMoreTypes};
|
||||
CHECK(more == bothSaid);
|
||||
}
|
||||
|
||||
TEST_CASE("threads that meet the same new types at once keep each exactly once", "[ffxtypes]") {
|
||||
// The detours run on whatever threads the game dispatches from. Six types, eight threads, each noting all six in
|
||||
// its own order, many times over: six slots filled, no type twice, none lost, nothing said to be missing.
|
||||
for (int round = 0; round < 200; ++round) {
|
||||
fl::ffxtypes::Seen seen;
|
||||
std::vector<std::thread> threads;
|
||||
for (int t = 0; t < 8; ++t) {
|
||||
threads.emplace_back([&seen, t] {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
fl::ffxtypes::Note(seen, 0x10000u + static_cast<std::uint64_t>((i + t) % 6) + 1u);
|
||||
}
|
||||
});
|
||||
}
|
||||
for (std::thread& th : threads) {
|
||||
th.join();
|
||||
}
|
||||
std::vector<std::uint64_t> kept = Kept(seen);
|
||||
REQUIRE(kept.size() == 6u);
|
||||
std::uint64_t sum = 0;
|
||||
for (std::size_t i = 0; i < kept.size(); ++i) {
|
||||
sum += kept[i] - 0x10000u;
|
||||
for (std::size_t j = i + 1; j < kept.size(); ++j) {
|
||||
REQUIRE(kept[i] != kept[j]);
|
||||
}
|
||||
}
|
||||
REQUIRE(sum == 21u); // 1 + 2 + ... + 6: every one of the six, once
|
||||
REQUIRE(seen.more.load() == 0u);
|
||||
}
|
||||
}
|
||||
@@ -5985,6 +5985,117 @@ TEST_CASE("the FSR 3.0 host facade: Fsr3 identity and the count from its upscale
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// Whether the log has a line of this code whose text starts with `name` and which ends in `tail`.
|
||||
bool LogHasLine(const std::string& text, const char* code, const char* name, const char* tail) {
|
||||
const std::string head = std::string("s ") + code + " ";
|
||||
std::size_t at = 0;
|
||||
while (at < text.size()) {
|
||||
std::size_t end = text.find('\n', at);
|
||||
if (end == std::string::npos) {
|
||||
end = text.size();
|
||||
}
|
||||
const std::string line = text.substr(at, end - at);
|
||||
const std::size_t h = line.find(head);
|
||||
if (h != std::string::npos) {
|
||||
std::size_t n = h + head.size();
|
||||
while (n < line.size() && line[n] == ' ') {
|
||||
++n;
|
||||
}
|
||||
const std::string tailText = tail;
|
||||
if (line.compare(n, std::strlen(name), name) == 0 && line.size() >= tailText.size() &&
|
||||
line.compare(line.size() - tailText.size(), tailText.size(), tailText) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
at = end + 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::size_t CountOf(const std::string& text, const char* needle) {
|
||||
std::size_t n = 0;
|
||||
for (std::size_t at = text.find(needle); at != std::string::npos; at = text.find(needle, at + 1)) {
|
||||
++n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("the native log outlives a game that just exits (beta.42, D121): the watchdog writes it unasked -- installs "
|
||||
"by module and symbol, the descriptor types each ffx module was handed, the census",
|
||||
"[guard][inject][shm][ffx][log]") {
|
||||
// WHAT A REAL SESSION LOOKED LIKE UNTIL NOW. The log was written at the end of init, when the Agent asked, and on
|
||||
// a stop. A game that exits asks for nothing and stops nothing: the file held the first half second -- before
|
||||
// the title had loaded its upscaler -- and Cyberpunk 2077's "unknown" upscaler (FSR set, frame generation
|
||||
// measured) could not be read back from anywhere. Here nobody asks and nothing stops; the process is then killed.
|
||||
Child child;
|
||||
REQUIRE(StartHarness(
|
||||
child, L"--real --presents-per-eval 4 --ffx-topology 1x --ffx-query ratios --hold-presenting-ffx 14"));
|
||||
|
||||
ResetFake();
|
||||
g.modules = {"kernel32.dll"};
|
||||
g.scanSet = {child.pi.dwProcessId};
|
||||
REQUIRE(GuardedInjectWithSources(child.pi.dwProcessId, FL_OVERLAY_DLL, FakeSources()).Allowed());
|
||||
|
||||
MappedRing r;
|
||||
REQUIRE(OpenRingFor(child.pi.dwProcessId, r));
|
||||
|
||||
// The monolith's three dispatch types of an SDK 1.1.x title generating frames, and the ratio query, by value:
|
||||
// UPSCALE 0x10001, FRAMEGENERATION_PREPARE 0x20004, FRAMEGENERATION 0x20003, GETUPSCALERATIOFROMQUALITYMODE
|
||||
// 0x10002 (the vendored ffx_upscale.h / ffx_framegeneration.h).
|
||||
const char* mono = "amd_fidelityfx_dx12.dll";
|
||||
std::wstring log;
|
||||
std::string text;
|
||||
bool complete = false;
|
||||
for (int i = 0; i < 150 && !complete; ++i) {
|
||||
++r.ctl->guardTicks; // supervised, as a session is -- and that is ALL this test tells the Overlay
|
||||
Sleep(100);
|
||||
if (log.empty() && !FindOverlayLog(child.pi.dwProcessId, child.pi.hProcess, log)) {
|
||||
continue;
|
||||
}
|
||||
text = ReadWholeFile(log);
|
||||
complete = LogHasLine(text, "FFX_DISPATCH", mono, " b=0x10001") &&
|
||||
LogHasLine(text, "FFX_DISPATCH", mono, " b=0x20004") &&
|
||||
LogHasLine(text, "FFX_DISPATCH", mono, " b=0x20003") &&
|
||||
LogHasLine(text, "FFX_QUERY", mono, " b=0x10002") &&
|
||||
LogHasLine(text, "UPSCALE_ROUTE", mono, " a=1 b=0x0");
|
||||
}
|
||||
INFO("log " << Narrow(log) << ":\n" << text);
|
||||
REQUIRE(complete);
|
||||
CHECK(r.ctl->logFlushRequested == 0u);
|
||||
CHECK(r.ctl->unhookRequested == 0u);
|
||||
CHECK(r.st->status == fl::FL_STATUS_READY);
|
||||
CHECK(r.st->faultCount == 0u);
|
||||
|
||||
// The game exits. No stop, no last flush, no watchdog left to make one.
|
||||
REQUIRE(TerminateProcess(child.pi.hProcess, 0));
|
||||
WaitForSingleObject(child.pi.hProcess, 5000);
|
||||
text = ReadWholeFile(log);
|
||||
INFO("after the exit:\n" << text);
|
||||
|
||||
CHECK(CountOf(text, "# FrameLedger.Overlay build ") == 1u); // one file, one header, however many flushes
|
||||
CHECK(CountOf(text, "RING_CREATED") == 1u);
|
||||
// Every row that went in says which module and which symbol -- these two read "hook" until now.
|
||||
CHECK(LogHasLine(text, "HOOK_INSTALLED", "amd_fidelityfx_dx12.dll!ffxDispatch", ""));
|
||||
CHECK(LogHasLine(text, "HOOK_INSTALLED", "amd_fidelityfx_dx12.dll!ffxQuery", ""));
|
||||
CHECK(text.find(" hook ") == std::string::npos);
|
||||
// Each type once, however many thousand dispatches carried it.
|
||||
CHECK(CountOf(text, "FFX_DISPATCH") == 3u);
|
||||
CHECK(CountOf(text, "FFX_QUERY") == 1u);
|
||||
CHECK(CountOf(text, "UPSCALE_ROUTE") == 1u);
|
||||
// The census, with the monolith's bit in the word it carries.
|
||||
CHECK(text.find("RUNTIME_CENSUS") != std::string::npos);
|
||||
// And nothing that did not happen.
|
||||
CHECK(text.find(" STOP ") == std::string::npos);
|
||||
CHECK(text.find("STOP_FLUSHED") == std::string::npos);
|
||||
CHECK(text.find("PATCH_FAILED") == std::string::npos);
|
||||
CHECK(text.find("FAULT") == std::string::npos);
|
||||
CHECK(text.find("overwritten before") == std::string::npos);
|
||||
}
|
||||
|
||||
TEST_CASE("FSR's quality mode (beta.25, D65): the mode the title asked for names the dispatch, by its size and by "
|
||||
"its ratio",
|
||||
"[guard][inject][shm][ffx]") {
|
||||
|
||||
@@ -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").
|
||||
|
||||
@@ -33,6 +33,8 @@ public sealed class OverlayLogTests : IDisposable
|
||||
"# FrameLedger.Overlay build abc pid 4242 layout v3 image game.exe",
|
||||
"+ 0.001s RING_CREATED Local\\FrameLedger.Ring.<pid> a=8192 b=0x0",
|
||||
"+ 0.020s HOOK_INSTALLED dxgi!IDXGISwapChain::Present a=0 b=0x7ff0",
|
||||
"+ 1.020s PATCH_FAILED amd_fidelityfx_dx12.dll!ffxDispatch a=4 b=0x7ff8",
|
||||
"+ 2.020s FFX_DISPATCH amd_fidelityfx_dx12.dll a=0 b=0x10001",
|
||||
"+ 3.400s FAULT Hook_Present a=3221225477 b=0x0",
|
||||
"+ 9.000s STOP observing stopped a=3 b=0x0",
|
||||
"+ 9.001s UNHOOK_RESTORED dxgi!IDXGISwapChain::Present a=1 b=0x7ff0",
|
||||
@@ -44,12 +46,13 @@ public sealed class OverlayLogTests : IDisposable
|
||||
OverlayLog.Find(4242, _dir).Should().Be(newer);
|
||||
List<string> lines = [.. OverlayLog.Describe(4242, _dir)];
|
||||
|
||||
lines[0].Should().Contain(newer).And.Contain("(6 event(s))");
|
||||
lines.Should().HaveCount(5, "the header, then FAULT, STOP and the two unhook decisions; the installs stay in the file");
|
||||
lines[1].Should().Contain("FAULT");
|
||||
lines[2].Should().Contain("STOP");
|
||||
lines[3].Should().Contain("UNHOOK_RESTORED");
|
||||
lines[4].Should().Contain("UNHOOK_DECLINED");
|
||||
lines[0].Should().Contain(newer).And.Contain("(8 event(s))");
|
||||
lines.Should().HaveCount(6, "the header, then the patch that failed, FAULT, STOP and the two unhook decisions; the installs and what was seen stay in the file");
|
||||
lines[1].Should().Contain("PATCH_FAILED");
|
||||
lines[2].Should().Contain("FAULT");
|
||||
lines[3].Should().Contain("STOP");
|
||||
lines[4].Should().Contain("UNHOOK_RESTORED");
|
||||
lines[5].Should().Contain("UNHOOK_DECLINED");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user