Recompiler: 64-bit image atomics (DMASK 0x3) run as 32-bit atomics on the low dword #1485

Open
opened 2026-11-26 04:55:21 +00:00 by github-bot · 5 comments
Owner

@⁠13hourstilliland on GitHub · 2026-11-24 16:50 UTC · original

What happens. An MIMG image atomic with DMASK 0x3 (0xF for image_atomic_cmpswap) works on 64 bits: VDATA[0:1] against the texel's two dwords. That's LLVM's SIISelLowering.cpp:10634-10638 at 7292bcac6ac8: DMask = Is64Bit ? 0xf : 0x3 for cmpswap, Is64Bit ? 0x3 : 0x1 for the others.

The image atomic arms in mimg never read DMASK (crates/xcl/src/gpu/recomp/emit.rs:2485-2517 at b7aa9f3; dmask is read at :2069 and used only by the load/sample and gather paths). Each atomic:

  • declares a RWTexture<uint> / <int> view (:2511)
  • takes one data register, self.vreg(vdata) (:2508)
  • runs a 32-bit Interlocked* or 32-bit CAS loop, and with GLC returns one dword (:2514-2516)

The program counts as translated, so nothing shows up in the unsupported list or the shader statistics.

Measured on main. A GPU test in tests.rs, next to gpu_images_sample_load_store_atomic and in the same style (patch below). 64 lanes run image_atomic_add and image_atomic_umax with DMASK 0x3 on one texel of a 1x1 R32G32_UINT texture (console 32_32_UINT, format 62, desc.rs:111):

  • add: 0xFFFFFFFF per lane, so the sum carries into the high dword
  • umax: (l << 32) | (1000 - l) per lane, so the largest u64 is lane 63's, not the largest low dword

On b7aa9f3:

image_atomic_add 64-bit: 0x00000000ffffffc0, want 0x0000003fffffffc0 (a 32-bit add loses the carry)
image_atomic_umax 64-bit: 0x00000000000003e8, want 0x0000003f000003a9 (a 32-bit max orders by the low dword)
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 743 filtered out

So the add drops the carry, and the max picks the lane with the largest low dword (1000, lane 0) instead of the largest 64-bit value.

The test passes if the program is refused, or if both 64-bit results are right. I checked both outcomes with temporary emit.rs edits, reverted afterwards:

  • a guard that refuses DMASK ≠ 1 (≠ 3 for cmpswap): passes through the refusal branch
  • a rough 64-bit version of the Interlocked* arm (a uint64_t view, VDATA[0:1] packed into one value): passes on the GPU

The rough version is not a fix: no GLC return, no CAS arm, no capability check.

Where it matters (from another project's count, not measured here). VIctory refuses these programs explicitly (crates/victory-shader/src/emit/lower.rs:5674-5681, "a 64-bit image atomic"). Its census of the same retail shader pack, 26,503 records like ours, counts 653 programs that stop there (Marvisak/VIctory#748, Marvisak/VIctory#885). I haven't counted them in XCL. If they are the same programs, XCL translates them with the 32-bit form.

What a fix needs (inferred).

  • Host side: 64-bit typed atomics need a uint64_t / int64_t view of format R32G32_UINT (SM 6.6 int64 atomics). That's already the view XCL makes for 32_32_UINT.
  • Device caps: they need D3D12_OPTIONS9.AtomicInt64OnTypedResourceSupported. Because the views come from ResourceDescriptorHeap, they also need D3D12_OPTIONS11.AtomicInt64OnDescriptorHeapResourceSupported. The RTX 3070 below reports both, and groupshared, as supported.
  • Without those caps: refusing the program (an unsupported entry with a reason) is better than running it on 32 bits.
  • Return value: with GLC, the old value comes back in VDATA[0:1].

The fix is runtime code, so it needs a smoke run on a title. I can't do that one, but I can run the test on a fix branch.

Tested

  • NVIDIA GeForce RTX 3070 (driver 32.0.16.1088, 32-lane waves, so wave64 runs in the split form), Intel Core i5-12600K, Windows 10.0.26200
  • rustc 1.100.0 x86_64-pc-windows-gnu (GNU toolchain, not MSVC), DXC 1.9.2609.5, debug build
  • Tree: b7aa9f3 plus the test patch only (tests.rs)
  • cargo test -p xcl --lib gpu_image_atomics_64_bit -- --nocapture --test-threads=1: 0 passed, 1 failed (output above). With each temporary edit: 1 passed.
  • gpu_images_sample_load_store_atomic on the same tree: 1 passed
  • No display driver resets (System event 4101) during the session

Not tested. AMD / native wave64; the cmpswap and GLC paths; the full suite; any retail run. Which of the programs above affect the picture is unknown.

The test (patch on b7aa9f3, tests.rs only)
diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs
index 5a8d735..77bc555 100644
--- a/crates/xcl/src/gpu/recomp/tests.rs
+++ b/crates/xcl/src/gpu/recomp/tests.rs
@@ -2394,6 +2394,64 @@ fn gpu_images_sample_load_store_atomic() {
     assert_eq!(u32::from_le_bytes(r.textures[2][..4].try_into().unwrap()), 64, "image_atomic_inc (64 lanes, limit 100)");
 }
 
+/// An image atomic with DMASK 0x3 works on 64 bits: VDATA[0:1] against the texel's two
+/// dwords (LLVM's SIISelLowering: `DMask = Is64Bit ? 0x3 : 0x1`, cmpswap `0xf : 0x3`). On a
+/// PC, 64-bit typed atomics need a uint64_t view of format R32G32_UINT, the format of the
+/// console's 32_32_UINT (D3D12's SM 6.6 int64 atomics). A translation either keeps all 64
+/// bits or refuses the program; it never runs the atomic on the low dword only.
+#[test]
+fn gpu_image_atomics_64_bit() {
+    if !gpu_ready() {
+        return;
+    }
+    use runner::{TestTexture, TexDim};
+    use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R32G32_UINT;
+    let mimg = |name: &'static str, f: &[(&str, u64)]| -> Vec<u8> { encode(name, "ENC_MIMG", f, None).unwrap() };
+    let mut code = Vec::new();
+    // tex0, tex1: 1x1 32_32_UINT UAVs, T# in s[16:23] (SRSRC = 4) and s[32:39] (8); every lane hits texel (0, 0)
+    code.extend(mimg("IMAGE_ATOMIC_ADD", &[("VDATA", 10), ("VADDR", 0), ("SRSRC", 4), ("DMASK", 0x3), ("DIM", 1), ("UNORM", 1)]));
+    code.extend(mimg("IMAGE_ATOMIC_UMAX", &[("VDATA", 12), ("VADDR", 0), ("SRSRC", 8), ("DMASK", 0x3), ("DIM", 1), ("UNORM", 1)]));
+    code.extend(encode("S_ENDPGM", "ENC_SOPP", &[], None).unwrap());
+
+    let t = translate(&code, &runner::options(Mode::Kernel)).unwrap();
+    if !t.complete() {
+        // refused, not mistranslated: acceptable
+        assert!(t.unsupported.keys().any(|k| k.contains("image_atomic")), "{:?}", t.unsupported_why);
+        return;
+    }
+    let mut st = KernelState::default();
+    st.sgpr[16..24].copy_from_slice(&tsharp(0, 62, 9));
+    st.sgpr[32..40].copy_from_slice(&tsharp(2, 62, 9));
+    for (l, r) in st.vgpr.iter_mut().enumerate() {
+        r[0] = 0;
+        r[1] = 0;
+        // add 2^32 - 1 per lane: the sum carries into the high dword
+        r[10] = 0xFFFF_FFFF;
+        r[11] = 0;
+        // (l << 32) | (1000 - l): the largest u64 is lane 63's, not the largest low dword
+        r[12] = 1000 - l as u32;
+        r[13] = l as u32;
+    }
+    let lanes = st.vgpr.len() as u64;
+    let tex = vec![
+        TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32_UINT, width: 1, height: 1, depth: 1, texel_bytes: 8, data: vec![0; 8], uav: true },
+        TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32_UINT, width: 1, height: 1, depth: 1, texel_bytes: 8, data: vec![0; 8], uav: true },
+    ];
+    let r = runner::run_code_with(&code, &st, &[], &tex, &[]).unwrap();
+    let texel = |i: usize| u64::from_le_bytes(r.textures[i][..8].try_into().unwrap());
+    let (add, umax) = (texel(0), texel(1));
+    let add_want = lanes * 0xFFFF_FFFF;
+    let umax_want = (lanes - 1) << 32 | (1000 - (lanes - 1));
+    let mut bad = Vec::new();
+    if add != add_want {
+        bad.push(format!("image_atomic_add 64-bit: {add:#018x}, want {add_want:#018x} (a 32-bit add loses the carry)"));
+    }
+    if umax != umax_want {
+        bad.push(format!("image_atomic_umax 64-bit: {umax:#018x}, want {umax_want:#018x} (a 32-bit max orders by the low dword)"));
+    }
+    assert!(bad.is_empty(), "{}", bad.join("\n"));
+}
+
 /// Static samplers: the program builds two S# from constants (point / linear, clamp) – as
 /// the console compiler places a root signature's static samplers – and samples the same
 /// texel boundary with each; they become static samplers of the root signature.

AI use. Hermes Agent with Claude Opus 5.5 compared the code with VIctory's, wrote the test and the temporary checks, ran them on my PC and wrote this issue.

**@⁠13hourstilliland** on GitHub · 2026-11-24 16:50 UTC · [original](https://github.com/xcl-dev/xcl/issues/1485) **What happens.** An MIMG image atomic with DMASK 0x3 (0xF for `image_atomic_cmpswap`) works on 64 bits: VDATA[0:1] against the texel's two dwords. That's LLVM's `SIISelLowering.cpp:10634-10638` at `7292bcac6ac8`: `DMask = Is64Bit ? 0xf : 0x3` for cmpswap, `Is64Bit ? 0x3 : 0x1` for the others. The image atomic arms in `mimg` never read DMASK (`crates/xcl/src/gpu/recomp/emit.rs:2485-2517` at `b7aa9f3`; `dmask` is read at `:2069` and used only by the load/sample and gather paths). Each atomic: - declares a `RWTexture<uint>` / `<int>` view (`:2511`) - takes one data register, `self.vreg(vdata)` (`:2508`) - runs a 32-bit `Interlocked*` or 32-bit CAS loop, and with GLC returns one dword (`:2514-2516`) The program counts as translated, so nothing shows up in the unsupported list or the shader statistics. **Measured on main.** A GPU test in `tests.rs`, next to `gpu_images_sample_load_store_atomic` and in the same style (patch below). 64 lanes run `image_atomic_add` and `image_atomic_umax` with DMASK 0x3 on one texel of a 1x1 `R32G32_UINT` texture (console 32_32_UINT, format 62, `desc.rs:111`): - add: 0xFFFFFFFF per lane, so the sum carries into the high dword - umax: `(l << 32) | (1000 - l)` per lane, so the largest u64 is lane 63's, not the largest low dword On `b7aa9f3`: ``` image_atomic_add 64-bit: 0x00000000ffffffc0, want 0x0000003fffffffc0 (a 32-bit add loses the carry) image_atomic_umax 64-bit: 0x00000000000003e8, want 0x0000003f000003a9 (a 32-bit max orders by the low dword) test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 743 filtered out ``` So the add drops the carry, and the max picks the lane with the largest low dword (1000, lane 0) instead of the largest 64-bit value. The test passes if the program is refused, or if both 64-bit results are right. I checked both outcomes with temporary `emit.rs` edits, reverted afterwards: - a guard that refuses DMASK ≠ 1 (≠ 3 for cmpswap): passes through the refusal branch - a rough 64-bit version of the `Interlocked*` arm (a `uint64_t` view, VDATA[0:1] packed into one value): passes on the GPU The rough version is not a fix: no GLC return, no CAS arm, no capability check. **Where it matters (from another project's count, not measured here).** VIctory refuses these programs explicitly (`crates/victory-shader/src/emit/lower.rs:5674-5681`, "a 64-bit image atomic"). Its census of the same retail shader pack, 26,503 records like ours, counts 653 programs that stop there (Marvisak/VIctory#748, Marvisak/VIctory#885). I haven't counted them in XCL. If they are the same programs, XCL translates them with the 32-bit form. **What a fix needs (inferred).** - **Host side:** 64-bit typed atomics need a `uint64_t` / `int64_t` view of format `R32G32_UINT` ([SM 6.6 int64 atomics](https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_Int64_and_Float_Atomics.html)). That's already the view XCL makes for 32_32_UINT. - **Device caps:** they need `D3D12_OPTIONS9.AtomicInt64OnTypedResourceSupported`. Because the views come from `ResourceDescriptorHeap`, they also need `D3D12_OPTIONS11.AtomicInt64OnDescriptorHeapResourceSupported`. The RTX 3070 below reports both, and groupshared, as supported. - **Without those caps:** refusing the program (an unsupported entry with a reason) is better than running it on 32 bits. - **Return value:** with GLC, the old value comes back in VDATA[0:1]. The fix is runtime code, so it needs a smoke run on a title. I can't do that one, but I can run the test on a fix branch. **Tested** - NVIDIA GeForce RTX 3070 (driver 32.0.16.1088, 32-lane waves, so wave64 runs in the split form), Intel Core i5-12600K, Windows 10.0.26200 - rustc 1.100.0 `x86_64-pc-windows-gnu` (GNU toolchain, not MSVC), DXC 1.9.2609.5, debug build - Tree: `b7aa9f3` plus the test patch only (`tests.rs`) - `cargo test -p xcl --lib gpu_image_atomics_64_bit -- --nocapture --test-threads=1`: 0 passed, 1 failed (output above). With each temporary edit: 1 passed. - `gpu_images_sample_load_store_atomic` on the same tree: 1 passed - No display driver resets (System event 4101) during the session **Not tested.** AMD / native wave64; the cmpswap and GLC paths; the full suite; any retail run. Which of the programs above affect the picture is unknown. <details><summary>The test (patch on b7aa9f3, tests.rs only)</summary> ```diff diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs index 5a8d735..77bc555 100644 --- a/crates/xcl/src/gpu/recomp/tests.rs +++ b/crates/xcl/src/gpu/recomp/tests.rs @@ -2394,6 +2394,64 @@ fn gpu_images_sample_load_store_atomic() { assert_eq!(u32::from_le_bytes(r.textures[2][..4].try_into().unwrap()), 64, "image_atomic_inc (64 lanes, limit 100)"); } +/// An image atomic with DMASK 0x3 works on 64 bits: VDATA[0:1] against the texel's two +/// dwords (LLVM's SIISelLowering: `DMask = Is64Bit ? 0x3 : 0x1`, cmpswap `0xf : 0x3`). On a +/// PC, 64-bit typed atomics need a uint64_t view of format R32G32_UINT, the format of the +/// console's 32_32_UINT (D3D12's SM 6.6 int64 atomics). A translation either keeps all 64 +/// bits or refuses the program; it never runs the atomic on the low dword only. +#[test] +fn gpu_image_atomics_64_bit() { + if !gpu_ready() { + return; + } + use runner::{TestTexture, TexDim}; + use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R32G32_UINT; + let mimg = |name: &'static str, f: &[(&str, u64)]| -> Vec<u8> { encode(name, "ENC_MIMG", f, None).unwrap() }; + let mut code = Vec::new(); + // tex0, tex1: 1x1 32_32_UINT UAVs, T# in s[16:23] (SRSRC = 4) and s[32:39] (8); every lane hits texel (0, 0) + code.extend(mimg("IMAGE_ATOMIC_ADD", &[("VDATA", 10), ("VADDR", 0), ("SRSRC", 4), ("DMASK", 0x3), ("DIM", 1), ("UNORM", 1)])); + code.extend(mimg("IMAGE_ATOMIC_UMAX", &[("VDATA", 12), ("VADDR", 0), ("SRSRC", 8), ("DMASK", 0x3), ("DIM", 1), ("UNORM", 1)])); + code.extend(encode("S_ENDPGM", "ENC_SOPP", &[], None).unwrap()); + + let t = translate(&code, &runner::options(Mode::Kernel)).unwrap(); + if !t.complete() { + // refused, not mistranslated: acceptable + assert!(t.unsupported.keys().any(|k| k.contains("image_atomic")), "{:?}", t.unsupported_why); + return; + } + let mut st = KernelState::default(); + st.sgpr[16..24].copy_from_slice(&tsharp(0, 62, 9)); + st.sgpr[32..40].copy_from_slice(&tsharp(2, 62, 9)); + for (l, r) in st.vgpr.iter_mut().enumerate() { + r[0] = 0; + r[1] = 0; + // add 2^32 - 1 per lane: the sum carries into the high dword + r[10] = 0xFFFF_FFFF; + r[11] = 0; + // (l << 32) | (1000 - l): the largest u64 is lane 63's, not the largest low dword + r[12] = 1000 - l as u32; + r[13] = l as u32; + } + let lanes = st.vgpr.len() as u64; + let tex = vec![ + TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32_UINT, width: 1, height: 1, depth: 1, texel_bytes: 8, data: vec![0; 8], uav: true }, + TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32_UINT, width: 1, height: 1, depth: 1, texel_bytes: 8, data: vec![0; 8], uav: true }, + ]; + let r = runner::run_code_with(&code, &st, &[], &tex, &[]).unwrap(); + let texel = |i: usize| u64::from_le_bytes(r.textures[i][..8].try_into().unwrap()); + let (add, umax) = (texel(0), texel(1)); + let add_want = lanes * 0xFFFF_FFFF; + let umax_want = (lanes - 1) << 32 | (1000 - (lanes - 1)); + let mut bad = Vec::new(); + if add != add_want { + bad.push(format!("image_atomic_add 64-bit: {add:#018x}, want {add_want:#018x} (a 32-bit add loses the carry)")); + } + if umax != umax_want { + bad.push(format!("image_atomic_umax 64-bit: {umax:#018x}, want {umax_want:#018x} (a 32-bit max orders by the low dword)")); + } + assert!(bad.is_empty(), "{}", bad.join("\n")); +} + /// Static samplers: the program builds two S# from constants (point / linear, clamp) – as /// the console compiler places a root signature's static samplers – and samples the same /// texel boundary with each; they become static samplers of the root signature. ``` </details> **AI use.** Hermes Agent with Claude Opus 5.5 compared the code with VIctory's, wrote the test and the temporary checks, ran them on my PC and wrote this issue.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:55:21 +00:00
Author
Owner

@⁠youroot-code on GitHub · 2026-11-24 17:32 UTC · original

Claiming this one, measured on the RTX 4060 here.

Plan:

  1. emit.rs: a new arm ahead of the 32-bit ones for DMASK 0x3 (0xf for cmpswap) — VDATA[0:1] packed into one uint64_t against a RWTexture<D3D12> view of the console 32_32_UINT texel, with InterlockedAdd/Min/Max/And/Or/Xor/Exchange and InterlockedCompareExchange, a uint64_t CAS loop for inc / dec, and the GLC return in VDATA[0:1].
  2. A capability gate: D3D12_OPTIONS9::AtomicInt64OnTypedResourceSupported and D3D12_OPTIONS11::AtomicInt64OnDescriptorHeapResourceSupported, asked once when the device is created and carried in Options::image_atomic64. Without them the program is refused (image_atomic_64) instead of run on the low dword, as you suggest.
  3. Your test as gpu_image_atomics_64_bit, extended so it also asserts the refusal case is the one taken when the adapter reports no int64 typed atomics.

Not in it: 64-bit smin / smax / fmin / fmax (refused for now), and the offline xcl shaders path has no device, so it refuses these programs too.

I have an unpacked retail title here, so the smoke run is possible; I'll post the xcl-smoke block once the PR is up.

AI use: Freebuff (Buffy) — the exact model name is not known to me; the measurement and this comment were produced with it.

**@⁠youroot-code** on GitHub · 2026-11-24 17:32 UTC · [original](https://github.com/xcl-dev/xcl/issues/1485#issuecomment-7139338109) Claiming this one, measured on the RTX 4060 here. Plan: 1. `emit.rs`: a new arm ahead of the 32-bit ones for `DMASK 0x3` (0xf for `cmpswap`) — VDATA[0:1] packed into one `uint64_t` against a `RWTexture<D3D12>` view of the console `32_32_UINT` texel, with `InterlockedAdd/Min/Max/And/Or/Xor/Exchange` and `InterlockedCompareExchange`, a `uint64_t` CAS loop for `inc` / `dec`, and the GLC return in VDATA[0:1]. 2. A capability gate: `D3D12_OPTIONS9::AtomicInt64OnTypedResourceSupported` **and** `D3D12_OPTIONS11::AtomicInt64OnDescriptorHeapResourceSupported`, asked once when the device is created and carried in `Options::image_atomic64`. Without them the program is refused (`image_atomic_64`) instead of run on the low dword, as you suggest. 3. Your test as `gpu_image_atomics_64_bit`, extended so it also asserts the refusal case is the one taken when the adapter reports no int64 typed atomics. Not in it: 64-bit `smin` / `smax` / `fmin` / `fmax` (refused for now), and the offline `xcl shaders` path has no device, so it refuses these programs too. I have an unpacked retail title here, so the smoke run is possible; I'll post the `xcl-smoke` block once the PR is up. AI use: Freebuff (Buffy) — the exact model name is not known to me; the measurement and this comment were produced with it.
Author
Owner

@⁠youroot-code on GitHub · 2026-11-24 17:33 UTC · original

Draft PR for this: #1551 (recomp/image-atomics-64-bit).

The regression run (scripts/smoke.ps1) is still pending; I will paste the xcl-smoke block here and on the PR once it is done.

**@⁠youroot-code** on GitHub · 2026-11-24 17:33 UTC · [original](https://github.com/xcl-dev/xcl/issues/1485#issuecomment-7139368389) Draft PR for this: https://git.gtahub.st/github/xcl-dev--xcl/pulls/1551 (`recomp/image-atomics-64-bit`). The regression run (`scripts/smoke.ps1`) is still pending; I will paste the `xcl-smoke` block here and on the PR once it is done.
Author
Owner

@⁠ddaikodaiko on GitHub · 2026-11-24 18:57 UTC · original · edited 2026-11-24 19:37 UTC

Test report + local fix for #1485 — 64-bit image atomics (DMASK 0x3)

Tested

GPU NVIDIA GeForce RTX 3060 Ti 8 GB (Ampere, 32-lane waves), driver 32.0.16.1088
CPU / RAM AMD Ryzen 5 1600 (6C / 12T), 15.9 GB
OS Windows 10 Pro 22H2, 10.0.19045.7846
D3D12 Agility SDK 1.620.2 (%LOCALAPPDATA%\XCL\D3D12)
DXC 1.8.2502.11 (Windows SDK 10.0.26100.0)
Rust 1.100.0 x86_64-pc-windows-msvc, release
Tree main c160d86 + local commit 615a4f5 (fix branch local/int64-image-atomics, rebased after the repo moved to xcl-dev/xcl)
  • cargo test -p xcl --lib --release gpu_image_atomics_64_bit -- --nocapture: 1 passed, 0 failed. The issue's own test (add + umax on a 1x1 R32G32_UINT UAV, every lane hitting the same texel) now gives 0x0000003fffffffc0 / 0x0000003f000003a9.
  • The device log prints D3D12: 64-bit typed image atomics: supported.
  • Full suite after the rebase: cargo test --workspace --release -- --test-threads=4: 859 passed, 0 failed, 42 ignored, 2 SKIPPED (no wave64). The existing gpu_images_sample_load_store_atomic (32-bit atomics, including the 32-bit cmpswap DMASK 0x3 path) still passes.
  • On main the issue's test fails exactly as reported on the RTX 3070 (add loses the carry, umax orders by the low dword); that measurement is the issue's, not repeated here.

What the local fix does

  • Options::int64_image_atomics, set once in real::init from D3D12_OPTIONS9::AtomicInt64OnTypedResourceSupported and D3D12_OPTIONS11::AtomicInt64OnDescriptorHeapResourceSupported (the views come from ResourceDescriptorHeap). Options::default reads it, so VS / PS / CS / mesh / geometry all get it.
  • emit.rs, MIMG atomics: DMASK 0x3 (non-cmpswap) and 0xF (cmpswap) are no longer silently 32-bit. The non-cmpswap ops (add, sub, smin/umin, smax/umax, and, or, xor, swap, inc, dec) declare a uint64_t / int64_t typed view, pack VDATA[0:1], use Interlocked*, and put the GLC old value back in VDATA[0:1]. Without the device caps the program is refused (image_atomic 64-bit (no int64 typed atomics)), not mistranslated.
  • 64-bit cmpswap / float atomics (fcmpswap / fmin / fmax) and 2DMS are refused with a reason; 32-bit cmpswap (DMASK 0x3) and every other 32-bit atomic keep their existing path. Any other DMASK is refused instead of guessed.

Not tested

  • 64-bit cmpswap (refused for now), the GLC return value, fmin/fmax 64-bit (refused), AMD / native wave64, a retail title / xcl-smoke.
  • The fix is a local branch, not a PR: this repository does not accept PRs written with DeepSeek models. It is not yet ported to the opt-in direct DXIL translator (XCL_DIRECT_DXIL=1); the HLSL path is the default. The patch is prepared locally for a human / frontier-model contributor to submit under the project rules.

AI use: OpenCode with DeepSeek V4.1 Flash wrote the fix and the GPU test, ran them on the machine above and drafted this report; every number is from those runs.

**@⁠ddaikodaiko** on GitHub · 2026-11-24 18:57 UTC · [original](https://github.com/xcl-dev/xcl/issues/1485#issuecomment-7141392017) · edited 2026-11-24 19:37 UTC Test report + local fix for #1485 — 64-bit image atomics (DMASK 0x3) **Tested** | | | |---|---| | GPU | NVIDIA GeForce RTX 3060 Ti 8 GB (Ampere, 32-lane waves), driver `32.0.16.1088` | | CPU / RAM | AMD Ryzen 5 1600 (6C / 12T), 15.9 GB | | OS | Windows 10 Pro 22H2, `10.0.19045.7846` | | D3D12 | Agility SDK `1.620.2` (`%LOCALAPPDATA%\XCL\D3D12`) | | DXC | `1.8.2502.11` (Windows SDK `10.0.26100.0`) | | Rust | `1.100.0` `x86_64-pc-windows-msvc`, release | | Tree | `main` `c160d86` + local commit `615a4f5` (fix branch `local/int64-image-atomics`, rebased after the repo moved to `xcl-dev/xcl`) | - `cargo test -p xcl --lib --release gpu_image_atomics_64_bit -- --nocapture`: **1 passed, 0 failed**. The issue's own test (add + umax on a 1x1 `R32G32_UINT` UAV, every lane hitting the same texel) now gives `0x0000003fffffffc0` / `0x0000003f000003a9`. - The device log prints `D3D12: 64-bit typed image atomics: supported`. - Full suite after the rebase: `cargo test --workspace --release -- --test-threads=4`: **859 passed, 0 failed, 42 ignored**, 2 SKIPPED (`no wave64`). The existing `gpu_images_sample_load_store_atomic` (32-bit atomics, including the 32-bit cmpswap DMASK 0x3 path) still passes. - On `main` the issue's test fails exactly as reported on the RTX 3070 (add loses the carry, umax orders by the low dword); that measurement is the issue's, not repeated here. **What the local fix does** - `Options::int64_image_atomics`, set once in `real::init` from `D3D12_OPTIONS9::AtomicInt64OnTypedResourceSupported` **and** `D3D12_OPTIONS11::AtomicInt64OnDescriptorHeapResourceSupported` (the views come from `ResourceDescriptorHeap`). `Options::default` reads it, so VS / PS / CS / mesh / geometry all get it. - `emit.rs`, MIMG atomics: DMASK 0x3 (non-cmpswap) and 0xF (cmpswap) are no longer silently 32-bit. The non-cmpswap ops (`add`, `sub`, `smin`/`umin`, `smax`/`umax`, `and`, `or`, `xor`, `swap`, `inc`, `dec`) declare a `uint64_t` / `int64_t` typed view, pack VDATA[0:1], use `Interlocked*`, and put the GLC old value back in VDATA[0:1]. Without the device caps the program is refused (`image_atomic 64-bit (no int64 typed atomics)`), not mistranslated. - 64-bit cmpswap / float atomics (`fcmpswap` / `fmin` / `fmax`) and `2DMS` are refused with a reason; 32-bit cmpswap (DMASK 0x3) and every other 32-bit atomic keep their existing path. Any other DMASK is refused instead of guessed. **Not tested** - 64-bit cmpswap (refused for now), the GLC return value, `fmin`/`fmax` 64-bit (refused), AMD / native wave64, a retail title / `xcl-smoke`. - The fix is a local branch, **not a PR**: this repository does not accept PRs written with DeepSeek models. It is **not yet ported to the opt-in direct DXIL translator** (`XCL_DIRECT_DXIL=1`); the HLSL path is the default. The patch is prepared locally for a human / frontier-model contributor to submit under the project rules. AI use: OpenCode with DeepSeek V4.1 Flash wrote the fix and the GPU test, ran them on the machine above and drafted this report; every number is from those runs.
Author
Owner

@⁠ddaikodaiko on GitHub · 2026-11-24 23:48 UTC · original

Direct-DXIL path verified on the Windows GPU box (RTX 3060 Ti 8 GB, driver 32.0.16.1088, DXC 1.8.2502.11), branch contrib/int64-image-atomics rebased on main b9b6ea6:

  • HLSL path: gpu_image_atomics_64_bit passes.
  • XCL_DIRECT_DXIL=1 (the opt-in translator from #1426): passes.
  • Negative control: with only the direct port (3a5f88a) reverted and everything else kept, the same test fails at tests.rs:2507 - so it really goes through the DMASK 0x3 64-bit typed-atomic path and not the old behaviour.

The first version of my verification script used upstream/main as the negative control; that is not valid, because the test only exists on the branch (cargo test <name> ran 0 tests and exited 0). Reverting just the port is the correct control, and it fails as it should.

Note for whoever can open the PR: I cannot submit one myself (the project does not accept PRs produced with DeepSeek models), but the branch and the per-commit patches are ready to be picked up.

**@⁠ddaikodaiko** on GitHub · 2026-11-24 23:48 UTC · [original](https://github.com/xcl-dev/xcl/issues/1485#issuecomment-7147820992) Direct-DXIL path verified on the Windows GPU box (RTX 3060 Ti 8 GB, driver 32.0.16.1088, DXC 1.8.2502.11), branch `contrib/int64-image-atomics` rebased on `main` `b9b6ea6`: - HLSL path: `gpu_image_atomics_64_bit` passes. - `XCL_DIRECT_DXIL=1` (the opt-in translator from #1426): passes. - Negative control: with **only** the direct port (`3a5f88a`) reverted and everything else kept, the same test fails at `tests.rs:2507` - so it really goes through the DMASK 0x3 64-bit typed-atomic path and not the old behaviour. The first version of my verification script used `upstream/main` as the negative control; that is not valid, because the test only exists on the branch (`cargo test <name>` ran 0 tests and exited 0). Reverting just the port is the correct control, and it fails as it should. Note for whoever can open the PR: I cannot submit one myself (the project does not accept PRs produced with DeepSeek models), but the branch and the per-commit patches are ready to be picked up.
Author
Owner

@⁠iGoldenNinja on GitHub · 2026-11-25 00:12 UTC · original · edited 2026-11-25 02:58 UTC

I measured this on an RTX 5080, NVIDIA 617.14, Windows 11 build 26200, using XCL e9e94ce and DXC 1.9.2609.5.

In a selected subset of the 1.0.2.1 shader pack, I found 169 pixel-shader records with this form of 2D unsigned max, representing 168 distinct containers and 259 instruction sites after deduplication. Each site had DMASK 3 and GLC clear. This is a lower bound from the readable subset at the time of collection.

Stock XCL marked all 168 complete. A local change limited to that 2D UMAX form packed both source words and used a 64-bit typed UAV. All 168 then compiled as ps_6_6, and each shader's count of i64 UMAX calls in DXIL matched its native site count. In one example the upper word comes from pixel depth, so two fragments with different depths can exchange order when that word is dropped.

I also replayed that example’s stock and corrected emitted instruction blocks in single-thread D3D12 kernels, using the supported UAV format for each width. With an initial key of 0x3E800000FFFFFFFF and candidate 0x3F40000000000003, the stock 32-bit operation kept 0xFFFFFFFF; the corrected one wrote 0x3F40000000000003. This measured the selected instruction under controlled inputs. Scene rendering and the proposed PR branches were outside this test.

AI-assisted testing with OpenAI Codex (GPT-6).

Update after the verified download completed. My named-record scanner successfully unpacked 26,503 records. Filtering for reachable 2D image UMAX with two words and GLC clear yielded 682 pixel records, 676 distinct pixel containers, and 945 instruction sites across those distinct containers. All 168 previously tested containers are in that set. The 945 is a native instruction count. The earlier per-container DXIL validation covered the original 168.

I also ran an original two-instruction synthetic test on both XCL translation routes, with a narrow control and wide cases with GLC clear and set. On main at 80f48190 both wide cases compiled to i32 on both routes. At #1541 (a4f78345) they compiled to i64 on the HLSL route. At #1948 (1e4f2bda) they compiled to i64 on the direct DXIL route. The narrow control stayed i32 on all six combinations, and all 18 modules passed DXIL validation. This measures the emitted atomic width. Reproducible fixture, exact commits and disassemblies.

Re-ran the public synthetic fixture against main cbc296ab with DXC and the DXIL validator 1.9.2609.5. All six modules validated. The DMASK=1 control is still i32. Both DMASK=3 cases (GLC 0 and 1) still emit i32 in the HLSL and direct DXIL backends where i64 is expected. Observed emitted width and validation; this rerun did not perform GPU readback. Revision-specific result. AI-assisted with OpenAI Codex.

**@⁠iGoldenNinja** on GitHub · 2026-11-25 00:12 UTC · [original](https://github.com/xcl-dev/xcl/issues/1485#issuecomment-7148260253) · edited 2026-11-25 02:58 UTC I measured this on an RTX 5080, NVIDIA 617.14, Windows 11 build 26200, using XCL `e9e94ce` and DXC 1.9.2609.5. In a selected subset of the 1.0.2.1 shader pack, I found 169 pixel-shader records with this form of 2D unsigned max, representing 168 distinct containers and 259 instruction sites after deduplication. Each site had DMASK 3 and GLC clear. This is a lower bound from the readable subset at the time of collection. Stock XCL marked all 168 complete. A local change limited to that 2D UMAX form packed both source words and used a 64-bit typed UAV. All 168 then compiled as ps_6_6, and each shader's count of i64 UMAX calls in DXIL matched its native site count. In one example the upper word comes from pixel depth, so two fragments with different depths can exchange order when that word is dropped. I also replayed that example’s stock and corrected emitted instruction blocks in single-thread D3D12 kernels, using the supported UAV format for each width. With an initial key of `0x3E800000FFFFFFFF` and candidate `0x3F40000000000003`, the stock 32-bit operation kept `0xFFFFFFFF`; the corrected one wrote `0x3F40000000000003`. This measured the selected instruction under controlled inputs. Scene rendering and the proposed PR branches were outside this test. AI-assisted testing with OpenAI Codex (GPT-6). Update after the verified download completed. My named-record scanner successfully unpacked 26,503 records. Filtering for reachable 2D image UMAX with two words and GLC clear yielded 682 pixel records, 676 distinct pixel containers, and 945 instruction sites across those distinct containers. All 168 previously tested containers are in that set. The 945 is a native instruction count. The earlier per-container DXIL validation covered the original 168. I also ran an original two-instruction synthetic test on both XCL translation routes, with a narrow control and wide cases with GLC clear and set. On main at 80f48190 both wide cases compiled to i32 on both routes. At #1541 (a4f78345) they compiled to i64 on the HLSL route. At #1948 (1e4f2bda) they compiled to i64 on the direct DXIL route. The narrow control stayed i32 on all six combinations, and all 18 modules passed DXIL validation. This measures the emitted atomic width. [Reproducible fixture, exact commits and disassemblies](https://github.com/iGoldenNinja/xcl-shader-checks/tree/e713b3b39ff02990ba09bdca9c82198ad533d5b2). Re-ran the public synthetic fixture against main `cbc296ab` with DXC and the DXIL validator 1.9.2609.5. All six modules validated. The `DMASK=1` control is still i32. Both `DMASK=3` cases (GLC 0 and 1) still emit i32 in the HLSL and direct DXIL backends where i64 is expected. Observed emitted width and validation; this rerun did not perform GPU readback. [Revision-specific result](https://github.com/iGoldenNinja/xcl-shader-checks/blob/main/observed/main-cbc296ab.txt). AI-assisted with OpenAI Codex.
This discussion has been locked. Commenting is limited to contributors.
No description provided.