Skip to content

icd_shim: spend generation leftover as a rate, not a ratio of whole frames - #71

Merged
joshuatam merged 1 commit into
masterfrom
fix/lsfg-generation-rate
Nov 21, 2026
Merged

joshuatam merged 1 commit into
masterfrom
fix/lsfg-generation-rate

Conversation

@joshuatam

@joshuatam joshuatam commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

What this is

Generation's leftover is a rate, not a ratio of whole frames. The eight rows of limits() already match docs/10's table, so the ceiling was never wrong — the divergence was one step later: generate_per_source floored generate / acquire to whole frames per source, and every ceiling below one frame per source became zero.

The floor ate the leftover

At 60 Hz, cap 40, ×2 the panel leaves 20 generated against 40 source frames — one every other source frame — and the flooring produced none. So frame generation did nothing at any cap above half the refresh, while the panel still had room. That is not what the table's total column promises.

Measured on Nova at 120 Hz, cap 70, ×2: cap=70 acquire=70 generate=70, so the leftover 120 − 70 = 50 was reachable in principle and unreachable in fact.

setting table total before after
cap 70 ×2, 120 Hz 70 + 50 = 120 70 + 0 = 70 70 + 50 = 120
cap 40 ×2, 60 Hz 40 + 20 = 60 40 + 0 = 40 40 + 20 = 60

The change

generate_batch(m, &mut credit) carries the remainder across source frames in units of one source frame, so a rate that is not a whole frame per source is still spent. The multiplier's m − 1 stays the per-frame bound. The credit lives on GnSwapchain, one per swapchain, since it is that stream being spaced.

docs/10's paragraph about the leftover says it floors to none and generation therefore does nothing above half the refresh; that is corrected in the same change.

Verified

  • 130 tests pass, cargo clippy --all-targets -D warnings clean.
  • The test that pinned the flooring as intended behaviour now asserts the leftover is spent: 20 generated over 40 source frames, 0 only above the panel. Two new tests pin the 0,1,0,1,… sequence and cap 70 on 120 Hz yielding 50 in 70.
  • Not yet measured on a device: the census after a build should show generated frames at a cap above half the refresh where it previously showed none.

… frames

The eight rows of `limits()` already match docs/10's table, so the ceiling was
right and the divergence was one step later: `generate_per_source` floored
`generate / acquire` to whole frames per source, which turned every ceiling below
one frame per source into zero.

At 60 Hz, cap 40, ×2 the panel leaves 20 generated against 40 source frames --
one every other source frame -- and the flooring produced none. So frame
generation did nothing at any cap above half the refresh while the panel still had
room, which is not what the table's total column promises. Measured on Nova at
120 Hz, cap 70, ×2: `cap=70 acquire=70 generate=70`, and the leftover
`120 - 70 = 50` was reachable in principle and unreachable in fact.

`generate_batch(m, &mut credit)` carries the remainder across source frames in
units of one source frame, so a rate that is not a whole frame per source is still
spent: cap 70 on 120 Hz yields 50 generated over 70 source frames, cap 40 on 60 Hz
yields 0,1,0,1,..., and the multiplier's `m - 1` remains the per-frame bound. The
credit lives on `GnSwapchain`, one per swapchain, since it is the swapchain's
stream being spaced.

Tests are rewritten rather than deleted: the one that pinned the flooring as
intended behaviour now asserts the leftover is spent (`20` over `40`, `0` only
above the panel), and two new ones pin the 0,1,0,1 sequence and the cap-70 case.
docs/10's paragraph about the leftover is corrected with it.

130 tests pass; clippy clean with -D warnings.
@joshuatam
joshuatam merged commit 8f31cbd into master Nov 21, 2026
1 check passed
@joshuatam
joshuatam deleted the fix/lsfg-generation-rate branch November 21, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant