Repository navigation
gfx: a plain textured program for the image program's no-card exit - #983
Merged
Merged
Conversation
Every textured quad runs the image program (fs_img.frag). Its first exit, `u_card.z < 0.5`, is `vec4(tex*u_tint.rgb, ta*u_tint.a)`: about 2 arithmetic words and 1 texture word a fragment. Midgard sizes registers and occupancy for the whole shader, so that exit was charged the card chain's footprint it never runs. The two Home hero photographs (radius 0) take that exit over about 2.1M px a frame, and so does every resting card's interior piece (`card_cut` splits it off with the card flag off). Measured on the device 2026-10-24. fs_tex.frag is that exit as a whole program: the same declarations at the same precision and the same three statements, paired with the unchanged vs_img.vert. It reads u_tex, v_cuv and u_tint and nothing else, so no premultiply, scrim or crop clamp had to be carried over. draw_tex_core_in routes a draw to it when plain_texture_program() says so: the draw is not overridden by the focus or still program and its radius takes the exit (`radius < 0.5`, the packed u_card.z), and for a split card's interior piece (drawn last, radius 0). The ring pieces stay on the image program. The program is optional: if it does not link, IPROG draws the same picture as before. gate() and the card-path ledger book exactly what they booked. Expected saving (an ESTIMATE to be measured on the TV, not a result): 0.5-1.0M GPU cycles a frame on hero-pong and 0.2-0.4M on grid-pong. Tests: fs_tex.frag is pinned line for line to fs_img.frag's plain exit and sits in the dither-free hot-path list; the routing rule is a pure function graded against the shader replica over every card shape and a ladder of radii; the source-shape tests pin the choice after the ledger's gate and the uniforms the bind sends. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # rust-modules/gfx/src/gfx.rs
The exactness test matched fs_img's lines as a subsequence, so a statement inserted into main before the plain exit passed. It now compares fs_img's main from its brace through the u_card.z < 0.5 exit as one contiguous block of normalized statements against fs_tex's main, and requires vs_img.vert to declare exactly u_trect, u_tscreen and u_uvrect (a pad or inflation uniform would fail it). The argument wiring is pinned as whole statements: both bind_plain_image call sites, its signature and uniform writes, and the init's PlainUniforms mapping (quad and uv are both [f32; 4], so a swap compiled). Prose that the program made false is corrected: the pad is not free (its fragments run the exit in both programs), the focus specialization's exit is the same plain write (only the still's differs), a fused still's split interior stays on the still program and exits through stillOver, and the blur reductions, warm_tex, FrameCache quads and field chain moved off IPROG. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The takes_plain_exit doc now says only that a square-cornered draw draws no rim and no shadow and that its pad fragments still run the exit in either program; what the pad samples is not claimed. The unfocused-program test doc no longer lists the draws that moved to the plain texture program as running the image program. Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21
marked this pull request as ready for review
October 24, 2026 12:55
GLinnik21
added a commit
that referenced
this pull request
Oct 24, 2026
…n/main The first version of the pad exit (#985) wrote `vec4(0, 0, 0, sh)` from its own copy of the body's shadow expression. On the TV (Mali-T820, release build, 2026-10-24) that was not the same picture: against the pre-change build the Home shelves differed in 1,118 px and the library grid in 20 px, every one the red channel lower by 1/255, 1-5 px outside a resting card's edge. fs_img.frag now has no exit there. `m` is computed once, before a gate `if (d < 1.0) { ... }` that wraps only the work that changes `tex` (the lit glass in the focus program, and the rim); the shadow and the closing write are written once after it, so a pad fragment runs the body's own instructions with `tex`/`ta` the raw sample. The focus program's fully-transparent early exit is main's again, verbatim. the_card_shaders_pad_exit_is_the_shadow_alone and ..._pad_exit_tail_and_inputs_are_untouched are replaced by the_card_shaders_pad_path_runs_the_bodys_shadow_tail: the coverage, shadow and closing write each appear once per program, the lit work only inside the gate, the gate neither returns, writes a fragment nor assigns anything but `tex` among the values the tail reads, and what follows it is exactly the shadow and the closing write. Merges origin/main (#983): the two comment conflicts (the FOCUS_IMAGE test doc and fs_img.frag's header) take both versions. Co-Authored-By: Claude Sonnet 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 and why
fs_img.frag(the image program,IPROG) has an early exit for any draw that is not a rounded card:u_card.z < 0.5writesvec4(tex*u_tint.rgb, ta*u_tint.a), about 2 arithmetic words and 1 texture word a fragment. Midgard sizes registers and occupancy for the whole shader, so that exit was charged the card chain's footprint it never runs. The two Home hero photographs (radius 0) take it over about 2.1M px a frame, and so does every resting card's interior piece (card_cutsplits it off with the card flag off). Measured on the device 2026-10-24.This adds
fs_tex.frag, that exit as a whole program, linked with the unchangedvs_img.vert.u_tex,v_cuvandu_tintand nothing else (no premultiply, scrim, crop clamp or colour-space flag stands behind that exit), so nothing had to be carried over or excluded.draw_tex_core_in, by the pureplain_texture_program(plain, overridden, radius): a draw goes to the new program when it carries no focus/still program override andradius < 0.5(the packedu_card.z). A rim, shadow pad or tint do not matter: the shader never reads them past that exit, so a radius-0Class::Cardhero with a shadow pad routes there too. A split card's interior piece (drawn last, radius 0) routes there as well; its four ring pieces stay onIPROG. A still-program card's interior stays on the still program (its exit isstillOver, not the plain write).FOCUS_IMAGE: if it does not link,IPROGdraws the same picture as before and a line is logged.u_trect,u_uvrect,u_tint) is sent on every bind from one helper;u_tscreenand the sampler unit are set once at link.gate()still runs first,note_card_pathstill books the same paths. The program is chosen after both.Expected saving (an ESTIMATE, not a result): 0.5-1.0M GPU cycles a frame on hero-pong and 0.2-0.4M on grid-pong.
Identity evidence (macOS simulator, raw 3840x2160 PNGs)
Captured with
tools/screenshots.py --keeponhome,home-shelves,library-grid(the demo library), comparing the rawshot.pngthe sim writes, before JPEG encoding. A canary build (the new program halving its colour) changed 7.6M ofhome's 8.3M pixels, so these scenes do run through the new program for most of the page. Desktop GL ignores precision qualifiers, so this proves the routing and the arithmetic, not Mali's fp16 rounding; that rests on the identical declarations the new test pins.Run-to-run noise on
origin/main(20homecaptures oforigin/main, one of them the reference):homediffers by 0 to 2880 px (max channel delta 1, or 2 in 98 px),home-shelvesby 0 to 2 px,library-gridby 0.Branch vs main:
library-grid: 0 differing pixels in every run.home-shelves: 0 to 2 px in all runs but one (below).home: in 17 of 19 branch captures, 0 to 3445 px against the main reference, max delta 1 or 2, in the same bottom-left region the main-vs-main noise sits in (identical bounding box (222,1425)-(790,1559) for branch-vs-main and main-vs-main). Three of them were pixel-identical to the main reference or within 4 px.homecaptures (the first one after building, and one more) showed a different pattern: about 10-11k px, max delta 1-2, scattered over the hero photograph region. Neither reproduced in 17 further branch captures (home-only and full runs), and none of the 20origin/maincaptures showed it. I could not tie it to the change: the new program's output is a pure function of its inputs and 17 captures match, which points at a differing input (an animation caught at a slightly different value under load, the failure modetools/screenshots.pyitself documents) rather than the program, but that is an inference, not a measurement. It is the one thing the reviewer should weigh.Local tests
make test-crate C=plx_gfx T=plain:test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 157 filtered outmake test-crate C=plx_gfx:test result: ok. 163 passed; 0 failed; 0 ignored; 0 measured; 0 filtered outfs_tex.frag's alpha term, or the rule toradius < 0.6, fails 3 of the new tests.cargo check --lib --no-default-featuresstayed silent after the last edit.make checkwas not run locally (congested machine); CI gates it.Device measurement
Measured on the dev TV (Mali-T820, webOS 4.5) on 2026-10-24:
make ARM_PROFILE=release deployof 6bea562.tests/run.py --fps --mock, panel off, no sampler.plxnative-hwcnt=frame.ui, GPU_ACTIVE per frame, first 60 frames discarded.No linked issue.
🤖 Generated with Claude Code