Compare commits

...
Author SHA1 Message Date
poli0981andClaude Opus 5.5 5d0f8a47ac feat: every frame-generation state a session held - a bar and a table with each state's share, its own Native -> Displayed and how it was set (D62, beta.24 PR-6)
- Domain: Metrics/FgMix over the steady state's own five-second windows (FgSlices: the cut and the
  dominant state, moved out of FgSteadyState unchanged). Windows are active, no frame generation (only
  where a counted none is allowed) or not classified; active ones are grouped by repeating the steady
  state's extraction until none is left, a group under 10 s going back to not classified. Each row has
  its own factor, rates, seconds and share; the shares sum to 1. Never an average across states.
- Application: SessionAggregator stores it as sessions.fg_mix (schema 0020, JSON through FgMixRecord)
  when the frame generation was named and the count stood or was refused only as non_uniform /
  ambiguous_band. Older sessions keep NULL and are never rebuilt from their blobs.
- App: the summary's "Frame generation in this session" - FgMixBar (chart palette, a state by its
  multiplier, two new keys; follows a theme switch through ApplicationBackgroundColor) and a table
  (swatch, x4.0 frame generation, 35.33%, 70 -> 282 FPS, time); above it how frame generation was set
  (NvidiaOverrides.FrameGenerationContext: the NVIDIA App's Dynamic / Fixed, the driver's own profile, or
  the game); a line for a session that counted frame generation and has no mix. CSV "# fg_mix:"; the
  FG column's formats moved to resx; the profile line's automatic dynamic target reads "max refresh rate".
- Strings: 26 new keys en/vi/ja (ja marked review), one reworded.
- Tests: FgMixTests, FgMixPresentationTests, NvidiaOverridesTests, SessionSummaryViewModelTests,
  SessionExporterTests, SessionAggregatorTests, LedgerDatabaseTests (script 0020), the repository round
  trip, MetricEnumMirrorTests (FgMixKind is Domain's own); the summary surface in PagesLoadTests carries
  a mix, so the block is read in both themes and through a switch.
- Docs: CLAUDE.md rule 6 (dated amendment), 03_METRICS The mix, 06_DATA_MODEL 0020, 08_UI, LIMITATIONS,
  guide 03/07/10, CHANGELOG; legal/ACCURACY.md's frame-generation bullet gains the sentence approved
  with the plan (README and the Disclaimer carry it verbatim).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 18:48:10 +07:00
52 changed files with 1933 additions and 125 deletions

No files matched your search

+14
View File
@@ -35,6 +35,20 @@ numeric core and does not move; the heading is the full version — corrected 20
## [Unreleased]
### Added
- **Every frame-generation state a session held, in its summary** (owner request 2026-10-19, decision D62). Under the
figures, *Frame generation in this session* lists each state — `×2.0`, `×3.0`, `×4.0`, `×6.0`… — with its own
Native → Displayed and its share of the time to two decimals, then the time with no frame generation and the time no
state explains (*Not classified*: switching, loading, a multiplier that changed faster than five seconds), above a bar
of those shares. A line above them says how frame generation was set: in the NVIDIA App (*Dynamic, up to ×6, target:
max refresh rate*, *Fixed ×4*, from the driver profile stored with the session) or in the game. Each state is read
over the same five-second windows as the steady state and lasts at least 10 seconds; nothing is averaged across
states (rule 6). Stored with the session (schema 0020, `sessions.fg_mix`): a session recorded before has none, and
its summary says so in one line. The CSV export gains a `# fg_mix:` line; the JSON carries the column. The FG×
column's two formats are translated strings now, and the driver-profile line's automatic dynamic target reads as the
NVIDIA App says it: *max refresh rate*.
### Changed
- **SonarCloud analyses only FrameLedger's own code** (developers only; owner request 2026-10-19, decision D67). A
+2
View File
@@ -30,6 +30,8 @@ A C++ DLL (`FrameLedger.Overlay.dll`) is injected into games the user explicitly
> **Amended 2026-09-06 (Leg 0 landed): narrowed, not withdrawn.** `sl.dlss_g.dll` is a startup-time load on that title (frame generation off, census unchanged, twice), and the same morning's ×4 capture measured the discriminator the gate lacked: the 2.8.0 pacer's generated presents are DXGI presents on the hooked chain (§H5 row P1-DXGI), counted through `dxgiUnseen` into `Native 70.52 → Displayed 282.08 (×4 FG)`. So a counted `none` beside a READ `IDXGISwapChain::GetLastPresentCount` with zero unseen is `none`, printed with DXGI's agreement; it is withheld only when the counter was not read.
>
> **Amended 2026-09-17 (owner decision): the steady state.** A session whose frame-generation state changed (menus, loading, a settings change) has no session-wide factor — averaging ×1 menus with ×4 gameplay is the inflated-or-deflated single number this rule forbids — but it is no longer left with none: *Native → Displayed (×N FG)* is shown for the state the session spent most of its generating time in, **always with the share of the session it covers** (`62 → 118 FPS (×1.9 FG · 75%)`), never as a session average (`docs/03_METRICS.md` §The steady state).
>
> **Amended 2026-10-19 (owner decision D62): the mix.** Beside the steady state, the session summary lists every frame-generation state the session held — each with its own *Native → Displayed*, its factor and its share of the presenting time (`×4.0 frame generation · 35.33% · 70 → 282 FPS`) — then the time with no frame generation and the time no state claims. Every row is one state's own numbers; nothing is averaged across states, and a state's factor never appears without its rates (`docs/03_METRICS.md` §The mix).
7. **RT / PT / RR are tri-state** (`Yes` / `No` / `N/A`) with manual override. They are now *measured*, not guessed — but where measurement is genuinely impossible, the honest answer is still `N/A`. Never fabricate `Yes`.
> **Amended 2026-08-20 with the PR that wrote the hooks, per the owner ruling of 2026-08-14.** This rule named *"inline RayQuery without DXIL scan"* as one of the impossible cases, and that conflated two questions. **Whether rays are being traced is measurable** — `BuildRaytracingAccelerationStructure` is called by RayQuery titles and by `DispatchRays` titles alike, which is why both hooks exist and why the `No` branch requires the AS-build hook to have been *installed*. What needs a DXIL scan is **classifying the technique as RayQuery**, and that stays `N/A`. So the impossible cases are: naming the technique, and path-tracing classification, which has no API-level signature at all (`03_METRICS` §RT/PT/RR — a confidence score that may only ever *suggest*).
+6
View File
@@ -65,6 +65,12 @@ shown is recorded too, from outside the game. ([Capture](docs/04_CAPTURE.md))
- **A session whose frame generation changed** (menus, loading, a settings change) shows the factor of the
state it spent most of its time in, with the share of the session it covers — never an average of the two.
([Metrics](docs/03_METRICS.md))
- **The mix of frame-generation states** in a session's summary (since 0.1.0-beta.24) is read over five-second
windows: frame generation that changes faster than that — the NVIDIA App's *Dynamic* mode can — reads partly as
*Not classified*, and a state shorter than 10 seconds is not listed. The multiplier chosen in a game's own menu is
not read; the measured factor is its evidence. How the NVIDIA App's *Dynamic* ceiling and *Max refresh rate* target
are stored by the driver is read from NVIDIA's own setting names and not yet checked against the App on a real
game. Sessions recorded before 0.1.0-beta.24 have no mix. ([Metrics](docs/03_METRICS.md))
- **Time below 30, 60 FPS and below the refresh rate** (since 0.1.0-beta.14) leaves out the small wobble of a game
held at its limit: a frame counts as below 60 when it took 10 % longer than 1/60 s, or when the frames around it ran
2 % slower. So a game running steadily just under the line — 59 FPS against 60 — reads partly as at it. Time below
+8 -7
View File
@@ -11,7 +11,7 @@ guide, Help ▸ Limitations), and on the project's [wiki](https://github.com/pol
pages.
<!-- accuracy-block:begin -->
> ⚠ **What FrameLedger actually measures today — 2026-10-13.** The software is a beta; its latest
> ⚠ **What FrameLedger actually measures today — 2026-10-19.** The software is a beta; its latest
> **pre-release is `0.1.0-beta.23`** (2026-10-14), an unsigned installer built from that tag with its
> checksums published beside it. The source holds the desktop app
> (library, store import, charts, settings) and the background Agent, which records a session when a
@@ -50,12 +50,13 @@ pages.
> (menus, loading screens, a settings change), no session-wide factor is shown: the factor, Native and
> Displayed are those of the state that held longest — five-second windows whose ratios agree within
> 10 %, covering at least 10 s and 10 % of the time the game was presenting — and are always shown with
> the share of the session they cover; with no such state, the reason is shown instead. DLSS-G and FSR
> FG are named from the calls the game makes; any other generator (XeSS-FG, one compiled into the game)
> is shown only as active with the technology not identified, and is never named. Where a technology is
> named but its frames could not be counted, or frame generation is not measured, the software shows
> **Presented FPS** with a note on what it may include — never a Native figure. Where generated frames
> were counted, the lows, median and stutter are taken over application frames only.
> the share of the session they cover; with no such state, the reason is shown instead. The session
> summary lists each state it held, with its share of the time and its own Native → Displayed rates.
> DLSS-G and FSR FG are named from the calls the game makes; any other generator (XeSS-FG, one compiled
> into the game) is shown only as active with the technology not identified, and is never named. Where a
> technology is named but its frames could not be counted, or frame generation is not measured, the
> software shows **Presented FPS** with a note on what it may include — never a Native figure. Where generated
> frames were counted, the lows, median and stutter are taken over application frames only.
> - **Ray tracing:** Yes/No measured on Direct3D 12 from ray-dispatch and acceleration-structure-build
> calls; the technique and path tracing are `N/A`, and so is ray tracing on other APIs.
> - **Display mode:** how each game's window was shown — exclusive full-screen, borderless, windowed or
+43
View File
@@ -470,6 +470,49 @@ F_app = Σ fgEvaluations (APPLICATION frames, counted at the
> *(Settled 2026-08-20 with the RT hooks — §RT/PT/RR, "The denominator": `rt_frame_pct` is a share of presents
> and says so, and the tri-state is unaffected. Marked here 2026-10-04.)*
> ### The mix — owner decision 2026-10-19 (D62)
>
> **The steady state names one state; a session can hold several.** A player who tries ×2, ×3 and ×4 in one session,
> or whose NVIDIA App runs frame generation as *Dynamic*, got the longest state alone. Since beta.24 **every** state is
> stored beside it: `Domain.Metrics.FgMix`, over the same five-second windows the steady state is read over (one cut,
> `FgSlices.Cut`), from where `FgWindow` starts (the claimed suffix).
>
> **The rule.** Each window is classified by its own `presents ÷ tokens`: **active** (≥ 1.5, with ≥ 8 samples and
> tokens), **no frame generation** (≤ 1.05, with ≥ 8 samples and tokens — and only where a counted `none` is allowed:
> not on the shape `FgLadder.WithholdNone` withholds, §Frame Generation), else **not classified** (too few samples, no
> tokens, the band between 1.05 and 1.5, or a withheld `none`). The active windows are grouped by repeating the steady
> state's own extraction on what is left — the ±10 % cluster holding the most time, pooled, redrawn once — until no
> cluster remains; a cluster under **10 s** returns its windows to *not classified*. A state's factor, Native and
> Displayed are its own (Σ presents ÷ Σ tokens over its windows; each rate over its own seconds); a row's share is its
> seconds over every window's, so the rows sum to 100 % and the longest state's share is `fg_steady_share` when the
> session has one. Rows: the states by rising factor, then *no frame generation*, then *not classified*. **Never an
> average across states** (CLAUDE.md rule 6), and ×5 and ×6 are 20 % apart and never pool.
>
> **When there is a mix.** Only where the session's frame generation was named (`Named` / `ActiveUnidentified`) and the
> session-wide count either stood or was refused as `NonUniform` / `AmbiguousBand` — a change of state is exactly what a
> mix describes. Every other refusal (not counted, unattributed, interleaved streams, either saturation, no
> evaluations, too short, no batches) gets none — slicing does not make a refused record set trustworthy, the steady
> state's rule — and so does a session in which no state formed.
>
> **Stored, never replayed.** `sessions.fg_mix` (schema 0020) holds the rows as JSON (`FgMixRecord`), written by the
> recorder's aggregation beside the steady state. A session recorded before has none and is not rebuilt: `frame_blobs`
> keep one Generated bit per frame and lose the presents only DXGI counted, so a mix rebuilt from them would be wrong on
> exactly the titles that need one. The summary says so in one line for a session that counted frame generation and has
> no mix.
>
> **What it shows, and what it cannot.** The summary's block (`08_UI` §Session summary): a bar of the shares, then a
> row per state — `×4.0 frame generation · 35.33% · 70 → 282 FPS · 2m 05s` —, *No frame generation* with its one rate,
> *Not classified* with its time; shown when the mix has two rows or more (one state throughout is the readout's own
> number). Frame generation that changes faster than the five-second windows — the NVIDIA App's *Dynamic* mode can —
> reads partly as *not classified* rather than as a factor nobody held. Above the rows, how frame generation was SET:
> the NVIDIA App's Frame Generation Mode from the driver profile stored with the session (*Dynamic, up to ×6, target:
> max refresh rate*; *Fixed ×4*), or that the profile sets none — the game's own menu chose
> (`NvidiaOverrides.FrameGenerationContext`). That line is configuration, never one of the rows. The multiplier chosen
> in a game's menu is not read — it reaches the runtime through `sl::DLSSGOptions`, the route `HANDOFF` §2b refused —
> so the measured row is its evidence. The dynamic ceiling (`NGX_DLSSG_DYNAMIC_MULTI_FRAME_COUNT_MAX`) is decoded as
> `NGX_DLSSG_MULTI_FRAME_COUNT` is (frames generated per rendered frame) and the automatic target as "max refresh
> rate"; NVIDIA's header names neither, and owner-only item 20(a) checks both against the App.
`fgEvaluations` is recorded per present by ~~the NGX/Streamline/FFX/XeSS FG hooks~~ the `slGetNewFrameToken`
detour; where Streamline never issued a token, by the FidelityFX dispatches — new PREPARE `frameID`s, else UPSCALE
dispatches, the FSR 3.0 host's included *(corrected 2026-10-04: NGX and XeSS have no hook)*
+16
View File
@@ -315,6 +315,11 @@ CREATE TABLE sessions (
power_limit_pct REAL, thermal_limit_pct REAL, -- shares of the ticks that carried reasons: NVIDIA (L3) only
app_frames_per_joule REAL, -- application FPS / average GPU board power; never displayed frames (rule 6)
-- schema 0020 (2026-10-19, beta.24, D62): every frame-generation state the session held — 03_METRICS §The mix
fg_mix TEXT, -- {"Rows":[{"Kind":"generated","Factor":4.0,"NativeFps":…,"DisplayedFps":…,
-- "Seconds":…,"Share":…,"Windows":…}, …]}: states by rising factor, then
-- "none", then "unclassified"; NULL with no state, and before 0020
-- schema 0016 (2026-09-27, beta.10): the display mode, both tiers (03_METRICS §Display mode). Milliseconds per mode,
-- each sample standing for the time until the next (100 ms hooked, 1 s at Tier 2), a pause not counted; nowindow is
-- outside every share. NULL before, on a session recovered from its .partial file, and where the loop never sampled —
@@ -671,6 +676,17 @@ Sequential embedded SQL (`Migrations/0001_init.sql`, `0002_*.sql`, …), applied
> already carried. `LatestVersion` is 19; `LedgerDatabaseTests.ScriptNineteenAddsThePacingAndCardColumnsAndAnEarlierSessionHasNone`,
> `SqliteSessionRepositoryTests.ASessionRoundTripsColumnForColumn`. **A beta.13 cannot open a ledger beta.14 migrated.**
> **`0020_fg_mix.sql` (beta.24, 2026-10-19, owner decision D62) — every frame-generation state a session held.** One
> TEXT column, ADD COLUMN only: `fg_mix`, `Application.Recording.FgMixRecord`'s JSON of `Domain.Metrics.FgMix` — each
> state's pooled factor, its own Native and Displayed rates, its seconds, its share of the presenting time and its
> five-second windows; then the time with no frame generation and the time no state claims (`03_METRICS` §The mix).
> Written by the recorder's aggregation (`SessionAggregator.ApplyFg`, beside the steady state) for a hooked session whose
> frame generation was named and whose count stood or was refused only as `non_uniform` / `ambiguous_band`; NULL
> otherwise. A session before it has none and is **never rebuilt** from its `frame_blobs` (one Generated bit per frame,
> the DXGI-counted presents lost). The `.partial` needs no change: a recovered session is aggregated from its records
> like any other. `LatestVersion` is 20; `LedgerDatabaseTests.ScriptTwentyAddsTheFgMixColumnAndAnEarlierSessionHasNone`,
> `SqliteSessionRepositoryTests.ASessionRoundTripsColumnForColumn`. **A beta.23 cannot open a ledger beta.24 migrated.**
> **Every open used to migrate, and one that should not have did — 2026-09-16.** The Agent's `--console sessions`,
> a verb that prints, was run against the owner's ledger while the file on disk was at schema 2 and applied 0003 and
> 0004 to it. `LedgerDatabase.OpenReadOnlyAsync` exists since that day: an existing file, `PRAGMA query_only`, no
+16
View File
@@ -561,6 +561,22 @@ All screens are `Page`s registered with the navigation page provider and navigat
### Session summary (secondary `FluentWindow`, also the post-session toast target)
Stat cards (Avg uses `FpsReadout`, Median, 1% Low, 0.1% Low, Min/Max, σ, stutter %, duration, **Display** — beta.10: the mode shown longest with its share and the window's size, both tiers; **VRAM (this game)** and **RAM (this game)** — beta.12: the median with the peak beneath, both tiers), **Statistics per series** (beta.12: every stored series' mean / median / minimum / peak), TriState chips, API/PresentMode/upscaler line, **the display line** (beta.10: every mode's share, the changes, the window on its monitor at its refresh rate, the back buffer and swap effect, and what the facts rested on — "the swap chain said whether it was exclusive" or "from the window alone: exclusive fullscreen cannot be told from borderless"; absent for a session recorded before), crash `InfoBar` (Severity=Error) when `crashed`, frametime chart, sensor strip, tags/notes editor, Export buttons.
> **beta.24 (D62): the frame-generation mix.** Under the stat cards, **Frame generation in this session** — shown when
> the session stored a mix of two rows or more (`sessions.fg_mix`, `03_METRICS` §The mix): a line saying how frame
> generation was set (the NVIDIA App's Frame Generation Mode from the stored driver profile — *Set in the NVIDIA App:
> Dynamic, up to ×6, target: max refresh rate*, *Fixed ×4* — or *Set in the game — no NVIDIA App frame-generation
> override*; a value the driver ships in its own profile is said as the driver's; no line where no NVIDIA profile was
> read), a bar of the shares (`Controls/FgMixBar`: drawn from code in the chart palette — a state by its multiplier,
> `Chart_MixNone` and `Chart_MixUnclassified` for the other two — following a theme switch through
> `ApplicationBackgroundColor` as `ArtTint` does; announced by its `AutomationProperties.Name`), and a table: a colour
> swatch, the row (*×4.0 frame generation*, *No frame generation*, *Not classified*), its share to two decimals
> (`<0.01%` for a sliver, never 0), its own *Native → Displayed* (one rate with no frame generation, none where no state
> was read), and its time. A sentence explains *Not classified* when the table has it. A session that counted frame
> generation and stored no mix — recorded before beta.24, or no state of 10 s — says so in one tertiary line. The CSV
> export gains `# fg_mix:`; the JSON carries the column in its aggregates. Tests: `FgMixPresentationTests`,
> `NvidiaOverridesTests`, `SessionSummaryViewModelTests`, `SessionExporterTests`, and the summary surface in
> `PagesLoadTests` carries a mix so the block is read in both themes and through a switch.
> **beta.14 (D49): the new measurements, as cards and charts.** The cards come in three methods (`AddFrameCards`,
> `AddPacingCards`, `AddMachineCards`), every value read from the row — never recomputed — and N/A on a row written before
> beta.14:
+5
View File
@@ -13,6 +13,11 @@ A value FrameLedger could not measure reads **N/A** — never 0, and never an es
- **When frame generation was measured**, the game's own frames and the frames you saw are shown together:
`62 → 118 FPS (×1.9 FG)`. If frame generation changed during the session (menus, loading screens, a settings change),
the figures are for the state that lasted longest, with the share of the session it covers: `(×1.9 FG · 75%)`.
- **Frame generation in this session** (sessions recorded with 0.1.0-beta.24 or later) lists every frame-generation
state the session held — `×2.0`, `×4.0`… — each with its own frame rates and its share of the time, then the time
without frame generation, and *Not classified* for time in no state that lasted at least 10 seconds: switching,
loading, or a multiplier that changed faster than FrameLedger reads it. Above the list, whether the NVIDIA App set
frame generation (*Dynamic*, *Fixed*) or the game did.
- **When it could not be measured**, you see **Presented FPS** with a sentence saying whether generated frames could be
included in it. FrameLedger never shows a single number that may count generated frames as the game's own.
- **1% low** and **0.1% low** are the frame rate of the slowest 1% and 0.1% of frames: the further they fall below the
+2
View File
@@ -96,6 +96,8 @@ It opens from a session row, from the Dashboard, and from the notice when a sess
- The **Ray Tracing**, **Path Tracing** and **Ray Reconstruction** chips: click one to correct it by hand, for this
session or as the game's default. Your correction is labelled as yours.
- The figures, the charts and **Statistics per series** — [Read your results](03-read-your-results.md) explains each.
- **Frame generation in this session** — a bar and a table of every frame-generation state the session held, when it
held more than one, with how frame generation was set.
- **Tags and notes** with **Save**, and **Export CSV**, **Export JSON**, **Export PNG**.
## Compare
+2
View File
@@ -28,6 +28,8 @@ What the words on FrameLedger's screens mean, in alphabetical order. How each fi
- **Ledger** — the one database file that holds your library and sessions, `%LOCALAPPDATA%\FrameLedger\ledger.db`.
- **N/A** — not measured. Never 0, and never an estimate.
- **Native FPS** — the frames the game rendered itself.
- **Not classified** — in a session's frame-generation mix, time in no state that lasted at least 10 seconds:
switching, loading, or a multiplier that changed faster than FrameLedger reads it.
- **Overlay build** — the version of the component that hooking loads into a game. It draws nothing on your screen.
- **Override** — your own Yes, No or N/A for a ray-tracing chip. The measured value is kept, and yours is marked as
yours.
+8 -7
View File
@@ -11,7 +11,7 @@
that changes what FrameLedger.Overlay or the capture host does; date the change.
HTML comments are not part of the block.
-->
> ⚠ **What FrameLedger actually measures today — 2026-10-13.** The software is a beta; its latest
> ⚠ **What FrameLedger actually measures today — 2026-10-19.** The software is a beta; its latest
> **pre-release is `0.1.0-beta.23`** (2026-10-14), an unsigned installer built from that tag with its
> checksums published beside it. The source holds the desktop app
> (library, store import, charts, settings) and the background Agent, which records a session when a
@@ -50,12 +50,13 @@
> (menus, loading screens, a settings change), no session-wide factor is shown: the factor, Native and
> Displayed are those of the state that held longest — five-second windows whose ratios agree within
> 10 %, covering at least 10 s and 10 % of the time the game was presenting — and are always shown with
> the share of the session they cover; with no such state, the reason is shown instead. DLSS-G and FSR
> FG are named from the calls the game makes; any other generator (XeSS-FG, one compiled into the game)
> is shown only as active with the technology not identified, and is never named. Where a technology is
> named but its frames could not be counted, or frame generation is not measured, the software shows
> **Presented FPS** with a note on what it may include — never a Native figure. Where generated frames
> were counted, the lows, median and stutter are taken over application frames only.
> the share of the session they cover; with no such state, the reason is shown instead. The session
> summary lists each state it held, with its share of the time and its own Native → Displayed rates.
> DLSS-G and FSR FG are named from the calls the game makes; any other generator (XeSS-FG, one compiled
> into the game) is shown only as active with the technology not identified, and is never named. Where a
> technology is named but its frames could not be counted, or frame generation is not measured, the
> software shows **Presented FPS** with a note on what it may include — never a Native figure. Where generated
> frames were counted, the lows, median and stutter are taken over application frames only.
> - **Ray tracing:** Yes/No measured on Direct3D 12 from ray-dispatch and acceleration-structure-build
> calls; the technique and path tracing are `N/A`, and so is ray tracing on other APIs.
> - **Display mode:** how each game's window was shown — exclusive full-screen, borderless, windowed or
+8 -7
View File
@@ -113,7 +113,7 @@ Software running inside another process can, in principle, destabilize it. Frame
Frame timing is derived from high-resolution timestamps taken at the moment the game presents each frame; upscaling, frame-generation and ray-tracing state are read from the parameters the game passes to those APIs. This is substantially more accurate than inferring settings from files on disk, but **no measurement is guaranteed to be exact**:
<!-- accuracy-block:begin -->
> ⚠ **What FrameLedger actually measures today — 2026-10-13.** The software is a beta; its latest
> ⚠ **What FrameLedger actually measures today — 2026-10-19.** The software is a beta; its latest
> **pre-release is `0.1.0-beta.23`** (2026-10-14), an unsigned installer built from that tag with its
> checksums published beside it. The source holds the desktop app
> (library, store import, charts, settings) and the background Agent, which records a session when a
@@ -152,12 +152,13 @@ Frame timing is derived from high-resolution timestamps taken at the moment the
> (menus, loading screens, a settings change), no session-wide factor is shown: the factor, Native and
> Displayed are those of the state that held longest — five-second windows whose ratios agree within
> 10 %, covering at least 10 s and 10 % of the time the game was presenting — and are always shown with
> the share of the session they cover; with no such state, the reason is shown instead. DLSS-G and FSR
> FG are named from the calls the game makes; any other generator (XeSS-FG, one compiled into the game)
> is shown only as active with the technology not identified, and is never named. Where a technology is
> named but its frames could not be counted, or frame generation is not measured, the software shows
> **Presented FPS** with a note on what it may include — never a Native figure. Where generated frames
> were counted, the lows, median and stutter are taken over application frames only.
> the share of the session they cover; with no such state, the reason is shown instead. The session
> summary lists each state it held, with its share of the time and its own Native → Displayed rates.
> DLSS-G and FSR FG are named from the calls the game makes; any other generator (XeSS-FG, one compiled
> into the game) is shown only as active with the technology not identified, and is never named. Where a
> technology is named but its frames could not be counted, or frame generation is not measured, the
> software shows **Presented FPS** with a note on what it may include — never a Native figure. Where generated
> frames were counted, the lows, median and stutter are taken over application frames only.
> - **Ray tracing:** Yes/No measured on Direct3D 12 from ray-dispatch and acceleration-structure-build
> calls; the technique and path tracing are `N/A`, and so is ray tracing on other APIs.
> - **Display mode:** how each game's window was shown — exclusive full-screen, borderless, windowed or
+28 -3
View File
@@ -2,6 +2,7 @@
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Windows;
using FrameLedger.Domain.Metrics;
using ScottPlot;
using Wpf.Ui.Appearance;
@@ -26,14 +27,16 @@ public sealed record ChartPalette(
Color Segment,
Color Histogram,
Color Percentile,
Color SensorTertiary)
Color SensorTertiary,
Color MixNone,
Color MixUnclassified)
{
/// <summary>The keys both dictionaries must carry, in the record's order.</summary>
public static readonly IReadOnlyList<string> Keys =
[
"Chart_Figure", "Chart_Data", "Chart_Axis", "Chart_Grid", "Chart_Native", "Chart_Displayed", "Chart_Stutter",
"Chart_StutterPso", "Chart_Sensor", "Chart_SensorSecondary", "Chart_Segment", "Chart_Histogram", "Chart_Percentile",
"Chart_SensorTertiary",
"Chart_SensorTertiary", "Chart_MixNone", "Chart_MixUnclassified",
];
private static readonly Dictionary<ApplicationTheme, ChartPalette> _cache = [];
@@ -59,7 +62,7 @@ public sealed record ChartPalette(
{
ArgumentNullException.ThrowIfNull(dictionary);
Color[] c = [.. Keys.Select(k => Convert(dictionary, k))];
return new ChartPalette(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10], c[11], c[12], c[13]);
return new ChartPalette(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10], c[11], c[12], c[13], c[14], c[15]);
}
/// <summary>The colour a key names — how a chart that assigns palette entries to series by name reads them (<c>SensorsChart</c>).</summary>
@@ -79,9 +82,31 @@ public sealed record ChartPalette(
"Chart_Histogram" => Histogram,
"Chart_Percentile" => Percentile,
"Chart_SensorTertiary" => SensorTertiary,
"Chart_MixNone" => MixNone,
"Chart_MixUnclassified" => MixUnclassified,
_ => throw new ArgumentOutOfRangeException(nameof(key), key, "not a chart palette key"),
};
/// <summary>
/// The fill of a frame-generation mix segment (beta.24, D62): a state by its multiplier, so ×4 reads the same colour in
/// every session — the series colours, never the stutter reds —, and no frame generation and the time no state claims
/// each a colour of their own.
/// </summary>
public Color MixFill(FgMixKind kind, double? factor) => kind switch
{
FgMixKind.None => MixNone,
FgMixKind.Unclassified => MixUnclassified,
_ => (int)Math.Round(factor ?? 0, MidpointRounding.AwayFromZero) switch
{
<= 2 => Native,
3 => Sensor,
4 => Displayed,
5 => SensorSecondary,
6 => Percentile,
_ => SensorTertiary,
},
};
private static ChartPalette Load(ApplicationTheme theme)
{
string file = theme == ApplicationTheme.Light ? "ChartPalette.Light.xaml" : "ChartPalette.Dark.xaml";
+110
View File
@@ -0,0 +1,110 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Media;
using FrameLedger.App.Charts;
using FrameLedger.App.Services;
using Wpf.Ui.Appearance;
namespace FrameLedger.App.Controls;
/// <summary>
/// The frame-generation mix as one bar (beta.24, owner decision D62): each segment a row's share of the session's presenting
/// time, in the chart palette's colours (<see cref="ChartPalette.MixFill"/>). It says nothing the table beside it does not —
/// every number is there, in text — and is announced by its <c>AutomationProperties.Name</c>.
/// </summary>
/// <remarks>
/// It follows a theme switch the way <see cref="ArtTint"/> does: a resource reference to <c>ApplicationBackgroundColor</c>, whose
/// change redraws it and whose luminance picks the palette — never <c>ApplicationThemeManager.Changed</c>, which only
/// <c>ApplicationThemeManager.Apply</c> raises. No colour is written in XAML (<c>08_UI</c> §Accessibility).
/// </remarks>
public sealed class FgMixBar : FrameworkElement
{
public static readonly DependencyProperty SegmentsProperty = DependencyProperty.Register(
nameof(Segments), typeof(IReadOnlyList<FgMixSegment>), typeof(FgMixBar),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
/// <summary>The space between two segments, so neighbours of near colours — or any two in high contrast — still read as two.</summary>
internal const double Gap = 2;
// The theme, heard through a resource reference (ArtTint's way).
private static readonly DependencyProperty _themeProperty = DependencyProperty.Register(
"Theme", typeof(object), typeof(FgMixBar), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public FgMixBar()
{
SetResourceReference(_themeProperty, "ApplicationBackgroundColor");
SnapsToDevicePixels = true;
}
public IReadOnlyList<FgMixSegment>? Segments
{
get => (IReadOnlyList<FgMixSegment>?)GetValue(SegmentsProperty);
set => SetValue(SegmentsProperty, value);
}
/// <summary>
/// Each segment's rectangle in a bar <paramref name="width"/> by <paramref name="height"/>: widths in proportion to the
/// shares, a <see cref="Gap"/> between two drawn segments; an empty rectangle (zero width) for a share of nothing.
/// </summary>
internal static IReadOnlyList<Rect> Layout(IReadOnlyList<FgMixSegment> segments, double width, double height)
{
ArgumentNullException.ThrowIfNull(segments);
var rects = new Rect[segments.Count];
double total = segments.Sum(static s => Math.Max(0, s.Share));
if (total <= 0 || width <= 0 || height <= 0)
{
return rects;
}
int drawn = segments.Count(static s => s.Share > 0);
double usable = Math.Max(0, width - (Gap * (drawn - 1)));
double x = 0;
for (int i = 0; i < segments.Count; i++)
{
double w = usable * Math.Max(0, segments[i].Share) / total;
if (w <= 0)
{
continue;
}
rects[i] = new Rect(x, 0, w, height);
x += w + Gap;
}
return rects;
}
/// <summary>The palette for the theme the element's resources hold now; the applied theme's when none is reachable.</summary>
internal ChartPalette Palette() => GetValue(_themeProperty) is Color background
? ChartPalette.For(ColorMath.Luminance(background) < 0.5 ? ApplicationTheme.Dark : ApplicationTheme.Light)
: ChartTheme.Current;
protected override void OnRender(DrawingContext drawingContext)
{
ArgumentNullException.ThrowIfNull(drawingContext);
if (Segments is not { Count: > 0 } segments)
{
return;
}
ChartPalette palette = Palette();
IReadOnlyList<Rect> rects = Layout(segments, ActualWidth, ActualHeight);
for (int i = 0; i < rects.Count; i++)
{
if (rects[i].Width <= 0)
{
continue;
}
ScottPlot.Color fill = palette.MixFill(segments[i].Kind, segments[i].Factor);
var brush = new SolidColorBrush(Color.FromArgb(fill.A, fill.R, fill.G, fill.B));
brush.Freeze();
drawingContext.DrawRoundedRectangle(brush, null, rects[i], 2, 2);
}
}
protected override AutomationPeer OnCreateAutomationPeer() => new FrameworkElementAutomationPeer(this);
}
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using FrameLedger.Domain.Metrics;
namespace FrameLedger.App.Controls;
/// <summary>One segment of <see cref="FgMixBar"/> (beta.24, D62): a row of the stored mix, as its kind, factor and share.</summary>
/// <param name="Kind">A state, no frame generation, or the time no state claims.</param>
/// <param name="Factor">A state's factor, which picks its colour; null otherwise.</param>
/// <param name="Share">Its share of the session's presenting time (0..1); the bar draws the segments in proportion.</param>
public sealed record FgMixSegment(FgMixKind Kind, double? Factor, double Share);
@@ -0,0 +1,110 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using FrameLedger.App.Controls;
using FrameLedger.App.ViewModels;
using FrameLedger.Application.Persistence;
using FrameLedger.Application.Recording;
using FrameLedger.Domain.Metrics;
using FrameLedger.Domain.Sessions;
namespace FrameLedger.App.Services;
/// <summary>
/// The session summary's "Frame generation in this session" block (beta.24, owner decision D62; <c>08_UI</c> §Session
/// summary): <c>sessions.fg_mix</c> as rows — each state with its factor, its own Native → Displayed and its share of the
/// presenting time, then the time with no frame generation, then the time no state claims — and the bar those shares draw.
/// Never an average across states (CLAUDE.md rule 6); the stored rows are read, never recomputed.
/// </summary>
[SuppressMessage("Performance", "CA1863:Use 'CompositeFormat'", Justification = "the format strings are resources that follow the UI culture, which changes at runtime")]
public static class FgMixPresentation
{
private static readonly CultureInfo _inv = CultureInfo.InvariantCulture;
/// <summary>
/// The block's rows in the stored order; empty when the session stored no mix, or one row only — a session in one state
/// throughout says so in its readout, and a bar of one colour would add nothing.
/// </summary>
public static IReadOnlyList<FgMixRowModel> Rows(SessionRow row)
{
ArgumentNullException.ThrowIfNull(row);
FgMixRecord? mix = row.Tier == CaptureTier.Hooked ? FgMixRecord.Parse(row.FgMixJson) : null;
return mix is null || mix.Rows.Count < 2 ? [] : [.. mix.Rows.Select(Row)];
}
/// <summary>One stored row in the user's words.</summary>
public static FgMixRowModel Row(FgMixRecordRow stored)
{
ArgumentNullException.ThrowIfNull(stored);
FgMixKind kind = FgMixRecordRow.KindOf(stored.Kind);
double? factor = kind == FgMixKind.Generated ? stored.Factor : null;
if (kind == FgMixKind.Generated && factor is null)
{
// A state always carries its factor; one that does not is read as what it then is — time no state explains.
kind = FgMixKind.Unclassified;
}
string label = kind switch
{
FgMixKind.Generated => string.Format(CultureInfo.CurrentCulture, Strings.FgMix_State_Format, factor),
FgMixKind.None => Strings.FgMix_None,
_ => Strings.FgMix_Unclassified,
};
string rates = kind switch
{
FgMixKind.Generated => string.Format(CultureInfo.CurrentCulture, Strings.FgMix_Rates_Format, Formats.Fps(stored.NativeFps), Formats.Fps(stored.DisplayedFps)),
FgMixKind.None => string.Format(CultureInfo.CurrentCulture, Strings.FgMix_Rate_Format, Formats.Fps(stored.NativeFps)),
_ => string.Empty,
};
return new FgMixRowModel(label, ShareText(stored.Share), rates, Formats.Duration(stored.Seconds), new FgMixSegment(kind, factor, stored.Share));
}
/// <summary>A share (0..1) to two decimals, <c>35.33%</c>; a share too small to show at that precision reads <c>&lt;0.01%</c>, never 0.</summary>
public static string ShareText(double share) => share switch
{
<= 0 => 0d.ToString("0.00", CultureInfo.CurrentCulture) + "%",
< 0.00005 => "<" + 0.01.ToString("0.00", CultureInfo.CurrentCulture) + "%",
_ => (share * 100).ToString("0.00", CultureInfo.CurrentCulture) + "%",
};
/// <summary>The bar's spoken name: every row with its share, in the table's order.</summary>
public static string AccessibleName(IReadOnlyList<FgMixRowModel> rows)
{
ArgumentNullException.ThrowIfNull(rows);
return string.Format(CultureInfo.CurrentCulture, Strings.FgMix_Bar_Name_Format, string.Join(", ", rows.Select(static r => r.Label + " " + r.Share)));
}
/// <summary>
/// Why a session that counted frame generation shows no mix: only where one could have been stored — a counted factor,
/// or a count refused only because the state changed —, so the sentence is about the session, not about refusals the
/// readout already names. Null otherwise.
/// </summary>
public static string? Missing(SessionRow row)
{
ArgumentNullException.ThrowIfNull(row);
bool couldHaveOne = row.Tier == CaptureTier.Hooked
&& row.FgMode is { Length: > 0 } mode && mode is not ("na" or "none")
&& (row.FgFactor is not null || row.FgRefusal is "non_uniform" or "ambiguous_band");
return couldHaveOne && FgMixRecord.Parse(row.FgMixJson) is null ? Strings.FgMix_NotStored : null;
}
/// <summary>
/// The CSV header's line (<c>03_METRICS</c> §Export schema), InvariantCulture: each row's kind, factor, share, rates and
/// seconds; <c>N/A</c> for a session with no stored mix.
/// </summary>
public static string ExportLine(SessionRow row)
{
ArgumentNullException.ThrowIfNull(row);
FgMixRecord? mix = FgMixRecord.Parse(row.FgMixJson);
return mix is null || mix.Rows.Count == 0
? "N/A"
: string.Join("; ", mix.Rows.Select(static r => r.Kind
+ (r.Factor is double f ? " x" + f.ToString("0.00", _inv) : string.Empty)
+ " " + (r.Share * 100).ToString("0.00", _inv) + "%"
+ (r.NativeFps is double n ? " native " + n.ToString("0.0", _inv) : string.Empty)
+ (r.DisplayedFps is double d ? " displayed " + d.ToString("0.0", _inv) : string.Empty)
+ " " + r.Seconds.ToString("0.0", _inv) + " s"));
}
}
@@ -74,8 +74,9 @@ public static class FpsPresentation
return m.Kind switch
{
// A steady-state factor carries its share in the grid too (rule 6; beta.8 — the column was the one place it did not).
FpsReadoutKind.Generated when m.Factor is double f && m.SteadyShare is double share => string.Format(CultureInfo.CurrentCulture, "×{0:0.0} · {1:0}%", f, share * 100),
FpsReadoutKind.Generated when m.Factor is double f => string.Format(CultureInfo.CurrentCulture, "×{0:0.0}", f),
// The formats are resources since beta.24, like every other text the column shows.
FpsReadoutKind.Generated when m.Factor is double f && m.SteadyShare is double share => string.Format(CultureInfo.CurrentCulture, Strings.Fps_Fg_Column_Steady_Format, f, share * 100),
FpsReadoutKind.Generated when m.Factor is double f => string.Format(CultureInfo.CurrentCulture, Strings.Fps_Fg_Column_Format, f),
FpsReadoutKind.None => Strings.Common_Dash,
_ => Strings.Common_NotAvailable,
};
@@ -96,6 +96,62 @@ public static class NvidiaOverrides
return parts;
}
/// <summary>
/// The frame-generation block's context line (beta.24, D62): how frame generation was set for the game, in the NVIDIA
/// App's own terms (its Frame Generation Mode dialog — Dynamic with its multiplier ceiling and target, Fixed with its
/// multiplier), or that the profile sets none — the game's own menu decided. Configuration, never a measurement: the
/// rows beneath it are what was counted. Null when no profile was read (no NVIDIA driver, a row from before beta.8).
/// </summary>
/// <remarks>
/// The dynamic ceiling (<c>NGX_DLSSG_DYNAMIC_MULTI_FRAME_COUNT_MAX</c>) is decoded as <c>NGX_DLSSG_MULTI_FRAME_COUNT</c> is —
/// frames generated per rendered frame, so 5 is "up to ×6" — and the automatic target as the App's "Max refresh rate";
/// NVIDIA's header names neither, and owner-only item 20(a) checks both against the App's own words. A value outside the
/// header's ranges is left out, never guessed.
/// </remarks>
public static string? FrameGenerationContext(string? driverProfileJson)
{
DriverProfileRecord? profile = DriverProfileRecord.Parse(driverProfileJson);
if (profile is null || !IsRead(profile))
{
return null;
}
string? set = FrameGenerationSetting(profile);
if (set is null)
{
return Strings.FgMix_Context_Game;
}
// A value the driver ships in its own profile for the game is not one the user chose in the App.
bool shipped = new[] { S.DlssgMode, S.DlssgMultiFrameCount, S.DlssgDynamicMultiFrameCountMax, S.DlssgDynamicTargetFrameRate }
.Select(profile.SettingOf).Where(static s => s?.Value is > 0).All(static s => s!.Predefined);
return string.Format(CultureInfo.CurrentCulture, shipped ? Strings.FgMix_Context_Driver_Format : Strings.FgMix_Context_App_Format, set);
}
private static string? FrameGenerationSetting(DriverProfileRecord profile)
{
string? multiplier = Multiplier(profile.ValueOf(S.DlssgMultiFrameCount));
string? fixedCount = multiplier is null ? null : string.Format(CultureInfo.CurrentCulture, Strings.FgMix_Context_Fixed_Format, multiplier);
return profile.ValueOf(S.DlssgMode) switch
{
4 => string.Join(", ", new[]
{
Strings.FgMix_Context_Dynamic,
Multiplier(profile.ValueOf(S.DlssgDynamicMultiFrameCountMax)) is { } ceiling ? string.Format(CultureInfo.CurrentCulture, Strings.FgMix_Context_UpTo_Format, ceiling) : null,
profile.ValueOf(S.DlssgDynamicTargetFrameRate) switch
{
S.DynamicTargetAuto => Strings.FgMix_Context_Target_Auto,
uint fps and > 0 and < S.DynamicTargetAuto => string.Format(CultureInfo.CurrentCulture, Strings.FgMix_Context_Target_Format, fps),
_ => null,
},
}.Where(static p => p is not null)),
1 => Strings.FgMix_Context_Off,
2 => fixedCount ?? Strings.FgMix_Context_On,
3 => multiplier is null ? Strings.FgMix_Context_Auto : Strings.FgMix_Context_Auto + ", " + multiplier,
_ => fixedCount,
};
}
/// <summary>
/// The session summary's line for the driver's own report on the game's process (<c>NvAPI_NGX_GetNGXOverrideState</c>):
/// what its override bits say it applied. Null when it answered nothing, or reported no override.
@@ -120,6 +120,8 @@ public sealed class SessionExporter
w.WriteLine("# hardware: " + (hardware is null ? "N/A" : string.Join("; ", new[] { hardware.CpuName, hardware.GpuName, hardware.GpuDriver, hardware.OsBuild, hardware.DisplayRes }.Where(static s => !string.IsNullOrEmpty(s)))));
w.WriteLine("# rt: " + row.RtFlag + " (" + (row.RtSource ?? "n/a") + "); pt: " + row.PtFlag + " (" + (row.PtSource ?? "n/a") + "); rr: " + row.RrFlag + " (" + (row.RrSource ?? "n/a") + ")");
w.WriteLine("# fg_mode: " + row.FgMode + "; fg_source: " + (row.FgSource ?? "n/a") + "; presented_qualifier: " + (row.PresentedQualifier ?? "n/a"));
// beta.24 (D62): every frame-generation state the session held, each with its share and its own rates: the session's, not a frame's.
w.WriteLine("# fg_mix: " + FgMixPresentation.ExportLine(row));
foreach (SegmentRow s in segments)
{
w.WriteLine("# segment: frames " + s.StartFrame.ToString(_inv) + "-" + s.EndFrame.ToString(_inv) + "; " + (s.Upscaler ?? "n/a") + " " + (s.UpscalerQuality ?? string.Empty) + "; " + (s.RenderW?.ToString(_inv) ?? "?") + "x" + (s.RenderH?.ToString(_inv) ?? "?") + " -> " + (s.OutputW?.ToString(_inv) ?? "?") + "x" + (s.OutputH?.ToString(_inv) ?? "?") + "; fg " + (s.FgMode ?? "n/a"));
+78
View File
@@ -375,6 +375,30 @@ public static class Strings
nameof(Fg_RefusalDetail_Records_Format),
nameof(Fg_RefusalDetail_TooShort_Format),
nameof(Fg_Unknown),
nameof(FgMix_Bar_Name_Format),
nameof(FgMix_Col_Rates),
nameof(FgMix_Col_Share),
nameof(FgMix_Col_State),
nameof(FgMix_Col_Time),
nameof(FgMix_Context_App_Format),
nameof(FgMix_Context_Auto),
nameof(FgMix_Context_Driver_Format),
nameof(FgMix_Context_Dynamic),
nameof(FgMix_Context_Fixed_Format),
nameof(FgMix_Context_Game),
nameof(FgMix_Context_Off),
nameof(FgMix_Context_On),
nameof(FgMix_Context_Target_Auto),
nameof(FgMix_Context_Target_Format),
nameof(FgMix_Context_UpTo_Format),
nameof(FgMix_Header),
nameof(FgMix_None),
nameof(FgMix_NotStored),
nameof(FgMix_Rate_Format),
nameof(FgMix_Rates_Format),
nameof(FgMix_State_Format),
nameof(FgMix_Unclassified),
nameof(FgMix_Unclassified_Note),
nameof(FirstRun_Accept),
nameof(FirstRun_Agent_Body),
nameof(FirstRun_Agent_Header),
@@ -427,6 +451,8 @@ public static class Strings
nameof(Fps_Census_Withheld_Tooltip),
nameof(Fps_Fg_Chip_Format),
nameof(Fps_Fg_Chip_Steady_Format),
nameof(Fps_Fg_Column_Format),
nameof(Fps_Fg_Column_Steady_Format),
nameof(Fps_Fg_Format),
nameof(Fps_Fg_Identified_Format),
nameof(Fps_Fg_Identified_Tooltip_Format),
@@ -1812,6 +1838,54 @@ public static class Strings
public static string Fg_Unknown => ResourceManager.GetString(nameof(Fg_Unknown), Culture) ?? nameof(Fg_Unknown);
public static string FgMix_Bar_Name_Format => ResourceManager.GetString(nameof(FgMix_Bar_Name_Format), Culture) ?? nameof(FgMix_Bar_Name_Format);
public static string FgMix_Col_Rates => ResourceManager.GetString(nameof(FgMix_Col_Rates), Culture) ?? nameof(FgMix_Col_Rates);
public static string FgMix_Col_Share => ResourceManager.GetString(nameof(FgMix_Col_Share), Culture) ?? nameof(FgMix_Col_Share);
public static string FgMix_Col_State => ResourceManager.GetString(nameof(FgMix_Col_State), Culture) ?? nameof(FgMix_Col_State);
public static string FgMix_Col_Time => ResourceManager.GetString(nameof(FgMix_Col_Time), Culture) ?? nameof(FgMix_Col_Time);
public static string FgMix_Context_App_Format => ResourceManager.GetString(nameof(FgMix_Context_App_Format), Culture) ?? nameof(FgMix_Context_App_Format);
public static string FgMix_Context_Auto => ResourceManager.GetString(nameof(FgMix_Context_Auto), Culture) ?? nameof(FgMix_Context_Auto);
public static string FgMix_Context_Driver_Format => ResourceManager.GetString(nameof(FgMix_Context_Driver_Format), Culture) ?? nameof(FgMix_Context_Driver_Format);
public static string FgMix_Context_Dynamic => ResourceManager.GetString(nameof(FgMix_Context_Dynamic), Culture) ?? nameof(FgMix_Context_Dynamic);
public static string FgMix_Context_Fixed_Format => ResourceManager.GetString(nameof(FgMix_Context_Fixed_Format), Culture) ?? nameof(FgMix_Context_Fixed_Format);
public static string FgMix_Context_Game => ResourceManager.GetString(nameof(FgMix_Context_Game), Culture) ?? nameof(FgMix_Context_Game);
public static string FgMix_Context_Off => ResourceManager.GetString(nameof(FgMix_Context_Off), Culture) ?? nameof(FgMix_Context_Off);
public static string FgMix_Context_On => ResourceManager.GetString(nameof(FgMix_Context_On), Culture) ?? nameof(FgMix_Context_On);
public static string FgMix_Context_Target_Auto => ResourceManager.GetString(nameof(FgMix_Context_Target_Auto), Culture) ?? nameof(FgMix_Context_Target_Auto);
public static string FgMix_Context_Target_Format => ResourceManager.GetString(nameof(FgMix_Context_Target_Format), Culture) ?? nameof(FgMix_Context_Target_Format);
public static string FgMix_Context_UpTo_Format => ResourceManager.GetString(nameof(FgMix_Context_UpTo_Format), Culture) ?? nameof(FgMix_Context_UpTo_Format);
public static string FgMix_Header => ResourceManager.GetString(nameof(FgMix_Header), Culture) ?? nameof(FgMix_Header);
public static string FgMix_None => ResourceManager.GetString(nameof(FgMix_None), Culture) ?? nameof(FgMix_None);
public static string FgMix_NotStored => ResourceManager.GetString(nameof(FgMix_NotStored), Culture) ?? nameof(FgMix_NotStored);
public static string FgMix_Rate_Format => ResourceManager.GetString(nameof(FgMix_Rate_Format), Culture) ?? nameof(FgMix_Rate_Format);
public static string FgMix_Rates_Format => ResourceManager.GetString(nameof(FgMix_Rates_Format), Culture) ?? nameof(FgMix_Rates_Format);
public static string FgMix_State_Format => ResourceManager.GetString(nameof(FgMix_State_Format), Culture) ?? nameof(FgMix_State_Format);
public static string FgMix_Unclassified => ResourceManager.GetString(nameof(FgMix_Unclassified), Culture) ?? nameof(FgMix_Unclassified);
public static string FgMix_Unclassified_Note => ResourceManager.GetString(nameof(FgMix_Unclassified_Note), Culture) ?? nameof(FgMix_Unclassified_Note);
public static string FirstRun_Accept => ResourceManager.GetString(nameof(FirstRun_Accept), Culture) ?? nameof(FirstRun_Accept);
public static string FirstRun_Agent_Body => ResourceManager.GetString(nameof(FirstRun_Agent_Body), Culture) ?? nameof(FirstRun_Agent_Body);
@@ -1916,6 +1990,10 @@ public static class Strings
public static string Fps_Fg_Chip_Steady_Format => ResourceManager.GetString(nameof(Fps_Fg_Chip_Steady_Format), Culture) ?? nameof(Fps_Fg_Chip_Steady_Format);
public static string Fps_Fg_Column_Format => ResourceManager.GetString(nameof(Fps_Fg_Column_Format), Culture) ?? nameof(Fps_Fg_Column_Format);
public static string Fps_Fg_Column_Steady_Format => ResourceManager.GetString(nameof(Fps_Fg_Column_Steady_Format), Culture) ?? nameof(Fps_Fg_Column_Steady_Format);
public static string Fps_Fg_Format => ResourceManager.GetString(nameof(Fps_Fg_Format), Culture) ?? nameof(Fps_Fg_Format);
public static string Fps_Fg_Identified_Format => ResourceManager.GetString(nameof(Fps_Fg_Identified_Format), Culture) ?? nameof(Fps_Fg_Identified_Format);
+105 -1
View File
@@ -3122,7 +3122,7 @@
<comment>review</comment>
</data>
<data name="Nv_DynamicTarget_Auto" xml:space="preserve">
<value>動的ターゲットは自動</value>
<value>動的ターゲット: 最大リフレッシュレート</value>
<comment>review</comment>
</data>
<data name="Nv_Driver_Format" xml:space="preserve">
@@ -4389,4 +4389,108 @@
<value>画像 (*.png;*.jpg;*.jpeg;*.bmp;*.webp)|*.png;*.jpg;*.jpeg;*.bmp;*.webp</value>
<comment>review</comment>
</data>
<data name="FgMix_Header" xml:space="preserve">
<value>このセッションのフレーム生成</value>
<comment>review</comment>
</data>
<data name="FgMix_Col_State" xml:space="preserve">
<value>状態</value>
<comment>review</comment>
</data>
<data name="FgMix_Col_Share" xml:space="preserve">
<value>時間の割合</value>
<comment>review</comment>
</data>
<data name="FgMix_Col_Rates" xml:space="preserve">
<value>ネイティブ → 表示</value>
<comment>review</comment>
</data>
<data name="FgMix_Col_Time" xml:space="preserve">
<value>時間</value>
<comment>review</comment>
</data>
<data name="FgMix_State_Format" xml:space="preserve">
<value>フレーム生成 ×{0:0.0}</value>
<comment>review</comment>
</data>
<data name="FgMix_None" xml:space="preserve">
<value>フレーム生成なし</value>
<comment>review</comment>
</data>
<data name="FgMix_Unclassified" xml:space="preserve">
<value>分類なし</value>
<comment>review</comment>
</data>
<data name="FgMix_Rates_Format" xml:space="preserve">
<value>{0} → {1} FPS</value>
<comment>review</comment>
</data>
<data name="FgMix_Rate_Format" xml:space="preserve">
<value>{0} FPS</value>
<comment>review</comment>
</data>
<data name="FgMix_Bar_Name_Format" xml:space="preserve">
<value>フレーム生成の状態ごとのセッション時間の割合: {0}</value>
<comment>review</comment>
</data>
<data name="FgMix_Unclassified_Note" xml:space="preserve">
<value>分類なし: 10 秒以上続いたどの状態にも属さない時間 — 切り替えや読み込み、読み取りに使う 5 秒の区間より速く変わった倍率、または読み取るにはフレームが少なすぎる区間です。</value>
<comment>review</comment>
</data>
<data name="FgMix_NotStored" xml:space="preserve">
<value>フレーム生成の状態の内訳は、0.1.0-beta.24 以降で記録し、ある状態が 10 秒以上続いたセッションに保存されます。</value>
<comment>review</comment>
</data>
<data name="FgMix_Context_App_Format" xml:space="preserve">
<value>NVIDIA App で設定: {0}</value>
<comment>review</comment>
</data>
<data name="FgMix_Context_Driver_Format" xml:space="preserve">
<value>NVIDIA ドライバー独自のゲーム用プロファイルで設定: {0}</value>
<comment>review</comment>
</data>
<data name="FgMix_Context_Game" xml:space="preserve">
<value>ゲーム内で設定 — NVIDIA App によるフレーム生成の上書きなし</value>
<comment>review</comment>
</data>
<data name="FgMix_Context_Dynamic" xml:space="preserve">
<value>Dynamic(動的)</value>
<comment>review</comment>
</data>
<data name="FgMix_Context_Fixed_Format" xml:space="preserve">
<value>Fixed(固定){0}</value>
<comment>review</comment>
</data>
<data name="FgMix_Context_UpTo_Format" xml:space="preserve">
<value>最大 {0}</value>
<comment>review</comment>
</data>
<data name="FgMix_Context_Target_Auto" xml:space="preserve">
<value>目標: 最大リフレッシュレート</value>
<comment>review</comment>
</data>
<data name="FgMix_Context_Target_Format" xml:space="preserve">
<value>目標 {0} FPS</value>
<comment>review</comment>
</data>
<data name="FgMix_Context_Off" xml:space="preserve">
<value>フレーム生成オフ</value>
<comment>review</comment>
</data>
<data name="FgMix_Context_On" xml:space="preserve">
<value>フレーム生成オン</value>
<comment>review</comment>
</data>
<data name="FgMix_Context_Auto" xml:space="preserve">
<value>自動</value>
<comment>review</comment>
</data>
<data name="Fps_Fg_Column_Format" xml:space="preserve">
<value>×{0:0.0}</value>
<comment>review</comment>
</data>
<data name="Fps_Fg_Column_Steady_Format" xml:space="preserve">
<value>×{0:0.0} · {1:0}%</value>
<comment>review</comment>
</data>
</root>
+79 -1
View File
@@ -2352,7 +2352,7 @@ The documents below are the full terms; this summary does not replace them.</val
<value>dynamic target {0} FPS</value>
</data>
<data name="Nv_DynamicTarget_Auto" xml:space="preserve">
<value>dynamic target automatic</value>
<value>dynamic target: max refresh rate</value>
</data>
<data name="Nv_Driver_Format" xml:space="preserve">
<value>NVIDIA driver, for this game's process: {0}</value>
@@ -3302,4 +3302,82 @@ The documents below are the full terms; this summary does not replace them.</val
<data name="ImagePicker_Filter" xml:space="preserve">
<value>Images (*.png;*.jpg;*.jpeg;*.bmp;*.webp)|*.png;*.jpg;*.jpeg;*.bmp;*.webp</value>
</data>
<data name="FgMix_Header" xml:space="preserve">
<value>Frame generation in this session</value>
</data>
<data name="FgMix_Col_State" xml:space="preserve">
<value>State</value>
</data>
<data name="FgMix_Col_Share" xml:space="preserve">
<value>Share of the time</value>
</data>
<data name="FgMix_Col_Rates" xml:space="preserve">
<value>Native → Displayed</value>
</data>
<data name="FgMix_Col_Time" xml:space="preserve">
<value>Time</value>
</data>
<data name="FgMix_State_Format" xml:space="preserve">
<value>×{0:0.0} frame generation</value>
</data>
<data name="FgMix_None" xml:space="preserve">
<value>No frame generation</value>
</data>
<data name="FgMix_Unclassified" xml:space="preserve">
<value>Not classified</value>
</data>
<data name="FgMix_Rates_Format" xml:space="preserve">
<value>{0} → {1} FPS</value>
</data>
<data name="FgMix_Rate_Format" xml:space="preserve">
<value>{0} FPS</value>
</data>
<data name="FgMix_Bar_Name_Format" xml:space="preserve">
<value>Share of the session's time by frame-generation state: {0}</value>
</data>
<data name="FgMix_Unclassified_Note" xml:space="preserve">
<value>Not classified: time in no state that held for at least 10 seconds — switching, loading, a factor that changed faster than the five-second windows it is read over, or windows with too few frames to read.</value>
</data>
<data name="FgMix_NotStored" xml:space="preserve">
<value>The mix of frame-generation states is stored for sessions recorded with 0.1.0-beta.24 or later, when a state held for at least 10 seconds.</value>
</data>
<data name="FgMix_Context_App_Format" xml:space="preserve">
<value>Set in the NVIDIA App: {0}</value>
</data>
<data name="FgMix_Context_Driver_Format" xml:space="preserve">
<value>Set by the NVIDIA driver's own profile for the game: {0}</value>
</data>
<data name="FgMix_Context_Game" xml:space="preserve">
<value>Set in the game — no NVIDIA App frame-generation override</value>
</data>
<data name="FgMix_Context_Dynamic" xml:space="preserve">
<value>Dynamic</value>
</data>
<data name="FgMix_Context_Fixed_Format" xml:space="preserve">
<value>Fixed {0}</value>
</data>
<data name="FgMix_Context_UpTo_Format" xml:space="preserve">
<value>up to {0}</value>
</data>
<data name="FgMix_Context_Target_Auto" xml:space="preserve">
<value>target: max refresh rate</value>
</data>
<data name="FgMix_Context_Target_Format" xml:space="preserve">
<value>target {0} FPS</value>
</data>
<data name="FgMix_Context_Off" xml:space="preserve">
<value>frame generation off</value>
</data>
<data name="FgMix_Context_On" xml:space="preserve">
<value>frame generation on</value>
</data>
<data name="FgMix_Context_Auto" xml:space="preserve">
<value>automatic</value>
</data>
<data name="Fps_Fg_Column_Format" xml:space="preserve">
<value>×{0:0.0}</value>
</data>
<data name="Fps_Fg_Column_Steady_Format" xml:space="preserve">
<value>×{0:0.0} · {1:0}%</value>
</data>
</root>
+79 -1
View File
@@ -2347,7 +2347,7 @@ Các văn bản bên dưới là điều khoản đầy đủ; bản tóm tắt
<value>mục tiêu động {0} FPS</value>
</data>
<data name="Nv_DynamicTarget_Auto" xml:space="preserve">
<value>mục tiêu động tự động</value>
<value>mục tiêu động: tần số quét tối đa</value>
</data>
<data name="Nv_Driver_Format" xml:space="preserve">
<value>Driver NVIDIA, cho tiến trình của game này: {0}</value>
@@ -3297,4 +3297,82 @@ Các văn bản bên dưới là điều khoản đầy đủ; bản tóm tắt
<data name="ImagePicker_Filter" xml:space="preserve">
<value>Ảnh (*.png;*.jpg;*.jpeg;*.bmp;*.webp)|*.png;*.jpg;*.jpeg;*.bmp;*.webp</value>
</data>
<data name="FgMix_Header" xml:space="preserve">
<value>Tạo khung hình trong phiên này</value>
</data>
<data name="FgMix_Col_State" xml:space="preserve">
<value>Trạng thái</value>
</data>
<data name="FgMix_Col_Share" xml:space="preserve">
<value>Tỷ lệ thời gian</value>
</data>
<data name="FgMix_Col_Rates" xml:space="preserve">
<value>Gốc → Hiển thị</value>
</data>
<data name="FgMix_Col_Time" xml:space="preserve">
<value>Thời gian</value>
</data>
<data name="FgMix_State_Format" xml:space="preserve">
<value>Tạo khung hình ×{0:0.0}</value>
</data>
<data name="FgMix_None" xml:space="preserve">
<value>Không tạo khung hình</value>
</data>
<data name="FgMix_Unclassified" xml:space="preserve">
<value>Không phân loại</value>
</data>
<data name="FgMix_Rates_Format" xml:space="preserve">
<value>{0} → {1} FPS</value>
</data>
<data name="FgMix_Rate_Format" xml:space="preserve">
<value>{0} FPS</value>
</data>
<data name="FgMix_Bar_Name_Format" xml:space="preserve">
<value>Tỷ lệ thời gian của phiên theo trạng thái tạo khung hình: {0}</value>
</data>
<data name="FgMix_Unclassified_Note" xml:space="preserve">
<value>Không phân loại: thời gian không thuộc trạng thái nào kéo dài ít nhất 10 giây — lúc chuyển đổi, lúc tải, hệ số thay đổi nhanh hơn các khoảng năm giây dùng để đọc, hoặc những khoảng có quá ít khung hình để đọc.</value>
</data>
<data name="FgMix_NotStored" xml:space="preserve">
<value>Tỷ lệ các trạng thái tạo khung hình được lưu cho các phiên ghi bằng 0.1.0-beta.24 trở lên, khi có một trạng thái kéo dài ít nhất 10 giây.</value>
</data>
<data name="FgMix_Context_App_Format" xml:space="preserve">
<value>Đặt trong NVIDIA App: {0}</value>
</data>
<data name="FgMix_Context_Driver_Format" xml:space="preserve">
<value>Do hồ sơ riêng của driver NVIDIA cho game này đặt: {0}</value>
</data>
<data name="FgMix_Context_Game" xml:space="preserve">
<value>Đặt trong game — NVIDIA App không ghi đè tạo khung hình</value>
</data>
<data name="FgMix_Context_Dynamic" xml:space="preserve">
<value>Dynamic (động)</value>
</data>
<data name="FgMix_Context_Fixed_Format" xml:space="preserve">
<value>Fixed (cố định) {0}</value>
</data>
<data name="FgMix_Context_UpTo_Format" xml:space="preserve">
<value>tối đa {0}</value>
</data>
<data name="FgMix_Context_Target_Auto" xml:space="preserve">
<value>mục tiêu: tần số quét tối đa</value>
</data>
<data name="FgMix_Context_Target_Format" xml:space="preserve">
<value>mục tiêu {0} FPS</value>
</data>
<data name="FgMix_Context_Off" xml:space="preserve">
<value>tắt tạo khung hình</value>
</data>
<data name="FgMix_Context_On" xml:space="preserve">
<value>bật tạo khung hình</value>
</data>
<data name="FgMix_Context_Auto" xml:space="preserve">
<value>tự động</value>
</data>
<data name="Fps_Fg_Column_Format" xml:space="preserve">
<value>×{0:0.0}</value>
</data>
<data name="Fps_Fg_Column_Steady_Format" xml:space="preserve">
<value>×{0:0.0} · {1:0}%</value>
</data>
</root>
@@ -25,4 +25,8 @@
<!-- beta.14: the seventh line on the temperatures plot (the card's memory temperature) — no colour above is 60 apart
from all six beside it. -->
<Color x:Key="Chart_SensorTertiary">#FFE6E6E6</Color>
<!-- beta.24 (D62): the frame-generation mix bar. A state takes its multiplier's series colour (ChartPalette.MixFill);
no frame generation is a solid neutral, and the time no state claims a dim one, so the two never read as one. -->
<Color x:Key="Chart_MixNone">#FFA0A0A0</Color>
<Color x:Key="Chart_MixUnclassified">#40FFFFFF</Color>
</ResourceDictionary>
@@ -20,4 +20,7 @@
<Color x:Key="Chart_Percentile">#FF795548</Color>
<!-- beta.14: the seventh line on the temperatures plot (the card's memory temperature). -->
<Color x:Key="Chart_SensorTertiary">#FFBE008C</Color>
<!-- beta.24 (D62): the frame-generation mix bar — no frame generation solid, the time no state claims faint. -->
<Color x:Key="Chart_MixNone">#FF6E6E6E</Color>
<Color x:Key="Chart_MixUnclassified">#33000000</Color>
</ResourceDictionary>
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using FrameLedger.App.Controls;
namespace FrameLedger.App.ViewModels;
/// <summary>
/// One row of the summary's frame-generation mix (beta.24, D62): what the row is, its share of the presenting time, its own
/// Native → Displayed (CLAUDE.md rule 6: a state's factor never stands without them), and how long it lasted — from
/// <c>sessions.fg_mix</c>, never recomputed.
/// </summary>
/// <param name="Label"><c>×4.0 frame generation</c>, <c>No frame generation</c> or <c>Not classified</c>.</param>
/// <param name="Share">Two decimals, as the owner's example reads (<c>35.33%</c>); <c>&lt;0.01%</c> for a sliver.</param>
/// <param name="Rates"><c>70 → 282 FPS</c> for a state, <c>118 FPS</c> with no frame generation, empty where no state was read.</param>
/// <param name="Duration">The time the row covers.</param>
/// <param name="Segment">The row as the bar draws it.</param>
public sealed record FgMixRowModel(string Label, string Share, string Rates, string Duration, FgMixSegment Segment)
{
/// <summary>The row's colour, as a one-segment bar beside its label.</summary>
public IReadOnlyList<FgMixSegment> Swatch { get; } = [Segment with { Share = 1 }];
}
@@ -9,6 +9,7 @@ using System.Text;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using FrameLedger.App.Charts;
using FrameLedger.App.Controls;
using FrameLedger.App.Services;
using FrameLedger.Application.Persistence;
using FrameLedger.Application.TriState;
@@ -130,6 +131,30 @@ public sealed partial class SessionSummaryViewModel : ObservableObject
[ObservableProperty]
private string? _sensorStatsMissing;
/// <summary>beta.24 (D62): the session stored a mix of two rows or more, so the block is shown.</summary>
[ObservableProperty]
private bool _hasFgMix;
/// <summary>The mix as the bar draws it, in the table's order.</summary>
[ObservableProperty]
private IReadOnlyList<FgMixSegment> _fgMixSegments = [];
/// <summary>The bar's spoken name: every row with its share.</summary>
[ObservableProperty]
private string _fgMixName = string.Empty;
/// <summary>How frame generation was set — in the NVIDIA App, or in the game — when an NVIDIA profile was read; null otherwise.</summary>
[ObservableProperty]
private string? _fgMixContext;
/// <summary>What "not classified" means, when the mix has such a row; null otherwise.</summary>
[ObservableProperty]
private string? _fgMixUnclassifiedNote;
/// <summary>Why a session that counted frame generation shows no mix (<see cref="FgMixPresentation.Missing"/>); null otherwise.</summary>
[ObservableProperty]
private string? _fgMixMissing;
[ObservableProperty]
private string _tags = string.Empty;
@@ -192,6 +217,16 @@ public sealed partial class SessionSummaryViewModel : ObservableObject
public static string ShowSensorsText => Strings.Summary_Show_Sensors;
public static string FgMixHeader => Strings.FgMix_Header;
public static string FgMixStateHeader => Strings.FgMix_Col_State;
public static string FgMixShareHeader => Strings.FgMix_Col_Share;
public static string FgMixRatesHeader => Strings.FgMix_Col_Rates;
public static string FgMixTimeHeader => Strings.FgMix_Col_Time;
public static string AnnotationsHeader => Strings.Summary_Annotations_Header;
public static string TagsPlaceholder => Strings.Summary_Tags_Placeholder;
@@ -222,6 +257,9 @@ public sealed partial class SessionSummaryViewModel : ObservableObject
public ObservableCollection<TriStateChipModel> Chips { get; } = [];
/// <summary>beta.24 (D62): every frame-generation state the session held, then no frame generation, then the time no state claims.</summary>
public ObservableCollection<FgMixRowModel> FgMix { get; } = [];
/// <summary>The action in flight, for a test to await.</summary>
public Task Pending { get; private set; } = Task.CompletedTask;
@@ -388,10 +426,29 @@ public sealed partial class SessionSummaryViewModel : ObservableObject
HasSensorCharts = SensorSeries is { Sensors.Count: > 0 };
DecimationNote = Series is null ? string.Empty : string.Format(CultureInfo.CurrentCulture, Strings.Chart_Decimated_Format, Series.Presents, Math.Min(Series.Presents, Decimator.DefaultBuckets * 2));
PresentStats(row);
PresentFgMix(row);
PresentChips();
Presented?.Invoke(this, EventArgs.Empty);
}
/// <summary>beta.24 (D62): the stored mix as rows and a bar, the setting that framed it, and why a session has none.</summary>
private void PresentFgMix(SessionRow row)
{
IReadOnlyList<FgMixRowModel> rows = FgMixPresentation.Rows(row);
FgMix.Clear();
foreach (FgMixRowModel line in rows)
{
FgMix.Add(line);
}
HasFgMix = rows.Count > 0;
FgMixSegments = [.. rows.Select(static r => r.Segment)];
FgMixName = HasFgMix ? FgMixPresentation.AccessibleName(rows) : string.Empty;
FgMixContext = HasFgMix ? NvidiaOverrides.FrameGenerationContext(row.DriverProfileJson) : null;
FgMixUnclassifiedNote = rows.Any(static r => r.Segment.Kind == Domain.Metrics.FgMixKind.Unclassified) ? Strings.FgMix_Unclassified_Note : null;
FgMixMissing = FgMixPresentation.Missing(row);
}
private void PresentStats(SessionRow row)
{
IReadOnlyDictionary<string, Application.Recording.SensorSeriesStats> stats = Application.Recording.SensorSeriesStats.Parse(row.SensorStatsJson);
@@ -91,6 +91,56 @@
</ItemsControl.ItemTemplate>
</ItemsControl>
<!-- beta.24 (D62): every frame-generation state the session held, each with its share of the presenting time and its
own Native to Displayed (CLAUDE.md rule 6): the stored fg_mix, never recomputed. The bar draws in the chart
palette's colours from code (FgMixBar); the table carries every number in text. -->
<StackPanel Margin="0,8,0,0" Visibility="{Binding ViewModel.HasFgMix, Converter={StaticResource BoolToVis}}">
<ui:TextBlock FontTypography="Subtitle" Text="{x:Static vm:SessionSummaryViewModel.FgMixHeader}" />
<ui:TextBlock Style="{StaticResource TertiaryText}" TextWrapping="Wrap" Text="{Binding ViewModel.FgMixContext}"
Visibility="{Binding ViewModel.FgMixContext, Converter={StaticResource NullToCollapsed}}" />
<controls:FgMixBar Margin="0,6,0,0" Height="14" Segments="{Binding ViewModel.FgMixSegments}"
AutomationProperties.Name="{Binding ViewModel.FgMixName}" />
<StackPanel Margin="0,8,0,0" Grid.IsSharedSizeScope="True">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="MixSwatch" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MixState" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MixShare" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MixRates" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MixTime" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Column="1" Margin="0,0,24,4" FontTypography="BodyStrong" Text="{x:Static vm:SessionSummaryViewModel.FgMixStateHeader}" />
<ui:TextBlock Grid.Column="2" Margin="0,0,24,4" FontTypography="BodyStrong" TextAlignment="Right" Text="{x:Static vm:SessionSummaryViewModel.FgMixShareHeader}" />
<ui:TextBlock Grid.Column="3" Margin="0,0,24,4" FontTypography="BodyStrong" TextAlignment="Right" Text="{x:Static vm:SessionSummaryViewModel.FgMixRatesHeader}" />
<ui:TextBlock Grid.Column="4" Margin="0,0,0,4" FontTypography="BodyStrong" TextAlignment="Right" Text="{x:Static vm:SessionSummaryViewModel.FgMixTimeHeader}" />
</Grid>
<ItemsControl ItemsSource="{Binding ViewModel.FgMix}" Focusable="False">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type vm:FgMixRowModel}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="MixSwatch" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MixState" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MixShare" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MixRates" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MixTime" />
</Grid.ColumnDefinitions>
<controls:FgMixBar Grid.Column="0" Width="12" Height="12" Margin="0,0,8,0" VerticalAlignment="Center" Segments="{Binding Swatch}" />
<ui:TextBlock Grid.Column="1" Margin="0,2,24,2" Text="{Binding Label}" />
<ui:TextBlock Grid.Column="2" Margin="0,2,24,2" TextAlignment="Right" Text="{Binding Share}" />
<ui:TextBlock Grid.Column="3" Margin="0,2,24,2" TextAlignment="Right" Text="{Binding Rates}" />
<ui:TextBlock Grid.Column="4" Margin="0,2,0,2" Style="{StaticResource SecondaryText}" TextAlignment="Right" Text="{Binding Duration}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
<ui:TextBlock Margin="0,4,0,0" Style="{StaticResource TertiaryText}" TextWrapping="Wrap" Text="{Binding ViewModel.FgMixUnclassifiedNote}"
Visibility="{Binding ViewModel.FgMixUnclassifiedNote, Converter={StaticResource NullToCollapsed}}" />
</StackPanel>
<ui:TextBlock Margin="0,8,0,0" Style="{StaticResource TertiaryText}" TextWrapping="Wrap" Text="{Binding ViewModel.FgMixMissing}"
Visibility="{Binding ViewModel.FgMixMissing, Converter={StaticResource NullToCollapsed}}" />
<ui:TextBlock Margin="0,8,0,0" Style="{StaticResource SecondaryText}" TextWrapping="Wrap" Text="{x:Static vm:SessionSummaryViewModel.Tier2Text}"
Visibility="{Binding ViewModel.IsHooked, Converter={StaticResource InverseBoolToVis}}" />
<ui:TextBlock Margin="0,4,0,0" TextWrapping="Wrap" Text="{Binding ViewModel.Tier2Reason}"
@@ -140,6 +140,13 @@ public sealed record SessionRow
/// <summary>The fraction (0..1) of the presenting time the steady state covers; null unless <see cref="FgFactorScope"/> is <c>steady</c>.</summary>
public double? FgSteadyShare { get; init; }
/// <summary>
/// <c>fg_mix</c> (schema 0020, beta.24, D62): every frame-generation state the session held, each with its factor, its
/// Native and Displayed rates and its share of the presenting time, as <c>FgMixRecord</c>'s JSON. Null on a session
/// that generated no state, and on every session recorded before it — never rebuilt from stored frames.
/// </summary>
public string? FgMixJson { get; init; }
public double? PresentedFps { get; init; }
public string? PresentedQualifier { get; init; }
@@ -67,8 +67,11 @@ public sealed record DriverProfileRecord
}
/// <summary>The value the profile gives <paramref name="id"/>, or null when it is set in no profile or was not read.</summary>
public uint? ValueOf(uint id) =>
Settings.FirstOrDefault(s => string.Equals(s.Id, Hex(id), StringComparison.OrdinalIgnoreCase))?.Value;
public uint? ValueOf(uint id) => SettingOf(id)?.Value;
/// <summary>The stored setting for <paramref name="id"/> — its value, where it comes from, whether it is the driver's own — or null when it was not read.</summary>
public DriverSettingRecord? SettingOf(uint id) =>
Settings.FirstOrDefault(s => string.Equals(s.Id, Hex(id), StringComparison.OrdinalIgnoreCase));
private static string Hex(uint id) => "0x" + id.ToString("X8", CultureInfo.InvariantCulture);
}
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Text.Json;
using FrameLedger.Domain.Metrics;
namespace FrameLedger.Application.Recording;
/// <summary>
/// <c>sessions.fg_mix</c> (schema 0020, beta.24, decision D62): <see cref="FgMix"/> as JSON — every frame-generation
/// state the session held, each with its factor, its own rates and its share of the presenting time.
/// </summary>
/// <param name="Rows">States first, by rising factor, then no frame generation, then the time no state claims.</param>
public sealed record FgMixRecord(IReadOnlyList<FgMixRecordRow> Rows)
{
/// <summary>The column's text for <paramref name="mix"/>, or null when there is none.</summary>
public static string? ToJson(FgMix? mix) => mix is null
? null
: JsonSerializer.Serialize(new FgMixRecord([.. mix.Rows.Select(FgMixRecordRow.From)]), RecordingJsonContext.Default.FgMixRecord);
/// <summary>The column's text back, or null for a null/empty/unparsable column (a writer that predates it, or a hand edit).</summary>
public static FgMixRecord? Parse(string? json)
{
if (string.IsNullOrWhiteSpace(json))
{
return null;
}
try
{
return JsonSerializer.Deserialize(json, RecordingJsonContext.Default.FgMixRecord);
}
catch (JsonException)
{
return null;
}
}
}
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using FrameLedger.Domain.Metrics;
namespace FrameLedger.Application.Recording;
/// <summary>One row of <see cref="FgMixRecord"/>: <see cref="FgMixRow"/> with its kind as a token.</summary>
/// <param name="Kind"><c>generated</c>, <c>none</c> or <c>unclassified</c>.</param>
/// <param name="Factor">A state's pooled factor; null otherwise.</param>
/// <param name="NativeFps">Application frames per second over the row's windows; null for unclassified time.</param>
/// <param name="DisplayedFps">Displayed frames per second over the row's windows; null for unclassified time.</param>
/// <param name="Seconds">The time the row covers.</param>
/// <param name="Share">That time over the session's presenting time (0..1).</param>
/// <param name="Windows">How many five-second windows the row holds.</param>
public sealed record FgMixRecordRow(string Kind, double? Factor, double? NativeFps, double? DisplayedFps, double Seconds, double Share, int Windows)
{
/// <summary>The token stored for <paramref name="kind"/>.</summary>
public static string Token(FgMixKind kind) => kind switch
{
FgMixKind.Generated => "generated",
FgMixKind.None => "none",
_ => "unclassified",
};
/// <summary>A stored token back as its kind; a token this build does not know reads as unclassified — time no state claims.</summary>
public static FgMixKind KindOf(string? token) => token switch
{
"generated" => FgMixKind.Generated,
"none" => FgMixKind.None,
_ => FgMixKind.Unclassified,
};
public static FgMixRecordRow From(FgMixRow row)
{
ArgumentNullException.ThrowIfNull(row);
return new FgMixRecordRow(Token(row.Kind), row.Factor, row.NativeFps, row.DisplayedFps, row.Seconds, row.Share, row.Windows);
}
}
@@ -5,12 +5,13 @@ using System.Text.Json.Serialization;
namespace FrameLedger.Application.Recording;
/// <summary>Source-generated JSON for the three JSON columns of <c>sessions</c>; no reflection.</summary>
/// <summary>Source-generated JSON for the JSON columns of <c>sessions</c>; no reflection.</summary>
[JsonSourceGenerationOptions(WriteIndented = false)]
[JsonSerializable(typeof(Dictionary<string, string?>))]
[JsonSerializable(typeof(Dictionary<string, int>))]
[JsonSerializable(typeof(NgxDriverWords))]
[JsonSerializable(typeof(FgRefusalDetail))]
[JsonSerializable(typeof(FgMixRecord))]
[JsonSerializable(typeof(DriverProfileRecord))]
[JsonSerializable(typeof(Dictionary<string, SensorSeriesStats>))]
public sealed partial class RecordingJsonContext : JsonSerializerContext
@@ -145,6 +145,7 @@ public static class SessionAggregator
DisplayedFps = usable ? fg!.DisplayedFps : steady?.DisplayedFps,
FgFactorScope = usable && fg!.Factor is not null ? "session" : steady is not null ? "steady" : null,
FgSteadyShare = steady?.Share,
FgMixJson = FgMixRecord.ToJson(Mix(c)),
DisplayedP1LowFps = usable && c.Verdict is FgVerdict.Named or FgVerdict.ActiveUnidentified ? c.PresentStats.P1LowFps : null,
DisplayedCountedBy = usable || steady is not null ? (fg!.DxgiCounted ? "dxgi" : "hook") : null,
FgNoneWithheldReason = c.Withheld,
@@ -160,6 +161,19 @@ public static class SessionAggregator
};
}
/// <summary>
/// Every frame-generation state the session held (beta.24, D62): only where the session generated frames and its
/// count is one a window can be read from — a whole-session factor, or one refused as non-uniform or in the band
/// between none and generating. Unattributed, interleaved or saturated records are not made trustworthy by slicing
/// them (03_METRICS §The steady state).
/// </summary>
private static FgMix? Mix(Context c) =>
c.Verdict is FgVerdict.Named or FgVerdict.ActiveUnidentified
&& c.Fg is { } fg
&& (fg.Refusal is null || fg.Refusal is { Subject: FgRefusalSubject.Factor, Kind: FgRefusalKind.NonUniform or FgRefusalKind.AmbiguousBand })
? FgMix.From(c.All, c.Input.QpcFrequency, c.NoneAllowed)
: null;
/// <summary>The qualifier the one number that stands alone must carry (CLAUDE.md rule 6, as amended); the ladder's, shared with the live card (P3 PR-1).</summary>
private static string PresentedQualifier(Context c) => FgLadder.PresentedQualifier(c.Input.Writer, c.Withheld);
@@ -434,6 +448,8 @@ public static class SessionAggregator
FgCounted = FgLadder.FgHookRan(input.Records);
var census = (FlRuntimeCensus)input.Writer.RuntimeCensus;
Withheld = Fg?.IsNone == true ? FgLadder.WithholdNone(census, input.Modules, input.Writer) : null;
// The mix (beta.24, D62) asks the same question of every window, whatever the session factor was.
NoneAllowed = FgLadder.WithholdNone(census, input.Modules, input.Writer) is null;
FgIdentity = FgLadder.Identity(dominantRecords);
Verdict = FgLadder.Resolve(FgIdentity, Fg, Withheld);
FgUsable = Fg is { Refusal: null } && Verdict is FgVerdict.Named or FgVerdict.ActiveUnidentified or FgVerdict.None or FgVerdict.NoneInputsTagged;
@@ -471,6 +487,9 @@ public static class SessionAggregator
public string? Withheld { get; }
/// <summary>Whether a window that counted no generated frame may read as none in the mix (not FgLadder's withheld shape).</summary>
public bool NoneAllowed { get; }
public FlFgMode? FgIdentity { get; }
public FgVerdict Verdict { get; }
+134
View File
@@ -0,0 +1,134 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
namespace FrameLedger.Domain.Metrics;
/// <summary>
/// Every frame-generation state a session held, with the share of its presenting time each one took — the owner's
/// "×2: 10 %, ×3: 25.75 %, ×4: 35.33 %, no frame generation: …" (beta.24, decision D62).
/// </summary>
/// <remarks>
/// <para>
/// <b>The steady state's windows, all of them.</b> <see cref="FgSteadyState"/> keeps the state that held the most time;
/// this takes it, then the state that holds the most of what is left, and so on, by the same rule
/// (<see cref="FgSlices.DominantState"/>) over the same five-second windows (<see cref="FgSlices.Cut"/>), until no group of
/// agreeing windows lasts <see cref="FgSteadyState.MinSeconds"/>. So the longest state of the mix is the steady state.
/// </para>
/// <para>
/// <b>Never an average across states</b> (CLAUDE.md rule 6): each state keeps its own factor, its own Native and
/// Displayed rates and its share. The factor is the pooled ratio, never rounded to a whole multiplier: a session at ×4
/// reads 3.99 or 4.11 because that is what was counted.
/// </para>
/// <para>
/// <b>Rows add up to the whole</b>: the share's denominator is every window of the claimed span — the steady state's own
/// denominator — and every window lands in exactly one row. States come first, by rising factor, then
/// <see cref="FgMixKind.None"/>, then <see cref="FgMixKind.Unclassified"/>.
/// </para>
/// </remarks>
public sealed record FgMix(IReadOnlyList<FgMixRow> Rows)
{
/// <summary>
/// The mix over <paramref name="all"/> from its first sample that counted application frames, or null when there is
/// nothing to split: no counted span, a span of no length, or no frame-generation state at all.
/// </summary>
/// <param name="all">The session's samples, every stream, in drained order.</param>
/// <param name="qpcFrequency">Ticks per second of the samples' clock.</param>
/// <param name="noneAllowed">
/// Whether a counted <c>none</c> may be believed: false on the shape <c>FgLadder.WithholdNone</c> withholds, where
/// generated presents can be invisible to the hook — those windows are then unclassified, never "no frame generation".
/// </param>
public static FgMix? From(IReadOnlyList<FrameSample> all, long qpcFrequency, bool noneAllowed)
{
ArgumentNullException.ThrowIfNull(all);
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(qpcFrequency);
int start = RecordWindow.ClaimedSuffixStart(all, MeasuredFields.FgCounts);
if (start >= all.Count)
{
return null;
}
List<FgSlices.Slice> slices = FgSlices.Cut(all, start, qpcFrequency);
double total = slices.Sum(static s => s.Seconds);
if (total <= 0)
{
return null;
}
var active = new List<FgSlices.Slice>();
var none = new List<FgSlices.Slice>();
var unclassified = new List<FgSlices.Slice>();
foreach (FgSlices.Slice s in slices)
{
List<FgSlices.Slice> into = s.IsActive ? active
: noneAllowed && s.Samples >= FgWindow.MinPerBucket && s.Tokens > 0 && s.Factor <= FgWindow.NoneCeiling ? none
: unclassified;
into.Add(s);
}
List<List<FgSlices.Slice>> states = States(active, unclassified);
if (states.Count == 0)
{
return null;
}
var rows = new List<FgMixRow>();
rows.AddRange(states.OrderBy(static s => Pooled(s)).Select(s => Row(FgMixKind.Generated, s, total)));
// A last window can end on its first sample and so last no time: it changes no share and makes no row.
if (none.Sum(static s => s.Seconds) > 0)
{
rows.Add(Row(FgMixKind.None, none, total));
}
if (unclassified.Sum(static s => s.Seconds) > 0)
{
rows.Add(Row(FgMixKind.Unclassified, unclassified, total));
}
return new FgMix(rows);
}
/// <summary>
/// The steady state, then the steady state of what is left, until no group of agreeing windows lasts
/// <see cref="FgSteadyState.MinSeconds"/>; what is left then goes to <paramref name="unclassified"/>.
/// </summary>
private static List<List<FgSlices.Slice>> States(List<FgSlices.Slice> active, List<FgSlices.Slice> unclassified)
{
var states = new List<List<FgSlices.Slice>>();
while (active.Count > 0)
{
List<FgSlices.Slice> state = FgSlices.DominantState(active);
if (state.Sum(static s => s.Seconds) < FgSteadyState.MinSeconds)
{
// The longest group left is a transition, so every group left is: none of them is a state.
unclassified.AddRange(active);
break;
}
states.Add(state);
active.RemoveAll(state.Contains);
}
return states;
}
private static double Pooled(List<FgSlices.Slice> slices) =>
slices.Sum(static s => s.Displayed) / (double)slices.Sum(static s => s.Tokens);
private static FgMixRow Row(FgMixKind kind, List<FgSlices.Slice> slices, double total)
{
double seconds = slices.Sum(static s => s.Seconds);
long displayed = slices.Sum(static s => s.Displayed);
long tokens = slices.Sum(static s => s.Tokens);
bool rated = kind != FgMixKind.Unclassified;
return new FgMixRow(
kind,
kind == FgMixKind.Generated ? displayed / (double)tokens : null,
rated ? tokens / seconds : null,
rated ? displayed / seconds : null,
seconds,
seconds / total,
slices.Count);
}
}
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
namespace FrameLedger.Domain.Metrics;
/// <summary>What one row of a session's frame-generation mix (<see cref="FgMix"/>) is.</summary>
public enum FgMixKind
{
/// <summary>A frame-generation state: windows agreeing within <see cref="FgSteadyState.StateTolerance"/>.</summary>
Generated,
/// <summary>Windows that counted no generated frame (a factor at or below <see cref="FgWindow.NoneCeiling"/>).</summary>
None,
/// <summary>
/// Time no state can claim: a window with too few frames or no application frame counted, a factor between
/// <see cref="FgWindow.NoneCeiling"/> and <see cref="FgWindow.ActiveThreshold"/>, a factor changing faster than the
/// windows (a transition, or dynamic frame generation), a group of agreeing windows shorter than
/// <see cref="FgSteadyState.MinSeconds"/>, and — where a counted <c>none</c> may not be trusted — the windows that
/// read none.
/// </summary>
Unclassified,
}
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
namespace FrameLedger.Domain.Metrics;
/// <summary>One row of <see cref="FgMix"/>.</summary>
/// <param name="Kind">What the row is.</param>
/// <param name="Factor">A state's pooled <c>Σ displayed ÷ Σ tokens</c>; null for the other kinds.</param>
/// <param name="NativeFps"><c>Σ tokens ÷ seconds</c> over the row's windows; null for <see cref="FgMixKind.Unclassified"/>.</param>
/// <param name="DisplayedFps"><c>Σ displayed ÷ seconds</c>; null for <see cref="FgMixKind.Unclassified"/>.</param>
/// <param name="Seconds">The time the row's windows cover.</param>
/// <param name="Share">That time over the time of every window — the rows' shares add up to one.</param>
/// <param name="Windows">How many windows the row holds.</param>
public sealed record FgMixRow(FgMixKind Kind, double? Factor, double? NativeFps, double? DisplayedFps, double Seconds, double Share, int Windows);
+103
View File
@@ -0,0 +1,103 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Runtime.InteropServices;
namespace FrameLedger.Domain.Metrics;
/// <summary>
/// The five-second windows frame generation is read over — the live card's own — and the one way both
/// <see cref="FgSteadyState"/> and <see cref="FgMix"/> group them into states, so the two can never disagree about what a
/// window or a state is (beta.24: cut out of <see cref="FgSteadyState"/> unchanged when <see cref="FgMix"/> needed it too).
/// </summary>
internal static class FgSlices
{
/// <summary>One window: its displayed presents, application-frame tokens, samples, and seconds.</summary>
[StructLayout(LayoutKind.Auto)]
internal readonly record struct Slice(long Displayed, long Tokens, int Samples, double Seconds)
{
/// <summary>Read only on windows that have tokens.</summary>
public double Factor => Displayed / (double)Tokens;
/// <summary>Generating: enough samples to judge, tokens counted, and at least <see cref="FgWindow.ActiveThreshold"/>.</summary>
public bool IsActive => Samples >= FgWindow.MinPerBucket && Tokens > 0 && Displayed >= Tokens * FgWindow.ActiveThreshold;
}
/// <summary>
/// The set of mutually agreeing windows of <paramref name="active"/> (none empty, all active) that holds the most time:
/// every window is tried as the centre, the winner pooled and the set re-drawn once around the pooled factor, so the
/// centre's own noise does not decide membership. Never empty: the pooled factor is a weighted mean of members within
/// <see cref="FgSteadyState.StateTolerance"/> of the centre, and a mean always has a member that close to itself.
/// </summary>
public static List<Slice> DominantState(List<Slice> active)
{
double centre = active[0].Factor;
double best = -1;
foreach (Slice candidate in active)
{
double seconds = Within(active, candidate.Factor).Sum(static s => s.Seconds);
if (seconds > best)
{
best = seconds;
centre = candidate.Factor;
}
}
return [.. Within(active, Pooled([.. Within(active, centre)]))];
}
private static IEnumerable<Slice> Within(List<Slice> active, double factor) =>
active.Where(s => Math.Abs(s.Factor - factor) <= factor * FgSteadyState.StateTolerance);
private static double Pooled(List<Slice> slices) =>
slices.Sum(static s => s.Displayed) / (double)Math.Max(1, slices.Sum(static s => s.Tokens));
/// <summary>
/// Fixed wall-clock windows from <paramref name="start"/>'s sample. A window's seconds are its nominal length, except
/// the last, which ends at the last sample; a window with no sample in it (the title minimised) is not a window.
/// </summary>
public static List<Slice> Cut(IReadOnlyList<FrameSample> all, int start, long qpcFrequency)
{
ulong origin = all[start].Qpc;
ulong last = all[^1].Qpc;
double ticksPerWindow = FgSteadyState.WindowSeconds * qpcFrequency;
var slices = new List<Slice>();
long index = -1;
long displayed = 0;
long tokens = 0;
int samples = 0;
void Close()
{
if (samples == 0)
{
return;
}
// A window's length is nominal, except the last, which ends at the last sample (and may be zero long).
double windowStart = origin + (index * ticksPerWindow);
slices.Add(new Slice(displayed, tokens, samples, Math.Clamp((last - windowStart) / qpcFrequency, 0, FgSteadyState.WindowSeconds)));
}
for (int i = start; i < all.Count; i++)
{
FrameSample s = all[i];
long at = (long)(Math.Max(0d, (double)s.Qpc - origin) / ticksPerWindow);
if (at != index)
{
Close();
index = at;
displayed = 0;
tokens = 0;
samples = 0;
}
displayed += 1 + (s.Claims(MeasuredFields.DxgiPresents) ? s.DxgiUnseen : 0);
tokens += s.FgEvaluations;
samples++;
}
Close();
return slices;
}
}
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Runtime.InteropServices;
namespace FrameLedger.Domain.Metrics;
/// <summary>
@@ -53,15 +51,6 @@ public sealed record FgSteadyState(double Factor, double NativeFps, double Displ
/// <summary>A state covering less of the presenting time than this does not speak for the session.</summary>
public const double MinShare = 0.10;
[StructLayout(LayoutKind.Auto)]
private readonly record struct Slice(long Displayed, long Tokens, int Samples, double Seconds)
{
/// <summary>Read only on active slices, which have tokens.</summary>
public double Factor => Displayed / (double)Tokens;
public bool IsActive => Samples >= FgWindow.MinPerBucket && Tokens > 0 && Displayed >= Tokens * FgWindow.ActiveThreshold;
}
/// <summary>The dominant active state over <paramref name="all"/> from <paramref name="start"/>, or null when none qualifies.</summary>
public static FgSteadyState? From(IReadOnlyList<FrameSample> all, int start, long qpcFrequency)
{
@@ -70,31 +59,16 @@ public sealed record FgSteadyState(double Factor, double NativeFps, double Displ
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(start, all.Count);
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(qpcFrequency);
List<Slice> slices = Cut(all, start, qpcFrequency);
List<Slice> active = [.. slices.Where(static s => s.IsActive)];
List<FgSlices.Slice> slices = FgSlices.Cut(all, start, qpcFrequency);
List<FgSlices.Slice> active = [.. slices.Where(static s => s.IsActive)];
if (active.Count == 0)
{
return null;
}
// The state is the set of mutually agreeing windows holding the most time. Every active window is tried as
// the centre; the winner is pooled and the set re-drawn once around the pooled factor, so the centre's own
// noise does not decide membership.
double centre = active[0].Factor;
double best = -1;
foreach (Slice candidate in active)
{
double seconds = Within(active, candidate.Factor).Sum(static s => s.Seconds);
if (seconds > best)
{
best = seconds;
centre = candidate.Factor;
}
}
// Never empty: the pooled factor is a weighted mean of members within 10 % of the centre, and a mean always has a
// member within 10 % of itself (a member below it and one above it cannot both be further than that).
List<Slice> state = [.. Within(active, Pooled([.. Within(active, centre)]))];
// The state is the set of mutually agreeing windows holding the most time (FgSlices.DominantState, which
// FgMix applies again to what is left).
List<FgSlices.Slice> state = FgSlices.DominantState(active);
long displayed = state.Sum(static s => s.Displayed);
long tokens = state.Sum(static s => s.Tokens);
double stateSeconds = state.Sum(static s => s.Seconds);
@@ -103,59 +77,4 @@ public sealed record FgSteadyState(double Factor, double NativeFps, double Displ
? null
: new FgSteadyState(displayed / (double)tokens, tokens / stateSeconds, displayed / stateSeconds, stateSeconds, share, state.Count);
}
private static IEnumerable<Slice> Within(List<Slice> active, double factor) =>
active.Where(s => Math.Abs(s.Factor - factor) <= factor * StateTolerance);
private static double Pooled(List<Slice> slices) =>
slices.Sum(static s => s.Displayed) / (double)Math.Max(1, slices.Sum(static s => s.Tokens));
/// <summary>
/// Fixed wall-clock windows from the first claimed sample. A window's seconds are its nominal length, except the
/// last, which ends at the last sample; a window with no sample in it (the title minimised) is not a window.
/// </summary>
private static List<Slice> Cut(IReadOnlyList<FrameSample> all, int start, long qpcFrequency)
{
ulong origin = all[start].Qpc;
ulong last = all[^1].Qpc;
double ticksPerWindow = WindowSeconds * qpcFrequency;
var slices = new List<Slice>();
long index = -1;
long displayed = 0;
long tokens = 0;
int samples = 0;
void Close()
{
if (samples == 0)
{
return;
}
// A window's length is nominal, except the last, which ends at the last sample (and may be zero long).
double windowStart = origin + (index * ticksPerWindow);
slices.Add(new Slice(displayed, tokens, samples, Math.Clamp((last - windowStart) / qpcFrequency, 0, WindowSeconds)));
}
for (int i = start; i < all.Count; i++)
{
FrameSample s = all[i];
long at = (long)(Math.Max(0d, (double)s.Qpc - origin) / ticksPerWindow);
if (at != index)
{
Close();
index = at;
displayed = 0;
tokens = 0;
samples = 0;
}
displayed += 1 + (s.Claims(MeasuredFields.DxgiPresents) ? s.DxgiUnseen : 0);
tokens += s.FgEvaluations;
samples++;
}
Close();
return slices;
}
}
@@ -0,0 +1,12 @@
-- 0020 (2026-10-19, beta.24, owner decision D62): every frame-generation state a session held, with its share of the
-- presenting time (03_METRICS §The mix).
--
-- One JSON column, written by the recorder's aggregation from the same five-second windows the steady state is read over
-- (Domain.Metrics.FgMix, stored through Application.Recording.FgMixRecord): each state's pooled factor, its own Native and
-- Displayed rates, its seconds and share; then the time with no frame generation and the time no state claims. Never an
-- average across states (CLAUDE.md rule 6). Written by the Agent only (06_DATA_MODEL §Writer ownership); ADD COLUMN only.
-- A session written before this script has none and is never rebuilt from its frame_blobs: they keep one Generated bit
-- per frame and lose the presents only DXGI counted, so a mix rebuilt from them would be wrong on exactly the titles that
-- need it.
ALTER TABLE sessions ADD COLUMN fg_mix TEXT;
@@ -19,10 +19,10 @@ namespace FrameLedger.Infrastructure.Persistence;
internal static class SessionRowColumns
{
public const string Insert =
"INSERT INTO sessions (session_guid, game_id, snapshot_id, started_at, ended_at, duration_s, qpc_epoch, qpc_frequency, capture_tier, capture_mode, capture_notes, ac_exception_family, late_attach, telemetry_source, overlay_build_id, exit_status, drain_ticks, foreground_ticks, records_before_attach, dxgi_presents_before_hook, gap_count, guard_ticks_published, launch_wait_ms, api, present_mode, swap_effect, hdr_flag, hdr_source, sync_interval_mode, upscaler, upscaler_quality, upscaler_sharpness, upscaler_driver_reported, render_w, render_h, output_w, output_h, upscale_ratio, settings_changed_midsession, fg_mode, fg_source, fg_factor, fg_driver_reported, fg_runtime_census, fg_none_withheld_reason, fg_refusal, fg_refusal_detail, fg_factor_scope, fg_steady_share, presented_fps, presented_qualifier, dxgi_unseen_total, dxgi_present_samples, displayed_counted_by, sl_tag_census, sl_interposer_version, runtime_modules, driver_profile, executable_markers, ngx_driver_words, rt_flag, rt_source, pt_flag, pt_source, pt_confidence, rr_flag, rr_source, rt_frame_pct, rays_per_pixel, rt_pso_count, rt_tier, hooks_installed_mask, raster_pso_count, frame_count, app_frame_count, displayed_frame_count, dropped_frames, native_fps, displayed_fps, median_fps, p1_low_fps, p01_low_fps, displayed_p1_low_fps, min_fps, max_fps, frametime_stddev_ms, stutter_count, stutter_time_pct, pso_stutter_pct, reflex_active, latency_avg_us, latency_p95_us, dropped_records, fault_count, data_quality_warnings, writer_status_at_end, early_stop_family, loader_signals, vram_proc_avg_mb, vram_proc_max_mb, vram_budget_exceeded_pct, vram_adapter_max_mb, avg_cpu_temp, max_cpu_temp, avg_gpu_temp, max_gpu_temp, max_gpu_hotspot, avg_gpu_load, avg_cpu_load, avg_ram_mb, avg_gpu_power_w, throttle_pct, display_exclusive_ms, display_borderless_ms, display_windowed_ms, display_covers_ms, display_minimized_ms, display_nowindow_ms, display_changes, display_source, display_window_w, display_window_h, display_buffer_w, display_buffer_h, display_monitor_w, display_monitor_h, display_monitor_hz, game_vram_dedicated_avg_mb, game_vram_dedicated_median_mb, game_vram_dedicated_max_mb, game_vram_shared_max_mb, game_ram_private_avg_mb, game_ram_private_median_mb, game_ram_private_max_mb, game_ram_ws_max_mb, game_commit_max_mb, game_memory_processes, game_memory_source, sensor_stats_json, time_below_30_pct, time_below_60_pct, time_below_refresh_pct, frametime_delta_mean_ms, vsync_present_pct, tearing_allowed_pct, avg_gpu_core_clock_mhz, avg_gpu_mem_clock_mhz, avg_gpu_fan_rpm, max_gpu_mem_temp, power_limit_pct, thermal_limit_pct, app_frames_per_joule) "
+ "VALUES (@session_guid, @game_id, @snapshot_id, @started_at, @ended_at, @duration_s, @qpc_epoch, @qpc_frequency, @capture_tier, @capture_mode, @capture_notes, @ac_exception_family, @late_attach, @telemetry_source, @overlay_build_id, @exit_status, @drain_ticks, @foreground_ticks, @records_before_attach, @dxgi_presents_before_hook, @gap_count, @guard_ticks_published, @launch_wait_ms, @api, @present_mode, @swap_effect, @hdr_flag, @hdr_source, @sync_interval_mode, @upscaler, @upscaler_quality, @upscaler_sharpness, @upscaler_driver_reported, @render_w, @render_h, @output_w, @output_h, @upscale_ratio, @settings_changed_midsession, @fg_mode, @fg_source, @fg_factor, @fg_driver_reported, @fg_runtime_census, @fg_none_withheld_reason, @fg_refusal, @fg_refusal_detail, @fg_factor_scope, @fg_steady_share, @presented_fps, @presented_qualifier, @dxgi_unseen_total, @dxgi_present_samples, @displayed_counted_by, @sl_tag_census, @sl_interposer_version, @runtime_modules, @driver_profile, @executable_markers, @ngx_driver_words, @rt_flag, @rt_source, @pt_flag, @pt_source, @pt_confidence, @rr_flag, @rr_source, @rt_frame_pct, @rays_per_pixel, @rt_pso_count, @rt_tier, @hooks_installed_mask, @raster_pso_count, @frame_count, @app_frame_count, @displayed_frame_count, @dropped_frames, @native_fps, @displayed_fps, @median_fps, @p1_low_fps, @p01_low_fps, @displayed_p1_low_fps, @min_fps, @max_fps, @frametime_stddev_ms, @stutter_count, @stutter_time_pct, @pso_stutter_pct, @reflex_active, @latency_avg_us, @latency_p95_us, @dropped_records, @fault_count, @data_quality_warnings, @writer_status_at_end, @early_stop_family, @loader_signals, @vram_proc_avg_mb, @vram_proc_max_mb, @vram_budget_exceeded_pct, @vram_adapter_max_mb, @avg_cpu_temp, @max_cpu_temp, @avg_gpu_temp, @max_gpu_temp, @max_gpu_hotspot, @avg_gpu_load, @avg_cpu_load, @avg_ram_mb, @avg_gpu_power_w, @throttle_pct, @display_exclusive_ms, @display_borderless_ms, @display_windowed_ms, @display_covers_ms, @display_minimized_ms, @display_nowindow_ms, @display_changes, @display_source, @display_window_w, @display_window_h, @display_buffer_w, @display_buffer_h, @display_monitor_w, @display_monitor_h, @display_monitor_hz, @game_vram_dedicated_avg_mb, @game_vram_dedicated_median_mb, @game_vram_dedicated_max_mb, @game_vram_shared_max_mb, @game_ram_private_avg_mb, @game_ram_private_median_mb, @game_ram_private_max_mb, @game_ram_ws_max_mb, @game_commit_max_mb, @game_memory_processes, @game_memory_source, @sensor_stats_json, @time_below_30_pct, @time_below_60_pct, @time_below_refresh_pct, @frametime_delta_mean_ms, @vsync_present_pct, @tearing_allowed_pct, @avg_gpu_core_clock_mhz, @avg_gpu_mem_clock_mhz, @avg_gpu_fan_rpm, @max_gpu_mem_temp, @power_limit_pct, @thermal_limit_pct, @app_frames_per_joule) RETURNING id";
"INSERT INTO sessions (session_guid, game_id, snapshot_id, started_at, ended_at, duration_s, qpc_epoch, qpc_frequency, capture_tier, capture_mode, capture_notes, ac_exception_family, late_attach, telemetry_source, overlay_build_id, exit_status, drain_ticks, foreground_ticks, records_before_attach, dxgi_presents_before_hook, gap_count, guard_ticks_published, launch_wait_ms, api, present_mode, swap_effect, hdr_flag, hdr_source, sync_interval_mode, upscaler, upscaler_quality, upscaler_sharpness, upscaler_driver_reported, render_w, render_h, output_w, output_h, upscale_ratio, settings_changed_midsession, fg_mode, fg_source, fg_factor, fg_driver_reported, fg_runtime_census, fg_none_withheld_reason, fg_refusal, fg_refusal_detail, fg_factor_scope, fg_steady_share, presented_fps, presented_qualifier, dxgi_unseen_total, dxgi_present_samples, displayed_counted_by, sl_tag_census, sl_interposer_version, runtime_modules, driver_profile, executable_markers, ngx_driver_words, rt_flag, rt_source, pt_flag, pt_source, pt_confidence, rr_flag, rr_source, rt_frame_pct, rays_per_pixel, rt_pso_count, rt_tier, hooks_installed_mask, raster_pso_count, frame_count, app_frame_count, displayed_frame_count, dropped_frames, native_fps, displayed_fps, median_fps, p1_low_fps, p01_low_fps, displayed_p1_low_fps, min_fps, max_fps, frametime_stddev_ms, stutter_count, stutter_time_pct, pso_stutter_pct, reflex_active, latency_avg_us, latency_p95_us, dropped_records, fault_count, data_quality_warnings, writer_status_at_end, early_stop_family, loader_signals, vram_proc_avg_mb, vram_proc_max_mb, vram_budget_exceeded_pct, vram_adapter_max_mb, avg_cpu_temp, max_cpu_temp, avg_gpu_temp, max_gpu_temp, max_gpu_hotspot, avg_gpu_load, avg_cpu_load, avg_ram_mb, avg_gpu_power_w, throttle_pct, display_exclusive_ms, display_borderless_ms, display_windowed_ms, display_covers_ms, display_minimized_ms, display_nowindow_ms, display_changes, display_source, display_window_w, display_window_h, display_buffer_w, display_buffer_h, display_monitor_w, display_monitor_h, display_monitor_hz, game_vram_dedicated_avg_mb, game_vram_dedicated_median_mb, game_vram_dedicated_max_mb, game_vram_shared_max_mb, game_ram_private_avg_mb, game_ram_private_median_mb, game_ram_private_max_mb, game_ram_ws_max_mb, game_commit_max_mb, game_memory_processes, game_memory_source, sensor_stats_json, time_below_30_pct, time_below_60_pct, time_below_refresh_pct, frametime_delta_mean_ms, vsync_present_pct, tearing_allowed_pct, avg_gpu_core_clock_mhz, avg_gpu_mem_clock_mhz, avg_gpu_fan_rpm, max_gpu_mem_temp, power_limit_pct, thermal_limit_pct, app_frames_per_joule, fg_mix) "
+ "VALUES (@session_guid, @game_id, @snapshot_id, @started_at, @ended_at, @duration_s, @qpc_epoch, @qpc_frequency, @capture_tier, @capture_mode, @capture_notes, @ac_exception_family, @late_attach, @telemetry_source, @overlay_build_id, @exit_status, @drain_ticks, @foreground_ticks, @records_before_attach, @dxgi_presents_before_hook, @gap_count, @guard_ticks_published, @launch_wait_ms, @api, @present_mode, @swap_effect, @hdr_flag, @hdr_source, @sync_interval_mode, @upscaler, @upscaler_quality, @upscaler_sharpness, @upscaler_driver_reported, @render_w, @render_h, @output_w, @output_h, @upscale_ratio, @settings_changed_midsession, @fg_mode, @fg_source, @fg_factor, @fg_driver_reported, @fg_runtime_census, @fg_none_withheld_reason, @fg_refusal, @fg_refusal_detail, @fg_factor_scope, @fg_steady_share, @presented_fps, @presented_qualifier, @dxgi_unseen_total, @dxgi_present_samples, @displayed_counted_by, @sl_tag_census, @sl_interposer_version, @runtime_modules, @driver_profile, @executable_markers, @ngx_driver_words, @rt_flag, @rt_source, @pt_flag, @pt_source, @pt_confidence, @rr_flag, @rr_source, @rt_frame_pct, @rays_per_pixel, @rt_pso_count, @rt_tier, @hooks_installed_mask, @raster_pso_count, @frame_count, @app_frame_count, @displayed_frame_count, @dropped_frames, @native_fps, @displayed_fps, @median_fps, @p1_low_fps, @p01_low_fps, @displayed_p1_low_fps, @min_fps, @max_fps, @frametime_stddev_ms, @stutter_count, @stutter_time_pct, @pso_stutter_pct, @reflex_active, @latency_avg_us, @latency_p95_us, @dropped_records, @fault_count, @data_quality_warnings, @writer_status_at_end, @early_stop_family, @loader_signals, @vram_proc_avg_mb, @vram_proc_max_mb, @vram_budget_exceeded_pct, @vram_adapter_max_mb, @avg_cpu_temp, @max_cpu_temp, @avg_gpu_temp, @max_gpu_temp, @max_gpu_hotspot, @avg_gpu_load, @avg_cpu_load, @avg_ram_mb, @avg_gpu_power_w, @throttle_pct, @display_exclusive_ms, @display_borderless_ms, @display_windowed_ms, @display_covers_ms, @display_minimized_ms, @display_nowindow_ms, @display_changes, @display_source, @display_window_w, @display_window_h, @display_buffer_w, @display_buffer_h, @display_monitor_w, @display_monitor_h, @display_monitor_hz, @game_vram_dedicated_avg_mb, @game_vram_dedicated_median_mb, @game_vram_dedicated_max_mb, @game_vram_shared_max_mb, @game_ram_private_avg_mb, @game_ram_private_median_mb, @game_ram_private_max_mb, @game_ram_ws_max_mb, @game_commit_max_mb, @game_memory_processes, @game_memory_source, @sensor_stats_json, @time_below_30_pct, @time_below_60_pct, @time_below_refresh_pct, @frametime_delta_mean_ms, @vsync_present_pct, @tearing_allowed_pct, @avg_gpu_core_clock_mhz, @avg_gpu_mem_clock_mhz, @avg_gpu_fan_rpm, @max_gpu_mem_temp, @power_limit_pct, @thermal_limit_pct, @app_frames_per_joule, @fg_mix) RETURNING id";
public const string Select = "SELECT id, session_guid, game_id, snapshot_id, started_at, ended_at, duration_s, qpc_epoch, qpc_frequency, capture_tier, capture_mode, capture_notes, ac_exception_family, late_attach, telemetry_source, overlay_build_id, exit_status, drain_ticks, foreground_ticks, records_before_attach, dxgi_presents_before_hook, gap_count, guard_ticks_published, launch_wait_ms, api, present_mode, swap_effect, hdr_flag, hdr_source, sync_interval_mode, upscaler, upscaler_quality, upscaler_sharpness, upscaler_driver_reported, render_w, render_h, output_w, output_h, upscale_ratio, settings_changed_midsession, fg_mode, fg_source, fg_factor, fg_driver_reported, fg_runtime_census, fg_none_withheld_reason, fg_refusal, fg_refusal_detail, fg_factor_scope, fg_steady_share, presented_fps, presented_qualifier, dxgi_unseen_total, dxgi_present_samples, displayed_counted_by, sl_tag_census, sl_interposer_version, runtime_modules, driver_profile, executable_markers, ngx_driver_words, rt_flag, rt_source, pt_flag, pt_source, pt_confidence, rr_flag, rr_source, rt_frame_pct, rays_per_pixel, rt_pso_count, rt_tier, hooks_installed_mask, raster_pso_count, frame_count, app_frame_count, displayed_frame_count, dropped_frames, native_fps, displayed_fps, median_fps, p1_low_fps, p01_low_fps, displayed_p1_low_fps, min_fps, max_fps, frametime_stddev_ms, stutter_count, stutter_time_pct, pso_stutter_pct, reflex_active, latency_avg_us, latency_p95_us, dropped_records, fault_count, data_quality_warnings, writer_status_at_end, early_stop_family, loader_signals, vram_proc_avg_mb, vram_proc_max_mb, vram_budget_exceeded_pct, vram_adapter_max_mb, avg_cpu_temp, max_cpu_temp, avg_gpu_temp, max_gpu_temp, max_gpu_hotspot, avg_gpu_load, avg_cpu_load, avg_ram_mb, avg_gpu_power_w, throttle_pct, display_exclusive_ms, display_borderless_ms, display_windowed_ms, display_covers_ms, display_minimized_ms, display_nowindow_ms, display_changes, display_source, display_window_w, display_window_h, display_buffer_w, display_buffer_h, display_monitor_w, display_monitor_h, display_monitor_hz, game_vram_dedicated_avg_mb, game_vram_dedicated_median_mb, game_vram_dedicated_max_mb, game_vram_shared_max_mb, game_ram_private_avg_mb, game_ram_private_median_mb, game_ram_private_max_mb, game_ram_ws_max_mb, game_commit_max_mb, game_memory_processes, game_memory_source, sensor_stats_json, time_below_30_pct, time_below_60_pct, time_below_refresh_pct, frametime_delta_mean_ms, vsync_present_pct, tearing_allowed_pct, avg_gpu_core_clock_mhz, avg_gpu_mem_clock_mhz, avg_gpu_fan_rpm, max_gpu_mem_temp, power_limit_pct, thermal_limit_pct, app_frames_per_joule FROM sessions";
public const string Select = "SELECT id, session_guid, game_id, snapshot_id, started_at, ended_at, duration_s, qpc_epoch, qpc_frequency, capture_tier, capture_mode, capture_notes, ac_exception_family, late_attach, telemetry_source, overlay_build_id, exit_status, drain_ticks, foreground_ticks, records_before_attach, dxgi_presents_before_hook, gap_count, guard_ticks_published, launch_wait_ms, api, present_mode, swap_effect, hdr_flag, hdr_source, sync_interval_mode, upscaler, upscaler_quality, upscaler_sharpness, upscaler_driver_reported, render_w, render_h, output_w, output_h, upscale_ratio, settings_changed_midsession, fg_mode, fg_source, fg_factor, fg_driver_reported, fg_runtime_census, fg_none_withheld_reason, fg_refusal, fg_refusal_detail, fg_factor_scope, fg_steady_share, presented_fps, presented_qualifier, dxgi_unseen_total, dxgi_present_samples, displayed_counted_by, sl_tag_census, sl_interposer_version, runtime_modules, driver_profile, executable_markers, ngx_driver_words, rt_flag, rt_source, pt_flag, pt_source, pt_confidence, rr_flag, rr_source, rt_frame_pct, rays_per_pixel, rt_pso_count, rt_tier, hooks_installed_mask, raster_pso_count, frame_count, app_frame_count, displayed_frame_count, dropped_frames, native_fps, displayed_fps, median_fps, p1_low_fps, p01_low_fps, displayed_p1_low_fps, min_fps, max_fps, frametime_stddev_ms, stutter_count, stutter_time_pct, pso_stutter_pct, reflex_active, latency_avg_us, latency_p95_us, dropped_records, fault_count, data_quality_warnings, writer_status_at_end, early_stop_family, loader_signals, vram_proc_avg_mb, vram_proc_max_mb, vram_budget_exceeded_pct, vram_adapter_max_mb, avg_cpu_temp, max_cpu_temp, avg_gpu_temp, max_gpu_temp, max_gpu_hotspot, avg_gpu_load, avg_cpu_load, avg_ram_mb, avg_gpu_power_w, throttle_pct, display_exclusive_ms, display_borderless_ms, display_windowed_ms, display_covers_ms, display_minimized_ms, display_nowindow_ms, display_changes, display_source, display_window_w, display_window_h, display_buffer_w, display_buffer_h, display_monitor_w, display_monitor_h, display_monitor_hz, game_vram_dedicated_avg_mb, game_vram_dedicated_median_mb, game_vram_dedicated_max_mb, game_vram_shared_max_mb, game_ram_private_avg_mb, game_ram_private_median_mb, game_ram_private_max_mb, game_ram_ws_max_mb, game_commit_max_mb, game_memory_processes, game_memory_source, sensor_stats_json, time_below_30_pct, time_below_60_pct, time_below_refresh_pct, frametime_delta_mean_ms, vsync_present_pct, tearing_allowed_pct, avg_gpu_core_clock_mhz, avg_gpu_mem_clock_mhz, avg_gpu_fan_rpm, max_gpu_mem_temp, power_limit_pct, thermal_limit_pct, app_frames_per_joule, fg_mix FROM sessions";
public static Dictionary<string, object?> Parameters(SessionRow s)
{
@@ -34,10 +34,11 @@ internal static class SessionRowColumns
Parameters4(d, s);
Parameters5(d, s);
Parameters6(d, s);
Parameters7(d, s);
return d;
}
public static SessionRow Read(DbDataReader r) => Read6(Read5(Read4(Read3(Read2(Read1(Read0(r), r), r), r), r), r), r);
public static SessionRow Read(DbDataReader r) => Read7(Read6(Read5(Read4(Read3(Read2(Read1(Read0(r), r), r), r), r), r), r), r);
private static void Parameters0(Dictionary<string, object?> d, SessionRow s)
@@ -405,6 +406,11 @@ internal static class SessionRowColumns
AppFramesPerJoule = D(r, "app_frames_per_joule"),
};
// Schema 0020 (beta.24, D62): every frame-generation state the session held, with its share (FgMixRecord's JSON).
private static void Parameters7(Dictionary<string, object?> d, SessionRow s) => d["fg_mix"] = s.FgMixJson;
private static SessionRow Read7(SessionRow row, DbDataReader r) => row with { FgMixJson = S(r, "fg_mix") };
public static string ExitStatusText(ExitStatus status) => Vocabulary.ExitStatusText(status);
public static ExitStatus ParseExitStatus(string text) => text switch
@@ -0,0 +1,193 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Globalization;
using System.Windows;
using FluentAssertions;
using FrameLedger.App.Charts;
using FrameLedger.App.Controls;
using FrameLedger.App.Services;
using FrameLedger.App.ViewModels;
using FrameLedger.Application.Persistence;
using FrameLedger.Application.Recording;
using FrameLedger.Domain.Metrics;
using FrameLedger.Domain.Sessions;
namespace FrameLedger.App.Tests;
/// <summary>
/// The summary's frame-generation mix (beta.24, D62) in words: each state with its factor, its own Native → Displayed and its
/// share to two decimals, then no frame generation, then the time no state claims — the stored rows, never recomputed; and
/// the bar those shares draw.
/// </summary>
[Collection(StringsCultureCollection.Name)]
public sealed class FgMixPresentationTests
{
private static T In<T>(string culture, Func<T> f)
{
CultureInfo? previous = Strings.Culture;
CultureInfo previousCulture = CultureInfo.CurrentCulture;
try
{
Strings.Culture = CultureInfo.GetCultureInfo(culture);
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(culture);
return f();
}
finally
{
Strings.Culture = previous;
CultureInfo.CurrentCulture = previousCulture;
}
}
private static string Mix(params FgMixRow[] rows) => FgMixRecord.ToJson(new FgMix(rows))!;
// The owner's example (2026-10-19): ×2 10%, ×3 25.75%, ×4 35.33%, then the time without frame generation.
private static readonly string _owners = Mix(
new FgMixRow(FgMixKind.Generated, 2.0, 62, 124, 60, 0.1, 12),
new FgMixRow(FgMixKind.Generated, 3.0, 60, 180, 154.5, 0.2575, 30),
new FgMixRow(FgMixKind.Generated, 4.0, 70.5, 282, 212, 0.3533, 42),
new FgMixRow(FgMixKind.None, null, 118, 118, 171, 0.285, 34),
new FgMixRow(FgMixKind.Unclassified, null, null, null, 2.5, 0.0042, 1));
private static SessionRow Hooked(string fgMode = "dlssg", double? factor = 1.9, string? refusal = null, string? mix = null, CaptureTier tier = CaptureTier.Hooked) => new()
{
SessionGuid = Guid.NewGuid(),
GameId = 1,
SnapshotId = 1,
StartedAt = DateTimeOffset.UnixEpoch,
EndedAt = DateTimeOffset.UnixEpoch.AddMinutes(10),
QpcEpoch = 0,
QpcFrequency = 1,
Tier = tier,
Mode = CaptureMode.Launch,
ExitStatus = ExitStatus.Normal,
FrameCount = 1000,
FgMode = fgMode,
FgFactor = factor,
FgRefusal = refusal,
FgMixJson = mix,
};
[Fact]
public void TheOwnersExampleReadsAsOneRowPerStateEachWithItsOwnRatesAndTwoDecimals() => In("en", () =>
{
IReadOnlyList<FgMixRowModel> rows = FgMixPresentation.Rows(Hooked(mix: _owners));
rows.Select(static r => r.Label).Should().Equal("×2.0 frame generation", "×3.0 frame generation", "×4.0 frame generation", "No frame generation", "Not classified");
rows.Select(static r => r.Share).Should().Equal("10.00%", "25.75%", "35.33%", "28.50%", "0.42%");
rows[0].Rates.Should().Be(Formats.Fps(62) + " → " + Formats.Fps(124) + " FPS", "a state's factor never stands without its Native and Displayed (rule 6)");
rows[2].Rates.Should().Be(Formats.Fps(70.5) + " → " + Formats.Fps(282) + " FPS");
rows[3].Rates.Should().Be(Formats.Fps(118) + " FPS", "no frame generation: what was rendered is what was shown");
rows[4].Rates.Should().BeEmpty("no state was read over that time, so it has no rate of its own");
rows[1].Duration.Should().Be(Formats.Duration(154.5));
rows.Select(static r => r.Segment.Kind).Should().Equal(FgMixKind.Generated, FgMixKind.Generated, FgMixKind.Generated, FgMixKind.None, FgMixKind.Unclassified);
rows.Select(static r => r.Segment.Factor).Should().Equal(2.0, 3.0, 4.0, null, null);
rows[2].Swatch.Should().ContainSingle().Which.Should().Be(new FgMixSegment(FgMixKind.Generated, 4.0, 1), "the swatch is the row's colour, filled");
FgMixPresentation.AccessibleName(rows).Should().Be("Share of the session's time by frame-generation state: ×2.0 frame generation 10.00%, "
+ "×3.0 frame generation 25.75%, ×4.0 frame generation 35.33%, No frame generation 28.50%, Not classified 0.42%");
return 0;
});
[Fact]
public void OneStateNoMixAndASessionThatWasNotHookedShowNoBlock()
{
FgMixPresentation.Rows(Hooked(mix: Mix(new FgMixRow(FgMixKind.Generated, 2.0, 60, 120, 600, 1, 120))))
.Should().BeEmpty("one state throughout is what the readout already says");
FgMixPresentation.Rows(Hooked()).Should().BeEmpty("no mix stored");
FgMixPresentation.Rows(Hooked(mix: "{not json")).Should().BeEmpty("a hand-edited column reads as none");
FgMixPresentation.Rows(Hooked(mix: _owners, tier: CaptureTier.NotHooked)).Should().BeEmpty("a session that was not hooked measured nothing");
}
[Fact]
public void AStateWithNoFactorAndAKindThisBuildDoesNotKnowReadAsNotClassified() => In("en", () =>
{
FgMixModel(new FgMixRecordRow("generated", null, 60, 120, 10, 0.5, 2)).Should().Be(("Not classified", FgMixKind.Unclassified));
FgMixModel(new FgMixRecordRow("dynamic", 3.0, 60, 180, 10, 0.5, 2)).Should().Be(("Not classified", FgMixKind.Unclassified), "a token from a later writer");
FgMixRecordRow.KindOf(null).Should().Be(FgMixKind.Unclassified);
FgMixRecordRow.KindOf("none").Should().Be(FgMixKind.None);
return 0;
static (string, FgMixKind) FgMixModel(FgMixRecordRow stored)
{
FgMixRowModel row = FgMixPresentation.Row(stored);
row.Rates.Should().BeEmpty();
return (row.Label, row.Segment.Kind);
}
});
[Fact]
public void AShareTooSmallToShowReadsAsUnderOneHundredthAndNeverAsZero()
{
In("en", () => FgMixPresentation.ShareText(0.35333)).Should().Be("35.33%");
In("en", () => FgMixPresentation.ShareText(0.00004)).Should().Be("<0.01%");
In("en", () => FgMixPresentation.ShareText(0.00006)).Should().Be("0.01%");
In("en", () => FgMixPresentation.ShareText(0)).Should().Be("0.00%");
In("en", () => FgMixPresentation.ShareText(1)).Should().Be("100.00%");
In("vi", () => FgMixPresentation.ShareText(0.2575)).Should().Be("25,75%", "the reader's own decimal separator");
In("vi", () => FgMixPresentation.ShareText(0.00001)).Should().Be("<0,01%");
}
[Fact]
public void ASessionWithoutAMixSaysWhyOnlyWhereOneCouldHaveBeenStored() => In("en", () =>
{
string notStored = Strings.FgMix_NotStored;
FgMixPresentation.Missing(Hooked()).Should().Be(notStored, "a counted factor, recorded before the mix was stored");
FgMixPresentation.Missing(Hooked(factor: null, refusal: "non_uniform")).Should().Be(notStored, "the count was refused only because the state changed");
FgMixPresentation.Missing(Hooked(factor: null, refusal: "ambiguous_band")).Should().Be(notStored);
FgMixPresentation.Missing(Hooked(factor: null, refusal: "not_counted")).Should().BeNull("the readout names that refusal; a mix was never possible");
FgMixPresentation.Missing(Hooked(fgMode: "none", factor: null)).Should().BeNull("no frame generation");
FgMixPresentation.Missing(Hooked(fgMode: "na", factor: null)).Should().BeNull("not measured");
FgMixPresentation.Missing(Hooked(tier: CaptureTier.NotHooked)).Should().BeNull("not hooked");
FgMixPresentation.Missing(Hooked(mix: _owners)).Should().BeNull("it has one");
notStored.Should().Contain("0.1.0-beta.24");
return 0;
});
[Fact]
public void TheExportLineIsTheSameInEveryLanguage()
{
string line = In("vi", () => FgMixPresentation.ExportLine(Hooked(mix: _owners)));
line.Should().Be("generated x2.00 10.00% native 62.0 displayed 124.0 60.0 s; generated x3.00 25.75% native 60.0 displayed 180.0 154.5 s; "
+ "generated x4.00 35.33% native 70.5 displayed 282.0 212.0 s; none 28.50% native 118.0 displayed 118.0 171.0 s; unclassified 0.42% 2.5 s");
FgMixPresentation.ExportLine(Hooked()).Should().Be("N/A");
}
[Fact]
public void TheBarDrawsEachShareInProportionWithAGapBetweenTwoSegments()
{
FgMixSegment[] segments = [new(FgMixKind.Generated, 2.0, 0.25), new(FgMixKind.None, null, 0), new(FgMixKind.Generated, 4.0, 0.75)];
IReadOnlyList<Rect> rects = FgMixBar.Layout(segments, 400 + FgMixBar.Gap, 14);
rects[0].Should().Be(new Rect(0, 0, 100, 14));
rects[1].Width.Should().Be(0, "a share of nothing draws nothing and takes no gap");
rects[2].Should().Be(new Rect(100 + FgMixBar.Gap, 0, 300, 14));
FgMixBar.Layout([new(FgMixKind.None, null, 1)], 12, 12).Should().Equal(new Rect(0, 0, 12, 12));
FgMixBar.Layout([new(FgMixKind.None, null, 0)], 100, 14).Should().OnlyContain(static r => r.Width == 0);
FgMixBar.Layout(segments, 0, 14).Should().OnlyContain(static r => r.Width == 0, "a bar not yet laid out");
FgMixBar.Layout([], 100, 14).Should().BeEmpty();
}
[Fact]
public void AStateTakesItsMultipliersColourSoTheSameFactorReadsTheSameInEverySession()
{
ScottPlot.Color[] c = [.. Enumerable.Range(1, 16).Select(static i => ScottPlot.Color.FromARGB((uint)(0xFF000000 | i)))];
var p = new ChartPalette(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10], c[11], c[12], c[13], c[14], c[15]);
p.MixFill(FgMixKind.Generated, 1.6).Should().Be(p.Native, "an FSR-style ×1.6 is the ×2 family");
p.MixFill(FgMixKind.Generated, 2.0).Should().Be(p.Native);
p.MixFill(FgMixKind.Generated, 2.6).Should().Be(p.Sensor);
p.MixFill(FgMixKind.Generated, 3.0).Should().Be(p.Sensor);
p.MixFill(FgMixKind.Generated, 4.0).Should().Be(p.Displayed);
p.MixFill(FgMixKind.Generated, 5.0).Should().Be(p.SensorSecondary);
p.MixFill(FgMixKind.Generated, 6.0).Should().Be(p.Percentile);
p.MixFill(FgMixKind.Generated, 8.0).Should().Be(p.SensorTertiary);
p.MixFill(FgMixKind.None, null).Should().Be(p.MixNone);
p.MixFill(FgMixKind.Unclassified, null).Should().Be(p.MixUnclassified);
p.ByKey("Chart_MixNone").Should().Be(p.MixNone);
p.ByKey("Chart_MixUnclassified").Should().Be(p.MixUnclassified);
Enumerable.Range(0, 80).Select(i => p.MixFill(FgMixKind.Generated, 1.5 + (i * 0.1)))
.Should().NotContain(fill => fill == p.Stutter || fill == p.StutterPso, "a state is never drawn in the stutter colours");
}
}
@@ -105,4 +105,68 @@ public sealed class NvidiaOverridesTests
[InlineData(0u)]
[InlineData(27u)]
public void AnOffOrUnknownPresetSaysNothing(uint value) => NvidiaOverrides.Preset(value).Should().BeNull();
/// <summary>
/// beta.24 (D62): the frame-generation block's context line, in the NVIDIA App's own terms (its Frame Generation Mode
/// dialog, owner's screenshot 2026-10-19: Dynamic with Target FPS and Multiplier "Up to 6x", or Fixed) — configuration
/// above the measured rows, never one of them.
/// </summary>
[Fact]
public void TheFrameGenerationContextSaysHowTheNvidiaAppSetItInItsOwnTerms() => InEnglish(() =>
{
NvidiaOverrides.FrameGenerationContext(Profile(DriverProfileOutcome.Application,
(S.DlssgMode, 4), (S.DlssgDynamicMultiFrameCountMax, 5), (S.DlssgDynamicTargetFrameRate, S.DynamicTargetAuto)))
.Should().Be("Set in the NVIDIA App: Dynamic, up to ×6, target: max refresh rate", "5 generated frames per rendered one is the App's \"Up to 6x\"");
NvidiaOverrides.FrameGenerationContext(Profile(DriverProfileOutcome.Application,
(S.DlssgMode, 4), (S.DlssgDynamicTargetFrameRate, 120)))
.Should().Be("Set in the NVIDIA App: Dynamic, target 120 FPS", "no ceiling stored: none is named");
NvidiaOverrides.FrameGenerationContext(Profile(DriverProfileOutcome.Application,
(S.DlssgMode, 4), (S.DlssgDynamicMultiFrameCountMax, 16), (S.DlssgDynamicTargetFrameRate, 0x0200_0000)))
.Should().Be("Set in the NVIDIA App: Dynamic", "a value outside the header's ranges is left out, never guessed");
NvidiaOverrides.FrameGenerationContext(Profile(DriverProfileOutcome.Application, (S.DlssgMode, 2), (S.DlssgMultiFrameCount, 3)))
.Should().Be("Set in the NVIDIA App: Fixed ×4");
NvidiaOverrides.FrameGenerationContext(Profile(DriverProfileOutcome.Global, (S.DlssgMultiFrameCount, 5)))
.Should().Be("Set in the NVIDIA App: Fixed ×6", "a multiplier with the mode unset is the Fixed one");
NvidiaOverrides.FrameGenerationContext(Profile(DriverProfileOutcome.Application, (S.DlssgMode, 2)))
.Should().Be("Set in the NVIDIA App: frame generation on");
NvidiaOverrides.FrameGenerationContext(Profile(DriverProfileOutcome.Application, (S.DlssgMode, 1), (S.DlssgMultiFrameCount, 3)))
.Should().Be("Set in the NVIDIA App: frame generation off");
NvidiaOverrides.FrameGenerationContext(Profile(DriverProfileOutcome.Application, (S.DlssgMode, 3)))
.Should().Be("Set in the NVIDIA App: automatic");
NvidiaOverrides.FrameGenerationContext(Profile(DriverProfileOutcome.Application, (S.DlssgMode, 3), (S.DlssgMultiFrameCount, 2)))
.Should().Be("Set in the NVIDIA App: automatic, ×3");
return 0;
});
[Fact]
public void WithNoFrameGenerationSettingTheGameDecidedAndWithNoProfileNothingIsSaid() => InEnglish(() =>
{
NvidiaOverrides.FrameGenerationContext(Profile(DriverProfileOutcome.Application, (S.DlssgMode, 0), (S.DlssgMultiFrameCount, null), (S.DlssSrOverride, 1)))
.Should().Be("Set in the game — no NVIDIA App frame-generation override", "Use 3D app setting: the game's own menu chose");
NvidiaOverrides.FrameGenerationContext(Profile(DriverProfileOutcome.Degraded)).Should().BeNull("no NVIDIA driver answered");
NvidiaOverrides.FrameGenerationContext(null).Should().BeNull("a row from before beta.8");
NvidiaOverrides.FrameGenerationContext("{broken").Should().BeNull();
return 0;
});
[Fact]
public void AValueTheDriverShipsInItsOwnProfileIsNotCalledTheUsersChoice() => InEnglish(() =>
{
string shipped = DriverProfileRecord.Serialize(new DriverProfileReading
{
Outcome = DriverProfileOutcome.Application,
ProfileName = "A game NVIDIA profiles",
Settings = [new DriverSettingReading(S.DlssgMode, 2, DriverSettingLocation.Profile, true), new DriverSettingReading(S.DlssgMultiFrameCount, 1, DriverSettingLocation.Profile, true)],
})!;
NvidiaOverrides.FrameGenerationContext(shipped).Should().Be("Set by the NVIDIA driver's own profile for the game: Fixed ×2");
string mixed = DriverProfileRecord.Serialize(new DriverProfileReading
{
Outcome = DriverProfileOutcome.Application,
ProfileName = "A game NVIDIA profiles",
Settings = [new DriverSettingReading(S.DlssgMode, 2, DriverSettingLocation.Profile, true), new DriverSettingReading(S.DlssgMultiFrameCount, 3, DriverSettingLocation.Profile, false)],
})!;
NvidiaOverrides.FrameGenerationContext(mixed).Should().Be("Set in the NVIDIA App: Fixed ×4", "one value someone set makes it the user's");
return 0;
});
}
@@ -62,7 +62,15 @@ public sealed partial class PagesLoadTests
GameRow game = await s.GameAsync("Alpha").ConfigureAwait(false);
await s.SessionAsync(game.Id, DateTimeOffset.UtcNow.AddHours(-1), fgMode: "dlssg", native: 62, displayed: 118, factor: 1.9).ConfigureAwait(false);
await s.SessionAsync(game.Id, DateTimeOffset.UtcNow.AddHours(-3), hooked: false).ConfigureAwait(false);
long withFrames = await s.SessionWithFramesAsync(game.Id, DateTimeOffset.UtcNow.AddHours(-5), frames: 600, spikeEvery: 200).ConfigureAwait(false);
// beta.24 (D62): the summary's session carries a frame-generation mix, so its block is drawn and read in both themes.
string mix = Application.Recording.FgMixRecord.ToJson(new Domain.Metrics.FgMix(
[
new Domain.Metrics.FgMixRow(Domain.Metrics.FgMixKind.Generated, 2.0, 62, 124, 2, 0.2, 1),
new Domain.Metrics.FgMixRow(Domain.Metrics.FgMixKind.Generated, 4.0, 60, 240, 5, 0.5, 1),
new Domain.Metrics.FgMixRow(Domain.Metrics.FgMixKind.None, null, 118, 118, 2, 0.2, 1),
new Domain.Metrics.FgMixRow(Domain.Metrics.FgMixKind.Unclassified, null, null, null, 1, 0.1, 1),
]))!;
long withFrames = await s.SessionWithFramesAsync(game.Id, DateTimeOffset.UtcNow.AddHours(-5), frames: 600, spikeEvery: 200, shape: r => r with { FgMixJson = mix }).ConfigureAwait(false);
var surfaces = new Surfaces(s);
await surfaces.LoadPagesAsync(game.Id).ConfigureAwait(false);
surfaces.Summary = new SessionSummaryViewModel(s.Sessions, s.Games, s.Annotations, new SqliteHardwareSnapshotRepository(s.Db),
+2 -1
View File
@@ -93,7 +93,7 @@ internal sealed class ScratchLedger : IAsyncDisposable
]);
/// <summary>A hooked session WITH blobs: <paramref name="frames"/> presents at 60 fps, a 4× spike every <paramref name="spikeEvery"/> frames, one segment, a gpu_temp series.</summary>
public async Task<long> SessionWithFramesAsync(long gameId, DateTimeOffset startedAt, int frames, int spikeEvery)
public async Task<long> SessionWithFramesAsync(long gameId, DateTimeOffset startedAt, int frames, int spikeEvery, Func<SessionRow, SessionRow>? shape = null)
{
long snapshotId = await new SqliteHardwareSnapshotRepository(Db).EnsureAsync(new HardwareSnapshot { GpuName = "G" }, startedAt, TestContext.Current.CancellationToken).ConfigureAwait(false);
var frametimes = new float[frames];
@@ -108,6 +108,7 @@ internal sealed class ScratchLedger : IAsyncDisposable
double seconds = frametimes.Sum() / 1000.0;
SessionRow row = HookedRow(gameId, snapshotId, startedAt, frames, spikeEvery, seconds);
row = shape is null ? row : shape(row);
return await Sessions.InsertFinalizedAsync(new FinalizedSession
{
Row = row,
@@ -8,6 +8,8 @@ using FluentAssertions;
using FrameLedger.App.Charts;
using FrameLedger.App.Services;
using FrameLedger.Application.Persistence;
using FrameLedger.Application.Recording;
using FrameLedger.Domain.Metrics;
using FrameLedger.Domain.Sessions;
namespace FrameLedger.App.Tests;
@@ -75,6 +77,7 @@ public sealed class SessionExporterTests
lines.Should().Contain("# display: N/A (not recorded: a session recorded before beta.10, or recovered from its crash file)");
lines.Should().Contain("# game_memory: vram_dedicated_mb avg=1000 median=1024 max=2048; vram_shared_mb max=N/A; ram_private_ws_mb avg=N/A median=N/A max=N/A; ram_ws_mb max=N/A; commit_mb max=N/A; processes=1; source=counters",
"a Tier-2 session has the game's memory too (beta.12): a header line, the session's figure, never a per-frame column");
lines.Should().Contain("# fg_mix: N/A", "beta.24: a session with no stored mix says so");
SessionExportDocument doc = SessionExporter.Document(row, game, null, [], await s.Annotations.FindAsync(id, Ct));
using var stream = new MemoryStream();
@@ -90,6 +93,30 @@ public sealed class SessionExporterTests
_ = CaptureTier.NotHooked;
}
/// <summary>beta.24 (D62): the CSV's <c># fg_mix:</c> line is every stored row, invariant; the JSON's aggregates carry the column.</summary>
[Fact]
public async Task TheFgMixHeaderLineIsEveryStoredRowAndTheJsonCarriesTheColumn()
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
GameRow game = await s.GameAsync("Alpha");
string mix = FgMixRecord.ToJson(new FgMix([
new FgMixRow(FgMixKind.Generated, 4.0, 70.5, 282, 90, 0.75, 18),
new FgMixRow(FgMixKind.None, null, 118, 118, 30, 0.25, 6),
]))!;
long id = await s.SessionAsync(game.Id, DateTimeOffset.UtcNow, fgMode: "dlssg", native: 70.5, displayed: 282, factor: 4.0, shape: r => r with { FgMixJson = mix });
SessionRow row = (await s.Sessions.FindByIdAsync(id, Ct))!;
using var writer = new StringWriter();
SessionExporter.WriteCsv(writer, row, game, null, [], null);
writer.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries)
.Should().Contain("# fg_mix: generated x4.00 75.00% native 70.5 displayed 282.0 90.0 s; none 25.00% native 118.0 displayed 118.0 30.0 s");
using var stream = new MemoryStream();
SessionExporter.WriteJson(stream, SessionExporter.Document(row, game, null, [], null));
using JsonDocument json = JsonDocument.Parse(stream.ToArray());
json.RootElement.GetProperty("aggregates").GetProperty("fg_mix_json").GetString().Should().Be(mix);
}
/// <summary>beta.10: the CSV's <c># display:</c> line is the stored milliseconds by name, invariant in every UI language.</summary>
[Fact]
public async Task TheDisplayHeaderLineIsTheStoredMillisecondsByName()
@@ -164,6 +164,73 @@ public sealed class SessionSummaryViewModelTests
}
}
/// <summary>
/// beta.24 (D62): the stored mix as a block — a row per state with its own Native → Displayed and its share, the time with
/// no frame generation, the time no state claims —, the NVIDIA App setting above it, and for a session that counted frame
/// generation before the mix was stored, one line saying so rather than an empty block.
/// </summary>
[Fact]
public async Task TheStoredMixIsShownWithItsSettingAndAnOlderSessionSaysItHasNone()
{
CultureInfo? previous = Strings.Culture;
CultureInfo previousCulture = CultureInfo.CurrentCulture;
Strings.Culture = CultureInfo.GetCultureInfo("en");
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("en");
try
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
GameRow game = await s.GameAsync("Gamma");
string mix = Application.Recording.FgMixRecord.ToJson(new FgMix(
[
new FgMixRow(FgMixKind.Generated, 2.0, 62, 124, 120, 0.2, 24),
new FgMixRow(FgMixKind.Generated, 6.0, 48, 288, 360, 0.6, 72),
new FgMixRow(FgMixKind.Unclassified, null, null, null, 120, 0.2, 24),
]))!;
string profile = Application.Recording.DriverProfileRecord.Serialize(new Application.Capture.DriverProfileReading
{
Outcome = Application.Capture.DriverProfileOutcome.Application,
ProfileName = "Gamma",
Settings =
[
new Application.Capture.DriverSettingReading(Application.Capture.NvidiaDriverSettings.DlssgMode, 4, Application.Capture.DriverSettingLocation.Profile, false),
new Application.Capture.DriverSettingReading(Application.Capture.NvidiaDriverSettings.DlssgDynamicMultiFrameCountMax, 5, Application.Capture.DriverSettingLocation.Profile, false),
],
})!;
long withMix = await s.SessionAsync(game.Id, DateTimeOffset.UtcNow, fgMode: "dlssg", native: 48, displayed: 288, factor: 6.0, shape: r => r with
{
FgFactorScope = "steady",
FgSteadyShare = 0.6,
FgMixJson = mix,
DriverProfileJson = profile,
});
long older = await s.SessionAsync(game.Id, DateTimeOffset.UtcNow.AddHours(-1), fgMode: "dlssg", native: 60, displayed: 118, factor: 1.97);
SessionSummaryViewModel vm = Build(s);
await vm.LoadAsync(withMix, Ct);
vm.HasFgMix.Should().BeTrue();
vm.FgMix.Select(static r => r.Label).Should().Equal("×2.0 frame generation", "×6.0 frame generation", "Not classified");
vm.FgMix.Select(static r => r.Share).Should().Equal("20.00%", "60.00%", "20.00%");
vm.FgMixSegments.Select(static g => g.Share).Should().Equal(0.2, 0.6, 0.2);
vm.FgMixContext.Should().Be("Set in the NVIDIA App: Dynamic, up to ×6");
vm.FgMixUnclassifiedNote.Should().Be(Strings.FgMix_Unclassified_Note);
vm.FgMixName.Should().StartWith("Share of the session's time by frame-generation state: ×2.0 frame generation 20.00%");
vm.FgMixMissing.Should().BeNull();
await vm.LoadAsync(older, Ct);
vm.HasFgMix.Should().BeFalse("the block is cleared, not left from the session before");
vm.FgMix.Should().BeEmpty();
vm.FgMixSegments.Should().BeEmpty();
vm.FgMixContext.Should().BeNull();
vm.FgMixUnclassifiedNote.Should().BeNull();
vm.FgMixMissing.Should().Be(Strings.FgMix_NotStored, "it counted frame generation before the mix was stored");
}
finally
{
Strings.Culture = previous;
CultureInfo.CurrentCulture = previousCulture;
}
}
/// <summary>A session recorded before beta.14 has none of schema 0019's values: every new card reads N/A, never a zero.</summary>
[Fact]
public async Task ARowRecordedBeforeBetaFourteenReadsNotAvailableOnTheNewCards()
@@ -58,7 +58,8 @@ public sealed class MetricEnumMirrorTests
// A new enum in Domain.Metrics that mirrors nothing is fine; one that mirrors a Shared enum and is
// not in the table above would be a mirror nobody checks. Enumerate Domain.Metrics' enums and
// require each to be either paired or explicitly local.
string[] local = [nameof(Tri), nameof(FgRefusalKind), nameof(FgRefusalSubject)];
// FgMixKind (beta.24, D62): a row of the stored mix — Domain's own, read by no native code.
string[] local = [nameof(Tri), nameof(FgRefusalKind), nameof(FgRefusalSubject), nameof(FgMixKind)];
IEnumerable<string> enums = typeof(FrameSample).Assembly.GetTypes()
.Where(t => t.IsEnum && string.Equals(t.Namespace, typeof(FrameSample).Namespace, StringComparison.Ordinal))
.Select(t => t.Name);
@@ -118,11 +118,27 @@ public sealed class SessionAggregatorTests
row.FgRefusalDetail.Should().NotBeNull();
row.DisplayedCountedBy.Should().Be("hook");
// beta.24 (D62): beside the steady state, every state the session held, each with its share.
FgMixRecord mix = FgMixRecord.Parse(row.FgMixJson)!;
FgMixRecordRow generated = mix.Rows.Should().ContainSingle(static r => r.Kind == "generated").Subject;
generated.Factor.Should().BeApproximately(2.0, 0.01);
generated.Share.Should().BeApproximately(row.FgSteadyShare!.Value, 1e-9, "the longest state of the mix is the steady state");
mix.Rows.Sum(static r => r.Share).Should().BeApproximately(1.0, 1e-9);
mix.Rows.Should().HaveCountGreaterThan(1, "the menu's time is a row of its own");
// A uniform session is scoped 'session' and carries no share.
SessionRow uniform = SessionAggregator.Aggregate(SessionFixtures.Skeleton(), SessionFixtures.Hooked(SessionFixtures.Stream(2_000, claims, fgPerBatch: 2), writer)).Row;
uniform.FgFactorScope.Should().Be("session");
uniform.FgSteadyShare.Should().BeNull();
uniform.FgRefusal.Should().BeNull();
FgMixRecord.Parse(uniform.FgMixJson)!.Rows[0].Kind.Should().Be("generated", "a uniform session's mix is its one state");
// Nothing counted: no mix, as no factor.
SessionRow uncounted = SessionAggregator.Aggregate(SessionFixtures.Skeleton(), SessionFixtures.Hooked(SessionFixtures.Stream(2_000, _presentOnly, fgPerBatch: 2), writer)).Row;
uncounted.FgMixJson.Should().BeNull();
FgMixRecord.Parse("not json").Should().BeNull("a hand-edited column reads as none, never as an exception");
FgMixRecord.Parse(null).Should().BeNull();
FgMixRecord.ToJson(null).Should().BeNull();
}
[Fact]
@@ -0,0 +1,173 @@
// 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;
using static FrameLedger.Domain.Tests.Metrics.SampleFixtures;
namespace FrameLedger.Domain.Tests.Metrics;
/// <summary>
/// beta.24 (decision D62): every frame-generation state a session held, each with its share of the presenting time —
/// the steady state's windows, all of them. 240 presents per second in these fixtures, as in
/// <see cref="FgSteadyStateTests"/>, so five seconds is 1,200 presents.
/// </summary>
public sealed class FgMixTests
{
private const int _presentsPerSecond = 240;
private static List<FrameSample> Play(int seconds, int k) =>
FgStream(appFrames: seconds * _presentsPerSecond / k, k: k);
private static List<FrameSample> Concat(params List<FrameSample>[] runs)
{
List<FrameSample> all = runs[0];
for (int i = 1; i < runs.Length; i++)
{
all = SampleFixtures.Concat(all, runs[i]);
}
return all;
}
private static void AddsUpToTheWhole(FgMix mix) =>
mix.Rows.Sum(static r => r.Share).Should().BeApproximately(1.0, 1e-9, "every window lands in exactly one row");
[Fact]
public void MenusThenTwoThreeAndFourTimesAreFourRowsInOrder()
{
FgMix mix = FgMix.From(Concat(Play(20, 1), Play(30, 2), Play(40, 3), Play(50, 4)), Frequency, noneAllowed: true)!;
mix.Rows.Select(static r => r.Kind).Should().Equal(FgMixKind.Generated, FgMixKind.Generated, FgMixKind.Generated, FgMixKind.None);
mix.Rows[0].Factor.Should().BeApproximately(2.0, 0.02);
mix.Rows[1].Factor.Should().BeApproximately(3.0, 0.02);
mix.Rows[2].Factor.Should().BeApproximately(4.0, 0.02);
mix.Rows[0].Share.Should().BeApproximately(30.0 / 140, 0.03);
mix.Rows[1].Share.Should().BeApproximately(40.0 / 140, 0.03);
mix.Rows[2].Share.Should().BeApproximately(50.0 / 140, 0.03);
mix.Rows[3].Share.Should().BeApproximately(20.0 / 140, 0.03);
mix.Rows[3].Factor.Should().BeNull("no frame generation has no factor to show");
mix.Rows[3].DisplayedFps.Should().BeApproximately(240, 3);
foreach (FgMixRow state in mix.Rows.Take(3))
{
(state.NativeFps!.Value * state.Factor!.Value).Should().BeApproximately(state.DisplayedFps!.Value, 1, "each state's rates are its own, counted independently");
}
AddsUpToTheWhole(mix);
}
[Fact]
public void TheLongestStateIsTheSteadyState()
{
List<FrameSample> session = Concat(Play(20, 1), Play(30, 3), Play(60, 4));
FgMix mix = FgMix.From(session, Frequency, noneAllowed: true)!;
FgSteadyState steady = FgWindow.From(session, Frequency).Steady!;
FgMixRow longest = mix.Rows.Where(static r => r.Kind == FgMixKind.Generated).MaxBy(static r => r.Seconds)!;
longest.Factor.Should().Be(steady.Factor);
longest.Share.Should().Be(steady.Share);
longest.Windows.Should().Be(steady.Windows);
}
[Fact]
public void FiveAndSixTimesStayApart()
{
FgMix mix = FgMix.From(Concat(Play(30, 5), Play(30, 6)), Frequency, noneAllowed: true)!;
mix.Rows.Where(static r => r.Kind == FgMixKind.Generated).Select(static r => Math.Round(r.Factor!.Value)).Should().Equal(5, 6);
AddsUpToTheWhole(mix);
}
[Fact]
public void ABurstShorterThanTenSecondsIsNotAState()
{
FgMix mix = FgMix.From(Concat(Play(60, 2), Play(6, 4)), Frequency, noneAllowed: true)!;
mix.Rows.Select(static r => r.Kind).Should().Equal(FgMixKind.Generated, FgMixKind.Unclassified);
mix.Rows[0].Factor.Should().BeApproximately(2.0, 0.02);
mix.Rows[1].Seconds.Should().BeApproximately(6, 2);
mix.Rows[1].NativeFps.Should().BeNull("time no state claims has no rate to show");
AddsUpToTheWhole(mix);
}
[Fact]
public void WhereACountedNoneIsWithheldItsWindowsAreUnclassified()
{
List<FrameSample> session = Concat(Play(20, 1), Play(40, 4));
FgMix.From(session, Frequency, noneAllowed: true)!.Rows.Select(static r => r.Kind).Should().Equal(FgMixKind.Generated, FgMixKind.None);
FgMix withheld = FgMix.From(session, Frequency, noneAllowed: false)!;
withheld.Rows.Select(static r => r.Kind).Should().Equal(FgMixKind.Generated, FgMixKind.Unclassified);
withheld.Rows[1].Share.Should().BeApproximately(1.0 / 3, 0.03);
}
[Fact]
public void NoTokensAndABandFactorAreUnclassified()
{
List<FrameSample> noTokens = FgStream(appFrames: 15 * _presentsPerSecond, k: 1, evalsPerFrame: 0);
// Four presents for three application frames: 1.33, between none and generating.
List<FrameSample> band = FgStream(appFrames: 15 * _presentsPerSecond / 4, k: 4, evalsPerFrame: 3);
FgMix mix = FgMix.From(Concat(noTokens, band, Play(40, 2)), Frequency, noneAllowed: true)!;
mix.Rows.Select(static r => r.Kind).Should().Equal(FgMixKind.Generated, FgMixKind.Unclassified);
mix.Rows[1].Seconds.Should().BeApproximately(30, 2);
AddsUpToTheWhole(mix);
}
[Fact]
public void AFactorThatWandersStillAddsUpAndNamesNoFactorItNeverHad()
{
// Dynamic frame generation: the multiplier moves every two seconds.
var runs = new List<List<FrameSample>>();
for (int i = 0; i < 30; i++)
{
runs.Add(Play(2, 2 + (i % 5)));
}
FgMix? mix = FgMix.From(Concat([.. runs]), Frequency, noneAllowed: true);
if (mix is not null)
{
AddsUpToTheWhole(mix);
mix.Rows.Where(static r => r.Kind == FgMixKind.Generated).Should().OnlyContain(static r => r.Factor >= 2 && r.Factor <= 6);
}
}
[Fact]
public void ASessionWithNoStateHasNoMix()
{
FgMix.From(Play(60, 1), Frequency, noneAllowed: true).Should().BeNull("no frame-generation state, nothing to split");
FgMix.From(FgStream(appFrames: 1_000, k: 2, counted: false), Frequency, noneAllowed: true).Should().BeNull("nothing counted application frames");
FgMix.From(Play(60, 2).Take(1).ToList(), Frequency, noneAllowed: true).Should().BeNull("one sample spans no time");
}
[Fact]
public void AWindowThatLastsNoTimeMakesNoRow()
{
List<FrameSample> session = Play(60, 2);
ulong boundary = session[0].Qpc + (ulong)(60 * Frequency);
// One sample opening a new window, and eight at one instant that read none: both last no time.
session.Add(session[^1] with { Qpc = boundary, FgEvaluations = 1 });
FgMix lonely = FgMix.From(session, Frequency, noneAllowed: true)!;
lonely.Rows.Should().ContainSingle().Which.Share.Should().Be(1.0);
List<FrameSample> instant = Play(60, 2);
for (int i = 0; i < FgWindow.MinPerBucket; i++)
{
instant.Add(instant[^1] with { Qpc = boundary, FgEvaluations = 1 });
}
FgMix.From(instant, Frequency, noneAllowed: true)!.Rows.Should().ContainSingle();
}
[Fact]
public void ItChecksItsArguments()
{
Action nullSamples = () => FgMix.From(null!, Frequency, noneAllowed: true);
nullSamples.Should().Throw<ArgumentNullException>();
Action noClock = () => FgMix.From(Play(10, 2), 0, noneAllowed: true);
noClock.Should().Throw<ArgumentOutOfRangeException>();
}
}
@@ -225,6 +225,46 @@ public sealed class LedgerDatabaseTests
}
}
/// <summary>
/// Schema 0020 (2026-10-19, beta.24, D62): <c>sessions.fg_mix</c>, every frame-generation state a session held, as JSON
/// — ADD COLUMN only; a session written before has none and is never rebuilt from its stored frames.
/// </summary>
[Fact]
public async Task ScriptTwentyAddsTheFgMixColumnAndAnEarlierSessionHasNone()
{
await using LedgerFixture f = await LedgerFixture.OpenAsync();
MigrationRunner.LatestVersion.Should().BeGreaterThanOrEqualTo(20);
long gameId = (await new SqliteGameRepository(f.Db).EnsureAsync(
new() { ExePath = @"C:\Games\M\m.exe", SizeBytes = 1, MtimeUnixMs = 2 }, "M", Ct).ConfigureAwait(true)).Id;
long snapshotId = await new SqliteHardwareSnapshotRepository(f.Db).EnsureAsync(new HardwareSnapshot { GpuName = "g" }, DateTimeOffset.UnixEpoch, Ct)
.ConfigureAwait(true);
string path = f.Path;
await f.Db.DisposeAsync().ConfigureAwait(true);
var c19 = new SqliteConnection(new SqliteConnectionStringBuilder { DataSource = path, Pooling = false }.ToString());
await using (c19.ConfigureAwait(true))
{
await c19.OpenAsync(Ct).ConfigureAwait(true);
await RewindToAsync(c19, 19).ConfigureAwait(true);
await c19.ExecuteAsync(new CommandDefinition(
"INSERT INTO sessions (session_guid, game_id, snapshot_id, started_at, ended_at, duration_s, qpc_epoch, qpc_frequency, capture_tier, capture_mode, exit_status, frame_count, app_frame_count, displayed_frame_count, dropped_frames, fg_mode, fg_factor, fg_factor_scope, fg_steady_share) "
+ "VALUES ('00000000-0000-0000-0000-000000000020', @gameId, @snapshotId, 0, 60000, 60, 0, 10000000, 1, 'attach', 'normal', 6000, 1500, 6000, 0, 'dlssg', 4.0, 'steady', 0.75)",
new { gameId, snapshotId }, cancellationToken: Ct)).ConfigureAwait(true);
}
LedgerDatabase migrated = await LedgerDatabase.OpenAsync(path, ct: Ct).ConfigureAwait(true);
await using (migrated.ConfigureAwait(true))
{
migrated.SchemaVersion.Should().Be(MigrationRunner.LatestVersion);
IReadOnlyList<string> added = await migrated.ReadAsync(async (c, ct) => (IReadOnlyList<string>)[.. await c.QueryAsync<string>(new CommandDefinition(
"SELECT name FROM pragma_table_info('sessions') WHERE name = 'fg_mix' AND type = 'TEXT'", cancellationToken: ct)).ConfigureAwait(false)], Ct).ConfigureAwait(true);
added.Should().ContainSingle();
SessionRow before = (await new SqliteSessionRepository(migrated).FindAsync(Guid.Parse("00000000-0000-0000-0000-000000000020"), Ct).ConfigureAwait(true))!;
before.FgFactor.Should().Be(4.0, "the row keeps everything it had");
before.FgSteadyShare.Should().Be(0.75);
before.FgMixJson.Should().BeNull("a session recorded before beta.24 has no mix, and is not rebuilt from its frames");
}
}
/// <summary>
/// Schema 0017 (2026-10-03, beta.11, D38): <c>games.ac_exception_trial_failed_at</c>, NULL on every row written before — a
/// grant made under D33 keeps everything it had and carries no failed trial.
@@ -107,6 +107,7 @@ public sealed class SqliteSessionRepositoryTests
PowerLimitPct = 33.25,
ThermalLimitPct = 2.5,
AppFramesPerJoule = 0.3125,
FgMixJson = "{\"Rows\":[{\"Kind\":\"generated\",\"Factor\":3.99,\"NativeFps\":70.5,\"DisplayedFps\":281.3,\"Seconds\":120,\"Share\":0.75,\"Windows\":24}]}",
};
private static FrameBlobs Frames(int n) => new()