Repository navigation
Conversation
gut0to
left a comment
There was a problem hiding this comment.
AI-assisted review (GPT-6): I verified the exhaustion path in the generated compare-exchange loop.
| 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;") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.)
|
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 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. |
|
Update for head AMD run with 64-lane waves, which this PR lists as not tested (the other report here is NVIDIA). Tested: pass, head
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. |
|
Checked on NVIDIA at head Tested
Not tested: the whole suite, AMD, a retail run. AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment. |
Hardware test report — commit
|
|
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
Regression run The
PR head Not tested Native Windows with AI use OpenAI Codex (GPT-6, exact variant unavailable) ran the tests and prepared this report. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
Adapt xcl-dev#1541 and the signed views and contention fixtures from xcl-dev#1533. Key translation caches on the device capability. Five independent operations failed on the baseline and passed on the RTX 5070. Co-authored-by: enderrr9 <178652333+enderrr9@users.noreply.github.com> Assisted-by: OpenCode (Gemini 4 Neon) Assisted-by: T3 Code (gpt-6.2-astra)
|
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. |
An MIMG image atomic with DMASK 0x3 (0xF for cmpswap) works on the texel's two dwords, VDATA[0:1] (cmpswap: compare value in VDATA[2:3]). The atomic arms never read DMASK and ran a 32-bit atomic on the low dword: an add lost the carry and a max ordered by the low dword. They now run as SM 6.6 64-bit typed atomics on a uint64_t / int64_t view of the R32G32_UINT texel (add, sub, and, or, xor, swap, u/s min, u/s max, cmpswap, fcmpswap bitwise; inc / dec as a compare-exchange loop), with GLC returning the old value in VDATA[0:1]. 64-bit float min / max have no typed form and are refused. Tests: gpu_image_atomics_64_bit (the issue's test, by 13hourstilliland) and gpu_image_atomics_64_bit_cmpswap_smin_inc. Both fail on main and pass with the change on an RTX 3050 Laptop GPU. Fixes xcl-dev#1485 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
23d6656 to
4426781
Compare
|
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 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, 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.) |
|
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
Thanks! — Devin |
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_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 Recompiler: 64-bit image atomics (DMASK 0x3) run as 32-bit atomics on the low dword #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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.