Repository navigation
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
The shared shader changes still need human hardware validation because required AMD checks are unrun and the packed-ballot path has no reported runtime measurement.
No open issues 🎉
What changed in this PR
Updates TuxBox’s shader translator to avoid lane-dependent short-circuit evaluation around ballot operands, addressing reported NVIDIA GPU hangs.
Changes:
- Replaces
&&with eagerand(...)at five ballot emission sites. - Adds a regression test checking the emitted ballot form.
| File | Description |
|---|---|
| tools/shader-compiler/src/tests/hlsl/exec_group_wave32.rs | Tests that resolve ballots avoid short-circuit operands. |
| tools/shader-compiler/src/hlsl/float64_div.rs | Uses eager evaluation for the division carry ballot. |
| tools/shader-compiler/src/hlsl/emitter/vector.rs | Uses eager evaluation for the vector carry ballot. |
| tools/shader-compiler/src/hlsl/emitter/vector_wide.rs | Updates resolve comparisons, packed comparisons, and carry ballots. |
Review effort: Balanced
|
AMD run, and a second NVIDIA hang that this fixes. AMD. PR head 705be7c on a Radeon iGPU (1002:13c0), GE-Proton11-15, Windows DXC 1.8.2505, That includes the wave32 guard checks (wave-guard-32-*, 33 cases each) and mask-ballots (665 cases). The shader-compiler tests pass natively too, with the new test among them. A second hang, on an RTX 5090 (NVIDIA 620). I had been chasing a different ProjectScarlett program that ends in Xid 109: a ray-traced shadow pass that dispatches without rays and still hangs. In its translation a per-lane Method: same request, same DXC, run standalone with a fixed pseudo-random input, 1,700 groups, outside the game:
The HLSL with this PR differs from 106120c's only in the 120 ballot lines ( Limits: one program, one input fill (a zero fill never hung, with or without either change), small counts. Not yet run in the game with this PR. 🤖 Generated with Claude Code |
|
Thanks @NickStallman. Another card and another program, with the two changes tested apart: that's a stronger confirmation than mine. I've added your AMD run to the description. |
Summary
What you see. With the programs that shade ray hits running, the console ray-tracing structures light the room in ProjectScarlett's first playable scene. The right side of the view (the drawings on the wall, the bunk) is lit by indirect light while the structures are on, and goes black when they are off. I alternated them every 45 s from a still camera, all nine walks served and nothing skipped. In one run the corner switched 5 times out of 5 each way (mean grey about 40 on, 3 off). A second, shorter run did the same (37 and 21 on, 3 off). On this card those programs used to stop the GPU 11 to 20 s after the world loaded, so this could not be seen.
What was wrong. Programs translated to one thread per console lane ballot their compares as
WaveActiveBallot((exec_lo & tb_lane_bit) != 0u && cond). HLSL's&&evaluates its right side only where the left one holds, so DXC branches on the lane around the operand. When another branch on the same condition follows, and then another ballot, the program NVIDIA's driver compiles never ends on some inputs: Xid 109, one dispatch in flight, no bad address. The smallest program I reduced it to has no loop. I take it for a convergence deadlock in the driver, which I can't confirm from outside.The change. Both sides are evaluated,
and(...)instead of&&, at the five places that write a ballot. The operands only read registers and constants.It changes many programs. 3,601 of the 38,785 ProjectScarlett requests in my cache that translate on their own (1,649 more don't), all
cs_6_6, so their cached shaders recompile. CONTRIBUTING asks to agree on that first: if you'd rather land it together with another translator change, that's fine with me. None of them uses the packed form ((exec_lo & 1u), one of the five places). I changed it for the same reason and have measured nothing on it.Tested
106120cawithout the change, see below)106120cahas tooGPU, driver and backend: RTX 4070 Ti SUPER 16 GB, NVIDIA 620.73.04, vkd3d-proton (Proton Experimental), Intel CPU.
AMD, run by @NickStallman on a Radeon iGPU (1002:13c0), GE-Proton11-15, Windows DXC 1.8.2505,
tuxbox.py check --changed 106120ca(his comment):No Lanes scenario: the hang needs two ballots and a branch arranged the way a title program has them, and a scenario that fails without the change would hang the card of whoever runs it. The unit test
a_resolve_ballots_without_branching_on_its_lanechecks the emitted form and fails without the change.Outside the game. I reproduced the hang with generated inputs, the same DXC and vkd3d-proton, and reduced one program to 57 lines of HLSL that still hang.
and(...)One of them wrote the same bytes before and after on the 60 inputs before its first hang. This branch's own translator output for the four programs also ran there: 29,000 inputs, no hang.
In the game. These runs did not use this branch's translator. They used
6d4f1cd7with #647 and local diagnostics, and the cached HLSL of the same programs rewritten the same way. 20 runs reached the world with the hit-shading programs running and nothing skipped. None ended with one of those programs stuck without a bad address.What I can't claim:
TUXBOX_READ_RESIDENCY=0,TUXBOX_CONSOLE_STRUCTURES=1and noTUXBOX_CONSOLE_WALKS.docs/ENVIRONMENT.mdsays only four walks can be served in ProjectScarlett. I left that line until that walk is fixed.Checks
No evidence JSON changes.