Recompiler: shadow v_writelane spill slots in split-wave64 #911
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/917"
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 ivall/xcl. Originally posted by zondy1i on 2026-11-24T08:13:24Z.
��In split-wave64 mode (two hardware wave32 halves per console wave64), SGPR spill reloads (
v_writelane_b32�!v_readlane_b32with a constant lane) previously went throughxcl_x_rla_uniformand emitted a full cross-half exchange (bounded spin loop, barriers, and atomics), even though both halves already hold identical SGPRs (x64_maskskeepsv_writelane_b32's scalar source whole-live).This adds a conservative forward must-analysis (
upper_lanes::analyze_spills) for split-wave64Kernel,Compute, andMeshprograms so constant-lane spill reloads read a scalar shadowxcl_sh<v>_<l>directly without exchanging across halves, reducing DXIL size and NVIDIA driver (nvgpucomp64.dll) pipeline compile time. Native wave64 HLSL is unchanged.What is in it
crates/xcl/src/gpu/recomp/upper_lanes.rs: addanalyze_spills(tracks constant-lanev_writelane_b32slots0..63across the CFG; invalidates on any VGPR write, dynamic-lanev_writelane_b32,v_movrel/v_swaprel,LOOP_GUARDexits, or indirect jumps) + unit tests.crates/xcl/src/gpu/recomp/mod.rs: runanalyze_spillsfor split-wave64Kernel/Compute/Meshprograms.crates/xcl/src/gpu/recomp/emit.rs: emit directxcl_sh<v>_<l>reads for shadowedv_readlane_b32inx64()mode without declaring VS/PS-onlyxcl_hw32.crates/xcl/src/gpu/recomp/tests.rs: addgpu_split_wave64_writelane_spill_shadowsGPU test covering lower- and upper-half spill reloads alongside a non-spill cross-half read.Measured on three spill-heavy retail wave64 compute shaders (RTX 3060 Ti, DXC 1.9.2609.5, before �! after):
rla_u259 �! 9, DXC 9231 �! 4869 ms, DXIL 394692 �! 293800 B (-25.6%), PSO 9118 �! 6334 ms (-30.5%)rla_u311 �! 17, DXC 14047 �! 7720 ms, DXIL 506376 �! 386384 B (-23.7%), PSO 11848 �! 9305 ms (-21.5%)rla_u506 �! 323, DXC 30955 �! 24472 ms, DXIL 1200072 �! 1113164 B (-7.2%), PSO 30468 �! 27233 ms (-10.6%)Tested
x86_64-pc-windows-msvc), debug + release.cargo test --workspace -- --test-threads=1: 718 passed, 0 failed, 41 ignored (2 SKIPPED GPU tests:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)).--test-threads=4on commit1ec4c98, pre-existinghle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixelsfailed intermittently (cascading 2PoisonErrors in unrelatedd3d12xtests); allrecomptests pass under both--test-threads=4and--test-threads=1.Regression run
main:
PR:
Not tested
split_wave64is false there so emitted HLSL is unchanged).CreateComputePipelineState).AI use
Imported from ivall/xcl. Originally posted by Diskuss on 2026-11-24T08:19:12Z.
Tested on AMD Radeon RX 9070 XT (RDNA4) at
32976332072567e6fe9a7cc621e9cedce509ea2fHardware: RX 9070 XT (RDNA4, driver 32.0.32015.7029), Ryzen 7 5700X3D, 32 GB RAM, Windows 11 Pro build 26300.9974, Rust 1.100.0 x86_64-pc-windows-msvc, DXC 1.9.2602.17, debug build.
Tested
cargo build --workspace: succeeded (1 existing warning in thexcllib).cargo test --workspace --no-fail-fast -- --test-threads=4: 718 passed, 0 failed, 41 ignored (summed over alltest result:lines).gpu_split_wave64_writelane_spill_shadows: okspills_follow_writelane_for_both_halves: okspills_stay_conservative_across_overwrites_branches_and_loops: ok1ec4c98: 715 passed, 0 failed, 41 ignored, 0 SKIPPED): +3 passed, which matches the 3 new tests; failed and ignored are unchanged.Not tested: retail title /
scripts/smoke.ps1(no game files), release build, wave32-only GPUs.Report written by Claude Code (Claude Sonnet 5.5) from a real run on this machine.
Correction (hidden skips): "0 SKIPPED" above means no
SKIPPEDline appeared in the normal run. A later-- --nocapturerun on this machine shows that two tests skip silently, because the D3D12 debug layer is not installed (no Graphics Tools /d3d12SDKLayers.dll). libtest captures their output, so they show asok:e2e::test_title_draws_with_a_root_signature_under_the_debug_layerandtexture_states::uploads_start_from_each_subresources_state. Neither is related to this change, and all other GPU tests ran on the RX 9070 XT.Imported from ivall/xcl. Originally posted by IvyNotFound on 2026-11-24T08:55:51Z.
Tested on NVIDIA RTX 5080 (Blackwell, wave32) at
32976332072567e6fe9a7cc621e9cedce509ea2fTested
XCL_SAMPLE_RPF(retailshaders.rpf),XCL_SAMPLE_DLLS,XCL_SAMPLE_TTPF,XCL_SAMPLE_BVH4cargo build --workspace: succeeded (the existingfetch_updatedeprecation warning only)cargo test --workspace --no-fail-fast -- --test-threads=4: 715 passed, 3 failed, 41 ignored;SKIPPED(no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardwaregpu_split_wave64_writelane_spill_shadows(ran, noSKIPPEDline),upper_lanes::tests::spill_slots_come_from_their_shadow,spills_follow_writelane_for_both_halves,spills_stay_conservative_across_overwrites_branches_and_loops; the existinggpu_wave64_vs_spill_slots_and_identityandgpu_wave64_ps_spill_slotspass toogpu_pso_e2ewith the pack: 7 passed (includingretail_es_gs_voxelize_geometry_modeand the retail mesh / GS pipelines)placed_title_textures_share_vram_and_preserve_pixels(cubemap extra_pages must be reused at same va), thentransitions_apply_when_their_list_is_submittedandd32s8_targets_take_their_own_size_of_video_memoryon thePoisonError. The same three failed the same way onmain09940bbon this machine.cargo test -p xcl --lib -- --test-threads=4 title_textures::tests vram::testsat this head, three runs: 20 passed, 0 failed each time.Not tested
scripts/smoke.ps1/ the retail title, and the compile-time or DXIL-size numbers (not measured here)AI use
Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-24T09:43:38Z.
AMD run with native 64-lane waves, plus NVIDIA. Updated for head
709abd7(first run was on3297633, same result).Tested: pass, head
709abd7applied onmainaaa0936, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.cargo test -p xcl --lib -- gpu:: --test-threads=4:gpu_split_wave64_writelane_spill_shadowsok. The 2 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1and_3, which fail the same way onmainwithout this PR on this card.gpu_split_wave64_writelane_spill_shadowsok.Not tested: retail gameplay.
Note: these runs check that the translated HLSL matches the test's reference model, in 64-lane and in 32-lane waves. They cannot show that the model matches the hardware.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-24T10:37:21Z.
Linux / AMD RDNA3 datapoint.
Merged state: head
3297633onto main6efdabc, clean merge.Full suite,
cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 723 passed, 7 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows. writelane spill-slot shadowing in split-wave64 green.Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.
Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross
x86_64-pc-windows-gnu,XCL_NETWORK=0, release profile,--test-threads=4. My Linux rows: #42 / #718.AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
Imported from ivall/xcl. Originally posted by pvfreis on 2026-11-24T14:36:42Z.
Review: COMMENTED
Review of
3297633(merge base1ec4c98; it merges cleanly into currentmain), by reading the code; nothing was built or run here. I checked thatanalyze_spillsdrops a VGPR's shadowed slots on every writerdna2::vgpr_useslists (VALU, VMEM/DS loads, returning atomics, MIMG data registers), on a dynamic-lanev_writelaneand onv_movrel*/v_swaprel*, gives up on indirect jumps, and that both halves still write the real VGPR lane. No defect found.Questions for the author
v_writelanewrote. Could it also spill to a slot, overwrite that VGPR with a VALU op, and read the slot from the upper half? Then a stale shadow would be caught on the GPU, not only by the analysis unit tests.rla_ucounts taken (command, number of runs, cold or warm cache), so someone else can repeat them?Review by Claude Code (written by Claude Opus 5.5, second read by Claude Fable 5.2); each point checked by a person before posting.
Imported from ivall/xcl. Originally posted by zondy1i on 2026-11-24T14:48:15Z.
Thanks for the code review! Answering both questions:
gpu_split_wave64_writelane_spill_shadowscurrently tests vector invalidation onv11(not previously spilled), while VALU overwrite of a spilled VGPR is covered by the analysis unit tests inupper_lanes.rs. I left3297633untouched for now to avoid invalidating the existing independent hardware PASS runs on this head, but happy to add a spill-then-VALU-overwrite-then-read case directly to the GPU test if desired.xcl_x_rla_uniformcounts come from a one-off local Rust scan over all 10,490 wave64 CS/MS shaders in a retail shader corpus, callingrecomp::translatewith split-wave64 options and countingxcl_x_rla_uniform(occurrences before vs. after this PR.recomp::translate->dxc::compile->ID3D12Device::CreateComputePipelineState(withrecomp::pso::abi_root_signature_with) on a cold DXIL/PSO cache on Windows 11 + RTX 3060 Ti (single cold build per shader for base vs. PR).AI use: Antigravity (Gemini 4 Neon) helped draft this reply from the code and measurement logs.
Imported from ivall/xcl. Originally posted by pvfreis on 2026-11-24T14:57:51Z.
Thanks. I'd add the spill, VALU overwrite, read case to the GPU test: it is the one way a stale shadow gives a wrong value without failing anything, and the analysis unit tests don't run the emitted HLSL. It changes only the test, so the existing runs stay meaningful for the code.
On the numbers: the scan and the benchmark could live in the tree as an
#[ignore]test that reads the shader pack from anXCL_SAMPLE_*variable, as the other game-data tests do (CONTRIBUTING, "Tests on game data"), so others can repeat them on their own GPUs.Reply by Claude Code (Claude Opus 5.5); checked by a person before posting.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T09:31:02Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-25T22:50:19Z.
Independent RTX 3080 Ti check of #917 head
709abd7. Windows 11 build 26300, RTX 3080 Ti / driver 621.35, Ryzen 7 9800X3D, rustc 1.99.1, DXC 1.8.2502.11. The PR checkout was clean.cargo test --offline --locked -p xcl --lib gpu_split_wave64_writelane_spill_shadows -- --test-threads=1 --nocapture, withXCL_D3D12_DEBUG=1: 1 passed, 0 failed, no skip. This is the stock GPU regression containing the spill, vector overwrite, and reload case.cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4on the exact head, without the optional debug setting: 1,105 passed, 0 failed, 46 ignored across 20 test binaries; 23 explicitSKIPPEDnotices (19 no native wave64, 3 unsupported f16 forms, 1 no heap windows). The spill-shadow GPU test ran and passed.I also made a clean, uncommitted merge of that same head into current
maine1d84b7in a disposable checkout. It merged without conflicts. The focused GPU test again passed 1/0 with no skip underXCL_D3D12_DEBUG=1. The full workspace suite on that merged tree passed 1,426/0/46 across 37 binaries, with 25 explicitSKIPPEDnotices (21 no native wave64, 3 unsupported f16 forms, 1 no heap windows). The merged-tree counts are integration evidence, not counts from the PR commit itself.Not tested: retail smoke on this machine, cold DXC/PSO compile-time improvement, or native AMD wave64. AI use: Codex (GPT-6; exact variant unavailable) ran the tests and drafted this report; GPT-6.2 Astra Low reviewed the current diff.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-26T22:49:03Z.
Tested
Independent run at clean PR head
709abd7fe1a546668c8631b2e691e58d71e3e233on Intel Arc A770 (driver 32.0.101.9175), Ryzen 7 3800X, Windows 11 x64 26200.9974, Rust/Cargo 1.100.0 MSVC, DXC/DXIL 1.9.2609.5, debug test profile.Prebuilt with
cargo test --locked -p xcl --lib --no-run --message-format=jsonoutside the GPU mutex. Ran<test-exe> gpu::recomp::tests::gpu_split_wave64_writelane_spill_shadows --exact --nocapture --test-threads=1under the Arc mutex withXCL_ADAPTER=A770.1 passed, 0 failed, 0 ignored and 0 GPU skips (3.71 s). HLSL/DXC split-wave64 readback matched both spill slots (
0x11223344and0x55667788), the post-overwrite cross-half read (152), and the untouched control lane (0xDEAD0006).Not tested
Branch-join behavior, native wave64, the workspace suite and retail smoke.
AI use
T3 Code / Codex (gpt-6.2-sol) ran the original verification and summarized the saved results.
Imported from ivall/xcl. Originally posted by throny on 2026-11-27T21:10:53Z.
merge-check claim
head:
709abd7fe1Imported from ivall/xcl. Originally posted by throny on 2026-11-27T21:27:14Z.
merge-check
base:
6089122ahead:
709abd7fe1merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1468 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1465 passed, 0 failed, 47 ignored
review: none. The spill analysis is a must-analysis (intersection at joins): a slot is dropped on any write to its register, on a dynamic-lane writelane and on movrel / swaprel; loop exits are handled and indirect jumps give up. Lane operands are masked. The case asked for in the thread (spill, overwrite, read) is in the GPU test.
performance: it changes a translator source: every tester re-translates all shaders once. Only split-wave64 programs that use writelane change: fewer cross-half exchanges at run time (reasoned).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-27T22:24:53Z.
merge-check
base:
2c717a043c(main)head:
709abd7fe1merge: clean, uncommitted trial merge
build:
cargo build --workspace --locked-> oktests:
cargo test --workspace --locked --no-fail-fast -- --test-threads=4-> 1,468 passed, 1 failed, 47 ignored; 25 GPUSKIPPEDnotices. All three new spill tests passed, includinggpu_split_wave64_writelane_spill_shadowson the RTX 3080 Ti without a skip. The only failure,console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk, is the same failure on cleanmain2c717a04with the same command and machine (1,465 passed, 1 failed, 47 ignored, 25 skips; paired baseline report).review: No actionable finding in the four-file diff. The forward must-analysis intersects spill slots at joins, clears them on ordinary VGPR writes or dynamic-lane writes, and accounts for loop exits and indirect control flow. Only a proven constant-lane
v_readlane_b32uses the scalar shadow; the overwritten VGPR case still takes the cross-half exchange. The GPU test checks both halves and the overwritten case by readback.performance: Proven spill reloads avoid a cross-half exchange in split wave64. The PR's three-shader timings suggest smaller DXIL and faster compile/PSO creation, but I did not repeat those measurements. The new analysis runs during translation; its CPU cost was not measured. Native wave64 lowering is unchanged.
verdict: safe to merge
hardware / tool and model: Windows 11 build 26300; RTX 3080 Ti 12 GB, NVIDIA 621.35; Ryzen 7 9800X3D; Rust 1.99.1 MSVC; DXC 1.8.2502.11. Codex (GPT-6.2 Sol) ran the merge, build and full GPU suite, reviewed the diff and wrote this report; Codex (GPT-6.2 Astra) independently traced the spill analysis and emitter. I did not run a retail smoke on this head.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:29:49Z.
Triage (#1607) – head
709abd7No open or merged PR makes the same change: main's spill-slot shadows (
4d64749,upper_lanes::analyze) cover wave64 VS / PS only, #3380 is wave32 graphics, and #944 batches exchanges instead of removing them.analyze_spillsgives split-wave64 compute / mesh the shadows. The PR conflicts with main: emit.rs now declaresxcl_hw32andxcl_presentfor anyupperand reads upper-lane shadows throughxcl_present, so theself.x64()branches need to be redone against that code when rebasing.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.