Recompiler: 64-bit image atomics keep all 64 bits (#1485) #1533
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!1533
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1533"
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?
@enderrr9 on GitHub · 2026-11-24 17:19 UTC · original
enderrr9:recomp-image-atomics-64→main· +159 −0 · 2 files · 1 commits · openAn image atomic with DMASK 0x3 (0xF for cmpswap) works on 64 bits: VDATA[0:1] against the texel's two dwords. The MIMG atomic arms never read DMASK, so XCL ran these on the low dword only. An add lost its carry, a max ordered by the low dword, and the program still counted as translated. They now run as SM 6.6 64-bit typed atomics on a
uint64_t/int64_tview of the R32G32_UINT texel. Fixes #1485.What is in it
crates/xcl/src/gpu/recomp/emit.rs: a 64-bit arm ahead of the 32-bit atomic arms inmimg, picked by DMASK. It covers add, sub, and, or, xor, swap, umin/umax, smin/smax (int64 view), and cmpswap/fcmpswap (bitwise, compare value in VDATA[2:3]). inc/dec run as a compare-exchange loop. With GLC, the old value comes back in VDATA[0:1]. 64-bit float min/max have no typed HLSL form, so they are refused (image_atomic 64-bit float min/max) instead of mistranslated.crates/xcl/src/gpu/recomp/tests.rs:gpu_image_atomics_64_bitis the test from #1485, written by its author and used unchanged.gpu_image_atomics_64_bit_cmpswap_smin_inccovers cmpswap with GLC (exactly one lane sees the initial texel, and the rest get the swapped one), a signed min decided by the high dwords, and an inc that carries past 2^32 with a limit above 2^32.Tested
4426781(rebased ontomain3f27770; onlytests.rsconflicted, both sides' new tests kept).cargo test --workspace -- --test-threads=4: 1280 passed, 1 failed, 26 ignored. The failure islower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, which fails the same way on plainmain3f27770(3 of 3 runs,lower_dxil.rs:1155), so it is not from this PR. 24 SKIPPED, all "no wave64" except threelower_dxilper-lane forms refused for #1426.gpu_image_atomics_64_bitandgpu_image_atomics_64_bit_cmpswap_smin_incpass on4426781. Without theemit.rschange (checked on the first head23d6656), both fail:image_atomic_add 64-bit: 0x00000000ffffffc0, want 0x0000003fffffffc0,image_atomic_umax 64-bit: 0x00000000000003e8, want 0x0000003f000003a9, andimage_atomic_cmpswap 64-bit: texel 0x0000000100000000 is no lane's new value.23d6656are in the comments: AMD RX 9070 XT (native wave64), RTX 3060, 3070, 5090, and a smoke run on a retail title.Regression run
The rebase changed the head commit, so the smoke runs posted for
23d6656no longer count. I have no title, so a run of4426781is needed from someone who has one.main:
PR:
Not tested
AtomicInt64OnTypedResourceSupported/AtomicInt64OnDescriptorHeapResourceSupported: the translation doesn't check these caps, and I haven't checked how such a host handles the pipelineAI use
emit.rschange, the second test and this description, and ran the tests above. The first test is from the issue.github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@dcastell1 on GitHub · 2026-11-24 17:24 UTC · original
Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on
main@9e3831e(baseline 776 passed, 0 failed, 41 ignored on this box):Two more passing tests than the baseline; keeping all 64 bits in 64-bit image atomics ships its cases and they run green.
Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.
@upipibi on GitHub · 2026-11-24 17:34 UTC · original
Checked on NVIDIA at head
23d6656: pass.Tested
cargo test -p xcl --lib -- image_atomic --test-threads=1:gpu_image_atomics_64_bitandgpu_image_atomics_64_bit_cmpswap_smin_incpass.image_atomic_cmpswap(DMASK 0x3) in the same program, and that one must leave the texel's high dword alone. Test: https://github.com/upipibi/xcl/blob/fix/image-atomic-64/crates/xcl/src/gpu/recomp/tests.rs (gpu_image_atomics_64_bitthere).Not tested: the whole suite, AMD, a retail run.
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment.
@eizispark on GitHub · 2026-11-24 17:55 UTC · original
Hardware test report — commit
23d6656Checked
23d6656744935901eff8cc85ce3593da600ae82c(based onmain9e3831e1f570d3646e53ab753b19ec07eb8f1485): pass.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profilecargo test --workspace --no-fail-fast -- --test-threads=4:778 passed, 0 failed, 41 ignored(1skipped:heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows)cargo test -p xcl --lib image_atomics_64_bit -- --nocapture:2 passed, 0 failed, 0 ignored, 0 skipped(gpu::recomp::tests::gpu_image_atomics_64_bitandgpu::recomp::tests::gpu_image_atomics_64_bit_cmpswap_smin_incexecuted natively in wave32 and wave64 on AMD RDNA4RWTexture2D<uint64_t>overR32G32_UINT)Regression run
main(9e3831e):PR (
23d6656):Not tested
AtomicInt64OnTypedResourceSupported/AtomicInt64OnDescriptorHeapResourceSupported, NVIDIA/Intel GPUs, Wine/vkd3d-proton,XCL_SAMPLE_*AI use
@vitor127wt on GitHub · 2026-11-24 18:23 UTC · original
I ran the retail smoke comparison requested in #1243 on Proton. Both runs used the same Xbox title for 60 seconds, with fresh Proton prefixes and XCL caches.
Tested
7.3.5-2-cachyos).experimental-11.0-20261112-x86_64), vkd3d-protonec207194with the XCL patch from #257, DXC 1.9.2609.5 andVKD3D_CONFIG=ignore_shared_fence.cargo xwin build --offline --locked --target x86_64-pc-windows-msvc --release -p xcl --bin xcl. Ranscripts/linux/smoke.sh "$PROTON" "$PREFIX" "$GAME" 60from #257 withXCL_EXEpointing to the matching build.cargo xwin test --offline --locked --target x86_64-pc-windows-msvc --release -p xcl --lib --no-run. Ranwine <xcl-test.exe> gpu_image_atomics_64_bit --test-threads=1 --nocapturewith Proton's Wine on the RTX 5070 Ti. 2 passed, 0 failed, 0 ignored, 0 skipped.Regression run
The
titlefield omits a local folder suffix. All measurements are as emitted by the script.mainPR head
Not tested
Native Windows with
scripts/smoke.ps1and the full workspace suite. Wine reportedpeak commit: 0 MBin both runs, so these blocks provide no usable peak memory comparison.AI use
OpenAI Codex (GPT-6, exact variant unavailable) ran the tests and prepared this report.
@DavidM1911 on GitHub · 2026-11-24 19:05 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.Thanks!
@throny on GitHub · 2026-11-24 19:55 UTC · original
Two contributors checked independently and found that #1541 #1551 solves the same problem (for #1485) in a different way: #1607, group D9. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
@enderrr9 on GitHub · 2026-11-25 18:50 UTC · original
Thanks, everyone, for the test runs (AMD RX 9070 XT native wave64, RTX 3060 / 3070 / 5070 Ti / 5090, and the two smoke runs).
I rebased onto
main3f27770to fix the merge conflict (onlytests.rs; both sides' new tests are kept), so the head is now4426781and the smoke runs of23d6656no longer count. If someone with a title can rerun it on the new head, please paste both blocks here:The full suite on the new head is in the description. Its one failure,
a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, fails on plainmain3f27770too.On the overlap hint: #1541 and #1551 were opened after this PR and fix the same issue, #1485. I'm happy for the maintainer to pick whichever fits best.
(Posted with Claude Code, Claude Opus 5.5.)
@DarkPanda69 on GitHub · 2026-11-24 17:28 UTC · original · edited 2026-11-25 19:04 UTC
Update for head
4426781: same result. Applied onmain2898511,gpu_image_atomics_64_bitandgpu_image_atomics_64_bit_cmpswap_smin_incpass on the RX 9070 XT (native wave64) and the RTX 3060. Wholegpu::filter: RX 9070 XT 694 passed, 2 failed (the AMD fuzz seeds tracked in #2115, same onmain); RTX 3060 696 passed, 0 failed.AMD run with 64-lane waves, which this PR lists as not tested (the other report here is NVIDIA).
Tested: pass, head
23d6656applied on its basemain9e3831e, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.cargo test -p xcl --lib -- gpu::recomp --test-threads=4:gpu_image_atomics_64_bitandgpu_image_atomics_64_bit_cmpswap_smin_incok.Not tested: Intel; a host without 64-bit image atomics; the whole workspace suite; a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@ -2984,0 +3000,4 @@self.line(&format!("{vt} {t}_old = 0;"));let texel = format!("{t}_U[{icoord}]");let cas = |new: &str| {format!("uint64_t {t}_c = 0; [allow_uav_condition] for (uint {t}_i = 0u; {t}_i < 4096u; {t}_i++) {{ uint64_t {t}_n = {new}; uint64_t {t}_p = 0; InterlockedCompareExchange({texel}, {t}_c, {t}_n, {t}_p); if ({t}_p == {t}_c) break; {t}_c = {t}_p; }} {t}_old = {t}_c;")@gut0to on GitHub · 2026-11-24 17:22 UTC · original
If every compare-exchange attempt loses to concurrent updates, this loop exits after 4096 iterations and then assigns
_old = _cwithout recording whether any exchange succeeded. That silently drops the 64-bitincordecoperation under contention. Please retry until the compare-exchange succeeds, or handle exhaustion as a failure. AI-assisted review: I checked the generated loop and its post-loop success handling.@ -2984,0 +3000,4 @@self.line(&format!("{vt} {t}_old = 0;"));let texel = format!("{t}_U[{icoord}]");let cas = |new: &str| {format!("uint64_t {t}_c = 0; [allow_uav_condition] for (uint {t}_i = 0u; {t}_i < 4096u; {t}_i++) {{ uint64_t {t}_n = {new}; uint64_t {t}_p = 0; InterlockedCompareExchange({texel}, {t}_c, {t}_n, {t}_p); if ({t}_p == {t}_c) break; {t}_c = {t}_p; }} {t}_old = {t}_c;")@enderrr9 on GitHub · 2026-11-25 18:50 UTC · original
Thanks for checking the loop. The bound is deliberate and matches every compare-exchange loop the recompiler already emits: the 32- and 64-bit buffer, flat and LDS loops in
rmw32/rmw64all stop after 4096 attempts (HANDOFF: "a bounded CAS loop (4096)"). An unbounded loop that a lane never leaves would hang the GPU and remove the device, which is worse than a dropped inc / dec. With at most 64 lanes of a wave on one texel, each round lets at least one lane win, so 4096 is only reached under contention far beyond that. Changing this policy for all of the loops (retry until success, or report exhaustion) would be its own PR, so I'd keep this one consistent with the others.(Reply written with Claude Code, Claude Opus 5.5, after checking the existing loops.)
@DavidM1911 on GitHub · 2026-11-26 05:40 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
@gut0to on GitHub · 2026-11-24 17:22 UTC · original · reviewed
AI-assisted review (GPT-6): I verified the exhaustion path in the generated compare-exchange loop.
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.