xshader: keep the wave together for a program that walks its lanes #609

Merged
NickStallman merged 4 commits from upstream-pr/609 into main 2026-12-01 03:18:28 +00:00
NickStallman commented 2026-12-01 02:39:18 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-12-01T02:39:18Z.


A 32-lane compute program that walks its lanes in order (a scalar counter, reads of lane N's registers with v_readlane_b32, a write-back to the one lane v_cmpx_eq_u32 sN, lane selects) was refused as "compute swizzle inside a loop": the lane exchange sits in a loop the one-thread-at-a-time translation can't take. The lockstep translation can, because it keeps the wave together, but its retry ran only for the refusal "inside non-uniform loop". It now also runs for this one.

Refs #533 (claimed there). Based on a4eeeac9.

Why it is sound, and one gap closed

  • Every branch is a vote of the whole wave, and a lane read by number becomes a whole-wave read that ignores EXEC, as on the console; the write-back is guarded by each invocation's own EXEC bit; all invocations run a statement together, so a read sees every earlier write. This is the existing lockstep model.
  • Not covered before: a lane read by number names a host lane, while the program numbered its lanes by thread (v0 = gtid.x). Nothing promises thread N sits in host lane N. A program admitted this way now takes the host's lane number (WaveGetLaneIndex()) as its thread number. It is admitted only for a 32x1x1 group under [WaveSize(32)], and only if the finished HLSL has no other source of a thread or lane number. Anything else keeps the old refusal.
  • Still assumed, as for all lockstep programs: a 32-thread group under [WaveSize(32)] is one host wave.

Measured

  • Recorded ProjectScarlett requests (54,859, both hosts, against a4eeeac9): 6 programs newly accepted on both hosts (12 requests), 0 newly refused, 0 changed. All compile with DXC 1.9.2609 and pass dxv.
  • The two that a run's timeline shows in use are refused dispatches about 49 and 0.3 times a frame in the world. In a 17-minute ProjectScarlett run of an integration build with this branch (RTX 5090), the two programs were dispatched 25,780 and 179 times with none skipped (before: 49 a frame skipped). That run lost the GPU near the end to our own capture code, which is not part of this branch; whether the solver's results look right hasn't been checked.
  • Unit tests and mutations: a synthetic walk is refused the old way and translates here; the same program in 8x4, 64x1 and 16x1 groups stays refused; the numbering rule has its own test. 11 mutations, 10 caught: skipping the final HLSL numbering check is not, because no program reaches it (the emitter always numbers a walk by host lane); its function is tested directly.
  • GPU check lockstep gains a sweep: pass n reads lane n and, where its value is odd, writes the sum of lanes n and n + 1 back to lane n + 1 alone; a CPU model walks the lanes. The inputs are checked to tell the walk from a reversed one and from one that never writes back. 792 cases, all match, on both cards.
  • Full python tuxbox.py check of c17adcfa (GE-Proton11-15): RTX 5090 (10de:2b85, 620.70.10) 206 pass, 0 fail; AMD iGPU (1002:13c0, RADV) 205 pass, 0 fail.

Evidence: TuxBox check of c17adcfad8, no uncommitted changes, GPU 10de:2b85: 17 passed, 0 failed, 0 not run
Evidence: TuxBox check of c17adcfad8, no uncommitted changes, GPU 1002:13c0: 17 passed, 0 failed, 0 not run

Not covered

  • 6 other programs of the same family stay refused ("whole-wave lane reads need a program of complete 32-lane waves"), as do two resolve families and a screen-space shadow trace with the same text. I haven't looked into them.
  • Whether the solver's results are right in the game has not been seen: the picture isn't readable enough yet.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5577837771 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/609). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-12-01T02:39:18Z. --- A 32-lane compute program that walks its lanes in order (a scalar counter, reads of lane N's registers with `v_readlane_b32`, a write-back to the one lane `v_cmpx_eq_u32 sN, lane` selects) was refused as "compute swizzle inside a loop": the lane exchange sits in a loop the one-thread-at-a-time translation can't take. The lockstep translation can, because it keeps the wave together, but its retry ran only for the refusal "inside non-uniform loop". It now also runs for this one. Refs #533 (claimed there). Based on a4eeeac9. ## Why it is sound, and one gap closed - Every branch is a vote of the whole wave, and a lane read by number becomes a whole-wave read that ignores EXEC, as on the console; the write-back is guarded by each invocation's own EXEC bit; all invocations run a statement together, so a read sees every earlier write. This is the existing lockstep model. - **Not covered before:** a lane read by number names a host lane, while the program numbered its lanes by thread (`v0 = gtid.x`). Nothing promises thread N sits in host lane N. A program admitted this way now takes the host's lane number (`WaveGetLaneIndex()`) as its thread number. It is admitted only for a 32x1x1 group under `[WaveSize(32)]`, and only if the finished HLSL has no other source of a thread or lane number. Anything else keeps the old refusal. - **Still assumed**, as for all lockstep programs: a 32-thread group under `[WaveSize(32)]` is one host wave. ## Measured - **Recorded ProjectScarlett requests** (54,859, both hosts, against a4eeeac9): 6 programs newly accepted on both hosts (12 requests), 0 newly refused, 0 changed. All compile with DXC 1.9.2609 and pass dxv. - The two that a run's timeline shows in use are refused dispatches about 49 and 0.3 times a frame in the world. In a 17-minute ProjectScarlett run of an integration build with this branch (RTX 5090), the two programs were dispatched 25,780 and 179 times with none skipped (before: 49 a frame skipped). That run lost the GPU near the end to our own capture code, which is not part of this branch; whether the solver's results look right hasn't been checked. - **Unit tests and mutations:** a synthetic walk is refused the old way and translates here; the same program in 8x4, 64x1 and 16x1 groups stays refused; the numbering rule has its own test. 11 mutations, 10 caught: skipping the final HLSL numbering check is not, because no program reaches it (the emitter always numbers a walk by host lane); its function is tested directly. - **GPU check `lockstep`** gains a sweep: pass n reads lane n and, where its value is odd, writes the sum of lanes n and n + 1 back to lane n + 1 alone; a CPU model walks the lanes. The inputs are checked to tell the walk from a reversed one and from one that never writes back. 792 cases, all match, on both cards. - Full `python tuxbox.py check` of c17adcfa (GE-Proton11-15): RTX 5090 (`10de:2b85`, 620.70.10) 206 pass, 0 fail; AMD iGPU (`1002:13c0`, RADV) 205 pass, 0 fail. Evidence: TuxBox check of c17adcfad81b, no uncommitted changes, GPU 10de:2b85: 17 passed, 0 failed, 0 not run Evidence: TuxBox check of c17adcfad81b, no uncommitted changes, GPU 1002:13c0: 17 passed, 0 failed, 0 not run ## Not covered - 6 other programs of the same family stay refused ("whole-wave lane reads need a program of complete 32-lane waves"), as do two resolve families and a screen-space shadow trace with the same text. I haven't looked into them. - Whether the solver's results are right in the game has not been seen: the picture isn't readable enough yet. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
brcly/TuxBox!609
No description provided.