Recompiler: use u128 dependency masks for reload invalidation #2751
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by amazedturnip on 2026-11-26T10:27:01Z.
Precomputes 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
Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-26T10:35:47Z.
Update for head
7cbc651: paired rerun onmainb49be18withXCL_DIRECT_DXIL=1, same cards. On both, the only result changes againstmainaredep_mask_agrees_with_reads_for_all_tracked_address_shapes,mask_intersection_matches_per_register_scanand the newa_write_to_one_slot_base_invalidates_only_that_slot, all ok, with no new skips. RTX 3060: 710 → 713 passed, 0 failed, 24 SKIPPED. RX 9070 XT: 708 → 711 passed, 2 failed (#2115, the same onmain), 6 SKIPPED.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.
Imported from ivall/xcl. Originally posted by frenziedcoder on 2026-11-26T10:44:12Z.
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.
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-26T10:45:59Z.
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
Imported from ivall/xcl. Originally posted by CryingLaughing on 2026-11-26T11:10:46Z.
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.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-26T11:12:00Z.
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.
Imported from ivall/xcl. Originally posted by amazedturnip on 2026-11-26T11:33:11Z.
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.Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-26T12:03:48Z.
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
xcl shaders --precompile --only cs --pipelines: access violation in dxcompiler.dll with parallel DXC compiles, not with XCL_DXC_THREADS=1 #2741Imported from ivall/xcl. Originally posted by amazedturnip on 2026-11-26T12:22:13Z.
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.Imported from ivall/xcl. Originally posted by amazedturnip on 2026-11-26T12:32:07Z.
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.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-26T15:41:06Z.
Independent Windows/NVIDIA test of PR head
7cbc6513(parentb49be18). RTX 3080 Ti (driver 621.35), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC; debug build.cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4: 1,437 passed, 1 failed, 47 ignored across 37 targets. There were 25 GPUSKIPPEDnotices within Cargo's passing count (21 no wave64, 3 refused per-lane forms, 1 no heap windows). All three reload-mask tests passed, including the two-slot invalidation regression.The sole failure was
console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk(cached_only console_mesh hit: "DXIL not compiled yet"). I rancargo test --offline --locked -p xcl --lib console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk -- --test-threads=1on the exact parentb49be18; it failed with the same message (0 passed, 1 failed, 0 ignored), so this run does not attribute that failure to #2761.Not tested: retail title smoke, AMD/Intel hardware, or a measured cold-compile speedup. AI use: Codex (GPT-6.2 Sol) reviewed the two-file patch, ran the tests, checked the parent control, and drafted this report.
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T15:53:23Z.
NVIDIA test report for
7cbc651: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug.cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4(head as-is, onb49be18, default translation mode): 1303 passed, 0 failed, 27 ignored. All 9gpu::dxil::reloadtests are ok,the_translator_emits_a_repeated_load_onceamong them. 25 SKIPPED: 21no wave64, 3 wave32 per-lane forms the translator refuses (#1426), 1pso_measurement_compiles_an_exact_synthetic_recordwithout Developer Mode. None is in this PR's files.dep_mask_agrees_with_reads_for_all_tracked_address_shapes,mask_intersection_matches_per_register_scan,a_write_to_one_slot_base_invalidates_only_that_slot,--exact --test-threads=1 --nocapture, 3 runs each: 9/9 passed, 0 SKIPPED.Lib tests only; no title run.
AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T22:02:21Z.
Independent desktop NVIDIA verification of PR #2761 at head
7cbc6513999534d4479c3ad4801bd6f5991bd678(1commit; exact parent & merge-base:b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, pre-#2555ancestor ofmain).Environment
7956 MiBreported by D3D12, Wave32-only Ada), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted release tests & build (
7cbc6513)cargo test --release -p xcl --lib a_write_to_one_slot_base_invalidates_only_that_slot -- --nocapture1 passed; 0 failed; 0 ignored; 1338 filtered out(0.00s)cargo test --release -p xcl --lib dep_mask_agrees_with_reads_for_all_tracked_address_shapes -- --nocapture1 passed; 0 failed; 0 ignored; 1338 filtered out(0.00s)cargo test --release -p xcl --lib mask_intersection_matches_per_register_scan -- --nocapture1 passed; 0 failed; 0 ignored; 1338 filtered out(0.00s)cargo test --release -p xcl --lib gpu::dxil::reload(3 consecutive runs)9 passed; 0 failed; 0 ignored; 1330 filtered out× 3 (0.01s,0.01s,0.01s)cargo test --release -p xcl --lib gpu::dxil::187 passed; 0 failed; 3 ignored; 1149 filtered out(3.55s;dispatch_chain_native_wave64_builds_wholeself-skipped on Wave32-only RTX 4060)cargo test --release -p xcl --lib gpu::recomp::401 passed; 0 failed; 20 ignored; 918 filtered out(4.88s; Wave64-only and#1426-refused subcases self-skipped as expected)cargo build --release -p xcl --bin xcl1m 08s, exit0)Paired quiet 60 s retail smoke (
title: 29640639)Exact parent & merge-base (
b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, cached baseline on the same machine):PR #2761 (
7cbc6513999534d4479c3ad4801bd6f5991bd678):Runtime log observations (
xcl.log)9221log lines,0[ERROR]/ device-removal / panic lines.19441 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample13982 MB committed by the process; video memory 6115 MB local, 4651 MB non-local.Limits of coverage
u128dependency-mask invalidation path against per-register scanning and address-shape reads was verified via the 3 new reload tests, 3×gpu::dxil::reload,gpu::dxil::(187/0/3),gpu::recomp::(401/0/20), and a paired 60 s warm-cache retail smoke (title: 29640639).reload::analyzespeedup on large shaders was run, and Wave64-only GPU subcases self-skipped on the Wave32-only RTX 4060. Frame-count delta vs. the cached parent smoke (1596vs.1518) reflects normal single-run startup variance and is not attributed to this PR.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by amazedturnip on 2026-11-26T22:08:30Z.
Thanks for the report. Nothing to change here: the Tested section already lists the
cargo test --workspace -- --test-threads=4run on this commit, and the one workspace failure in thehollowedone's report fails on the parentb49be18too.Edited: the first version of this reply said the description would be rewritten from a new gate run. That did not happen, and nothing in the description was out of date.
AI use: written by a local model (Inkling 2 mini), corrected by Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T02:45:46Z.
merge-check claim
head:
7cbc651399Imported from ivall/xcl. Originally posted by throny on 2026-11-28T03:01:11Z.
merge-check
base:
753e8b1ahead:
7cbc651399merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1515 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1512 passed, 0 failed, 47 ignored
review: none in the code. Bit indices stay below 128: the key accepts base registers up to 123 and offsets up to 125, so the highest bit is 125. Main already used a 128-bit register mask with a scan of all bits; the decisions are the same, and a tester in the thread found the output byte-identical over the title's programs. One point for the maintainer, not about the code: the AI-use section names a local model, and CONTRIBUTING has a rule about which models may write PRs; that is not mine to judge.
performance: no measurable change; only direct-DXIL cache entries are re-translated (figures from the thread, not re-measured).
verdict: safe to merge (code)
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 KOLESNiii on 2026-11-28T11:38:29Z.
merge-check claim
head:
7cbc651399Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T12:04:55Z.
merge-check
base:
e429936c10head:
7cbc651399merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2129 passed, 9 failed, 48 ignored, 25 SKIPPED: 21 no wave64, 3 per-lane f16/f32 forms refused (#1426 semantics), 1 no heap windows; failing: gpu::dxil::module::split::tests::dispatch_chain_oversized_loop_matches_whole, gpu::dxil::module::split::tests::dispatch_chain_wave32_live_loops, gpu::dxil::module::split::tests::dispatch_chain_wave64_live_loops_and_exchange, gpu::recomp::heap_window_tests::gpu_heap_flat_reads_match_guarded_and_root_output, gpu::recomp::tests::gpu_compute_mode_dispatch_abi, gpu::recomp::tests::gpu_float_cas_uses_ieee_equality, test_title_draws_with_a_root_signature_under_the_debug_layer, test_title_runs_and_game_folder_is_untouched, test_title_runs_under_the_debug_layer_with_dred: these 9 fail on the base too (the base e429936c's suite, run alone on this PC with the same command: 2126 passed, 9 failed, 48 ignored, 25 SKIPPED, these same 9 failing), and each also failed when rerun alone on this merge (the two debug-layer e2e tests stop on the D3D12 debug layer rejecting a pixel shader as corrupt or unsigned, and test_title_runs_and_game_folder_is_untouched on the test title's console command list memory-methods check, "post-Wait32/64 write failed"); not caused by this PR. The suite ran on this PC at the same time as 3 other PRs' suites, in one queued job.
review: none. Whole diff read (reload.rs: the per-address check against an instruction's written SGPRs becomes one AND with a precomputed mask of the base pair and offset register, instead of a scan of 128 registers; 1 new analysis test, 2 tests that the mask agrees with reads() for every address shape and change mask). key() bounds SBASE to 123 and SOFFSET to 124 or the 125 sentinel, so the shifts stay below 128; the sentinel bit is set exactly as reads() matches it.
performance: reasoned, not measured: shader translation only (the reload analysis); a 128-step loop per address per SGPR-writing instruction becomes one AND.
verdict: safe to merge
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile; trial merge b5602206300edf1421d7f7c79b53cf08b435f4a6 (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).
correction (2026-11-28): the base counts above were first given as 2128 passed: that base run reused this PC's merge test binary (one cargo target dir for both sides). The base was rerun with its own target dir; the same 9 tests fail on it, so the classification and the verdict stand.