Compare commits

...
Author SHA1 Message Date
poli0981andClaude Fable 5.2 ee8d0fe322 fix(tests): compute the index of a feature slot in size_t - three products of two 32-bit values used as a pointer offset, in the injected test and the harness (Qodana native, bugprone-implicit-widening-of-multiplication-result)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 17:34:59 +07:00
poli0981andClaude Fable 5.2 6cb1558f15 feat(overlay): hook slGetFeatureVersion and slGetFeatureRequirements - what Streamline answers when a game asks which version a feature is and what it requires, read after the original call and only once the Agent has asked; never the lists the answer points to (beta.44 PR-2)
Two new patch sites on sl.interposer.dll, a row and a family bit each (15, 16), installed only in a process that
was asked for Advanced metrics (D111) and the first two rows the watchdog patches. The answer is read only when
the original returned eOk and the struct carries its own GUID: two versions; the flags, three counts and four
versions of the requirements - every one a member of struct version 1 at each of sixteen upstream tags (D115).
requiredTags and the Vulkan members are never read; no pointer of the game's is followed. Twelve slots in region 5
(layout 5 as it was), kept across a new request.

Measured (the detours' bodies on the headers, the Overlay's flags, 20 M calls x 3): the version +0.58/+0.61/+0.58 ns
not asked, +14.82/+14.54/+14.47 ns asked; the requirements +0.58/+0.63/+0.61 ns not asked, +20.88/+21.01/+20.96 ns
asked.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 17:15:31 +07:00
15 changed files with 590 additions and 28 deletions

No files matched your search

+14
View File
@@ -35,6 +35,20 @@ numeric core and does not move; the heading is the full version — corrected 20
## [Unreleased]
### Added
- **Two more calls are hooked inside a game, only where Advanced metrics was asked for** (Advanced metrics train B,
the third step): `slGetFeatureVersion` and `slGetFeatureRequirements` of `sl.interposer.dll` — what Streamline
answers when a game asks which version a feature is and what it requires. The original call runs first and its
answer is read only when it succeeded: the feature's Streamline and NGX versions; the graphics APIs it supports,
whether V-Sync must be off and hardware-accelerated GPU scheduling on, how many threads, viewports and buffers,
and the Windows and driver versions found beside the ones required. **The lists the answer points to — the
buffer tags, the names of Vulkan extensions and features — are never followed.** As with `slSetConstants`,
neither patch is made in a game no session has asked, and each stays for the life of the process once made. A
game asks these while it starts, so the two rows are the first the Overlay patches — and most sessions, attached
later, will still not see the calls. Nothing is shown of them yet: the Agent and the App read them in the next
pull request. No layout change (5), no schema change (23).
### Changed
- **Switching hooking back on starts the count of early abnormal ends again** (owner decision D126). The count was
+7
View File
@@ -145,6 +145,13 @@ What the region is, as a contract between the two sides:
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 feature slots are written since 0.1.0-beta.44**: `features` is twelve slots of twenty-four words — word 0
the `sl::Feature` id plus one (0 is an empty slot), word 1 which of the two questions has an answer (bit 0 the
version, bit 1 the requirements), then the two versions, the flags, three counts and four more versions, as
`fl_shm.h` lays them out. Slots fill from 0 in the order the game first asked about each feature; **a new request
does not empty them** — the one group that is a fact about the process and not about a session — and
`FL_ADV_VALID_SL_FEATURES` stays set with them. `FL_HOOK_SL_FEATURE_VERSION` (bit 15) and
`FL_HOOK_SL_FEATURE_REQUIREMENTS` (bit 16) are published with their patches, in a process that was asked.
- 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.
+14 -1
View File
@@ -194,8 +194,9 @@ Every hook must be listed here with a purpose. Anything not on this list is not
|---|---|
| NGX: `NVSDK_NGX_D3D11/D3D12/VULKAN_CreateFeature`, `EvaluateFeature`, `ReleaseFeature` | Which NGX feature is *actually created and evaluated per frame*: SuperSampling (DLSS), RayReconstruction (DLSS-D), FrameGeneration (DLSS-G) |
| NGX parameter accessors (`NVSDK_NGX_Parameter_SetI/GetI/SetUI`) — **exported by `sl.common.dll` only; see below** | `Width`/`Height` (render) vs `OutWidth`/`OutHeight` (output), `PerfQualityValue` (quality preset), sharpness |
| ✅ Streamline: `slEvaluateFeature` · ⏳ `slInit`, `slSetFeatureLoaded`, ~~`slSetConstants`~~ *(its own row below since beta.43)*, `slGetFeatureRequirements` | Feature set actually active when the game goes through SL rather than NGX directly (`kFeatureDLSS`, `DLSS_G`, `DLSS_RR`, `Reflex`, `NIS`; since beta.34 `kFeatureDLSS_NR` — DLSS 5's neural rendering, its own fact bit and family `FL_HOOK_SL_NEURAL_RENDERING`, D84; rule 4: the `feature` argument of the API hooked, nothing else). **Built 2026-08-09**, identity only: one MinHook detour on `sl.interposer.dll!slEvaluateFeature`, resolved **module-scoped** and installed lazily by the watchdog. Sets `FL_MEASURED_UPSCALER` + `FL_HOOK_UPSCALER_IDENTITY`; decodes `kFeatureDLSS`/`kFeatureNIS` and reports `FL_UPSCALER_UNKNOWN` for anything else. **Never `FL_UPSCALER_NONE`** — a Streamline-only writer cannot see FFX, XeSS or NGX-direct, and `NONE` is the only one of the three states that may be aggregated as a negative. **Since 0.1.0-beta.40 (Advanced metrics train B, D111), and only while the Agent asks** (`FlControlBlock.advancedRequested`): the `sl::DLSSOptions` a title chains into `inputs` — the struct the quality mode is read from — is read further: `outputWidth`/`outputHeight`, `preExposure`, `exposureScale`, `colorBuffersHDR`, the five presets of version 1, and where the struct's own `structVersion` proves them present `ultraQualityPreset` and `useAutoExposure` (≥ 2) and `alphaUpscalingEnabled` (≥ 3) — §Which struct version carries which field. Rule 4: more members of the same argument of the same call; `fl_adv_fields.h` is the one place, `tools/overlay-fields-check.ps1` holds it. No new patch site. **Measured** (the header's own functions, `/O2 /guard:cf /Qspectre /MT`, 20 M calls × 3): +9.5–11.7 ns per evaluation that chains the options while asked; with the word at 0, one relaxed load and a branch not taken — below what the bench resolves. Most titles set these through `slDLSSSetOptions`, which is not an export, and read N/A (train D) |
| ✅ Streamline: `slEvaluateFeature` · ⏳ `slInit`, `slSetFeatureLoaded`, ~~`slSetConstants`~~ *(its own row below since beta.43)*, ~~`slGetFeatureRequirements`~~ *(its own row below since beta.44, with `slGetFeatureVersion`)* | Feature set actually active when the game goes through SL rather than NGX directly (`kFeatureDLSS`, `DLSS_G`, `DLSS_RR`, `Reflex`, `NIS`; since beta.34 `kFeatureDLSS_NR` — DLSS 5's neural rendering, its own fact bit and family `FL_HOOK_SL_NEURAL_RENDERING`, D84; rule 4: the `feature` argument of the API hooked, nothing else). **Built 2026-08-09**, identity only: one MinHook detour on `sl.interposer.dll!slEvaluateFeature`, resolved **module-scoped** and installed lazily by the watchdog. Sets `FL_MEASURED_UPSCALER` + `FL_HOOK_UPSCALER_IDENTITY`; decodes `kFeatureDLSS`/`kFeatureNIS` and reports `FL_UPSCALER_UNKNOWN` for anything else. **Never `FL_UPSCALER_NONE`** — a Streamline-only writer cannot see FFX, XeSS or NGX-direct, and `NONE` is the only one of the three states that may be aggregated as a negative. **Since 0.1.0-beta.40 (Advanced metrics train B, D111), and only while the Agent asks** (`FlControlBlock.advancedRequested`): the `sl::DLSSOptions` a title chains into `inputs` — the struct the quality mode is read from — is read further: `outputWidth`/`outputHeight`, `preExposure`, `exposureScale`, `colorBuffersHDR`, the five presets of version 1, and where the struct's own `structVersion` proves them present `ultraQualityPreset` and `useAutoExposure` (≥ 2) and `alphaUpscalingEnabled` (≥ 3) — §Which struct version carries which field. Rule 4: more members of the same argument of the same call; `fl_adv_fields.h` is the one place, `tools/overlay-fields-check.ps1` holds it. No new patch site. **Measured** (the header's own functions, `/O2 /guard:cf /Qspectre /MT`, 20 M calls × 3): +9.5–11.7 ns per evaluation that chains the options while asked; with the word at 0, one relaxed load and a branch not taken — below what the bench resolves. Most titles set these through `slDLSSSetOptions`, which is not an export, and read N/A (train D) |
| ✅ 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. 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: `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
@@ -325,6 +326,9 @@ v2.8.0, v2.9.0, v2.10.0, v2.10.3, v2.11.1, v2.12.0, v2.14.1, v2.14.16):
| | 3 | v2.4.0 (`27d352db364f`) | `alphaUpscalingEnabled` |
| `sl::Constants` (`include/sl_consts.h`) | 1 | v2.0.0 (`db6f37adcf66`) | every member through `motionVectorsJittered` — the matrices, `jitterOffset`, `mvecScale`, `cameraPinholeOffset`, the camera's position and axes, `cameraNear`, `cameraFar`, `cameraFOV`, `cameraAspectRatio`, `motionVectorsInvalidValue`, the seven `Boolean`s |
| | 2 | v2.4.0 (`bba15338a623`) | `minRelativeLinearDepthObjectSeparation` |
| `sl::FeatureVersion` (`include/sl.h`; `include/sl_core_types.h` from v2.7.2) | 1 | v2.0.0 (`fc2d6ee39fea`) | `versionSL`, `versionNGX` |
| `sl::FeatureRequirements` (the same headers) | 1 | v2.0.0 (`fc2d6ee39fea`) | `flags`, `maxNumCPUThreads`, `maxNumViewports`, `numRequiredTags`, `requiredTags`, `osVersionDetected`, `osVersionRequired`, `driverVersionDetected`, `driverVersionRequired`, then ten Vulkan members from `vkNumComputeQueuesRequired` to `vkFeatures13` |
| | 2 | v2.1.0 (`79037e0974d2`) | `vkNumOpticalFlowQueuesRequired` |
`sl::DLSSOptions` keeps those seventeen declarations, same types and order, through v2.14.16 (`9a875bd4f843`); v2.8.0
only re-spelled the deprecated `sharpness`. `sl::Constants` is unchanged from v2.4.0 through v2.14.16
@@ -333,6 +337,15 @@ Overlay reads `sl::Constants`, and only members of version 1** — nothing of ve
"at least 1" is needed, and the read ends before `minRelativeLinearDepthObjectSeparation`, the member version 2
added.
**The two answers about a feature** (established 2026-11-12, the same way, over the same sixteen tags):
`sl::FeatureVersion` is two members at every tag, and `sl::FeatureRequirements` is the nineteen of v2.0.0 plus the
one v2.1.0 added, unchanged through v2.14.16 (`a255f5c5e99a`). `sl::Version` is three `uint32_t` — `major`, `minor`,
`build` — in `include/sl_version.h` from v2.0.0 (`deec7cd04363`) to v2.14.16 (`dc3041ae8b44`), and the two functions'
declarations are the same at both ends: `sl::Result slGetFeatureVersion(sl::Feature, sl::FeatureVersion&)` and
`sl::Result slGetFeatureRequirements(sl::Feature, sl::FeatureRequirements&)`. **Since 0.1.0-beta.44 the Overlay reads
both, and only members of version 1**: the read of the requirements ends at `driverVersionRequired`, before the first
Vulkan member, so no version test beyond "at least 1" is needed.
**FidelityFX** (`GPUOpen-LibrariesAndSDKs/FidelityFX-SDK`; tags v1.1.0 — FSR 3.1.0, the first ffx-api — v1.1.1,
v1.1.2, v1.1.3, v1.1.4, v2.0.0, v2.1.0, v2.2.0, v2.3.0, v2.4.0). The descriptor header carries a `type` and no size
or version, so the question is whether the declaration ever changed:
+2 -1
View File
@@ -814,7 +814,8 @@ planning, the design reviewed against the code before it was approved.
- **D116 — "never the camera" is a build check**, as "never a setter" is (D108): `tools/overlay-fields-check.ps1` —
every read of a vendor struct in one header, each allowed member named and used, the camera's names refused
anywhere in the Overlay and the Vulkan layer, no copy of `sl::Constants` by value. *(Built 2026-11-12:
twenty-eight members on `tools/overlay-allowed-fields.txt`; `12_BUILD` gate 14f.)*
twenty-eight members on `tools/overlay-allowed-fields.txt`; `12_BUILD` gate 14f. Fifty-six since 0.1.0-beta.44,
with the two answers about a feature.)*
- **What will read N/A, and says why.** Many titles set their DLSS options through `slDLSSSetOptions`, which is not
an export (train D), so `sl.dlss.*` is filled only for a title that passes its options with the evaluate call.
`slGetFeatureVersion` and `slGetFeatureRequirements` are calls a game makes while starting.
@@ -35,4 +35,10 @@ public enum HookFamilies
/// <summary><c>ffxConfigure</c> is hooked (0.1.0-beta.43) - only where Advanced metrics was ever asked for.</summary>
FfxConfigure = 1 << 14,
/// <summary><c>slGetFeatureVersion</c> is hooked (0.1.0-beta.44) - only where Advanced metrics was ever asked for.</summary>
SlFeatureVersion = 1 << 15,
/// <summary><c>slGetFeatureRequirements</c> is hooked (0.1.0-beta.44) - only where Advanced metrics was ever asked for.</summary>
SlFeatureRequirements = 1 << 16,
}
+10
View File
@@ -292,6 +292,16 @@ public enum FlHookFamily : uint
/// was asked for Advanced metrics at least once; it entitles no frame field.
/// </summary>
FfxConfigure = 1u << 14,
/// <summary>
/// <c>slGetFeatureVersion</c> is hooked (0.1.0-beta.44, Advanced metrics train B). Only in a process that was asked
/// for Advanced metrics at least once. A game asks while it starts, so the bit beside a feature with no version means
/// "hooked, and the game did not ask again"; it entitles no frame field.
/// </summary>
SlFeatureVersion = 1u << 15,
/// <summary><c>slGetFeatureRequirements</c> is hooked (0.1.0-beta.44), under the same conditions.</summary>
SlFeatureRequirements = 1u << 16,
}
/// <summary>
@@ -188,8 +188,16 @@ struct Accumulators {
std::atomic<uint32_t> slAspectBits{FL_ADV_FLOAT_NONE};
std::atomic<uint32_t> slFlagsSeenTrue{0u};
std::atomic<uint32_t> slFlagsSeenFalse{0u};
// 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]{};
};
// Word 1 of a feature slot: which of the two questions has an answer in it.
inline constexpr uint32_t kFeatureVersionAnswered = 1u << 0;
inline constexpr uint32_t kFeatureRequirementsAnswered = 1u << 1;
// 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
// arrive at two hooked modules; a count is a count of calls and not of hooks.
@@ -461,15 +469,85 @@ inline void ObserveSlConstants(const sl::Constants& k, uint32_t viewport, Accumu
NoteBits(a.validMask, FL_ADV_VALID_SL_CONSTANTS);
}
// The slot of `feature`: the one that holds it already, else the first empty one, claimed here. nullptr when every
// slot holds another feature -- a thirteenth is not kept -- and for the one id that cannot be stored plus one.
// Slots fill from 0 and are never emptied, so the first empty slot ends the search.
inline std::atomic<uint32_t>* FeatureSlot(uint32_t feature, Accumulators& a) noexcept {
const uint32_t id = feature + 1u;
if (id == 0u) {
return nullptr;
}
for (uint32_t i = 0; i < FL_ADV_FEATURE_SLOTS; ++i) {
std::atomic<uint32_t>* slot = &a.features[i * FL_ADV_FEATURE_WORDS];
uint32_t held = slot[0].load(std::memory_order_relaxed);
if (held == 0u && slot[0].compare_exchange_strong(held, id, std::memory_order_relaxed)) {
return slot;
}
if (held == id) { // it was there, or another thread asking about the same feature claimed it just now
return slot;
}
}
return nullptr;
}
// Three words of a slot from one sl::Version: major, minor, build.
inline void PutVersion(std::atomic<uint32_t>* words, const sl::Version& number) noexcept {
words[0].store(number.major, std::memory_order_relaxed);
words[1].store(number.minor, std::memory_order_relaxed);
words[2].store(number.build, std::memory_order_relaxed);
}
// What slGetFeatureVersion ANSWERED (0.1.0-beta.44): the caller is the detour, after the original returned OK and
// the struct's GUID and version were checked. Both members are version 1's (17_HOOK_ENGINE "Which struct version
// carries which field"). A feature asked about again overwrites its own slot: the last answer is the one kept.
inline void ObserveSlFeatureVersion(uint32_t feature, const sl::FeatureVersion& fv, Accumulators& a) noexcept {
std::atomic<uint32_t>* slot = FeatureSlot(feature, a);
if (slot == nullptr) {
return;
}
PutVersion(slot + 2, fv.versionSL);
PutVersion(slot + 5, fv.versionNGX);
NoteBits(slot[1], kFeatureVersionAnswered);
NoteBits(a.validMask, FL_ADV_VALID_SL_FEATURES);
}
// What slGetFeatureRequirements ANSWERED (0.1.0-beta.44), under the same conditions. WHAT IS READ: the flags, three
// counts, the number of required buffer tags, and four versions -- every one a member of struct version 1, the last
// of them `driverVersionRequired`. WHAT IS NOT, EVER: `requiredTags`, the pointer the count belongs to, and every
// member after the versions -- the Vulkan queue counts and the pointers to the names of extensions and features.
// Nothing here follows a pointer of the game's.
inline void ObserveSlFeatureRequirements(uint32_t feature, const sl::FeatureRequirements& fr,
Accumulators& a) noexcept {
std::atomic<uint32_t>* slot = FeatureSlot(feature, a);
if (slot == nullptr) {
return;
}
slot[8].store(static_cast<uint32_t>(fr.flags), std::memory_order_relaxed);
slot[9].store(fr.maxNumCPUThreads, std::memory_order_relaxed);
slot[10].store(fr.maxNumViewports, std::memory_order_relaxed);
slot[11].store(fr.numRequiredTags, std::memory_order_relaxed);
PutVersion(slot + 12, fr.osVersionDetected);
PutVersion(slot + 15, fr.osVersionRequired);
PutVersion(slot + 18, fr.driverVersionDetected);
PutVersion(slot + 21, fr.driverVersionRequired);
NoteBits(slot[1], kFeatureRequirementsAnswered);
NoteBits(a.validMask, FL_ADV_VALID_SL_FEATURES);
}
// 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
// stores is of the call it is in, which belongs to the request that is starting.
// The two owners stay - which module's calls are counted is a fact about the
// process, not about a session.
// process, not about a session. SO DO THE FEATURE SLOTS (0.1.0-beta.44): what
// version a feature is and what it requires do not change while the game runs,
// and a game asks once, while it starts -- a second session of the same process
// would otherwise have nothing where the first had the answer. Their bit of the
// mask is therefore kept with them.
inline void Reset(Accumulators& a) noexcept {
const auto relaxed = std::memory_order_relaxed;
a.validMask.store(0u, relaxed);
a.validMask.store(a.features[0].load(relaxed) != 0u ? static_cast<uint32_t>(FL_ADV_VALID_SL_FEATURES) : 0u,
relaxed);
a.dlssStructVersion.store(0u, relaxed);
a.dlssOptionsSeen.store(0u, relaxed);
a.dlssOutputWidth.store(0u, relaxed);
@@ -609,6 +687,10 @@ inline void Publish(Accumulators& a, FlAdvancedState* region, uint32_t request,
put32(region->slFlagsSeenTrue, a.slFlagsSeenTrue.load(relaxed));
put32(region->slFlagsSeenFalse, a.slFlagsSeenFalse.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));
}
std::atomic_ref<uint32_t> samples{region->samples};
samples.store(samples.load(relaxed) + 1u, relaxed);
seq.store(odd + 1u, std::memory_order_release);
@@ -125,7 +125,8 @@ inline constexpr uint32_t kFamiliesEvaluateFeatureDoesNotImplement =
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_FFX_CONFIGURE);
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_assert((kFamilyEvaluateFeature & kFamiliesEvaluateFeatureDoesNotImplement) == 0u,
"the slEvaluateFeature row claims a family its detour does not implement -- hookinventory-check "
@@ -209,7 +210,8 @@ 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_FFX_CONFIGURE);
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_assert((kFamilyFfxDispatch & kFamiliesFfxDispatchDoesNotImplement) == 0u,
"the ffxDispatch rows claim a family their detour does not implement -- hookinventory-check reads "
@@ -303,6 +305,37 @@ 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");
// --- Streamline: slGetFeatureVersion and slGetFeatureRequirements (0.1.0-beta.44, train B's third step) ---
//
// THE TWO QUESTIONS A GAME ASKS STREAMLINE ABOUT A FEATURE: which version it is (Streamline's own, and the NGX
// model's), and what it requires -- the graphics APIs, V-Sync off, hardware-accelerated GPU scheduling, how many
// threads and viewports, how many buffers, and the versions of Windows and of the driver it found beside the ones it
// needs. THE ANSWER IS WHAT IS READ: the detour calls the original first and reads the struct the game passed only
// when the original said OK. The pointers the same answer carries -- the list of required buffer tags, the names of
// Vulkan extensions and features -- are never followed (fl_adv_fields.h; tools/overlay-fields-check.ps1).
//
// INSTALLED ONLY WHERE ASKED FOR, as slSetConstants is (D111), a row and a bit each. THEY ARE THE FIRST ROWS OF THE
// TABLE because a game asks while it starts: the watchdog patches the rows in the table's order, each patch stops
// the game's threads for a moment, and in a process that was asked these two are the ones that cannot wait. In a
// process never asked they are passed over before anything is resolved, and the order changes nothing.
inline constexpr uint32_t kFamilySlFeatureVersion = static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_VERSION);
inline constexpr uint32_t kFamilySlFeatureRequirements = static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_REQUIREMENTS);
static_assert(kFamilySlFeatureVersion != kFamilySlFeatureRequirements &&
kFamilySlFeatureVersion != kFamilyEvaluateFeature && kFamilySlFeatureVersion != kFamilyFfxDispatch &&
kFamilySlFeatureVersion != kFamilyFfxQuery && kFamilySlFeatureVersion != kFamilySlConstants &&
kFamilySlFeatureVersion != static_cast<uint32_t>(fl::FL_HOOK_UPSCALER_PARAMS) &&
kFamilySlFeatureVersion != static_cast<uint32_t>(fl::FL_HOOK_FG_EVALUATIONS),
"InstallByFamily binds a row by EQUALITY on this value -- a collision would hand slGetFeatureVersion's "
"detour to another export, or another's to it");
static_assert(kFamilySlFeatureRequirements != kFamilyEvaluateFeature &&
kFamilySlFeatureRequirements != kFamilyFfxDispatch &&
kFamilySlFeatureRequirements != kFamilyFfxQuery &&
kFamilySlFeatureRequirements != kFamilySlConstants &&
kFamilySlFeatureRequirements != static_cast<uint32_t>(fl::FL_HOOK_UPSCALER_PARAMS) &&
kFamilySlFeatureRequirements != static_cast<uint32_t>(fl::FL_HOOK_FG_EVALUATIONS),
"InstallByFamily binds a row by EQUALITY on this value -- a collision would hand "
"slGetFeatureRequirements' 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
@@ -319,6 +352,8 @@ static_assert(kFamilySlConstants != kFamilyEvaluateFeature && kFamilySlConstants
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 != kFamilySlFeatureVersion &&
kFamilyFfxConfigure != kFamilySlFeatureRequirements &&
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 "
@@ -415,6 +450,8 @@ inline int FfxLeafOf(const wchar_t* moduleName) noexcept {
// first, it entitled records the second row was not yet producing (measured 38 of
// 41 on the frame-based fixture), which is the ffx leaves' defect from #110 again.
#define FL_HOOK_INVENTORY(X) \
X(L"sl.interposer.dll", "slGetFeatureVersion", fl::inventory::kFamilySlFeatureVersion) \
X(L"sl.interposer.dll", "slGetFeatureRequirements", fl::inventory::kFamilySlFeatureRequirements) \
X(L"sl.interposer.dll", "slEvaluateFeature", fl::inventory::kFamilyEvaluateFeature) \
X(L"sl.interposer.dll", "slSetTag", fl::FL_HOOK_UPSCALER_PARAMS) \
X(L"sl.interposer.dll", "slSetTagForFrame", fl::FL_HOOK_UPSCALER_PARAMS) \
@@ -439,7 +476,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 == 18u, "a row was added or removed: say so here, and in 17_HOOK_ENGINE §Hook inventory");
static_assert(kRowCount == 20u, "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
+55 -1
View File
@@ -1175,7 +1175,16 @@ std::atomic<uint32_t> g_frameTokensLive{0};
using PFN_SlSetConstants = ::PFun_slSetConstants*;
PFN_SlSetConstants g_origSlSetConstants = nullptr;
std::atomic<uint32_t> g_slConstantsLive{0};
std::atomic<uint32_t> g_frameTokens{0};
// slGetFeatureVersion and slGetFeatureRequirements (0.1.0-beta.44, Advanced metrics): patched only in a process that
// was asked for Advanced metrics at least once, as slSetConstants is. A patch, a trampoline and a latch each.
using PFN_SlGetFeatureVersion = ::PFun_slGetFeatureVersion*;
using PFN_SlGetFeatureRequirements = ::PFun_slGetFeatureRequirements*;
PFN_SlGetFeatureVersion g_origSlGetFeatureVersion = nullptr;
PFN_SlGetFeatureRequirements g_origSlGetFeatureRequirements = nullptr;
std::atomic<uint32_t> g_slFeatureVersionLive{0};
std::atomic<uint32_t> g_slFeatureRequirementsLive{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
@@ -1760,6 +1769,37 @@ sl::Result STDMETHODCALLTYPE Hook_SlSetConstants(const sl::Constants& values, co
return g_origSlSetConstants(values, frame, viewport);
}
// What Streamline answers when the game asks which version a feature is (0.1.0-beta.44). THE ORIGINAL RUNS FIRST,
// exactly once, on every path, with both arguments forwarded untouched: what is read is its ANSWER, in the struct the
// game passed, and only when it said OK -- a refusal leaves the struct as the game made it, which is not an answer.
// Then the same three conditions as slSetConstants: the Agent is asking, observing has not stopped, and the struct is
// the one these headers describe (its GUID and a version of at least 1, checked on this call). The read itself is in
// fl_adv_fields.h.
sl::Result STDMETHODCALLTYPE Hook_SlGetFeatureVersion(sl::Feature feature, sl::FeatureVersion& version) {
const sl::Result result = g_origSlGetFeatureVersion(feature, version);
FL_HOOK_GUARD({
if (result == sl::Result::eOk && g_advancedRequested.load(std::memory_order_relaxed) != 0u && MayObserve() &&
fl::slinputs::IsReadable<sl::FeatureVersion>(&version)) {
fl::adv::ObserveSlFeatureVersion(static_cast<uint32_t>(feature), version, g_adv);
}
})
return result;
}
// What Streamline answers when the game asks what a feature requires (0.1.0-beta.44): the same shape. The answer
// carries pointers -- the required buffer tags, the names of Vulkan extensions and features -- and fl_adv_fields.h
// follows none of them.
sl::Result STDMETHODCALLTYPE Hook_SlGetFeatureRequirements(sl::Feature feature, sl::FeatureRequirements& requirements) {
const sl::Result result = g_origSlGetFeatureRequirements(feature, requirements);
FL_HOOK_GUARD({
if (result == sl::Result::eOk && g_advancedRequested.load(std::memory_order_relaxed) != 0u && MayObserve() &&
fl::slinputs::IsReadable<sl::FeatureRequirements>(&requirements)) {
fl::adv::ObserveSlFeatureRequirements(static_cast<uint32_t>(feature), requirements, g_adv);
}
})
return result;
}
// 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
@@ -2514,6 +2554,20 @@ 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::kFamilySlFeatureVersion) {
if (g_advancedSeen == 0u) {
return false;
}
return InstallRow(moduleName, symbol, family, reinterpret_cast<void*>(&Hook_SlGetFeatureVersion),
reinterpret_cast<void**>(&g_origSlGetFeatureVersion), g_slFeatureVersionLive, name);
}
if (family == fl::inventory::kFamilySlFeatureRequirements) {
if (g_advancedSeen == 0u) {
return false;
}
return InstallRow(moduleName, symbol, family, reinterpret_cast<void*>(&Hook_SlGetFeatureRequirements),
reinterpret_cast<void**>(&g_origSlGetFeatureRequirements), g_slFeatureRequirementsLive, name);
}
if (family == fl::inventory::kFamilyFfxConfigure) {
if (g_advancedSeen == 0u) {
return false;
@@ -415,6 +415,13 @@ enum FlHookFamily : uint32_t {
// 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,
// Advanced metrics, train B's third step (0.1.0-beta.44): slGetFeatureVersion and slGetFeatureRequirements are
// hooked -- a bit each, because a patch each. Published only in a process that was asked for Advanced metrics at
// least once, as the two above. A GAME ASKS THESE WHILE IT STARTS, so the usual reading of a bit beside a slot
// that has no answer of that kind is "hooked, and the game did not ask again"; neither entitles a measured field
// of a frame record.
FL_HOOK_SL_FEATURE_VERSION = 1u << 15,
FL_HOOK_SL_FEATURE_REQUIREMENTS = 1u << 16,
};
// FlWriterState::runtimeCensus -- which vendor RUNTIME MODULES the loader reported
@@ -966,6 +973,9 @@ enum FlAdvancedValid : uint32_t {
#define FL_ADV_FLOAT_INFINITE 0x7F800000u
// Feature slots (0.1.0-beta.44): FL_ADV_FEATURE_SLOTS slots of FL_ADV_FEATURE_WORDS uint32 each, in `features`.
// Filled in the order the game first asked about each feature, from slot 0, and NOT emptied by a new request: what
// version a feature is and what it requires are facts about the process, and a game asks once, while it starts. A
// thirteenth feature is not kept.
// [0] sl::Feature id PLUS ONE; 0 = an empty slot
// [1] bit 0: slGetFeatureVersion answered; bit 1: slGetFeatureRequirements answered
// [2..4] versionSL major, minor, build [5..7] versionNGX
+88 -17
View File
@@ -6969,6 +6969,17 @@ constexpr float kAdvSlFar = 4000.0f;
constexpr float kAdvSlFovLow = 0.8f;
constexpr float kAdvSlFovHigh = 1.2f;
constexpr float kAdvSlAspect = 1.75f;
// ...and asks the stub interposer about DLSS and DLSS frame generation every sixteenth frame (0.1.0-beta.44). What
// the stub answers (stub_sl_interposer.cpp), as a slot's words 2..23: the two versions, the flags, three counts,
// Windows found and required, the driver found and required.
constexpr uint32_t kAdvFeatureDlss[22] = {2u, 14u, 1u, 310u, 4u, 0u, 7u, 2u, 32u, 3u, 10u,
0u, 26100u, 10u, 0u, 19041u, 591u, 44u, 0u, 512u, 15u, 0u};
constexpr uint32_t kAdvFeatureDlssG[22] = {2u, 14u, 1u, 310u, 4u, 1u, 26u, 1u, 1u, 4u, 10u,
0u, 26100u, 10u, 0u, 19041u, 591u, 44u, 0u, 551u, 23u, 0u};
constexpr uint32_t kFeatureIdDlss = 0u;
constexpr uint32_t kFeatureIdNis = 2u;
constexpr uint32_t kFeatureIdPcl = 4u;
constexpr uint32_t kFeatureIdDlssG = 1000u;
// ...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;
@@ -7031,16 +7042,35 @@ uint32_t BitsOf(float v) {
return std::bit_cast<uint32_t>(v);
}
// 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 = true;
// The feature slots of a target that asks Streamline nothing about a feature: every word zero, and no bit of the
// mask. (Filled since 0.1.0-beta.44 by a target that asks; until then this was "what later releases fill".)
bool FeatureSlotsAreEmpty(const fl::FlAdvancedState& a) {
bool zero = (a.validMask & fl::FL_ADV_VALID_SL_FEATURES) == 0u;
for (uint32_t i = 0; i < FL_ADV_FEATURE_SLOTS * FL_ADV_FEATURE_WORDS; ++i) {
zero = zero && a.features[i] == 0u;
}
return zero;
}
// The slot region 5 holds for `feature` (the id plus one in its first word), or nullptr.
const uint32_t* FeatureSlotOf(const fl::FlAdvancedState& a, uint32_t feature) {
for (uint32_t i = 0; i < FL_ADV_FEATURE_SLOTS; ++i) {
const uint32_t* slot = &a.features[static_cast<size_t>(i) * FL_ADV_FEATURE_WORDS];
if (slot[0] == feature + 1u) {
return slot;
}
}
return nullptr;
}
// A slot's words 1..23 against "both questions answered" and the stub's numbers.
bool FeatureSlotIs(const uint32_t* slot, const uint32_t (&expected)[22]) {
if (slot == nullptr || slot[1] != 3u) {
return false;
}
return std::memcmp(slot + 2, expected, sizeof(expected)) == 0;
}
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 &&
@@ -7193,7 +7223,7 @@ TEST_CASE("region 5 stays empty until the Agent asks, then carries what an FSR t
CHECK(SlConstantsAreUnread(a)); // an FSR title with no Streamline: nothing calls slSetConstants
CHECK(a.ffxMemoryQueries != 0u);
CHECK(a.ffxMemoryQueries <= a.ffxDispatches + 2u);
CHECK(LaterGroupsAreZero(a));
CHECK(FeatureSlotsAreEmpty(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.
@@ -7297,12 +7327,13 @@ TEST_CASE("FSR's plane at infinity (beta.42, D119): a far plane of FLT_MAX reach
CHECK(r.st->status == fl::FL_STATUS_READY);
}
TEST_CASE("region 5 carries what a Streamline title chains into its evaluation and tells slSetConstants, and "
"slSetConstants is patched only once the Agent has asked",
TEST_CASE("region 5 carries what a Streamline title chains into its evaluation, tells slSetConstants and is "
"answered about a feature, and the three calls are patched only once the Agent has asked",
"[guard][inject][shm][advanced]") {
// ONE TARGET, FOUR STRETCHES: never asked -> asked -> no longer asked -> stopped. The target does the same thing
// throughout: it chains an sl::DLSSOptions into every evaluation and calls slSetConstants for two viewports every
// frame, with the matrices and the camera's position and axes set to loud, changing values.
// frame, with the matrices and the camera's position and axes set to loud, changing values; and every sixteenth
// frame it asks Streamline which version four features are and what three of them require (0.1.0-beta.44).
Child child;
REQUIRE(StartHarness(child, L"--real --advanced --hold-presenting-upscaled 60"));
@@ -7317,7 +7348,12 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation a
return; // not reached after the REQUIRE; said in the form a static analyser follows (cpp:S2259)
}
REQUIRE(WaitForIdentityHook(r.st));
const auto slConstants = static_cast<uint32_t>(fl::FL_HOOK_SL_CONSTANTS);
const auto slConstants = static_cast<uint32_t>(fl::FL_HOOK_SL_CONSTANTS);
const auto slFeatures = static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_VERSION) |
static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_REQUIREMENTS);
const char* const featureExports[2] = {"slGetFeatureVersion", "slGetFeatureRequirements"};
unsigned char featurePristine[2][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.
@@ -7331,26 +7367,54 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation a
REQUIRE(r.st->writeIndex > atHooks + 30u);
CHECK(RegionFiveIsZero(r));
CHECK((r.st->hooksInstalledMask & slConstants) == 0u);
CHECK((r.st->hooksInstalledMask & slFeatures) == 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 < 2; ++i) {
unsigned char featureInFile[16]{};
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_SL_INTERPOSER, featureExports[i],
featurePristine[i], featureInFile));
CHECK(std::memcmp(featurePristine[i], featureInFile, sizeof(featureInFile)) == 0); // the file's bytes
}
// ---- 2. ASKED: the patch goes in on the tick that sees the request, and the next publications carry both groups.
// ---- 2. ASKED: the patches go in on the tick that sees the request, and the next publications carry the groups.
SetAdvancedRequest(r, 1u);
REQUIRE(WaitForHookFamily(r.st, slConstants));
REQUIRE(WaitForHookFamily(r.st, static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_VERSION)));
REQUIRE(WaitForHookFamily(r.st, static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_REQUIREMENTS)));
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 < 2; ++i) {
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_SL_INTERPOSER, featureExports[i], featureNow));
CHECK(std::memcmp(featurePristine[i], featureNow, sizeof(featureNow)) != 0);
}
const auto wanted = fl::FL_ADV_VALID_DLSS_OPTIONS | fl::FL_ADV_VALID_SL_CONSTANTS | fl::FL_ADV_VALID_SL_FEATURES;
fl::FlAdvancedState a{};
REQUIRE(ReadAdvanced(r, 1u, a, 0u, fl::FL_ADV_VALID_DLSS_OPTIONS | fl::FL_ADV_VALID_SL_CONSTANTS));
// A reset arrives on one frame in sixty-four and both halves of each alternation within two: read on until the
// summaries hold all of them (bounded by ReadAdvanced's own wait, a few publications).
for (int i = 0; i < 8 && (a.slResets == 0u || a.slFovMinBits == a.slFovMaxBits); ++i) {
REQUIRE(ReadAdvanced(r, 1u, a, a.samples, fl::FL_ADV_VALID_DLSS_OPTIONS | fl::FL_ADV_VALID_SL_CONSTANTS));
REQUIRE(ReadAdvanced(r, 1u, a, 0u, wanted));
// A reset arrives on one frame in sixty-four, both halves of each alternation within two, and the questions about
// a feature on one frame in sixteen: read on until the summaries hold all of them (bounded by ReadAdvanced's own
// wait, a few publications).
for (int i = 0; i < 8 && (a.slResets == 0u || a.slFovMinBits == a.slFovMaxBits ||
!FeatureSlotIs(FeatureSlotOf(a, kFeatureIdDlssG), kAdvFeatureDlssG));
++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>(fl::FL_ADV_VALID_DLSS_OPTIONS | fl::FL_ADV_VALID_SL_CONSTANTS));
CHECK(a.validMask == static_cast<uint32_t>(wanted));
// 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
// back full of 99s -- and NOT the one asked about with a struct whose GUID was broken, which it did answer.
CHECK(FeatureSlotIs(FeatureSlotOf(a, kFeatureIdDlss), kAdvFeatureDlss));
CHECK(FeatureSlotIs(FeatureSlotOf(a, kFeatureIdDlssG), kAdvFeatureDlssG));
CHECK(FeatureSlotOf(a, kFeatureIdNis) == nullptr);
CHECK(FeatureSlotOf(a, kFeatureIdPcl) == nullptr);
CHECK(a.features[0] == kFeatureIdDlss + 1u);
CHECK(a.features[FL_ADV_FEATURE_WORDS] == kFeatureIdDlssG + 1u);
CHECK(a.features[size_t{2} * FL_ADV_FEATURE_WORDS] == 0u); // two features, two slots
// The options chained into the evaluation, as before.
CHECK(a.dlssStructVersion == 3u); // the version these headers declare, which is what entitles the tail
@@ -7395,7 +7459,6 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation a
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
// (it is never taken out mid-session).
@@ -7406,9 +7469,11 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation a
TickFor(r, 2500);
CHECK(std::memcmp(&held, RegionFive(r), sizeof(held)) == 0);
CHECK((r.st->hooksInstalledMask & slConstants) != 0u);
CHECK((r.st->hooksInstalledMask & slFeatures) == slFeatures);
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_SL_INTERPOSER, "slSetConstants", now));
CHECK(std::memcmp(pristine, now, sizeof(now)) != 0);
// The stub's answers carry wild pointers (the tag list, the Vulkan extension names): followed, they would fault.
CHECK(r.st->faultCount == 0u);
CHECK(r.st->status == fl::FL_STATUS_READY);
@@ -7435,6 +7500,12 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation a
CHECK(std::memcmp(pristine, now, sizeof(now)) == 0);
CHECK(text.find("HOOK_INSTALLED sl.interposer.dll!slSetConstants") != std::string::npos);
CHECK(text.find("UNHOOK_RESTORED sl.interposer.dll!slSetConstants") != std::string::npos);
for (int i = 0; i < 2; ++i) {
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_SL_INTERPOSER, featureExports[i], featureNow));
CHECK(std::memcmp(featurePristine[i], featureNow, sizeof(featureNow)) == 0);
CHECK(text.find(std::string("HOOK_INSTALLED sl.interposer.dll!") + featureExports[i]) != std::string::npos);
CHECK(text.find(std::string("UNHOOK_RESTORED sl.interposer.dll!") + featureExports[i]) != std::string::npos);
}
CHECK(text.find("UNHOOK_DECLINED") == std::string::npos);
CHECK(text.find("PATCH_FAILED") == std::string::npos);
}
+169 -2
View File
@@ -121,7 +121,12 @@
// 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
// the frame id - never read either - loud and changing.
// Since 0.1.0-beta.44 the upscaled hold also asks the stub slGetFeatureVersion and
// slGetFeatureRequirements every sixteenth frame - a real game asks while it starts; this one asks
// again so that a hook installed later sees an answer - about DLSS and DLSS frame generation
// (answered), NIS (refused, with loud numbers left in the struct) and PCL with a struct whose GUID
// is broken (answered, and not to be kept)
// --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)
@@ -2019,6 +2024,26 @@ bool ObserveSlConstantsFaults(const void* constants, fl::adv::Accumulators& a) {
}
}
// The same for the two answers about a feature (0.1.0-beta.44).
bool ObserveSlFeatureRequirementsFaults(const void* requirements, fl::adv::Accumulators& a) {
__try {
fl::adv::ObserveSlFeatureRequirements(sl::kFeatureDLSS,
*static_cast<const sl::FeatureRequirements*>(requirements), a);
return false;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return true;
}
}
bool ObserveSlFeatureVersionFaults(const void* version, fl::adv::Accumulators& a) {
__try {
fl::adv::ObserveSlFeatureVersion(sl::kFeatureDLSS, *static_cast<const sl::FeatureVersion*>(version), a);
return false;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return true;
}
}
bool ProbeAdvFields() {
g_failures = 0;
const auto bitsOf = [](float v) { return std::bit_cast<uint32_t>(v); };
@@ -2315,7 +2340,7 @@ bool ProbeAdvFields() {
for (uint32_t i = 0; i < FL_ADV_FEATURE_SLOTS * FL_ADV_FEATURE_WORDS; ++i) {
untouched = untouched && region->features[i] == 0u;
}
Check(untouched, "what a later release fills stays zero");
Check(untouched, "what no call wrote stays zero: the configure, the constants, every feature slot");
// A NEW REQUEST: a second session of a game that kept running. Its summaries are its own.
fl::adv::Reset(a);
@@ -2463,6 +2488,125 @@ bool ProbeAdvFields() {
}
}
// --- slGetFeatureVersion and slGetFeatureRequirements: Streamline's answers about a feature (0.1.0-beta.44) -----
{
fl::adv::Accumulators a;
sl::FeatureVersion v;
v.versionSL = sl::Version(2, 14, 1);
v.versionNGX = sl::Version(310, 4, 0);
fl::adv::ObserveSlFeatureVersion(sl::kFeatureDLSS, v, a);
sl::FeatureRequirements r;
r.flags = sl::FeatureRequirementFlags::eD3D12Supported | sl::FeatureRequirementFlags::eVSyncOffRequired;
r.maxNumCPUThreads = 2;
r.maxNumViewports = 32;
r.numRequiredTags = 3;
r.osVersionDetected = sl::Version(10, 0, 26100);
r.osVersionRequired = sl::Version(10, 0, 19041);
r.driverVersionDetected = sl::Version(591, 44, 0);
r.driverVersionRequired = sl::Version(512, 15, 0);
fl::adv::ObserveSlFeatureRequirements(sl::kFeatureDLSS_G, r, a);
fl::adv::ObserveSlFeatureRequirements(sl::kFeatureDLSS, r, a);
const auto word = [&a](uint32_t slot, uint32_t i) {
return a.features[static_cast<size_t>(slot) * FL_ADV_FEATURE_WORDS + i].load();
};
Check(word(0, 0) == sl::kFeatureDLSS + 1u && word(1, 0) == sl::kFeatureDLSS_G + 1u && word(2, 0) == 0u,
"a slot per feature, in the order first asked about, the id plus one; the next slot is empty");
Check(word(0, 1) == (fl::adv::kFeatureVersionAnswered | fl::adv::kFeatureRequirementsAnswered) &&
word(1, 1) == fl::adv::kFeatureRequirementsAnswered,
"word 1 says which question has an answer: both for DLSS, the requirements alone for frame generation");
Check(word(0, 2) == 2u && word(0, 3) == 14u && word(0, 4) == 1u && word(0, 5) == 310u && word(0, 6) == 4u &&
word(0, 7) == 0u,
"the two versions: major, minor, build");
Check(word(1, 2) == 0u && word(1, 5) == 0u, "a version nobody asked for is not there");
Check(word(1, 8) == 10u && word(1, 9) == 2u && word(1, 10) == 32u && word(1, 11) == 3u,
"the flags (D3D12 | V-Sync off required), the threads, the viewports, the number of required tags");
Check(word(1, 12) == 10u && word(1, 14) == 26100u && word(1, 15) == 10u && word(1, 17) == 19041u &&
word(1, 18) == 591u && word(1, 19) == 44u && word(1, 21) == 512u && word(1, 22) == 15u,
"Windows and the driver: what was found, then what is required");
Check((a.validMask.load() & fl::FL_ADV_VALID_SL_FEATURES) != 0u, "and the group is marked as read");
// The last answer about a feature is the one kept, in the slot it already has.
v.versionNGX = sl::Version(310, 5, 2);
fl::adv::ObserveSlFeatureVersion(sl::kFeatureDLSS, v, a);
Check(word(0, 6) == 5u && word(0, 7) == 2u && word(2, 0) == 0u, "asked again: the same slot, the newer answer");
// A NEW REQUEST KEEPS THEM: a fact about the process, and a game asks once.
fl::adv::Reset(a);
auto* region = new fl::FlAdvancedState{};
fl::adv::Publish(a, region, 9u, 1u);
Check(region->features[0] == sl::kFeatureDLSS + 1u && region->features[FL_ADV_FEATURE_WORDS + 8u] == 10u &&
region->validMask == static_cast<uint32_t>(fl::FL_ADV_VALID_SL_FEATURES),
"a new request publishes the slots as they were, and their bit of the mask with them - alone");
delete region;
// TWELVE SLOTS: a thirteenth feature is not kept, and the id that cannot be stored plus one is refused.
fl::adv::Accumulators full;
for (uint32_t f = 0; f < FL_ADV_FEATURE_SLOTS + 1u; ++f) {
fl::adv::ObserveSlFeatureVersion(100u + f, v, full);
}
fl::adv::ObserveSlFeatureVersion(0xFFFFFFFFu, v, full);
bool twelve = true;
for (uint32_t i = 0; i < FL_ADV_FEATURE_SLOTS; ++i) {
twelve = twelve && full.features[static_cast<size_t>(i) * FL_ADV_FEATURE_WORDS].load() == 101u + i;
}
Check(twelve,
"twelve features fill the twelve slots in order; the thirteenth and feature 0xFFFFFFFF are dropped");
// 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) {
return static_cast<size_t>(static_cast<const unsigned char*>(member) -
reinterpret_cast<const unsigned char*>(&r));
};
Check(at(&r.flags) == 32u && at(&r.numRequiredTags) == 44u && at(&r.requiredTags) == 48u &&
at(&r.osVersionDetected) == 56u && at(&r.driverVersionRequired) == 92u &&
at(&r.vkNumComputeQueuesRequired) == 104u,
"the flags at 32, the tag count at 44, its pointer at 48, the four versions at 56..103, Vulkan from 104");
// NOTHING OF THE POINTERS OR THE VULKAN MEMBERS REACHES WHAT IS PUBLISHED: two structs alike in what is read
// and different in every byte that is not come out the same.
sl::FeatureRequirements p = r;
sl::FeatureRequirements q = r;
std::memset(reinterpret_cast<unsigned char*>(&p) + 48u, 0x11, 8u);
std::memset(reinterpret_cast<unsigned char*>(&q) + 48u, 0xEE, 8u);
std::memset(reinterpret_cast<unsigned char*>(&p) + 104u, 0x11, sizeof(p) - 104u);
std::memset(reinterpret_cast<unsigned char*>(&q) + 104u, 0xEE, sizeof(q) - 104u);
auto* regionP = new fl::FlAdvancedState{};
auto* regionQ = new fl::FlAdvancedState{};
fl::adv::Accumulators ap;
fl::adv::Accumulators aq;
fl::adv::ObserveSlFeatureRequirements(sl::kFeatureDLSS, p, ap);
fl::adv::ObserveSlFeatureRequirements(sl::kFeatureDLSS, q, aq);
fl::adv::Publish(ap, regionP, 5u, 1u);
fl::adv::Publish(aq, regionQ, 5u, 1u);
Check(std::memcmp(regionP, regionQ, sizeof(fl::FlAdvancedState)) == 0 && regionP->features[11] == 3u,
"two answers that differ only in the pointers and the Vulkan members publish the same bytes");
delete regionP;
delete regionQ;
// A STRUCT CUT OFF RIGHT AFTER THE LAST MEMBER READ, against a page that cannot be read: read whole, no fault.
auto* pages =
static_cast<unsigned char*>(VirtualAlloc(nullptr, 8192, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE));
DWORD old = 0;
if (pages == nullptr || !VirtualProtect(pages + 4096, 4096, PAGE_NOACCESS, &old)) {
Check(false, "two pages, the second unreadable, for the cut-off answers");
} else {
unsigned char* cut = pages + 4096 - 104u;
std::memcpy(cut, &r, 104u);
fl::adv::Accumulators edge;
Check(!ObserveSlFeatureRequirementsFaults(cut, edge) && edge.features[21].load() == 512u,
"requirements that end where the Vulkan members begin are read without a fault, to the last member");
const size_t versionSize = sizeof(sl::FeatureVersion);
unsigned char* whole = pages + 4096 - versionSize;
std::memcpy(whole, &v, versionSize);
fl::adv::Accumulators edgeVersion;
Check(!ObserveSlFeatureVersionFaults(whole, edgeVersion) && edgeVersion.features[2].load() == 2u,
"a version answer at the end of readable memory is read without a fault");
VirtualFree(pages, 0, MEM_RELEASE);
}
}
// --- ffxConfigure with a frame-generation descriptor (0.1.0-beta.43) -------------------------------------------
{
fl::adv::Accumulators a;
@@ -3133,6 +3277,17 @@ int HoldPresentingUpscaled(Gfx& g, int seconds, bool real, sl::Feature feature,
Check(false, "the stub exports slSetConstants");
return 1;
}
// --advanced, 0.1.0-beta.44: the two questions about a feature, through the stub's exports.
using StubGetFeatureVersionFn = sl::Result(STDMETHODCALLTYPE*)(sl::Feature, sl::FeatureVersion&);
using StubGetFeatureRequirementsFn = sl::Result(STDMETHODCALLTYPE*)(sl::Feature, sl::FeatureRequirements&);
auto getFeatureVersion =
reinterpret_cast<StubGetFeatureVersionFn>(reinterpret_cast<void*>(GetProcAddress(stub, "slGetFeatureVersion")));
auto getFeatureRequirements = reinterpret_cast<StubGetFeatureRequirementsFn>(
reinterpret_cast<void*>(GetProcAddress(stub, "slGetFeatureRequirements")));
if (advanced && (getFeatureVersion == nullptr || getFeatureRequirements == nullptr)) {
Check(false, "the stub exports slGetFeatureVersion and slGetFeatureRequirements");
return 1;
}
sl::Constants constants;
sl::Constants otherConstants;
sl::ViewportHandle otherViewport{kAdvSlOtherViewport};
@@ -3188,6 +3343,18 @@ int HoldPresentingUpscaled(Gfx& g, int seconds, bool real, sl::Feature feature,
constants.cameraFwd = {loud + 19.0f, loud + 20.0f, loud + 21.0f};
setConstants(constants, g_dummyFrameToken, viewport);
setConstants(otherConstants, g_dummyFrameToken, otherViewport);
if ((evaluated % 16) == 3) {
for (const sl::Feature asked : {sl::kFeatureDLSS, sl::kFeatureDLSS_G, sl::kFeatureNIS}) {
sl::FeatureVersion version;
sl::FeatureRequirements requirements;
getFeatureVersion(asked, version);
getFeatureRequirements(asked, requirements);
}
// A struct that is not the one the headers describe: the stub answers, and nothing may be kept.
sl::FeatureVersion broken;
broken.structType = sl::StructType{};
getFeatureVersion(sl::kFeaturePCL, broken);
}
}
// ONE EVALUATION PER PRESENT, which is what a real upscaled title does
// and what makes the drained record's identity checkable frame by frame.
@@ -62,6 +62,9 @@ StubFrameToken g_tokenPool[8];
static_assert(fl::stub::InventoryHas("slGetNewFrameToken"),
"fl_hook_inventory.h no longer contains \"slGetNewFrameToken\", so the frame-token fixture would "
"exercise a row the Overlay does not install.");
static_assert(fl::stub::InventoryHas("slGetFeatureVersion") && fl::stub::InventoryHas("slGetFeatureRequirements"),
"fl_hook_inventory.h no longer contains \"slGetFeatureVersion\" or \"slGetFeatureRequirements\", so the "
"feature 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.");
@@ -157,6 +160,72 @@ SL_API sl::Result slSetConstants(const sl::Constants& values, const sl::FrameTok
return sl::Result::eOk;
}
// The two questions a game asks about a feature (0.1.0-beta.44). Signatures from the vendored header. The stub
// ANSWERS for DLSS and for DLSS frame generation with fixed numbers the injected case mirrors (guard_test.cpp
// kAdvFeature*), answers for PCL too -- the harness asks about that one with a struct whose GUID it has broken, which
// the Overlay must not keep -- and REFUSES every other feature after writing loud numbers into the struct, as a
// refusal that leaves rubbish behind: a detour that kept a refused answer would publish 99s.
SL_API sl::Result slGetFeatureVersion(sl::Feature feature, sl::FeatureVersion& version) {
if (feature == sl::kFeatureDLSS) {
version.versionSL = sl::Version(2, 14, 1);
version.versionNGX = sl::Version(310, 4, 0);
return sl::Result::eOk;
}
if (feature == sl::kFeatureDLSS_G) {
version.versionSL = sl::Version(2, 14, 1);
version.versionNGX = sl::Version(310, 4, 1);
return sl::Result::eOk;
}
if (feature == sl::kFeaturePCL) {
version.versionSL = sl::Version(7, 7, 7);
version.versionNGX = sl::Version(7, 7, 7);
return sl::Result::eOk;
}
version.versionSL = sl::Version(99, 99, 99);
version.versionNGX = sl::Version(99, 99, 99);
return sl::Result::eErrorFeatureMissing;
}
// THE POINTERS ARE WILD ON PURPOSE: the Overlay keeps the count of required tags and never the list, and nothing of
// the Vulkan members. An address of 1 is not readable in any process; a detour that followed either would fault, and
// the injected case asserts that none was counted.
SL_API sl::Result slGetFeatureRequirements(sl::Feature feature, sl::FeatureRequirements& requirements) {
requirements.requiredTags = reinterpret_cast<const sl::BufferType*>(static_cast<uintptr_t>(1));
requirements.vkNumDeviceExtensions = 3;
requirements.vkDeviceExtensions = reinterpret_cast<const char**>(static_cast<uintptr_t>(1));
requirements.vkNumInstanceExtensions = 2;
requirements.vkInstanceExtensions = reinterpret_cast<const char**>(static_cast<uintptr_t>(1));
requirements.osVersionDetected = sl::Version(10, 0, 26100);
requirements.osVersionRequired = sl::Version(10, 0, 19041);
requirements.driverVersionDetected = sl::Version(591, 44, 0);
if (feature == sl::kFeatureDLSS) {
requirements.flags = sl::FeatureRequirementFlags::eD3D11Supported |
sl::FeatureRequirementFlags::eD3D12Supported |
sl::FeatureRequirementFlags::eVulkanSupported;
requirements.maxNumCPUThreads = 2;
requirements.maxNumViewports = 32;
requirements.numRequiredTags = 3;
requirements.driverVersionRequired = sl::Version(512, 15, 0);
return sl::Result::eOk;
}
if (feature == sl::kFeatureDLSS_G) {
requirements.flags = sl::FeatureRequirementFlags::eD3D12Supported |
sl::FeatureRequirementFlags::eVSyncOffRequired |
sl::FeatureRequirementFlags::eHardwareSchedulingRequired;
requirements.maxNumCPUThreads = 1;
requirements.maxNumViewports = 1;
requirements.numRequiredTags = 4;
requirements.driverVersionRequired = sl::Version(551, 23, 0);
return sl::Result::eOk;
}
requirements.flags = sl::FeatureRequirementFlags::eAll;
requirements.maxNumCPUThreads = 99;
requirements.maxNumViewports = 99;
requirements.numRequiredTags = 99;
requirements.driverVersionRequired = sl::Version(99, 99, 99);
return sl::Result::eErrorFeatureMissing;
}
SL_API sl::Result slGetNewFrameToken(sl::FrameToken*& token, const uint32_t* frameIndex) {
// The vendor's contract in miniature: an explicit index returns THAT frame's
// token (the same object on a re-request), no index advances to a new one.
+16
View File
@@ -61,6 +61,22 @@ sl::Constants::orthographicProjection
sl::Constants::motionVectorsDilated
sl::Constants::motionVectorsJittered
# sl::FeatureVersion and sl::FeatureRequirements, what Streamline ANSWERS when the game asks about a feature
# (parameters `fv` and `fr`; 0.1.0-beta.44) - read after the original call said OK. The two versions; the flags,
# three counts and four versions of the requirements. The count of required buffer tags is read and its pointer,
# `requiredTags`, is not; nothing after `driverVersionRequired` is - the Vulkan queue counts and the pointers to
# the names of extensions and features.
sl::FeatureVersion::versionSL
sl::FeatureVersion::versionNGX
sl::FeatureRequirements::flags
sl::FeatureRequirements::maxNumCPUThreads
sl::FeatureRequirements::maxNumViewports
sl::FeatureRequirements::numRequiredTags
sl::FeatureRequirements::osVersionDetected
sl::FeatureRequirements::osVersionRequired
sl::FeatureRequirements::driverVersionDetected
sl::FeatureRequirements::driverVersionRequired
# 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.
+6 -1
View File
@@ -58,6 +58,8 @@ $script:Parameter = [ordered]@{
q = 'ffxQueryDescUpscaleGetGPUMemoryUsage'
k = 'sl::Constants'
g = 'ffxConfigureDescFrameGeneration'
fv = 'sl::FeatureVersion'
fr = 'sl::FeatureRequirements'
desc = 'ffxQueryDescHeader'
}
@@ -106,7 +108,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|g)\b(\s*\.\s*([A-Za-z_]\w*))?')) {
foreach ($m in [regex]::Matches($Code, '(?<![\w.>:])(o|d|m|q|k|g|fv|fr)\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)")
@@ -219,6 +221,9 @@ inline void Publish(Accumulators& a, FlAdvancedState* region) noexcept { region-
@{ 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 = 'the answers about a feature read through their parameters, each member on the list, pass'; Header = $goodHeader + "`ninline void ObserveV(uint32_t feature, const sl::FeatureVersion& fv, Accumulators& a) noexcept { Put(a.f, fv.versionSL); }`ninline void ObserveR(uint32_t feature, const sl::FeatureRequirements& fr, Accumulators& a) noexcept { a.n.store(fr.numRequiredTags); Put(a.f, fr.osVersionDetected); }"; List = $goodList + "sl::FeatureVersion::versionSL`nsl::FeatureRequirements::numRequiredTags`nsl::FeatureRequirements::osVersionDetected`n"; Other = $goodOther; Expect = 0 },
@{ Name = 'the list of required tags, a pointer of the game''s, FAILS when it is not on the list'; Header = $goodHeader + "`ninline void ObserveR(uint32_t feature, const sl::FeatureRequirements& fr, Accumulators& a) noexcept { a.n.store(fr.numRequiredTags); Keep(fr.requiredTags[0]); }"; List = $goodList + "sl::FeatureRequirements::numRequiredTags`n"; Other = $goodOther; Expect = 1 },
@{ Name = 'a member of the answer read outside the header FAILS'; Header = $goodHeader + "`ninline void ObserveR(uint32_t feature, const sl::FeatureRequirements& fr, Accumulators& a) noexcept { a.n.store(fr.numRequiredTags); }"; List = $goodList + "sl::FeatureRequirements::numRequiredTags`n"; Other = @{ 'dllmain.cpp' = 'void Hook(sl::FeatureRequirements& requirements) { Keep(requirements.numRequiredTags); }' }; 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) {