xshader: keep no local arrays in the console node test #520
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/520"
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-29T19:06:38Z.
For #509.
Summary
The console BVH node test filled a 32-word array in a loop and indexed vectors at run time, so each inlined copy kept 296 bytes of local arrays. One ProjectScarlett program holds 72 copies, 21,408 bytes a lane. On an RTX 5090, only creating such a pipeline makes another program lose the device (#509); the signs match a known NVIDIA bug, and this keeps clear of it.
The node's words are now read at constant indices and vector components picked by comparison, which DXC turns into plain values. A type 5 node reads its upper 64 bytes only when it needs them. The largest local array in the recorded programs is 96 bytes a lane.
Measured
Of the compute requests recorded, 200 translations change, all of them console walks; 9,868 stay the same; no request changes whether it translates. (Other stages were not translated; the changed text is only added to programs that contain the call.)
brcly measured all 125 recorded BVH programs (2 passes): private memory 21,408 to 96 bytes a thread, programs over 8 KiB 16 to 0, DXIL 63.6 to 59.1 MB, DXC time 598 to 610 s (+2%). My counts above are of distinct translations.
Tested
tests/test_bvh_node_scratch.py, skipped withoutdxc) that no local array is left; seven mutations each fail it.python tuxbox.py check --no-gpu.tools/reference/bvh-node/nativepassed, and its nine synthetic dumps (48 box and 492 triangle cases) were compared withnode.hlslfrommain(2d6dc338) and from this branch (4564db59), on RADV (Mesa 26.0.8) through GE-Proton11-14, default and--strict. Both versions return identical words in all 540 cases in both modes. Against the native instruction both differ in the same 222 cases by default and 161 with--strict, so this neither fixes nor adds a mismatch. I usedcheck_native_bvh_hlsl.pywith its NVIDIA half removed and its case limit raised, so that it takes the edge, degenerate, scale, mixed and underflow dumps. The box code compiles to the same DXIL, so only the triangle cases exercise this change. It doesn't cover the node loading inbvh_node.rs, NVIDIA, or recorded nodes.python tuxbox.py checkof4564db59on an RTX 5090 (10de:2b85, 620.70.10, GE-Proton11-14): exit 0, 192 pass, 0 fail.1002:13c0, RADV, Mesa 26.0.8): exit 0, 191 pass, 0 fail.090cf6ceplus our diagnostics and this change): in the one conclusive run (warm cache; the log shows both suspect programs requested, and the run's failure report lists neither, so I take them as created), the loss this targets did not happen. The run presented for 501 s after the story starts loading; the 12 earlier runs with these programs on that base were lost within 54 s. It was then lost anyway, with an Xid 13 MMU fault in mesh draws (no fault address reported), not on thed7674d99…dispatch the earlier ones died on. The first mesh program of that crash region also leads the one in a run on an older build without18189694, so I believe it is a separate, older fault; I haven't proved that. Two earlier game runs were inconclusive (a cold driver cache, and one that reached the story with under 10 s left). One run is not many.🤖 Generated with Claude Code
Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T19:45:01Z.
Thanks for this. I measured it against
mainon all 125 recorded BVH programs (DXC 1.9, same flags as the runtime, 2 passes each, 3 jobs at a time):All 125 translate and compile. I couldn't time the NVIDIA driver on these: the standalone pipeline timer can't create d29efb84's root signature, so the driver side is still unmeasured.
To offset the extra DXC time, I've pushed one commit onto your branch (
e1d5b043): structured loops now count their 65536-iteration watchdog at the top of awhile (true)body instead of in aforheader. The header's induction variable gives DXC's loop passes a trip count to work out for every loop. Same cap, including throughcontinue. On the 30 slowest of 600 random compute requests: 3.6% less DXC (5–27% on loop-heavy programs), with the same DXIL. It passed the full check on an RTX 4070 Ti SUPER and a Radeon 610M on its own. On top of your commit, the 630 translator unit tests andtests/test_bvh_node_scratch.pypass; I haven't run the GPU checks on the combination.If you're happy with the idea, we can merge both together once your checks are through; if you'd rather keep the PR to the node test, say so and I'll take it back off and land it separately.
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T19:49:51Z.
Thanks for measuring it. Your 16 programs over 8 KiB are the 8 at 21,408 and the 8 at 10,752; mine counted distinct translations, so that settles the difference. I'll use your numbers in the description.
Please take
e1d5b043off and land it separately. The idea looks fine to me, but:4564db59as well; the AMD one is still queued.I haven't reviewed
e1d5b043in detail. I won't push to the branch while it's there.Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T19:51:06Z.
Done: the branch is back at your
4564db59, and I won't push to it again. I'll land the loop header change separately, after #522's loop limits are settled. The per-loop caps multiplying when loops nest (65,536 × 65,536) is a fair point; I'll take that up with the header change rather than here.Once your AMD check and game runs are through and the PR is out of draft, I'll merge it.
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T20:46:09Z.
Out of draft: full checks are through on an RTX 5090 (192 pass) and an AMD iGPU (191 pass), and one conclusive game run is in. The loss this targets didn't happen: 501 s past the point where the 12 earlier runs died within 54 s. That run was still lost later, in mesh draws, with an Xid 13 MMU fault and no address. The crash region's first program is one that also leads the region of a loss on a build without
18189694, so I think it's an older fault, but I haven't proved that. Details are in the description. It isn't a claim that the game no longer crashes.