Compare commits

...
Author SHA1 Message Date
poli0981andClaude Fable 5.2 8259fba7ef feat(overlay): hook slSetConstants - what a game tells Streamline about each frame, read only while the Agent asks and patched only once it has; never the matrices or the camera's position and axes (beta.43 PR-2)
A new inventory row, sl.interposer.dll!slSetConstants, family FL_HOOK_SL_CONSTANTS (bit 13). InstallByFamily returns before resolving the symbol in a process never asked for Advanced metrics (D111), so nothing is patched with the option off. The detour checks the request, MayObserve, the struct's GUID and version and the viewport handle's on every call; fl_adv_fields.h reads jitterOffset, mvecScale, cameraNear, cameraFar, cameraFOV, cameraAspectRatio and the seven Booleans into region 5's sl group, summarised for the first viewport seen. tools/overlay-fields-check.ps1 gains the parameter k and thirteen list entries; the camera's names are still refused everywhere.

Measured on the headers with the Overlay's flags: +0.6 ns not asked, +19.6 ns asked on the summarised viewport, +5.8 ns on another.

ctest fl_adv_fields and fl_guard [advanced]: never asked - the export's first 16 bytes in the target are the file's; asked - the first viewport's numbers and none of the second's; no longer asked - the region unchanged; stopped - the bytes restored.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 11:28:35 +07:00
14 changed files with 636 additions and 23 deletions

No files matched your search

+12
View File
@@ -35,6 +35,18 @@ numeric core and does not move; the heading is the full version — corrected 20
## [Unreleased]
### Added
- **Advanced metrics, inside the game: what the game tells NVIDIA Streamline about each frame** (the part inside the
game; what a session shows of it comes with the same release). With **Advanced metrics** on, FrameLedger now also
reads, from a call a Streamline game makes every frame, the size of the jitter, the motion-vector scale, the depth
range, the range of the field of view, the aspect ratio and seven on/off settings (inverted depth, how motion
vectors are stored, whether the upscaler's history was reset). It never reads where the game's camera is, which
way it looks, or its matrices, which sit in the same data — a check in the build refuses any code that names
them. This is the first reading that needs a hook of its own, and that hook is put into a game only once
Advanced metrics has been asked for: with the option off, nothing in the game is touched for it. Measured cost:
about 20 billionths of a second per frame while the option is on, under one billionth while it is off.
### Fixed
- **FSR upscaling is counted once per frame whichever way the game's FidelityFX loader passes it on.** Newer
+6 -1
View File
@@ -133,7 +133,12 @@ What the region is, as a contract between the two sides:
beta.43~~ 0.1.0-beta.43 and beta.44 fill *(renumbered twice on 2026-11-12 — D118: a fix release took beta.41;
D122: the second step became two releases, and beta.42 fills none of them. The comments in `fl_shm.h` and
`ShmLayout.cs` carry the new numbers since beta.42)* (`ffxFg*`,
`sl*`, `features`) are declared now and stay zero until then, so those releases bump no layout.
`sl*`, `features`) are declared now and stay zero until then, so those releases bump no layout. **The `sl*` group
is filled since 0.1.0-beta.43** by the `slSetConstants` hook (`17_HOOK_ENGINE` §Hook inventory), under
`FL_ADV_VALID_SL_CONSTANTS`: the call count of every viewport, and for the first viewport seen the resets, the
jitter's largest magnitude, the motion-vector scale, the two depth planes, the field of view's range, the aspect
ratio, and one bit per `Boolean` in each of two words — seen true, seen false. `FlHookFamily` gains
`FL_HOOK_SL_CONSTANTS` (bit 13): the hook is in, which it is only in a process that was asked at least once.
- The 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.
+6 -2
View File
@@ -194,7 +194,8 @@ 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`, `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` | 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: `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
@@ -326,7 +327,10 @@ v2.8.0, v2.9.0, v2.10.0, v2.10.3, v2.11.1, v2.12.0, v2.14.1, v2.14.16):
`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
(`15589e577df9`). Streamline 1.x is refused before any read (`SpeaksStreamline2`).
(`15589e577df9`). Streamline 1.x is refused before any read (`SpeaksStreamline2`). **Since 0.1.0-beta.43 the
Overlay reads `sl::Constants`, and only members of version 1** — nothing of version 2 — so no version test beyond
"at least 1" is needed, and the read ends before `minRelativeLinearDepthObjectSeparation`, the member version 2
added.
**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
@@ -29,4 +29,7 @@ public enum HookFamilies
/// <summary>The Streamline detour decodes DLSS 5's neural rendering (beta.34, D84).</summary>
SlNeuralRendering = 1 << 12,
/// <summary><c>slSetConstants</c> is hooked (0.1.0-beta.43) - only where Advanced metrics was ever asked for.</summary>
SlConstants = 1 << 13,
}
+6
View File
@@ -280,6 +280,12 @@ public enum FlHookFamily : uint
/// writer that looked for neural rendering is told from one built before it could (<see cref="FlFeatureFlags.SlNeuralRendering"/>).
/// </summary>
SlNeuralRendering = 1u << 12,
/// <summary>
/// <c>slSetConstants</c> is hooked (0.1.0-beta.43, Advanced metrics train B). Only in a process that was asked for
/// Advanced metrics at least once; it tells "hooked, never called" from "not hooked", and entitles no frame field.
/// </summary>
SlConstants = 1u << 13,
}
/// <summary>
@@ -162,6 +162,22 @@ struct Accumulators {
std::atomic<uint64_t> ffxMemoryAliasableBytes{0u};
std::atomic<uint32_t> ffxMemoryQueries{0u};
std::atomic<uint32_t> ffxMemoryOwner{0u}; // leaf + 1 of the module whose answered queries are counted
// sl::Constants (0.1.0-beta.43), summarised - from the first viewport seen; the calls count every viewport
std::atomic<uint64_t> slViewport{0u}; // that viewport's id + 1; 0 = none yet
std::atomic<uint32_t> slConstantsCalls{0u};
std::atomic<uint32_t> slResets{0u};
std::atomic<uint32_t> slJitterMaxXBits{FL_ADV_FLOAT_NONE};
std::atomic<uint32_t> slJitterMaxYBits{FL_ADV_FLOAT_NONE};
std::atomic<uint32_t> slMvecScaleXBits{FL_ADV_FLOAT_NONE};
std::atomic<uint32_t> slMvecScaleYBits{FL_ADV_FLOAT_NONE};
std::atomic<uint32_t> slNearBits{FL_ADV_FLOAT_NONE};
std::atomic<uint32_t> slFarBits{FL_ADV_FLOAT_NONE};
std::atomic<uint32_t> slFovMinBits{FL_ADV_FLOAT_NONE};
std::atomic<uint32_t> slFovMaxBits{FL_ADV_FLOAT_NONE};
std::atomic<uint32_t> slAspectBits{FL_ADV_FLOAT_NONE};
std::atomic<uint32_t> slFlagsSeenTrue{0u};
std::atomic<uint32_t> slFlagsSeenFalse{0u};
};
// Whether `leaf` is the module whose calls a summary counts: the first one seen, and
@@ -307,6 +323,86 @@ inline void ObserveFfxMemoryQuery(uint32_t leaf, const ffxQueryDescHeader* desc,
}
}
// One sl::Boolean of sl::Constants into the two "seen" words: true sets its bit in `seenTrue`, false in `seenFalse`,
// the third state ("invalid": the game set nothing) in neither.
inline void NoteSlBoolean(sl::Boolean value, uint32_t bit, uint32_t& seenTrue, uint32_t& seenFalse) noexcept {
if (value == sl::Boolean::eTrue) {
seenTrue |= bit;
} else if (value == sl::Boolean::eFalse) {
seenFalse |= bit;
}
}
// What the game told Streamline about a frame (slSetConstants, 0.1.0-beta.43). The caller has matched the struct's
// GUID and found its version at least 1, on THIS call (fl_sl_inputs.h IsReadable): every member read below is one
// version 1 carries (17_HOOK_ENGINE "Which struct version carries which field").
//
// WHAT IS READ: the jitter, the motion-vector scale, the two depth planes, the field of view, the aspect ratio and
// the seven Booleans. WHAT IS NOT, EVER: the five matrices that precede them and the pinhole offset, the camera's
// position and its three axes that sit between the scale and the planes (rule 4). Nothing here names them, and
// tools/overlay-fields-check.ps1 fails the build if anything in the code loaded into a game does.
//
// THE SUMMARIES ARE THE FIRST VIEWPORT'S. A title with two viewports -- a scene and a picture-in-picture, a
// split screen -- sets constants for each every frame; "the last value seen" across them would flip twice a frame
// and a range would span two cameras. The first viewport that calls is the one summarised, for the life of the
// process. The call count is of every viewport: it says how often the game called.
//
// FLT_MAX IS "NOT SET" HERE (Streamline's INVALID_FLOAT) and is kept nowhere: the plane at infinity of D119 is
// FidelityFX's convention and stays on that route.
inline void ObserveSlConstants(const sl::Constants& k, uint32_t viewport, Accumulators& a) noexcept {
a.slConstantsCalls.fetch_add(1u, std::memory_order_relaxed);
const uint64_t me = static_cast<uint64_t>(viewport) + 1u;
uint64_t owner = a.slViewport.load(std::memory_order_relaxed);
if (owner == 0u && a.slViewport.compare_exchange_strong(owner, me, std::memory_order_relaxed)) {
owner = me;
}
if (owner != me) {
return;
}
if (Usable(k.jitterOffset.x) && Usable(k.jitterOffset.y)) {
KeepMax(a.slJitterMaxXBits, Magnitude(k.jitterOffset.x));
KeepMax(a.slJitterMaxYBits, Magnitude(k.jitterOffset.y));
}
if (Usable(k.mvecScale.x) && Usable(k.mvecScale.y)) {
a.slMvecScaleXBits.store(std::bit_cast<uint32_t>(k.mvecScale.x), std::memory_order_relaxed);
a.slMvecScaleYBits.store(std::bit_cast<uint32_t>(k.mvecScale.y), std::memory_order_relaxed);
}
if (Usable(k.cameraNear)) {
a.slNearBits.store(std::bit_cast<uint32_t>(k.cameraNear), std::memory_order_relaxed);
}
if (Usable(k.cameraFar)) {
a.slFarBits.store(std::bit_cast<uint32_t>(k.cameraFar), std::memory_order_relaxed);
}
// A range, lowest to highest, never a series (D114).
if (Usable(k.cameraFOV) && k.cameraFOV > 0.0f) {
KeepMin(a.slFovMinBits, k.cameraFOV);
KeepMax(a.slFovMaxBits, k.cameraFOV);
}
if (Usable(k.cameraAspectRatio) && k.cameraAspectRatio > 0.0f) {
a.slAspectBits.store(std::bit_cast<uint32_t>(k.cameraAspectRatio), std::memory_order_relaxed);
}
// One bit per Boolean, in the header's order (FlAdvancedState::slFlagsSeenTrue).
uint32_t seenTrue = 0u;
uint32_t seenFalse = 0u;
NoteSlBoolean(k.depthInverted, 1u << 0, seenTrue, seenFalse);
NoteSlBoolean(k.cameraMotionIncluded, 1u << 1, seenTrue, seenFalse);
NoteSlBoolean(k.motionVectors3D, 1u << 2, seenTrue, seenFalse);
NoteSlBoolean(k.reset, 1u << 3, seenTrue, seenFalse);
NoteSlBoolean(k.orthographicProjection, 1u << 4, seenTrue, seenFalse);
NoteSlBoolean(k.motionVectorsDilated, 1u << 5, seenTrue, seenFalse);
NoteSlBoolean(k.motionVectorsJittered, 1u << 6, seenTrue, seenFalse);
NoteBits(a.slFlagsSeenTrue, seenTrue);
NoteBits(a.slFlagsSeenFalse, seenFalse);
if ((seenTrue & (1u << 3)) != 0u) {
a.slResets.fetch_add(1u, std::memory_order_relaxed);
}
NoteBits(a.validMask, FL_ADV_VALID_SL_CONSTANTS);
}
// 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
@@ -343,6 +439,20 @@ inline void Reset(Accumulators& a) noexcept {
a.ffxMemoryTotalBytes.store(0u, relaxed);
a.ffxMemoryAliasableBytes.store(0u, relaxed);
a.ffxMemoryQueries.store(0u, relaxed);
// Which viewport is summarised stays, as the two owners do: a fact about the process.
a.slConstantsCalls.store(0u, relaxed);
a.slResets.store(0u, relaxed);
a.slJitterMaxXBits.store(FL_ADV_FLOAT_NONE, relaxed);
a.slJitterMaxYBits.store(FL_ADV_FLOAT_NONE, relaxed);
a.slMvecScaleXBits.store(FL_ADV_FLOAT_NONE, relaxed);
a.slMvecScaleYBits.store(FL_ADV_FLOAT_NONE, relaxed);
a.slNearBits.store(FL_ADV_FLOAT_NONE, relaxed);
a.slFarBits.store(FL_ADV_FLOAT_NONE, relaxed);
a.slFovMinBits.store(FL_ADV_FLOAT_NONE, relaxed);
a.slFovMaxBits.store(FL_ADV_FLOAT_NONE, relaxed);
a.slAspectBits.store(FL_ADV_FLOAT_NONE, relaxed);
a.slFlagsSeenTrue.store(0u, relaxed);
a.slFlagsSeenFalse.store(0u, relaxed);
}
// Copies the accumulators into region 5, under the request they answer. THE
@@ -410,6 +520,20 @@ inline void Publish(Accumulators& a, FlAdvancedState* region, uint32_t request,
put64(region->ffxMemoryAliasableBytes, a.ffxMemoryAliasableBytes.load(relaxed));
put32(region->ffxMemoryQueries, a.ffxMemoryQueries.load(relaxed));
put32(region->slConstantsCalls, a.slConstantsCalls.load(relaxed));
put32(region->slResets, a.slResets.load(relaxed));
put32(region->slJitterMaxXBits, a.slJitterMaxXBits.load(relaxed));
put32(region->slJitterMaxYBits, a.slJitterMaxYBits.load(relaxed));
put32(region->slMvecScaleXBits, a.slMvecScaleXBits.load(relaxed));
put32(region->slMvecScaleYBits, a.slMvecScaleYBits.load(relaxed));
put32(region->slNearBits, a.slNearBits.load(relaxed));
put32(region->slFarBits, a.slFarBits.load(relaxed));
put32(region->slFovMinBits, a.slFovMinBits.load(relaxed));
put32(region->slFovMaxBits, a.slFovMaxBits.load(relaxed));
put32(region->slAspectBits, a.slAspectBits.load(relaxed));
put32(region->slFlagsSeenTrue, a.slFlagsSeenTrue.load(relaxed));
put32(region->slFlagsSeenFalse, a.slFlagsSeenFalse.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);
@@ -124,7 +124,7 @@ inline constexpr uint32_t kFamiliesEvaluateFeatureDoesNotImplement =
static_cast<uint32_t>(fl::FL_HOOK_RT_AS_BUILD) | static_cast<uint32_t>(fl::FL_HOOK_RT_PSO) |
static_cast<uint32_t>(fl::FL_HOOK_PSO) | static_cast<uint32_t>(fl::FL_HOOK_COLOR_SPACE) |
static_cast<uint32_t>(fl::FL_HOOK_REFLEX) | static_cast<uint32_t>(fl::FL_HOOK_VRAM) |
static_cast<uint32_t>(fl::FL_HOOK_UPSCALER_QUALITY);
static_cast<uint32_t>(fl::FL_HOOK_UPSCALER_QUALITY) | static_cast<uint32_t>(fl::FL_HOOK_SL_CONSTANTS);
static_assert((kFamilyEvaluateFeature & kFamiliesEvaluateFeatureDoesNotImplement) == 0u,
"the slEvaluateFeature row claims a family its detour does not implement -- hookinventory-check "
@@ -207,7 +207,8 @@ inline constexpr uint32_t kFamiliesFfxDispatchDoesNotImplement =
static_cast<uint32_t>(fl::FL_HOOK_RT_AS_BUILD) | static_cast<uint32_t>(fl::FL_HOOK_RT_PSO) |
static_cast<uint32_t>(fl::FL_HOOK_PSO) | static_cast<uint32_t>(fl::FL_HOOK_COLOR_SPACE) |
static_cast<uint32_t>(fl::FL_HOOK_REFLEX) | static_cast<uint32_t>(fl::FL_HOOK_VRAM) |
static_cast<uint32_t>(fl::FL_HOOK_UPSCALER_QUALITY) | static_cast<uint32_t>(fl::FL_HOOK_SL_NEURAL_RENDERING);
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_assert((kFamilyFfxDispatch & kFamiliesFfxDispatchDoesNotImplement) == 0u,
"the ffxDispatch rows claim a family their detour does not implement -- hookinventory-check reads "
@@ -278,6 +279,29 @@ static_assert(kFamilyFfxQuery != kFamilyFfxDispatch && kFamilyFfxQuery != kFamil
static_assert((kFamilyFfxDispatch & kFamilyFfxQuery) == 0u,
"the dispatch rows must not claim the query's bit: they do not hook ffxQuery");
// --- Streamline: slSetConstants (0.1.0-beta.43, Advanced metrics train B, owner decisions D111-D116) ---
//
// WHAT THE GAME TELLS STREAMLINE ABOUT A FRAME, once per frame and viewport: the jitter, the motion-vector scale,
// the depth range, the field of view, the aspect ratio and seven Booleans -- beside five matrices and the camera's
// position and axes, WHICH ARE NEVER READ (rule 4; tools/overlay-fields-check.ps1 refuses their names anywhere in
// the code loaded into a game). One exporter, sl.interposer.dll, like the other Streamline rows.
//
// THE ONE ROW THAT IS NOT INSTALLED UNLESS ASKED FOR. Every other row is patched when its module appears; this one
// only in a process the Agent has asked for Advanced metrics at least once (D111: with the option off, nothing more
// is read -- and nothing more is patched). dllmain's installer checks that BEFORE it resolves the symbol, because
// resolving takes a reference on the module. Once in, the patch stays for the life of the process and the detour
// forwards without looking while the request is off.
//
// ITS OWN BIT. It entitles no measured field of a frame record; the bit says the hook is in, so that a session can
// tell "hooked, and the game never called it" from "not hooked".
inline constexpr uint32_t kFamilySlConstants = static_cast<uint32_t>(fl::FL_HOOK_SL_CONSTANTS);
static_assert(kFamilySlConstants != kFamilyEvaluateFeature && kFamilySlConstants != kFamilyFfxDispatch &&
kFamilySlConstants != kFamilyFfxQuery &&
kFamilySlConstants != static_cast<uint32_t>(fl::FL_HOOK_UPSCALER_PARAMS) &&
kFamilySlConstants != static_cast<uint32_t>(fl::FL_HOOK_FG_EVALUATIONS),
"InstallByFamily binds a row by EQUALITY on this value -- a collision would hand slSetConstants' "
"detour to another export, or another's to it");
// The leaves, in the order dllmain's per-leaf trampoline and latch arrays are indexed.
enum FfxLeaf : uint32_t {
kFfxLeafMonolith = 0, // amd_fidelityfx_dx12.dll -- SDK 1.1.x, FSR 3.1 only
@@ -373,6 +397,7 @@ inline int FfxLeafOf(const wchar_t* moduleName) noexcept {
X(L"sl.interposer.dll", "slSetTag", fl::FL_HOOK_UPSCALER_PARAMS) \
X(L"sl.interposer.dll", "slSetTagForFrame", fl::FL_HOOK_UPSCALER_PARAMS) \
X(L"sl.interposer.dll", "slGetNewFrameToken", fl::FL_HOOK_FG_EVALUATIONS) \
X(L"sl.interposer.dll", "slSetConstants", fl::inventory::kFamilySlConstants) \
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) \
@@ -388,7 +413,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 == 13u, "a row was added or removed: say so here, and in 17_HOOK_ENGINE §Hook inventory");
static_assert(kRowCount == 14u, "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
+40 -1
View File
@@ -1166,7 +1166,13 @@ std::atomic<uint32_t> g_slSetTagForFramePatched{0};
using PFN_SlGetNewFrameToken = ::PFun_slGetNewFrameToken*;
PFN_SlGetNewFrameToken g_origSlGetNewFrameToken = nullptr;
std::atomic<uint32_t> g_frameTokensLive{0};
std::atomic<uint32_t> g_frameTokens{0};
// slSetConstants (0.1.0-beta.43, Advanced metrics): patched only in a process that was asked for Advanced metrics at
// least once (InstallByFamily), and its detour forwards without looking while the request is off.
using PFN_SlSetConstants = ::PFun_slSetConstants*;
PFN_SlSetConstants g_origSlSetConstants = nullptr;
std::atomic<uint32_t> g_slConstantsLive{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
@@ -1724,6 +1730,26 @@ sl::Result STDMETHODCALLTYPE Hook_SlSetTag(const sl::ViewportHandle& viewport, c
return g_origSlSetTag(viewport, tags, numTags, cmdBuffer);
}
// What the game tells Streamline about a frame (0.1.0-beta.43). THREE CONDITIONS BEFORE ANYTHING IS READ, in the
// order that costs least: the Agent is asking for Advanced metrics; observing has not stopped (after a stop nobody
// clears the request word, so the first test alone would keep reading); and the struct is the one these headers
// describe -- its GUID and a version of at least 1, checked on THIS call, because the game owns the struct and a
// Streamline generation that lays it out differently keeps the export's name. The struct is read in
// fl_adv_fields.h, which never touches its matrices or the camera's position and axes (rule 4). The viewport's id
// is the handle's own conversion to an integer, taken only from a handle that is one (the same GUID check).
sl::Result STDMETHODCALLTYPE Hook_SlSetConstants(const sl::Constants& values, const sl::FrameToken& frame,
const sl::ViewportHandle& viewport) {
FL_HOOK_GUARD({
if (g_advancedRequested.load(std::memory_order_relaxed) != 0u && MayObserve() &&
fl::slinputs::IsReadable<sl::Constants>(&values) &&
fl::slinputs::IsReadable<sl::ViewportHandle>(&viewport)) {
fl::adv::ObserveSlConstants(values, static_cast<uint32_t>(viewport), g_adv);
}
})
// ALWAYS exactly once, on every path including the fault path, with every argument forwarded untouched.
return g_origSlSetConstants(values, frame, viewport);
}
// 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
@@ -2426,6 +2452,19 @@ bool InstallByFamily(const wchar_t* moduleName, const char* symbol, uint32_t fam
// bit test would bind any future row that happens to include identity to THIS
// detour -- which is the neighbour's-body defect this function exists to stop,
// and it would arrive silently because the row would still install.
//
// THE ROWS THAT ARE INSTALLED ONLY WHERE ADVANCED METRICS WAS EVER ASKED FOR (owner decision D111), FIRST -- before
// anything is resolved, because ResolveScoped takes a reference on the module at every call: in a process never
// asked, these rows must change nothing, not even a reference count. g_advancedSeen is the watchdog's, and this
// runs on the watchdog, after the block that sets it. Once the patch is in it stays; the detour forwards without
// looking while the request is off.
if (family == fl::inventory::kFamilySlConstants) {
if (g_advancedSeen == 0u) {
return false;
}
return InstallRow(moduleName, symbol, family, reinterpret_cast<void*>(&Hook_SlSetConstants),
reinterpret_cast<void**>(&g_origSlSetConstants), g_slConstantsLive, name);
}
if (family == fl::inventory::kFamilyEvaluateFeature) {
return InstallRow(moduleName, symbol, family, reinterpret_cast<void*>(&Hook_SlEvaluateFeature),
reinterpret_cast<void**>(&g_origSlEvaluateFeature), g_upscalerIdentityLive, name);
@@ -405,6 +405,11 @@ enum FlHookFamily : uint32_t {
// FL_FEAT_RAY_RECONSTRUCTION_OBSERVED and never bit 7, and without this family its silence would read as a
// measured "not running" -- a fabricated negative of the kind 03_METRICS §RT/PT/RR forbids for ray reconstruction.
FL_HOOK_SL_NEURAL_RENDERING = 1u << 12,
// Advanced metrics, train B's second step (0.1.0-beta.43): slSetConstants is hooked. Published only in a process
// that was asked for Advanced metrics at least once -- the patch is not made otherwise (owner decision D111) --
// so its absence beside FL_ADV_VALID_* bits says "the hook was not installed", and its presence beside a zero
// slConstantsCalls says "hooked, and the game never called it". It entitles no measured field of a frame record.
FL_HOOK_SL_CONSTANTS = 1u << 13,
};
// FlWriterState::runtimeCensus -- which vendor RUNTIME MODULES the loader reported
+153 -12
View File
@@ -6959,6 +6959,16 @@ constexpr float kAdvFfxFar = 1000.0f;
constexpr float kAdvFfxFovLow = 0.9f;
constexpr float kAdvFfxFovHigh = 1.1f;
constexpr uint32_t kAdvFfxFrameTimeUs = 16000u;
// ...and hands slSetConstants for viewport 0 (0.1.0-beta.43); a second viewport gets other numbers every frame.
constexpr float kAdvSlJitterX = 0.3125f;
constexpr float kAdvSlJitterY = 0.4375f;
constexpr float kAdvSlMvecScaleX = 0.5f;
constexpr float kAdvSlMvecScaleY = 0.25f;
constexpr float kAdvSlNear = 0.25f;
constexpr float kAdvSlFar = 4000.0f;
constexpr float kAdvSlFovLow = 0.8f;
constexpr float kAdvSlFovHigh = 1.2f;
constexpr float kAdvSlAspect = 1.75f;
constexpr uint64_t kAdvMemoryTotal = 123456789ull;
constexpr uint64_t kAdvMemoryAliasable = 23456789ull;
@@ -7017,16 +7027,63 @@ uint32_t BitsOf(float v) {
return std::bit_cast<uint32_t>(v);
}
// What 0.1.0-beta.43 and beta.44 fill (beta.41 and beta.42 until D118 and D122): declared, written by nothing yet.
// What later releases fill: declared, written by nothing yet. (The sl::Constants group left this list with
// 0.1.0-beta.43, which fills it; SlConstantsAreUnread below is for a target that never calls slSetConstants.)
bool LaterGroupsAreZero(const fl::FlAdvancedState& a) {
bool zero = a.ffxFgConfigures == 0u && a.ffxFgEnabledSeen == 0u && a.ffxFgFlagsSeen == 0u &&
a.slConstantsCalls == 0u && a.slResets == 0u && a.slFlagsSeenTrue == 0u && a.slFlagsSeenFalse == 0u;
bool zero = a.ffxFgConfigures == 0u && a.ffxFgEnabledSeen == 0u && a.ffxFgFlagsSeen == 0u;
for (uint32_t i = 0; i < FL_ADV_FEATURE_SLOTS * FL_ADV_FEATURE_WORDS; ++i) {
zero = zero && a.features[i] == 0u;
}
return zero;
}
bool SlConstantsAreUnread(const fl::FlAdvancedState& a) {
return a.slConstantsCalls == 0u && a.slResets == 0u && a.slFlagsSeenTrue == 0u && a.slFlagsSeenFalse == 0u &&
(a.validMask & fl::FL_ADV_VALID_SL_CONSTANTS) == 0u;
}
// The first 16 bytes of one export of a module AS THEY ARE IN ANOTHER PROCESS: the export's offset from this
// process's own mapping of the same file (mapped as an image, nothing run), the module's base from the target's
// module list. What a patch changes, and what a restore puts back.
bool ReadTargetExportBytes(DWORD pid, const wchar_t* dllPath, const char* symbol, unsigned char out[16]) {
const HMODULE mine = LoadLibraryExW(dllPath, nullptr, DONT_RESOLVE_DLL_REFERENCES);
if (mine == nullptr) {
return false;
}
const auto* entry = reinterpret_cast<const unsigned char*>(GetProcAddress(mine, symbol));
const size_t rva =
entry != nullptr ? static_cast<size_t>(entry - reinterpret_cast<const unsigned char*>(mine)) : 0u;
FreeLibrary(mine);
const wchar_t* slash = wcsrchr(dllPath, L'\\');
const wchar_t* slash2 = wcsrchr(dllPath, L'/');
const wchar_t* leaf = slash != nullptr && (slash2 == nullptr || slash > slash2) ? slash + 1
: slash2 != nullptr ? slash2 + 1
: dllPath;
if (rva == 0u) {
return false;
}
HANDLE h = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION | PROCESS_VM_READ, FALSE, pid);
if (h == nullptr) {
return false;
}
HMODULE mods[1024]{};
DWORD needed = 0;
bool read = false;
if (EnumProcessModulesEx(h, mods, sizeof(mods), &needed, LIST_MODULES_ALL)) {
const size_t n = (needed > sizeof(mods) ? sizeof(mods) : needed) / sizeof(HMODULE);
for (size_t i = 0; i < n && !read; ++i) {
wchar_t name[MAX_PATH]{};
if (GetModuleBaseNameW(h, mods[i], name, MAX_PATH) != 0 && _wcsicmp(name, leaf) == 0) {
SIZE_T got = 0;
read = ReadProcessMemory(h, reinterpret_cast<const unsigned char*>(mods[i]) + rva, out, 16, &got) &&
got == 16;
}
}
}
CloseHandle(h);
return read;
}
} // namespace
TEST_CASE("region 5 stays empty until the Agent asks, then carries what an FSR title told its upscaler, per request",
@@ -7094,6 +7151,7 @@ TEST_CASE("region 5 stays empty until the Agent asks, then carries what an FSR t
// hands the same query on to the leaf and both are hooked.
CHECK(a.ffxMemoryTotalBytes == kAdvMemoryTotal);
CHECK(a.ffxMemoryAliasableBytes == kAdvMemoryAliasable);
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));
@@ -7160,10 +7218,14 @@ 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 the DLSS options a title chains into its evaluation, and only while asked",
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",
"[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.
Child child;
REQUIRE(StartHarness(child, L"--real --advanced --hold-presenting-upscaled 30"));
REQUIRE(StartHarness(child, L"--real --advanced --hold-presenting-upscaled 60"));
ResetFake();
g.modules = {"kernel32.dll"};
@@ -7176,19 +7238,40 @@ TEST_CASE("region 5 carries the DLSS options a title chains into its evaluation,
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);
// Not asked: the evaluation is hooked, the options are chained into every one, and none of it is kept.
// ---- 1. NEVER ASKED (owner decision D111): the evaluation is hooked, the game calls slSetConstants every frame,
// and that export is not patched -- its first bytes in the target are the file's -- nor is anything kept.
unsigned char pristine[16]{};
unsigned char now[16]{};
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_SL_INTERPOSER, "slSetConstants", pristine));
const std::uint64_t atHooks = r.st->writeIndex;
TickFor(r, 2500);
TickFor(r, 2500); // two watchdog ticks and more: every row that installs unasked has had its chance
REQUIRE(r.st->writeIndex > atHooks + 30u);
CHECK(RegionFiveIsZero(r));
CHECK((r.st->hooksInstalledMask & slConstants) == 0u);
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_SL_INTERPOSER, "slSetConstants", now));
CHECK(std::memcmp(pristine, now, sizeof(now)) == 0);
// ---- 2. ASKED: the patch goes in on the tick that sees the request, and the next publications carry both groups.
SetAdvancedRequest(r, 1u);
REQUIRE(WaitForHookFamily(r.st, slConstants));
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_SL_INTERPOSER, "slSetConstants", now));
CHECK(std::memcmp(pristine, now, sizeof(now)) != 0); // patched now
fl::FlAdvancedState a{};
REQUIRE(ReadAdvanced(r, 1u, a, 0u, fl::FL_ADV_VALID_DLSS_OPTIONS));
INFO("mask 0x" << std::hex << a.validMask << std::dec << " version " << a.dlssStructVersion << " seen "
<< a.dlssOptionsSeen << " output " << a.dlssOutputWidth << "x" << a.dlssOutputHeight);
CHECK(a.validMask == static_cast<uint32_t>(fl::FL_ADV_VALID_DLSS_OPTIONS)); // no ffx call in this target
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));
}
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));
// 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);
CHECK(a.dlssOutputWidth == kAdvDlssOutputW);
@@ -7207,11 +7290,69 @@ TEST_CASE("region 5 carries the DLSS options a title chains into its evaluation,
CHECK(a.dlssColorBuffersHdr == 1u);
CHECK(a.dlssAutoExposure == 2u);
CHECK(a.dlssAlphaUpscaling == 2u);
CHECK(a.ffxDispatches == 0u);
// What the game told slSetConstants for the FIRST viewport: exactly the harness's numbers, and not one of the
// second viewport's (near 9, far 99, a field of view of 2, depth not inverted, an orthographic projection).
CHECK(a.slConstantsCalls > 60u); // both viewports' calls are counted
CHECK(a.slJitterMaxXBits == BitsOf(kAdvSlJitterX));
CHECK(a.slJitterMaxYBits == BitsOf(kAdvSlJitterY));
CHECK(a.slMvecScaleXBits == BitsOf(kAdvSlMvecScaleX));
CHECK(a.slMvecScaleYBits == BitsOf(kAdvSlMvecScaleY));
CHECK(a.slNearBits == BitsOf(kAdvSlNear));
CHECK(a.slFarBits == BitsOf(kAdvSlFar));
CHECK(a.slFovMinBits == BitsOf(kAdvSlFovLow)); // a range, never a series (D114)
CHECK(a.slFovMaxBits == BitsOf(kAdvSlFovHigh));
CHECK(a.slAspectBits == BitsOf(kAdvSlAspect));
// Bits in the header's order: depthInverted 0, cameraMotionIncluded 1, motionVectors3D 2, reset 3,
// orthographicProjection 4, motionVectorsDilated 5, motionVectorsJittered 6.
CHECK(a.slFlagsSeenTrue == ((1u << 0) | (1u << 1) | (1u << 3) | (1u << 6)));
CHECK(a.slFlagsSeenFalse == ((1u << 2) | (1u << 3) | (1u << 4) | (1u << 5)));
CHECK(a.slResets >= 1u);
CHECK(a.slResets * 32u < a.slConstantsCalls); // one frame in sixty-four of ONE viewport, not of both
CHECK(a.ffxDispatches == 0u); // no ffx call in this target
CHECK(a.ffxSharpnessMinBits == FL_ADV_FLOAT_NONE); // a float nobody saw is "none", never 0.0
CHECK(a.ffxMemoryQueries == 0u);
CHECK(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).
SetAdvancedRequest(r, 0u);
TickFor(r, 1500);
fl::FlAdvancedState held{};
std::memcpy(&held, RegionFive(r), sizeof(held));
TickFor(r, 2500);
CHECK(std::memcmp(&held, RegionFive(r), sizeof(held)) == 0);
CHECK((r.st->hooksInstalledMask & slConstants) != 0u);
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_SL_INTERPOSER, "slSetConstants", now));
CHECK(std::memcmp(pristine, now, sizeof(now)) != 0);
CHECK(r.st->faultCount == 0u);
CHECK(r.st->status == fl::FL_STATUS_READY);
// ---- 4. STOPPED: the export's first bytes are the file's again, and the log says which patch was restored.
r.ctl->unhookRequested = 1;
for (int i = 0; i < 60 && r.st->status != fl::FL_STATUS_UNHOOKED; ++i) {
++r.ctl->guardTicks;
Sleep(50);
}
REQUIRE(r.st->status == fl::FL_STATUS_UNHOOKED);
std::wstring log;
std::string text;
for (int i = 0; i < 100; ++i) {
if ((!log.empty() || FindOverlayLog(child.pi.dwProcessId, child.pi.hProcess, log))) {
text = ReadWholeFile(log);
if (text.find("STOP_FLUSHED") != std::string::npos) {
break;
}
}
Sleep(100);
}
INFO("after the stop:\n" << text);
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_SL_INTERPOSER, "slSetConstants", now));
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);
CHECK(text.find("UNHOOK_DECLINED") == std::string::npos);
CHECK(text.find("PATCH_FAILED") == std::string::npos);
}
+214 -1
View File
@@ -115,7 +115,10 @@
// --advanced send what Advanced metrics reads (train B, 0.1.0-beta.40): --hold-presenting-upscaled chains an
// sl::DLSSOptions into slEvaluateFeature's inputs, --hold-presenting-ffx fills the rest of the
// UPSCALE descriptor (sharpening, jitter, exposure, depth range, field of view, flags, frame time).
// The values are the kAdv* constants below; the injected fl_guard cases assert them
// The values are the kAdv* constants below; the injected fl_guard cases assert them.
// Since 0.1.0-beta.43 the upscaled hold also calls slSetConstants every frame, for viewport 0
// (kAdvSl*) and for a second viewport whose numbers must never be shown, with the matrices and
// the camera's position and axes - which the Overlay never reads - set to loud, changing values
// --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)
@@ -2002,6 +2005,17 @@ bool ProbeSlInputs() {
// send. A UNIT PROBE, as --probe-sl-inputs is: what matters here is a struct of an OLDER VERSION than these headers
// declare, whose tail must not be read (owner decision D115), and the vendors' own sentinels and zeros, which must
// never leave the header as values. No fixture title can be made to send a version-1 DLSSOptions; this can.
// A read of sl::Constants at an address chosen by the caller, in a function of its own so that the SEH frame holds no
// object with a destructor. True when the read faulted.
bool ObserveSlConstantsFaults(const void* constants, fl::adv::Accumulators& a) {
__try {
fl::adv::ObserveSlConstants(*static_cast<const sl::Constants*>(constants), 0u, 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); };
@@ -2311,6 +2325,140 @@ bool ProbeAdvFields() {
"and nothing of the session before: no mask, no count, no range, no size");
delete region;
}
// --- sl::Constants, what the game tells Streamline about a frame (0.1.0-beta.43) ------------------------------
{
fl::adv::Accumulators a;
sl::Constants c;
c.jitterOffset = {-0.375f, 0.25f};
c.mvecScale = {0.5f, 0.25f};
c.cameraNear = 0.1f;
c.cameraFar = 5000.0f;
c.cameraFOV = 1.0f;
c.cameraAspectRatio = 1.6f;
c.depthInverted = sl::Boolean::eTrue;
c.cameraMotionIncluded = sl::Boolean::eFalse;
c.reset = sl::Boolean::eFalse;
c.motionVectorsJittered = sl::Boolean::eTrue; // motionVectors3D is left in its third state
fl::adv::ObserveSlConstants(c, 3u, a);
c.jitterOffset = {0.125f, -0.4375f};
c.cameraFOV = 0.6f;
c.reset = sl::Boolean::eTrue;
fl::adv::ObserveSlConstants(c, 3u, a);
Check(a.validMask.load() == fl::FL_ADV_VALID_SL_CONSTANTS && a.slConstantsCalls.load() == 2u,
"two calls, counted, and the group marked read");
Check(a.slJitterMaxXBits.load() == bitsOf(0.375f) && a.slJitterMaxYBits.load() == bitsOf(0.4375f),
"the jitter is the largest magnitude on each axis");
Check(a.slMvecScaleXBits.load() == bitsOf(0.5f) && a.slMvecScaleYBits.load() == bitsOf(0.25f),
"the motion-vector scale is kept");
Check(a.slNearBits.load() == bitsOf(0.1f) && a.slFarBits.load() == bitsOf(5000.0f), "the depth range is kept");
Check(a.slFovMinBits.load() == bitsOf(0.6f) && a.slFovMaxBits.load() == bitsOf(1.0f),
"the field of view is a range, lowest and highest (D114)");
Check(a.slAspectBits.load() == bitsOf(1.6f), "the aspect ratio is kept");
// Bits in the header's order: depthInverted 0, cameraMotionIncluded 1, motionVectors3D 2, reset 3,
// orthographicProjection 4, motionVectorsDilated 5, motionVectorsJittered 6.
Check(a.slFlagsSeenTrue.load() == ((1u << 0) | (1u << 3) | (1u << 6)),
"a Boolean seen true sets its bit: depth inverted, reset, jittered");
Check(a.slFlagsSeenFalse.load() == ((1u << 1) | (1u << 3) | (1u << 4) | (1u << 5)),
"a Boolean seen false sets its bit in the other word; one in its third state sets neither");
Check(a.slResets.load() == 1u, "a reset is counted");
// A SECOND VIEWPORT is counted as a call and summarised nowhere.
sl::Constants other;
other.jitterOffset = {0.9f, 0.9f};
other.cameraNear = 9.0f;
other.cameraFar = 99.0f;
other.cameraFOV = 2.0f;
other.depthInverted = sl::Boolean::eFalse;
other.reset = sl::Boolean::eTrue;
fl::adv::ObserveSlConstants(other, 4u, a);
Check(a.slConstantsCalls.load() == 3u, "a call for another viewport is a call");
Check(a.slNearBits.load() == bitsOf(0.1f) && a.slFovMaxBits.load() == bitsOf(1.0f) &&
a.slJitterMaxXBits.load() == bitsOf(0.375f) && a.slResets.load() == 1u &&
(a.slFlagsSeenFalse.load() & 1u) == 0u,
"and the summaries stay the first viewport's: no value, range, flag or reset of the second");
// The handle's own "no viewport" value is a viewport like another.
fl::adv::Accumulators last;
fl::adv::ObserveSlConstants(c, 0xFFFFFFFFu, last);
fl::adv::ObserveSlConstants(other, 0u, last);
Check(last.slNearBits.load() == bitsOf(0.1f) && last.slConstantsCalls.load() == 2u,
"a first viewport of 0xFFFFFFFF owns the summaries; viewport 0 after it does not");
// SENTINELS: a struct the game set nothing in. FLT_MAX is Streamline's INVALID_FLOAT - on THIS route it is
// "not set", never the plane at infinity (D119 is the ffx route's).
fl::adv::Accumulators unset;
sl::Constants blank;
fl::adv::ObserveSlConstants(blank, 0u, unset);
Check(unset.slNearBits.load() == FL_ADV_FLOAT_NONE && unset.slFarBits.load() == FL_ADV_FLOAT_NONE &&
unset.slFovMinBits.load() == FL_ADV_FLOAT_NONE && unset.slAspectBits.load() == FL_ADV_FLOAT_NONE &&
unset.slJitterMaxXBits.load() == FL_ADV_FLOAT_NONE &&
unset.slMvecScaleXBits.load() == FL_ADV_FLOAT_NONE,
"INVALID_FLOAT - FLT_MAX - is 'no value' in every member, a depth plane included");
Check(unset.slFlagsSeenTrue.load() == 0u &&
unset.slFlagsSeenFalse.load() == ((1u << 4) | (1u << 5) | (1u << 6)),
"the four Booleans in their third state are neither; the three the vendor defaults to false are false");
blank.cameraFOV = -1.0f;
blank.cameraAspectRatio = 0.0f;
blank.jitterOffset = {0.5f, std::bit_cast<float>(0x7FC00000u)};
fl::adv::ObserveSlConstants(blank, 0u, unset);
Check(unset.slFovMinBits.load() == FL_ADV_FLOAT_NONE && unset.slAspectBits.load() == FL_ADV_FLOAT_NONE &&
unset.slJitterMaxXBits.load() == FL_ADV_FLOAT_NONE,
"a field of view or an aspect ratio that is not positive is not one; half a jitter is no jitter");
// WHERE THE MEMBERS ARE, by the addresses of this build's own struct: the two ranges never read are bytes
// 32..351 (five matrices) and 368..423 (the pinhole offset, the camera's position and its three axes).
const auto at = [&c](const void* member) {
return static_cast<size_t>(static_cast<const unsigned char*>(member) -
reinterpret_cast<const unsigned char*>(&c));
};
Check(at(&c.cameraViewToClip) == 32u && at(&c.jitterOffset) == 352u && at(&c.mvecScale) == 360u,
"the five matrices are bytes 32..351; the jitter and the scale follow at 352 and 360");
Check(at(&c.cameraPinholeOffset) == 368u && at(&c.cameraNear) == 424u,
"the pinhole offset, the camera's position and its axes are bytes 368..423; the near plane is at 424");
// NOTHING OF THOSE TWO RANGES REACHES WHAT IS PUBLISHED. Two structs alike in every member that is read and
// different in every byte that is not: the accumulators come out byte for byte the same.
sl::Constants p = c;
sl::Constants q = c;
std::memset(reinterpret_cast<unsigned char*>(&p) + 32u, 0x11, 352u - 32u);
std::memset(reinterpret_cast<unsigned char*>(&p) + 368u, 0x11, 424u - 368u);
std::memset(reinterpret_cast<unsigned char*>(&q) + 32u, 0xEE, 352u - 32u);
std::memset(reinterpret_cast<unsigned char*>(&q) + 368u, 0xEE, 424u - 368u);
auto* regionP = new fl::FlAdvancedState{};
auto* regionQ = new fl::FlAdvancedState{};
fl::adv::Accumulators ap;
fl::adv::Accumulators aq;
fl::adv::ObserveSlConstants(p, 0u, ap);
fl::adv::ObserveSlConstants(q, 0u, 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->slNearBits == bitsOf(0.1f) &&
regionP->slConstantsCalls == 1u,
"two structs that differ only in the matrices and the camera publish the same bytes");
delete regionP;
delete regionQ;
// A VERSION-1 STRUCT ENDS WHERE VERSION 2's MEMBER BEGINS, and is read no further: laid against a page that
// cannot be read, it is read whole and nothing faults.
const size_t v1Size = at(&c.minRelativeLinearDepthObjectSeparation);
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 version-1 struct");
} else {
unsigned char* v1 = pages + 4096 - v1Size;
std::memcpy(v1, &c, v1Size);
fl::adv::Accumulators edge;
Check(!ObserveSlConstantsFaults(v1, edge),
"a version-1 struct at the end of readable memory is read without a fault");
Check(edge.slNearBits.load() == bitsOf(0.1f) && edge.slFlagsSeenTrue.load() != 0u,
"and what it carries is read: the last member version 1 has is the last one read");
VirtualFree(pages, 0, MEM_RELEASE);
}
}
return g_failures == 0;
}
@@ -2763,6 +2911,19 @@ constexpr float kAdvFfxFar = 1000.0f;
constexpr float kAdvFfxFovLow = 0.9f; // radians; the two alternate, frame by frame
constexpr float kAdvFfxFovHigh = 1.1f;
constexpr float kAdvFfxFrameTimeMs = 16.0f;
// What --advanced hands slSetConstants (0.1.0-beta.43), for viewport 0. The jitter and the field of view alternate
// frame by frame; `reset` is true on one frame in sixty-four. A SECOND viewport (7) is set every frame with
// different numbers, which must never be the ones a session shows.
constexpr float kAdvSlJitterX = 0.3125f; // the larger magnitude of the two that alternate
constexpr float kAdvSlJitterY = 0.4375f;
constexpr float kAdvSlMvecScaleX = 0.5f;
constexpr float kAdvSlMvecScaleY = 0.25f;
constexpr float kAdvSlNear = 0.25f;
constexpr float kAdvSlFar = 4000.0f;
constexpr float kAdvSlFovLow = 0.8f;
constexpr float kAdvSlFovHigh = 1.2f;
constexpr float kAdvSlAspect = 1.75f;
constexpr uint32_t kAdvSlOtherViewport = 7u;
using StubTokenFn = sl::Result(STDMETHODCALLTYPE*)(sl::FrameToken*&, const uint32_t*);
alignas(16) unsigned char g_dummyFrameToken[64]{};
@@ -2863,6 +3024,41 @@ int HoldPresentingUpscaled(Gfx& g, int seconds, bool real, sl::Feature feature,
options.performancePreset = sl::DLSSPreset::ePresetM;
options.ultraPerformancePreset = sl::DLSSPreset::ePresetL;
const sl::BaseStructure* advancedInputs[] = {&options};
// --advanced, 0.1.0-beta.43: the per-frame constants, through the stub's slSetConstants. Everything the Overlay may
// read is a known value; EVERYTHING IT MAY NOT -- the five matrices, the pinhole offset, the camera's position and
// axes -- is filled with loud numbers that change every frame, so a read of them would show in what is published.
// The frame token by address, as the other stub entry points take it: a reference parameter is a pointer in
// the ABI, and the harness has no token object, only storage of the right size.
using StubSetConstantsFn =
sl::Result(STDMETHODCALLTYPE*)(const sl::Constants&, const void*, const sl::ViewportHandle&);
auto setConstants =
reinterpret_cast<StubSetConstantsFn>(reinterpret_cast<void*>(GetProcAddress(stub, "slSetConstants")));
if (advanced && setConstants == nullptr) {
Check(false, "the stub exports slSetConstants");
return 1;
}
sl::Constants constants;
sl::Constants otherConstants;
sl::ViewportHandle otherViewport{kAdvSlOtherViewport};
constants.mvecScale = {kAdvSlMvecScaleX, kAdvSlMvecScaleY};
constants.cameraNear = kAdvSlNear;
constants.cameraFar = kAdvSlFar;
constants.cameraAspectRatio = kAdvSlAspect;
constants.depthInverted = sl::Boolean::eTrue;
constants.cameraMotionIncluded = sl::Boolean::eTrue;
constants.motionVectors3D = sl::Boolean::eFalse;
constants.orthographicProjection = sl::Boolean::eFalse;
constants.motionVectorsDilated = sl::Boolean::eFalse;
constants.motionVectorsJittered = sl::Boolean::eTrue;
otherConstants.jitterOffset = {0.9f, 0.9f};
otherConstants.mvecScale = {9.0f, 9.0f};
otherConstants.cameraNear = 9.0f;
otherConstants.cameraFar = 99.0f;
otherConstants.cameraFOV = 2.0f;
otherConstants.cameraAspectRatio = 9.0f;
otherConstants.depthInverted = sl::Boolean::eFalse;
otherConstants.orthographicProjection = sl::Boolean::eTrue;
if (advanced) {
std::printf(" --advanced: an sl::DLSSOptions (version %zu, output %ux%u) chained into every evaluation\n",
options.structVersion, kAdvDlssOutputW, kAdvDlssOutputH);
@@ -2881,6 +3077,23 @@ int HoldPresentingUpscaled(Gfx& g, int seconds, bool real, sl::Feature feature,
} else {
setTag(viewport, tags, numTags, nullptr);
}
if (advanced) {
const bool odd = (evaluated & 1) != 0;
const float loud = static_cast<float>(evaluated % 977) + 1000.0f;
constants.jitterOffset = {odd ? -kAdvSlJitterX : 0.125f, odd ? 0.0625f : -kAdvSlJitterY};
constants.cameraFOV = odd ? kAdvSlFovLow : kAdvSlFovHigh;
constants.reset = (evaluated % 64) == 5 ? sl::Boolean::eTrue : sl::Boolean::eFalse;
// What must never be read: a different loud value in each, every frame.
constants.cameraViewToClip.row[0] = {loud, loud + 1.0f, loud + 2.0f, loud + 3.0f};
constants.clipToPrevClip.row[3] = {loud + 4.0f, loud + 5.0f, loud + 6.0f, loud + 7.0f};
constants.cameraPinholeOffset = {loud + 8.0f, loud + 9.0f};
constants.cameraPos = {loud + 10.0f, loud + 11.0f, loud + 12.0f};
constants.cameraUp = {loud + 13.0f, loud + 14.0f, loud + 15.0f};
constants.cameraRight = {loud + 16.0f, loud + 17.0f, loud + 18.0f};
constants.cameraFwd = {loud + 19.0f, loud + 20.0f, loud + 21.0f};
setConstants(constants, g_dummyFrameToken, viewport);
setConstants(otherConstants, g_dummyFrameToken, otherViewport);
}
// ONE EVALUATION PER PRESENT, which is what a real upscaled title does
// and what makes the drained record's identity checkable frame by frame.
eval(feature, g_dummyFrameToken, advanced ? advancedInputs : nullptr, advanced ? 1u : 0u, nullptr);
@@ -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("slSetConstants"),
"fl_hook_inventory.h no longer contains \"slSetConstants\", so the constants fixture would exercise a "
"row the Overlay does not install.");
static_assert(fl::stub::InventoryHas("slSetTagForFrame"),
"fl_hook_inventory.h no longer contains \"slSetTagForFrame\", so the frame-based tag fixture would "
"exercise a row the Overlay does not install.");
@@ -144,6 +147,16 @@ SL_API sl::Result slIsFeatureLoaded(sl::Feature feature, bool& loaded) {
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,
const sl::ViewportHandle& viewport) {
(void)values;
(void)frame;
(void)viewport;
return sl::Result::eOk;
}
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.
+18
View File
@@ -43,6 +43,24 @@ ffxDispatchDescUpscale::flags
ffxDispatchDescUpscale::reset
ffxDispatchDescUpscale::frameTimeDelta
# sl::Constants, what the game tells slSetConstants about a frame (parameter `k`; 0.1.0-beta.43). The jitter, the
# motion-vector scale, the depth range, the field of view, the aspect ratio and the seven Booleans - numbers and
# switches of the kind a settings menu or a debug overlay shows. The five matrices, the pinhole offset, the camera's
# position and its three axes sit in the same struct and are refused by name wherever they appear (rule 4).
sl::Constants::jitterOffset
sl::Constants::mvecScale
sl::Constants::cameraNear
sl::Constants::cameraFar
sl::Constants::cameraFOV
sl::Constants::cameraAspectRatio
sl::Constants::depthInverted
sl::Constants::cameraMotionIncluded
sl::Constants::motionVectors3D
sl::Constants::reset
sl::Constants::orthographicProjection
sl::Constants::motionVectorsDilated
sl::Constants::motionVectorsJittered
# The upscaler's memory query: the header's type, the game's out-pointer in either version of the descriptor
# (parameter `q`), and what ffxQuery wrote through it after answering OK (parameter `m`)
ffxQueryDescHeader::type
+8 -3
View File
@@ -17,9 +17,9 @@
1. The reads are in ONE header, src/native/FrameLedger.Overlay/include/fl_adv_fields.h, through parameters with
fixed names - `o` (sl::DLSSOptions), `d` (ffxDispatchDescUpscale), `m` (FfxApiEffectMemoryUsage), `q` (the
memory query's descriptor) and `desc` (a query's header). Every member read through them is on
memory query's descriptor), `k` (sl::Constants, since 0.1.0-beta.43) and `desc` (a query's header). Every member read through them is on
tools/overlay-allowed-fields.txt, and every name on that list is read.
2. Those parameters are not aliased: each of the four letters appears only as `x.member` or where it is
2. Those parameters are not aliased: each of the five letters appears only as `x.member` or where it is
declared, and `->` is applied to nothing but `desc` and the Overlay's own `region`. So a member cannot be
read under a name this check does not look at.
3. No other source of the Overlay or the Vulkan layer reads a member the list names (the names every struct
@@ -55,6 +55,7 @@ $script:Parameter = [ordered]@{
d = 'ffxDispatchDescUpscale'
m = 'FfxApiEffectMemoryUsage'
q = 'ffxQueryDescUpscaleGetGPUMemoryUsage'
k = 'sl::Constants'
desc = 'ffxQueryDescHeader'
}
@@ -103,7 +104,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)\b(\s*\.\s*([A-Za-z_]\w*))?')) {
foreach ($m in [regex]::Matches($Code, '(?<![\w.>:])(o|d|m|q|k)\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)")
@@ -210,6 +211,10 @@ inline void Publish(Accumulators& a, FlAdvancedState* region) noexcept { region-
@{ Name = 'a pointer to it, and offsetof into it, pass'; Header = $goodHeader; List = $goodList; Other = $goodOther; Expect = 0 },
@{ Name = 'a name listed twice FAILS'; Header = $goodHeader; List = $goodList + "sl::DLSSOptions::outputWidth`n"; Other = $goodOther; Expect = 1 },
@{ Name = 'a line that is not one Struct::member FAILS'; Header = $goodHeader; List = $goodList + "sl::DLSSOptions::outputWidth # the size`n"; Other = $goodOther; Expect = 1 },
@{ Name = 'sl::Constants read through its parameter, each member on the list, passes'; Header = $goodHeader + "`ninline void ObserveK(const sl::Constants& k, uint32_t viewport, Accumulators& a) noexcept { a.n.store(k.cameraNear + k.jitterOffset.x); }"; List = $goodList + "sl::Constants::cameraNear`nsl::Constants::jitterOffset`n"; Other = $goodOther; Expect = 0 },
@{ Name = 'a member of sl::Constants the list does not allow FAILS'; Header = $goodHeader + "`ninline void ObserveK(const sl::Constants& k, Accumulators& a) noexcept { a.n.store(k.cameraNear + k.cameraFOV); }"; List = $goodList + "sl::Constants::cameraNear`n"; Other = $goodOther; Expect = 1 },
@{ Name = 'the camera read through the sl::Constants parameter FAILS, listed or not'; Header = $goodHeader + "`ninline void ObserveK(const sl::Constants& k, Accumulators& a) noexcept { a.n.store(k.cameraPos.x); }"; List = $goodList + "sl::Constants::cameraPos`n"; Other = $goodOther; Expect = 2 },
@{ Name = 'the sl::Constants parameter handed on whole FAILS'; Header = $goodHeader + "`ninline void ObserveK(const sl::Constants& k, Accumulators& a) noexcept { a.n.store(k.cameraNear); Other(k); }"; List = $goodList + "sl::Constants::cameraNear`n"; Other = $goodOther; Expect = 1 },
@{ Name = '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) {