launcher: give each -O0 loop one block that returns to its header #535
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/535"
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?
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T20:33:58Z.
Problem. The DXC helper runs
-simplifycfgafter-O0code generation (#479). On a block-dispatcher program it can leave several blocks branching back to one loop header. dxil-spirv assumes one (cfg_structurizer.cpp,visit); with more its dominator walk recurses without end, the pipeline thread overflows its stack and dies, and the provider waits for it forever ("still running"). ProjectScarlett'sCS_ScreenProbes_ActivateRays(8ae931bd, requestfeb4cf08…) hit this in every run of ours I checked that has that DXIL (19), each with one Wine "stack overflow" line. The same program without-simplifycfgfinished compiling on an RTX 5090 in 174 and 161 s (two runs on builds without #479).Change. Run
-loop-simplifyafter it.Tested
tests/test_dxc_worker.py: four back edges before, one after. Removing the pass fails it.python tuxbox.py check --no-gpu: passed.python tuxbox.py checkofe6adb185(rebased ontoe5d2e913; no change to the patch): RTX 5090 (10de:2b85, 620.70.10) 200 pass, 0 fail; AMD iGPU (1002:13c0, RADV) 199 pass, 0 fail. GE-Proton11-14.On main (
2d6dc338) this program takes #489's structured form, which has one back edge per loop, so it should compile there as it is (no GPU run). Other block-dispatcher programs that fall to-O0can still hit this.Cost. The helper is part of the cache identity, so recorded shaders are compiled again once.
Game (RTX 5090
10de:2b85, 620.70.10, GE-Proton11-14; an integration build of007b982dwith this and other open PRs): the program's pipeline finished compiling in 146 s with a cold driver cache and 89 s in a second run that started from the first one's, with no stack overflow in either. That build also has the newer structured form, so the runs don't show which of the two fixed it. The second run reached the story and then ended in a crash that is still being looked into (a refused ray scene); neither shows the program being dispatched.Not run: an output comparison of the two DXIL forms (
-loop-simplifyis a stock LLVM pass).Evidence: TuxBox check of
e6adb18527, no uncommitted changes, GPU 10de:2b85: 16 passed, 0 failed, 0 not runEvidence: TuxBox check of
e6adb18527, no uncommitted changes, GPU 1002:13c0: 16 passed, 0 failed, 0 not run🤖 Generated with Claude Code
Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T09:17:13Z.
Thanks, the analysis is clear and the fix looks right:
-loop-simplifyis the stock way to restore one back edge per loop, and the synthetic test pins it down.I'm holding it rather than merging now, for one reason: cost against a benefit we can't measure on main today. The helper is part of the DXC cache identity, so merging this recompiles every player's shaders once. By your own numbers, though, nothing on current main hits the fault:
8ae931bdnow takes #489's structured form, and none of the other 241 large DXIL files you checked has it.Either of these would get it merged:
-O0on current main and hits the multiple-back-edge recursion (a request hash plus the stack-overflow line is enough).tools/dxc_worker.cppfor another reason. We'd fold this in so players recompile once, not twice.Leaving it open in the meantime.