Repository navigation
gfx: a two-stop ramp program for square unfocused gradients (off fs_src's flat path) - #981
Merged
Merged
Conversation
…rc's flat path) Home's hero backdrop draws two full-width ramp bands (~1.37M px a frame) through gfx::draw_rect. They land in fs_src.frag's flat fast path (`mix(u_colTop, u_colBot, vy)` behind a uniform branch), which HWCNT put at ~3 arithmetic words per pixel on the TV (2026-10-24) where a bare mix is ~1-1.5: the branch runs on every fragment, and Midgard sizes the register file for the whole 12 KB shader, which lowers occupancy. shaders/fs_ramp.frag is that one expression and nothing else, with the same precision qualifiers as fs_src.frag, undithered like the path it replaces. It is linked beside FS_FLAT with the same fallback on a failed link (fs_src's flat path, as before). The routing is a pure function, rect_fill(radius, focus, one_colour): radius < 0.5 && focus < 0.001 is fs_src.frag's own flat-path test, so a rect leaves that program only when the shader would have skipped the SDF for it; one colour goes to the flat program, two to the ramp program. The quad is exactly the rect's bounds (aa = 0, as on that path), and gate(Class::Rect, ..) still books the draw before a program is chosen. draw_rrect is single-colour, and draw_rect_sheened/shaped always inflate the quad by AA_BLEED, so neither routes. Expected saving is an ESTIMATE, to be measured on the TV: 0.7-1.3M GPU cycles a frame on the hero-pong bench (budget ~11.2M). Tests: the routing function and its thresholds from both sides (NaN included); fs_ramp.frag's expression and qualifiers read out of both shaders and compared; the draw keeps the exact bounds, the ledger gate before the routing, and the fallback; fs_ramp.frag joins the dither-prelude-free list. Stale prose in fs_src.frag (scrims no longer take that path) corrected. Co-Authored-By: Claude Opus 5.5 <[email protected]>
link_program exits the process on a compile rejection, so the ramp program's fallback to fs_src's flat path was unreachable for exactly that failure. RPROG now links through link_optional_program, and the comments say compile or link. The source-shape test cuts the Flat and Ramp arms out of draw_rect's routing and requires each to call its own program (a swap kept both calls in the function and passed the old check), and requires RPROG to be built from VS_SRC + FS_RAMP optionally. rect_fill's doc notes that the shader's u_focus compare may run in fp16, and two shader comments no longer claim what the routing made false. Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21
marked this pull request as ready for review
October 24, 2026 10:34
GLinnik21
added a commit
that referenced
this pull request
Oct 24, 2026
## What broke #981 (65e976b) added `rust-modules/gfx/src/shaders/fs_ramp.frag`, whose line-8 comment spells the dev-trigger name `plxnative-hwcnt`. `glsl!` embeds a shader source whole (`concat!(include_str!(..), "\0")`, comments included; nothing strips them), so the name was compiled into the binary. The Nightly workflow's `make ipk` step then failed `ci/check-package.py`'s packaged-binary scan: `the com.beb.plxnative.nightly package carries no dev-trigger surface ... (found plxnative-hwcnt)` (seen on PR #991's "ARM build + gates / build + verify" job). #981's only other `plxnative-hwcnt` is a plain `//` comment in `gfx.rs`, which is not compiled in. ## The fix - `fs_ramp.frag`: line 8 now reads `(HWCNT, 2026-10-24)` instead of naming the trigger. A comment only, so the compiled program is unchanged. - New test `gfx::tests::no_shader_source_names_a_dev_trigger` reads EVERY file under `rust-modules/gfx/src/shaders/` (it lists the directory, so a new shader is covered by being added; that is the only `shaders/` directory in the tree) and fails on any `plxnative-`. The scan matches the dev-trigger catalog's names (`dev.rs` `DIAG` + `devtrig.rs` `CONTROLLED`, minus the release-legitimate allowlist); the test matches the whole prefix, a superset that nothing in a shader needs, and the failure message says why. ## Red / green Red, before the reword (`make test-crate C=plx_gfx T=no_shader_source_names_a_dev_trigger`): ``` test gfx::tests::no_shader_source_names_a_dev_trigger ... FAILED .../rust-modules/gfx/src/shaders/fs_ramp.frag:8: // arithmetic words (`plxnative-hwcnt`, 2026-10-24) where one `mix` is 1-1.5: the three uniform test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 163 filtered out; finished in 0.00s ``` Green, after: ``` test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 163 filtered out; finished in 0.00s ``` Whole crate (`make test-crate C=plx_gfx`): `test result: ok. 164 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out`. `make check-nodef` passes. Full `make check` is left to CI. No linked issue. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What / why
Home's hero backdrop draws two full-width "ramp band" quads (~1.37M px a frame) through
gfx::draw_rect. They land infs_src.frag's flat fast path (mix(u_colTop, u_colBot, vy)behind a uniform branch), which HWCNT measured at ~3 arithmetic words per pixel on the TV (2026-10-24) where a baremixis ~1-1.5: the branch runs on every fragment, and Midgard sizes the register file for the whole 12 KB shader, which lowers occupancy.This adds
shaders/fs_ramp.frag: that one expression and nothing else, same precision qualifiers asfs_src.frag, undithered like the path it replaces. Linked besideFS_FLATwith the same fallback on a failed link.Routing is a pure function,
rect_fill(radius, focus, one_colour):radius < 0.5 && focus < 0.001isfs_src.frag's own flat-path test, so a rect leaves that program only when the shader would have skipped the SDF for it. One colour goes to the flat program, two colours to the ramp program, everything else stays on the fill program. The quad is exactly the rect's bounds (aa = 0, as on that path) andgate(Class::Rect, ..)still books the draw before a program is chosen.draw_rectroutes.draw_rrectis single-colour (no ramp case).draw_rect_sheened/draw_rect_shapedare left alone: they always inflate the quad byAA_BLEED, so a ramp quad would not draw the same fringe.fs_src.frag(it said scrims take that path) corrected; comment-only.Identity evidence (macOS simulator, desktop GL)
tools/screenshots.py --only home,home-shelves --keep, rawshot.png(3840x2160) compared with Pillow;origin/maincaptured twice, this branch once.home: with the ramp shader temporarily replaced by a solid colour, 3,814,203 px changed.home-shelveshas NO ramp draw (0 px changed), so it only shows the flat/fill routing is undisturbed.home. The max delta is 1, as in the main-vs-main noise bound, but main-vs-main onhomeis 0 differing px and the branch differs in 2879 px (0.075% of the 3.8M-px ramp region). All 2879 lie inside the ramp region (0 outside), the sign is mixed (2080 brighter, 784 darker), spread over 617 rows (at most 63 a row). That is the signature of the driver compiling the samemixdifferently in a different program (rounding order), not of a geometry change, but the simulator cannot tell us what the Mali compiler does with fp16mix. Same expression and same qualifiers on device are pinned by a unit test; a device pixel-diff of the hero is the real check and is pending.Local tests
make test-crate C=plx_gfx T=ramp:test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 159 filtered outmake test-crate C=plx_gfx:test result: ok. 161 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out(includes the dither-prelude-free shader list, now withfs_ramp.frag, and theLOC_RGB_CAPsource test)make check-nodef: finished clean.make checkwas not run locally (congested machine); CI is the gate.Device measurement
Measured on the dev TV (Mali-T820, webOS 4.5) on 2026-10-24. The build was
make ARM_PROFILE=release deployof 503562c, run withtests/run.py --fps --mock, the panel off and no sampler. The control is the same base plus #980 (the late-probe gate), measured the same day. The counters come fromplxnative-hwcnt=frame.ui, GPU_ACTIVE per frame after the first 60 frames are discarded. Misses come from separate runs without the counters.No linked issue.
🤖 Generated with Claude Code