Repository navigation
Conversation
A translated thread holds only its own bit of a lane mask, so counting a mask's lanes (s_bcnt1), finding its first one (s_ff1) or counting those before a lane (v_mbcnt) gave 0 or 1 for a whole wave. Compute programs that hand out list slots this way gave the same few slots to every thread: in ProjectScarlett the shadow mask tiles of lit surfaces, which showed as 16-pixel blocks. Find the masks such instructions read by their reaching definitions, take the wave's ballot right after each one, while every lane that can be in it is there, and read that. A register that holds anything else on some path keeps the old translation. One-word masks need 32-lane waves. Two words hold a wave of any size, so wave64 programs gain no requirement and still run on adapters that only have wave32. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Static review against current main found multiple high-risk correctness issues before merge: (1) 64-bit counts can combine a captured low mask with a stale high word; (2) implicit scalar writes such as v_readfirstlane and VOP3B carry outputs are missing from reaching definitions; (3) WaveActiveBallot cannot reconstruct a 64-lane mask on a wave32 host, so the advertised wave64 fallback changes results; (4) partial waves can produce wrong counts because the width requirement is applied after complete-wave validation; (5) operand width is used as wave-width evidence, causing false SGPR aliases; (6) captures under divergent control flow do not see the whole wave; (7) high-word ballot names/declarations are incomplete. Please address these with focused regressions before merging. |
Review fixes for reading lane masks as numbers: - Ray tracing resolve programs keep whole masks already. A ballot of one lane's bit broke their counts in about 1,000 programs. - Both words of a wave64 mask must come from the same definitions, and a 64-bit count must start at the first word. - v_readfirstlane, v_readlane and the scalar carry of VOP3B instructions count as writes, and a VOP2 carry writes VCC. - Masks are moved and combined only at the wave's width, and a program that uses both widths of EXEC, or the second word in a 32-lane wave, gets no ballots. S_WQM is not followed. - A ballot is taken only where the lanes that can be in the mask run together: not where a branch on another mask skips or repeats, and not after an early exit. A branch on EXEC keeps the running lanes together. - The width is applied before the complete-wave check. A group that is not made of whole waves keeps the old translation, and a wave64 program needs wave64 instead of reading half a wave on a 32-lane host. Over the 24,463 ProjectScarlett programs I have, 76 change against main and none is newly refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Ai Thanks, these were right, and fixing them turned up a worse problem. All in 1270654:
The worse problem: ray tracing resolve programs ( |
Summary
A translated thread holds only its own bit of a lane mask, in the register's bit 0. Instructions that use a mask as a number see that single bit:
s_bcnt1andv_mbcntgave 0 or 1 for a whole wave, ands_ff1always gave lane 0.Compute programs use these to hand out list slots, so every thread got one of the same few slots. In ProjectScarlett this hits the shadow mask tiles: lit surfaces and people showed 16-pixel blocks. With the first version of this change their shadows were smooth in the game. The shadow tile passes are among the programs the current version changes, but I have not rerun the game with it.
The masks such instructions read are found by their reaching definitions. The wave's ballot is taken right after each definition and the counting instruction reads that. It is only taken where every lane that can be in the mask runs together: not in code that a branch on another mask skips or repeats, and not after some lanes have left the program. Both words of a wave64 mask have to come from the same definitions. A register that holds anything else on some path keeps the old translation, and so does a group that is not made of whole waves.
The program then runs in waves of the guest's width:
WaveSize(32)orWaveSize(64). A wave64 program therefore needs an adapter with wave64. The alternative, reading half a wave on a 32-lane host, gives different counts. #201's portable Wave64 lowering could lift this later. Ray tracing resolve programs keep whole masks already and are left alone. Shader Model 6.5 is used where a ballot is taken.Over the 24,463 ProjectScarlett programs I have, 76 change and none is newly refused. 33 of them, among them the shadow tile passes, now require wave64.
Verified on Lanes
python tuxbox.py checkpassed on this branchGPU, driver and backend: RX 9060 XT, RADV (Mesa 26.1.8), Proton Experimental
The same seven cases fail on plain main (7b22d71) on this machine, where I run the check in a private Xwayland inside a container. The branch only touches the translator. The full check above ran on the second commit.
Not a Lanes scenario because it is about single instructions. A new GPU check,
mask-ballots, assembles 300 small programs, runs them and compares every word with a reference: 300 of 300 pass. On plain main 200 of the 300 give wrong words. The unit tests cover each review point, and each of the six new ones fails on the first commit.Checks
cargo checkof tuxbox-d3d12 for x86_64-pc-windows-msvcdocs/SHADERS.mdhas a paragraph on it🤖 Generated with Claude Code