Recompiler: global/flat dwordx2-x4 accesses take one window switch #1433

Closed
tctev wants to merge 1 commit from upstream-pr/1443 into main
tctev commented 2026-11-24 16:03:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tctev on 2026-11-24T16:03:08Z.


Global loads and stores of 2-4 dwords used to emit one mem.Load or mem.Store per dword. With 4 memory windows each of those runs a switch (xcl_w), so a global_load_dwordx4 meant four switches for one contiguous access. They now use a single Load2/3/4 or Store2/3/4 instead, like s_load already does. Part of #1269.

Addresses are unchanged, and single-dword accesses produce the same HLSL as before. The only difference is an access that runs past the end of a 4 GiB window, which used to wrap to the start of that window and now reads 0 or is dropped (neither matches the console). This doesn't touch mem_accessors, so it doesn't conflict with #1380 or #680.

The test extends gpu_memory_windows_above_4_gib with an unaligned global_load_dwordx4 and a global_store_dwordx3 in window 1 and checks that each is a single accessor call, which fails on main.

Tested
Ran cargo build --workspace && cargo test --workspace -- --test-threads=4 on 1d4549e with this change (debug, Rust 1.100.0, Windows 11 build 26300, i5-12500H, RTX 4050 Laptop GPU with driver 32.0.16.1742). 751 passed, 0 failed, and 41 ignored, with gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware skipped because there is no wave64.

Also compiled a synthetic compute program made only of these accesses (150 rounds of x4 and x2 loads and an x4 store), three runs each with a fresh constant per run so the driver cache couldn't help. With 4 windows, DXIL went from 272 KB to 129 KB, DXC from about 15 s to 7 s, and CreateComputePipelineState from about 10 s to 8 s. With 1 window, DXIL went from 87 KB to 52 KB and the driver from about 0.8 s to 0.5 s. This is an upper bound since real programs mix in other things.

Regression run
TODO: still need smoke blocks for main and this head. I don't have a retail title, so someone who does will need to run them.

Not tested
Haven't tested a retail title, AMD, Linux, native wave64, or this combined with #1380.

AI use
Claude Code (Claude Opus 5.5) wrote the code, test, and benchmark and ran them on the hardware above. I reviewed the diff and the numbers.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:6586024603 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1443). Originally posted by [tctev](https://github.com/tctev) on 2026-11-24T16:03:08Z. --- Global loads and stores of 2-4 dwords used to emit one `mem.Load` or `mem.Store` per dword. With 4 memory windows each of those runs a `switch (xcl_w)`, so a `global_load_dwordx4` meant four switches for one contiguous access. They now use a single `Load2/3/4` or `Store2/3/4` instead, like `s_load` already does. Part of #1269. Addresses are unchanged, and single-dword accesses produce the same HLSL as before. The only difference is an access that runs past the end of a 4 GiB window, which used to wrap to the start of that window and now reads 0 or is dropped (neither matches the console). This doesn't touch `mem_accessors`, so it doesn't conflict with #1380 or #680. The test extends `gpu_memory_windows_above_4_gib` with an unaligned `global_load_dwordx4` and a `global_store_dwordx3` in window 1 and checks that each is a single accessor call, which fails on `main`. **Tested** Ran `cargo build --workspace && cargo test --workspace -- --test-threads=4` on `1d4549e` with this change (debug, Rust 1.100.0, Windows 11 build 26300, i5-12500H, RTX 4050 Laptop GPU with driver 32.0.16.1742). 751 passed, 0 failed, and 41 ignored, with `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware` skipped because there is no wave64. Also compiled a synthetic compute program made only of these accesses (150 rounds of x4 and x2 loads and an x4 store), three runs each with a fresh constant per run so the driver cache couldn't help. With 4 windows, DXIL went from 272 KB to 129 KB, DXC from about 15 s to 7 s, and `CreateComputePipelineState` from about 10 s to 8 s. With 1 window, DXIL went from 87 KB to 52 KB and the driver from about 0.8 s to 0.5 s. This is an upper bound since real programs mix in other things. **Regression run** TODO: still need smoke blocks for `main` and this head. I don't have a retail title, so someone who does will need to run them. **Not tested** Haven't tested a retail title, AMD, Linux, native wave64, or this combined with #1380. **AI use** Claude Code (Claude Opus 5.5) wrote the code, test, and benchmark and ran them on the hardware above. I reviewed the diff and the numbers. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 17:05:53 +00:00
tctev commented 2026-11-24 17:06:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tctev on 2026-11-24T16:08:40Z.


Closing as a duplicate of #1439, which was opened first and already has the same global/flat change along with the s_buffer_load / buffer_load part.

<!-- greyfinch-sync:ivall/xcl:comment:7137188578 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1443#issuecomment-7137188578). Originally posted by [tctev](https://github.com/tctev) on 2026-11-24T16:08:40Z. --- Closing as a duplicate of #1439, which was opened first and already has the same global/flat change along with the s_buffer_load / buffer_load part.
DavidM1911 commented 2026-11-24 19:07:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:52:38Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7141276382 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1443#issuecomment-7141276382). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T18:52:38Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1433
No description provided.