Recompiler: 64-bit image atomics keep all 64 bits (#1485) #1523

Open
enderrr9 wants to merge 1 commit from upstream-pr/1533 into main
enderrr9 commented 2026-11-24 17:19:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by enderrr9 on 2026-11-24T17:19:45Z.


An 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_t view 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 in mimg, 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_bit is the test from #1485, written by its author and used unchanged. gpu_image_atomics_64_bit_cmpswap_smin_inc covers 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

  • NVIDIA GeForce RTX 3050 Laptop GPU (4 GB, driver 621.24, 32-lane waves, so the split wave64 path), AMD Ryzen 5 4600H, Windows 11 build 26300, rustc 1.100.0 (MSVC), DXC 1.8.2502.11, debug build
  • Head 4426781 (rebased onto main 3f27770; only tests.rs conflicted, both sides' new tests kept). cargo test --workspace -- --test-threads=4: 1280 passed, 1 failed, 26 ignored. The failure is lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, which fails the same way on plain main 3f27770 (3 of 3 runs, lower_dxil.rs:1155), so it is not from this PR. 24 SKIPPED, all "no wave64" except three lower_dxil per-lane forms refused for #1426.
  • gpu_image_atomics_64_bit and gpu_image_atomics_64_bit_cmpswap_smin_inc pass on 4426781. Without the emit.rs change (checked on the first head 23d6656), both fail: image_atomic_add 64-bit: 0x00000000ffffffc0, want 0x0000003fffffffc0, image_atomic_umax 64-bit: 0x00000000000003e8, want 0x0000003f000003a9, and image_atomic_cmpswap 64-bit: texel 0x0000000100000000 is no lane's new value.
  • Other people's runs of the first head 23d6656 are 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 23d6656 no longer count. I have no title, so a run of 4426781 is needed from someone who has one.

main:

PR:

Not tested

  • any retail title (no smoke run, see above), so which 64-bit atomic programs a title reaches, and whether its picture changes, is unknown
  • AMD / native wave64, and Intel
  • a host without AtomicInt64OnTypedResourceSupported / AtomicInt64OnDescriptorHeapResourceSupported: the translation doesn't check these caps, and I haven't checked how such a host handles the pipeline
  • the and / or / xor / swap / sub / smax / dec / fcmpswap forms on the GPU (they are emitted but not exercised by the tests)

AI use

  • Claude Code with Claude Opus 5.5: wrote the emit.rs change, the second test and this description, and ran the tests above. The first test is from the issue.
<!-- greyfinch-sync:ivall/xcl:issue:5476976433 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533). Originally posted by [enderrr9](https://github.com/enderrr9) on 2026-11-24T17:19:45Z. --- An 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_t` view 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 in `mimg`, 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_bit` is the test from #1485, written by its author and used unchanged. `gpu_image_atomics_64_bit_cmpswap_smin_inc` covers 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** - NVIDIA GeForce RTX 3050 Laptop GPU (4 GB, driver 621.24, 32-lane waves, so the split wave64 path), AMD Ryzen 5 4600H, Windows 11 build 26300, rustc 1.100.0 (MSVC), DXC 1.8.2502.11, debug build - Head `4426781` (rebased onto `main` `3f27770`; only `tests.rs` conflicted, both sides' new tests kept). `cargo test --workspace -- --test-threads=4`: 1280 passed, 1 failed, 26 ignored. The failure is `lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier`, which fails the same way on plain `main` `3f27770` (3 of 3 runs, `lower_dxil.rs:1155`), so it is not from this PR. 24 SKIPPED, all "no wave64" except three `lower_dxil` per-lane forms refused for #1426. - `gpu_image_atomics_64_bit` and `gpu_image_atomics_64_bit_cmpswap_smin_inc` pass on `4426781`. Without the `emit.rs` change (checked on the first head `23d6656`), both fail: `image_atomic_add 64-bit: 0x00000000ffffffc0, want 0x0000003fffffffc0`, `image_atomic_umax 64-bit: 0x00000000000003e8, want 0x0000003f000003a9`, and `image_atomic_cmpswap 64-bit: texel 0x0000000100000000 is no lane's new value`. - Other people's runs of the first head `23d6656` are 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 `23d6656` no longer count. I have no title, so a run of `4426781` is needed from someone who has one. main: PR: **Not tested** - any retail title (no smoke run, see above), so which 64-bit atomic programs a title reaches, and whether its picture changes, is unknown - AMD / native wave64, and Intel - a host without `AtomicInt64OnTypedResourceSupported` / `AtomicInt64OnDescriptorHeapResourceSupported`: the translation doesn't check these caps, and I haven't checked how such a host handles the pipeline - the and / or / xor / swap / sub / smax / dec / fcmpswap forms on the GPU (they are emitted but not exercised by the tests) **AI use** - Claude Code with Claude Opus 5.5: wrote the `emit.rs` change, the second test and this description, and ran the tests above. The first test is from the issue.
gut0to commented 2026-11-24 17:22:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T17:22:52Z.

Review: COMMENTED


AI-assisted review (GPT-6): I verified the exhaustion path in the generated compare-exchange loop.

<!-- greyfinch-sync:ivall/xcl:review:6044100597 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533#pullrequestreview-6044100597). Originally posted by [gut0to](https://github.com/gut0to) on 2026-11-24T17:22:52Z. **Review:** COMMENTED --- AI-assisted review (GPT-6): I verified the exhaustion path in the generated compare-exchange loop.
dcastell1 commented 2026-11-24 18:09:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by dcastell1 on 2026-11-24T17:24:28Z.


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):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
778 passed; 0 failed; 41 ignored   (exit 0)

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.

<!-- greyfinch-sync:ivall/xcl:comment:7139147909 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533#issuecomment-7139147909). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T17:24:28Z. --- 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): ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace -- --test-threads=4 778 passed; 0 failed; 41 ignored (exit 0) ``` 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.
DarkPanda69 commented 2026-11-24 18:09:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-24T17:28:47Z.


Update for head 4426781: same result. Applied on main 2898511, gpu_image_atomics_64_bit and gpu_image_atomics_64_bit_cmpswap_smin_inc pass on the RX 9070 XT (native wave64) and the RTX 3060. Whole gpu:: filter: RX 9070 XT 694 passed, 2 failed (the AMD fuzz seeds tracked in #2115, same on main); 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 23d6656 applied on its base main 9e3831e, 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:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, native wave64: 194 passed, 0 failed, 18 ignored, 0 SKIPPED. gpu_image_atomics_64_bit and gpu_image_atomics_64_bit_cmpswap_smin_inc ok.
  • NVIDIA RTX 3060, driver 32.0.16.1088: 194 passed, 0 failed, 18 ignored, 2 SKIPPED (no wave64). Both ok.

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.

<!-- greyfinch-sync:ivall/xcl:comment:7139256199 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533#issuecomment-7139256199). Originally posted by [DarkPanda69](https://github.com/DarkPanda69) on 2026-11-24T17:28:47Z. --- **Update for head `4426781`:** same result. Applied on `main` `2898511`, `gpu_image_atomics_64_bit` and `gpu_image_atomics_64_bit_cmpswap_smin_inc` pass on the RX 9070 XT (native wave64) and the RTX 3060. Whole `gpu::` filter: RX 9070 XT 694 passed, 2 failed (the AMD fuzz seeds tracked in #2115, same on `main`); 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 `23d6656` applied on its base `main` `9e3831e`, 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`: - AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, native wave64: 194 passed, 0 failed, 18 ignored, 0 SKIPPED. `gpu_image_atomics_64_bit` and `gpu_image_atomics_64_bit_cmpswap_smin_inc` ok. - NVIDIA RTX 3060, driver 32.0.16.1088: 194 passed, 0 failed, 18 ignored, 2 SKIPPED (no wave64). Both ok. **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.
upipibi commented 2026-11-24 18:09:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T17:34:46Z.


Checked on NVIDIA at head 23d6656: pass.

Tested

  • RTX 3070, driver 616.56 (32-lane waves, so the split form), Windows 11 Pro 26100, Rust 1.100.0 MSVC, DXC 1.8.2502.11, debug.
  • cargo test -p xcl --lib -- image_atomic --test-threads=1: gpu_image_atomics_64_bit and gpu_image_atomics_64_bit_cmpswap_smin_inc pass.
  • An extra test of my own, added locally (not part of this PR), also passes. It has a 64-bit add with GLC (each lane gets a distinct earlier sum), umax, smin over negative values, and cmpswap with GLC (exactly one lane sees the initial texel; the others get the winner's value). It also puts a 32-bit 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_bit there).

Not tested: the whole suite, AMD, a retail run.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment.

<!-- greyfinch-sync:ivall/xcl:comment:7139403027 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533#issuecomment-7139403027). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T17:34:46Z. --- Checked on NVIDIA at head `23d6656`: pass. **Tested** - RTX 3070, driver 616.56 (32-lane waves, so the split form), Windows 11 Pro 26100, Rust 1.100.0 MSVC, DXC 1.8.2502.11, debug. - `cargo test -p xcl --lib -- image_atomic --test-threads=1`: `gpu_image_atomics_64_bit` and `gpu_image_atomics_64_bit_cmpswap_smin_inc` pass. - An extra test of my own, added locally (not part of this PR), also passes. It has a 64-bit add with GLC (each lane gets a distinct earlier sum), umax, smin over negative values, and cmpswap with GLC (exactly one lane sees the initial texel; the others get the winner's value). It also puts a 32-bit `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_bit` there). **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 commented 2026-11-24 18:09:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by eizispark on 2026-11-24T17:55:44Z.


Hardware test report — commit 23d6656

Checked 23d6656744935901eff8cc85ce3593da600ae82c (based on main 9e3831e1f570d3646e53ab753b19ec07eb8f1485): pass.

Tested

  • Hardware: Windows 11 x64, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT (RDNA4, native wave32 + wave64, driver 32.0.32015.16001), 32 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profile
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 778 passed, 0 failed, 41 ignored (1 skipped: 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_bit and gpu::recomp::tests::gpu_image_atomics_64_bit_cmpswap_smin_inc executed natively in wave32 and wave64 on AMD RDNA4 RWTexture2D<uint64_t> over R32G32_UINT)

Regression run
main (9e3831e):

xcl-smoke v1
commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1677 (PresentX 1677)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14728 MB

PR (23d6656):

xcl-smoke v1
commit: 23d6656744935901eff8cc85ce3593da600ae82c
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1677 (PresentX 1677)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14863 MB

Not tested

  • adapters without AtomicInt64OnTypedResourceSupported / AtomicInt64OnDescriptorHeapResourceSupported, NVIDIA/Intel GPUs, Wine/vkd3d-proton, XCL_SAMPLE_*

AI use

  • Antigravity (Google DeepMind, Gemini 4 Carbon) — ran the workspace test suite and 60 s retail smoke run on this commit and formatted the report.
<!-- greyfinch-sync:ivall/xcl:comment:7139906990 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533#issuecomment-7139906990). Originally posted by [eizispark](https://github.com/eizispark) on 2026-11-24T17:55:44Z. --- ### Hardware test report — commit `23d6656` Checked `23d6656744935901eff8cc85ce3593da600ae82c` (based on `main` `9e3831e1f570d3646e53ab753b19ec07eb8f1485`): **pass**. **Tested** - Hardware: Windows 11 x64, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT (RDNA4, native wave32 + wave64, driver 32.0.32015.16001), 32 GB RAM, `rustc 1.100.0 (0ef1bc386 2026-11-09)`, release + test profile - `cargo test --workspace --no-fail-fast -- --test-threads=4`: `778 passed, 0 failed, 41 ignored` (`1` skipped: `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_bit` and `gpu::recomp::tests::gpu_image_atomics_64_bit_cmpswap_smin_inc` executed natively in wave32 and wave64 on AMD RDNA4 `RWTexture2D<uint64_t>` over `R32G32_UINT`) **Regression run** `main` (`9e3831e`): ``` xcl-smoke v1 commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485 gpu: AMD Radeon RX 9070 XT title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1677 (PresentX 1677) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14728 MB ``` PR (`23d6656`): ``` xcl-smoke v1 commit: 23d6656744935901eff8cc85ce3593da600ae82c gpu: AMD Radeon RX 9070 XT title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1677 (PresentX 1677) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14863 MB ``` **Not tested** - adapters without `AtomicInt64OnTypedResourceSupported` / `AtomicInt64OnDescriptorHeapResourceSupported`, NVIDIA/Intel GPUs, Wine/vkd3d-proton, `XCL_SAMPLE_*` **AI use** - Antigravity (Google DeepMind, Gemini 4 Carbon) — ran the workspace test suite and 60 s retail smoke run on this commit and formatted the report.
gut0to commented 2026-11-24 18:09:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T17:22:52Z.

Code review location: crates/xcl/src/gpu/recomp/emit.rs; line 2504

@@ -2482,6 +2482,54 @@ impl Em {
                     uav("float")
                 ));
             }
+            // DMASK 0x3 (cmpswap 0xF): a 64-bit atomic on the texel's two dwords, VDATA[0:1]
+            // (cmpswap: compare value in VDATA[2:3]), as LLVM's SIISelLowering sets it. On the
+            // PC: SM 6.6 64-bit typed atomics on a uint64_t / int64_t view of the R32G32_UINT
+            // texel (#1485). They need OPTIONS9.AtomicInt64OnTypedResourceSupported and
+            // OPTIONS11.AtomicInt64OnDescriptorHeapResourceSupported (not checked here).
+            _ if base.starts_with("atomic_") && dmask == if matches!(&base[7..], "cmpswap" | "fcmpswap") { 0xF } else { 0x3 } => {
+                let op = &base[7..];
+                if matches!(op, "fmin" | "fmax") {
+                    return Err("image_atomic 64-bit float min/max");
+                }
+                let (v0, v1) = (self.vreg(vdata), self.vreg(vdata + 1));
+                let cmp_regs = if matches!(op, "cmpswap" | "fcmpswap") { Some((self.vreg(vdata + 2), self.vreg(vdata + 3))) } else { None };
+                let signed = matches!(op, "smin" | "smax");
+                let vt = if signed { "int64_t" } else { "uint64_t" };
+                self.line(&format!("uint64_t {t}_v = (uint64_t){v0} | ((uint64_t){v1} << 32);"));
+                self.line(&format!("RWTexture{rty}<{vt}> {t}_U = ResourceDescriptorHeap[NonUniformResourceIndex({tw0} + 1u)];"));
+                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;")

If every compare-exchange attempt loses to concurrent updates, this loop exits after 4096 iterations and then assigns _old = _c without recording whether any exchange succeeded. That silently drops the 64-bit inc or dec operation 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.

<!-- greyfinch-sync:ivall/xcl:review-comment:4683872867 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533#discussion_r4683872867). Originally posted by [gut0to](https://github.com/gut0to) on 2026-11-24T17:22:52Z. **Code review location:** `crates/xcl/src/gpu/recomp/emit.rs`; line 2504 ~~~~diff @@ -2482,6 +2482,54 @@ impl Em { uav("float") )); } + // DMASK 0x3 (cmpswap 0xF): a 64-bit atomic on the texel's two dwords, VDATA[0:1] + // (cmpswap: compare value in VDATA[2:3]), as LLVM's SIISelLowering sets it. On the + // PC: SM 6.6 64-bit typed atomics on a uint64_t / int64_t view of the R32G32_UINT + // texel (#1485). They need OPTIONS9.AtomicInt64OnTypedResourceSupported and + // OPTIONS11.AtomicInt64OnDescriptorHeapResourceSupported (not checked here). + _ if base.starts_with("atomic_") && dmask == if matches!(&base[7..], "cmpswap" | "fcmpswap") { 0xF } else { 0x3 } => { + let op = &base[7..]; + if matches!(op, "fmin" | "fmax") { + return Err("image_atomic 64-bit float min/max"); + } + let (v0, v1) = (self.vreg(vdata), self.vreg(vdata + 1)); + let cmp_regs = if matches!(op, "cmpswap" | "fcmpswap") { Some((self.vreg(vdata + 2), self.vreg(vdata + 3))) } else { None }; + let signed = matches!(op, "smin" | "smax"); + let vt = if signed { "int64_t" } else { "uint64_t" }; + self.line(&format!("uint64_t {t}_v = (uint64_t){v0} | ((uint64_t){v1} << 32);")); + self.line(&format!("RWTexture{rty}<{vt}> {t}_U = ResourceDescriptorHeap[NonUniformResourceIndex({tw0} + 1u)];")); + 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;") ~~~~ --- If every compare-exchange attempt loses to concurrent updates, this loop exits after 4096 iterations and then assigns `_old = _c` without recording whether any exchange succeeded. That silently drops the 64-bit `inc` or `dec` operation 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.
vitor127wt commented 2026-11-24 19:07:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vitor127wt on 2026-11-24T18:23:00Z.


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

  • Ryzen 7 9700X, 32 GB DDR5 and NVIDIA GeForce RTX 5070 Ti with driver 620.73.04 on CachyOS (kernel 7.3.5-2-cachyos).
  • Proton Experimental 11.0 (experimental-11.0-20261112-x86_64), vkd3d-proton ec207194 with the XCL patch from #257, DXC 1.9.2609.5 and VKD3D_CONFIG=ignore_shared_fence.
  • Windows MSVC release builds from clean checkouts using cargo xwin build --offline --locked --target x86_64-pc-windows-msvc --release -p xcl --bin xcl. Ran scripts/linux/smoke.sh "$PROTON" "$PREFIX" "$GAME" 60 from #257 with XCL_EXE pointing to the matching build.
  • Built the release test executable with cargo xwin test --offline --locked --target x86_64-pc-windows-msvc --release -p xcl --lib --no-run. Ran wine <xcl-test.exe> gpu_image_atomics_64_bit --test-threads=1 --nocapture with Proton's Wine on the RTX 5070 Ti. 2 passed, 0 failed, 0 ignored, 0 skipped.

Regression run

The title field omits a local folder suffix. All measurements are as emitted by the script.

main

xcl-smoke v1
commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1193 (PresentX 1193)
presents per 2 s (last 3): 60 60 57
device removals: 0
crashes: 0
peak commit: 0 MB

PR head

xcl-smoke v1
commit: 23d6656744935901eff8cc85ce3593da600ae82c
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1192 (PresentX 1192)
presents per 2 s (last 3): 60 58 60
device removals: 0
crashes: 0
peak commit: 0 MB

Not tested

Native Windows with scripts/smoke.ps1 and the full workspace suite. Wine reported peak commit: 0 MB in 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.

<!-- greyfinch-sync:ivall/xcl:comment:7140567390 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533#issuecomment-7140567390). Originally posted by [vitor127wt](https://github.com/vitor127wt) on 2026-11-24T18:23:00Z. --- I ran the retail smoke comparison requested in [#1243](https://github.com/xcl-dev/xcl/issues/1243#issuecomment-7139034451) on Proton. Both runs used the same Xbox title for 60 seconds, with fresh Proton prefixes and XCL caches. **Tested** - Ryzen 7 9700X, 32 GB DDR5 and NVIDIA GeForce RTX 5070 Ti with driver 620.73.04 on CachyOS (kernel `7.3.5-2-cachyos`). - Proton Experimental 11.0 (`experimental-11.0-20261112-x86_64`), vkd3d-proton `ec207194` with the XCL patch from #257, DXC 1.9.2609.5 and `VKD3D_CONFIG=ignore_shared_fence`. - Windows MSVC release builds from clean checkouts using `cargo xwin build --offline --locked --target x86_64-pc-windows-msvc --release -p xcl --bin xcl`. Ran `scripts/linux/smoke.sh "$PROTON" "$PREFIX" "$GAME" 60` from #257 with `XCL_EXE` pointing to the matching build. - Built the release test executable with `cargo xwin test --offline --locked --target x86_64-pc-windows-msvc --release -p xcl --lib --no-run`. Ran `wine <xcl-test.exe> gpu_image_atomics_64_bit --test-threads=1 --nocapture` with Proton's Wine on the RTX 5070 Ti. **2 passed, 0 failed, 0 ignored, 0 skipped.** **Regression run** The `title` field omits a local folder suffix. All measurements are as emitted by the script. `main` ``` xcl-smoke v1 commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485 gpu: NVIDIA GeForce RTX 5070 Ti title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1193 (PresentX 1193) presents per 2 s (last 3): 60 60 57 device removals: 0 crashes: 0 peak commit: 0 MB ``` PR head ``` xcl-smoke v1 commit: 23d6656744935901eff8cc85ce3593da600ae82c gpu: NVIDIA GeForce RTX 5070 Ti title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1192 (PresentX 1192) presents per 2 s (last 3): 60 58 60 device removals: 0 crashes: 0 peak commit: 0 MB ``` **Not tested** Native Windows with `scripts/smoke.ps1` and the full workspace suite. Wine reported `peak commit: 0 MB` in 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 commented 2026-11-24 19:07:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T19:05:53Z.


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

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7141593553 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533#issuecomment-7141593553). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T19:05:53Z. --- 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 commented 2026-11-24 21:09:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-24T19:55:16Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7142780614 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533#issuecomment-7142780614). Originally posted by [throny](https://github.com/throny) on 2026-11-24T19:55:16Z. --- <!-- xcl-1607-hint:D9 --> 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 commented 2026-11-25 19:07:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by enderrr9 on 2026-11-25T18:50:01Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:ivall/xcl:review:6063187095 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533#pullrequestreview-6063187095). Originally posted by [enderrr9](https://github.com/enderrr9) on 2026-11-25T18:50:01Z. **Review:** COMMENTED --- _No description provided._
enderrr9 commented 2026-11-25 19:09:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by enderrr9 on 2026-11-25T18:50:04Z.


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 main 3f27770 to fix the merge conflict (only tests.rs; both sides' new tests are kept), so the head is now 4426781 and the smoke runs of 23d6656 no longer count. If someone with a title can rerun it on the new head, please paste both blocks here:

git fetch origin main pull/1533/head:pr-1533
git checkout origin/main;  cargo build --release -p xcl;  .\scripts\smoke.ps1 -Game '<your game folder>'
git checkout 4426781;      cargo build --release -p xcl;  .\scripts\smoke.ps1 -Game '<your game folder>'

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 plain main 3f27770 too.

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.)

<!-- greyfinch-sync:ivall/xcl:comment:7171463808 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533#issuecomment-7171463808). Originally posted by [enderrr9](https://github.com/enderrr9) on 2026-11-25T18:50:04Z. --- 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 `main` `3f27770` to fix the merge conflict (only `tests.rs`; both sides' new tests are kept), so the head is now **`4426781`** and the smoke runs of `23d6656` no longer count. If someone with a title can rerun it on the new head, please paste both blocks here: ```powershell git fetch origin main pull/1533/head:pr-1533 git checkout origin/main; cargo build --release -p xcl; .\scripts\smoke.ps1 -Game '<your game folder>' git checkout 4426781; cargo build --release -p xcl; .\scripts\smoke.ps1 -Game '<your game folder>' ``` 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 plain `main` `3f27770` too. 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.)
enderrr9 commented 2026-11-25 19:09:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by enderrr9 on 2026-11-25T18:50:01Z.

Code review location: crates/xcl/src/gpu/recomp/emit.rs; line 2504

@@ -2482,6 +2482,54 @@ impl Em {
                     uav("float")
                 ));
             }
+            // DMASK 0x3 (cmpswap 0xF): a 64-bit atomic on the texel's two dwords, VDATA[0:1]
+            // (cmpswap: compare value in VDATA[2:3]), as LLVM's SIISelLowering sets it. On the
+            // PC: SM 6.6 64-bit typed atomics on a uint64_t / int64_t view of the R32G32_UINT
+            // texel (#1485). They need OPTIONS9.AtomicInt64OnTypedResourceSupported and
+            // OPTIONS11.AtomicInt64OnDescriptorHeapResourceSupported (not checked here).
+            _ if base.starts_with("atomic_") && dmask == if matches!(&base[7..], "cmpswap" | "fcmpswap") { 0xF } else { 0x3 } => {
+                let op = &base[7..];
+                if matches!(op, "fmin" | "fmax") {
+                    return Err("image_atomic 64-bit float min/max");
+                }
+                let (v0, v1) = (self.vreg(vdata), self.vreg(vdata + 1));
+                let cmp_regs = if matches!(op, "cmpswap" | "fcmpswap") { Some((self.vreg(vdata + 2), self.vreg(vdata + 3))) } else { None };
+                let signed = matches!(op, "smin" | "smax");
+                let vt = if signed { "int64_t" } else { "uint64_t" };
+                self.line(&format!("uint64_t {t}_v = (uint64_t){v0} | ((uint64_t){v1} << 32);"));
+                self.line(&format!("RWTexture{rty}<{vt}> {t}_U = ResourceDescriptorHeap[NonUniformResourceIndex({tw0} + 1u)];"));
+                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;")

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 / rmw64 all 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.)

<!-- greyfinch-sync:ivall/xcl:review-comment:4699414280 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533#discussion_r4699414280). Originally posted by [enderrr9](https://github.com/enderrr9) on 2026-11-25T18:50:01Z. **Code review location:** `crates/xcl/src/gpu/recomp/emit.rs`; line 2504 ~~~~diff @@ -2482,6 +2482,54 @@ impl Em { uav("float") )); } + // DMASK 0x3 (cmpswap 0xF): a 64-bit atomic on the texel's two dwords, VDATA[0:1] + // (cmpswap: compare value in VDATA[2:3]), as LLVM's SIISelLowering sets it. On the + // PC: SM 6.6 64-bit typed atomics on a uint64_t / int64_t view of the R32G32_UINT + // texel (#1485). They need OPTIONS9.AtomicInt64OnTypedResourceSupported and + // OPTIONS11.AtomicInt64OnDescriptorHeapResourceSupported (not checked here). + _ if base.starts_with("atomic_") && dmask == if matches!(&base[7..], "cmpswap" | "fcmpswap") { 0xF } else { 0x3 } => { + let op = &base[7..]; + if matches!(op, "fmin" | "fmax") { + return Err("image_atomic 64-bit float min/max"); + } + let (v0, v1) = (self.vreg(vdata), self.vreg(vdata + 1)); + let cmp_regs = if matches!(op, "cmpswap" | "fcmpswap") { Some((self.vreg(vdata + 2), self.vreg(vdata + 3))) } else { None }; + let signed = matches!(op, "smin" | "smax"); + let vt = if signed { "int64_t" } else { "uint64_t" }; + self.line(&format!("uint64_t {t}_v = (uint64_t){v0} | ((uint64_t){v1} << 32);")); + self.line(&format!("RWTexture{rty}<{vt}> {t}_U = ResourceDescriptorHeap[NonUniformResourceIndex({tw0} + 1u)];")); + 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;") ~~~~ --- 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` / `rmw64` all 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 commented 2026-11-26 06:06:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:40:30Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7183701699 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533#issuecomment-7183701699). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T05:40:30Z. --- 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
github-actions[bot] commented 2026-12-01 02:32:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:32:52Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7298733759 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533#issuecomment-7298733759). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-12-01T02:32:52Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 06:00:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:00:46Z.


Triage (#1607) – head 4426781

Same issue (#1485) as #1541 and #1551 (#1607 D9), different approaches. Main's HLSL path (emit.rs MIMG atomics) still runs DMASK 0x3 atomics on 32 bits; only the direct DXIL translator has 64-bit image atomics.
Problems in the diff: the new 64-bit branch in emit.rs declares RWTexture... {t}_U = ResourceDescriptorHeap[...] unconditionally and guards the op with if ({act}) only, skipping the {t}_ok T# check that every other MIMG path on this base uses (and({act}, {t}_ok)), so an invalid T# indexes the descriptor heap. There is also no check of OPTIONS9/OPTIONS11 int64 typed-atomic support (the comment says "not checked here"); #1541 gates on it and keys the caches on it.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302378293 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1533#issuecomment-7302378293). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:00:46Z. --- **Triage (#1607)** – head 4426781 Same issue (#1485) as #1541 and #1551 (#1607 D9), different approaches. Main's HLSL path (`emit.rs` MIMG atomics) still runs DMASK 0x3 atomics on 32 bits; only the direct DXIL translator has 64-bit image atomics. Problems in the diff: the new 64-bit branch in `emit.rs` declares `RWTexture... {t}_U = ResourceDescriptorHeap[...]` unconditionally and guards the op with `if ({act})` only, skipping the `{t}_ok` T# check that every other MIMG path on this base uses (`and({act}, {t}_ok)`), so an invalid T# indexes the descriptor heap. There is also no check of OPTIONS9/OPTIONS11 int64 typed-atomic support (the comment says "not checked here"); #1541 gates on it and keys the caches on it. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1533:upstream-pr/1533'
git switch 'upstream-pr/1533'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1533'
git switch 'upstream-pr/1533'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1533'
git switch 'upstream-pr/1533'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1533'
git switch 'main'
git merge --squash 'upstream-pr/1533'
git switch 'main'
git merge --ff-only 'upstream-pr/1533'
git switch 'main'
git merge 'upstream-pr/1533'
git push origin 'main'
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!1523
No description provided.