Recompiler: half context and second VGPR bank for folded wave64 (no behaviour change) #3529
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3529"
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 throny on 2026-11-30T14:59:35Z.
Preparation for folded wave64 (one hardware lane carries console lanes t and t + 32, instead of
two wave32 halves that meet through exchanges).
Lwlearns which console half (0 or 1) theinstruction being lowered addresses; half 0 is the only one anything selects, so every program
lowers as before. Part of #3011 (C57, step 1/2 of the design note).
What is in it
crates/xcl/src/gpu/dxil/lower.rs:Lw::bank(the console half being lowered) andLw::fold(the lane identity of both halves,
LaneIds;Noneeverywhere today).Lw::set_half(h)selectsthe half: the VGPR bank and, with a folded context,
lane/lane31/upper/half.Lw::vvar(n)is the SSA variable of VGPRnin the selected bank (VAR_VGPRor the newVAR_VGPR_HI= 512, in the free range belowVAR_TMP);vregreads through it. A second-bankvariable starts at 0 (it is not in
io).lower.rs,lower_valu.rs,lower_mem.rs,lower_image.rs,lower_wide.rs: the 17 VGPR writesthat spelled
VAR_VGPR + ngo throughvvar(n).lanes.rs: thelanebitcache key includes the bank (the two halves test different bits of thesame mask in one block); so does the
own_bitskey (new onmainsince the design note).kernel.rs:Lw::newstarts with no folded context and bank 0.lower.rs(half_tests):half_0_lowers_as_no_half_context_does(three programs,wave32 and wave64: the container is byte-identical with
set_half(0)before every instruction,with and without a folded context) and
half_1_addresses_the_second_bank_and_its_own_lane.No behaviour change, and how that was checked: besides the test above, a throw-away test (not in
the PR) hashed the containers of 6 programs (VALU, masks, lane reads, memory, LDS, image store)
x wave32 / wave64 / split wave64 x kernel, compute
[32,1,1][64,1,1][8,8,4]and mesh (128threads) entries: 90 containers, all translated, 90 distinct hashes, identical on
main0fe06eb0and on this change before its rebase. The rebase onto
9dfbe3eaalso keysown_bits(new onmainsince) by the bank; that hash comparison was not repeated after the rebase, only
half_tests.Left as it is, for the PRs that use the second bank:
store_registers(kernel epilogue) andtop_vgpr(relative moves) know bank 0 only; the folded form refuses relative moves by design.The compact form and the dispatch chain were not checked for the second bank.
Tested
cargo test -p xcl --lib -j 12 -- half_tests gpu::dxil --test-threads=4: 308 passed, 1 failed (theresinfo_d16test below), 3 ignoredcargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 2887 passed, 1 failed, 51 ignoredgpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16("2D D16 resinfo clobbered v2/v3"), fails the same way onorigin/main9dfbe3ea(cargo test -p xcl --lib -- gpu_direct_image_get_resinfo_d16: 0 passed, 1 failed), so it is not from this PR. Not looked into further.SKIPPEDon this adapter (32-lane waves only): the wave64 variants ofgpu::recomp::lower/lower_dxiltests (no wave64),gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole, two heap-window tests (no heap windows),shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(driver cache cannot be disabled: Developer Mode)Regression run
9dfbe3ea(scripts/smoke.ps1 -Game <title>, 60 s):scripts/smoke.ps1setsXCL_NETWORK,XCL_RUN_SECONDSandXCL_ACTIVITYbefore it startsxcl.exe, so the child process gets them (the run ended after 60 s with exit 0). The runs used-Xclwith a release build of each commit in its own target directory.Not tested
lane identity it addresses.
AI use
main9dfbe3ea, ran the suite and prepared this PR.🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-30T17:03:47Z.
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 Foniass on 2026-12-01T03:12:30Z.
merge-check
base:
d0832e614fhead:
cc606cc125merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff. The "no behaviour change" claim holds:
bankis only ever 0 andfoldonly None on main's paths, everyVAR_VGPR + nwrite is converted tovvar(n)(which isVAR_VGPR + nfor bank 0), theexec_cache/own_bitsmaps only gain an always-0 key and are never iterated, and nothing uses SSA variables 512-767 (temporaries start at 1024). Findings: (1)half_0_lowers_as_no_half_context_doescompares the PR's lowering with itself (set_half(0)without a fold, orfold = [ids, ids]), so it would not catch a wrongVAR_VGPR->vvarconversion; only the!second_bankassertion guards anything. (2) For step 2, code that still only knows bank 0 beyondstore_registers/top_vgpr: recomp/lower_dxil.rs ~280 / ~298, kernel.rs ~419 / ~583, compact.rs ~958, the sharedLw.scratch, andInit::firstzeroing bank-1 VGPRs even withComputeInitlaunch values. (3)set_half(1)without a folded context is only caught by adebug_assert!. No GPU path a title takes is changed, so no smoke run.performance: none expected (no change to emitted code on main's paths); not measured
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T05:24:49Z.
merge-check claim
head:
cc606cc125Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T05:25:18Z.
merge-check claim
head:
cc606cc125Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T05:40:54Z.
merge-check
base:
d0832e614fhead:
cc606cc125merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2891 passed, 1 failed, 51 ignored; 29 SKIPPED lines
failing: test_title_runs_and_game_folder_is_untouched
review: automated overnight check — diff inspected for safety only (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no duplicate search performed; no line-by-line code review.
performance: not assessed beyond the suite.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T06:47:02Z.
Closing our own PR to keep the queue small: measured in the world (see #3543), the folded wave64 form brings no gain on an RTX 4080 (folded programs ran at a median 1.27× their split time, within run-to-run noise), so this code would sit unused in the tree. The branch stays on throny/xcl; reopen if a later measurement (e.g. on another GPU) shows a gain.
AI use: Claude Code (Claude Opus 5.5).
Pull request closed