xshader: hide the lane number of mesh programs that vote (workaround) #473

Merged
NickStallman merged 1 commit from upstream-pr/473 into main 2026-11-29 14:37:55 +00:00
NickStallman commented 2026-11-29 13:20:23 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T13:20:23Z.


Summary

On an RTX 5090 (driver 620.70.10) some 32-lane waves of a 128-lane mesh group can get wrong register values in programs that vote over the group (#458). Such a program now makes its lane number as SV_GroupIndex ^ (SV_GroupID.x >> 16). A D3D12 dispatch dimension is at most 65,535, so the value does not change. Two instructions per program, no resource.

This is a workaround. The cause is not known. It replaces #459, which is closed (below).

What was measured

Reduced shader, plain Vulkan (no D3D12, vkd3d-proton or Wine), 64 edits of it, 45 wrong on the 5090:

Change to the same module made right made wrong (of 19)
index ^ opaque zero from an input word, GroupID.x/y/z >> 16, GroupID.z, GroupID.x >> 22, sqrt(index) >> 8 45 0
the same hidden in bits 5 and 6 only 45 0
index masked to 127, or min with 127, after the opaque xor 45 0
hidden in bits 0 to 4 only, or bit 0 only 1 1
controls: GroupID.x & 0, SubgroupSize >> 8 (both fold) 0 0
thread id instead of the index, a copy of it, loaded and unused 0 0
dispatch thread id minus group * 128 1 4

In the wrong edits looked at (up to eight modules), index >> 5 is the use that decides: hidden there alone the module is right, hidden in every other use it is wrong. In some modules hiding another single use also makes it right. The range does not matter (masked to 127 is as good) and the low bits do not. The reading that fits is that the compiler recognises index >> 5; that is an inference.

Translated programs, every export against the compute form: three that are wrong as they are on the 5090 are right with the change, and all are right on AMD.

Random sample of the voting programs (fixed seed, 150, 30 from each of five size classes, none of them used to find or tune this). Each ran as mesh against the same program as compute: counts, indices and up to 58 vertex words of every lane, up to 12 vertex counts, three groups. 148 could be built.

Wrong RTX 5090 AMD iGPU
as they are 48 of 147 (33%) 0 of 147
index ^ a root constant that is zero 0 of 147 0 of 147
index ^ (GroupID.x >> 16), this change 0 of 147 0 of 147

No program became wrong. One more (the largest) had its root signature refused on both cards, and two used a resource kind the test does not support. By size class the wrong ones are 5, 10, 12, 16 and 5 of about 30. The wrong lanes lie in 0..31 in 27 programs, within 0..63 in 14, and elsewhere in 7 (64..95 alone in 3), so it is not only the first wave. 146 of the 147 have lanes that produce vertices.

Limits of that test: inputs are random, textures and heap resources are stubs, every buffer is a sized descriptor (which changes the code), and primitive attributes are not compared. 0 of 48 leaves room for a failure rate of up to about 6% among programs like these (95%).

Why not #459

Selects in place of the branches made 45 of 45 right, but so did as many selects on other values with the branches kept, and four more live values. So that was a perturbation. It also makes programs wrong: two copies of one recorded program that is right on the 5090 as translated are wrong (906 lanes) in #459's form, and right with this one.

Tested

Survey of 47,508 recorded requests, main (6e2c5dab) and this change: 13,858 of 19,872 mesh programs changed, all of them vote; 0 other programs; 0 newly refused.
DXC 1.8.2505.1, 600 of the changed programs at random and the 10 largest: 0 errors; +0.03% instruction lines (2 per program), +0.01% bytes, the same phis, branches, selects and barriers; 169.7 and 167.5 s.
python tuxbox.py check --no-gpu passed. The unit test fails with the change off, and with it applied to programs that do not vote.
Full tuxbox.py check at a65c5c45: RTX 5090 (620.70.10) 187 pass, 0 fail; AMD iGPU (RADV) 186 pass, 0 fail, guest-present-4k-splash skipped (software display). A game run on an RTX 5090, in a build with this (and #463, #461, #441, #390, #468 and diagnostics on main 6e2c5dab; warm caches, cold mesh pipelines): it ran about 700 s after the story started loading and ended in an Xid 13. The loading art was still up 160 to 230 s in, so the scene was on screen for roughly the last 8 minutes, with characters drawn (an earlier version of this text said 700 s). One run, and the build differs from earlier ones in several ways, so it shows the change works in the game, not that the game got further because of it. No game run compares it alone.

Not measured or unexplained

  • GPU and frame time; a game run that isolates this change.
  • Why exactly 128 threads (127, 112, 100, 97, 96, 64 and 32 are right in the reduced shader) and why only in mesh. Compute forms of the same code are right.
  • What the wrong value is. In the reduced shader it is a constant (0x10000) that follows no input and no literal tried.
  • Other NVIDIA cards and drivers, a discrete AMD card.
  • Whether hiding only the group exchanges would be enough in translated programs.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5551108961 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/473). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T13:20:23Z. --- ## Summary On an RTX 5090 (driver 620.70.10) some 32-lane waves of a 128-lane mesh group can get wrong register values in programs that vote over the group (#458). Such a program now makes its lane number as `SV_GroupIndex ^ (SV_GroupID.x >> 16)`. A D3D12 dispatch dimension is at most 65,535, so the value does not change. Two instructions per program, no resource. This is a workaround. The cause is not known. It replaces #459, which is closed (below). ## What was measured Reduced shader, plain Vulkan (no D3D12, vkd3d-proton or Wine), 64 edits of it, 45 wrong on the 5090: | Change to the same module | made right | made wrong (of 19) | | --- | --- | --- | | index ^ opaque zero from an input word, GroupID.x/y/z >> 16, GroupID.z, GroupID.x >> 22, sqrt(index) >> 8 | 45 | 0 | | the same hidden in bits 5 and 6 only | 45 | 0 | | index masked to 127, or min with 127, after the opaque xor | 45 | 0 | | hidden in bits 0 to 4 only, or bit 0 only | 1 | 1 | | controls: GroupID.x & 0, SubgroupSize >> 8 (both fold) | 0 | 0 | | thread id instead of the index, a copy of it, loaded and unused | 0 | 0 | | dispatch thread id minus group * 128 | 1 | 4 | In the wrong edits looked at (up to eight modules), `index >> 5` is the use that decides: hidden there alone the module is right, hidden in every other use it is wrong. In some modules hiding another single use also makes it right. The range does not matter (masked to 127 is as good) and the low bits do not. The reading that fits is that the compiler recognises `index >> 5`; that is an inference. Translated programs, every export against the compute form: three that are wrong as they are on the 5090 are right with the change, and all are right on AMD. Random sample of the voting programs (fixed seed, 150, 30 from each of five size classes, none of them used to find or tune this). Each ran as mesh against the same program as compute: counts, indices and up to 58 vertex words of every lane, up to 12 vertex counts, three groups. 148 could be built. | Wrong | RTX 5090 | AMD iGPU | | --- | --- | --- | | as they are | **48 of 147** (33%) | 0 of 147 | | index ^ a root constant that is zero | 0 of 147 | 0 of 147 | | index ^ (GroupID.x >> 16), this change | 0 of 147 | 0 of 147 | No program became wrong. One more (the largest) had its root signature refused on both cards, and two used a resource kind the test does not support. By size class the wrong ones are 5, 10, 12, 16 and 5 of about 30. The wrong lanes lie in 0..31 in 27 programs, within 0..63 in 14, and elsewhere in 7 (64..95 alone in 3), so it is not only the first wave. 146 of the 147 have lanes that produce vertices. Limits of that test: inputs are random, textures and heap resources are stubs, every buffer is a sized descriptor (which changes the code), and primitive attributes are not compared. 0 of 48 leaves room for a failure rate of up to about 6% among programs like these (95%). ## Why not #459 Selects in place of the branches made 45 of 45 right, but so did as many selects on other values with the branches kept, and four more live values. So that was a perturbation. It also makes programs wrong: two copies of one recorded program that is right on the 5090 as translated are wrong (906 lanes) in #459's form, and right with this one. ## Tested Survey of 47,508 recorded requests, main (6e2c5dab) and this change: 13,858 of 19,872 mesh programs changed, all of them vote; 0 other programs; 0 newly refused. DXC 1.8.2505.1, 600 of the changed programs at random and the 10 largest: 0 errors; +0.03% instruction lines (2 per program), +0.01% bytes, the same phis, branches, selects and barriers; 169.7 and 167.5 s. `python tuxbox.py check --no-gpu` passed. The unit test fails with the change off, and with it applied to programs that do not vote. Full `tuxbox.py check` at a65c5c45: RTX 5090 (620.70.10) 187 pass, 0 fail; AMD iGPU (RADV) 186 pass, 0 fail, guest-present-4k-splash skipped (software display). A game run on an RTX 5090, in a build with this (and #463, #461, #441, #390, #468 and diagnostics on `main` 6e2c5dab; warm caches, cold mesh pipelines): it ran about 700 s after the story started loading and ended in an Xid 13. The loading art was still up 160 to 230 s in, so the scene was on screen for roughly the last 8 minutes, with characters drawn (an earlier version of this text said 700 s). One run, and the build differs from earlier ones in several ways, so it shows the change works in the game, not that the game got further because of it. No game run compares it alone. ## Not measured or unexplained - GPU and frame time; a game run that isolates this change. - Why exactly 128 threads (127, 112, 100, 97, 96, 64 and 32 are right in the reduced shader) and why only in mesh. Compute forms of the same code are right. - What the wrong value is. In the reduced shader it is a constant (0x10000) that follows no input and no literal tried. - Other NVIDIA cards and drivers, a discrete AMD card. - Whether hiding only the group exchanges would be enough in translated programs. 🤖 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!473
No description provided.