Repository navigation
asahi: G16G blend destination term first, uniform-only arithmetic before the pixel wait - #49
IronsideXXVI wants to merge 5 commits into
Conversation
Additive blending currently emits src * src_factor + dst * dst_factor. With dst_term_first the destination term comes first, so contraction fuses the destination product into the final multiply-add and the source product becomes a separate multiply that a backend can schedule independently of the destination load. Off by default; no driver changes behaviour.
On G16G the epilog's additive blend now fuses dst * dst_factor into the final multiply-add, so each channel needs one dependent operation after the tilebuffer load instead of a multiply followed by a multiply-add. The source product no longer depends on the destination and is scheduled in the load's shadow. The association of the last add changes, so results may differ by one UNORM step from the previous order. The choice is carried in the epilog key, so it applies only to G16G and separates cached shaders. ASAHI_G16_BLEND_DST_FIRST=0 restores the previous order.
After scheduling, move fadd, fmul, ffma and mov_imm computed only from uniforms and immediates ahead of the first wait_pix of a G16G fragment block. With the blend destination term first, the source terms of a uniform-colour blend (clamps, 1 - alpha and the source products) are then computed before the ordered colour section, which holds only the tile load, unpack, one multiply-add per channel, pack and store. Texture, varying and tile-dependent work keeps its scheduled place. Operations, modifiers and operands are unchanged, so results are bit-identical. The choice is part of the Vulkan compiler flags and the Gallium disk-cache identity. ASAHI_G16_PIX_HOIST=0 restores the previous placement.
[Medium impact] The PR appears safe to merge; no new actionable issue was found. SummaryThis PR changes G16G blend arithmetic to shorten the work after the pixel wait.
Reviews (3) · Last reviewed commit: "asahi: drop the G16G blend and hoist swi..." · Reviewed by Greptile |
agx3_g16_hoist_pixel_independent reorders instructions after scheduling, so cover its rules directly instead of relying on hardware readbacks: - a chain of uniform-only fmul, fadd, ffma and mov_imm moves ahead of WAIT_PIX and keeps its scheduled order; - a tile load, the operation reading it and the operation reading that result stay after the wait, although they also read uniforms; - nothing moves without a wait, on other chips, in other stages or in preambles; - ASAHI_G16_PIX_HOIST=0 keeps the scheduled order. Export the pass so the test can call it.
|
On the test note: agreed, and added in 5f81ba4 (
The repo's CI |
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
|
The re-review of 5f81ba4 raised no new notes, so nothing more to change here. The fork CI run for this head still needs a maintainer to approve it. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Thanks Dylan. Emitting the destination term first, so each channel needs one FMA after the tile load, makes sense. The opt-in nir_lower_blend_rt::dst_term_first leaves every other driver unchanged. The order-balanced timings and the off-vs-on readback (at most one UNORM8 step) are what we'd want to see.
What blocks a merge:
ASAHI_G16_BLEND_DST_FIRSTandASAHI_G16_PIX_HOISTare runtime switches. Merged code here can't carry those. Please drop both, along with the cache-identity bits that exist only to keep the settings apart. The tests intest-g16-pixel-hoist.cppthatsetenvthe opt-out can check the result against the pre-change program on a chip the pass doesn't touch instead.agx3_g16_hoist_pixel_independent()moves uniform reads ahead of the firstWAIT_PIXwithout checking for a uniform write between the two. If a G16G main fragment program can never write a uniform register, please say that in the comment, or assert it. If it can, the pass has to stop at the first such write.- Hardware conformance, which this tree's policy requires before a merge. Blend output changes by up to one UNORM8 step, so we need a G16G vk-default subset run (blend and fragment-ops groups at least) with 0 new Fail/Crash against the
integration/aurorabase.
A question, not a blocker: every G16 part executes AGX3b, but both changes are G16G-only. If G16S/G16C are out only because they weren't measured, please say so in the commit messages.
#50 and #51 carry these commits, so this one merges first. Mesa CI on 5f81ba4 is approved and running.
|
Thanks. I'll drop On G16S/G16C: same as #48, left out only because I haven't measured them; the commit messages will say so. |
Merged code cannot carry runtime switches. Remove ASAHI_G16_BLEND_DST_FIRST and ASAHI_G16_PIX_HOIST with their helpers: on G16G the blend destination term is always emitted first and uniform-only arithmetic is always issued ahead of the first WAIT_PIX. The Vulkan compiler-flag bit and the Gallium disk-cache bit only kept the settings apart, so they go too. agx3_g16_hoist_pixel_independent() moved uniform reads ahead of the wait without looking for a uniform write between the two. Stop the scan of a block at the first instruction after the wait that writes the uniform file (uniform_store or a uniform destination); nothing after it moves. Tests: the opt-out test is replaced by StopsAtUniformWrite; the other-chip test already checks the scheduled program is left as it was where the pass does not run. Both changes stay limited to G16G because that is the only AGX3b part they were measured on. G16S and G16C were not measured; nothing known rules them out. Assisted-by: LLM
|
Pushed 6f13b2d ("asahi: drop the G16G blend and hoist switches, stop at uniform writes"):
The repo's CI Still open: the G16G vk-default subset run (blend and fragment-ops groups at least) against the |
|
Retargeted to aurora-silicon#605 |
Two small G16G changes to alpha-blended fragment programs, plus one opt-in
nir_lower_blendoption they rely on.nir/lower_blend: add an option to emit the destination term first. Additive blending emitssrc * src_factor + dst * dst_factor, which contraction turns intoffma(src, src_factor, dst * dst_factor). Withnir_lower_blend_rt::dst_term_firstthe destination term comes first, so contraction givesffma(dst, dst_factor, src * src_factor). Default off; no other driver changes behaviour.asahi: emit the blend destination term first on G16G. The epilog key carries the choice and it is set only on G16G, so other chips compile as before (including the G17P golden-byte epilog tests) and cached shaders are separated. Each channel then needs one dependent operation after the tilebuffer load and unpack instead of a multiply followed by a multiply-add.asahi: issue uniform-only G16 fragment arithmetic before the pixel wait. After scheduling,fadd,fmul,ffmaandmov_immcomputed only from uniforms and immediates move ahead of the firstwait_pixof a G16G fragment block. For a uniform-colour blend the source terms (clamps,1 - alphaand the source products) are then computed before the ordered colour section, which holds only the tile load, unpack, one multiply-add per channel, pack and store. Texture, varying and tile-dependent work keeps its scheduled place. Operations, modifiers and operands are unchanged.Opt-outs:
ASAHI_G16_BLEND_DST_FIRST=0andASAHI_G16_PIX_HOIST=0(both part of the compiler cache identity). The selected 1080p blended-fill program stays at 170 bytes / 22 instructions; only association and order change.Testing
This improves blended fill by about 5 %; it is not a parity claim. No Apple binaries or captures are included.