Recompiler: compact form splits out repeated memory ops and dead SGPR stores #3261
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3261"
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 Foniass on 2026-11-29T02:13:13Z.
Stacked on #3250; only the top commit (
16f2f5c1) belongs here.Second part of moving amd-dev's direct DXIL size work (
f089a9df) to main: the compact form's micro-blocks and SGPR liveness. This is where the NVIDIA driver's compile time goes down. On large programs (64 blocks or more), a memory instruction that occurs more than once becomes its own micro-block and is lowered once. Blocks that differ only in one literal ors_getpc_b64position share a class. Successors can come from a target pool. A backward SGPR/SCC liveness drops stores of registers no later block reads, and strips dead far-jump veneers.What is in it
crates/xcl/src/gpu/dxil/compact.rs: micro-blocks, no-op stripping and empty-block bypass, literal / block-PC tables,NextEnc::TargetPool, table limit 12288 to 32768 words, liveness (inst_sreg_scc_use_def,compute_live_out, far-jump veneer stripping, per-class store elision)crates/xcl/src/gpu/dxil/lower.rs,kernel.rs:compact_lit/compact_blk_pcfor the parameterized literal ands_getpc_b6433d1222d(open as #2604, which cannot land on main without this code):s_cmov*/s_addk/s_mulk/s_bitset*read their destination, wave32 VALU mask writes define one SGPRS1set are SGPR uses (the port only handledS0), so an SGPR read through SDWAVSRC1no longer has its store dropped. Test:sdwa_sgpr_sources_are_uses(fails without the fix)repeated_loads_split_into_micro_blocks_and_literals_into_a_tableandgpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form(a 200-copy program with a repeateds_load, a per-copy literal and early outs; compact against plain on the GPU)Why one commit, and why over 800 lines
On an RTX 5070 Ti, the micro-blocks without the liveness make the retail title's largest compute program (
95cc13288a27a96e) a pipeline the NVIDIA driver refuses withE_OUTOFMEMORY. With the liveness it builds. So the two halves can't be separate PRs or separate commits without a broken state in between. Of the 890 changed lines, about 200 are tests.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4on16f2f5c1: 2607 passed, 6 failed, 49 ignoredgpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3:E_OUTOFMEMORYfromCreateComputePipelineStateon this card, the same on main. They pass on Kalmarv's RTX 5070 Ti, so they come from this machine's driver / setup, not the code.test_title_runs_and_game_folder_is_untouchedandincomplete_discovered_corpus_blocks_headless_title_entry, because the test title was not built in that worktree; aftercargo build --workspace,cargo test -p xcl --test e2e: 5 passed, 0 failedno wave64; alsotwo_pass_binds_set_the_shared_view_heap(no heap windows) andpso_measurement_compiles_an_exact_synthetic_record(cannot disable the driver cache); the new GPU compact test ranxcl shaders --direct --sample 0 --max-bytes 0) with #3250 and with this PR: 16307 programs, 5 change (only large ones take the micro-block form):95cc13288a27a96e: 784 KB to 251 KB56c0cd3b82a00c6e: 449 KB to 291 KB958400d2caf07244: 405 KB to 253 KB--precompile --only cs --pipelines --records <the 5>): 5 made, 0 refusedRegression run
The PR's run used
-StartupTimeoutSeconds 3600: new DXIL means the title's shader preparation rebuilds its pipelines before the timed minute.main:
this PR:
Not tested
AI use
f089a9df, merged in33d1222d, found and fixed the SDWAS1gap, wrote the new tests, found the A-without-B refusal on NVIDIA, ran the tests, measurements and smoke runs above, wrote this descriptionf089a9df(raylitebull, from46aecbf7, written with Antigravity (Gemini 4 Neon High)) and33d1222d(Alp Pesen, Antigravity (Gemini 4 Neon))🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T03:23:02Z.
merge-check
base:
fa204595a4head:
16f2f5c106merge: clean (stacked on #3250, merges cleanly onto main and with the 7-PR stack).
build: cargo build --workspace -> ok; cargo build --release -p xcl -> ok.
tests: tested in the clean 7-PR stack (#3250+#3261+#3263+#3264+#3265+#3266+#3268) on main
fa204595:cargo test --workspace --no-fail-fast -- --test-threads=4(DXC 1.9.2609.5;-p xcl --librerun skipping the 2 knownmain#3187uma_drivermixed-window testsa_refused_gpu_upload_segment_becomes_customandmixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment) -> 2620 passed, 0 failed, 49 ignored (2481 lib + 139 integration, 25 SKIPPED notices; all 4fuzz_validate_and_gpu_0..3passed); failing: none. 150 sxcl-smoke(ea3b5e4d,XCL_PREPARE=0, RTX 5070 Ti) on the combined 8-PR stack:exit: 0x0,2096frames shown,0device removals,0crashes,0display System events,32049 MBpeak commit.review: none (diff reviewed: micro-block splitting for repeated memory ops on >=64-block programs, literal/PC table sharing, target pool, backward SGPR/SCC liveness with conservative
s_movrel*/s_cmov*/SDWA S0+S1 uses; kernel-mode ABI keeps all registers live).performance: positive: shrinks large compact-form CS DXIL and pipeline compile time; no runtime regression in 150 s smoke (2096 frames, 32049 MB peak commit).
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (wave32 only), Windows 11, DXC 1.9.2609.5 via XCL_DXC_DIR; Antigravity (Gemini 3.5 Pro) ran the merges, builds, workspace test suites, 150 s title smokes, diff reviews, and drafted this check.
Imported from ivall/xcl. Originally posted by moombathepilot on 2026-11-29T18:28:14Z.
merge-check
base:
0fe06eb0f0head:
16f2f5c106merge: clean. The trial merge includes #3250 (
e13ccd7fff), the PR head’s parent. No later stack slices were added.build:
cargo build --workspace-> ok.cargo build --release -p xclalso passed on main, the exact PR head, and the trial merge.tests:
cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture-> 2,740 passed, 3 failed, 49 ignored. 12SKIPPEDnotices: 6 unsupported per-lane f16/f32 cases, 2 no heap windows, 3 missing D3D12 debug layer, and 1 driver cache could not be disabled.gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_formatcompact_tests.rs:180. The compact shader returned(50, 0, 1, 5)instead of(50, 10045, 1, 5). It reproduced in isolated reruns withXCL_SPLIT_WAVE64=0and=1usingcargo test -p xcl --lib gpu::dxil::compact_tests::gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form -- --exact --nocapture --test-threads=1. This fixture is new in the PR and is absent on main.fuzz_validate_and_gpu_1(seed 722) andtwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs(two-pass state release) match earlier targeted runs on this exact unmodified main commit and machine.review: Read the compact-form changes and the stacked bitcode prerequisite. The GPU failure occurs at the compact output assertion, before the comparison against the plain path. The isolated runs report 401 blocks of 4 kinds. The cause of the missing SGPR 1 accumulation is unconfirmed.
git diff --cached --checkpassed.performance: 60-second
scripts/smoke.ps1 -Game <folder> -Seconds 60 -StartupTimeoutSeconds 300runs on title817b32af, withXCL_PREPARE=0, networking off and no input. All three exited 0 with zero crashes and zero device removals.416bb94f973c458462eb1d339811486273786902These are startup smoke results. Gameplay and visual parity were not checked. The cold PSO check with
XCL_DIRECT_DXIL=1and--measure-pso 95cc13288a27a96e --repeat 1exited 2 because D3D12 could not disable the driver cache (0x887A002D), so cold compile time was not measured.verdict: not yet: the new compact-form GPU test returns the wrong scalar accumulator on RX 7800 XT in both native and forced split wave64.
hardware / tool and model: Radeon RX 7800 XT (32.0.32029.2010), Ryzen 7 5700X3D, Windows 11 Home build 26300, Rust 1.100.0 x86_64-pc-windows-msvc, DXC 1.9.2602.17. Codex (GPT-6, exact variant unavailable) verified refs, inspected the diffs, ran the build, tests and smokes, and drafted this report.
Reviewed by the posting user before submission.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T22:39:21Z.
Review: COMMENTED
Static review of
16f2f5c1for the stack in the #3041 comparison.Wave32 liveness can drop a live SGPR store.
inst_sreg_scc_use_deftreats the destination ofS_AND_SAVEEXEC_B64 s[4:5], ???as a two-register definition. Wave32 lowering writes onlys4. If one compact block writess5and its successor readss5after the save, liveness can drop the first block's store and the successor then reads stale data. A wave32 compact/plain comparison with that cross-block dependency would cover the case.Plan::words()also omits the new PC and literal tables, so the 32,768-word limit can admit a larger plan.Review assisted by Codex (GPT-6, exact variant unavailable). No new build or GPU run for this review.
Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T23:17:35Z.
Thanks for the RX 7800 XT run. It caught a real bug that NVIDIA can't show. I reproduced it on an RDNA2 iGPU: the compact form read every parameterized literal as 0. The cause is the two-word read of the literal's pool index, which AMD's driver gets wrong when the result indexes the next table. The same DXIL is right on NVIDIA. This PR was merged before the fix, so the fix is #3473. A rerun of
gpu::dxil::compact_testson that branch on your card would confirm it on RDNA3.(Claude Code, Claude Opus 5.5, for Foniass)
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-30T08:24:15Z.
@Prime1997 @Foniass: a regression on
mainfrom this PR (16f2f5c1), confirmed on two NVIDIA cards.What happens. The title's largest compute program,
95cc13288a27a96e(the one this PR shrinks from 784 KB to 251 KB), never finishes its Dispatch in the new compact form, and the device is removed at the first world frames. BBareth found it first on an RTX 5070 Ti (#505, comment 7271589972). On our RTX 5090 32 GB, onmaind52ff48c(plus #3094 and #3281, which do nothing without their switches, and here ran with them off):The same tree with only
16f2f5c1reverted:main: removed in the world in 2 of 2 runs (with and without other switches). With16f2f5c1reverted: the world in 2 of 2 runs, 268 s and 246 s in it, 0 removals.cs 95cc13288a27a96eis bound.XCL_SKIP_CS=95cc13288a27a96e) also avoids it.0x887a0006with DRED state 7 at a known Dispatch, not a silent0x887a0005.Why it was easy to miss. The program builds fine ("5 made, 0 refused"), and it only runs once the world is drawn, which the 60-second smoke run doesn't reach on this title.
A suggestion for translator changes. A change in
gpu/dxilorgpu/recompchanges the translated programs, so every tester rebuilds their shader cache to pick it up, and again for any fix. And as this PR shows, such a change can pass every current check (the suite, a driver build of each changed program, the 60-second smoke run) and still stopmainfrom loading the world. So for PRs that touch the translator, it's probably worth asking for a full run that confirms the title still enters the world, not only the smoke run. It's an expensive check, but a failure here is far more expensive: this one stops the world from loading for anyone running currentmainon NVIDIA (two cards so far), and the fix costs every tester another full shader-cache rebuild, which takes hours. A number of cards in this thread already get into the world, so the check is within reach, and it would have caught this before everyone paid for it.It may also help if translator changes come from, or are checked by, someone who can load the world themselves.
Meanwhile we run
mainwith16f2f5c1reverted locally, and say so in our reports, until a fix lands. Before this merge, our runs on an oldermainreached the prologue's first interior scene every time (0 device removals in the 16 runs that reached the world), and that's the baseline we're working from on the room's lighting.Related: #505, #2403.
AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 3.8 Flash.
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-30T18:16:53Z.
A correction to the scope of my comment above: this removal looks specific to RTX 50-series cards, not NVIDIA in general.
throny ran
mainwith #3261 on an RTX 4080 (#505, comment 7287561824): the record95cc13288a27a96ewas built in the same compact form that hangs here (228,708 B and 237,860 B of DXIL) and both runs stayed in the world for about 13 and 18 minutes after it without a removal, and none of their 20-odd runs onmainsince lost the device. The two cards where it removes the device are both Blackwell (BBareth's RTX 5070 Ti and our RTX 5090).So the same compact program runs on Ada and never finishes on Blackwell, which may help find the fault (a difference in how the two driver generations compile it). The revert / #3516 results above are unchanged; they just apply to RTX 50-series cards.
AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 3.8 Flash.
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-30T18:16:55Z.
A narrowing from throny (#505, 7287561824): on an RTX 4080 (Ada, 621.40) this compact form of
95cc13288a27a96eis built and runs 13-18 minutes in the world without a removal, over 20-odd runs onmain. The two cards where it hangs, BBareth's RTX 5070 Ti and our RTX 5090, are both Blackwell. So this looks Blackwell-specific (the driver's code for that architecture), not wrong on every card.AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 3.8 Flash.