Recompiler: use u128 dependency masks for reload invalidation #2761
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2761
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2761"
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?
@amazedturnip on GitHub · 2026-11-26 10:27 UTC · original
amazedturnip:xcl/recompiler-reload-sgpr-dependency-masks-101316→main· +89 −2 · 2 files · 1 commits · openPrecomputes one u128 dependency mask per tracked address in gpu/dxil/reload.rs so fixed-point availability and recording time use a single regs & mask != 0 test instead of a 128-wide per-register scan, with identical emitted reload decisions. New sibling test file pins bitmask agreement with the original reads() scan across base/offset/sentinel shapes and adversarial changes() masks; full 60s retail smoke and the AMD Radeon suite remain green.
Fixes #2747
What is in it
crates/xcl/src/gpu/dxil/reload.rs: precompute oneu128dependency mask per tracked address (dep_mask: base pair + offset register, including the SOFFSET=125 sentinel) and replace the 128-widereads(k, r)scan inside the fixed-pointstepclosure and at recording time with a singleregs & m != 0test. Analysis results, transfer order, memory clobbers and instruction effects are unchanged.crates/xcl/src/gpu/dxil/reload_dep_mask_tests.rs(new sibling test file, declared next to the existingmod tests):dep_mask_agrees_with_reads_for_all_tracked_address_shapeschecks per-register-bit agreement across base/offset-sentinel shapes, andmask_intersection_matches_per_register_scanchecks the mask decision against the per-register scan for every tracked key against adversarialchanges()masks (0, u128::MAX, isolated base/offset bits, sentinel bit, pair bits).Tested
AMD Radeon(TM) Graphics (driver 32.0.21043.19003, DXC 1.9.2609, native wave64),XCL_ADAPTER=radeon):cargo test --workspace -- --test-threads=4— 1311 passed, 1 failed, 27 ignored (SKIPPED GPU tests: 1 (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)); pre-existing upstream/main failures excluded: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1)Regression run
main:
PR:
Not tested
AI use
@DarkPanda69 on GitHub · 2026-11-26 10:35 UTC · original
NVIDIA wave32 run (listed as untested) on an RTX 3060, plus an RX 9070 XT: both new tests pass, and nothing else changes in the direct-DXIL GPU suite.
Head
fdbf8bfapplied onmainb49be18, debug, Windows 11 Pro 26200,XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4onmainand with the PR, card chosen withXCL_ADAPTER:mainOn both cards, the only result changes against
mainare the newdep_mask_agrees_with_reads_for_all_tracked_address_shapesandmask_intersection_matches_per_register_scan, both ok, with no new skips. The 2 RX 9070 XT failures are the AMD fuzz seeds tracked in #2115, the same onmain.Not tested: translation timings on Windows, Intel, a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@frenziedcoder on GitHub · 2026-11-26 10:44 UTC · original
Checked "identical emitted reload decisions" on a real shader pack: the direct DXIL of every program in the retail title of #505 is byte-for-byte the same with and without this PR.
xcl shaders <shaders.rpf> --direct --sample 0 --threads 12 --dump DIR, release builds ofmainb49be183and offdbf8bf(this PR on that base), Windows 11, RTX 5080 box (CPU-only translation), DXC 1.8.2502.11:b49be183fdbf8bf.direct.dxiloutputsSo the mask form makes the same reload decisions as the per-register scan on this corpus. End-to-end translation time doesn't move measurably here; the fixed-point step isn't a visible share of whole-program translation on these shaders.
AI use: Claude Code (Claude Opus 5.5) built both trees, ran the dumps on my machine, compared them and wrote this comment. The dumps were deleted afterwards.
@emirduran707 on GitHub · 2026-11-26 10:45 UTC · original
Independent AMD RDNA4 (native wave64) verification of exact PR head
fdbf8bf69a5f518f02b82f6d52ce96df56e57b7aon Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver32.0.31044.16, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC1.9.2602.17).Tested
cargo build --workspace(debug): passed (0errors).cargo test --workspace --no-fail-fast -- --test-threads=4:1435 passed, 2 failed, 47 ignored(8 SKIPPED: 6 per-lane DXIL forms refused by host adapter/driver, 1heap_window_out_of_memory_falls_back_to_the_switch_formno heap windows, 1pso_measurement_compiles_an_exact_synthetic_recordWindows Developer Mode off).gpu::dxil::reload::reload_dep_mask_tests::dep_mask_agrees_with_reads_for_all_tracked_address_shapesgpu::dxil::reload::reload_dep_mask_tests::mask_intersection_matches_per_register_scangpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1andfuzz_validate_and_gpu_3) are pre-existing on unmodifiedmainon this RX 9060 XT / driver32.0.31044.16.cargo build --release -p xcl+ 60 s retail-title smoke test (scripts/smoke.ps1, offline):(Compare against
mainb49be183on this machine:1603 frames, 18576 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
@CryingLaughing on GitHub · 2026-11-26 11:10 UTC · original
A synthetic case where reload analysis takes a large share of translation time shows where the masks help. The fixture uses 8,199 instructions, 4,097 blocks and 128 tracked addresses. I used the same test-only overlay on parent
b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7and exact headfdbf8bf69a5f518f02b82f6d52ce96df56e57b7a, with separate release builds and confirmed different test binary hashes.The large fixture and a second 11-load fixture both produced byte-identical reload-decision traces (36,448 and 137 bytes) and DXIL (99,608 and 3,420 bytes). The focused test was 1 passed, 0 failed, 0 ignored per revision. Both upstream mask tests passed on the head with zero failures or ignores. No capability skips.
Tested on an i5-13600K, Windows 11 25H2 26200.9974, Rust 1.100.0 x64 MSVC, and DXC 1.8.2502.11. The host has an RTX 4080 with driver 621.01. Translation ran on the CPU.
XCL_DIRECT_COMPACT=0 XCL_DIRECT_SPLIT_INSTRUCTIONS=0 cargo test --release -p xcl --lib --locked -j 2 gpu::dxil::reload_comparison_tests::ordinary_reload_analysis_and_dxil_comparison -- --exact --test-threads=1 --nocapture.These times describe the synthetic input with all 128 addresses in play. The retail pack results above show no measurable overall translation speedup on that corpus.
@KOLESNiii on GitHub · 2026-11-26 11:12 UTC · original
I’m happy with the implementation at
fdbf8bffor #2747. The mask is equivalent to the old scan for every key the analyzer accepts, including theSOFFSET=125sentinel. Both analysis passes share the same transfer function, and slot numbering, memory clobbers, and instruction effects are preserved.I ran the analyzer tests in a standalone Linux harness with
rustc --edition=2024 --testand thegpu::reload::filter. Baselineb49be183passed 5 tests andfdbf8bfpassed 7, with zero failures, ignores, or skips. The harness excluded the Windows DXIL emitter test. I did not run the workspace suite or retail smoke.One test improvement would be to cover two load slots with distinct bases and a write that invalidates only one. All seven current analyzer tests passed when I deliberately reversed the mask vector in the harness. The two-slot fixture passed on the PR and failed with the reversed vector.
AI use was OpenAI Codex (GPT-6, exact serving variant unavailable) for review, the standalone harness, and this comment.
github-bot referenced this pull request2026-11-26 11:35:05 +00:00
fdbf8bf69ato0cff1698dc@amazedturnip on GitHub · 2026-11-26 11:33 UTC · original
Thanks for the careful reports. Added the requested two-slot fixture (
a_write_to_one_slot_base_invalidates_only_that_slot): two loads with distinct bases (s[4:5] vs s[20:21]), a write to the first base's low dword, and assertions that the first slot becomes unavailable while the second stays available (negative control: it fails with the mask deliberately reversed). Analyzer tests: 9 passed. Other review comments were passing test reports; no code changes needed for them.@KOLESNiii on GitHub · 2026-11-26 12:03 UTC · original
Re-review of head
0cff1698dc377edc3678550a5cbabb7881528d1f. The only change sincefdbf8bfis the two-slot test I asked for, and it looks good to me.a_write_to_one_slot_base_invalidates_only_that_slotis correct. The second load's base is s[20:21], neither load writes into the other's address registers, and thes_movto s4 kills only the first slot.by_slot.iter().rev().map(dep_mask)), the new test fails and the other 8 still pass. So the gap I described is covered now.key()limits the base register to 123 or less and the offset register to 124 or less, or the 125 sentinel. So no shift goes past bit 125, anddep_masksets exactly the registersreads()checks.One note on the description: Tested still shows the counts from before the push, run with
--test-threads=2. CONTRIBUTING.md asks for a run with--test-threads=4.Tested
cargo test -p xcl --lib gpu::dxil::reload(debug) at0cff1698: 9 passed, 0 failed, 0 ignored, 0 skippeda_write_to_one_slot_base_invalidates_only_that_slot)scripts/smoke.ps1on a retail game, 60 s, release builds ofmain'sb49be183and this PR's head, both with no uncommitted changes, run on an otherwise idle machine:main:
PR:
The PR's run reached 99.7 % of main's frames and 100.9 % of its peak commit, with no device removals and no crashes.
Not tested
AI use
0cff1698dcto7cbc651399@amazedturnip on GitHub · 2026-11-26 12:22 UTC · original
Addressed the description note: Tested now shows
cargo test --workspace -- --test-threads=4(1311 passed, 1 failed, 27 ignored), run on head0cff1698on the AMD Radeon iGPU with the pre-existing gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 failure excluded. The reload-slice tests at --test-threads=4 are 9 passed, 0 failed. No code changes were needed; all other comments were passing reports.@amazedturnip on GitHub · 2026-11-26 12:32 UTC · original
Correction to the reply above: the head did change, to
7cbc6513, but only because the same commit was signed again.git diff 0cff1698 7cbc6513is empty (same tree), so the re-review of0cff1698covers it. The counts under Tested come fromcargo test --workspace -- --test-threads=4on0cff1698; the PR block under Regression run is from7cbc6513. No further pushes are planned for this PR unless a review asks for one.AI use: Claude Code (Claude Opus 5.5) compared the two heads and wrote this note.
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.