Compare commits

...
Author SHA1 Message Date
poli0981andClaude Fable 5.2 32eae25d24 fix(metrics): a session's upscaler is the technology named on the most samples, with that technology's quality and render size - not the first one named beside the others' values (beta.42 PR-1, D120; decisions D119-D122)
A session that evaluated DLSS briefly and then ran FSR was stored as DLSS with FSR's quality byte and render size. Domain.Metrics.UpscalerChoice picks the modal named technology over the dominant stream; with more than one named, quality and size are read only from the samples that name it, a quality byte of the other family is withheld, and the session is marked settings-changed. One technology named keeps the whole stream, as before. The live card is unchanged.

HANDOFF and 18_GPU_VENDOR_APIS record D119-D122: train B's second step is beta.42 (no new patch site) and beta.43 (the two new hooks).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 07:47:02 +07:00
8 changed files with 340 additions and 16 deletions

No files matched your search

+10
View File
@@ -35,6 +35,16 @@ numeric core and does not move; the heading is the full version — corrected 20
## [Unreleased]
### Fixed
- **A session that saw two upscalers is named after the one it ran, with that one's quality and render size.** The
session's upscaler used to be the first one FrameLedger saw named, while the quality mode and the render size
came from whichever frames carried them. A game that evaluated DLSS briefly and then ran FSR was stored as "DLSS"
with FSR's quality and FSR's render size. The name is now the technology named on the most frames, the quality
and the size are read from that technology's frames only, and such a session is marked "settings changed during
session". What that technology did not say reads N/A rather than borrowing the other's value. Sessions already
stored are not rewritten.
## Releases
Newest first. Each file holds that release's section exactly as it stood here.
+12
View File
@@ -687,6 +687,18 @@ From the upscaler hooks we get, per frame:
> Measured on the hook harness with the vendor stub answering as the SDK documents (`fl_guard` "FSR's quality
> mode", by size through the SDK 2.x loader and by ratio through the 1.1.x monolith); a real title is owner-only
> item 21 (Lies of P at Quality, then Performance).
- **One technology's name, quality and size** *(2026-11-12, owner decision D120)*. A session's — and a segment's —
upscaler is **the technology named on the most samples of the dominant stream** (a tie goes to the lower value, as
the quality byte's does), not the first one any record names. While a session names one technology, its quality
and render size are read from the whole stream as before: under frame generation the name sits on one present in
N. When it names **more than one**, the quality and the size are read **only from the samples that name the
chosen one**, a quality byte of the other family is withheld (`UpscalerChoice.QualityFor`), and the session is
marked "settings changed during session". The session this was found on (Dying Light: The Beast, 81 seconds:
DLSS evaluated for most of it, an FSR dispatch for a few seconds) had been stored as "DLSS" with FSR's Balanced
byte and FSR's render size — three true readings of two technologies under one name. What the chosen technology
did not say stays N/A (rule 7). `Domain.Metrics.UpscalerChoice`; the live card still names the first technology
the session saw (`FgLadder.UpscalerIdentity`), which for a session in progress is a different question and was
not changed.
- Resolution changes mid-session (user changed settings, or dynamic resolution scaling) produce **segments**: the session stores a segment list `(startFrame, renderW/H, outputW/H, upscaler, quality)`. Aggregates report the dominant segment plus a "settings changed during session" flag — averaging across a settings change is the classic way benchmark numbers become meaningless.
> **Two segmentation axes exist, they compose in ONE order, and neither document said so until
+10 -3
View File
@@ -715,9 +715,9 @@ every `nvapi.` row; nothing is estimated in its place (FR-4.9).
| Train | Release | What | Its gate |
|---|---|---|---|
| A | 0.1.0-beta.39 | read by the Agent only — NVAPI and LibreHardwareMonitor — storage, the page. **Nothing changes in code loaded into a game** | this section |
| B | 0.1.0-beta.40, ~~.41, .42~~ .42, .43 *(three releases since D113, 2026-11-11; one was planned. Renumbered 2026-11-12, D118: 0.1.0-beta.41 is a fix release for the sensor library, not part of the train)* | inside the game: more fields of the Streamline and FidelityFX calls already hooked, and new hooks on functions `sl.interposer.dll` **exports** (`17_HOOK_ENGINE` §Hook inventory's ⏳ rows); shared-memory layout 5 — §Train B below | a plan of its own; overhead measured; each release after the first waits for the owner's run of the one before |
| C | ~~0.1.0-beta.41~~ ~~0.1.0-beta.43~~ 0.1.0-beta.44 *(D118)* | Reflex latency per frame | a spike, then the owner's go or no |
| D | ~~0.1.0-beta.42~~ ~~0.1.0-beta.44~~ 0.1.0-beta.45 *(D118)* | the Streamline feature state behind `slGetFeatureFunction` — DLSS frame generation's, DLSS's, Reflex's | a spike, then the owner's go or no |
| B | 0.1.0-beta.40, ~~.41, .42~~ ~~.42, .43~~ .42, .43, .44 *(three releases since D113, 2026-11-11; one was planned. Renumbered 2026-11-12, D118: 0.1.0-beta.41 is a fix release for the sensor library, not part of the train. **Four since D122, the same day**: the second step is beta.42 — no new patch site — and beta.43, the two new hooks; the third step is beta.44)* | inside the game: more fields of the Streamline and FidelityFX calls already hooked, and new hooks on functions `sl.interposer.dll` **exports** (`17_HOOK_ENGINE` §Hook inventory's ⏳ rows); shared-memory layout 5 — §Train B below | a plan of its own; overhead measured; each release after the first waits for the owner's run of the one before |
| C | ~~0.1.0-beta.41~~ ~~0.1.0-beta.43~~ ~~0.1.0-beta.44~~ 0.1.0-beta.45 *(D118, D122)* | Reflex latency per frame | a spike, then the owner's go or no |
| D | ~~0.1.0-beta.42~~ ~~0.1.0-beta.44~~ ~~0.1.0-beta.45~~ 0.1.0-beta.46 *(D118, D122)* | the Streamline feature state behind `slGetFeatureFunction` — DLSS frame generation's, DLSS's, Reflex's | a spike, then the owner's go or no |
Rules 4 and 5, the hook inventory, the measured overhead and the anti-cheat guard bind B, C and D exactly as they bind
every hook. `sl::Constants` is read without its camera position, axes and matrices: where the camera is, is where the
@@ -771,6 +771,13 @@ planning, the design reviewed against the code before it was approved.
page; **no new patch site**. **~~beta.41~~ beta.42**: `slSetConstants` and `ffxConfigure`. **~~beta.42~~
beta.43**: `slGetFeatureVersion` and `slGetFeatureRequirements` — the owner's words: a release of their own, still
hooked. Each starts when the owner says the one before passed its owner-only item.
- **D122 — the second step is two releases** (owner decision 2026-11-12, after the owner's sessions on beta.40
and beta.41 and a review of the draft against the code). **0.1.0-beta.42 adds no patch site**: the session's
upscaler label (D120, `03_METRICS` §Upscaling), a patch registry that refuses what it cannot register, a native
log that survives the game's exit and says which descriptor types each ffx module saw — because Cyberpunk 2077,
set to FSR upscaling, was named "unknown" and nothing in the field could say why (D121) — and FSR's infinite depth
plane (D119). **0.1.0-beta.43 is `slSetConstants` and `ffxConfigure`**, begun only when that log was read. The
third step (`slGetFeatureVersion`, `slGetFeatureRequirements`) is beta.44, train C beta.45, train D beta.46.
- **D118 — 0.1.0-beta.41 is a fix release, and the train's numbers move by one** (owner decision 2026-11-12). The
owner's first evening with beta.40 showed the sensor library being closed under its other users (the paragraph on
`LhmLibrary` below; `20_OPEN_QUESTIONS` §M13); told that the fix would take the number D113 had given the train's
+19 -1
View File
@@ -120,7 +120,21 @@ the traps — is [`handoff/history/0.1.0-beta.40.md`](handoff/history/0.1.0-beta
**Both passed on 2026-11-12, on the owner's word** ("Bạn có thể đánh dấu là pass và tiếp tục") after the thirteen
sessions below; [`handoff/owner-only-passed.md`](handoff/owner-only-passed.md) says what those sessions covered and
what they did not.
2. **0.1.0-beta.42 — train B's second release — ~~when the owner says item 38 passed~~ begins now, with its plan**: `slSetConstants` and
2. **Planned and approved 2026-11-12 (D119–D122): the second step is two releases.** **0.1.0-beta.42 has no new
patch site** — five pull requests: (1) the session's upscaler label (D120); (2) the Overlay's patch registry
refuses a patch it cannot register, and registers before it enables; (3) the native log is flushed whenever
something new was logged, every inventory row's install line names its module and symbol, a failed patch says
why, and the first sight of each ffx descriptor type on each module is logged — so that one Cyberpunk session on
beta.42 says where its upscale goes (D121); (4) FSR's infinite depth plane (D119); (5) the release, owner-only
item 40. **0.1.0-beta.43 is the two new hooks** and begins only when that log was read; its design — reviewed
against the code, which changed it — is in the plan of that day and below. What the review found that the first
draft had wrong: there is no "dominant segment" (segments split on output size only), so the label is the modal
name over the dominant stream; the patch table drops a patch silently when full; the init thread's flush runs
after the watchdog starts; a second NaN pattern for "infinite" would have been dropped by the Agent — real
+infinity is stored instead; the new rows must be gated before `ResolveScoped`, which takes a module reference a
call; `slSetConstants` needs the struct's GUID checked on every call; `ffxConfigure` needs an owner slot of its
own; summaries across viewports must come from the first viewport seen.
~~**0.1.0-beta.42 — train B's second release — when the owner says item 38 passed begins now, with its plan**~~: `slSetConstants` and
`ffxConfigure`. A plan of its own first. What it must settle, beside what
[`handoff/history/0.1.0-beta.40.md`](handoff/history/0.1.0-beta.40.md) §NEXT lists (`kMaxPatches = 48`, the window
of `sl::Constants` pinned outside the camera members, the per-call overhead, the gate's list for the two new
@@ -631,6 +645,10 @@ Where each owner decision is recorded — the file and its section, and a label
| D115 | [`17_HOOK_ENGINE.md`](17_HOOK_ENGINE.md) §Which struct version carries which field | a tail member of a vendor struct is read only where the upstream tags prove it is there |
| D116 | [`18_GPU_VENDOR_APIS.md`](18_GPU_VENDOR_APIS.md) §Train B | "never the camera" is a build gate: `tools/overlay-fields-check.ps1` |
| D118 | [`18_GPU_VENDOR_APIS.md`](18_GPU_VENDOR_APIS.md) §Train B | told that the sensor-library fix would take the number D113 gave train B's second release, the owner chose to release it at once as 0.1.0-beta.41: the train's second and third releases are beta.42 and beta.43, train C beta.44, train D beta.45 |
| D119 | [`07_IPC.md`](07_IPC.md) §Region 5 | `FLT_MAX` (or +infinity) in an FSR depth plane is stored and shown as "infinite" — three engines pass it for the plane at infinity; for FSR only: for Streamline `FLT_MAX` is the "not set" sentinel and stays absent |
| D120 | [`03_METRICS.md`](03_METRICS.md) §Upscaling | a session's upscaler is the technology named on the most samples, and its quality and render size are read from that technology's samples — not the first one named, with the others' values beside it |
| D121 | [`HANDOFF.md`](HANDOFF.md) §NEXT | Cyberpunk 2077 was set to FSR upscaling and FrameLedger named none: a detection gap, to be investigated — which first needs a native log that survives the game's exit |
| D122 | [`18_GPU_VENDOR_APIS.md`](18_GPU_VENDOR_APIS.md) §Train B | train B's second step is split: **beta.42** has no new patch site (D119–D121 and the patch registry's hardening); **beta.43** is the two new hooks, begun only after the owner has run Cyberpunk on beta.42 and its log was read. The third release is beta.44, train C beta.45, train D beta.46 |
| D109 | [`../legal/DISCLAIMER.md`](../legal/DISCLAIMER.md) §5, §5A | asked on 2026-11-11 with both sentences quoted: the Disclaimer goes to 2.15 with the Privacy Policy — PawnIO and the admin mode are no longer "for the CPU temperature" alone; with Advanced metrics on they also read the processor's, the memory's and the motherboard's sensors. The admin mode's disclosure follows (`agent-admin-dialog/2`) |
---
@@ -179,14 +179,22 @@ public static class SessionAggregator
private static SessionRow ApplyUpscaler(SessionRow row, Context c)
{
UpscaleExtent? extent = UpscaleExtent.From(c.Dominant);
FlUpscaler? identity = FgLadder.UpscalerIdentity(c.Input.Records);
// ONE TECHNOLOGY'S NAME, QUALITY AND SIZE (D120, 2026-11-12): the technology named on the most samples of
// the dominant stream, and - when the session names more than one - only the samples that name it. The name
// used to be the first one any record carried, beside a quality byte and a render size taken from whichever
// records had them: a session that saw DLSS briefly and then ran FSR was "DLSS" with FSR's byte and size.
UpscalerChoice choice = UpscalerChoice.From(c.Dominant);
UpscaleExtent? extent = UpscaleExtent.From(choice.Samples);
// A dominant stream that names nothing leaves the name to any other stream that does, as before.
string? named = choice.Kind is { } kind
? Vocabulary.Upscaler(kind)
: FgLadder.UpscalerIdentity(c.Input.Records) is { } elsewhere ? Vocabulary.Upscaler(elsewhere) : null;
bool hookRan = FgLadder.UpscalerHookRan(c.Input.Records);
IReadOnlyList<FrameSample> withParams = [.. c.Dominant.Where(static s => s.Claims(MeasuredFields.UpscalerParams))];
IReadOnlyList<FrameSample> withParams = [.. choice.Samples.Where(static s => s.Claims(MeasuredFields.UpscalerParams))];
return row with
{
Upscaler = identity is { } u ? Vocabulary.Upscaler(u) : hookRan ? "unknown" : null,
UpscalerQuality = QualityByte.Of(withParams)?.ToString(CultureInfo.InvariantCulture),
Upscaler = named ?? (hookRan ? "unknown" : null),
UpscalerQuality = choice.QualityFor(QualityByte.Of(withParams))?.ToString(CultureInfo.InvariantCulture),
UpscalerSharpness = Modal(withParams, static s => s.UpscalerSharpness),
UpscalerDriverReported = c.Input.Ngx.SrCreatedAndEvaluated ? "dlss" : null,
RenderW = extent?.RenderW,
@@ -194,7 +202,9 @@ public static class SessionAggregator
OutputW = extent?.OutputW,
OutputH = extent?.OutputH,
UpscaleRatio = extent?.Ratio,
SettingsChangedMidSession = c.Segments.Count(s => s.Samples.Count > 0) > c.All.Select(static s => s.SwapchainId).Distinct().Count(),
// A second technology named in one session is a setting changed mid-session, as a changed output size is.
SettingsChangedMidSession = choice.Named > 1
|| c.Segments.Count(s => s.Samples.Count > 0) > c.All.Select(static s => s.SwapchainId).Distinct().Count(),
HdrFlag = Vocabulary.Tri(c.Hdr),
HdrSource = c.Hdr == Tri.NotApplicable ? null : Vocabulary.Measured,
};
@@ -408,10 +418,9 @@ public static class SessionAggregator
FrameStatistics stats = c.Generating
? FrameStatistics.From(FrameTimeSeries.ApplicationFrames(seg.Samples, null, c.Input.QpcFrequency).FrameTimesMs, presented: false)
: FrameStatistics.From(series.FrameTimesMs, presented: true);
UpscaleExtent? extent = UpscaleExtent.From(seg.Samples);
UpscalerKind? upscaler = seg.Samples.Where(static s => s.Claims(MeasuredFields.Upscaler))
.Select(static s => s.Upscaler)
.FirstOrDefault(static u => u is not UpscalerKind.NotReported and not UpscalerKind.Unknown and not UpscalerKind.RetiredRayReconstruction, UpscalerKind.NotReported);
// The segment's upscaler is chosen as the session's is (D120): one technology's name, quality and size.
UpscalerChoice choice = UpscalerChoice.From(seg.Samples);
UpscaleExtent? extent = UpscaleExtent.From(choice.Samples);
rows.Add(new SegmentRow
{
SwapchainId = seg.SwapchainId,
@@ -421,8 +430,8 @@ public static class SessionAggregator
RenderH = extent?.RenderH,
OutputW = seg.OutputW == 0 ? null : seg.OutputW,
OutputH = seg.OutputH == 0 ? null : seg.OutputH,
Upscaler = upscaler is { } u && u != UpscalerKind.NotReported ? Vocabulary.Upscaler(u) : null,
UpscalerQuality = QualityByte.Of([.. seg.Samples.Where(static s => s.Claims(MeasuredFields.UpscalerParams))])?.ToString(CultureInfo.InvariantCulture),
Upscaler = choice.Kind is { } u ? Vocabulary.Upscaler(u) : null,
UpscalerQuality = choice.QualityFor(QualityByte.Of([.. choice.Samples.Where(static s => s.Claims(MeasuredFields.UpscalerParams))]))?.ToString(CultureInfo.InvariantCulture),
FgMode = null,
NativeFps = null,
DisplayedFps = series.AverageFps,
@@ -0,0 +1,82 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
namespace FrameLedger.Domain.Metrics;
/// <summary>
/// Which upscaler a stream of samples names, and the samples its quality and render size are to be read from - so
/// that the name, the quality and the size a session shows are those of ONE technology (owner decision D120,
/// 2026-11-12; <c>03_METRICS</c> §Upscaling).
/// </summary>
/// <remarks>
/// <para>
/// <b>WHY.</b> The session's name used to be the FIRST technology any record named, while its quality byte and its
/// render size came from whichever records carried them. A real session of 81 seconds (Dying Light: The Beast, an FSR
/// dispatch and a DLSS evaluation both seen) was stored as "DLSS" with FSR's quality byte and FSR's render size: three
/// true readings, of two technologies, under one name.
/// </para>
/// <para>
/// <b>THE RULE.</b> The technology named on the most samples; a tie goes to the lower value, as
/// <see cref="QualityByte.Of"/> breaks its own. While only one technology is named the samples are the whole stream,
/// exactly as before - under frame generation a name sits on one present in N, and the render size of the presents
/// between must still count. When more than one is named, the samples are those that name the chosen one, and
/// nothing of the other is carried under its name.
/// </para>
/// </remarks>
public sealed record UpscalerChoice
{
private UpscalerChoice(UpscalerKind? kind, int named, IReadOnlyList<FrameSample> samples)
{
Kind = kind;
Named = named;
Samples = samples;
}
/// <summary>The technology named on the most samples; null when no sample names one.</summary>
public UpscalerKind? Kind { get; }
/// <summary>How many different technologies the stream names. More than one is a setting changed mid-session.</summary>
public int Named { get; }
/// <summary>The samples the quality and the render size are read from.</summary>
public IReadOnlyList<FrameSample> Samples { get; }
/// <summary>True for a value that names a technology: not "not reported", not "unknown", not the retired value.</summary>
public static bool IsNamed(UpscalerKind kind) =>
kind is not (UpscalerKind.NotReported or UpscalerKind.Unknown or UpscalerKind.RetiredRayReconstruction);
/// <summary>True for FSR in any of its versions, the family <see cref="QualityByte.IsFsr"/>'s bytes belong to.</summary>
public static bool IsFsr(UpscalerKind kind) =>
kind is UpscalerKind.Fsr2 or UpscalerKind.Fsr3 or UpscalerKind.Fsr4 or UpscalerKind.FsrUnversioned;
/// <summary>
/// A quality byte that belongs to the named technology's family, or null: FSR's bytes under an FSR name, any
/// other byte under any other name. A byte of the other family is withheld rather than shown under a name it
/// was not measured for.
/// </summary>
public byte? QualityFor(byte? quality) =>
quality is byte value && Kind is { } kind && QualityByte.IsFsr(value) != IsFsr(kind) ? null : quality;
public static UpscalerChoice From(IReadOnlyList<FrameSample> stream)
{
ArgumentNullException.ThrowIfNull(stream);
(UpscalerKind Kind, int Count)[] named =
[
.. stream
.Where(static s => s.Claims(MeasuredFields.Upscaler) && IsNamed(s.Upscaler))
.GroupBy(static s => s.Upscaler)
.Select(static g => (g.Key, g.Count()))
.OrderByDescending(static g => g.Item2)
.ThenBy(static g => g.Key),
];
if (named.Length == 0)
{
return new UpscalerChoice(kind: null, named: 0, stream);
}
UpscalerKind chosen = named[0].Kind;
return named.Length == 1
? new UpscalerChoice(chosen, named: 1, stream)
: new UpscalerChoice(chosen, named.Length, [.. stream.Where(s => s.Claims(MeasuredFields.Upscaler) && s.Upscaler == chosen)]);
}
}
@@ -239,6 +239,78 @@ public sealed class SessionAggregatorTests
r.Segments[0].OutputW.Should().Be(2560);
}
[Fact]
public void ASessionThatSawDlssFirstAndThenRanFsrIsFsrWithFsrsQualityAndSize()
{
// D120. The name used to be the FIRST technology any record carried: this session was "dlss" with the quality
// byte and the render size of the FSR that ran for four fifths of it.
FlMeasured claims = _presentOnly | FlMeasured.Upscaler | FlMeasured.UpscalerParams;
var writer = new FlWriterState { Status = 1, HooksInstalledMask = 0x7 };
List<FlFrameRecord> records =
[
.. SessionFixtures.Stream(500, claims, upscaler: FlUpscaler.Dlss).Select(static (r, i) => i < 100
? r with { UpscalerQuality = 0xFF, RenderW = 1485, RenderH = 835 }
: r with { Upscaler = (byte)FlUpscaler.FsrUnversioned, UpscalerQuality = 0x12, RenderW = 1505, RenderH = 847 }),
];
AggregationResult r = SessionAggregator.Aggregate(SessionFixtures.Skeleton(), SessionFixtures.Hooked(records, writer));
r.Row.Upscaler.Should().Be("fsr", "named on four hundred records, against a hundred");
r.Row.UpscalerQuality.Should().Be("18");
r.Row.RenderW.Should().Be(1505);
r.Row.RenderH.Should().Be(847);
r.Row.SettingsChangedMidSession.Should().BeTrue("a second technology named in one session is a setting changed mid-session");
r.Segments.Should().ContainSingle("the output size never changed").Which.Upscaler.Should().Be("fsr");
r.Segments[0].UpscalerQuality.Should().Be("18");
r.Segments[0].RenderW.Should().Be(1505);
}
[Fact]
public void ASessionThatRanDlssAndSawFsrBrieflyKeepsNothingOfFsrUnderDlssName()
{
// The real one (Dying Light: The Beast, 81 s): DLSS for most of it, which does not tell its mode; FSR for a few
// seconds, which does. Stored as "dlss" with FSR's Balanced byte and FSR's render size - three true readings of
// two technologies under one name. What DLSS did not say is N/A, never the neighbour's value (rule 7).
FlMeasured claims = _presentOnly | FlMeasured.Upscaler | FlMeasured.UpscalerParams;
var writer = new FlWriterState { Status = 1, HooksInstalledMask = 0x7 };
List<FlFrameRecord> records =
[
.. SessionFixtures.Stream(500, claims, upscaler: FlUpscaler.Dlss).Select(static (r, i) => i is >= 200 and < 260
? r with { Upscaler = (byte)FlUpscaler.FsrUnversioned, UpscalerQuality = 0x12, RenderW = 1505, RenderH = 847 }
: r with { UpscalerQuality = 0xFF, RenderW = 1485, RenderH = 835 }),
];
AggregationResult r = SessionAggregator.Aggregate(SessionFixtures.Skeleton(), SessionFixtures.Hooked(records, writer));
r.Row.Upscaler.Should().Be("dlss");
r.Row.UpscalerQuality.Should().BeNull("DLSS did not tell its mode, and FSR's byte is not DLSS's");
r.Row.RenderW.Should().Be(1485, "the size DLSS rendered at, not the one FSR did for sixty frames");
r.Row.RenderH.Should().Be(835);
r.Row.SettingsChangedMidSession.Should().BeTrue();
}
[Fact]
public void ANameOnOnePresentInFourStillNamesTheSessionAndChangesNothingElse()
{
// Under frame generation the writer names the upscaler only on the presents that drained an evaluation. One
// technology, named rarely: the whole stream still counts, and nothing is "changed mid-session".
FlMeasured claims = _presentOnly | FlMeasured.Upscaler | FlMeasured.UpscalerParams;
var writer = new FlWriterState { Status = 1, HooksInstalledMask = 0x7 };
List<FlFrameRecord> records =
[
.. SessionFixtures.Stream(500, claims, upscaler: FlUpscaler.Unknown).Select(static (r, i) => i % 4 == 0
? r with { Upscaler = (byte)FlUpscaler.Fsr3, UpscalerQuality = 0x11, RenderW = 1707, RenderH = 960 }
: r with { UpscalerQuality = 0xFF, RenderW = 1707, RenderH = 960 }),
];
AggregationResult r = SessionAggregator.Aggregate(SessionFixtures.Skeleton(), SessionFixtures.Hooked(records, writer));
r.Row.Upscaler.Should().Be("fsr3");
r.Row.UpscalerQuality.Should().Be("17");
r.Row.RenderW.Should().Be(1707);
r.Row.SettingsChangedMidSession.Should().BeFalse();
}
/// <summary>
/// <c>0xFF</c> is the Overlay's "a hook ran and could not tell" for the quality byte, and every AMD dispatch carries it.
/// Aggregated as a number it became the text "255", which the game page appends to the upscaler's name ("FSR 255").
@@ -0,0 +1,114 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using FluentAssertions;
using FrameLedger.Domain.Metrics;
namespace FrameLedger.Domain.Tests.Metrics;
/// <summary>
/// One technology's name, quality and size (owner decision D120): which upscaler a stream names, and which samples
/// its quality and render size may be read from.
/// </summary>
public sealed class UpscalerChoiceTests
{
private static FrameSample Sample(UpscalerKind upscaler, MeasuredFields measured = MeasuredFields.Upscaler | MeasuredFields.UpscalerParams) => new()
{
SwapchainId = 1,
Upscaler = upscaler,
UpscalerQuality = FrameSample.QualityNotTold,
Measured = measured,
};
private static List<FrameSample> Of(params (UpscalerKind Kind, int Count)[] runs) =>
[.. runs.SelectMany(static r => Enumerable.Repeat(r.Kind, r.Count)).Select(static k => Sample(k))];
[Fact]
public void AStreamThatNamesNothingChoosesNothingAndKeepsEverySample()
{
List<FrameSample> stream = Of((UpscalerKind.Unknown, 40), (UpscalerKind.NotReported, 10), (UpscalerKind.RetiredRayReconstruction, 5));
UpscalerChoice choice = UpscalerChoice.From(stream);
choice.Kind.Should().BeNull("unknown, not reported and the retired value name no technology");
choice.Named.Should().Be(0);
choice.Samples.Should().BeSameAs(stream);
UpscalerChoice.From([]).Kind.Should().BeNull();
FluentActions.Invoking(static () => UpscalerChoice.From(null!)).Should().Throw<ArgumentNullException>();
}
[Fact]
public void OneTechnologyNamedOnAFewPresentsIsTheChoiceAndEverySampleStillCounts()
{
// Under frame generation a name sits on one present in N: the others say "unknown" and still carry the
// render size of the frame they belong to.
List<FrameSample> stream = Of((UpscalerKind.Unknown, 3), (UpscalerKind.FsrUnversioned, 1), (UpscalerKind.Unknown, 3), (UpscalerKind.FsrUnversioned, 1));
UpscalerChoice choice = UpscalerChoice.From(stream);
choice.Kind.Should().Be(UpscalerKind.FsrUnversioned);
choice.Named.Should().Be(1);
choice.Samples.Should().BeSameAs(stream, "with one technology named nothing is left out, exactly as before");
}
[Fact]
public void WithTwoTechnologiesNamedTheOneOnTheMostSamplesIsChosenAndOnlyItsSamplesAreRead()
{
// The session this exists for: DLSS seen first, briefly, then FSR for the rest. First-named said "DLSS".
List<FrameSample> stream = Of((UpscalerKind.Dlss, 20), (UpscalerKind.Unknown, 15), (UpscalerKind.FsrUnversioned, 60));
UpscalerChoice choice = UpscalerChoice.From(stream);
choice.Kind.Should().Be(UpscalerKind.FsrUnversioned);
choice.Named.Should().Be(2, "which is a setting changed mid-session");
choice.Samples.Should().HaveCount(60).And.OnlyContain(static s => s.Upscaler == UpscalerKind.FsrUnversioned,
"nothing of the other technology, and nothing unnamed, is carried under the chosen name");
}
[Fact]
public void ATieGoesToTheLowerValueAndASampleThatDoesNotClaimTheFieldNamesNothing()
{
UpscalerChoice.From(Of((UpscalerKind.Fsr3, 10), (UpscalerKind.Dlss, 10))).Kind.Should().Be(UpscalerKind.Dlss, "as QualityByte.Of breaks its own ties");
// A value set while its bit is clear is the writer's defect: it is not a name.
List<FrameSample> unclaimed = [.. Enumerable.Repeat(Sample(UpscalerKind.Dlss, MeasuredFields.None), 50), Sample(UpscalerKind.Fsr3)];
UpscalerChoice choice = UpscalerChoice.From(unclaimed);
choice.Kind.Should().Be(UpscalerKind.Fsr3);
choice.Named.Should().Be(1);
}
[Theory]
[InlineData(UpscalerKind.Dlss, true)]
[InlineData(UpscalerKind.Nis, true)]
[InlineData(UpscalerKind.None, true)]
[InlineData(UpscalerKind.FsrUnversioned, true)]
[InlineData(UpscalerKind.Unknown, false)]
[InlineData(UpscalerKind.NotReported, false)]
[InlineData(UpscalerKind.RetiredRayReconstruction, false)]
public void ATechnologyIsNamedByEveryValueButTheThreeThatSayNothing(UpscalerKind kind, bool named) =>
UpscalerChoice.IsNamed(kind).Should().Be(named);
[Theory]
[InlineData(UpscalerKind.Fsr2, true)]
[InlineData(UpscalerKind.Fsr3, true)]
[InlineData(UpscalerKind.Fsr4, true)]
[InlineData(UpscalerKind.FsrUnversioned, true)]
[InlineData(UpscalerKind.Dlss, false)]
[InlineData(UpscalerKind.XeSS, false)]
public void FsrIsAFamilyOfFour(UpscalerKind kind, bool fsr) => UpscalerChoice.IsFsr(kind).Should().Be(fsr);
[Fact]
public void AQualityByteOfTheOtherFamilyIsWithheldRatherThanShownUnderTheName()
{
UpscalerChoice dlss = UpscalerChoice.From(Of((UpscalerKind.Dlss, 5)));
UpscalerChoice fsr = UpscalerChoice.From(Of((UpscalerKind.Fsr3, 5)));
UpscalerChoice none = UpscalerChoice.From(Of((UpscalerKind.Unknown, 5)));
dlss.QualityFor(0x12).Should().BeNull("0x12 is FSR's Balanced; under DLSS it is not a mode anyone measured");
dlss.QualityFor(3).Should().Be(3);
fsr.QualityFor(0x12).Should().Be(0x12);
fsr.QualityFor(3).Should().BeNull("a DLSS mode under an FSR name");
fsr.QualityFor(null).Should().BeNull();
none.QualityFor(0x12).Should().Be(0x12, "with no technology named there is no name to contradict");
}
}