xshader: run lane-read loops that spill scalars as paired waves #546
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/546"
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-29T21:10:55Z.
#492 runs a constant lane read in a non-uniform loop as a paired wave, but refuses a program that also spills scalars with
v_writelane_b32. ProjectScarlett's five transmission-volumetrics programs are of that kind: one whole wave64 per group, sums over the wave in a loop lanes leave at different times, and SGPR spills.v_writelane_b32in the whole-wave proof. Likev_readlane_b32it ignores EXEC and takes one scalar of the wave. Barrier, branch, width and encoding requirements are unchanged.v_cvt_f32_f64takes an aligned scalar pair.Only programs refused today change. The explicit wave32-host paired form is left as it was.
Tested
New unit tests; 11 mutations of the change each make one fail (three repeated on
70781497).python tuxbox.py check --no-gpu: passed on70781497(4198b48c).All recorded requests (47,526 containers, compute also with
--wave32-host, 1,908 linked pairs, and the runtime's stride retry) onf482572a: 17 compute programs newly accepted, none newly refused, none changed. All 17 compile and pass dxv (DXC 1.9.2609.5, without-fnew-inlining-behavior).Of 5,366 recorded compute requests, the 1,999 that contain either affected instruction were translated before and after, plain and with
--wave32-host: 17 newly translate, none newly refused, 1,685 accepted outputs byte-identical.The five programs compile without
-fnew-inlining-behaviorand pass dxv at DXC 1.9.2609.5. Times at load 20: 11 to 69 s on the CLI, 9 to 60 s with the helper, so the largest (Submerged) sits at the runtime's 60 s -O1 limit. Onf482572a(70781497's patch) its three recordings took 75, 89 and 126 s at load 10 to 13, so compilation at -O0 looks likely there. With the flag, all five fail validation (Instructions must be of an allowed type, at<2 x i32>vectors): the helper's output is rejected, the CLI's retry fails too, and the runtime drops the flag. The trigger is the soft-f64 helpertb_f64_unpack, whoseout uint2is written in three branches. A change that builds it from scalars avoids it (14 lines, tried on lavapipe, not in this PR because it changes the HLSL of every f64 program).lavapipe, with the wave intrinsics replaced by group-shared exchanges: the three new
check_paired_wave64.pyprograms match its model in 64-thread groups.mainrefuses them.check_paired_wave64.py(branch merged into main39463ea5): RTX 5090 (10de:2b85, 620.70.10) and AMD iGPU (1002:13c0, RADV): 84 programs, all words match the model on both, including the nine new cases (spill, spill with vector registers, f64 sums; 1, 2 and 4 waves).Full
python tuxbox.py checkofab18a46c(rebased ontoe5d2e913; three lint fixes, no change in behaviour; HLSL of 1,597 random and the 17 named programs unchanged): RTX 5090 (10de:2b85, 620.70.10) 200 pass, 0 fail; AMD iGPU (1002:13c0, RADV) 199 pass, 0 fail. GE-Proton11-14.Known hazard, not touched here: main's explicit wave32-host paired form can bind an old buffer after a lane read overwrites a loaded descriptor (a synthetic test shows it); none of 217 recorded programs with an accepted paired output shows a difference at a memory instruction.
Game (RTX 5090
10de:2b85, 620.70.10, GE-Proton11-14; an integration build of007b982dwith this and other open PRs, two runs): the five pipelines finished compiling in the driver, in the second run (a part-filled driver cache) after 6, 6, 24, 31 and 407 s. In the first, with a cold cache, four finished after 41 to 268 s and the largest (4.1 MB DXIL) was still compiling, for over five minutes, when the run ended. Until then they're stand-ins.On an RX 9070 XT (RDNA 4, @Kayotic1337, with this and other PRs), four of the five finished compiling in the driver in 6 to 12 s; the fifth (
0a927142) isn't in that log, which only names pipelines that took 5 s or more.Not run: the programs in a drawn frame; nothing yet shows them dispatched. No claim about the picture or speed.
Prepared with AI assistance.
Evidence: TuxBox check of
ab18a46cb6, no uncommitted changes, GPU 10de:2b85: 16 passed, 0 failed, 0 not runEvidence: TuxBox check of
ab18a46cb6, no uncommitted changes, GPU 1002:13c0: 16 passed, 0 failed, 0 not run🤖 Generated with Claude Code
Imported from brcly/TuxBox. Originally posted by Kayotic1337 on 2026-11-30T00:50:03Z.
Game runs on an RX 9070 XT (
1002:7550, RDNA 4, RADV / Mesa 26.3.1, GE-Proton11-14, Linux 7.3.6). Build:mainf482572a+ #557 + #546 (70781497) + #548 (58198ae6) + #535 (fbbe6e0e), all merged cleanly.f360038dwithout these PRs. That is roughly the 5 + 5 programs these PRs recover, but the runs differ in length and the log only names programs by hash, so I can't say which programs these are.TUXBOX_XMEM_PRIVATE_VIEWS=1): the menus run at about 300 presents per 10 s. It reaches frame 2716 of the first cutscene (int_prolo), then hits the same compute TCP write permission fault (0x741041) I saw onmainbefore these PRs.Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-30T01:20:18Z.
Thanks, that's useful, and you're right that it doesn't show the programs dispatched. The log names programs by source digest and, for compute pipelines, by request. Filter on these:
TransmissionVolumetrics*(#546)07e0061f,0a927142,3f81993d,4efd015d,f9c81a48GenerateShadowMasks*andComputeStickyLips(#548)1a703579,a3c29b75,ae88c100,d7965490(the four I recorded for the masks)On an RTX 5090, our log has the first five compiled in the driver after 6 to 407 s (they're stand-ins until then) and none of the other four at all. Neither log of ours shows a dispatch. If yours names any of the nine, I'd like to know whether as "unsupported", "queued" or "finished".
Imported from brcly/TuxBox. Originally posted by Kayotic1337 on 2026-11-30T02:01:44Z.
Thanks, filtering on those works. Both runs from my comment above (
0102cold,0142warm, same build with #546 and #548), RX 9070 XT:#546: four of the five appear, all as compute pipelines that finished in the driver:
f9c81a48ecd781dc…dxc failed (5)-> without-inlining07e0061fb5fb0324…dxc failed (5)-> without-inlining3f81993de8570a69…timed out-> O04efd015d1564849c…dxc failed (5)-> without-inlining0a927142Each of the four logs "still running 5s" before "finished", and
big_stack.rsonly logs a pipeline that takes 5 s or more (unless its request is traced). So0a927142may simply have been faster, and its absence doesn't show it was refused. None is logged as unsupported.#548: none of
1a703579,a3c29b75,ae88c100ord7965490appears in either log: not as unsupported, queued or finished.As in your logs, I see nothing that shows a dispatch of any of the nine. Both runs ended in the first cutscene (
int_prolo).Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T04:12:15Z.
Heads-up: main just landed a large cleanup (up to
e5d2e913), so this PR needs a rebase.rustfmt.toml).unwrap(), lossyascasts and undocumentedunsafeoutside tests.cargo fmt --check, rustdoc with warnings denied, and Miri on the providers' unit tests.The least painful way is to format your branch first, so the rebase only shows real changes:
Then run
python tuxbox.py check --no-gpu, which now includes the format step.If clippy flags something new:
Fromfor widening,TryFromfor narrowing, and a mask for bit fields.unwrap(): use?, orexpectwith the reason it can't fail.unsafeblock: it needs a// SAFETY:comment.CONTRIBUTING's "Code checks" section lists the commands. Thanks!
Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T11:22:44Z.
Merged into main as
3926959e(squashed and credited to you). Thanks, and thanks @Kayotic1337 for the RDNA 4 runs.Checked here:
Compile cost, for whoever picks up the speed side next. On a 16-core machine at load 3 to 4, the four ~3.3 MB HLSL programs took about 12 minutes each at -O1 (six compiles in parallel), and two smaller ones took about 3 minutes. That's far slower than the 11 to 69 s you saw, so in the runtime they'll always miss the 60 s -O1 limit and fall back to -O0. For
3f81993d, -O0 takes 35 s at a 3.3 GB peak and gives 5.3 MB of DXIL. That DXIL is what the driver then spends minutes on, as in your cold 5090 run. Yourtb_f64_unpackscalar rewrite, or anything else that shrinks these programs, would be well worth a follow-up.Pull request closed