Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a423420bcf |
No files matched your search
@@ -19,6 +19,24 @@ GitHub release body, so a missing section will mean an empty release note.
|
||||
|
||||
### Added
|
||||
|
||||
- **Displayed FPS counted by DXGI where the hook cannot count it — the 2.8.0 pacer's presents.** The
|
||||
owner's run on the DXGI counter landed `20_OPEN_QUESTIONS` §H5 row P1-DXGI twice: Dying Light: The
|
||||
Beast at DLSS Frame Generation ×4 on Streamline 2.8.0 reads 2.90 and 2.95 presents per hooked present
|
||||
that DXGI counted on the same chain and the inline patches never saw, while Streamline 2.7.3 (Hell Is
|
||||
Us, ×3.86) and 2.10.3 (the Onimusha: Way of the Sword demo, ×3.67) read 0.00 — their generated frames
|
||||
come through the patched bodies. So the record now carries `dxgiUnseen` (@52, from the reserved word,
|
||||
under `FL_MEASURED_DXGI_PRESENTS`, no layout bump; mirror and `fl-layout-dump` follow), and the
|
||||
consumer's window counts `Displayed = hooked + Σ dxgiUnseen` — in the rule-6 trio, in `presents/batch`
|
||||
and in the uniformity buckets, never in a frame-time distribution — printing *"Displayed is
|
||||
DXGI-COUNTED"* on its own line whenever the sum is above zero, because that number is a count DXGI
|
||||
made rather than this hook. `none` withdraws on that title by count; a saturated byte is refused like
|
||||
a saturated `fgEvaluations`; a byte under a clear bit is an honesty violation. A present the hook SAW and
|
||||
declined — a paused session — is not an unseen present: every declined present bumps an epoch that
|
||||
invalidates the chain's last reading, which the paused-session integration case caught (the first record
|
||||
after a resume claimed the whole pause, 0x55, before the guard). On every other title
|
||||
the window is byte-identical (five cases pin it; the injected `[fg]` case checks the byte is claimed
|
||||
and zero on the harness). `03_METRICS` §Displayed may be DXGI-COUNTED carries the rule.
|
||||
|
||||
- **DXGI's own present counter against the hook's, in the writer state and the report.** On the one shape
|
||||
where `none` is withheld (Streamline ≥ 2.8 with `sl.dlss_g.dll` loaded, Dying Light: The Beast), the
|
||||
open question was whether the closed pacer's generated presents reach DXGI through a body the inline
|
||||
|
||||
@@ -77,6 +77,31 @@ This is the metric the rewrite exists for. Resolution ladder, highest confidence
|
||||
published `presents / tokens` at or below 1.05 over a uniform window (§The source, below).
|
||||
Never from a hook that merely saw nothing (rung 0), and never from the census.
|
||||
|
||||
> ### Displayed may be DXGI-COUNTED — measured 2026-09-05 on Dying Light: The Beast
|
||||
>
|
||||
> `F_disp = presents observed by the hook` (§Counting, below) assumed every present reaches the
|
||||
> `Present` / `Present1` bodies the Overlay inline-patches. On Streamline 2.8.0 with DLSS Frame
|
||||
> Generation ×4 it does not: the hook timed 4,392 presents while `IDXGISwapChain::GetLastPresentCount`,
|
||||
> read on the same chain at every hooked present, moved by 17,133 — **2.90 unseen presents per hooked
|
||||
> one** (2.95 on the second capture) — against **0.00** on Streamline 2.7.3 (Hell Is Us, ×3.86) and
|
||||
> 2.10.3 (the Onimusha demo, ×3.67), where the generated presents come through the patched bodies. So
|
||||
> the record carries `dxgiUnseen` (@52, under `FL_MEASURED_DXGI_PRESENTS`) and the consumer's window
|
||||
> counts
|
||||
>
|
||||
> ```
|
||||
> F_disp = hooked presents + Σ dxgiUnseen (DXGI-COUNTED when the sum is > 0)
|
||||
> ```
|
||||
>
|
||||
> **When the sum is above zero the report says so on its own line — "Displayed is DXGI-COUNTED" —
|
||||
> because the number is then a count DXGI made, on the hooked chain, of presents this hook never
|
||||
> timed.** It may stand in the rule-6 trio and in `presents/batch`; it may NOT stand in a frame-time
|
||||
> distribution, which has no timestamps for those presents. The uniformity buckets take the same
|
||||
> numerator, so a session whose pacer stopped mid-way refuses exactly as one whose tokens stopped. A
|
||||
> saturated byte (255) is refused like a saturated `fgEvaluations`, and a present the hook saw and
|
||||
> declined (a paused session) is not unseen — the resume's first record differences nothing. `20_OPEN_QUESTIONS` §H5 keeps the
|
||||
> rows this landed on; which body the 2.8.0 pacer presents through is unlocalised and does not need
|
||||
> to be for the count.
|
||||
>
|
||||
> **RUNG 2 IS CONDITIONAL ON THE VENDOR, measured 2026-08-20, and this list read as
|
||||
> though it were not.** `--track_frame_type` is a **beta** option in PresentMon 2.5.1
|
||||
> and its own help says it *"requires application and/or driver instrumentation using
|
||||
|
||||
@@ -135,7 +135,7 @@ Every hook must be listed here with a purpose. Anything not on this list is not
|
||||
### Presentation
|
||||
| Hook | Purpose |
|
||||
|---|---|
|
||||
| ✅ `IDXGISwapChain::Present`, `Present1` | Frame boundary, QPC, sync interval, present flags. **`DXGI_PRESENT_TEST` calls are dropped without a record** — the occlusion probe submits nothing, and a minimised game emits a stream of them (`07_IPC` §Protocol rules). **Since 2026-09-05 the hook also reads `IDXGISwapChain::GetLastPresentCount` on the chain it just saw** (rule 4: the same COM object `FindOrAdd` already calls `GetDesc` on, no new hook) and publishes `dxgiPresentSamples` / `dxgiPresentsUnseen` — DXGI's count of presents on that chain that this hook never saw, the in-process half of `20_OPEN_QUESTIONS` §H5 Leg 1. One virtual call per hooked present, costed by `hook-harness --probe-frames` |
|
||||
| ✅ `IDXGISwapChain::Present`, `Present1` | Frame boundary, QPC, sync interval, present flags. **`DXGI_PRESENT_TEST` calls are dropped without a record** — the occlusion probe submits nothing, and a minimised game emits a stream of them (`07_IPC` §Protocol rules). **Since 2026-09-05 the hook also reads `IDXGISwapChain::GetLastPresentCount` on the chain it just saw** (rule 4: the same COM object `FindOrAdd` already calls `GetDesc` on, no new hook) and publishes `dxgiPresentSamples` / `dxgiPresentsUnseen` — DXGI's count of presents on that chain that this hook never saw, the in-process half of `20_OPEN_QUESTIONS` §H5 Leg 1. One virtual call per hooked present, costed by `hook-harness --probe-frames`. **And per record since the same night: `dxgiUnseen` @52 under `FL_MEASURED_DXGI_PRESENTS`**, so the consumer's window counts `Displayed = hooked + unseen` per bucket (`03_METRICS` §Displayed may be DXGI-COUNTED) — measured 2.90 / 2.95 on DL:TB at Streamline 2.8.0, 0 on 2.7.3 and 2.10.3 |
|
||||
| ✅ `IDXGISwapChain::ResizeBuffers` · ⏳ `ResizeTarget` | Output resolution changes mid-session. `ResizeBuffers` re-reads the swapchain description *after* the original returns; `ResizeTarget` is not hooked |
|
||||
| ⏳ `IDXGISwapChain::SetFullscreenState` | Fullscreen ↔ borderless transitions |
|
||||
| ⏳ `IDXGISwapChain3::SetColorSpace1` | HDR output detection. **`IDXGISwapChain3`, not 4** — 4 adds only `SetHDRMetaData` (`20_OPEN_QUESTIONS` §H9). Unbuilt, which is why `colorSpace` reads `NOT_REPORTED` and `FL_MEASURED_HDR` stays clear. **When it is built, the writer must initialise `colorSpace = FL_COLOR_SPACE_SDR` at swapchain identification** — an SDR title never calls `SetColorSpace1`, so "hook live, no call" would otherwise sit at `NOT_REPORTED` forever and HDR's definite `No` would be unreachable. DXGI documents G22/Rec.709 as the default, which makes SDR a *measured* default rather than an affirmative negative |
|
||||
|
||||
@@ -3317,6 +3317,22 @@ probe never showed a deadlock.
|
||||
> | **P5-DXGI** | 0 < r < 2.5, or r ≠ 0 with `streams > 1` | a mixed path or a second chain | stop and localise; the number is printed, never averaged into a factor |
|
||||
> | **P2/P4** | r ≈ 0 with ours ≈ 4× tokens, or the count itself moved | as the kernel rows say: not generating, or the title changed | the kernel rows above decide |
|
||||
>
|
||||
> **LANDED 2026-09-05 night, on the owner's run on #124 (`spike-notes` §9): row P1-DXGI, twice.** DL:TB at
|
||||
> DLSS FG ×4 read `unseen=12204 over samples=4136 (2.95)` at 21:56 and `unseen=12741 over samples=4392
|
||||
> (2.90)` at 22:06 — DXGI counted 3.9× the presents this hook did, on the SAME chain, which is the owner's
|
||||
> ~300 against ours ~75 from the afternoon, now measured in-process. The two controls read 0.00: Hell Is Us
|
||||
> (Streamline **2.7.3**, `79.89 → 308.14 (×3.86)` through the patched bodies, 18,207 samples) and the
|
||||
> owner's new title, the **Onimusha: Way of the Sword demo on Streamline 2.10.3** (`60.04 → 220.33
|
||||
> (×3.67)`, `DlssG`, `upscaler: Dlss`, 12,914 samples, 0 unseen). So **2.8.0's pacer is the odd one** —
|
||||
> 2.7.x before it and 2.10.x after it present the generated frames through `Present`'s body — and the
|
||||
> "`sl.interposer.dll` + `sl.common.dll` must be loaded on ≥ 2.8" lead is closed by 2.10.3, which injects,
|
||||
> tags on the frame route and counts exactly like 2.7. **The pre-committed action is built:** the record
|
||||
> carries `dxgiUnseen` (@52, `FL_MEASURED_DXGI_PRESENTS`), the window counts `Displayed = hooked +
|
||||
> unseen` and prints *"Displayed is DXGI-COUNTED"* on its own line, `presents/batch` takes the same
|
||||
> numerator, and `none` withdraws on DL:TB by count (`03_METRICS` §Displayed may be DXGI-COUNTED). Expected
|
||||
> on DL:TB's next capture: the trio at ≈ ×3.9 with the label, no withheld line, `frame generation: DlssG`.
|
||||
> Which body the 2.8.0 pacer reaches stays unlocalised, as the row said.
|
||||
>
|
||||
> Leg 1's rows (ours = `presents / span`; PM = PresentMon rows / span; C = the counter; ≈ = within 5 %):
|
||||
>
|
||||
> | Row | Reading | Meaning | Action |
|
||||
|
||||
+8
-5
@@ -766,11 +766,14 @@ Cyberpunk 2077 never chains `sl::DLSSOptions`, so 0xFF there is the title's trut
|
||||
populated without an NVIDIA-app override, the identity question has a producer that is not a
|
||||
hook and the owner decides whether `03_METRICS` gains a *driver-reported* rung (§H5 says what
|
||||
that rung may and may not claim). If it is not populated, the answer stays `N/A` and the
|
||||
session goes back to the PresentMon leg. **The in-process half of that leg is built (2026-09-05,
|
||||
late): the report's `DXGI present counter:` line on a DL:TB DLSS FG ×4 capture reads off §H5's
|
||||
`P1-DXGI` / `P3-DXGI` rows** — r ≈ 3 and the next PR labels a DXGI-counted Displayed rate, r ≈ 0
|
||||
and only PresentMon and the NVAPI read remain. The owner's "sl.common must be loaded on 2.8" lead
|
||||
was checked against the interposer source and is a launcher's concern, not this hook's (§H5).
|
||||
session goes back to the PresentMon leg. **The in-process half of that leg LANDED (2026-09-05,
|
||||
night): DL:TB at DLSS FG ×4 read 2.90 and 2.95 unseen presents per hooked one on the same chain —
|
||||
§H5 row P1-DXGI — while Streamline 2.7.3 (Hell Is Us) and 2.10.3 (the Onimusha demo) read 0.00, so
|
||||
2.8.0's pacer is the one that bypasses the patched bodies. The record now carries `dxgiUnseen` and
|
||||
the window counts `Displayed = hooked + unseen`, labelled DXGI-COUNTED (`03_METRICS`); DL:TB's next
|
||||
capture is expected to print the trio at ≈ ×3.9 with that label and no withheld line.** The
|
||||
"sl.common must be loaded on 2.8" lead is closed by the 2.10.3 title, which injects and counts like
|
||||
2.7 (§H5).
|
||||
|
||||
#### 7b. Titles whose upscaler or frame generation is compiled into the executable
|
||||
|
||||
|
||||
@@ -1823,6 +1823,25 @@ one launch per capture, consent granted after launch. Exit codes and full report
|
||||
lesson). The owner's settings for that run are recorded when known; the earlier 14:01 run at MFG ×3 read
|
||||
`×2.98` with `tokens/batch 1.00` on the same title.
|
||||
|
||||
- **2026-09-05 night, the owner's run on #124 (the DXGI present counter) — DL:TB twice, Hell Is Us, and a
|
||||
new title, the Onimusha: Way of the Sword demo on Streamline 2.10.3.** `20_OPEN_QUESTIONS` §H5 row
|
||||
P1-DXGI landed on the first title and both controls read zero:
|
||||
|
||||
| Title / Streamline | Trio or Presented | `DXGI present counter:` | `frame generation:` |
|
||||
|---|---|---|---|
|
||||
| **Dying Light: The Beast**, 2.8.0, DLSS FG ×4 (21:56) | `Presented FPS 69.99` (withheld) | `unseen=12204 over samples=4136 (2.95)` | N/A (withheld) + *FEEDING* |
|
||||
| **Dying Light: The Beast**, 2.8.0, DLSS FG ×4 (22:06) | `Presented FPS 73.19` (withheld) | `unseen=12741 over samples=4392 (2.90)` | same |
|
||||
| **Hell Is Us**, 2.7.3, DLSS + FG ×4 | `79.89 → 308.14 (×3.86)` | `unseen=0 over samples=18207` | `DlssG` |
|
||||
| **Onimusha: Way of the Sword demo**, **2.10.3**, DLSS + FG | `60.04 → 220.33 (×3.67)` | `unseen=0 over samples=12914` | `DlssG`, `upscaler: Dlss`, RT Yes (27.1 %) |
|
||||
|
||||
The 2.8.0 pacer presents on the hooked chain through a body the inline patches do not cover; 2.7.3 and
|
||||
2.10.3 present through the body they do. The owner's "`sl.interposer.dll` + `sl.common.dll` must be
|
||||
loaded on ≥ 2.8" lead is closed by the 2.10.3 title: it injects, tags on the frame route (`depth, mvec,
|
||||
hudless, scaling-in, scaling-out, ui-color-alpha, backbuffer, other`) and counts like 2.7. Onimusha's
|
||||
`render -> output: N/A` with `UpscalerParams 0/13014` is DL:TB's shape again — the frame-route tags carry
|
||||
no size on D3D12, where `sl::Resource` declares none. The PR after #124 turns the 2.8.0 reading into a
|
||||
DXGI-COUNTED Displayed (`03_METRICS` §Displayed may be DXGI-COUNTED).
|
||||
|
||||
## 10 · Telemetry layering
|
||||
|
||||
- L1 baseline vendor-neutral:
|
||||
|
||||
@@ -61,6 +61,30 @@ internal sealed record FgWindow
|
||||
/// <summary>Records whose count hit the byte's ceiling.</summary>
|
||||
public required int Saturated { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Σ <c>dxgiUnseen</c> over the records that claim <see cref="FlMeasured.DxgiPresents"/>: presents DXGI
|
||||
/// counted on the hooked chain that this hook never saw. 0 on every title measured except Dying Light:
|
||||
/// The Beast on Streamline 2.8.0, where it is ≈ 3 × <see cref="Presents"/> at DLSS FG ×4 (§H5 row P1-DXGI).
|
||||
/// </summary>
|
||||
public required long DxgiUnseen { get; init; }
|
||||
|
||||
/// <summary>Records claiming <see cref="FlMeasured.DxgiPresents"/> — the byte's own denominator.</summary>
|
||||
public required int DxgiClaiming { get; init; }
|
||||
|
||||
/// <summary>Records whose <c>dxgiUnseen</c> hit 255, the saturation sentinel; any means a refusal.</summary>
|
||||
public required int DxgiSaturated { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The presents the window counts as DISPLAYED: the ones this hook timed plus the ones DXGI counted on the
|
||||
/// same chain and this hook never saw. Equal to <see cref="Presents"/> on every title where DXGI and the hook
|
||||
/// agree, and the numerator of <see cref="Factor"/>, <see cref="DisplayedFps"/> and
|
||||
/// <see cref="PresentsPerBatch"/> — never of a frame-time distribution, which has no timestamps for them.
|
||||
/// </summary>
|
||||
public long DisplayedPresents => Presents + DxgiUnseen;
|
||||
|
||||
/// <summary>True when Displayed is a count DXGI made rather than this hook — the report must say so.</summary>
|
||||
public bool DxgiCounted => DxgiUnseen > 0;
|
||||
|
||||
/// <summary>How many records carried 0, 1, 2 … evaluations. Index is the value.</summary>
|
||||
public required IReadOnlyList<int> Histogram { get; init; }
|
||||
|
||||
@@ -86,11 +110,11 @@ internal sealed record FgWindow
|
||||
|
||||
/// <summary><c>presents / Σ evaluations</c>, or null.</summary>
|
||||
public double? Factor =>
|
||||
Refusal is null && Evaluations > 0 ? Presents / (double)Evaluations : null;
|
||||
Refusal is null && Evaluations > 0 ? DisplayedPresents / (double)Evaluations : null;
|
||||
|
||||
/// <summary><c>F_disp</c> over this window's own intervals.</summary>
|
||||
public double? DisplayedFps =>
|
||||
Refusal is null && Seconds > 0 && Presents > 1 ? (Presents - 1) / Seconds : null;
|
||||
Refusal is null && Seconds > 0 && DisplayedPresents > 1 ? (DisplayedPresents - 1) / Seconds : null;
|
||||
|
||||
/// <summary><c>F_app</c>, counted rather than derived.</summary>
|
||||
public double? NativeFps => Refusal is null && Seconds > 0 ? Evaluations / Seconds : null;
|
||||
@@ -129,7 +153,7 @@ internal sealed record FgWindow
|
||||
/// <see cref="BatchRefusal"/>; it is never published as <c>fg_factor</c>, and
|
||||
/// <see cref="Factor"/> stays keyed on counted evaluations.
|
||||
/// </remarks>
|
||||
public double? PresentsPerBatch => Batches > 0 ? Presents / (double)Batches : null;
|
||||
public double? PresentsPerBatch => Batches > 0 ? DisplayedPresents / (double)Batches : null;
|
||||
|
||||
/// <summary>
|
||||
/// Why <see cref="PresentsPerBatch"/> may not be read as one configuration's number, or
|
||||
@@ -178,6 +202,9 @@ internal sealed record FgWindow
|
||||
Unidentified = 0,
|
||||
Streams = 0,
|
||||
Saturated = 0,
|
||||
DxgiUnseen = 0,
|
||||
DxgiClaiming = 0,
|
||||
DxgiSaturated = 0,
|
||||
Histogram = [],
|
||||
BucketFactors = [],
|
||||
BatchFactors = [],
|
||||
@@ -205,6 +232,7 @@ internal sealed record FgWindow
|
||||
int batches = 0;
|
||||
int unidentified = 0;
|
||||
int saturated = 0;
|
||||
(long dxgiUnseen, int dxgiClaiming, int dxgiSaturated) = TallyDxgi(all, start);
|
||||
|
||||
for (int i = start; i < all.Count; i++)
|
||||
{
|
||||
@@ -242,6 +270,9 @@ internal sealed record FgWindow
|
||||
Unidentified = unidentified,
|
||||
Streams = streams.Count,
|
||||
Saturated = saturated,
|
||||
DxgiUnseen = dxgiUnseen,
|
||||
DxgiClaiming = dxgiClaiming,
|
||||
DxgiSaturated = dxgiSaturated,
|
||||
Histogram = histogram,
|
||||
BucketFactors = BucketsOf(all, start, EvaluationWeight),
|
||||
BatchFactors = BucketsOf(all, start, BatchWeight),
|
||||
@@ -249,6 +280,34 @@ internal sealed record FgWindow
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Σ <c>dxgiUnseen</c>, the records claiming it, and the ones at the 255 sentinel — the DXGI half of
|
||||
/// the tally, in its own pass because it is its own measurement (<c>fl_shm.h</c> §dxgiUnseen).
|
||||
/// </summary>
|
||||
private static (long Unseen, int Claiming, int Saturated) TallyDxgi(IReadOnlyList<FlFrameRecord> all, int start)
|
||||
{
|
||||
long unseen = 0;
|
||||
int claiming = 0;
|
||||
int saturated = 0;
|
||||
for (int i = start; i < all.Count; i++)
|
||||
{
|
||||
FlFrameRecord r = all[i];
|
||||
if (!((FlMeasured)r.MeasuredMask).HasFlag(FlMeasured.DxgiPresents))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
claiming++;
|
||||
unseen += r.DxgiUnseen;
|
||||
if (r.DxgiUnseen == byte.MaxValue)
|
||||
{
|
||||
saturated++;
|
||||
}
|
||||
}
|
||||
|
||||
return (unseen, claiming, saturated);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Per-bucket <c>presents ÷ weight</c> in time order, or empty when the window is too
|
||||
/// short. One slicing, two weights.
|
||||
@@ -276,23 +335,53 @@ internal sealed record FgWindow
|
||||
int lo = start + (int)((long)n * b / _buckets);
|
||||
int hi = start + (int)((long)n * (b + 1) / _buckets);
|
||||
long sigma = 0;
|
||||
long displayed = 0;
|
||||
for (int i = lo; i < hi; i++)
|
||||
{
|
||||
sigma += weight(all[i]);
|
||||
displayed += 1 + Unseen(all[i]);
|
||||
}
|
||||
|
||||
factors.Add(sigma > 0 ? (hi - lo) / (double)sigma : double.PositiveInfinity);
|
||||
// The SAME numerator the window publishes: a DXGI-counted present belongs to the
|
||||
// bucket of the hooked present that read it, so a session where the 2.8 pacer
|
||||
// stopped mid-way fails uniformity exactly as one where tokens stopped would.
|
||||
factors.Add(sigma > 0 ? displayed / (double)sigma : double.PositiveInfinity);
|
||||
}
|
||||
|
||||
return factors;
|
||||
}
|
||||
|
||||
/// <summary><c>dxgiUnseen</c> where the record claims it, else 0 — an unclaimed byte is nobody's count.</summary>
|
||||
private static long Unseen(FlFrameRecord r) =>
|
||||
((FlMeasured)r.MeasuredMask).HasFlag(FlMeasured.DxgiPresents) ? r.DxgiUnseen : 0L;
|
||||
|
||||
/// <summary>The first reason a factor may not be published, or null.</summary>
|
||||
/// <remarks>
|
||||
/// Ordered so the most specific cause is named. Every one of these is a number this
|
||||
/// consumer would otherwise have printed as a measurement.
|
||||
/// </remarks>
|
||||
private static string? RefusalFor(FgWindow w)
|
||||
{
|
||||
if (RefusalForRecordSet(w) is string aboutTheRecords)
|
||||
{
|
||||
return aboutTheRecords;
|
||||
}
|
||||
|
||||
if (w.Evaluations == 0)
|
||||
{
|
||||
return "no application-frame token was counted in the window (slGetNewFrameToken, or an ffx-api "
|
||||
+ "PREPARE / UPSCALE dispatch) — a data gap, "
|
||||
+ "and treating it as 'no frame generation' is how fg_factor becomes 1.0";
|
||||
}
|
||||
|
||||
return RefusalForRatio(w);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Facts about the record SET that refuse a factor before anything is divided: attribution, and the
|
||||
/// two saturation sentinels.
|
||||
/// </summary>
|
||||
private static string? RefusalForRecordSet(FgWindow w)
|
||||
{
|
||||
// ATTRIBUTION FIRST, AND THE ORDER IS THE FIX. These two are facts about the record
|
||||
// set and hold whether or not anything was counted — but they used to sit BELOW the
|
||||
@@ -319,14 +408,19 @@ internal sealed record FgWindow
|
||||
+ "saturation sentinel rather than a count — dividing by it would report a floor";
|
||||
}
|
||||
|
||||
if (w.Evaluations == 0)
|
||||
if (w.DxgiSaturated > 0)
|
||||
{
|
||||
return "no application-frame token was counted in the window (slGetNewFrameToken, or an ffx-api "
|
||||
+ "PREPARE / UPSCALE dispatch) — a data gap, "
|
||||
+ "and treating it as 'no frame generation' is how fg_factor becomes 1.0";
|
||||
return $"{w.DxgiSaturated} record(s) hit the dxgiUnseen ceiling of 255, which is a saturation "
|
||||
+ "sentinel rather than a count — DXGI counted more presents than the byte can carry";
|
||||
}
|
||||
|
||||
string? nonUniform = NonUniform(w.BucketFactors, w.Presents / (double)w.Evaluations, w.Presents,
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>The refusals that need the ratio itself: uniformity, then the unnameable band.</summary>
|
||||
private static string? RefusalForRatio(FgWindow w)
|
||||
{
|
||||
string? nonUniform = NonUniform(w.BucketFactors, w.DisplayedPresents / (double)w.Evaluations, w.Presents,
|
||||
"the frame-generation state");
|
||||
if (nonUniform is not null)
|
||||
{
|
||||
@@ -346,7 +440,7 @@ internal sealed record FgWindow
|
||||
// What is still refused is the band between: a steady 1.05–1.5 is not a configuration
|
||||
// any vendor ships, and a window that mixed states would usually have failed the
|
||||
// uniformity check above. Naming it would be guessing.
|
||||
double factor = w.Presents / (double)w.Evaluations;
|
||||
double factor = w.DisplayedPresents / (double)w.Evaluations;
|
||||
return factor > NoneCeiling && factor < ActiveThreshold
|
||||
? $"presents/tokens = {factor.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)} sits "
|
||||
+ $"between the `none` ceiling ({NoneCeiling.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)}) "
|
||||
@@ -405,7 +499,7 @@ internal sealed record FgWindow
|
||||
+ "so a batch belonging to one stream can be drained by another's present";
|
||||
}
|
||||
|
||||
return NonUniform(w.BatchFactors, w.Presents / (double)w.Batches, w.Presents,
|
||||
return NonUniform(w.BatchFactors, w.DisplayedPresents / (double)w.Batches, w.Presents,
|
||||
"the presents-per-batch ratio");
|
||||
}
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ internal sealed record MeasuredFacts
|
||||
var allowed = FlMeasured.None;
|
||||
if (hooks.HasFlag(FlHookFamily.Present))
|
||||
{
|
||||
allowed |= FlMeasured.OutputRes | FlMeasured.PresentArgs;
|
||||
allowed |= FlMeasured.OutputRes | FlMeasured.PresentArgs | FlMeasured.DxgiPresents;
|
||||
}
|
||||
|
||||
if (hooks.HasFlag(FlHookFamily.UpscalerIdentity))
|
||||
@@ -414,6 +414,13 @@ internal sealed record MeasuredFacts
|
||||
return false;
|
||||
}
|
||||
|
||||
// dxgiUnseen has no in-band sentinel either — 0 is DXGI agreeing with the hook — so a
|
||||
// value under a clear bit is the same defect as an unclaimed count.
|
||||
if (!mask.HasFlag(FlMeasured.DxgiPresents) && r.DxgiUnseen != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// fgEvaluations has no in-band sentinel — 0 is a real count — so only the mask bit
|
||||
// can say whether anyone counted. Added here to keep this in step with the native
|
||||
// twin in guard_test.cpp, which HANDOFF item 3 will make load-bearing.
|
||||
|
||||
@@ -46,7 +46,17 @@ internal static class SessionReport
|
||||
sb.Append(" Native FPS: ").Append(Num(w.NativeFps))
|
||||
.Append(" -> Displayed FPS: ").Append(Num(w.DisplayedFps))
|
||||
.Append(" (x").Append(Num(w.Factor)).Append(" FG)")
|
||||
.Append(" over ").Append(Count(w.Presents)).AppendLine(" present(s)");
|
||||
.Append(" over ").Append(Count(w.DisplayedPresents)).AppendLine(" present(s)");
|
||||
if (w.DxgiCounted)
|
||||
{
|
||||
// A COUNT DXGI MADE, NOT THIS HOOK, and the line says so before anyone reads the
|
||||
// trio: those presents have no timestamps here, so they may stand in a rate and
|
||||
// a factor and never in a frame-time distribution (03_METRICS §Counting).
|
||||
sb.Append(" Displayed is DXGI-COUNTED: ").Append(Count(w.DxgiUnseen))
|
||||
.Append(" of those present(s) were counted by IDXGISwapChain::GetLastPresentCount on the hooked ")
|
||||
.Append("chain and never reached this hook (").Append(Count(w.Presents))
|
||||
.AppendLine(" hooked) — a count DXGI made, not this hook; 20_OPEN_QUESTIONS §H5 row P1-DXGI");
|
||||
}
|
||||
}
|
||||
else if (facts.Fg?.IsNone == true && facts.NoneWithheld is null)
|
||||
{
|
||||
@@ -157,8 +167,8 @@ internal static class SessionReport
|
||||
? ". DXGI's own counter on this chain saw " + unseen.ToString("0.00", CultureInfo.InvariantCulture)
|
||||
+ " present(s) per hooked present that this hook did not - the generated presents ARE DXGI presents "
|
||||
+ "reaching a body the inline patches do not cover (§H5 row P1-DXGI)"
|
||||
: ". DXGI's own counter on this chain saw nothing this hook did not - whatever generates frames presents "
|
||||
+ "below DXGI or on another object (§H5 row P3)"
|
||||
: ". DXGI's own counter on this chain saw nothing this hook did not - frame generation was off, or "
|
||||
+ "whatever generates frames presents below DXGI or on another object (§H5 row P3)"
|
||||
: "");
|
||||
}
|
||||
|
||||
@@ -254,6 +264,7 @@ internal static class SessionReport
|
||||
// record 0 while this one starts after the lazy-install prefix — and the resulting rate
|
||||
// moved across 78.6-83 on window choice alone, ten times the residual that draft quoted.
|
||||
sb.Append(" FG counts: presents=").Append(Count(w.Presents))
|
||||
.Append(" dxgi-unseen=").Append(Count(w.DxgiUnseen))
|
||||
.Append(" batches=").Append(Count(w.Batches))
|
||||
.Append(" tokens=").Append(Count(w.Evaluations))
|
||||
.Append(" streams=").Append(Count(w.Streams))
|
||||
|
||||
@@ -266,9 +266,9 @@ internal static class Program
|
||||
|
||||
double per = writer.DxgiPresentsUnseen / (double)writer.DxgiPresentSamples;
|
||||
string reading = writer.DxgiPresentsUnseen == 0
|
||||
? "DXGI counted nothing this hook did not: whatever generates frames on this title presents below DXGI or on another object"
|
||||
? "DXGI counted nothing this hook did not: frame generation was off, or whatever generates frames on this title presents below DXGI or on another object"
|
||||
: per >= 0.5
|
||||
? "DXGI counted presents this hook never saw on the SAME chain - a pacer presenting through a body the inline patches do not cover; the generated presents ARE DXGI presents here and this counter can count them"
|
||||
? "DXGI counted presents this hook never saw on the SAME chain - a pacer presenting through a body the inline patches do not cover; the generated presents ARE DXGI presents here and Displayed above is DXGI-counted from them"
|
||||
: "a few presents reached DXGI outside this hook - too few for a pacer, read the number rather than the ratio";
|
||||
return $" DXGI present counter: unseen={writer.DxgiPresentsUnseen} over samples={writer.DxgiPresentSamples} " +
|
||||
$"({per.ToString("0.00", CultureInfo.InvariantCulture)} unseen per hooked present) - {reading}";
|
||||
|
||||
@@ -453,7 +453,14 @@ public enum FlMeasured : ushort
|
||||
/// </summary>
|
||||
FgCounts = 1 << 10,
|
||||
|
||||
// Bits 11-15 reserved. Writers leave them zero; readers IGNORE them rather than validating them as
|
||||
/// <summary>
|
||||
/// <c>dxgiUnseen</c> (2026-09-05, <c>20_OPEN_QUESTIONS</c> §H5 row P1-DXGI): the present hook read
|
||||
/// <c>IDXGISwapChain::GetLastPresentCount</c> at this present and at the previous hooked present on the
|
||||
/// same chain, so the byte is a measurement, a zero included. Clear on a chain's first hooked present.
|
||||
/// </summary>
|
||||
DxgiPresents = 1 << 11,
|
||||
|
||||
// Bits 12-15 reserved. Writers leave them zero; readers IGNORE them rather than validating them as
|
||||
// zero. That does NOT make a future field bump-free — recordSize and layoutVersion are compared
|
||||
// first, so an old reader refuses a new writer outright.
|
||||
}
|
||||
@@ -598,7 +605,7 @@ public unsafe struct FlControlBlock
|
||||
|
||||
/// <summary>Region 4 — the ring. Exactly 64 bytes, no implicit padding.</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Size = 64)]
|
||||
public struct FlFrameRecord
|
||||
public unsafe struct FlFrameRecord
|
||||
{
|
||||
/// <summary>Present entry timestamp.</summary>
|
||||
public ulong Qpc;
|
||||
@@ -688,8 +695,18 @@ public struct FlFrameRecord
|
||||
/// <summary>0 = unavailable.</summary>
|
||||
public uint ReflexLatencyUs;
|
||||
|
||||
/// <summary>
|
||||
/// Presents DXGI's own counter recorded on this record's chain since the previous hooked present, beyond
|
||||
/// that one — the per-present form of <see cref="FlWriterState.DxgiPresentsUnseen"/>, under
|
||||
/// <see cref="FlMeasured.DxgiPresents"/>. Measured 2.90 / 2.95 per hooked present on Dying Light: The
|
||||
/// Beast (Streamline 2.8.0, DLSS FG ×4) and 0 on Streamline 2.7.3 and 2.10.3 titles, so on that shape
|
||||
/// the generated presents ARE DXGI presents and the consumer counts <c>Displayed = hooked + this</c>,
|
||||
/// labelled DXGI-COUNTED. Saturates at 255, which the consumer refuses as a sentinel.
|
||||
/// </summary>
|
||||
public byte DxgiUnseen;
|
||||
|
||||
/// <summary>Must be zero. Slack, so the next addition does not start from none.</summary>
|
||||
public uint Reserved;
|
||||
public fixed byte Reserved[3];
|
||||
|
||||
/// <summary>
|
||||
/// Seqlock counter. Monotonic per slot and NEVER reset, so a full lap of the ring always changes it —
|
||||
|
||||
@@ -302,6 +302,7 @@ struct SwapChainSlot {
|
||||
uint8_t api = FL_API_UNKNOWN;
|
||||
bool haveDxgiCount = false;
|
||||
uint32_t lastDxgiCount = 0;
|
||||
uint32_t dxgiEpoch = 0; // g_dxgiEpoch when lastDxgiCount was read; a mismatch means presents went by unrecorded
|
||||
};
|
||||
|
||||
// Ask the device whether it can ray-trace, once, and publish it as FlRtTier.
|
||||
@@ -927,6 +928,15 @@ std::atomic<uint32_t> g_slTagCensus{0};
|
||||
std::atomic<uint32_t> g_dxgiUnseen{0};
|
||||
std::atomic<uint32_t> g_dxgiSamples{0};
|
||||
|
||||
// A PRESENT THIS HOOK SAW AND DECLINED TO RECORD IS NOT ONE IT NEVER SAW. While a
|
||||
// session is paused (MayObserve false) the title keeps presenting and DXGI keeps
|
||||
// counting, so the first record after the resume would otherwise claim the whole
|
||||
// pause as unseen presents -- measured 0x55 on the paused-session integration case.
|
||||
// Every declined present bumps this epoch; a slot whose last read is from an older
|
||||
// epoch differences nothing and starts again. DXGI_PRESENT_TEST presents do not bump
|
||||
// it: they do not move the counter (#35), so there is nothing to invalidate.
|
||||
std::atomic<uint32_t> g_dxgiEpoch{0};
|
||||
|
||||
void NoteTagTypes(uint32_t typeBits, uint32_t routeShift) noexcept {
|
||||
if (typeBits == 0u) {
|
||||
return;
|
||||
@@ -1909,6 +1919,9 @@ DWORD WINAPI WatchdogThread(LPVOID) noexcept {
|
||||
// lock, no logging (NFR-1, target <= 1 us; a bare vtable detour measured 8.4 ns).
|
||||
void RecordPresent(IDXGISwapChain* sc, UINT syncInterval, UINT flags) noexcept {
|
||||
if (!MayObserve()) {
|
||||
if ((flags & DXGI_PRESENT_TEST) == 0u) {
|
||||
g_dxgiEpoch.fetch_add(1u, std::memory_order_relaxed); // see the declaration
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1951,16 +1964,22 @@ void RecordPresent(IDXGISwapChain* sc, UINT syncInterval, UINT flags) noexcept {
|
||||
// patches do not cover. A delta of exactly 1 every time says DXGI saw nothing more
|
||||
// than we did. DXGI_PRESENT_TEST presents are already filtered above and do not
|
||||
// move this counter (measured, #35), so they cannot read as unseen presents.
|
||||
bool dxgiDelta = false;
|
||||
uint8_t dxgiUnseenHere = 0;
|
||||
if (slot != nullptr) {
|
||||
UINT dxgiCount = 0;
|
||||
UINT dxgiCount = 0;
|
||||
const uint32_t epoch = g_dxgiEpoch.load(std::memory_order_relaxed);
|
||||
if (SUCCEEDED(sc->GetLastPresentCount(&dxgiCount))) {
|
||||
if (slot->haveDxgiCount) {
|
||||
if (slot->haveDxgiCount && slot->dxgiEpoch == epoch) {
|
||||
const uint32_t delta = dxgiCount - slot->lastDxgiCount;
|
||||
dxgiDelta = true;
|
||||
if (delta > 1u) {
|
||||
g_dxgiUnseen.fetch_add(delta - 1u, std::memory_order_relaxed);
|
||||
dxgiUnseenHere = fl::slseen::SaturateToByte(delta - 1u);
|
||||
}
|
||||
}
|
||||
slot->lastDxgiCount = dxgiCount;
|
||||
slot->dxgiEpoch = epoch;
|
||||
slot->haveDxgiCount = true;
|
||||
g_dxgiSamples.fetch_add(1u, std::memory_order_relaxed);
|
||||
}
|
||||
@@ -2007,6 +2026,14 @@ void RecordPresent(IDXGISwapChain* sc, UINT syncInterval, UINT flags) noexcept {
|
||||
const uint16_t haveOutputRes = (rec.outputW != 0 && rec.outputH != 0) ? FL_MEASURED_OUTPUT_RES : 0u;
|
||||
rec.measuredMask = static_cast<uint16_t>(haveOutputRes | FL_MEASURED_PRESENT_ARGS);
|
||||
|
||||
// The per-present form of the DXGI counter read above (fl_shm.h §dxgiUnseen). The
|
||||
// bit says a delta EXISTED -- a zero under it is DXGI agreeing with this hook, not
|
||||
// silence -- which is why the first present of a chain claims nothing.
|
||||
if (dxgiDelta) {
|
||||
rec.dxgiUnseen = dxgiUnseenHere;
|
||||
rec.measuredMask = static_cast<uint16_t>(rec.measuredMask | FL_MEASURED_DXGI_PRESENTS);
|
||||
}
|
||||
|
||||
// --- Upscaler identity, and the three states it must keep apart ----------
|
||||
//
|
||||
// The counter is CONSUMED here, once per present, so the record describes
|
||||
|
||||
@@ -568,13 +568,20 @@ enum FlMeasured : uint16_t {
|
||||
// must be able to say so.
|
||||
FL_MEASURED_FG_COUNTS = 1u << 10,
|
||||
|
||||
// bits 11-15 reserved. Writers leave them zero; readers must IGNORE them
|
||||
// dxgiUnseen @52 (2026-09-05, 20_OPEN_QUESTIONS §H5 row P1-DXGI): the present hook
|
||||
// read IDXGISwapChain::GetLastPresentCount at this present AND at the previous
|
||||
// hooked present on the same chain, so the byte is a measurement -- a zero
|
||||
// included. Clear on the first hooked present of every chain, where there is no
|
||||
// previous value to difference against, and whenever the read failed.
|
||||
FL_MEASURED_DXGI_PRESENTS = 1u << 11,
|
||||
|
||||
// bits 12-15 reserved. Writers leave them zero; readers must IGNORE them
|
||||
// rather than validate them as zero.
|
||||
//
|
||||
// BE PRECISE ABOUT WHAT THAT BUYS, because the tempting claim is false: it
|
||||
// does NOT mean a future field can be added without a layout bump. Any new
|
||||
// field also needs a byte, and every byte of this record is allocated except
|
||||
// `reserved` @52 -- and FlShmHandshake::recordSize plus the layout version are
|
||||
// `reserved` @53..55 -- and FlShmHandshake::recordSize plus the layout version are
|
||||
// compared before a reader looks at anything, so an old reader refuses a new
|
||||
// writer outright and never gets as far as an unknown bit. What the reserve
|
||||
// actually buys is that existing offsets do not move, which keeps the diff,
|
||||
@@ -832,7 +839,22 @@ struct alignas(64) FlFrameRecord {
|
||||
// and layoutVersion are compared before a reader looks at anything, so an old
|
||||
// reader refuses a new writer and never reaches an unknown field. What it buys
|
||||
// is that existing offsets do not move, which keeps the next diff small.
|
||||
uint32_t reserved; // @52
|
||||
// @52 -- DXGI'S OWN COUNT OF THIS CHAIN'S PRESENTS SINCE THE PREVIOUS HOOKED ONE,
|
||||
// beyond that one (2026-09-05, 20_OPEN_QUESTIONS §H5 row P1-DXGI). The per-present
|
||||
// form of FlWriterState.dxgiPresentsUnseen: the delta of GetLastPresentCount between
|
||||
// two consecutive hooked presents on the same chain, minus the one present the hook
|
||||
// saw. Measured 2.90 and 2.95 per hooked present on Dying Light: The Beast
|
||||
// (Streamline 2.8.0, DLSS Frame Generation x4) and 0 on every other title (Streamline
|
||||
// 2.7.3 and 2.10.3 present their generated frames through the patched bodies) -- so
|
||||
// on that shape the generated presents ARE DXGI presents, reaching a body the inline
|
||||
// patches do not cover, and the consumer counts Displayed = hooked + this, labelled
|
||||
// DXGI-COUNTED. Per record rather than per session so the consumer's uniformity
|
||||
// buckets see it. SATURATES AT 255: a NUMERATOR, so a wrap would read low rather than
|
||||
// high, but 255 is still a sentinel the consumer refuses rather than a count. Took the
|
||||
// first byte of v3's reserved word; additive, no offset moved, no layout bump.
|
||||
uint8_t dxgiUnseen; // @52
|
||||
|
||||
uint8_t reserved[3]; // @53..55 MUST BE ZERO
|
||||
|
||||
// Seqlock counter. Monotonic per slot and NEVER reset, so a full lap of
|
||||
// the ring always changes it — otherwise a reader stalled exactly one lap
|
||||
@@ -924,7 +946,8 @@ static_assert(offsetof(FlFrameRecord, upscalerSharpness) == 42);
|
||||
static_assert(offsetof(FlFrameRecord, fgEvaluations) == 43);
|
||||
static_assert(offsetof(FlFrameRecord, vramUsedMb) == 44);
|
||||
static_assert(offsetof(FlFrameRecord, reflexLatencyUs) == 48);
|
||||
static_assert(offsetof(FlFrameRecord, reserved) == 52);
|
||||
static_assert(offsetof(FlFrameRecord, dxgiUnseen) == 52);
|
||||
static_assert(offsetof(FlFrameRecord, reserved) == 53);
|
||||
static_assert(offsetof(FlFrameRecord, seq) == 56);
|
||||
static_assert(offsetof(FlFrameRecord, swapchainId) == 60);
|
||||
|
||||
@@ -940,7 +963,6 @@ static_assert(offsetof(FlFrameRecord, swapchainId) == 60, "07_IPC pins the paylo
|
||||
static_assert(offsetof(FlFrameRecord, qpc) % 8 == 0);
|
||||
static_assert(offsetof(FlFrameRecord, measuredMask) % 2 == 0);
|
||||
static_assert(offsetof(FlFrameRecord, vramUsedMb) % 4 == 0);
|
||||
static_assert(offsetof(FlFrameRecord, reserved) % 4 == 0);
|
||||
static_assert(offsetof(FlFrameRecord, seq) % 4 == 0);
|
||||
|
||||
// The regions must not overlap, and the ring must stay 64-aligned.
|
||||
|
||||
@@ -1179,7 +1179,8 @@ bool StartHarness(Child& child) {
|
||||
uint16_t EntitledBy(uint32_t hooks) noexcept {
|
||||
uint16_t allowed = 0;
|
||||
if ((hooks & fl::FL_HOOK_PRESENT) != 0u) {
|
||||
allowed |= static_cast<uint16_t>(fl::FL_MEASURED_OUTPUT_RES | fl::FL_MEASURED_PRESENT_ARGS);
|
||||
allowed |= static_cast<uint16_t>(fl::FL_MEASURED_OUTPUT_RES | fl::FL_MEASURED_PRESENT_ARGS |
|
||||
fl::FL_MEASURED_DXGI_PRESENTS);
|
||||
}
|
||||
if ((hooks & fl::FL_HOOK_UPSCALER_IDENTITY) != 0u) {
|
||||
allowed |= static_cast<uint16_t>(fl::FL_MEASURED_UPSCALER | fl::FL_MEASURED_FG);
|
||||
@@ -1225,6 +1226,11 @@ bool IsHonest(const fl::FlFrameRecord& r, uint16_t entitled) noexcept {
|
||||
if ((r.measuredMask & fl::FL_MEASURED_FG_COUNTS) == 0u && r.fgEvaluations != 0u) {
|
||||
return false;
|
||||
}
|
||||
// dxgiUnseen has no in-band sentinel either -- 0 is DXGI agreeing with the hook -- so
|
||||
// a value under a clear bit is the same defect as an unclaimed count.
|
||||
if ((r.measuredMask & fl::FL_MEASURED_DXGI_PRESENTS) == 0u && r.dxgiUnseen != 0u) {
|
||||
return false;
|
||||
}
|
||||
// featureFlags carries Ray Reconstruction's fact and OBSERVED bits, produced by the
|
||||
// same Streamline detour as the upscaler identity. A writer not entitled to claim
|
||||
// an upscaler is not entitled to say anything about RR either.
|
||||
@@ -3178,7 +3184,9 @@ struct FgObservation {
|
||||
std::uint32_t dxgiUnseen = 0;
|
||||
std::uint32_t dxgiSamples = 0;
|
||||
std::size_t drained = 0;
|
||||
std::uint64_t sigma = 0; // sum of fgEvaluations over the window
|
||||
std::uint64_t sigma = 0; // sum of fgEvaluations over the window
|
||||
std::uint64_t dxgiRecUnseen = 0; // sum of dxgiUnseen over records claiming it
|
||||
std::size_t dxgiRecClaiming = 0; // records carrying FL_MEASURED_DXGI_PRESENTS
|
||||
std::uint32_t hooks = 0;
|
||||
std::uint32_t faults = 0;
|
||||
bool everyRecordClaimsCounts = true;
|
||||
@@ -3258,6 +3266,10 @@ bool ObserveFg(int presentsPerEval, FgObservation& out) {
|
||||
out.drained = all.size();
|
||||
for (const auto& r : all) {
|
||||
out.sigma += r.fgEvaluations;
|
||||
if ((r.measuredMask & fl::FL_MEASURED_DXGI_PRESENTS) != 0u) {
|
||||
++out.dxgiRecClaiming;
|
||||
out.dxgiRecUnseen += r.dxgiUnseen;
|
||||
}
|
||||
if ((r.measuredMask & fl::FL_MEASURED_FG_COUNTS) == 0u) {
|
||||
out.everyRecordClaimsCounts = false;
|
||||
}
|
||||
@@ -3371,6 +3383,12 @@ TEST_CASE("application-frame tokens are COUNTED, and the count tracks the fixtur
|
||||
CAPTURE(obs.dxgiSamples);
|
||||
CHECK(obs.dxgiUnseen == 0u);
|
||||
CHECK(obs.dxgiSamples >= static_cast<std::uint32_t>(obs.drained));
|
||||
// And per record, in the form the consumer's buckets read: every drained record
|
||||
// claims the bit (the chain's first present, which cannot, is in the discarded
|
||||
// backlog) and carries a zero byte.
|
||||
CAPTURE(obs.dxgiRecClaiming);
|
||||
CHECK(obs.dxgiRecUnseen == 0u);
|
||||
CHECK(obs.dxgiRecClaiming == obs.drained);
|
||||
CHECK((obs.census & fl::FL_CENSUS_RAN) != 0u);
|
||||
CHECK((obs.census & fl::FL_CENSUS_SL_INTERPOSER) != 0u);
|
||||
CHECK((obs.census & fl::FL_CENSUS_FG_FAMILIES) == 0u);
|
||||
|
||||
@@ -101,7 +101,8 @@ int main() {
|
||||
Field("fgEvaluations", offsetof(FlFrameRecord, fgEvaluations), sizeof(uint8_t));
|
||||
Field("vramUsedMb", offsetof(FlFrameRecord, vramUsedMb), sizeof(uint32_t));
|
||||
Field("reflexLatencyUs", offsetof(FlFrameRecord, reflexLatencyUs), sizeof(uint32_t));
|
||||
Field("reserved", offsetof(FlFrameRecord, reserved), sizeof(uint32_t));
|
||||
Field("dxgiUnseen", offsetof(FlFrameRecord, dxgiUnseen), sizeof(uint8_t));
|
||||
Field("reserved", offsetof(FlFrameRecord, reserved), sizeof(uint8_t) * 3);
|
||||
Field("seq", offsetof(FlFrameRecord, seq), sizeof(uint32_t));
|
||||
Field("swapchainId", offsetof(FlFrameRecord, swapchainId), sizeof(uint32_t), true);
|
||||
std::printf(" ] }\n");
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
using System.Diagnostics;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.CaptureHost.Consume;
|
||||
using FrameLedger.Shared;
|
||||
|
||||
namespace FrameLedger.CaptureHost.Tests.Consume;
|
||||
|
||||
/// <summary>
|
||||
/// Displayed counted by DXGI (<c>FlFrameRecord.dxgiUnseen</c>, <c>20_OPEN_QUESTIONS</c> §H5 row P1-DXGI): on
|
||||
/// Dying Light: The Beast (Streamline 2.8.0, DLSS FG ×4) the hook timed one present per application frame
|
||||
/// while DXGI's own counter on the same chain moved by ≈ 3.9 — so the window counts
|
||||
/// <c>Displayed = hooked + unseen</c>, says so on its own line, and every other title is byte-identical.
|
||||
/// </summary>
|
||||
public sealed class DxgiCountedWindowTests
|
||||
{
|
||||
private const FlHookFamily _hooks =
|
||||
FlHookFamily.Present | FlHookFamily.UpscalerIdentity | FlHookFamily.UpscalerParams | FlHookFamily.FgEvaluations;
|
||||
|
||||
private const FlRuntimeCensus _dyingLightAtDlss = FlRuntimeCensus.Ran | FlRuntimeCensus.SlInterposer
|
||||
| FlRuntimeCensus.SlDlss | FlRuntimeCensus.SlDlssG
|
||||
| FlRuntimeCensus.NvngxDlssG;
|
||||
|
||||
private static readonly long _step = Stopwatch.Frequency / 70;
|
||||
|
||||
/// <summary>
|
||||
/// The DL:TB shape: one hooked present per application frame (token drained, DLSS-G identity from the
|
||||
/// tags), each carrying <paramref name="unseen"/> DXGI-counted presents under the bit, or under no bit
|
||||
/// when <paramref name="claim"/> is false.
|
||||
/// </summary>
|
||||
private static List<FlFrameRecord> Stream(int appFrames, byte unseen, bool claim = true, int from = 0, int to = int.MaxValue)
|
||||
{
|
||||
List<FlFrameRecord> stream = [];
|
||||
ulong qpc = 1_000_000;
|
||||
for (int f = 0; f < appFrames; f++)
|
||||
{
|
||||
bool inRange = f >= from && f < to;
|
||||
byte u = inRange ? unseen : (byte)0;
|
||||
stream.Add(new FlFrameRecord
|
||||
{
|
||||
Qpc = qpc,
|
||||
SwapchainId = 1,
|
||||
OutputW = 2560,
|
||||
OutputH = 1440,
|
||||
MeasuredMask = (ushort)(FlMeasured.OutputRes | FlMeasured.PresentArgs | FlMeasured.Upscaler
|
||||
| FlMeasured.Fg | FlMeasured.FgCounts
|
||||
| (claim ? FlMeasured.DxgiPresents : FlMeasured.None)),
|
||||
Upscaler = (byte)FlUpscaler.Dlss,
|
||||
FgEvaluations = 1,
|
||||
FgMode = (byte)FlFgMode.DlssG,
|
||||
FeatureFlags = (byte)FlFeatureFlags.RayReconstructionObserved,
|
||||
DxgiUnseen = u,
|
||||
});
|
||||
qpc += (ulong)_step;
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
private static RuntimeModuleSet Interposer(string version) => new(
|
||||
[new RuntimeModuleInfo("sl.interposer.dll", @"D:\Games\title\sl.interposer.dll", version.Replace('.', ','),
|
||||
Version.Parse(version))],
|
||||
Snapshots: 1, Unreadable: 0);
|
||||
|
||||
private static (MeasuredFacts Facts, string Text) Render(List<FlFrameRecord> stream, uint unseenTotal, uint samples)
|
||||
{
|
||||
var writer = new FlWriterState
|
||||
{
|
||||
HooksInstalledMask = (uint)_hooks,
|
||||
RuntimeCensus = (uint)_dyingLightAtDlss,
|
||||
DxgiPresentsUnseen = unseenTotal,
|
||||
DxgiPresentSamples = samples,
|
||||
};
|
||||
MeasuredFacts facts = MeasuredFacts.From(stream, writer, Stopwatch.Frequency, 0, 0,
|
||||
FgWindow.From(stream, Stopwatch.Frequency), Interposer("2.8.0.0"));
|
||||
return (facts, SessionReport.Render(facts));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThreeUnseenPerHookedPresentMakesAFourTimesTrioLabelledDxgiCounted()
|
||||
{
|
||||
List<FlFrameRecord> s = Stream(200, unseen: 3);
|
||||
|
||||
(MeasuredFacts facts, string text) = Render(s, unseenTotal: 600, samples: 200);
|
||||
FgWindow w = facts.Fg!;
|
||||
|
||||
w.Presents.Should().Be(200);
|
||||
w.DxgiUnseen.Should().Be(600);
|
||||
w.DxgiClaiming.Should().Be(200);
|
||||
w.DisplayedPresents.Should().Be(800);
|
||||
w.DxgiCounted.Should().BeTrue();
|
||||
w.Refusal.Should().BeNull();
|
||||
w.Factor.Should().BeApproximately(4.0, 0.001);
|
||||
w.IsActive.Should().BeTrue();
|
||||
w.PresentsPerBatch.Should().BeApproximately(4.0, 0.001);
|
||||
(w.DisplayedFps / w.NativeFps).Should().BeApproximately(4.0, 0.03, "Native × factor ≈ Displayed over ONE window");
|
||||
|
||||
facts.NoneWithheld.Should().BeNull("the count is no longer 1.0, so there is nothing to withhold");
|
||||
facts.FgMode.Should().Be("DlssG");
|
||||
text.Should().Contain("Native FPS:").And.Contain("-> Displayed FPS:").And.Contain("(x4 FG)");
|
||||
text.Should().Contain("over 800 present(s)");
|
||||
text.Should().Contain("Displayed is DXGI-COUNTED: 600 of those present(s)");
|
||||
text.Should().Contain("a count DXGI made, not this hook");
|
||||
text.Should().Contain("dxgi-unseen=600");
|
||||
text.Should().NotContain("WITHHELD").And.NotContain("Presented FPS:");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZeroUnseenEverywhereIsByteIdenticalToTheWindowBeforeTheByteExisted()
|
||||
{
|
||||
List<FlFrameRecord> claimed = Stream(200, unseen: 0);
|
||||
List<FlFrameRecord> unclaimed = Stream(200, unseen: 0, claim: false);
|
||||
|
||||
FgWindow a = FgWindow.From(claimed, Stopwatch.Frequency);
|
||||
FgWindow b = FgWindow.From(unclaimed, Stopwatch.Frequency);
|
||||
|
||||
a.DxgiCounted.Should().BeFalse();
|
||||
a.DxgiClaiming.Should().Be(200);
|
||||
b.DxgiClaiming.Should().Be(0);
|
||||
a.DisplayedPresents.Should().Be(200);
|
||||
a.Factor.Should().Be(b.Factor);
|
||||
a.DisplayedFps.Should().Be(b.DisplayedFps);
|
||||
a.BucketFactors.Should().Equal(b.BucketFactors);
|
||||
|
||||
// And the DL:TB shape with the count at 1.0 is still withheld, with the DXGI reading beside it.
|
||||
(MeasuredFacts facts, string text) = Render(claimed, unseenTotal: 0, samples: 200);
|
||||
facts.NoneWithheld.Should().NotBeNull();
|
||||
text.Should().Contain("`none` is WITHHELD").And.Contain("frame generation was off, or").And.NotContain("DXGI-COUNTED");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void APacerThatStopsHalfWayFailsUniformityLikeAnyOtherStateChange()
|
||||
{
|
||||
List<FlFrameRecord> s = Stream(400, unseen: 3, from: 0, to: 200);
|
||||
|
||||
FgWindow w = FgWindow.From(s, Stopwatch.Frequency);
|
||||
|
||||
w.DxgiUnseen.Should().Be(600);
|
||||
w.Refusal.Should().Contain("changed during the session");
|
||||
w.Factor.Should().BeNull();
|
||||
w.BatchRefusal.Should().Contain("changed during the session", "presents/batch takes the same numerator");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ASaturatedByteIsASentinelAndTheFactorIsRefused()
|
||||
{
|
||||
List<FlFrameRecord> s = Stream(200, unseen: 3);
|
||||
FlFrameRecord r = s[100];
|
||||
r.DxgiUnseen = byte.MaxValue;
|
||||
s[100] = r;
|
||||
|
||||
FgWindow w = FgWindow.From(s, Stopwatch.Frequency);
|
||||
|
||||
w.DxgiSaturated.Should().Be(1);
|
||||
w.Refusal.Should().Contain("255");
|
||||
w.Factor.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AByteUnderAClearBitIsNobodysCountAndAnHonestyViolation()
|
||||
{
|
||||
List<FlFrameRecord> s = Stream(200, unseen: 3, claim: false);
|
||||
|
||||
(MeasuredFacts facts, _) = Render(s, unseenTotal: 0, samples: 0);
|
||||
|
||||
facts.Fg!.DxgiUnseen.Should().Be(0, "an unclaimed byte is not read");
|
||||
facts.Fg.Factor.Should().BeApproximately(1.0, 0.001);
|
||||
facts.HonestyViolations.Should().Be(200);
|
||||
}
|
||||
}
|
||||
@@ -195,12 +195,25 @@ public sealed class ShmDrainIntegrationTests
|
||||
// else. In layout v3 the zero-defaults are honest by construction — FlUpscaler.NotReported and
|
||||
// FlFgMode.NotReported are 0 — and the mask corroborates rather than being the sole defence.
|
||||
//
|
||||
// OutputRes is asserted as "no bit outside these two" rather than as an exact value, because the
|
||||
// overflow fixture legitimately produces records with PresentArgs alone: past 16 swapchains the
|
||||
// writer has no size to report and #57 made the bit conditional on there being one.
|
||||
// OutputRes is asserted as "no bit outside these three" rather than as an exact value, because
|
||||
// the overflow fixture legitimately produces records with PresentArgs alone: past 16 swapchains
|
||||
// the writer has no size to report and #57 made the bit conditional on there being one. The
|
||||
// third bit is DxgiPresents (2026-09-05): the present hook reads GetLastPresentCount on the chain
|
||||
// it saw, and every record after a chain's first claims the delta — a zero here, which the
|
||||
// byte assertion below pins, because this fixture presents only through the patched body.
|
||||
records.Should().OnlyContain(
|
||||
r => (r.MeasuredMask & ~(ushort)(FlMeasured.OutputRes | FlMeasured.PresentArgs)) == 0,
|
||||
r => (r.MeasuredMask & ~(ushort)(FlMeasured.OutputRes | FlMeasured.PresentArgs | FlMeasured.DxgiPresents)) == 0,
|
||||
"the writer must claim exactly what it measured — no more");
|
||||
// ...AND A PAUSE IS NOT AN UNSEEN PRESENT. The paused-session case below lets the harness
|
||||
// present ~85 times while the hook declines them; the first record after the resume claimed
|
||||
// them all as "presents DXGI counted and this hook never saw" until the epoch guard in
|
||||
// RecordPresent made a declined present invalidate the chain's last reading. This assertion
|
||||
// runs on every fixture, so that case is the one that keeps the guard honest.
|
||||
records.Should().OnlyContain(r => r.DxgiUnseen == 0,
|
||||
"DXGI must count nothing this hook did not on a fixture that presents only through the patched body "
|
||||
+ "— including across a pause, which the hook SAW and declined");
|
||||
records.Should().Contain(r => (r.MeasuredMask & (ushort)FlMeasured.DxgiPresents) != 0,
|
||||
"after a chain's first hooked present the counter has a previous value to difference against");
|
||||
records.Should().OnlyContain(r => (r.MeasuredMask & (ushort)FlMeasured.PresentArgs) != 0,
|
||||
"syncInterval and presentFlags are the call's own arguments; a DXGI present hook always has them");
|
||||
records.Should().OnlyContain(r => r.RtFlags == 0,
|
||||
|
||||
Reference in new issue
Block a user