Skip to content

Cards: a released card lands at rest, and a resting card's interior skips the card math - held paging 52 -> 59 fps on the TV - #861

Merged
GLinnik21 merged 9 commits into
mainfrom
crx-card-interior
Oct 20, 2026
Merged

GLinnik21 merged 9 commits into
mainfrom
crx-card-interior

Conversation

@GLinnik21

@GLinnik21 GLinnik21 commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

On the TV, holding a key to page through a shelf ran at 52 fps on Home: the GPU was over its per-frame budget, and cards owned half of it. This PR takes held paging on Home to a 59 fps median with 0.5% of frames over 33 ms. The Library's held paging reaches 60 fps.

Cause (measured on the TV with GPU counters)

  • Held paging is fragment-bound. frame.ui used 11.6M GPU cycles per frame against a 60 Hz budget of about 10.8–11.6M. Cards took 5.79M of that (drawmask A/B) at about 8.5 ALU words per card pixel.

  • Cards the walk had visited never came to rest. A card released from focus settles one ulp above scale 1.0, because gfx::spring never lands exactly on its target (card_row.rs noted the stall). CardRow::park runs only for a dormant shelf. Every visited card therefore kept pop factor ≈ 1.3e-6 > 0 and drew with the focus program at an invisible pop:

    • the gloss mix;
    • the wide glow band;
    • the shadow branch.

    Nearly every visible card in the row being paged had been visited. In the simulator, after a walk, 5 cards drew with the focus program instead of 1.

  • Every resting card ran the full card math over its whole quad, although most of its area is plain texture × tint.

Fix (shared layers, every card on every screen)

  • A released card lands at rest.
    • plx_ui::Spring::land (relative epsilon 1/16384) snaps a spring that is close enough to its target, with velocity about zero, onto the target.
    • CardRow::update calls it for non-focused cells and for overflow, so cards::Shelf rows (Home, Recommended, Search, Detail/Cast) settle exactly.
    • gfx::spring and the other springs are unchanged.
  • The resting card is split.
    • gfx::draw_tex_core_in draws a resting rounded card's certainly-interior box through fs_img.frag's plain exit and only its ring through the full card math.
    • It is the same quad under five glScissor boxes, so the varyings and the pixels are identical.
    • LIVE_SCISSOR with scissor_box/scissor_off intersects and restores the caller's clip. target_map is now the one mapping that clip_set and the card boxes share.
    • The source (glass) pass is not split.
  • Instruments.
    • The OVERDRAW ledger's window line now ends with per-frame cardpath counts: split, focus, clip, no-interior, plain and off, each with pixels and draws.
    • /tmp/plxnative-nocardsplit turns the split off, so one binary can be measured with it on and off (docs/backdrop-blur-profiling.md, Part 5).

Verification

  • Red first: HOME: cell 3 still at 1.0000001 90 frames after focus moved to 4 on the unfixed tree.

  • Card split tests:

    • every interior pixel centre takes the plain exit, for every row style, scale and offset origin;
    • the boxes tile the target exactly once;
    • the caller's clip cuts the boxes;
    • restore of the scissor state;
    • a source pin on who may touch the GL scissor;
    • the shader's plain-exit expressions are pinned textually.
  • Gates on the committed tree (git status --short empty before and after):

    • make check exit 0, 103 steps — all ok, Python harness Ran 469 tests … OK, every test result: line ok, e.g. plx_ui 1265 passed, plx_screens 1622 passed, 1840 passed; 0 failed; 60 ignored;
    • make test-hostsim ok. 932 passed; 0 failed;
    • make check-nodef clean;
    • make check-replay 3 fixtures, 6 replays, 0 failures.
  • Replay anchor: 1-boot-home-chip-grid is re-recorded once. It diverged only on the released card's spring (frames 381–393) and was SAME with Spring::land made a no-op.

  • TV (ARM release build, 60 Hz, panel on, muted, mock only), at 37ea478 (this branch before its simplify commit, which is behaviour-identical):

    measure before after
    home-recent-paging-held loop median 52 59 (robust_min 55); frames > 33 ms 0.5% (was 4.4%)
    library-shelf-paging-held-3g / -remote-wan (before = Library: a key on a deep Recommended page no longer costs a late frame, and library-shelves-deep can pass #860's tree) 52 / 51; frames > 33 ms 11% / 12% 60 / 60; frames > 33 ms 0.2% / 0.2%
    home-grid 60 60
    frame.ui GPU cycles, paging mean 11.62M 10.15M
    card class (drawmask none − card) 5.79M 4.27M
    instrumented paging frames ≥ 25 ms 11.7% 2.3%
    compositor repaints ≥ 1.5 periods apart 8.6% 3.2%
    • Split on vs off, interleaved on one binary: the split saves 0.47M cycles per frame (10.15M vs 10.62M). Frames over 11.6M fall from 6.5% to 3.0%. The draw phase's CPU time does not move (26.1 vs 26.0 ms instrumented), so the extra draws (1 → 5 per resting card) cost nothing measurable.
    • The cardpath counter while paging: about 17 cards split; 3–5 on the focus program, which are the focused card plus cards still springing back during the held walk.
  • Simulator:

    • Stills after a walk differ from the unfixed build only by 1 level, on the visited cards: mostly faint speckle in the interior gloss (85-90% of the changed pixels) and on silhouette edges, which is the focus program's gloss at an invisible pop going away. A visited card now looks like a never-visited one.
    • Frame by frame, a released card's last moving frame and its first rest frame differ by under 0.5 px on every edge, so there is no snap.
  • One review: no correctness blocker. It found the settle bug above, and its shoulds are fixed here:

    • the ring boxes are clamped to the viewport;
    • there is one target mapping;
    • the restore and scissor-owner tests;
    • present_supersampled clears the clip.
  • pixel_scale() (scale()*render_scale()) is replaced by target_map's scale. On the TV and the default simulator these are equal. Under PLXNATIVE_RENDER_SCALE=n>1 (simulator supersampling only) the old value was n², so shadow-band seams could land on half pixels; that output now differs, and is now correct.

  • No crate, Cargo, Makefile, build.rs or workflow change, so there is no build-bench table.

Not in this PR

  • The remaining late frames while paging are the frame thread blocked about 23 ms in the back-buffer wait (the clear-call stall). On one binary, masking every card (GPU 10.2M -> 5.9M cycles/frame) does not reduce them (frames with a clear wait >= 10 ms: 1.9-2.9% drawn vs 3.3-3.7% masked), so our GPU load is not what holds them; the compositor side is not traced, so the cause is otherwise not determined.
  • The card class is still 4.27M against the 3.6M first targeted. Baking the resting ring as a shared 9-slice texture is the next step if the GPU is the limit again.

🤖 Generated with Claude Code

GLinnik21 and others added 9 commits October 20, 2026 07:42
…xture fast path and only its ring through the full card math

draw_tex_impl cuts a resting art tile's quad (Class::Card, rounded, f=0, dy=0, so the
shadow pad is symmetric about the card) into the card inset by radius + rim + 2 px,
snapped onto the pixel grid, and the four bands around it. The interior is one draw
with u_card.z = 0 (fs_img.frag's u_card.z < 0.5 exit: texture x tint), the ring four
draws through the full card math. vs_img.vert gains u_pofs, zero by default, which keeps
v_p measured from the whole card for a piece; v_cuv comes from the quad's UV window
restricted to the piece. The pixel snap and the band tiling are shadow_bands' own, now
split into snap_inner and bands_around so the card reuses them.

Host tests replay the plain shader's exits over the interior for every card shape the
app draws, pin the three vec4(tex, ta) exits as one expression, and check the pieces
tile the quad once with their seams on the pixel grid and their varyings equal to the
whole quad's.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…the picture is bit-identical

The first cut drew the interior and the ring's four bands as separate sub-quads. A before/after
simulator diff of Home found 122 pixels, one level off, in the same places on every run: a sub-quad
interpolates v_p and v_cuv from its own corners, and a different basis rounds a few texture and
edge-coverage values the other way. The pieces are now the SAME quad drawn five times, each under a
glScissor box (interior through the u_card.z < 0.5 fast path, the four bands of the ring through
the full card math), so every pixel sees the very varyings the single draw gave it. The vertex
shader is back to what main has (no u_pofs).

The boxes are whole window pixels from the pixel-grid hole, tile the target exactly (tested), and are
intersected with the clip a scrolling list set; every scissor change in gfx.rs now goes through
scissor_box / scissor_off so the live box is known, and is put back after the card. The reduced
resolution source pass is not split. pixel_scale() read scale() * render_scale(), which squares the
factor under simulator supersampling (scale() is already the drawable's); it is scale() now.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…s visited cards stop drawing through the focus program

gfx::spring's closed form never lands a released spring: its last addition rounds to the
nearest f32 and parks the pop one ulp above 1.0 with a velocity of ~1e-6, forever. CardRow::park
would snap it, but it refuses a row that still holds focus, and a held key keeps the row focused
(on the next cell), so every card the walk visited drew at f ~ 1.3e-6 > 0: wants_focus_program,
the FOCUS_IMAGE program (gloss, glow band, shadow branch) and never the resting split.

Spring::land puts a spring that has arrived (within 2^-14 of its target, relative, and travelling
less than that per frame) exactly on it, change-guarded like jump; CardRow::update lands every
cell that is not focused, and the shared overflow spring when it is not popped. gfx::spring and
the other integrators are untouched, so no other spring user moves. RowStyle::pop_factor is the
one place the painter's f is computed (draw_tile and the focused tile used the same expression),
and gfx::wants_focus_program is public so the test reads the compositor's own predicate.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…and by what it reports to the present gate

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… the card split

- overdraw: the ledger's window line ends in `cardpath split= focus= clip= nointerior= plain= off=`
  (visible px / logical draws per frame), booked once per card draw by `draw_tex_core_in`; dev-only
  like the ledger, a no-op in release. `/tmp/plxnative-nocardsplit` (dev::DIAG, armed in
  `dev::scenarios::arm_cardsplit` beside drawmask) draws every resting card whole on the same
  binary, booked as `off`; documented with drawmask in docs/backdrop-blur-profiling.md Part 5.
- S1: the ring's scissor boxes are clamped to the target's viewport, not +-PX_FAR.
- S2: one target mapping (`target_map`, `win_x`, `win_y`) for `clip_set` and the card boxes;
  `pixel_scale` is gone.
- S3: `card_plan` makes the scissor restore logic data and tests it; a source pin keeps the
  `LIVE_SCISSOR` invariant (only `scissor_box`, `scissor_off` and the piece loop touch GL's scissor).
- N1: `app::run` clears the clip through gfx before `present_supersampled`. N2/N3: doc wording.
  N4: `the_ring_still_runs_the_card_math` follows an edge fragment to the pixel box the production
  boxes put it in; the shader's `q`/`straight` lines the replica transcribes are pinned textually.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ased card's spring

A card the focus has left lands exactly on rest (Spring::land) instead of parking one ulp above it,
and the canon hashes that bit for bit: 1-boot-home-chip-grid diverged on 13 frames (381-393), every
other counter zero; the two other anchors stayed SAME. Attributed by replaying the committed anchors
against a build with only Spring::land made a no-op (all three SAME). Only rec-0000.jsonl replaced
(tests/focusfp.sh --rec --only 1); the manifest stands. Replayed SAME in Targets and Resolve.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…and says less

- card_row: the new RowStyle::pop_factor was widgets::pop_factor(s, focus_scale) again; the
  call sites use the shared one and its doc carries the "exactly 0.0 at rest" invariant.
- card_row: the overflow spring lands on the boolean the pop target was derived from.
- gfx: a split card wholly outside the caller's clip returns before touching the scissor.
- overdraw: window_line (one caller, five parameters) is folded into flush_window.
- comments: the fs_img.frag, overdraw module, boot.rs, surface.rs and clip_set notes that
  restated a doc a few lines away are cut to a pointer or dropped; no code or pixel changes.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
`clip` is a resting, rounded card on a blur source pass with the split on; a
popped, square-cornered or split-off card on that pass is booked as focus,
plain or off (gfx.rs card_cut sorts those before card_boxes checks
CLIP_TARGET), so the six paths add up to the `card` entry plus every
source-pass card draw and `card + clip` does not reconcile on a nocardsplit
leg. The sample line now prints the classes in NAMES order.

overdraw.rs's module doc now counts three questions and says all three
surfaces are dev-only (the release twin carries note_card_path and
set_card_split as empty fns, and card_split() is always true there).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit 3882f6e into main Oct 20, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the crx-card-interior branch October 20, 2026 07:36
GLinnik21 added a commit that referenced this pull request Oct 20, 2026
Both sides re-recorded the 1-boot-home-chip-grid anchor (the Under posters
captions on this branch, a released card's spring landing exactly at rest on
main), so neither recording matched the merged code. The branch's recording
replayed against the merged tree diverged on 13 frames (382-394), the tail of
the Home card spring release, with every other counter zero; the same recording
replayed SAME with Spring::land made a no-op, so the card landing is the whole
divergence. The anchor was recorded once afresh on the merged tree
(tests/focusfp.sh --rec --only 1) and only its rec-0000.jsonl replaced; the
README keeps both sides' paragraphs and gains one for the single re-record.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
GLinnik21 added a commit that referenced this pull request Oct 20, 2026
…ogs keeps the profiler counters (#863)

After #861, held paging on Home still spends 4.27M GPU cycles per frame on cards, and nothing could split that cost on the TV. This adds the instrument and makes the harness keep its data.

- drawmask (extended in place) gains card parts: card.interior refuses the interior piece of every split card, card.ring its four ring pieces, card.focus every card drawn with the focus program. Parts combine with commas or spaces beside the whole-class masks; an unknown name is logged with the valid ones. Both OVERDRAW ledgers book a card before its part is refused, so a part leg differs from its control only by the refused draws.
- tests/run.py no longer loses the profiler counters of an --fps --save-logs leg: run_fps_scene pulls exactly the file of each armed profiler (plxnative-hwcnt -> HWCNT JSONL, plxnative-profile -> GL-timer JSONL) once, after the app run and before the next wipe, beside the event log; run_graphics_profile uses the same pull.
- docs/backdrop-blur-profiling.md Part 5: the TV recipe for the per-part legs and how to read their deltas.

Cost: in release (devtriggers off) masked_part is a constant false and the check folds away; a dev build with nothing armed does about 40 thread-local reads a frame while paging.

Tests: each part mask refuses exactly its pieces (differential over every row style and three clip shapes), the text reaches the pieces, the harness keeps the right file per leg and pulls once for both callers in kill/wipe/run/pull order (watched red with the pull reverted to hwcnt-only). Gates on the committed tree: make check 103 steps ok, hostsim 932/0, check-nodef clean, check-replay 6/0 all SAME. One review, no blockers; its shoulds are fixed here, then a simplify pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21 added a commit that referenced this pull request Oct 20, 2026
…st, deep shelves, Home and Recommended Detail return) (#864)

App-tier route tests for the routes #857-#861 changed, in the World rig (real screens behind the real dispatch). Each was watched red against a stub of the production behaviour it guards (applied to the committed tree, restored, never committed).

- A released card is at exact rest on Home and Recommended after an 8-card held walk (red with Spring::land a no-op: "only the focused card is off rest, got [(0, 0, 1.0000001) ... (0, 8, 1.0899999)]").
- The same rule as conformance case eight, released_card_lands_at_rest: Tier 1 shelf and eight Tier 2 shelf screens go red with the same stub; the grid components pass by construction (one pop and one shrink spring).
- A publication that adds a shelf leaves focus on its card (guards key stability; red with an identity-minting rebuild) and the new shelf is reachable (red with sync ignoring later publications).
- A held Down through a deep Home reaches every row on a card that has landed (red with the hold band's reach at 0).
- A deep Recommended page returns from Detail onto the same published card (red with Enter::Restored passing no focus; the rows-in-view clauses live through the latched-band premise).
- Home -> Detail -> BACK lands on the card it left, at rest, with OK performed by the World pump through home_requests' guards and input::activate_deck_card -> activate_card -> open_detail (red with Enter::Restored dropping the focus, and with activate_card handing open_detail a focus-less return state). content::home_requests' arm and activate_home_item take the whole App and are not covered.

Outside the tests: test-support accessors only (HomeScreen/RecommendedScreen::probe_card_pops, BrowseStore::released_rows_for_test, World helpers), each #[cfg(any(test, feature = "test-support"))]. No production path change.

Gates on the committed tree: make check 103 steps ok, hostsim 938/0, check-nodef clean, check-replay 6/0. One review (no blockers; its should and nits fixed here). CodeQL cleartext-logging alerts on test assert messages printing fixture probe text dismissed as used in tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21 added a commit that referenced this pull request Oct 20, 2026
…y no longer snaps the card it left (#866)

A held Right on the Library poster grid snapped the card it had just left 3.7-5.4 px per edge: the grid kept ONE let-go spring, so each press threw the still-shrinking card away. The grid, and Detail's Episodes strip, now land on the shelf's own rule (Spring::land, #861), and every released grid card keeps a spring of its own until it lands.

- Sim, every frame (Library grid, held keys): largest single-frame step of a released card 5.38 -> 1.23 px per edge (the unchanged pop spring's own speed from full pop); step beyond smooth motion 5.38 -> 0.70 px (a free let-go: 0.69). A released grid card and an Episodes-strip cell rest at exactly 1.0 (were 1.002676 / 1.0000001 on the focus shader); landing jump 0.43-0.55 -> <=0.03 px (grid), 0.30-0.35 -> <=0.05 px (Detail).
- GridPop keeps a sparse list of let-gos (only cards off rest, each landing in ~28 frames: bounded by time, not a count). A let-go is born with its element; a press back onto a card picks its spring up where it is. The tick follows each let-go through a source change (nearest-first bounded search, one hash per let-go in flight); a frame resolves let-gos by cell, so the draw hashes no card; reset keeps capacity, so steady-state frames allocate nothing.
- Canon: the let-go canon is the pop then a counted sequence; LibraryGrid::SHAPE declares it and the bands slot's card (written since #843, never declared); SCREEN_SHAPES_PIN bumped; the three replay anchors re-recorded once for the shape fingerprint after replaying them SAME (diverged=0, every counter 0) against the new canon with the old shape text.

Tests, each watched red: every released grid card runs its own let-go; a removal/insert ahead of focus with a press in the same frame keeps the let-go; the landing test asserts each let-go's cell; the draw hashes no drawn card while cards let go; the canon cannot run into the state after it; Episodes cells at exact rest; the shape pin. Gates on the committed tree: make check 103 steps ok (1840/0 largest), hostsim 938/0, check-nodef clean, check-replay 6/0 SAME. One review (no blockers; its shoulds fixed here), one simplify pass.

Not here: a refresh that replaces a cell's element still drops that let-go (shelves too; needs a successor notion on CardSource); a let-go is followed within 96 cells except the last-focused card; the Episodes strip still steps its own per-slot springs (k 300).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21 added a commit that referenced this pull request Oct 20, 2026
…shows only once its room is there, and Home rests like the Library (#859)

The owner, after #843 on the TV: the Under posters setting applied only in the Library; it should apply on Home and Recommended too ("Seasons tiles left without title", "Search does not follow new tiles rule", the account chip over a Home heading).

- Settings > Libraries > Under posters is global: every poster tile reads it through one builder (screens/src/registry/captions.rs): Home and Recommended shelves, the Library grid, Collections page and Collection screen, Search poster rows and filmography, Detail's Related and collection shelves, the Watchlist. Landscape stills and headshots keep their own fixed labels (one shared still label).
- A line the setting turns on is never drawn empty: each kind falls back to an identity (season title / "Specials" / "Season N", "S1 · E3", year, collection size, then a kind word); Continue Watching keeps "8m left" and the amber play mark rule; one episode address spelling.
- A caption line is on screen only once the room under its card holds it, on the grid and every shelf alike (card_row.rs room_for / line_reveal_for; band_fade, band_reveal, band_reveal_for removed). The room is measured to the DRAWN top of what is below: the popped, pressed or still-shrinking tile on a grid (Grid::rise_below with #866's let-go scales) or the next shelf's lifted heading (SectionFrame::below_rise from Home, Stack, Recommended, Detail). This fixes the next row cutting the grid caption on Down (on main since #843; Collection and Watchlist too). The Person page carries its shelf air as Search does (shelf_foot); every owner keeps UNDER_LABEL_AIR under a shelf, pinned.
- Home's rest rule is the Library's (grid_rest_scroll): the focused shelf's heading rests in one place, clear of the account chip; headings under the chrome fade; every Down/Up moves a full shelf.
- Fixed along the way: the Library Episodes listing's label no longer covered by the next row; an untitled item is still a card (one pms::shelf_card); a season 0 tab reads "Specials".

Tests on the app-tier World rig and the card suite, each watched red (surfaces x settings, band heights, Home chip/nav clearance, a setting changed under a kept Home, the held-Right glide, released posters at exact rest, no caption line where the drawn tile or a let-go tile below is: 11.9 / 8.5 / 7.8 px red, the default policy monotone, the two-shelf walk, band 0, the shelf after an empty one, the Person page, the pinned air). Gates on the committed tree 48c8751: make check ok (1840 largest, plx_screens 1641, plx_ui 1305), hostsim 969/0, check-nodef clean, check-replay 6/0 SAME on three runs. Replay anchors re-anchored for the intended changes (owner-approved): Home for the captions and #861's exact rest, then 1 and 12 once on the merged tree with attribution (Person pixel-identical outside the caption box on 4350 frames; Home's streams equal but the caption measurements). Simulator every-frame evidence for Home, Recommended, Search, Detail shelves, Library grid 112/80/0, Collection, Watchlist; reviews: code audit, combined review, the design team three rounds (0 blockers), one review of the reveal, simplify, doc-claim audit. TV (release, panel on, muted, mock): held paging and deep walks at 58-60 fps. The owner looked at it on the TV and approved it ("I like it").

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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