Implement cheaper wave64 mesh shaders on 32-lane GPUs, IDEA 2 #69
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ThatRecompDev--five-star-recomp!69
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-69"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@almostxxx27 on GitHub · 2026-11-27 11:19 UTC · original
almostxxx27:issue-35-uniform-first-lane-reads→main· +181 −21 · 11 files · 3 commits · merged 2026-11-27 22:12 UTCPart of #35 (Idea 2: prove more operations wave-size independent).
Three rules in
Translation/Waveslet the mesh-window analysis prove morev_readfirstlaneresults are the console's, so fewer programs whose only blocker was a first-lane read fall to the superstep form.Changes
Compound assignments keep their facts (
WindowStatement.Parts,StatementTransfer.Apply)v_mad_u64_u32and the 64-bit shifts emitif (active) { lo = (uint)_p; hi = (uint)(_p >> 32); } }. This parsed as an opaque statement and dropped every uniformity fact, so areadfirstlaneof the result counted as "of a per-lane value". Each half is now applied as the guarded assignment it is.Bits equal on all lanes are exact under any EXEC (
ValueRules.FirstLane)readfirstlane(x)returns some lane'sxeven when the window holds no active lane or its active lanes are not the console's. So the bits that areAllUniform(an SGPR copy, the group's bits of the mesh thread id) are the console's regardless. Before, the result was unknown unless EXEC was exact and non-empty.Opaque non-effect statements propagate uniformity (
StatementTransfer.Opaque)GetDimensions, class-switch loads andasuint(double, lo, hi)now give their results the uniformity of what they read. Effects (an atomic's old value) stay per-lane.asuint(d, lo, hi)now also markslo/hias assigned. Before, they kept their declared "exact and uniform" fact, which was unsound.Tests
WaveEmulationTests: 3 new rows onA_mesh_program_states_whether_narrower_waves_give_console_results(64-bit multiply-add from SGPRs, the same with a VGPR operand, and a 64-bit shift), plus a new theoryA_first_lane_read_of_bits_equal_on_all_lanes_is_the_consoles_whatever_lanes_the_wave_holds(mesh thread id masked to the group bits under an inexact EXEC).mainand pass with this change. The new.binprograms are committed intests/FiveStar.Shaders.Tests/Assembled/.FiveStar.Shaders.Testssuite: 588 passed, 0 failed, 14 skipped (with DXC).Docs
docs/shader-translation.md: updated thev_readfirstlanerow in the Mesh windows table.docs/issue-35-wave64-mesh.md: write-up of the three ideas and of this first step.@ThatRecompDev on GitHub · 2026-11-27 12:08 UTC · original
hey, thanks a lot for picking this up, and for writing rows that actually fail on main. I went through it properly and ran it against the whole shader dump. (also re-assembled your seven test programs from the source here, they come out byte for byte the same as the .bin files you committed.)
the compound assignment part looks solid to me, and you're right that the asuint lo/hi thing was unsound before, nice catch.
I did run into three cases where the analysis now says more than is true though.
the first is the "any EXEC" rule: our readfirstlane in the prelude doesn't return some lane's value when the window has no active lane, it does
vw_read(x, 0), and for a window that doesn't hold console lane 0 that comes back as 0. so the group bits of the thread id end up wrong for every group except group 0. your first row in the new theory is actually that case, it just doesn't show because nothing draws it (it does show on WARP's 4-lane waves with two groups, 2 pixel mismatches). if you only take those bits when the window is known to hold an active lane it's fine again.the second is atomics. buffer, global and image atomics are emitted as two lines, and the first one (
uint _at = 0; if (active) { RWByteAddressBuffer ...) isn't an effect, so the old value now counts as uniform and a readfirstlane of it turns intos23 = v21;in the superstep form. the Interlocked line needs to mark its last argument as assigned.the third is small: the guard check only looks at statements that start with
if (active), and v_movreld emits a switch with theif (active)inside each case, so it gets "equal on all lanes" under a partial EXEC. treating anything that readsactiveas guarded fixes it. that one fails a draw on WARP and on a 4090.on the numbers: on the corpus (25,908 programs) this moves 3 mesh programs from 64 to 4 (MS_VS_TransformD_c5fd36bb and the two MirrorReflectionTransformD ones) and changes the reason comment on 22 others, nothing else differs, no compute program changes. funny detail, the win doesn't come from the mad/shift rule at all, no mesh program in the dump has one. it comes from the texture view declaration now passing uniformity on, so a Load at scalar coordinates is uniform. worth saying that in the description. with the three fixes below the output is byte for byte the same as yours, so you lose nothing.
a few housekeeping bits: the Architecture tests fail on two things in WindowStatement.cs (ParseText is 61 lines, the limit is 60, and the
? :in the initializer needs to be an if/else). commit messages here goShaders: what changed. and I'd rather keep docs/issue-35-wave64-mesh.md out of docs/ and put it in the issue, docs only describe what the code does. one thing in there to double check too: NVIDIA cards report 32-32 for us and reject a 64 pin, so idea 1 doesn't work as written. the 2,548 figure it repeats from shader-translation.md is stale as well, that's on us (1,489 on this corpus today).since any translator change makes everyone re-translate, this would go in with the next translator batch rather than on its own.
here's the small patch that closes the three holes, take it or do it your own way:
fix suggestion (15 lines in Translation/Waves)
the three failing tests need assembled programs, so they don't fit in a comment, tell me if you want them and I'll push them to a branch.
really appreciate the work, this is a good direction. fix those and I'm happy to merge.
Compound if (active) { lo; hi; } assignments keep their facts, non-effect opaque statements (GetDimensions, texture view declarations, class-switch loads, asuint splits) pass on the uniformity of their reads, and a readfirstlane of bits equal on all lanes is exact when the window holds an active lane. Atomics mark their result argument assigned and per-lane, and a statement reading active (the v_movreld switch) counts as guarded.@almostxxx27 on GitHub · 2026-11-27 13:28 UTC · original
• (a) FirstLane takes AllUniform bits only when active.NonEmpty (the prelude's vw_read(x, 0) on an empty window).
• (b) The Interlocked* result argument is marked assigned and per-lane.
• (c) A statement reading active counts as guarded (v_movreld switch).
• Regression tests for all three (each fails on the old commit). ParseText is under 60 lines with no ternary, the commit message uses Shaders:, and the issue notes moved out of docs/ (posting the corrected version in #35).
• Corpus impact as you measured: 3 mesh programs 64→4, and the win comes from texture view declarations passing uniformity on, not from the mad/shift rule.
@ThatRecompDev on GitHub · 2026-11-27 22:12 UTC · original
merged (squashed onto today's main, 603 shader tests pass on the merged tree). thanks a lot for turning the fixes around so fast, and for the clean regression tests. if you pick up another of the #35 ideas, main has moved quite a bit in the translator today (three fixes in the scalar emitters and a new BlockConstants pass), so rebase first.
@almostxxx27 on GitHub · 2026-11-28 08:00 UTC · original
np