Compare commits

...
Author SHA1 Message Date
poli0981andClaude Fable 5.2 9beaa51a4b feat(overlay): hook slAllocateResources, slFreeResources and slShutdown - a feature's resources allocated and freed and Streamline shut down, counted and nothing else, only once the Agent has asked (beta.45 PR-2; D130)
Three more patch sites on sl.interposer.dll (family bits 20-22), installed only in a process that was asked for
Advanced metrics. The feature's id is the only argument looked at; the command buffer and the viewport are forwarded
and never read. The two that sit on a game's way out note the call and then call the original, and run nothing after
it. Two four-bit counts in word 1 of the feature's slot, and slShutdowns in the first of three reserved words (layout
5 as it was) with FL_ADV_VALID_SL_SHUTDOWN; all three are a session's and a new request clears them.

Measured (the detours' bodies on the headers, the Overlay's flags, 20 M calls x 3): slAllocateResources +0.70/+0.72/
+0.80 ns not asked, +10.43/+10.53/+10.74 asked; slFreeResources +0.61/+0.84/+0.58, +10.33/+10.57/+10.44; slShutdown
within the bench's noise not asked, +3.39/+3.37/+3.52 asked.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 22:05:19 +07:00
13 changed files with 315 additions and 25 deletions

No files matched your search

+5
View File
@@ -45,6 +45,11 @@ numeric core and does not move; the heading is the full version — corrected 20
refuses code that names what identifies it. As with the four hooks before them, none of the three patches is made
in a game no session has asked. Nothing is shown of them yet: the Agent and the App read them in a later pull
request. No layout change (5), no schema change (23).
- **And three more, counted only**: `slAllocateResources`, `slFreeResources` and `slShutdown` — how many times a
game allocated and freed a feature's resources (up to fifteen each) and how many times it shut Streamline down.
The feature's id is the only argument looked at; the two that sit on a game's way out note the call and then
call the original, and run nothing after it. Six new calls in all in this release, each patched only where a
session asked.
- **`slInit` is not hooked, and will not be** (D129). A game starts Streamline once, before FrameLedger can be in
it — also when FrameLedger starts the game itself — so a hook there would be a patch that reads nothing.
+6
View File
@@ -159,6 +159,12 @@ What the region is, as a contract between the two sides:
other bit of the word is a fact about the process and stays, as the slot does. A feature Streamline refused has
a slot with only that word in it. `FL_HOOK_SL_FEATURE_SUPPORTED` (bit 17), `FL_HOOK_SL_FEATURE_LOADED` (18) and
`FL_HOOK_SL_SET_FEATURE_LOADED` (19) are published with their patches.
- **And two counts** (the same release): bits 16..19 of word 1 are how many times the game allocated the feature's
resources (`slAllocateResources`), bits 20..23 how many times it freed them (`slFreeResources`) — each stops at
15 — and `slShutdowns` (@308, taken from the three reserved words that ended the `sl::Constants` line; two remain)
counts `slShutdown` calls, with `FL_ADV_VALID_SL_SHUTDOWN` (bit 6 of the mask) set once one was seen. All three
are a session's and a new request clears them. `FL_HOOK_SL_ALLOCATE_RESOURCES` (bit 20),
`FL_HOOK_SL_FREE_RESOURCES` (21) and `FL_HOOK_SL_SHUTDOWN` (22) are published with their patches.
- 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.
+1
View File
@@ -198,6 +198,7 @@ Every hook must be listed here with a purpose. Anything not on this list is not
| ✅ Streamline: `slSetConstants` (0.1.0-beta.43, Advanced metrics train B; owner decisions D111–D116, D122) | **What the game tells Streamline about a frame**, once per frame and viewport, read from the `sl::Constants` it passes — rule 4: an argument of the call hooked, and of it only the members named here. **Read:** `jitterOffset`, `mvecScale`, `cameraNear`, `cameraFar`, `cameraFOV`, `cameraAspectRatio` and the seven `Boolean`s (`depthInverted`, `cameraMotionIncluded`, `motionVectors3D`, `reset`, `orthographicProjection`, `motionVectorsDilated`, `motionVectorsJittered`). **Never read:** the five matrices (bytes 32..351 of the struct), `cameraPinholeOffset`, and the camera's position and three axes (bytes 368..423) — `tools/overlay-fields-check.ps1` refuses their names anywhere in code loaded into a game, and ctest `fl_adv_fields` publishes two structs that differ in every one of those bytes and gets the same bytes out. **The one row that is not installed unless asked for** (D111): `InstallByFamily` returns before it resolves the symbol in a process the Agent has never asked for Advanced metrics — resolving takes a reference on the module — so with the option off the export's first bytes are the file's (`fl_guard` `[advanced]` reads them from the target). Once asked, the patch goes in on that watchdog tick and stays for the life of the process; the detour forwards without looking while the request is off, and after a stop (`MayObserve`). **Every call** checks the struct's GUID and a `structVersion` of at least 1 before any member is read, and the viewport handle's the same way; every member read is one version 1 carries, so a version-1 struct laid against unreadable memory is read whole without a fault (the same ctest). **Summaries are the first viewport's**: a title with two viewports sets constants for each every frame, and "the last value" across them would flip twice a frame; the call count is of every viewport. `FLT_MAX` is Streamline's "not set" here and is kept nowhere (D119's plane at infinity is FidelityFX's). Family `FL_HOOK_SL_CONSTANTS` (bit 13), published with the patch: it entitles no field of a frame record, and tells "hooked, never called" from "not hooked". **Measured overhead** (the detour's body on the headers, the Overlay's flags, 20 million calls a run, three runs): not asked **+0.57 / +0.60 / +0.58 ns**; asked, the summarised viewport **+19.61 / +19.54 / +19.79 ns**; asked, another viewport +5.83 / +6.01 / +5.62 ns. |
| ✅ Streamline: `slGetFeatureVersion` and `slGetFeatureRequirements` (0.1.0-beta.44, Advanced metrics train B's third step; owner decisions D111–D116, D122) | **What Streamline answers when the game asks about a feature** — which version it is, and what it requires. Two rows, two patches, two detours of one shape: **the original runs first, exactly once, on every path, with both arguments forwarded untouched**, and the struct the game passed is read only when the original said `eOk` — a refusal leaves the struct as the game made it, which is not an answer. Rule 4: an argument of the call hooked, read after the call, and of it only the members named here. **Read from `sl::FeatureVersion`:** `versionSL`, `versionNGX`. **Read from `sl::FeatureRequirements`:** `flags`, `maxNumCPUThreads`, `maxNumViewports`, `numRequiredTags`, `osVersionDetected`, `osVersionRequired`, `driverVersionDetected`, `driverVersionRequired`. **Never read:** `requiredTags` — the pointer the count belongs to — and everything after `driverVersionRequired`: the Vulkan queue counts and the pointers to the names of extensions and features. **No pointer of the game's is followed** (`tools/overlay-fields-check.ps1`, parameters `fv` and `fr`; ctest `fl_adv_fields`: two answers that differ only in those bytes publish the same region, and an answer cut off where the Vulkan members begin, laid against unreadable memory, is read without a fault; the injected `fl_guard` case's stub hands back wild pointers and no fault is counted). **Installed only where asked for** (D111), as `slSetConstants` is: `InstallByFamily` returns before it resolves either symbol in a process the Agent has never asked for Advanced metrics; once in, a patch stays for the life of the process and its detour forwards without looking while the request is off. **They are the first two rows of the table**: a game asks these while it starts, the watchdog patches rows in the table's order, and each patch stops the game's threads for a moment (0.1–0.25 s apart in the owner's logs of 2026-11-12, where `slSetConstants` was the fifth Streamline patch in, 1.9–7.8 s after the attach). In a process never asked they are passed over and the order changes nothing. ~~**Most sessions will still have missed the calls** — an attach after the game's start-up is the usual case — and the session then says the call was hooked and the game did not ask again.~~ *(Measured 2026-11-12, the owner's eight sessions on beta.44: both calls were read in six of six Streamline sessions on five games — Unreal's Streamline plugin asks again after the attach, Cyberpunk 2077 asks again for requirements and not for versions. A game that asks only while starting still reads "hooked, not asked again".)* Three conditions before a read, as for `slSetConstants`: the Agent is asking, observing has not stopped, and the struct carries its own GUID and a version of at least 1 on this call (a struct with another GUID is not kept: the injected case sends one). Every member read is version 1's (§Which struct version carries which field). **Twelve slots** in region 5 (`FlAdvancedState.features`, layout 5 as it was), one per feature in the order first asked about; the last answer about a feature is the one kept; a thirteenth feature is not kept. **A new request does not empty them**: what version a feature is and what it requires are facts about the process, and a second session of a game that kept running would otherwise have nothing where the first had the answer — the one group `Reset` leaves, with its bit of the mask. Streamline 1.x is refused before anything is resolved (`SpeaksStreamline2`). Families `FL_HOOK_SL_FEATURE_VERSION` (bit 15) and `FL_HOOK_SL_FEATURE_REQUIREMENTS` (bit 16), each published with its patch; neither entitles a field of a frame record. **Measured overhead** (the detours' bodies on the headers, the Overlay's flags, 20 million calls a run, three runs, eight features asked about in turn): the version — not asked **+0.58 / +0.61 / +0.58 ns**, asked **+14.82 / +14.54 / +14.47 ns**; the requirements — not asked **+0.58 / +0.63 / +0.61 ns**, asked **+20.88 / +21.01 / +20.96 ns**. A game makes these calls a handful of times. |
| ✅ Streamline: `slIsFeatureSupported`, `slIsFeatureLoaded`, `slSetFeatureLoaded` (0.1.0-beta.45; owner decisions D129–D131) | **Whether a feature is supported, whether it is loaded, and the game switching it on and off.** Three rows, three patches. Rule 4: bare arguments and results of the calls hooked, and no vendor struct at all — the feature's id; the `sl::Result` `slIsFeatureSupported` returned, **every result**, since a refusal is the answer to that question (the original runs first, both arguments forwarded untouched); the `bool` `slIsFeatureLoaded` wrote, read only when it returned `eOk`; the `bool` the game passed to `slSetFeatureLoaded`, noted before the call. **The adapter `slIsFeatureSupported` is asked about is never read** (D131): `sl::AdapterInfo` holds the adapter's LUID or a Vulkan physical device; the detour forwards the reference and `tools/overlay-fields-check.ps1` refuses the names of its members (`deviceLUID`, `deviceLUIDSizeInBytes`, `vkPhysicalDevice`) anywhere in the Overlay and the Vulkan layer — the fixture's adapter carries a wild pointer. **Installed only where asked for** (D111), as the four rows before them. `slIsFeatureSupported` and `slIsFeatureLoaded` follow the two rows of beta.44 at the head of the table; `slSetFeatureLoaded` follows `slSetConstants`. **Kept in word 1 of the feature's slot** (region 5, layout 5 as it was): bit 2 and the result in bits 8..15, bits 3 and 4, bits 5 and 6 — the last two a session's, cleared by a new request; the rest the process's, kept (`fl_adv_fields.h` `kFeatureSessionBits`). A refused feature therefore has a slot now, with nothing in it but that word. The declarations of the three functions are the same from Streamline v2.0.0 to v2.14.16, and `sl::Result` is the same forty codes in the same order at all sixteen tags (`include/sl_result.h`, `05a3c7e3889c` … `8a844b68ff55`), so a code means the same whatever interposer answered. Families `FL_HOOK_SL_FEATURE_SUPPORTED` (bit 17), `FL_HOOK_SL_FEATURE_LOADED` (18), `FL_HOOK_SL_SET_FEATURE_LOADED` (19), each published with its patch. **Measured overhead** (the detours' bodies on the headers, the Overlay's flags, 20 million calls a run, three runs, eight features in turn): `slIsFeatureSupported` — not asked **+1.50 / +1.48 / +1.50 ns**, asked **+11.97 / +11.98 / +12.08 ns**; `slIsFeatureLoaded` — **+1.79 / +1.77 / +1.89 ns**, **+12.35 / +12.31 / +12.33 ns**; `slSetFeatureLoaded` — **+1.44 / +1.47 / +1.80 ns**, **+11.28 / +11.54 / +11.45 ns**. **`slInit` is not a row and will not be** (D129): a game calls it once, before the Overlay is in the process or before a patch can land — launch mode waits for the presentation runtime before it injects, nothing is ever patched on a game's thread (§H2), and a row that exists only for Advanced metrics waits for the Agent's request. **A stop takes about 160 ms for every patch it restores** (measured on the fixture, 0.1.0-beta.45: each `MH_DisableHook` snapshots the system's threads): twelve patches took 1.9 s, fifteen 2.4 s, and the watchdog's wait for the stop's log lines, 2 s until then, is now a quarter of a second for every patch the registry can hold. |
| ✅ Streamline: `slAllocateResources`, `slFreeResources`, `slShutdown` (0.1.0-beta.45; owner decision D130) | **The game allocating and freeing a feature's resources, and shutting Streamline down — counted, and nothing else.** Three rows, three patches. Rule 4: the feature's id is the only argument looked at; the command buffer and the viewport of the two resource calls are forwarded and never read (the fixture's command buffer is a wild pointer), and `slShutdown` has no argument. **`slFreeResources` and `slShutdown` are on a game's way out**: each detour notes the call first and then calls the original, exactly once, and runs nothing of ours after it returns; the fixture goes on calling the stub after `slShutdown`, through every detour. **Installed only where asked for** (D111); the last three Streamline rows of the table. **Kept** in word 1 of the feature's slot as two four-bit counts — allocations in bits 16..19, frees in 20..23, each stopping at 15 and never carrying into its neighbour — and, for `slShutdown`, in `FlAdvancedState.slShutdowns` (@308, the first of three reserved words; layout 5 as it was) with `FL_ADV_VALID_SL_SHUTDOWN` (bit 6 of the mask). All three are a session's: a new request clears them. Families `FL_HOOK_SL_ALLOCATE_RESOURCES` (bit 20), `FL_HOOK_SL_FREE_RESOURCES` (21), `FL_HOOK_SL_SHUTDOWN` (22). The three declarations are the same from Streamline v2.0.0 to v2.14.16. **Measured overhead** (the detours' bodies on the headers, the Overlay's flags, 20 million calls a run, three runs): `slAllocateResources` — not asked **+0.70 / +0.72 / +0.80 ns**, asked **+10.43 / +10.53 / +10.74 ns**; `slFreeResources` — **+0.61 / +0.84 / +0.58 ns**, **+10.33 / +10.57 / +10.44 ns**; `slShutdown` — not asked within the bench's noise (+0.06 / −0.12 / +0.04 ns), asked **+3.39 / +3.37 / +3.52 ns**. Inventory 23 → 26 rows; a Streamline title with Advanced metrics asked for now carries thirteen patches on the interposer, and a stop restores each in about 160 ms (the row above). |
| ✅ Streamline: `slSetTag` — **and, since 2026-09-05, every tag's TYPE** (`slTagCensus`; a HUD-less / UI tag marks the present `FL_FG_DLSS_G`, rule 4: the same argument) | The **global** resource tags, where a title states the size of the buffer it is upscaling *from*: `kBufferTypeScalingInputColor`'s extent → `renderW/H` — **or, since 2026-09-05, the size the tagged `sl::Resource` declares when the extent is zero** (`TagSize` in `fl_sl_inputs.h`, shared by all three tag routes; GUID-checked; a Resource declaring no size is still the honest unknown). **Built 2026-08-15** (`FL_HOOK_UPSCALER_PARAMS`), and it is an ALTERNATIVE to the local tags in `slEvaluateFeature`'s `inputs`, not a layer over them — `sl_core_api.h:258` says global and local tags "do NOT interact", so a title using one yields nothing from the other and both are read. Published only on a frame where an evaluation was also seen, because a tag is viewport state that outlives any one frame. This row was MISSING from this table while the hook shipped, which is the gap the banner above now names |
| ✅ Streamline: `slSetTagForFrame` — **and every tag's TYPE, as above** | The same global tags through **Streamline 2.8's frame-based entry point**, which deprecates `slSetTag`: `(const FrameToken&, const ViewportHandle&, const ResourceTag*, uint32_t, CommandBuffer*)` — the token first, then exactly `slSetTag`'s list, handed to the same tag walk. **Built 2026-09-04** (`FL_HOOK_UPSCALER_PARAMS`, its own trampoline; the family is now **published when whole** — once every tag export the loaded interposer has is patched — because publishing on the first row entitled records the second was not yet producing, 38 of 41 on the fixture: the ffx leaves' #110 defect again, fixed the same way). Measured need: Dying Light: The Beast (SL 2.8.0) published `Dlss` identity on every batch and the params bit on none across three captures, because a 2.8 title that tags per frame never calls the deprecated export. The token is not read; the frame count stays with `slGetNewFrameToken`. The installer picks this detour by SYMBOL (`kSymbolSlSetTagForFrame`, bound to the row by `static_assert`), not by family, since the two rows share a family bit and differ in signature |
| ✅ **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
@@ -50,4 +50,13 @@ public enum HookFamilies
/// <summary><c>slSetFeatureLoaded</c> is hooked (0.1.0-beta.45) - only where Advanced metrics was ever asked for.</summary>
SlSetFeatureLoaded = 1 << 19,
/// <summary><c>slAllocateResources</c> is hooked (0.1.0-beta.45) - only where Advanced metrics was ever asked for.</summary>
SlAllocateResources = 1 << 20,
/// <summary><c>slFreeResources</c> is hooked (0.1.0-beta.45) - only where Advanced metrics was ever asked for.</summary>
SlFreeResources = 1 << 21,
/// <summary><c>slShutdown</c> is hooked (0.1.0-beta.45) - only where Advanced metrics was ever asked for.</summary>
SlShutdown = 1 << 22,
}
+16 -1
View File
@@ -314,6 +314,15 @@ public enum FlHookFamily : uint
/// <summary><c>slSetFeatureLoaded</c> is hooked (0.1.0-beta.45), under the same conditions.</summary>
SlSetFeatureLoaded = 1u << 19,
/// <summary><c>slAllocateResources</c> is hooked (0.1.0-beta.45), under the same conditions.</summary>
SlAllocateResources = 1u << 20,
/// <summary><c>slFreeResources</c> is hooked (0.1.0-beta.45), under the same conditions.</summary>
SlFreeResources = 1u << 21,
/// <summary><c>slShutdown</c> is hooked (0.1.0-beta.45), under the same conditions.</summary>
SlShutdown = 1u << 22,
}
/// <summary>
@@ -797,6 +806,9 @@ public enum FlAdvancedValid : uint
/// <summary>0.1.0-beta.44 (D118, D122): at least one feature slot is filled.</summary>
SlFeatures = 1u << 5,
/// <summary>0.1.0-beta.45: <c>slShutdown</c> was seen; <see cref="FlAdvancedState.SlShutdowns"/> counts.</summary>
SlShutdown = 1u << 6,
}
/// <summary>
@@ -989,8 +1001,11 @@ public unsafe struct FlAdvancedState
public uint SlFlagsSeenFalse;
/// <summary><c>slShutdown</c> calls since the request (0.1.0-beta.45; the word was the first of three reserved).</summary>
public uint SlShutdowns;
/// <summary>Must be zero.</summary>
public fixed uint ReservedSl[3];
public fixed uint ReservedSl[2];
/// <summary><see cref="FeatureSlots"/> slots of <see cref="FeatureWords"/> words each (0.1.0-beta.44).</summary>
public fixed uint Features[FeatureSlots * FeatureWords];
@@ -192,6 +192,9 @@ struct Accumulators {
// What Streamline answered about each feature the game asked about (0.1.0-beta.44): FL_ADV_FEATURE_SLOTS slots
// of FL_ADV_FEATURE_WORDS words, laid out as the region's `features` (fl_shm.h). Kept across a new request.
std::atomic<uint32_t> features[FL_ADV_FEATURE_SLOTS * FL_ADV_FEATURE_WORDS]{};
// slShutdown calls since the request (0.1.0-beta.45)
std::atomic<uint32_t> slShutdowns{0u};
};
// Word 1 of a feature slot: which of the two questions has an answer in it.
@@ -208,7 +211,13 @@ inline constexpr uint32_t kFeatureSupportResultShift = 8u;
inline constexpr uint32_t kFeatureSupportResultMask = 0xFFu << kFeatureSupportResultShift;
// What of word 1 is a SESSION's -- what the game did while it was watched -- and is cleared by a new request. The
// rest is a fact about the process (which version, what it requires, whether it is supported and loaded) and stays.
inline constexpr uint32_t kFeatureSessionBits = kFeatureSwitchedOff | kFeatureSwitchedOn;
// How many times the game allocated and freed the feature's resources: four bits each, stopping at 15.
inline constexpr uint32_t kFeatureAllocShift = 16u;
inline constexpr uint32_t kFeatureFreeShift = 20u;
inline constexpr uint32_t kFeatureCountMask = 0xFu;
inline constexpr uint32_t kFeatureSessionBits = kFeatureSwitchedOff | kFeatureSwitchedOn |
(kFeatureCountMask << kFeatureAllocShift) |
(kFeatureCountMask << kFeatureFreeShift);
// Whether `leaf` is the module whose calls a summary counts: the first one seen, and
// from then on only it. A title that goes through the loader has the same call
@@ -595,6 +604,42 @@ inline void ObserveSlSetFeatureLoaded(uint32_t feature, bool loaded, Accumulator
NoteBits(a.validMask, FL_ADV_VALID_SL_FEATURES);
}
// One more in a four-bit count of a slot's word 1, which stops at 15 and never carries into its neighbour.
inline void BumpCount(std::atomic<uint32_t>& word, uint32_t shift) noexcept {
uint32_t seen = word.load(std::memory_order_relaxed);
while (((seen >> shift) & kFeatureCountMask) != kFeatureCountMask) {
if (word.compare_exchange_weak(seen, seen + (1u << shift), std::memory_order_relaxed)) {
break;
}
}
}
// The game allocating, and freeing, a feature's resources (0.1.0-beta.45): counted for the feature and nothing else
// -- the command buffer and the viewport of the same calls are not arguments of these functions.
inline void ObserveSlAllocateResources(uint32_t feature, Accumulators& a) noexcept {
std::atomic<uint32_t>* slot = FeatureSlot(feature, a);
if (slot == nullptr) {
return;
}
BumpCount(slot[1], kFeatureAllocShift);
NoteBits(a.validMask, FL_ADV_VALID_SL_FEATURES);
}
inline void ObserveSlFreeResources(uint32_t feature, Accumulators& a) noexcept {
std::atomic<uint32_t>* slot = FeatureSlot(feature, a);
if (slot == nullptr) {
return;
}
BumpCount(slot[1], kFeatureFreeShift);
NoteBits(a.validMask, FL_ADV_VALID_SL_FEATURES);
}
// The game shutting Streamline down (0.1.0-beta.45): a count.
inline void ObserveSlShutdown(Accumulators& a) noexcept {
a.slShutdowns.fetch_add(1u, std::memory_order_relaxed);
NoteBits(a.validMask, FL_ADV_VALID_SL_SHUTDOWN);
}
// A NEW REQUEST: the summaries start afresh, so a session's ranges, masks and
// counts are its own and not those of the session before it in the same game.
// THE WATCHDOG'S. A detour running beside it loses nothing that matters: what it
@@ -656,6 +701,7 @@ inline void Reset(Accumulators& a) noexcept {
a.slAspectBits.store(FL_ADV_FLOAT_NONE, relaxed);
a.slFlagsSeenTrue.store(0u, relaxed);
a.slFlagsSeenFalse.store(0u, relaxed);
a.slShutdowns.store(0u, relaxed);
// The feature slots stay; what of their word 1 is a session's does not (0.1.0-beta.45).
for (uint32_t i = 0; i < FL_ADV_FEATURE_SLOTS; ++i) {
std::atomic<uint32_t>* slot = &a.features[static_cast<size_t>(i) * FL_ADV_FEATURE_WORDS];
@@ -757,6 +803,7 @@ inline void Publish(Accumulators& a, FlAdvancedState* region, uint32_t request,
put32(region->slAspectBits, a.slAspectBits.load(relaxed));
put32(region->slFlagsSeenTrue, a.slFlagsSeenTrue.load(relaxed));
put32(region->slFlagsSeenFalse, a.slFlagsSeenFalse.load(relaxed));
put32(region->slShutdowns, a.slShutdowns.load(relaxed));
for (uint32_t i = 0; i < FL_ADV_FEATURE_SLOTS * FL_ADV_FEATURE_WORDS; ++i) {
put32(region->features[i], a.features[i].load(relaxed));
@@ -128,7 +128,9 @@ inline constexpr uint32_t kFamiliesEvaluateFeatureDoesNotImplement =
static_cast<uint32_t>(fl::FL_HOOK_FFX_CONFIGURE) | static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_VERSION) |
static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_REQUIREMENTS) |
static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_SUPPORTED) | static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_LOADED) |
static_cast<uint32_t>(fl::FL_HOOK_SL_SET_FEATURE_LOADED);
static_cast<uint32_t>(fl::FL_HOOK_SL_SET_FEATURE_LOADED) |
static_cast<uint32_t>(fl::FL_HOOK_SL_ALLOCATE_RESOURCES) | static_cast<uint32_t>(fl::FL_HOOK_SL_FREE_RESOURCES) |
static_cast<uint32_t>(fl::FL_HOOK_SL_SHUTDOWN);
static_assert((kFamilyEvaluateFeature & kFamiliesEvaluateFeatureDoesNotImplement) == 0u,
"the slEvaluateFeature row claims a family its detour does not implement -- hookinventory-check "
@@ -215,7 +217,9 @@ inline constexpr uint32_t kFamiliesFfxDispatchDoesNotImplement =
static_cast<uint32_t>(fl::FL_HOOK_SL_CONSTANTS) | static_cast<uint32_t>(fl::FL_HOOK_FFX_CONFIGURE) |
static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_VERSION) | static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_REQUIREMENTS) |
static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_SUPPORTED) | static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_LOADED) |
static_cast<uint32_t>(fl::FL_HOOK_SL_SET_FEATURE_LOADED);
static_cast<uint32_t>(fl::FL_HOOK_SL_SET_FEATURE_LOADED) |
static_cast<uint32_t>(fl::FL_HOOK_SL_ALLOCATE_RESOURCES) | static_cast<uint32_t>(fl::FL_HOOK_SL_FREE_RESOURCES) |
static_cast<uint32_t>(fl::FL_HOOK_SL_SHUTDOWN);
static_assert((kFamilyFfxDispatch & kFamiliesFfxDispatchDoesNotImplement) == 0u,
"the ffxDispatch rows claim a family their detour does not implement -- hookinventory-check reads "
@@ -358,18 +362,31 @@ inline constexpr uint32_t kFamilySlFeatureLoaded = static_cast<uint32_t>(fl::FL_
inline constexpr uint32_t kFamilySlSetFeatureLoaded = static_cast<uint32_t>(fl::FL_HOOK_SL_SET_FEATURE_LOADED);
// One bit each, and no earlier family holds any of them: InstallByFamily binds a row by EQUALITY on its family, so
// a value shared with another row would hand one export's detour to another.
inline constexpr uint32_t kFamiliesOfBeta45FeatureState =
kFamilySlFeatureSupported | kFamilySlFeatureLoaded | kFamilySlSetFeatureLoaded;
//
// slAllocateResources, slFreeResources, slShutdown (the same release): COUNTED, AND NOTHING ELSE. The feature's id
// is the only argument looked at -- never the command buffer, never the viewport. slFreeResources and slShutdown
// are on a game's way out: their detours note the call and then call the original, exactly once, and touch nothing
// after it returns.
inline constexpr uint32_t kFamilySlAllocateResources = static_cast<uint32_t>(fl::FL_HOOK_SL_ALLOCATE_RESOURCES);
inline constexpr uint32_t kFamilySlFreeResources = static_cast<uint32_t>(fl::FL_HOOK_SL_FREE_RESOURCES);
inline constexpr uint32_t kFamilySlShutdown = static_cast<uint32_t>(fl::FL_HOOK_SL_SHUTDOWN);
inline constexpr uint32_t kFamiliesOfBeta45FeatureState = kFamilySlFeatureSupported | kFamilySlFeatureLoaded |
kFamilySlSetFeatureLoaded | kFamilySlAllocateResources |
kFamilySlFreeResources | kFamilySlShutdown;
static_assert(kFamilySlFeatureSupported != kFamilySlFeatureLoaded &&
kFamilySlFeatureSupported != kFamilySlSetFeatureLoaded &&
kFamilySlFeatureLoaded != kFamilySlSetFeatureLoaded,
"three rows, three detours, three different families");
kFamilySlFeatureLoaded != kFamilySlSetFeatureLoaded &&
kFamilySlAllocateResources != kFamilySlFreeResources &&
kFamilySlAllocateResources != kFamilySlShutdown && kFamilySlFreeResources != kFamilySlShutdown &&
((kFamilySlFeatureSupported | kFamilySlFeatureLoaded | kFamilySlSetFeatureLoaded) &
(kFamilySlAllocateResources | kFamilySlFreeResources | kFamilySlShutdown)) == 0u,
"six rows, six detours, six different families");
static_assert(((kFamilyEvaluateFeature | kFamilyFfxDispatch | kFamilyFfxQuery | kFamilySlConstants |
kFamilySlFeatureVersion | kFamilySlFeatureRequirements |
static_cast<uint32_t>(fl::FL_HOOK_UPSCALER_PARAMS) |
static_cast<uint32_t>(fl::FL_HOOK_FG_EVALUATIONS)) &
kFamiliesOfBeta45FeatureState) == 0u,
"an earlier family claims a bit of slIsFeatureSupported, slIsFeatureLoaded or slSetFeatureLoaded");
"an earlier family claims a bit of one of the six rows of 0.1.0-beta.45");
// --- AMD FidelityFX: ffxConfigure on the same four modules (0.1.0-beta.43, Advanced metrics train B) ---
//
@@ -496,6 +513,9 @@ inline int FfxLeafOf(const wchar_t* moduleName) noexcept {
X(L"sl.interposer.dll", "slGetNewFrameToken", fl::FL_HOOK_FG_EVALUATIONS) \
X(L"sl.interposer.dll", "slSetConstants", fl::inventory::kFamilySlConstants) \
X(L"sl.interposer.dll", "slSetFeatureLoaded", fl::inventory::kFamilySlSetFeatureLoaded) \
X(L"sl.interposer.dll", "slAllocateResources", fl::inventory::kFamilySlAllocateResources) \
X(L"sl.interposer.dll", "slFreeResources", fl::inventory::kFamilySlFreeResources) \
X(L"sl.interposer.dll", "slShutdown", fl::inventory::kFamilySlShutdown) \
X(L"amd_fidelityfx_dx12.dll", "ffxDispatch", fl::inventory::kFamilyFfxDispatch) \
X(L"amd_fidelityfx_upscaler_dx12.dll", "ffxDispatch", fl::inventory::kFamilyFfxDispatch) \
X(L"amd_fidelityfx_framegeneration_dx12.dll", "ffxDispatch", fl::inventory::kFamilyFfxDispatch) \
@@ -515,7 +535,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 == 23u, "a row was added or removed: say so here, and in 17_HOOK_ENGINE §Hook inventory");
static_assert(kRowCount == 26u, "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
+66 -1
View File
@@ -1195,7 +1195,18 @@ PFN_SlSetFeatureLoaded g_origSlSetFeatureLoaded = nullptr;
std::atomic<uint32_t> g_slFeatureSupportedLive{0};
std::atomic<uint32_t> g_slFeatureLoadedLive{0};
std::atomic<uint32_t> g_slSetFeatureLoadedLive{0};
std::atomic<uint32_t> g_frameTokens{0};
// slAllocateResources, slFreeResources, slShutdown (0.1.0-beta.45): the same terms.
using PFN_SlAllocateResources = ::PFun_slAllocateResources*;
using PFN_SlFreeResources = ::PFun_slFreeResources*;
using PFN_SlShutdown = ::PFun_slShutdown*;
PFN_SlAllocateResources g_origSlAllocateResources = nullptr;
PFN_SlFreeResources g_origSlFreeResources = nullptr;
PFN_SlShutdown g_origSlShutdown = nullptr;
std::atomic<uint32_t> g_slAllocateResourcesLive{0};
std::atomic<uint32_t> g_slFreeResourcesLive{0};
std::atomic<uint32_t> g_slShutdownLive{0};
std::atomic<uint32_t> g_frameTokens{0};
// The HIGHEST frame index seen so far, tagged in bit 32 so that index 0 is
// distinct from "no frame yet". Measured 2026-09-03 on Cyberpunk 2077
// (20_OPEN_QUESTIONS §S31, row P4): the title asks for a token 3 to 4.6 times per
@@ -1848,6 +1859,39 @@ sl::Result STDMETHODCALLTYPE Hook_SlSetFeatureLoaded(sl::Feature feature, bool l
return g_origSlSetFeatureLoaded(feature, loaded);
}
// The game allocating a feature's resources (0.1.0-beta.45): counted for the feature. The command buffer and the
// viewport are forwarded and not looked at. The original is called exactly once, on every path.
sl::Result STDMETHODCALLTYPE Hook_SlAllocateResources(sl::CommandBuffer* cmdBuffer, sl::Feature feature,
const sl::ViewportHandle& viewport) {
FL_HOOK_GUARD({
if (g_advancedRequested.load(std::memory_order_relaxed) != 0u && MayObserve()) {
fl::adv::ObserveSlAllocateResources(static_cast<uint32_t>(feature), g_adv);
}
})
return g_origSlAllocateResources(cmdBuffer, feature, viewport);
}
// The game freeing them (0.1.0-beta.45). ON A GAME'S WAY OUT, as slShutdown below is: the call is noted BEFORE the
// original, and nothing of ours runs after it returns.
sl::Result STDMETHODCALLTYPE Hook_SlFreeResources(sl::Feature feature, const sl::ViewportHandle& viewport) {
FL_HOOK_GUARD({
if (g_advancedRequested.load(std::memory_order_relaxed) != 0u && MayObserve()) {
fl::adv::ObserveSlFreeResources(static_cast<uint32_t>(feature), g_adv);
}
})
return g_origSlFreeResources(feature, viewport);
}
// The game shutting Streamline down (0.1.0-beta.45): a count, taken before the original runs.
sl::Result STDMETHODCALLTYPE Hook_SlShutdown() {
FL_HOOK_GUARD({
if (g_advancedRequested.load(std::memory_order_relaxed) != 0u && MayObserve()) {
fl::adv::ObserveSlShutdown(g_adv);
}
})
return g_origSlShutdown();
}
// slSetTagForFrame: the FrameToken first, then the same list slSetTag takes. The
// token is not read -- the frame count comes from slGetNewFrameToken -- and the tag
// list is handed to the same NoteTags, because a per-frame tag and a viewport tag
@@ -2637,6 +2681,27 @@ bool InstallByFamily(const wchar_t* moduleName, const char* symbol, uint32_t fam
return InstallRow(moduleName, symbol, family, reinterpret_cast<void*>(&Hook_SlSetFeatureLoaded),
reinterpret_cast<void**>(&g_origSlSetFeatureLoaded), g_slSetFeatureLoadedLive, name);
}
if (family == fl::inventory::kFamilySlAllocateResources) {
if (g_advancedSeen == 0u) {
return false;
}
return InstallRow(moduleName, symbol, family, reinterpret_cast<void*>(&Hook_SlAllocateResources),
reinterpret_cast<void**>(&g_origSlAllocateResources), g_slAllocateResourcesLive, name);
}
if (family == fl::inventory::kFamilySlFreeResources) {
if (g_advancedSeen == 0u) {
return false;
}
return InstallRow(moduleName, symbol, family, reinterpret_cast<void*>(&Hook_SlFreeResources),
reinterpret_cast<void**>(&g_origSlFreeResources), g_slFreeResourcesLive, name);
}
if (family == fl::inventory::kFamilySlShutdown) {
if (g_advancedSeen == 0u) {
return false;
}
return InstallRow(moduleName, symbol, family, reinterpret_cast<void*>(&Hook_SlShutdown),
reinterpret_cast<void**>(&g_origSlShutdown), g_slShutdownLive, name);
}
if (family == fl::inventory::kFamilyFfxConfigure) {
if (g_advancedSeen == 0u) {
return false;
+12 -3
View File
@@ -428,6 +428,10 @@ enum FlHookFamily : uint32_t {
FL_HOOK_SL_FEATURE_SUPPORTED = 1u << 17,
FL_HOOK_SL_FEATURE_LOADED = 1u << 18,
FL_HOOK_SL_SET_FEATURE_LOADED = 1u << 19,
// And the last three of 0.1.0-beta.45: slAllocateResources, slFreeResources, slShutdown -- counted, nothing more.
FL_HOOK_SL_ALLOCATE_RESOURCES = 1u << 20,
FL_HOOK_SL_FREE_RESOURCES = 1u << 21,
FL_HOOK_SL_SHUTDOWN = 1u << 22,
};
// FlWriterState::runtimeCensus -- which vendor RUNTIME MODULES the loader reported
@@ -963,6 +967,7 @@ enum FlAdvancedValid : uint32_t {
FL_ADV_VALID_FFX_FG_CONFIG = 1u << 3, // (0.1.0-beta.43) ffxConfigure with a frame-generation descriptor seen
FL_ADV_VALID_SL_CONSTANTS = 1u << 4, // (0.1.0-beta.43) slSetConstants seen
FL_ADV_VALID_SL_FEATURES = 1u << 5, // (0.1.0-beta.44) at least one feature slot filled
FL_ADV_VALID_SL_SHUTDOWN = 1u << 6, // (0.1.0-beta.45) slShutdown seen; slShutdowns counts
};
// A float nobody saw. An all-ones pattern is a NaN no detour stores: every value is checked finite first -- with the
@@ -987,7 +992,9 @@ enum FlAdvancedValid : uint32_t {
// (0.1.0-beta.45) bit 2: slIsFeatureSupported answered, and bits 8..15 the sl::Result it gave (0 = eOk;
// 0xFF = a code a byte cannot carry); bit 3: slIsFeatureLoaded answered, bit 4 what it said;
// bit 5: the game was seen to switch the feature OFF (slSetFeatureLoaded), bit 6: ON -- these two are a
// session's and are cleared by a new request; the rest are the process's and stay
// session's and are cleared by a new request; the rest are the process's and stay.
// bits 16..19: slAllocateResources calls for the feature, bits 20..23: slFreeResources calls -- each
// stops at 15, and both are a session's
// [2..4] versionSL major, minor, build [5..7] versionNGX
// [8] FeatureRequirementFlags [9] maxNumCPUThreads
// [10] maxNumViewports [11] numRequiredTags
@@ -1067,7 +1074,8 @@ struct alignas(64) FlAdvancedState {
// reset, orthographicProjection, motionVectorsDilated, motionVectorsJittered.
uint32_t slFlagsSeenTrue; // @300
uint32_t slFlagsSeenFalse; // @304
uint32_t reservedSl[3]; // @308..319 must be zero
uint32_t slShutdowns; // @308 (beta.45) slShutdown calls since the request (wraps)
uint32_t reservedSl[2]; // @312..319 must be zero
// ---- lines 5..22: Streamline's features (beta.44) --------------------------------------------------------------
uint32_t features[FL_ADV_FEATURE_SLOTS * FL_ADV_FEATURE_WORDS]; // @320..1471
@@ -1342,7 +1350,8 @@ static_assert(offsetof(FlAdvancedState, ffxFgRect) == 232);
static_assert(offsetof(FlAdvancedState, reservedFfx) == 248);
static_assert(offsetof(FlAdvancedState, slConstantsCalls) == 256);
static_assert(offsetof(FlAdvancedState, slFlagsSeenFalse) == 304);
static_assert(offsetof(FlAdvancedState, reservedSl) == 308);
static_assert(offsetof(FlAdvancedState, slShutdowns) == 308);
static_assert(offsetof(FlAdvancedState, reservedSl) == 312);
static_assert(offsetof(FlAdvancedState, features) == 320);
static_assert(offsetof(FlAdvancedState, sampleQpc) % 8 == 0 && offsetof(FlAdvancedState, ffxMemoryTotalBytes) % 8 == 0);
static_assert(FL_ADV_FEATURE_SLOTS * FL_ADV_FEATURE_WORDS * sizeof(uint32_t) == 1152);
+40 -10
View File
@@ -7073,10 +7073,21 @@ const uint32_t* FeatureSlotOf(const fl::FlAdvancedState& a, uint32_t feature) {
return nullptr;
}
// Word 1 of the slot region 5 holds for `feature`; 0 where it holds none.
// The ANSWERS in word 1 of the slot region 5 holds for `feature` -- its low sixteen bits; 0 where it holds none.
// The two four-bit counts above them (allocations in bits 16..19, frees in 20..23) grow while the target runs.
uint32_t FeatureWord1(const fl::FlAdvancedState& a, uint32_t feature) {
const uint32_t* slot = FeatureSlotOf(a, feature);
return slot == nullptr ? 0u : slot[1];
return slot == nullptr ? 0u : slot[1] & 0xFFFFu;
}
uint32_t FeatureAllocations(const fl::FlAdvancedState& a, uint32_t feature) {
const uint32_t* slot = FeatureSlotOf(a, feature);
return slot == nullptr ? 0u : (slot[1] >> 16) & 0xFu;
}
uint32_t FeatureFrees(const fl::FlAdvancedState& a, uint32_t feature) {
const uint32_t* slot = FeatureSlotOf(a, feature);
return slot == nullptr ? 0u : (slot[1] >> 20) & 0xFu;
}
// A slot's words 1..23 against "both questions of beta.44 answered" and the stub's numbers.
@@ -7370,12 +7381,15 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation,
const auto slFeatureState = static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_SUPPORTED) |
static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_LOADED) |
static_cast<uint32_t>(fl::FL_HOOK_SL_SET_FEATURE_LOADED);
constexpr int kFeatureExports = 5;
const char* const featureExports[kFeatureExports] = {"slGetFeatureVersion", "slGetFeatureRequirements",
"slIsFeatureSupported", "slIsFeatureLoaded",
"slSetFeatureLoaded"};
unsigned char featurePristine[kFeatureExports][16]{};
unsigned char featureNow[16]{};
const auto slCounted = static_cast<uint32_t>(fl::FL_HOOK_SL_ALLOCATE_RESOURCES) |
static_cast<uint32_t>(fl::FL_HOOK_SL_FREE_RESOURCES) |
static_cast<uint32_t>(fl::FL_HOOK_SL_SHUTDOWN);
constexpr int kFeatureExports = 8;
const char* const featureExports[kFeatureExports] = {
"slGetFeatureVersion", "slGetFeatureRequirements", "slIsFeatureSupported", "slIsFeatureLoaded",
"slSetFeatureLoaded", "slAllocateResources", "slFreeResources", "slShutdown"};
unsigned char featurePristine[kFeatureExports][16]{};
unsigned char featureNow[16]{};
// ---- 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.
@@ -7391,6 +7405,7 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation,
CHECK((r.st->hooksInstalledMask & slConstants) == 0u);
CHECK((r.st->hooksInstalledMask & slFeatures) == 0u);
CHECK((r.st->hooksInstalledMask & slFeatureState) == 0u);
CHECK((r.st->hooksInstalledMask & slCounted) == 0u);
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_SL_INTERPOSER, "slSetConstants", now));
CHECK(std::memcmp(pristine, now, sizeof(now)) == 0);
for (int i = 0; i < kFeatureExports; ++i) {
@@ -7408,6 +7423,9 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation,
REQUIRE(WaitForHookFamily(r.st, static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_SUPPORTED)));
REQUIRE(WaitForHookFamily(r.st, static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_LOADED)));
REQUIRE(WaitForHookFamily(r.st, static_cast<uint32_t>(fl::FL_HOOK_SL_SET_FEATURE_LOADED)));
REQUIRE(WaitForHookFamily(r.st, static_cast<uint32_t>(fl::FL_HOOK_SL_ALLOCATE_RESOURCES)));
REQUIRE(WaitForHookFamily(r.st, static_cast<uint32_t>(fl::FL_HOOK_SL_FREE_RESOURCES)));
REQUIRE(WaitForHookFamily(r.st, static_cast<uint32_t>(fl::FL_HOOK_SL_SHUTDOWN)));
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_SL_INTERPOSER, "slSetConstants", now));
CHECK(std::memcmp(pristine, now, sizeof(now)) != 0); // patched now
for (int i = 0; i < kFeatureExports; ++i) {
@@ -7425,14 +7443,15 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation,
!FeatureSlotIs(FeatureSlotOf(a, kFeatureIdDlssG), kAdvFeatureDlssG) ||
FeatureWord1(a, kFeatureIdDlssG) != kAdvFeatureWord1DlssG ||
FeatureWord1(a, kFeatureIdDlss) != kAdvFeatureWord1Dlss ||
FeatureWord1(a, kFeatureIdPcl) != kAdvFeatureWord1Pcl);
FeatureWord1(a, kFeatureIdPcl) != kAdvFeatureWord1Pcl || a.slShutdowns == 0u ||
FeatureAllocations(a, kFeatureIdDlss) == 0u || FeatureFrees(a, kFeatureIdDlssG) == 0u);
++i) {
REQUIRE(ReadAdvanced(r, 1u, a, a.samples, wanted));
}
INFO("mask 0x" << std::hex << a.validMask << " true 0x" << a.slFlagsSeenTrue << " false 0x" << a.slFlagsSeenFalse
<< std::dec << " calls " << a.slConstantsCalls << " resets " << a.slResets << " version "
<< a.dlssStructVersion << " output " << a.dlssOutputWidth << "x" << a.dlssOutputHeight);
CHECK(a.validMask == static_cast<uint32_t>(wanted));
CHECK(a.validMask == static_cast<uint32_t>(wanted | fl::FL_ADV_VALID_SL_SHUTDOWN));
// What Streamline answered about a feature: a slot for each of the two it answered for, in the order asked, with
// exactly the stub's numbers and both questions marked as answered. NOT the one it refused -- its struct came
@@ -7462,6 +7481,16 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation,
}
CHECK(a.features[size_t{5} * FL_ADV_FEATURE_WORDS] == 0u); // five features, five slots
// The counted three: DLSS's resources allocated and frame generation's freed on every sixteenth frame, Streamline
// shut down on every sixty-fourth -- and the target went on calling the stub after it, through every detour.
CHECK(FeatureAllocations(a, kFeatureIdDlss) >= 1u);
CHECK(FeatureFrees(a, kFeatureIdDlss) == 0u);
CHECK(FeatureFrees(a, kFeatureIdDlssG) >= 1u);
CHECK(FeatureAllocations(a, kFeatureIdDlssG) == 0u);
CHECK(a.slShutdowns >= 1u);
CHECK(a.reservedSl[0] == 0u);
CHECK(a.reservedSl[1] == 0u);
// The options chained into the evaluation, as before.
CHECK(a.dlssStructVersion == 3u); // the version these headers declare, which is what entitles the tail
CHECK(a.dlssOptionsSeen != 0u);
@@ -7517,6 +7546,7 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation,
CHECK((r.st->hooksInstalledMask & slConstants) != 0u);
CHECK((r.st->hooksInstalledMask & slFeatures) == slFeatures);
CHECK((r.st->hooksInstalledMask & slFeatureState) == slFeatureState);
CHECK((r.st->hooksInstalledMask & slCounted) == slCounted);
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_SL_INTERPOSER, "slSetConstants", now));
CHECK(std::memcmp(pristine, now, sizeof(now)) != 0);
+1
View File
@@ -167,6 +167,7 @@ int main() {
FL_ADV_FIELD(slAspectBits);
FL_ADV_FIELD(slFlagsSeenTrue);
FL_ADV_FIELD(slFlagsSeenFalse);
FL_ADV_FIELD(slShutdowns);
FL_ADV_FIELD(reservedSl);
Field("features", offsetof(FlAdvancedState, features), sizeof(FlAdvancedState::features), true);
#undef FL_ADV_FIELD
+59 -1
View File
@@ -130,7 +130,9 @@
// Since 0.1.0-beta.45, on the same frames, it asks slIsFeatureSupported about DLSS, DLSS frame
// generation, NIS (refused: not supported) and Reflex (refused: missing) with an adapter whose
// LUID pointer is wild; asks slIsFeatureLoaded about DLSS (yes), PCL (no) and NIS (refused);
// and switches DLSS on and DLSS frame generation on and off through slSetFeatureLoaded
// and switches DLSS on and DLSS frame generation on and off through slSetFeatureLoaded;
// allocates DLSS's resources and frees frame generation's on each of those frames, and calls
// slShutdown on every fourth of them - then goes on using the stub
// --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)
@@ -2601,6 +2603,43 @@ bool ProbeAdvFields() {
"a new request clears the switches seen and keeps the answers; the slot itself stays claimed");
}
// 0.1.0-beta.45, the counted three: a feature's resources allocated and freed, and Streamline shut down.
{
fl::adv::Accumulators s;
const auto word1 = [&s](uint32_t slot) {
return s.features[static_cast<size_t>(slot) * FL_ADV_FEATURE_WORDS + 1u].load();
};
fl::adv::ObserveSlSetFeatureLoaded(sl::kFeatureDLSS, true, s);
for (int i = 0; i < 3; ++i) {
fl::adv::ObserveSlAllocateResources(sl::kFeatureDLSS, s);
}
fl::adv::ObserveSlFreeResources(sl::kFeatureDLSS, s);
Check(word1(0) == (fl::adv::kFeatureSwitchedOn | (3u << fl::adv::kFeatureAllocShift) |
(1u << fl::adv::kFeatureFreeShift)),
"three allocations and one free of one feature: two four-bit counts beside the bits already there");
for (int i = 0; i < 40; ++i) {
fl::adv::ObserveSlAllocateResources(sl::kFeatureDLSS, s);
fl::adv::ObserveSlFreeResources(sl::kFeatureDLSS_G, s);
}
Check(word1(0) == (fl::adv::kFeatureSwitchedOn | (15u << fl::adv::kFeatureAllocShift) |
(1u << fl::adv::kFeatureFreeShift)) &&
word1(1) == (15u << fl::adv::kFeatureFreeShift),
"a count stops at 15 and never carries into the count beside it");
fl::adv::ObserveSlShutdown(s);
fl::adv::ObserveSlShutdown(s);
auto* counted = new fl::FlAdvancedState{};
fl::adv::Publish(s, counted, 3u, 1u);
Check(counted->slShutdowns == 2u && (counted->validMask & fl::FL_ADV_VALID_SL_SHUTDOWN) != 0u &&
counted->reservedSl[0] == 0u && counted->reservedSl[1] == 0u,
"two shutdowns: the count in its own word, its bit of the mask, the two words left reserved zero");
fl::adv::Reset(s);
fl::adv::Publish(s, counted, 4u, 2u);
Check(counted->slShutdowns == 0u && (counted->validMask & fl::FL_ADV_VALID_SL_SHUTDOWN) == 0u &&
word1(0) == 0u && word1(1) == 0u && counted->features[0] == sl::kFeatureDLSS + 1u,
"a new request: the counts and the shutdowns are the last session's and go; the slots stay claimed");
delete counted;
}
// WHERE THE MEMBERS ARE, by this build's own struct: everything read lies before the Vulkan members, and the
// pointer to the tag list sits between two members that are read.
const auto at = [&r](const void* member) {
@@ -3350,6 +3389,19 @@ int HoldPresentingUpscaled(Gfx& g, int seconds, bool real, sl::Feature feature,
Check(false, "the stub exports slIsFeatureSupported, slIsFeatureLoaded and slSetFeatureLoaded");
return 1;
}
using StubAllocateResourcesFn = sl::Result(STDMETHODCALLTYPE*)(void*, sl::Feature, const sl::ViewportHandle&);
using StubFreeResourcesFn = sl::Result(STDMETHODCALLTYPE*)(sl::Feature, const sl::ViewportHandle&);
using StubShutdownFn = sl::Result(STDMETHODCALLTYPE*)();
auto allocateResources =
reinterpret_cast<StubAllocateResourcesFn>(reinterpret_cast<void*>(GetProcAddress(stub, "slAllocateResources")));
auto freeResources =
reinterpret_cast<StubFreeResourcesFn>(reinterpret_cast<void*>(GetProcAddress(stub, "slFreeResources")));
auto shutdownStreamline =
reinterpret_cast<StubShutdownFn>(reinterpret_cast<void*>(GetProcAddress(stub, "slShutdown")));
if (advanced && (allocateResources == nullptr || freeResources == nullptr || shutdownStreamline == nullptr)) {
Check(false, "the stub exports slAllocateResources, slFreeResources and slShutdown");
return 1;
}
sl::Constants constants;
sl::Constants otherConstants;
sl::ViewportHandle otherViewport{kAdvSlOtherViewport};
@@ -3430,6 +3482,12 @@ int HoldPresentingUpscaled(Gfx& g, int seconds, bool real, sl::Feature feature,
isFeatureLoaded(sl::kFeatureNIS, loaded);
setFeatureLoaded(sl::kFeatureDLSS, true);
setFeatureLoaded(sl::kFeatureDLSS_G, (evaluated & 16) != 0);
// The command buffer is a wild pointer here too: counted, never looked at.
allocateResources(reinterpret_cast<void*>(static_cast<uintptr_t>(1)), sl::kFeatureDLSS, viewport);
freeResources(sl::kFeatureDLSS_G, viewport);
if ((evaluated % 64) == 3) {
shutdownStreamline();
}
}
}
// ONE EVALUATION PER PRESENT, which is what a real upscaled title does
@@ -69,6 +69,10 @@ static_assert(fl::stub::InventoryHas("slIsFeatureSupported") && fl::stub::Invent
fl::stub::InventoryHas("slSetFeatureLoaded"),
"fl_hook_inventory.h no longer contains one of the three feature-state rows of 0.1.0-beta.45, so the "
"fixture would exercise a row the Overlay does not install.");
static_assert(fl::stub::InventoryHas("slAllocateResources") && fl::stub::InventoryHas("slFreeResources") &&
fl::stub::InventoryHas("slShutdown"),
"fl_hook_inventory.h no longer contains one of the three counted rows of 0.1.0-beta.45, so the fixture "
"would exercise a row the Overlay does not install.");
static_assert(fl::stub::InventoryHas("slSetConstants"),
"fl_hook_inventory.h no longer contains \"slSetConstants\", so the constants fixture would exercise a "
"row the Overlay does not install.");
@@ -177,6 +181,26 @@ SL_API sl::Result slSetFeatureLoaded(sl::Feature feature, bool loaded) {
return sl::Result::eOk;
}
// The last three rows of 0.1.0-beta.45. They keep nothing and do nothing: the Overlay counts the calls, and the
// harness goes on using the stub after slShutdown, as a game that starts Streamline again would.
SL_API sl::Result slAllocateResources(sl::CommandBuffer* cmdBuffer, sl::Feature feature,
const sl::ViewportHandle& viewport) {
(void)cmdBuffer;
(void)feature;
(void)viewport;
return sl::Result::eOk;
}
SL_API sl::Result slFreeResources(sl::Feature feature, const sl::ViewportHandle& viewport) {
(void)feature;
(void)viewport;
return sl::Result::eOk;
}
SL_API sl::Result slShutdown() {
return sl::Result::eOk;
}
// The per-frame constants (0.1.0-beta.43). Signature from the vendored header, like the others. The stub keeps
// nothing: the harness hands it known values and the injected cases assert what the Overlay read of them.
SL_API sl::Result slSetConstants(const sl::Constants& values, const sl::FrameToken& frame,