Compare commits

...
Author SHA1 Message Date
poli0981andClaude Fable 5.2 d4b501df87 feat(overlay): hook ffxConfigure on the four ffx-api modules - how a game configures FSR frame generation, read only while the Agent asks and patched only once it has; never the swapchain, the callbacks, the HUD-less resource or the frame id (beta.43 PR-3)
Four inventory rows, family FL_HOOK_FFX_CONFIGURE (bit 14), installed only in a process asked for Advanced metrics at least once and published when every loaded ffx-api module is patched. fl_adv_fields.h reads frameGenerationEnabled, allowAsyncWorkloads, flags, onlyPresentGenerated and generationRect of a frame-generation configuration into region 5's ffxFg group, counted at the first module that saw one; the rectangle is kept in one word so it cannot tear, and one that does not fit is four -1. Every configure type is kept for the log (FFX_CONFIGURE). tools/overlay-fields-check.ps1 gains the parameter g and five list entries.

Measured on the headers with the Overlay's flags: +1.7 ns not asked, +15.2 ns on the counted module, +2.7 ns on the forwarded copy.

The test's 'is this export patched' compares the target's bytes with the file's own.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 12:48:55 +07:00
14 changed files with 510 additions and 27 deletions

No files matched your search

+8
View File
@@ -37,6 +37,14 @@ numeric core and does not move; the heading is the full version — corrected 20
### Added
- **Advanced metrics, inside the game: how the game configures FSR frame generation** (the part inside the game;
what a session shows of it comes with the same release). With **Advanced metrics** on, FrameLedger now also
reads, from the call a game makes to configure AMD's frame generation, whether generation is on, whether it may
run asynchronously, its flags, whether only generated frames are presented, and the part of the picture it
generates in. Nothing else of that call is read. Like the Streamline hook, this one is put into a game only once
Advanced metrics has been asked for. Measured cost: about 15 billionths of a second per call while the option is
on, under 2 while it is off.
- **Advanced metrics, inside the game: what the game tells NVIDIA Streamline about each frame** (the part inside the
game; what a session shows of it comes with the same release). With **Advanced metrics** on, FrameLedger now also
reads, from a call a Streamline game makes every frame, the size of the jitter, the motion-vector scale, the depth
+6
View File
@@ -139,6 +139,12 @@ What the region is, as a contract between the two sides:
jitter's largest magnitude, the motion-vector scale, the two depth planes, the field of view's range, the aspect
ratio, and one bit per `Boolean` in each of two words — seen true, seen false. `FlHookFamily` gains
`FL_HOOK_SL_CONSTANTS` (bit 13): the hook is in, which it is only in a process that was asked at least once.
**The `ffxFg*` group is filled since the same release** by the `ffxConfigure` hook, under
`FL_ADV_VALID_FFX_FG_CONFIG`: the frame-generation configures of the one module counted, three switches as "seen
off / seen on" bit pairs (enabled, asynchronous, generated frames only), every flag any configure carried, and
the last generation rectangle as left, top, width, height — **four `-1` for a rectangle with a negative side or
one past 32,767**, never a clipped one. `FL_HOOK_FFX_CONFIGURE` (bit 14) is published when every ffx-api module
the process loaded has its `ffxConfigure` patched.
- The Vulkan layer never writes it. `ShmLayoutMirrorTests.TheAdvancedStateMirrorMatches` checks every member's
offset against `fl-layout-dump`; `ShmRingReaderTests` the three reads and that the request is stored either way.
+4 -1
View File
@@ -201,6 +201,7 @@ Every hook must be listed here with a purpose. Anything not on this list is not
| ✅ **FidelityFX ffx-api: `ffxDispatch` on the FOUR modules a game calls** — `amd_fidelityfx_dx12.dll` (SDK 1.1.x monolith), `amd_fidelityfx_upscaler_dx12.dll`, `amd_fidelityfx_framegeneration_dx12.dll`, **and `amd_fidelityfx_loader_dx12.dll`** (added the evening of 2026-09-04: three loader-shipping titles at FSR produced zero dispatches at any leaf export, so the loader is where their calls arrive) · ⏳ FSR 3.0 host route `ffx_fsr3_x64.dll!ffxFsr3ContextDispatchUpscale` / `ffxFsr3DispatchFrameGeneration` · ~~`ffxFsr2ContextCreate`~~ · ~~`ffxCreateContext`~~ | **Built 2026-09-04** (`HANDOFF` item 7c). One observer behind three trampolines reads the DESCRIPTOR the title passed — head type first, body only after the type matched a constant from the vendored MIT headers (`third_party/fidelityfx/`, tag v2.3.0): **UPSCALE** → identity (`FSR3` from the monolith, `FSR_UNVERSIONED` from the 2.x upscaler DLL, which hosts FSR 3.1 and FSR 4 behind one type) + `renderSize` → `renderW/H` (quality and sharpness `0xFF`: the dispatch carries neither — *since beta.25 the quality byte is the mode the `ffxQuery` row below names for the dispatched size, `0xFF` when none does*) + one COUNT *(since 0.1.0-beta.43, owner decision D125: **counted at the first source that saw an UPSCALE and at no other** — `g_ffxUpscaleOwner`, `fl::adv::Owns`. Cyberpunk 2077's loader 2.3.0 hands a dispatch on to the leaf's export — its frame-generation dispatch types are logged on the loader and on the leaf — so an UPSCALE through such a loader reaches two hooked modules, and one count per module read K = 1 as 2.0 on the fixture bound that way (`--ffx-topology 2x-export`: 60 presents, 120 counted). No title run so far upscales through one; it is a precaution. Measured on the header with the Overlay's flags: +0.02 to +0.03 ns on the module that is counted, about 4 ns less on the forwarded copy)*; **PREPARE / PREPARE_V2** → `frameID` counted on a *new* index only — this vendor's `slGetNewFrameToken`, the `fgEvaluations` producer once a title has ever prepared, with the UPSCALE count as the fallback for a title that never does; **FRAMEGENERATION** → `fgMode = FSR_FG` on that present. Rule 4: the argument of the API we hooked, never `context`, `pNext`, a command list or a resource. **Why all four:** a UE5 title ships the two leaves with no loader and calls their exports; a loader-shipping title calls the loader's export and the signed loader reaches its providers through an object, not the leaves' exports (measured: Dying Light: The Beast, KCD2, Wukong). The morning's "never the loader" rested on the export tables alone and was reversed by the run. What guards against a loader that DID re-enter a leaf's export is the K = 1 control with all four hooked and the consumer's `frames/upscale-drained`, both of which read 2× in that case. `ffxCreateContext` is deliberately NOT a row — nothing it carries fills a field the dispatch does not, and its honest family would collide with `slEvaluateFeature`'s under the installer's equality binding. The family is compound (`IDENTITY \| PARAMS \| FG_EVALUATIONS`), pinned by `static_assert`s that also bind the leaf table to the rows both ways and refuse the loader as a row. Streamline keeps precedence for the count once it has ever issued a token, so every §S31-validated title is byte-identical. Second count: the consumer prints `frames/upscale-drained`, the AMD `tokens/batch`. **FSR 3.0 — BUILT 2026-09-05 as a fifth AMD target:** `ffx_fsr3_x64.dll!ffxFsr3ContextDispatchUpscale` (Cyberpunk's copy; named export, its own descriptor, vendored from tag **`fsr3-v3.0.4`** — the tag whose twelve `ffxFsr3*` declarations match the shipped module, not the `v1.1.4` first named). Rule 4: the detour reads `renderSize` of the descriptor the title passed and nothing else — never the context, a resource or the command list; the offset is pinned to a literal (1256) so a re-vendoring that moved it fails to compile. Same family and publish point as the four rows (`PublishFfxFamilyIfWhole` waits for a loaded host too), keyed by module in the installer; identity `FSR3` as a fact. `ffxFsr3DispatchFrameGeneration` is deliberately not a row (§H11 carries the reversal condition); the `ffx_fsr3upscaler_x64.dll` leaf is the pre-committed alternative if the facade reads silent (row B2) — never both, or `frames/upscale-drained` reads 2.00. **Since 0.1.0-beta.40 (Advanced metrics train B, D111), and only while the Agent asks:** the UPSCALE arm reads the rest of `ffxDispatchDescUpscale` — `enableSharpening`, `sharpness`, `jitterOffset`, `preExposure`, `cameraNear`, `cameraFar`, `cameraFovAngleVertical`, `flags`, `reset`, `frameTimeDelta` — into process-local summaries (an "ever seen" mask, a largest magnitude, a lowest and highest, a count and a sum; one module's dispatches are counted, so a dispatch that reaches the loader and a leaf is one). Never on the FSR 3.0 host's legacy descriptor, which is vouched Line truncated
| ✅ **FidelityFX ffx-api: `ffxQuery` on the same four modules** (beta.25, owner decision D65) — `amd_fidelityfx_dx12.dll`, `amd_fidelityfx_upscaler_dx12.dll`, `amd_fidelityfx_framegeneration_dx12.dll`, `amd_fidelityfx_loader_dx12.dll` | **Built 2026-10-19.** The mode an FSR title runs at reaches the vendor only as an argument of `ffxQuery` — "what render size (`…GETRENDERRESOLUTIONFROMQUALITYMODE`, `0x00010003`) or ratio (`…GETUPSCALERATIOFROMQUALITYMODE`, `0x00010002`) does this mode give at this display size?" — asked before the title sizes its targets; the per-frame dispatch carries the size alone. The detour calls the original FIRST, exactly once, and only when it returned `FFX_API_RETURN_OK` reads the descriptor's type, display size and mode and the values the vendor wrote through the title's own out pointers, into a five-slot table (one per `FfxApiUpscaleQualityMode`); the `ffxDispatch` UPSCALE arm names the ONE mode whose kept answer fits the dispatched `renderSize` (and `upscaleSize`, where stated) as `0x10 + mode` in `upscalerQuality`, else `0xFF` (`03_METRICS` §Upscaling). **Rule 4:** the arguments of the API we hooked — the descriptor the title passed and the out values of that same call — never `context`, a resource or anything the title did not hand the hooked export; nothing of the title's is written, and every read is under the hook's SEH guard. Both query layouts and type ids are pinned to literals by `static_assert`s, identical at SDK v1.1.4 and v2.3.0. **Its own family**, `FL_HOOK_UPSCALER_QUALITY` (bit 11 of `hooksInstalledMask`, mirrored in `FlHookFamily` and `HookFamilies`): `InstallByFamily` binds a row by equality, and the query entitles no measured field by itself — the byte rides under `FL_MEASURED_UPSCALER_PARAMS` from the dispatch arm — so the bit says only that the query was hooked, which tells "never asked" from "could not have seen it ask". Published like the dispatch family, once every loaded leaf is patched (`PublishFfxQueryFamilyIfWhole`); the FSR 3.0 host has no `ffxQuery` and no row (`static_assert`). A loader that passes a query on to a leaf's export refreshes one kept answer twice; nothing is counted, so nothing is counted twice. **Measured overhead** (a copy of the two bodies, `/O2 /guard:cf /Qspectre /MT`, 20 M calls × 3 runs, every slot holding both a size and a ratio — the worst case): 7.6–8.2 ns added per UPSCALE dispatch, i.e. per application frame, and 1.6 ns per query beside the trampoline; the per-present path gains one load. Harness: `--ffx-query sizes|ratios`; `fl_guard` "FSR's quality mode". **Since 0.1.0-beta.40 (Advanced metrics train B, D111), and only while the Agent asks:** when the query the vendor answered OK is the upscaler's memory — `FFX_API_QUERY_DESC_TYPE_UPSCALE_GPU_MEMORY_USAGE` (`0x00010008`, ffx-api 1.1.2) or `…_V2` (`0x00010009`, 2.0) — the `FfxApiEffectMemoryUsage` it wrote through the title's own out-pointer is kept (total and aliasable bytes), one module's queries counted. Only a title that asks is answered: FrameLedger never calls `ffxQuery` itself. The frame-generation memory queries (`0x00020007`, `0x0002000b`) are not read. +4.3–6.1 ns per such query while asked. Harness: `--ffx-memory-query v1|v2`; `fl_guard` "region 5 stays empty until the Agent asks". |
| ~~XeSS: `xessD3D12CreateContext`, `xessD3D12Init`, `xessD3D12Execute`~~ **Closed at the census by licence, 2026-09-04** (`20_OPEN_QUESTIONS` §Scope decisions, `18_GPU_VENDOR_APIS` §Intel XeSS SDK): no hook on any `libxess*.dll` export *(corrected 2026-10-04)* | ~~`outputResolution`, `qualitySetting`, XeSS version; `xess_fg` variants for XeFG~~ |
| ✅ **FidelityFX ffx-api: `ffxConfigure` on the same four modules** (0.1.0-beta.43, Advanced metrics train B; owner decisions D111–D116, D122) | **How the game configures FSR frame generation** — a title calls `ffxConfigure` with a frame-generation descriptor, usually every frame. Rule 4: an argument of the call hooked, and of it only what is named here. **Read**, and only when the header's type is `FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION` (`0x20002`): `frameGenerationEnabled`, `allowAsyncWorkloads`, `flags`, `onlyPresentGenerated`, `generationRect`. **Never read:** `swapChain`, the two callbacks and their contexts, `HUDLessColor`, `frameID`; and of every other configure type — key-value pairs, the distortion field, the camera info — nothing but the header's type. ctest `fl_adv_fields` publishes two descriptors that differ in all of those and gets the same bytes out, and hands the detour a key-value descriptor, which is shorter, without a read past it. **Installed only where asked for** (D111), as `slSetConstants` is: `InstallByFamily` returns before it resolves anything in a process never asked for Advanced metrics, so with the option off the export's first bytes in the target are the file's (`fl_guard` `[advanced]`). Published when every ffx-api module the process loaded is patched (`FL_HOOK_FFX_CONFIGURE`, bit 14), as the dispatch and query families are. **Counted at the first module that saw a frame-generation configure** — an owner slot of its own: the fixture's loader has always handed `ffxConfigure` on to the leaf's export, and Cyberpunk 2077's loader does the same with dispatches, so one call reaches two hooked modules (the injected case reads one configure a frame through the loader, not two). The rectangle is stored in one word, sixteen bits a side, so a publication never carries half of one rectangle beside half of the next; a side that is negative or past fifteen bits makes it four `-1`. The descriptor's type is kept for the log whatever it is (`FFX_CONFIGURE`, §Native logging). The detour consults `MayObserve()` first. **Measured overhead** (the detour's body on the headers, the Overlay's flags, 20 million calls a run, three runs): not asked **+1.72 / +1.68 / +1.78 ns** (the type kept for the log); asked, the counted module **+15.02 / +15.55 / +15.11 ns**; asked, the forwarded copy +2.70 / +2.81 / +2.65 ns; asked, another configure type +2.43 / +2.55 / +2.47 ns. |
| ✅ **Application frames per present** (`fgEvaluations`) — **`sl.interposer.dll!slGetNewFrameToken` since 2026-09-03** | Native vs Displayed frame counts at Tier 1 — see `03_METRICS` §Frame Generation. **The producer is the frame-token export**: Streamline hands a title one token per application frame and the title must ask; the detour counts distinct tokens between two presents (pointer changes, nothing dereferenced), `FL_HOOK_FG_EVALUATIONS` is its family, and it installs on every Streamline 2 title including the ones that evaluate nothing through `slEvaluateFeature`. Rule 4: the out-parameter of an API we hooked. Premise and its gate in `03_METRICS`; pre-committed table in `20_OPEN_QUESTIONS` §S31. *The row as it stood before:* ~~NGX/SL/FFX/XeSS FG feature evaluations per present. **Built 2026-08-15 for Streamline, and MEASURED TO YIELD NOTHING ON THAT ROUTE**~~ — `slEvaluateFeature(kFeatureDLSS_G)` is never called by Cyberpunk 2077 (0 across ~14,000 batches, four FG settings), so this row installs, is honest, and counts zero; see `docs/HANDOFF.md` item 3. Built on the detour that was already there: `kFeatureDLSS_G` contributes to a saturating COUNT in the same word the feature bits live in (`fl_sl_seen.h`) rather than to a bit, because a bit collapses several evaluations between two presents into one — and under multi-frame generation that is the common case, not the edge. The row's family is therefore compound (`FL_HOOK_UPSCALER_IDENTITY \| FL_HOOK_FG_EVALUATIONS`), pinned by a `static_assert` because `hookinventory-check` reads that column as an opaque identifier. **Counts EVALUATIONS, not generated frames** — the 2026-08-14 owner ruling; the multiplier lives in `sl::DLSSGOptions`, which is only reachable by the route §2b refused. ~~Non-NVIDIA FG vendors are **deferred with a written rationale**: `amd_fidelityfx_framegeneration_dx12.dll` 3.1.5 exports only the five generic `ffx*` entry points, identical to five sibling modules, so identity is in the arguments and we have no headers~~ — **AMD has a producer since 2026-09-04** (the FidelityFX row above: the PREPARE dispatch's `frameID`, or the UPSCALE count on a title that never prepares, feeds `fgEvaluations` when Streamline has never issued a token); Intel stays at the census (`20_OPEN_QUESTIONS` §Scope decisions, by licence); the FSR 3.0 host DLL's UPSCALE (`ffxFsr3ContextDispatchUpscale`, since 2026-09-05) counts like an ffx-api UPSCALE when neither Streamline nor a PREPARE has spoken |
> `GetFrameStatistics().PresentCount` is **not** in this inventory and must not be
@@ -792,7 +793,9 @@ No logging in hook bodies. A small fixed-size in-memory ring of structured event
> `FAULT`, `STOP` (the reason), `UNHOOK_RESTORED` / `UNHOOK_DECLINED` (one per patch), `LOADER_DETOUR`,
> `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).
> and `FFX_DISPATCH`, `FFX_QUERY`, `UPSCALE_ROUTE`, `RUNTIME_CENSUS` (the note at the end of this section), and
> since beta.43 `FFX_CONFIGURE` — each configure type a hooked ffx module was handed, in a process where
> `ffxConfigure` is hooked at all (one asked for Advanced metrics).
> **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),
@@ -32,4 +32,7 @@ public enum HookFamilies
/// <summary><c>slSetConstants</c> is hooked (0.1.0-beta.43) - only where Advanced metrics was ever asked for.</summary>
SlConstants = 1 << 13,
/// <summary><c>ffxConfigure</c> is hooked (0.1.0-beta.43) - only where Advanced metrics was ever asked for.</summary>
FfxConfigure = 1 << 14,
}
+6
View File
@@ -286,6 +286,12 @@ public enum FlHookFamily : uint
/// Advanced metrics at least once; it tells "hooked, never called" from "not hooked", and entitles no frame field.
/// </summary>
SlConstants = 1u << 13,
/// <summary>
/// <c>ffxConfigure</c> is hooked on every ffx-api module the process loaded (0.1.0-beta.43). Only in a process that
/// was asked for Advanced metrics at least once; it entitles no frame field.
/// </summary>
FfxConfigure = 1u << 14,
}
/// <summary>
@@ -45,6 +45,7 @@
#include <sl.h>
// After sl.h, as fl_sl_inputs.h explains: sl_dlss.h has no includes of its own.
#include <ffx_api.h>
#include <ffx_framegeneration.h>
#include <ffx_upscale.h>
#include <sl_dlss.h>
@@ -163,6 +164,15 @@ struct Accumulators {
std::atomic<uint32_t> ffxMemoryQueries{0u};
std::atomic<uint32_t> ffxMemoryOwner{0u}; // leaf + 1 of the module whose answered queries are counted
// ffxConfigure with a frame-generation descriptor (0.1.0-beta.43)
std::atomic<uint32_t> ffxFgOwner{0u}; // leaf + 1 of the module whose configures are counted
std::atomic<uint32_t> ffxFgConfigures{0u};
std::atomic<uint32_t> ffxFgEnabledSeen{0u}; // bit 0: seen off; bit 1: seen on
std::atomic<uint32_t> ffxFgAsyncSeen{0u}; // the same two bits
std::atomic<uint32_t> ffxFgOnlyGeneratedSeen{0u}; // the same two bits
std::atomic<uint32_t> ffxFgFlagsSeen{0u};
std::atomic<uint64_t> ffxFgRect{0u}; // PackRect: the last rectangle, in ONE word so it is never half of two
// sl::Constants (0.1.0-beta.43), summarised - from the first viewport seen; the calls count every viewport
std::atomic<uint64_t> slViewport{0u}; // that viewport's id + 1; 0 = none yet
std::atomic<uint32_t> slConstantsCalls{0u};
@@ -323,6 +333,54 @@ inline void ObserveFfxMemoryQuery(uint32_t leaf, const ffxQueryDescHeader* desc,
}
}
// A rectangle in one 64-bit word, sixteen bits a side: left, top, width, height from the lowest. The detour stores
// it with one store and the watchdog reads it with one load, so a publication never carries the left edge of one
// rectangle beside the width of the next. A side that is negative or does not fit in fifteen bits makes the whole
// word kRectUnfit, which Publish writes as four -1: a rectangle nobody can state rather than a clipped one.
inline constexpr uint64_t kRectUnfit = 0xFFFFFFFFFFFFFFFFull;
inline uint64_t PackRect(int32_t left, int32_t top, int32_t width, int32_t height) noexcept {
const auto fits = [](int32_t v) noexcept { return v >= 0 && v <= 0x7FFF; };
if (!fits(left) || !fits(top) || !fits(width) || !fits(height)) {
return kRectUnfit;
}
return static_cast<uint64_t>(left) | (static_cast<uint64_t>(top) << 16) | (static_cast<uint64_t>(width) << 32) |
(static_cast<uint64_t>(height) << 48);
}
// How the game configures FSR frame generation (ffxConfigure, 0.1.0-beta.43). Read only when the header's type is
// the frame-generation configuration -- a key-value pair, a distortion field or the camera info arriving through the
// same call is passed over with nothing but its type looked at.
//
// WHAT IS READ: whether generation is on, whether it may run asynchronously, the flags, whether only generated
// frames are presented, and the rectangle generated in. WHAT IS NOT, EVER: the swapchain, the two callbacks and
// their contexts, the HUD-less resource and the frame id that sit in the same descriptor.
//
// ONE MODULE'S CONFIGURES ARE COUNTED (Owns), with a slot of its own: behind a loader the same call reaches the
// loader and the leaf, and a title's upscale may be owned by another module than its frame generation.
inline void ObserveFfxConfigure(uint32_t leaf, const ffxConfigureDescHeader* desc, Accumulators& a) noexcept {
if (desc == nullptr || desc->type != FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION) {
return;
}
if (!Owns(a.ffxFgOwner, leaf)) {
return;
}
const auto& g = *reinterpret_cast<const ffxConfigureDescFrameGeneration*>(desc);
a.ffxFgConfigures.fetch_add(1u, std::memory_order_relaxed);
NoteBits(a.ffxFgEnabledSeen, ByteIsSet(g.frameGenerationEnabled) ? 2u : 1u);
NoteBits(a.ffxFgAsyncSeen, ByteIsSet(g.allowAsyncWorkloads) ? 2u : 1u);
NoteBits(a.ffxFgOnlyGeneratedSeen, ByteIsSet(g.onlyPresentGenerated) ? 2u : 1u);
if (g.flags != 0u) {
NoteBits(a.ffxFgFlagsSeen, g.flags);
}
a.ffxFgRect.store(
PackRect(g.generationRect.left, g.generationRect.top, g.generationRect.width, g.generationRect.height),
std::memory_order_relaxed);
NoteBits(a.validMask, FL_ADV_VALID_FFX_FG_CONFIG);
}
// One sl::Boolean of sl::Constants into the two "seen" words: true sets its bit in `seenTrue`, false in `seenFalse`,
// the third state ("invalid": the game set nothing) in neither.
inline void NoteSlBoolean(sl::Boolean value, uint32_t bit, uint32_t& seenTrue, uint32_t& seenFalse) noexcept {
@@ -439,7 +497,13 @@ inline void Reset(Accumulators& a) noexcept {
a.ffxMemoryTotalBytes.store(0u, relaxed);
a.ffxMemoryAliasableBytes.store(0u, relaxed);
a.ffxMemoryQueries.store(0u, relaxed);
// Which viewport is summarised stays, as the two owners do: a fact about the process.
a.ffxFgConfigures.store(0u, relaxed);
a.ffxFgEnabledSeen.store(0u, relaxed);
a.ffxFgAsyncSeen.store(0u, relaxed);
a.ffxFgOnlyGeneratedSeen.store(0u, relaxed);
a.ffxFgFlagsSeen.store(0u, relaxed);
a.ffxFgRect.store(0u, relaxed);
// Which viewport is summarised stays, as the owners do: a fact about the process.
a.slConstantsCalls.store(0u, relaxed);
a.slResets.store(0u, relaxed);
a.slJitterMaxXBits.store(FL_ADV_FLOAT_NONE, relaxed);
@@ -520,6 +584,17 @@ inline void Publish(Accumulators& a, FlAdvancedState* region, uint32_t request,
put64(region->ffxMemoryAliasableBytes, a.ffxMemoryAliasableBytes.load(relaxed));
put32(region->ffxMemoryQueries, a.ffxMemoryQueries.load(relaxed));
put32(region->ffxFgConfigures, a.ffxFgConfigures.load(relaxed));
put32(region->ffxFgEnabledSeen, a.ffxFgEnabledSeen.load(relaxed));
put32(region->ffxFgAsyncSeen, a.ffxFgAsyncSeen.load(relaxed));
put32(region->ffxFgOnlyGeneratedSeen, a.ffxFgOnlyGeneratedSeen.load(relaxed));
put32(region->ffxFgFlagsSeen, a.ffxFgFlagsSeen.load(relaxed));
const uint64_t rect = a.ffxFgRect.load(relaxed);
for (uint32_t i = 0; i < 4u; ++i) {
const auto side = rect == kRectUnfit ? int32_t{-1} : static_cast<int32_t>((rect >> (16u * i)) & 0xFFFFu);
std::atomic_ref<int32_t>{region->ffxFgRect[i]}.store(side, relaxed);
}
put32(region->slConstantsCalls, a.slConstantsCalls.load(relaxed));
put32(region->slResets, a.slResets.load(relaxed));
put32(region->slJitterMaxXBits, a.slJitterMaxXBits.load(relaxed));
@@ -124,7 +124,8 @@ inline constexpr uint32_t kFamiliesEvaluateFeatureDoesNotImplement =
static_cast<uint32_t>(fl::FL_HOOK_RT_AS_BUILD) | static_cast<uint32_t>(fl::FL_HOOK_RT_PSO) |
static_cast<uint32_t>(fl::FL_HOOK_PSO) | static_cast<uint32_t>(fl::FL_HOOK_COLOR_SPACE) |
static_cast<uint32_t>(fl::FL_HOOK_REFLEX) | static_cast<uint32_t>(fl::FL_HOOK_VRAM) |
static_cast<uint32_t>(fl::FL_HOOK_UPSCALER_QUALITY) | static_cast<uint32_t>(fl::FL_HOOK_SL_CONSTANTS);
static_cast<uint32_t>(fl::FL_HOOK_UPSCALER_QUALITY) | static_cast<uint32_t>(fl::FL_HOOK_SL_CONSTANTS) |
static_cast<uint32_t>(fl::FL_HOOK_FFX_CONFIGURE);
static_assert((kFamilyEvaluateFeature & kFamiliesEvaluateFeatureDoesNotImplement) == 0u,
"the slEvaluateFeature row claims a family its detour does not implement -- hookinventory-check "
@@ -208,7 +209,7 @@ inline constexpr uint32_t kFamiliesFfxDispatchDoesNotImplement =
static_cast<uint32_t>(fl::FL_HOOK_PSO) | static_cast<uint32_t>(fl::FL_HOOK_COLOR_SPACE) |
static_cast<uint32_t>(fl::FL_HOOK_REFLEX) | static_cast<uint32_t>(fl::FL_HOOK_VRAM) |
static_cast<uint32_t>(fl::FL_HOOK_UPSCALER_QUALITY) | static_cast<uint32_t>(fl::FL_HOOK_SL_NEURAL_RENDERING) |
static_cast<uint32_t>(fl::FL_HOOK_SL_CONSTANTS);
static_cast<uint32_t>(fl::FL_HOOK_SL_CONSTANTS) | static_cast<uint32_t>(fl::FL_HOOK_FFX_CONFIGURE);
static_assert((kFamilyFfxDispatch & kFamiliesFfxDispatchDoesNotImplement) == 0u,
"the ffxDispatch rows claim a family their detour does not implement -- hookinventory-check reads "
@@ -302,6 +303,27 @@ static_assert(kFamilySlConstants != kFamilyEvaluateFeature && kFamilySlConstants
"InstallByFamily binds a row by EQUALITY on this value -- a collision would hand slSetConstants' "
"detour to another export, or another's to it");
// --- AMD FidelityFX: ffxConfigure on the same four modules (0.1.0-beta.43, Advanced metrics train B) ---
//
// HOW THE GAME CONFIGURES FRAME GENERATION: a title calls ffxConfigure with a frame-generation descriptor, usually
// every frame, saying whether generation is on, whether it may run asynchronously, its flags, whether only generated
// frames are presented, and the rectangle it generates in. Those five are read; the swapchain, the two callbacks
// and their contexts, the HUD-less resource and the frame id in the same descriptor never are. Every other
// configure type -- key-value pairs, the distortion field, the camera info -- is passed over with only its header's
// type read. The rows are the four modules ffxDispatch is hooked on, for the reason those rows give.
//
// INSTALLED ONLY WHERE ASKED FOR, like slSetConstants above (D111), and published when whole, like the other two
// ffx families. One call reaches two hooked modules behind a loader that forwards to the leaf's export (Cyberpunk
// 2077's 2.3.0) and behind the fixture's loader, which has always forwarded ffxConfigure that way: the reads are
// counted at the first module that saw a frame-generation configure (fl_adv_fields.h).
inline constexpr uint32_t kFamilyFfxConfigure = static_cast<uint32_t>(fl::FL_HOOK_FFX_CONFIGURE);
static_assert(kFamilyFfxConfigure != kFamilyEvaluateFeature && kFamilyFfxConfigure != kFamilyFfxDispatch &&
kFamilyFfxConfigure != kFamilyFfxQuery && kFamilyFfxConfigure != kFamilySlConstants &&
kFamilyFfxConfigure != static_cast<uint32_t>(fl::FL_HOOK_UPSCALER_PARAMS) &&
kFamilyFfxConfigure != static_cast<uint32_t>(fl::FL_HOOK_FG_EVALUATIONS),
"InstallByFamily binds a row by EQUALITY on this value -- a collision would hand ffxConfigure's detour "
"to a dispatch or a query export, whose descriptors it does not share");
// The leaves, in the order dllmain's per-leaf trampoline and latch arrays are indexed.
enum FfxLeaf : uint32_t {
kFfxLeafMonolith = 0, // amd_fidelityfx_dx12.dll -- SDK 1.1.x, FSR 3.1 only
@@ -406,6 +428,10 @@ inline int FfxLeafOf(const wchar_t* moduleName) noexcept {
X(L"amd_fidelityfx_upscaler_dx12.dll", "ffxQuery", fl::inventory::kFamilyFfxQuery) \
X(L"amd_fidelityfx_framegeneration_dx12.dll", "ffxQuery", fl::inventory::kFamilyFfxQuery) \
X(L"amd_fidelityfx_loader_dx12.dll", "ffxQuery", fl::inventory::kFamilyFfxQuery) \
X(L"amd_fidelityfx_dx12.dll", "ffxConfigure", fl::inventory::kFamilyFfxConfigure) \
X(L"amd_fidelityfx_upscaler_dx12.dll", "ffxConfigure", fl::inventory::kFamilyFfxConfigure) \
X(L"amd_fidelityfx_framegeneration_dx12.dll", "ffxConfigure", fl::inventory::kFamilyFfxConfigure) \
X(L"amd_fidelityfx_loader_dx12.dll", "ffxConfigure", fl::inventory::kFamilyFfxConfigure) \
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
@@ -413,7 +439,7 @@ inline int FfxLeafOf(const wchar_t* moduleName) noexcept {
#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 == 14u, "a row was added or removed: say so here, and in 17_HOOK_ENGINE §Hook inventory");
static_assert(kRowCount == 18u, "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
@@ -581,6 +607,38 @@ static_assert(EveryFfxQueryRowIsALeaf(),
static_assert(!FfxQueryRowExistsFor(kModuleFfxFsr3Host),
"the FSR 3.0 host has its own query API, not ffxQuery; a row claiming one would resolve nothing");
// The ffxConfigure rows, bound to the leaf table the same way (0.1.0-beta.43).
inline constexpr const char* kSymbolFfxConfigure = "ffxConfigure";
constexpr bool FfxConfigureRowExistsFor(const wchar_t* moduleName) noexcept {
#define FL_FFX_CONFIGURE_ROW_FOR(mod, sym, family) \
if (SameW(mod, moduleName) && SameA(sym, kSymbolFfxConfigure)) { \
return true; \
}
FL_HOOK_INVENTORY(FL_FFX_CONFIGURE_ROW_FOR)
#undef FL_FFX_CONFIGURE_ROW_FOR
return false;
}
constexpr bool EveryFfxConfigureRowIsALeaf() noexcept {
#define FL_FFX_CONFIGURE_ROW_IS_LEAF(mod, sym, family) \
if (SameA(sym, kSymbolFfxConfigure) && FfxLeafOfExact(mod) < 0) { \
return false; \
}
FL_HOOK_INVENTORY(FL_FFX_CONFIGURE_ROW_IS_LEAF)
#undef FL_FFX_CONFIGURE_ROW_IS_LEAF
return true;
}
static_assert(FfxConfigureRowExistsFor(kFfxLeafModules[kFfxLeafMonolith]) &&
FfxConfigureRowExistsFor(kFfxLeafModules[kFfxLeafUpscaler]) &&
FfxConfigureRowExistsFor(kFfxLeafModules[kFfxLeafFrameGeneration]) &&
FfxConfigureRowExistsFor(kFfxLeafModules[kFfxLeafLoader]),
"every ffx leaf needs its ffxConfigure row, spelled identically -- the configure reaches whatever module "
"the game calls, as the dispatch does");
static_assert(EveryFfxConfigureRowIsALeaf(),
"an ffxConfigure row names a module the leaf table does not know -- InstallByFamily would find no slot");
static_assert(!FfxConfigureRowExistsFor(kModuleFfxFsr3Host),
"the FSR 3.0 host has its own configure API, not ffxConfigure; a row claiming one would resolve nothing");
// Does this module speak the Streamline 2 ABI the vendored headers describe?
//
// MEASURED 2026-08-14, and it cost an access violation to find. The Witcher 3
+97 -2
View File
@@ -163,6 +163,7 @@ enum FlLogCode : uint32_t {
kLogFfxQueryType,
kLogUpscaleRoute,
kLogRuntimeCensus,
kLogFfxConfigureType,
};
const char* LogCodeName(uint32_t code) noexcept {
@@ -201,6 +202,8 @@ const char* LogCodeName(uint32_t code) noexcept {
return "UPSCALE_ROUTE";
case kLogRuntimeCensus:
return "RUNTIME_CENSUS";
case kLogFfxConfigureType:
return "FFX_CONFIGURE";
default:
return "?";
}
@@ -1326,6 +1329,13 @@ PFN_FfxQuery g_origFfxQuery[fl::inventory::kFfxLeafCount] = {};
std::atomic<uint32_t> g_ffxQueryPatched[fl::inventory::kFfxLeafCount] = {};
std::atomic<uint32_t> g_ffxQueryLive{0};
// ffxConfigure on the same four modules (0.1.0-beta.43, Advanced metrics): patched only in a process that was asked
// for Advanced metrics at least once (InstallByFamily); one trampoline and one latch a leaf, as the query's.
using PFN_FfxConfigure = ::PfnFfxConfigure;
PFN_FfxConfigure g_origFfxConfigure[fl::inventory::kFfxLeafCount] = {};
std::atomic<uint32_t> g_ffxConfigurePatched[fl::inventory::kFfxLeafCount] = {};
std::atomic<uint32_t> g_ffxConfigureLive{0};
// THE VALUES AND LAYOUTS THE QUERY ARM READS, PINNED TO LITERALS. Identical at FidelityFX SDK v1.1.4 (the monolith's
// generation) and v2.3.0 (the vendored headers), checked against both on 2026-10-19: the two type ids, the mode enum,
// and both query descriptors -- a re-vendoring that moved a field fails here, not on a title's own descriptor.
@@ -1961,8 +1971,10 @@ void NoteFfxExtent(const FfxApiDimensions2D& size) noexcept {
// 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
fl::ffxtypes::Reported g_ffxDispatchTypesLogged[fl::inventory::kFfxLeafCount]; // watchdog only
fl::ffxtypes::Reported g_ffxQueryTypesLogged[fl::inventory::kFfxLeafCount]; // watchdog only
fl::ffxtypes::Seen g_ffxConfigureTypes[fl::inventory::kFfxLeafCount]; // only where ffxConfigure is hooked
fl::ffxtypes::Reported g_ffxConfigureTypesLogged[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.
@@ -2172,6 +2184,39 @@ ffxReturnCode_t Hook_FfxQueryT(ffxContext* context, ffxQueryDescHeader* desc) {
return rc;
}
// ffxConfigure's trampolines (0.1.0-beta.43), one per leaf. The descriptor's type is kept for the log whatever it
// is; the frame-generation configuration is read further only while the Agent asks, in fl_adv_fields.h, which never
// touches the swapchain, the callbacks, the HUD-less resource or the frame id. MayObserve first: after a stop nobody
// clears the request word. Every argument forwarded untouched, the original called exactly once on every path.
template <uint32_t Leaf>
ffxReturnCode_t Hook_FfxConfigureT(ffxContext* context, const ffxConfigureDescHeader* desc) {
static_assert(Leaf < fl::inventory::kFfxLeafCount, "a trampoline per leaf, and no more");
FL_HOOK_GUARD({
if (MayObserve() && desc != nullptr) {
fl::ffxtypes::Note(g_ffxConfigureTypes[Leaf], desc->type);
if (g_advancedRequested.load(std::memory_order_relaxed) != 0u) {
fl::adv::ObserveFfxConfigure(Leaf, desc, g_adv);
}
}
})
return g_origFfxConfigure[Leaf](context, desc);
}
void* FfxConfigureDetour(uint32_t leaf) noexcept {
switch (leaf) {
case fl::inventory::kFfxLeafMonolith:
return reinterpret_cast<void*>(&Hook_FfxConfigureT<fl::inventory::kFfxLeafMonolith>);
case fl::inventory::kFfxLeafUpscaler:
return reinterpret_cast<void*>(&Hook_FfxConfigureT<fl::inventory::kFfxLeafUpscaler>);
case fl::inventory::kFfxLeafFrameGeneration:
return reinterpret_cast<void*>(&Hook_FfxConfigureT<fl::inventory::kFfxLeafFrameGeneration>);
case fl::inventory::kFfxLeafLoader:
return reinterpret_cast<void*>(&Hook_FfxConfigureT<fl::inventory::kFfxLeafLoader>);
default:
return nullptr;
}
}
void* FfxQueryDetour(uint32_t leaf) noexcept {
switch (leaf) {
case fl::inventory::kFfxLeafMonolith:
@@ -2354,6 +2399,10 @@ void LogFfxObservations() noexcept {
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); });
fl::ffxtypes::ReportNew(
g_ffxConfigureTypes[leaf], g_ffxConfigureTypesLogged[leaf],
[moduleName](uint64_t type) noexcept { LogNoteW(kLogFfxConfigureType, moduleName, 0u, type); },
[moduleName](uint32_t more) noexcept { LogNoteW(kLogFfxConfigureType, 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.
@@ -2465,6 +2514,30 @@ bool InstallByFamily(const wchar_t* moduleName, const char* symbol, uint32_t fam
return InstallRow(moduleName, symbol, family, reinterpret_cast<void*>(&Hook_SlSetConstants),
reinterpret_cast<void**>(&g_origSlSetConstants), g_slConstantsLive, name);
}
if (family == fl::inventory::kFamilyFfxConfigure) {
if (g_advancedSeen == 0u) {
return false;
}
// FOUR ROWS, ONE ARM, the query arm's shape: the row's MODULE picks the trampoline and the latch slot.
// Published in PublishFfxConfigureFamilyIfWhole, once every loaded leaf is in.
const int leaf = fl::inventory::FfxLeafOf(moduleName);
if (leaf < 0) {
return false; // the static_asserts make this unreachable for the rows as written
}
const auto slot = static_cast<uint32_t>(leaf);
if (g_ffxConfigurePatched[slot].load(std::memory_order_acquire) != 0) {
return true;
}
void* target = fl::inventory::ResolveScoped(moduleName, symbol);
if (target == nullptr) {
return false; // not loaded, or a module of the name that does not speak ffx-api
}
if (!PatchTarget(target, FfxConfigureDetour(slot), reinterpret_cast<void**>(&g_origFfxConfigure[slot]), name)) {
return false;
}
g_ffxConfigurePatched[slot].store(1, std::memory_order_release);
return true;
}
if (family == fl::inventory::kFamilyEvaluateFeature) {
return InstallRow(moduleName, symbol, family, reinterpret_cast<void*>(&Hook_SlEvaluateFeature),
reinterpret_cast<void**>(&g_origSlEvaluateFeature), g_upscalerIdentityLive, name);
@@ -2635,6 +2708,27 @@ void PublishFfxQueryFamilyIfWhole() noexcept {
}
}
// Publish kFamilyFfxConfigure once every ffx leaf the process has loaded has its configure patched, and at least one
// does -- the query family's rule. Nothing is patched in a process never asked, so nothing is published there.
void PublishFfxConfigureFamilyIfWhole() noexcept {
if (g_advancedSeen == 0u || g_ffxConfigureLive.load(std::memory_order_acquire) != 0) {
return;
}
bool anyPatched = false;
for (uint32_t i = 0; i < fl::inventory::kFfxLeafCount; ++i) {
if (g_ffxConfigurePatched[i].load(std::memory_order_acquire) != 0) {
anyPatched = true;
continue;
}
if (fl::inventory::IsModuleLoaded(fl::inventory::kFfxLeafModules[i])) {
return; // loaded and not yet patched: the family is not whole
}
}
if (anyPatched) {
PublishHookFamily(fl::inventory::kFamilyFfxConfigure, g_ffxConfigureLive);
}
}
// Publish FL_HOOK_UPSCALER_PARAMS once EVERY TAG EXPORT THE LOADED INTERPOSER HAS is
// patched, and at least one is. "Has" is the export table, not the module list: a
// 2.7 interposer exports slSetTag alone and is whole with that one row patched; a
@@ -2678,6 +2772,7 @@ bool InstallUpscalerHooks() noexcept {
PublishParamsFamilyIfWhole();
PublishFfxFamilyIfWhole();
PublishFfxQueryFamilyIfWhole();
PublishFfxConfigureFamilyIfWhole();
return any;
}
@@ -410,6 +410,11 @@ enum FlHookFamily : uint32_t {
// so its absence beside FL_ADV_VALID_* bits says "the hook was not installed", and its presence beside a zero
// slConstantsCalls says "hooked, and the game never called it". It entitles no measured field of a frame record.
FL_HOOK_SL_CONSTANTS = 1u << 13,
// The same for ffxConfigure on the ffx-api modules (0.1.0-beta.43): hooked, in a process that was asked for
// Advanced metrics at least once. Published when every ffx-api module the process has loaded is patched, as the
// dispatch and query families are. Beside a zero ffxFgConfigures it says "hooked, and the game never configured
// frame generation"; it entitles no measured field of a frame record.
FL_HOOK_FFX_CONFIGURE = 1u << 14,
};
// FlWriterState::runtimeCensus -- which vendor RUNTIME MODULES the loader reported
+2
View File
@@ -137,6 +137,8 @@ target_compile_definitions(fl_guard_test PRIVATE
# late arrival must be hooked within milliseconds rather than on the next tick.
FL_STUB_SL_COMMON=L"$<TARGET_FILE:fl_stub_sl_common>"
FL_STUB_SL_INTERPOSER=L"$<TARGET_FILE:fl_stub_sl_interposer>"
# The ffx-api loader stub, so a test can read one of its exports' first bytes out of a target (0.1.0-beta.43).
FL_STUB_FFX_LOADER=L"$<TARGET_FILE:fl_stub_ffx_loader>"
FL_OVERLAY_DLL=L"${FL_STAGED_OVERLAY}"
# The un-staged original, so a test can prove the check discriminates on
# DIRECTORY rather than on filename: same bytes, same name, wrong place.
+98 -16
View File
@@ -6960,15 +6960,19 @@ constexpr float kAdvFfxFovLow = 0.9f;
constexpr float kAdvFfxFovHigh = 1.1f;
constexpr uint32_t kAdvFfxFrameTimeUs = 16000u;
// ...and hands slSetConstants for viewport 0 (0.1.0-beta.43); a second viewport gets other numbers every frame.
constexpr float kAdvSlJitterX = 0.3125f;
constexpr float kAdvSlJitterY = 0.4375f;
constexpr float kAdvSlMvecScaleX = 0.5f;
constexpr float kAdvSlMvecScaleY = 0.25f;
constexpr float kAdvSlNear = 0.25f;
constexpr float kAdvSlFar = 4000.0f;
constexpr float kAdvSlFovLow = 0.8f;
constexpr float kAdvSlFovHigh = 1.2f;
constexpr float kAdvSlAspect = 1.75f;
constexpr float kAdvSlJitterX = 0.3125f;
constexpr float kAdvSlJitterY = 0.4375f;
constexpr float kAdvSlMvecScaleX = 0.5f;
constexpr float kAdvSlMvecScaleY = 0.25f;
constexpr float kAdvSlNear = 0.25f;
constexpr float kAdvSlFar = 4000.0f;
constexpr float kAdvSlFovLow = 0.8f;
constexpr float kAdvSlFovHigh = 1.2f;
constexpr float kAdvSlAspect = 1.75f;
// ...and hands ffxConfigure a frame-generation configuration before each frame's dispatches (0.1.0-beta.43).
constexpr uint32_t kAdvFfxFgFlags = 1u << 4; // FFX_FRAMEGENERATION_FLAG_DRAW_DEBUG_PACING_LINES
constexpr int32_t kAdvFfxFgRectWidth = 1920;
constexpr int32_t kAdvFfxFgRectHeight = 1080;
constexpr uint64_t kAdvMemoryTotal = 123456789ull;
constexpr uint64_t kAdvMemoryAliasable = 23456789ull;
@@ -7027,16 +7031,22 @@ uint32_t BitsOf(float v) {
return std::bit_cast<uint32_t>(v);
}
// What later releases fill: declared, written by nothing yet. (The sl::Constants group left this list with
// 0.1.0-beta.43, which fills it; SlConstantsAreUnread below is for a target that never calls slSetConstants.)
// What later releases fill: declared, written by nothing yet. (The sl::Constants and the ffxConfigure groups left
// this list with 0.1.0-beta.43, which fills them; the two helpers below are for a target that makes neither call.)
bool LaterGroupsAreZero(const fl::FlAdvancedState& a) {
bool zero = a.ffxFgConfigures == 0u && a.ffxFgEnabledSeen == 0u && a.ffxFgFlagsSeen == 0u;
bool zero = true;
for (uint32_t i = 0; i < FL_ADV_FEATURE_SLOTS * FL_ADV_FEATURE_WORDS; ++i) {
zero = zero && a.features[i] == 0u;
}
return zero;
}
bool FfxFgConfigIsUnread(const fl::FlAdvancedState& a) {
return a.ffxFgConfigures == 0u && a.ffxFgEnabledSeen == 0u && a.ffxFgAsyncSeen == 0u &&
a.ffxFgOnlyGeneratedSeen == 0u && a.ffxFgFlagsSeen == 0u && a.ffxFgRect[2] == 0 && a.ffxFgRect[3] == 0 &&
(a.validMask & fl::FL_ADV_VALID_FFX_FG_CONFIG) == 0u;
}
bool SlConstantsAreUnread(const fl::FlAdvancedState& a) {
return a.slConstantsCalls == 0u && a.slResets == 0u && a.slFlagsSeenTrue == 0u && a.slFlagsSeenFalse == 0u &&
(a.validMask & fl::FL_ADV_VALID_SL_CONSTANTS) == 0u;
@@ -7045,7 +7055,12 @@ bool SlConstantsAreUnread(const fl::FlAdvancedState& a) {
// The first 16 bytes of one export of a module AS THEY ARE IN ANOTHER PROCESS: the export's offset from this
// process's own mapping of the same file (mapped as an image, nothing run), the module's base from the target's
// module list. What a patch changes, and what a restore puts back.
bool ReadTargetExportBytes(DWORD pid, const wchar_t* dllPath, const char* symbol, unsigned char out[16]) {
//
// `inFile`, when given, receives the same 16 bytes as this process's own mapping of the file has them -- nothing has
// patched that copy, so an export whose bytes in the target equal them is unpatched. (Not "does it start with a
// jump": a stub export may be a jump to begin with -- the loader stub's ffxConfigure is.)
bool ReadTargetExportBytes(DWORD pid, const wchar_t* dllPath, const char* symbol, unsigned char out[16],
unsigned char* inFile = nullptr) {
const HMODULE mine = LoadLibraryExW(dllPath, nullptr, DONT_RESOLVE_DLL_REFERENCES);
if (mine == nullptr) {
return false;
@@ -7053,6 +7068,9 @@ bool ReadTargetExportBytes(DWORD pid, const wchar_t* dllPath, const char* symbol
const auto* entry = reinterpret_cast<const unsigned char*>(GetProcAddress(mine, symbol));
const size_t rva =
entry != nullptr ? static_cast<size_t>(entry - reinterpret_cast<const unsigned char*>(mine)) : 0u;
if (entry != nullptr && inFile != nullptr) {
std::memcpy(inFile, entry, 16);
}
FreeLibrary(mine);
const wchar_t* slash = wcsrchr(dllPath, L'\\');
const wchar_t* slash2 = wcsrchr(dllPath, L'/');
@@ -7115,14 +7133,35 @@ TEST_CASE("region 5 stays empty until the Agent asks, then carries what an FSR t
REQUIRE(r.st->writeIndex > atHooks + 30u); // the hooks ran: this is not a target that sent nothing
CHECK(r.ctl->advancedRequested == 0u);
CHECK(RegionFiveIsZero(r));
// ...and ffxConfigure, which the target calls twice a frame, is not patched: never asked (D111). Its first bytes
// in the target's loader are the file's.
const auto ffxConfigure = static_cast<uint32_t>(fl::FL_HOOK_FFX_CONFIGURE);
unsigned char pristine[16]{};
unsigned char inFile[16]{};
unsigned char now[16]{};
CHECK((r.st->hooksInstalledMask & ffxConfigure) == 0u);
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_FFX_LOADER, "ffxConfigure", pristine, inFile));
CHECK(std::memcmp(pristine, inFile, sizeof(inFile)) == 0);
{
// The dispatch export beside it IS patched, since the module appeared: the same read tells the two apart.
unsigned char dispatch[16]{};
unsigned char dispatchInFile[16]{};
REQUIRE(
ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_FFX_LOADER, "ffxDispatch", dispatch, dispatchInFile));
CHECK(std::memcmp(dispatch, dispatchInFile, sizeof(dispatch)) != 0);
}
// ---- 2. ASKED. Within a tick or two the region answers THIS request with what the descriptor carried.
SetAdvancedRequest(r, 7u);
REQUIRE(WaitForHookFamily(r.st, ffxConfigure));
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_FFX_LOADER, "ffxConfigure", now));
CHECK(std::memcmp(pristine, now, sizeof(now)) != 0); // patched now
const uint32_t want = fl::FL_ADV_VALID_FFX_UPSCALE | fl::FL_ADV_VALID_FFX_MEMORY | fl::FL_ADV_VALID_FFX_FG_CONFIG;
fl::FlAdvancedState a{};
REQUIRE(ReadAdvanced(r, 7u, a, 0u, fl::FL_ADV_VALID_FFX_UPSCALE | fl::FL_ADV_VALID_FFX_MEMORY));
REQUIRE(ReadAdvanced(r, 7u, a, 0u, want));
// A few seconds of it, so the count is one a restart can be told from.
for (int i = 0; i < 20 && a.ffxDispatches < 300u; ++i) {
REQUIRE(ReadAdvanced(r, 7u, a, a.samples, fl::FL_ADV_VALID_FFX_UPSCALE | fl::FL_ADV_VALID_FFX_MEMORY));
REQUIRE(ReadAdvanced(r, 7u, a, a.samples, want));
}
INFO("mask 0x" << std::hex << a.validMask << std::dec << " dispatches " << a.ffxDispatches << " queries "
<< a.ffxMemoryQueries << " frameTime " << a.ffxFrameTimeCount << "/" << a.ffxFrameTimeSumUs
@@ -7155,6 +7194,22 @@ TEST_CASE("region 5 stays empty until the Agent asks, then carries what an FSR t
CHECK(a.ffxMemoryQueries != 0u);
CHECK(a.ffxMemoryQueries <= a.ffxDispatches + 2u);
CHECK(LaterGroupsAreZero(a));
// How the target configures frame generation: one configure a frame, counted ONCE though the loader hands it on
// to the leaf's export and both are hooked (twice would be past the dispatches), and the key-value configure
// beside it not at all. On, never asynchronous, never generated-only, one flag, the whole 1920x1080.
INFO("fg configures " << a.ffxFgConfigures << " enabled " << a.ffxFgEnabledSeen << " async " << a.ffxFgAsyncSeen
<< " flags 0x" << std::hex << a.ffxFgFlagsSeen << std::dec);
CHECK(a.ffxFgConfigures != 0u);
CHECK(a.ffxFgConfigures <= a.ffxDispatches + 2u);
CHECK(a.ffxFgConfigures * 2u > a.ffxDispatches);
CHECK(a.ffxFgEnabledSeen == 2u);
CHECK(a.ffxFgAsyncSeen == 1u);
CHECK(a.ffxFgOnlyGeneratedSeen == 1u);
CHECK(a.ffxFgFlagsSeen == kAdvFfxFgFlags);
CHECK(a.ffxFgRect[0] == 0);
CHECK(a.ffxFgRect[1] == 0);
CHECK(a.ffxFgRect[2] == kAdvFfxFgRectWidth);
CHECK(a.ffxFgRect[3] == kAdvFfxFgRectHeight);
// ---- 3. NOT ASKED AGAIN. Nothing more is read, and nothing more is written: the region is what it was.
SetAdvancedRequest(r, 0u);
@@ -7180,6 +7235,30 @@ TEST_CASE("region 5 stays empty until the Agent asks, then carries what an FSR t
CHECK(r.st->faultCount == 0u);
CHECK(r.st->status == fl::FL_STATUS_READY);
// The log, written by the watchdog unasked: the two configure patches by module and symbol, and each configure
// type each module was handed -- the frame-generation one (0x20002) and the key-value one (0x20006).
std::wstring log;
std::string text;
for (int i = 0; i < 60; ++i) {
++r.ctl->guardTicks;
if (log.empty() && !FindOverlayLog(child.pi.dwProcessId, child.pi.hProcess, log)) {
Sleep(100);
continue;
}
text = ReadWholeFile(log);
if (LogHasLine(text, "FFX_CONFIGURE", "amd_fidelityfx_loader_dx12.dll", " b=0x20006")) {
break;
}
Sleep(100);
}
INFO("log:\n" << text);
CHECK(LogHasLine(text, "HOOK_INSTALLED", "amd_fidelityfx_loader_dx12.dll!ffxConfigure", ""));
CHECK(LogHasLine(text, "HOOK_INSTALLED", "amd_fidelityfx_framegeneration_dx12.dll!ffxConfigure", ""));
CHECK(LogHasLine(text, "FFX_CONFIGURE", "amd_fidelityfx_loader_dx12.dll", " b=0x20002"));
CHECK(LogHasLine(text, "FFX_CONFIGURE", "amd_fidelityfx_loader_dx12.dll", " b=0x20006"));
CHECK(LogHasLine(text, "FFX_CONFIGURE", "amd_fidelityfx_framegeneration_dx12.dll", " b=0x20002"));
CHECK(text.find("PATCH_FAILED") == std::string::npos);
}
TEST_CASE("FSR's plane at infinity (beta.42, D119): a far plane of FLT_MAX reaches region 5 as +infinity, beside "
@@ -7243,8 +7322,10 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation a
// ---- 1. NEVER ASKED (owner decision D111): the evaluation is hooked, the game calls slSetConstants every frame,
// and that export is not patched -- its first bytes in the target are the file's -- nor is anything kept.
unsigned char pristine[16]{};
unsigned char inFile[16]{};
unsigned char now[16]{};
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_SL_INTERPOSER, "slSetConstants", pristine));
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_SL_INTERPOSER, "slSetConstants", pristine, inFile));
CHECK(std::memcmp(pristine, inFile, sizeof(inFile)) == 0); // the file's bytes: nothing has patched it
const std::uint64_t atHooks = r.st->writeIndex;
TickFor(r, 2500); // two watchdog ticks and more: every row that installs unasked has had its chance
REQUIRE(r.st->writeIndex > atHooks + 30u);
@@ -7313,6 +7394,7 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation a
CHECK(a.ffxDispatches == 0u); // no ffx call in this target
CHECK(a.ffxSharpnessMinBits == FL_ADV_FLOAT_NONE); // a float nobody saw is "none", never 0.0
CHECK(a.ffxMemoryQueries == 0u);
CHECK(FfxFgConfigIsUnread(a)); // a Streamline title with no FidelityFX: nothing calls ffxConfigure
CHECK(LaterGroupsAreZero(a));
// ---- 3. NO LONGER ASKED: the detour forwards without looking, the region is as it was left, and the patch stays
+128 -1
View File
@@ -118,7 +118,10 @@
// The values are the kAdv* constants below; the injected fl_guard cases assert them.
// Since 0.1.0-beta.43 the upscaled hold also calls slSetConstants every frame, for viewport 0
// (kAdvSl*) and for a second viewport whose numbers must never be shown, with the matrices and
// the camera's position and axes - which the Overlay never reads - set to loud, changing values
// the camera's position and axes - which the Overlay never reads - set to loud, changing values;
// and the ffx hold calls ffxConfigure every frame with a frame-generation configuration
// (kAdvFfxFg*) and with a key-value one, the swapchain, the contexts, the HUD-less resource and
// the frame id - never read either - loud and changing
// --churn-module <dll>
// load and free the module in a loop on a thread of its own, for the life of the process: a
// module list that keeps changing under whoever reads it (the guard's D123, 2026-11-12)
@@ -2459,6 +2462,94 @@ bool ProbeAdvFields() {
VirtualFree(pages, 0, MEM_RELEASE);
}
}
// --- ffxConfigure with a frame-generation descriptor (0.1.0-beta.43) -------------------------------------------
{
fl::adv::Accumulators a;
ffxConfigureDescFrameGeneration c{};
c.header.type = FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION;
c.frameGenerationEnabled = true;
c.allowAsyncWorkloads = false;
c.onlyPresentGenerated = false;
c.flags = FFX_FRAMEGENERATION_FLAG_DRAW_DEBUG_VIEW;
c.generationRect = {10, 20, 2560, 1440};
fl::adv::ObserveFfxConfigure(3u, &c.header, a);
c.frameGenerationEnabled = false; // the player switched it off in the menu
c.flags = FFX_FRAMEGENERATION_FLAG_DRAW_DEBUG_TEAR_LINES;
c.generationRect = {0, 0, 1920, 1080};
fl::adv::ObserveFfxConfigure(3u, &c.header, a);
Check(a.validMask.load() == fl::FL_ADV_VALID_FFX_FG_CONFIG && a.ffxFgConfigures.load() == 2u,
"two frame-generation configures, counted, and the group marked read");
Check(a.ffxFgEnabledSeen.load() == 3u, "generation seen on and seen off: both bits");
Check(a.ffxFgAsyncSeen.load() == 1u && a.ffxFgOnlyGeneratedSeen.load() == 1u,
"a switch only ever seen off sets the 'off' bit alone");
Check(a.ffxFgFlagsSeen.load() ==
(FFX_FRAMEGENERATION_FLAG_DRAW_DEBUG_VIEW | FFX_FRAMEGENERATION_FLAG_DRAW_DEBUG_TEAR_LINES),
"the flags are every bit any configure carried");
Check(a.ffxFgRect.load() == fl::adv::PackRect(0, 0, 1920, 1080), "the rectangle is the last one, whole");
// The same call arriving at a second hooked module - the leaf behind the loader - is passed over.
fl::adv::ObserveFfxConfigure(2u, &c.header, a);
Check(a.ffxFgConfigures.load() == 2u, "one module's configures are counted, not one per hook");
// ANOTHER CONFIGURE TYPE through the same call is not a frame-generation configuration: only its type is
// looked at. A key-value descriptor is shorter than the one above, so reading it as one would run past it.
fl::adv::Accumulators other;
ffxConfigureDescFrameGenerationKeyValue kv{};
kv.header.type = FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION_KEYVALUE;
kv.key = 0xFFFFFFFFFFFFFFFFull;
kv.u64 = 0xFFFFFFFFFFFFFFFFull;
fl::adv::ObserveFfxConfigure(0u, &kv.header, other);
fl::adv::ObserveFfxConfigure(0u, nullptr, other);
Check(other.validMask.load() == 0u && other.ffxFgConfigures.load() == 0u && other.ffxFgOwner.load() == 0u,
"a configure of another type, and no descriptor at all, read nothing and own nothing");
// WHAT IS NEVER READ CHANGES NOTHING: two descriptors alike in the five members read and different in the
// swapchain, the callbacks' contexts, the HUD-less resource and the frame id publish the same bytes.
ffxConfigureDescFrameGeneration p = c;
ffxConfigureDescFrameGeneration q = c;
p.swapChain = reinterpret_cast<void*>(static_cast<uintptr_t>(0x1111));
p.presentCallbackUserContext = reinterpret_cast<void*>(static_cast<uintptr_t>(0x2222));
p.frameGenerationCallbackUserContext = reinterpret_cast<void*>(static_cast<uintptr_t>(0x3333));
p.HUDLessColor.resource = reinterpret_cast<void*>(static_cast<uintptr_t>(0x4444));
p.frameID = 5u;
q.swapChain = reinterpret_cast<void*>(static_cast<uintptr_t>(0xEEEE));
q.presentCallbackUserContext = reinterpret_cast<void*>(static_cast<uintptr_t>(0xDDDD));
q.frameGenerationCallbackUserContext = reinterpret_cast<void*>(static_cast<uintptr_t>(0xCCCC));
q.HUDLessColor.resource = reinterpret_cast<void*>(static_cast<uintptr_t>(0xBBBB));
q.frameID = 0xFFFFFFFFFFFFull;
auto* regionP = new fl::FlAdvancedState{};
auto* regionQ = new fl::FlAdvancedState{};
fl::adv::Accumulators ap;
fl::adv::Accumulators aq;
fl::adv::ObserveFfxConfigure(1u, &p.header, ap);
fl::adv::ObserveFfxConfigure(1u, &q.header, aq);
fl::adv::Publish(ap, regionP, 9u, 1u);
fl::adv::Publish(aq, regionQ, 9u, 1u);
Check(std::memcmp(regionP, regionQ, sizeof(fl::FlAdvancedState)) == 0 && regionP->ffxFgConfigures == 1u,
"two configurations that differ only in what is never read publish the same bytes");
Check(regionP->ffxFgRect[0] == 0 && regionP->ffxFgRect[1] == 0 && regionP->ffxFgRect[2] == 1920 &&
regionP->ffxFgRect[3] == 1080 && regionP->ffxFgEnabledSeen == 1u,
"the rectangle lands as left, top, width, height; the switches as their two bits");
delete regionP;
delete regionQ;
// A RECTANGLE THAT DOES NOT FIT IS NOBODY'S, never a clipped one.
Check(fl::adv::PackRect(-1, 0, 100, 100) == fl::adv::kRectUnfit &&
fl::adv::PackRect(0, 0, 0x8000, 100) == fl::adv::kRectUnfit &&
fl::adv::PackRect(0, 0, 0x7FFF, 0x7FFF) != fl::adv::kRectUnfit,
"a negative side or one past fifteen bits makes the rectangle 'unfit'; the largest that fits is kept");
fl::adv::Accumulators big;
c.generationRect = {0, 0, 100000, 1080};
fl::adv::ObserveFfxConfigure(0u, &c.header, big);
auto* regionBig = new fl::FlAdvancedState{};
fl::adv::Publish(big, regionBig, 9u, 1u);
Check(regionBig->ffxFgRect[0] == -1 && regionBig->ffxFgRect[1] == -1 && regionBig->ffxFgRect[2] == -1 &&
regionBig->ffxFgRect[3] == -1,
"and is published as four -1, which no rectangle is");
delete regionBig;
}
return g_failures == 0;
}
@@ -2924,6 +3015,10 @@ constexpr float kAdvSlFovLow = 0.8f;
constexpr float kAdvSlFovHigh = 1.2f;
constexpr float kAdvSlAspect = 1.75f;
constexpr uint32_t kAdvSlOtherViewport = 7u;
// What --advanced hands ffxConfigure before each frame's frame-generation dispatches (0.1.0-beta.43).
constexpr uint32_t kAdvFfxFgFlags = FFX_FRAMEGENERATION_FLAG_DRAW_DEBUG_PACING_LINES;
constexpr int32_t kAdvFfxFgRectWidth = 1920;
constexpr int32_t kAdvFfxFgRectHeight = 1080;
using StubTokenFn = sl::Result(STDMETHODCALLTYPE*)(sl::FrameToken*&, const uint32_t*);
alignas(16) unsigned char g_dummyFrameToken[64]{};
@@ -3464,6 +3559,28 @@ int HoldPresentingFfx(Gfx& g, int seconds, bool real, int presentsPerEval, FfxTo
hostUp.renderSize.width = kTaggedRenderW;
hostUp.renderSize.height = kTaggedRenderH;
// --advanced, 0.1.0-beta.43: the frame-generation configuration a title sends every frame, and beside it a
// configure of another type, which the Overlay passes over. What may be read is a known value; WHAT MAY NOT --
// the swapchain, the callbacks' contexts, the HUD-less resource, the frame id -- is loud and changes every frame.
// Nothing is dereferenced: the stub looks at none of it.
const PfnFfxConfigure configureFg =
advanced && prepare && fgEntry != nullptr
? reinterpret_cast<PfnFfxConfigure>(reinterpret_cast<void*>(GetProcAddress(fgEntry, "ffxConfigure")))
: nullptr;
ffxConfigureDescFrameGeneration cfg{};
cfg.header.type = FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION;
cfg.frameGenerationEnabled = true;
cfg.allowAsyncWorkloads = false;
cfg.onlyPresentGenerated = false;
cfg.flags = kAdvFfxFgFlags;
cfg.generationRect = {0, 0, kAdvFfxFgRectWidth, kAdvFfxFgRectHeight};
ffxConfigureDescFrameGenerationKeyValue otherCfg{};
otherCfg.header.type = FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION_KEYVALUE;
if (advanced && prepare && fgEntry != nullptr && configureFg == nullptr) {
Check(false, "the frame-generation entry exports ffxConfigure");
return 1;
}
const ULONGLONG until = GetTickCount64() + static_cast<ULONGLONG>(seconds) * 1000ULL;
long long presented = 0;
long long frames = 0;
@@ -3489,6 +3606,16 @@ int HoldPresentingFfx(Gfx& g, int seconds, bool real, int presentsPerEval, FfxTo
} else {
dispatchUp(nullptr, &up.header);
}
if (configureFg != nullptr) {
const uintptr_t loud = 0x1000u + static_cast<uintptr_t>(frameId % 977u) * 0x10u;
cfg.swapChain = reinterpret_cast<void*>(loud);
cfg.presentCallbackUserContext = reinterpret_cast<void*>(loud + 1u);
cfg.frameGenerationCallbackUserContext = reinterpret_cast<void*>(loud + 2u);
cfg.HUDLessColor.resource = reinterpret_cast<void*>(loud + 3u);
cfg.frameID = frameId;
configureFg(nullptr, &cfg.header);
configureFg(nullptr, &otherCfg.header);
}
if (prepare && dispatchFg != nullptr) {
// TWICE, SAME frameID: the SDK's own sample re-issues the prepare when its
// configuration changes, and the vendor's contract is about the INDEX. A
+9
View File
@@ -61,6 +61,15 @@ sl::Constants::orthographicProjection
sl::Constants::motionVectorsDilated
sl::Constants::motionVectorsJittered
# ffxConfigureDescFrameGeneration, how the game configures FSR frame generation (parameter `g`; 0.1.0-beta.43):
# on or off, asynchronous or not, the flags, generated frames only or not, the rectangle generated in. The swapchain,
# the two callbacks and their contexts, the HUD-less resource and the frame id in the same descriptor are not read.
ffxConfigureDescFrameGeneration::frameGenerationEnabled
ffxConfigureDescFrameGeneration::allowAsyncWorkloads
ffxConfigureDescFrameGeneration::flags
ffxConfigureDescFrameGeneration::onlyPresentGenerated
ffxConfigureDescFrameGeneration::generationRect
# The upscaler's memory query: the header's type, the game's out-pointer in either version of the descriptor
# (parameter `q`), and what ffxQuery wrote through it after answering OK (parameter `m`)
ffxQueryDescHeader::type
+7 -3
View File
@@ -17,9 +17,10 @@
1. The reads are in ONE header, src/native/FrameLedger.Overlay/include/fl_adv_fields.h, through parameters with
fixed names - `o` (sl::DLSSOptions), `d` (ffxDispatchDescUpscale), `m` (FfxApiEffectMemoryUsage), `q` (the
memory query's descriptor), `k` (sl::Constants, since 0.1.0-beta.43) and `desc` (a query's header). Every member read through them is on
memory query's descriptor), `k` (sl::Constants) and `g` (ffxConfigureDescFrameGeneration), both since
0.1.0-beta.43, and `desc` (a query's or a configure's header: one type, ffxApiHeader). Every member read through them is on
tools/overlay-allowed-fields.txt, and every name on that list is read.
2. Those parameters are not aliased: each of the five letters appears only as `x.member` or where it is
2. Those parameters are not aliased: each of the six letters appears only as `x.member` or where it is
declared, and `->` is applied to nothing but `desc` and the Overlay's own `region`. So a member cannot be
read under a name this check does not look at.
3. No other source of the Overlay or the Vulkan layer reads a member the list names (the names every struct
@@ -56,6 +57,7 @@ $script:Parameter = [ordered]@{
m = 'FfxApiEffectMemoryUsage'
q = 'ffxQueryDescUpscaleGetGPUMemoryUsage'
k = 'sl::Constants'
g = 'ffxConfigureDescFrameGeneration'
desc = 'ffxQueryDescHeader'
}
@@ -104,7 +106,7 @@ function Get-HeaderRead([string]$Code) {
$reads = [System.Collections.Generic.SortedSet[string]]::new([StringComparer]::Ordinal)
$problems = [System.Collections.Generic.List[string]]::new()
foreach ($m in [regex]::Matches($Code, '(?<![\w.>:])(o|d|m|q|k)\b(\s*\.\s*([A-Za-z_]\w*))?')) {
foreach ($m in [regex]::Matches($Code, '(?<![\w.>:])(o|d|m|q|k|g)\b(\s*\.\s*([A-Za-z_]\w*))?')) {
$name = $m.Groups[1].Value
if ($m.Groups[3].Success) {
[void]$reads.Add("$($script:Parameter[$name])::$($m.Groups[3].Value)")
@@ -215,6 +217,8 @@ inline void Publish(Accumulators& a, FlAdvancedState* region) noexcept { region-
@{ Name = 'a member of sl::Constants the list does not allow FAILS'; Header = $goodHeader + "`ninline void ObserveK(const sl::Constants& k, Accumulators& a) noexcept { a.n.store(k.cameraNear + k.cameraFOV); }"; List = $goodList + "sl::Constants::cameraNear`n"; Other = $goodOther; Expect = 1 },
@{ Name = 'the camera read through the sl::Constants parameter FAILS, listed or not'; Header = $goodHeader + "`ninline void ObserveK(const sl::Constants& k, Accumulators& a) noexcept { a.n.store(k.cameraPos.x); }"; List = $goodList + "sl::Constants::cameraPos`n"; Other = $goodOther; Expect = 2 },
@{ Name = 'the sl::Constants parameter handed on whole FAILS'; Header = $goodHeader + "`ninline void ObserveK(const sl::Constants& k, Accumulators& a) noexcept { a.n.store(k.cameraNear); Other(k); }"; List = $goodList + "sl::Constants::cameraNear`n"; Other = $goodOther; Expect = 1 },
@{ Name = 'the frame-generation configuration read through its parameter, each member on the list, passes'; Header = $goodHeader + "`ninline void ObserveG(const ffxConfigureDescHeader* desc, Accumulators& a) noexcept { const auto& g = *reinterpret_cast<const ffxConfigureDescFrameGeneration*>(desc); a.n.store(g.flags + g.generationRect.left); }"; List = $goodList + "ffxConfigureDescFrameGeneration::flags`nffxConfigureDescFrameGeneration::generationRect`n"; Other = $goodOther; Expect = 0 },
@{ Name = 'a member of the frame-generation configuration the list does not allow FAILS'; Header = $goodHeader + "`ninline void ObserveG(const ffxConfigureDescHeader* desc, Accumulators& a) noexcept { const auto& g = *reinterpret_cast<const ffxConfigureDescFrameGeneration*>(desc); a.n.store(g.flags); Keep(g.swapChain); }"; List = $goodList + "ffxConfigureDescFrameGeneration::flags`n"; Other = $goodOther; Expect = 1 },
@{ Name = 'a header with no read at all FAILS'; Header = '// o.outputWidth is somewhere else'; List = "# nothing`n"; Other = $goodOther; Expect = 1 }
)
foreach ($c in $cases) {