Skip to content

gfx: Home's ground under the shelves is one flat colour, drawn as a clear - #1017

Merged
GLinnik21 merged 4 commits into
mainfrom
gfx/flat-wash-clear
Oct 24, 2026
Merged

GLinnik21 merged 4 commits into
mainfrom
gfx/flat-wash-clear

Conversation

@GLinnik21

@GLinnik21 GLinnik21 commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

Home's ambient wash is the UltraBlur corner colours as a page-wide bilinear gradient, plus the atmospheric ramp of scrim ink, dithered by ±1 LSB. It was one full-screen shaded pass on every frame. On the shelves and grid, once the hero is culled (env.sp >= HERO_ART_CULL), no photograph is drawn, and the ground is now ONE flat colour drawn as a glClear of the rect's pixel box, so no fragment is shaded. This is a look change, approved by the owner on 2026-10-24 after a side-by-side simulator walk of the demo library ("Hardly can tell apart").

  • ui: AmbientWash::draw_flat_ground hands Painter::ambient four equal corners of AmbientWash::flat_ground, the mean of the wash's four drawn corners (the exact mean of its bilinear gradient), snapped to exact 8-bit codes. It draws no atmospheric ramp. Home has none by then: the hero has faded out by sp = 0.55, so ramp is None at the cull, and a test pins that premise (home_has_no_ramp_at_the_cull).
  • gfx: draw_ambient_impl turns any ambient with four equal corners and no ink into clear_flat_ground. The decisions are pure and tested:
    • flat_clear: corners times dim, snapped to codes, so a clear never depends on GL_DITHER.
    • ground_clear: the open area, a scissored box, or nothing. The whole drawable is cleared unscissored only when the viewport fills it exactly (plx_base::surface::viewport_fills_drawable). A letterboxed surface and a render-target override are always scissored.
  • Clear colour: the clear colour the context holds is recorded and put back. Every glClearColor therefore goes through pub fn set_clear_color, including the app's player-route clear, whose extern is gone. A source-scan test fails on any other call in gfx.rs.
  • Other flat washes: any other wash resting on four equal codes, such as a browsing page's flat ground, is also a clear now. At most it loses its ±1 LSB noise, which a flat colour does not need.

Scope: the culled hero only

An earlier cut of this branch flattened draw_ground whenever it had no art that frame. On Home that also covers every hero-change slide, held art and a texture still pending; on Detail it covers the frames before the still loads and after it scrolls away. None of those frames were in the approved walk, which pinned the hero, and each would jump the page between gradient and flat in one frame. So draw_ground is origin/main's code again, byte for byte. Only Home calls the flat method, and only when the hero is culled, the same frame the approved build switched on. Detail is unchanged.

Look evidence (macOS simulator, demo library, tools/site_video.py render, 1380 frames)

The walk: hero, then down to Continue Watching and along it, then Movies, TV and Blender shelves.

  • This branch vs the approved build: frame-identical, all 1380 frames (framemd5).
  • This branch vs main, per resting beat:
    • hero: 0 px differ;
    • shelves: 26-41% of px, max 3-10/255, mean 0.4-1.3.
  • The dive's switch frame: a strip only the ground covers steps by max 9/255 (mean 3.8) in one frame while the shelves are still moving. main's step on that frame is max 2. This frame was in the approved walk.

Local tests

  • make test-crate C=plx_gfx: test result: ok. 172 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
  • make test-crate C=plx_ui: test result: ok. 1389 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
  • make test-crate C=plx_screens: test result: ok. 1706 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
  • make test-crate C=plx_base: test result: ok. 225 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
  • make check-nodef: exit 0.
  • python3 ci/check-list-caps.py and python3 ci/check-module-layers.py: exit 0.
  • New tests:
    • draw_ground with no art still records the layered picture;
    • the flat method is one primitive on four equal code-snapped corners;
    • Home's ground is one colour only at sp >= HERO_ART_CULL (read through draw_census::capture_grounds, a new census of the corners each Painter::ambient is handed), and a slide before the cull stays layered;
    • hero_a is 0 at the cull, so no ramp exists there.
  • Mutation check: making Home's flat branch unconditional fails the_ground_goes_flat_only_once_the_hero_is_culled.
  • make check was not run locally; CI gates it.

Known and left: the overdraw ledger's gate(Class::Ambient, …) still books the rect's fragments for a clear. Overdraw and profile-graphics attribution therefore over-report Ambient on these frames; HWCNT is unaffected. overdraw.rs and docs/backdrop-blur-profiling.md now say so.

Device measurement (webOS 4.5 set, Mali-T820)

main fba7a81 vs this branch eae7f89, both ARM_PROFILE=release. Each binary was copied into the debug install and md5-checked, then the builds were alternated. Panel off, sound muted, Guest on the mock demo catalog. The last commit (no ramp fold, docs) is pixel-identical on every real frame, because the ramp is None wherever the flat path runs.

GPU load (HWCNT GPU_ACTIVE cycles a frame, p50; legs main, branch, branch, main):

Scene main this branch
grid-pong 9.80, 9.80 7.94, 7.94
hero-pong 8.50, 8.52 8.52, 8.51

On grid, the share of frames above 8M cycles falls from 99.3% to 12%. The approved scratch build measured the same 7.94M.

Missed refreshes with counters on (the counters add GPU load, so this is a GPU-bound condition, not the production rate): grid 584, 571 → 179, 174; hero 197, 191 → 202, 197.

Missed refreshes without counters (grid-pong, 60 cycles each, two counterbalanced blocks: main, branch, branch, main, then branch, main, main, branch):

Block 1 Block 2 Total
main 8, 11 16, 13 48
this branch 12, 17 11, 10 50

No change in the production miss count; the branch's lead in block 1 reversed in block 2. Every slow frame in all eight runs is a back-buffer wait; none is a CPU phase.

  • Half-tick waits (under 18 ms), which a kernel trace attributes mostly to our GPU work missing the compositor's latch: main 36, this branch 23.
  • Full-refresh waits: main 42, this branch 46. These are late commits and compositor passes skipped while our GPU work was already done.

So the GPU-late slips shrink, but the full-refresh class sets the count and is not GPU-bound. This change buys GPU headroom; it does not by itself remove grid-pong's dropped frames.

Look (GRAPHIC-plane capture; the TV's own overlays masked; the two captures of each scene are identical):

  • home (hero up): 0 px vs main.
  • library-grid: 0 px vs main.
  • home-shelves vs main: 40.1% of px, max 7/255.
  • home-shelves vs the approved scratch build: 38.4% of px by 1 code (3 px by 2). The flat colour is (47,41,41) here and (47,41,40) there. The scratch averaged an 8×8 grid of code-snapped samples; this branch averages the four corners, the gradient's exact mean. On the simulator walk the two rounded alike, which is why those 1380 frames are identical.

No linked issue.

🤖 Generated with Claude Code

GLinnik21 and others added 4 commits October 24, 2026 22:20
Home's ambient wash (UltraBlur corner colours as a page-wide bilinear
gradient, plus the atmospheric ramp of scrim ink, ±1-LSB dithered) was one
full-screen shader pass on every frame. Wherever the ground has no photograph
(Home's shelves and grid once the hero is culled, Detail while its still has
no texture) it is now ONE flat colour drawn as a glClear of the rect's pixel
box: no fragment is shaded. Where the ground has art nothing changes.

ui: AmbientWash::draw_ground with no art takes the ramp and hands
Painter::ambient four equal corners of AmbientWash::flat_ground, the mean of
the wash's four drawn corners with the ramp folded in at its mean alpha over
64 rows (the mix vs_ambient.vert does per vertex), snapped to exact 8-bit
codes.

gfx: draw_ambient_impl turns four equal corners with no ink into
clear_flat_ground. The decisions are pure and tested: flat_clear (equal
corners and no ink -> the corners times dim snapped to codes, so a clear never
depends on GL_DITHER) and ground_clear (open area, scissored box, or nothing;
a letterboxed surface and a render-target override are never cleared bare).
The clear colour the context holds is recorded and put back, so every
glClearColor now goes through the pub set_clear_color, including the app's
player-route clear (its extern is gone); a source-scan test fails on any other
call in gfx.rs.

Measured on the dev television (Mali-T820) with the approved scratch of this
look: Home's grid scene 9.8M -> 7.94M GPU cycles/frame (-1.86M). The PR
re-measures this implementation.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…earlier Home frame stay layered

The previous commit flattened every `draw_ground` call with no art. That also fired
where the look was never approved and made the ground jump between gradient and one
colour in a single frame: Home during every hero SLIDE, while art is HELD and while the
hero's texture is still PENDING, and Detail before its still loads and once it scrolls
away.

ui: `AmbientWash::draw_ground` with no art is origin/main's layered picture again,
byte for byte. The flat path is its own method, `AmbientWash::draw_flat_ground`, with
the same contract (true = the ramp was taken). Home calls it only once the hero is
culled (`sp >= HERO_ART_CULL`), the frame from which no art is drawn at all; every other
Home frame and all of Detail draw exactly as on main. The ramp sample count is
`RAMP_SAMPLES` (it is a sample count, not a list cap, so `ci/check-list-caps.py` passes).

gfx: a flat ground clears unscissored only when the viewport is the whole drawable
(`surface::viewport_fills_drawable`: origin 0,0 AND the drawable's size). An origin of
zero alone proves nothing, because `surface::recompute` floors a centred letterbox: a
1-px remainder leaves vx == 0 with a column outside the viewport. Otherwise the clear is
scissored to the viewport box.

Prose the flat ground made false is corrected (the dither claims in gfx, dither.glsl,
idle.rs, run.rs, widgets.rs, Detail's `ground` doc), and the tests pin the split:
`draw_ground` with no art is the layered picture, `draw_flat_ground` takes the ramp,
and Home goes flat only at `sp >= HERO_ART_CULL`.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…cs the flat clear made false

Part 1. AmbientWash::draw_flat_ground folded Home's atmospheric ramp into the
flat colour, but that path never runs on a real frame: Home's hero_a is
(1 - sp/0.55).clamp(0, 1), which is 0 for every sp >= HERO_ART_CULL, so the
ramp is None whenever the flat ground is drawn. The fold (RAMP_SAMPLES, the
mean-alpha mix, the bool return) is removed: draw_flat_ground(p, r) draws the
wash's mean on exact codes and nothing else, and Home's culled branch is
`draw_flat_ground; false`, leaving the layered ramp path the only ramp drawer.
Pixel-identical on every real frame. The tests that reached the fold only by
forcing hero_a = 1.0 at the cull go with it. Home's flat-vs-layered test now
reads the wash's corners through a new draw_census::capture_grounds (the ramp
rects can no longer tell the two apart) and takes hero_a from HomeScreen::env;
home_has_no_ramp_at_the_cull pins the premise (hero_a == 0 at the cull).

Part 2. Prose the flat clear made false: PageGround::CARD_W (Home's culled
grid is drawn at the mean of those corners), Detail's PageGround "dithers
unconditionally", the overdraw ledger's "exactly" (draw_ambient books a flat
ground's clear as an Ambient quad; HWCNT is unaffected), the ~2M-fragment cost
claims for a wash on the clear colour (a clear at rest, shaded only while the
corners settle), and surface.rs's "nothing else knows the drawable size".

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit 19048ea into main Oct 24, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the gfx/flat-wash-clear branch October 24, 2026 21:54
GLinnik21 added a commit that referenced this pull request Oct 24, 2026
Brings in the Browse B-A section-hubs job and the other changes main gained
since fba7a81 (#1017, #1021, #950). Five files conflicted and every one
keeps both sides: the Direct arm of StoreJob::admission() lists BrowseHubs,
MetaSeason and MetaEpisodes; the runner and the Held docs name both the
Browse and the Metadata kinds; bridge.rs's late-job messages name every
drain of both stores; docs/sans-io.md numbers Metadata as the tenth store;
PINNED_LEDGER_TOTALS is the real sum of the # count: headers (the textual
merge produced a wrong-looking pair).

Co-Authored-By: Claude Sonnet 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