Skip to content

Recompiler: a VOPC SDWA compare's SDST ends the loads it addresses - #2804

Closed
oni-swr wants to merge 1 commit into
xcl-dev:mainfrom
oni-swr:recompiler/reload-sdwa-sdst
Closed

oni-swr wants to merge 1 commit into
xcl-dev:mainfrom
oni-swr:recompiler/reload-sdwa-sdst

Conversation

@oni-swr

@oni-swr oni-swr commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2464 (part 1 only; parts 2 and 3 are claimed by oni-swr in that issue).

reload::changes read SDST only from the base encoding. A VOPC SDWA compare with SD = 1 keeps its SDST in the extension dword, so the s[x:x+1] pair it writes was not marked. A following s_load_dword* whose address was made of that pair was then treated as a repeat and elided, returning the old value.

What is in it

  • crates/xcl/src/gpu/dxil/reload.rs: when the instruction is an SDWA compare with SD = 1, mark the SDST pair as written (125 is the null destination and writes nothing). Test an_sdwa_compare_into_an_sgpr_pair_ends_it: it fails without the fix (the load stays "available") and passes with it.

Tested

  • AMD Windows 11 build 26200, Rust stable x86_64-pc-windows-msvc, debug. No GPU was used for this PR.
  • cargo test -j 4 -p xcl --lib -- gpu::dxil::reload gpu::rdna2 --test-threads=4: 25 passed, 0 failed, 0 ignored.
  • On a GPU (RX 7800 XT, driver not recorded; debug) at head 89f75c4c: cargo test -p xcl --lib -j 4 -- --test-threads=4: 1309 passed, 1 failed, 27 ignored; 6 SKIPPED lines, all sub-cases of f16_programs_on_the_gpu / f32_programs_on_the_gpu (lower_dxil) refused for unsupported F16 ops. The failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (panic at fuzz_tests.rs:1171); it fails the same way on main b49be183 (run alone, 0 passed, 1 failed), so it is not caused by this PR. I did not run the full lib on main.
  • The new test fails on the parent commit (left: [(0, false), (2, true)], right: [(0, false), (2, false)]).

Regression run

  • scripts/smoke.ps1 -Game <title folder> -Seconds 60, release builds, same title, RX 7800 XT, run one after the other on the same machine. main is b49be183, this PR's head is 89f75c4c (clean tree). The PR's run had 1449 frames, 93 % of main's 1563, with no device removal and no crash; its peak commit was 15673 MB against 15808 MB.

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1563 (PresentX 1563)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15808 MB

This PR's head:

xcl-smoke v1
commit: 89f75c4c26a42ac41f6781aa08586e3955a962f7
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1449 (PresentX 1449)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15673 MB

Not tested

  • The rest of cargo test --workspace (integration and e2e tests outside -p xcl --lib).
  • Whether the title's 60 s run reaches an SDWA VOPC compare with SD = 1 followed by a load from its pair: the smoke is a regression check only, and the run was not checked for that.
  • NVIDIA runs; other titles.

AI use

  • AI-assisted: code by Claude Code (Claude Sonnet 5.5).
  • The smoke runs and the GPU lib run above were made later with Claude Code (Claude Sonnet 5.5), which added them to this description.

🤖 Generated with Claude Code

reload::changes read SDST only from the base encoding. For a VOPC SDWA
compare with SD set, SDST lives in the extension dword, so the s[x:x+1]
pair it writes was not marked and a later s_load_dword* whose address
was made of that pair was elided as a repeat, returning stale data.
lower_valu.rs already writes that pair; reload now marks it too
(SDST 125 is the null destination and writes nothing).

Part of xcl-dev#2464 (part 1).

Assisted-by: Claude Code (Claude Sonnet 5.5)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@SzczepanGrela

Copy link
Copy Markdown

RX 9070 / Wine paired GPU readback confirms the changed-address case through the direct plain backend.

Tested

  • Head 89f75c4c26a42ac41f6781aa08586e3955a962f7 against main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7.
  • RX 9070 16 GB (RADV GFX1201), Ryzen 7 7700, CachyOS kernel 7.3.0-5-cachyos, Mesa 26.3.1-arch3.5, GE-Proton11-12 Wine 11.0 Staging, vkd3d-proton 8293130ebe370b1+ (local asserts-disabled build), DXC/DXIL 1.9.2602.17, Rust 1.97.1, release x86_64-pc-windows-gnu.
  • XCL_ADAPTER=AMD Radeon RX 9070, XCL_REQUIRE_GPU=wave64, XCL_NETWORK=0, private caches. GPU fixture requests supported native Wave64 with split disabled, validates each DXIL container, and checks all 64 lanes.

Local fixture and source disclosure

Both source copies receive the same local test gpu::recomp::tests::gpu_sdwa_sdst_scalar_reload_readback; main additionally receives the unchanged upstream CPU regression. Removing these additions reconstructs the original sources. The production delta is only the eight SDWA invalidation lines in reload.rs.

The GPU fixture uses 1 KiB of synthetic memory: A=[0x11110001..0x11110004] at 0x140, B=[0x22220001..0x22220004] at 0x240. It loads four dwords from base+0x40, saves them, executes V_CMP_LT_F32 SDWA with SD=1, then repeats the identical scalar load and copies it to four VGPRs:

  • Low-half case: base s[4:5] starts at 0x100; SDST=4, only lane 9 compares true, changing the base to 0x200.
  • High-half case: base s[6:7] starts at 0x100; SDST=5, only lane 41 compares true, writing s6=0x200 and changing the base to 0x200.
  • Unrelated SDST=6 with base s[4:5], and null SDST=125: base stays 0x100.

Each case runs through HLSL/DXC, direct plain, and direct compact. All first reads are A, and the returned base pairs match the expected addresses on both revisions.

Results

Second read Main Head
Low/high changed base, direct plain A, wrong on all 64 lanes B, correct on all 64 lanes
Low/high changed base, HLSL or direct compact B B
Unrelated or null SDST, all three paths A A

Three fresh processes per revision give the same 12 case/path results each. The local GPU test is 1 passed / 0 failed on head, versus 0 passed / 1 failed on main; main fails its final collected-result assertion only for the low/high direct-plain cases.

The gpu::dxil::reload::tests:: filter gives head 7 passed / 0 failed versus main control 6 passed / 1 failed, in three serial processes plus one four-thread process per revision. Its sole main failure is an_sdwa_compare_into_an_sgpr_pair_ends_it.

Existing gpu_sdwa_f16_inline_constants and gpu_memory_and_exports each pass separately on both revisions with XCL_DIRECT_DXIL=0 and 1. Across all 22 processes: no runtime skips or ignored tests. All 72 GPU case/path records, raw summaries, exact failing assertions, source inventories and executable hashes were independently checked.

Build: cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run. Tests: GE-Proton Wine, <libtest.exe> <exact GPU test name> --exact --nocapture --test-threads=1; CPU filter as above without --exact, threads 1 and 4. The local GPU fixture explicitly selects all three translator paths in each invocation.

Not tested

Wave32 or forced Wave64 split execution, native Windows, other GPUs, other instruction combinations, full workspace suite, retail workload, scripts/smoke.ps1, performance or FPS. These are synthetic readback results only.

AI use

OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the source delta, wrote the local GPU fixture, ran and independently verified the paired tests, and drafted this report. Publication authorized by the account owner.

@retrope13

Copy link
Copy Markdown

Independent Windows/NVIDIA (RTX 4060 Laptop 8 GB) full-workspace verification and diff review of #2804 (89f75c4c) against main (b49be183): full debug workspace suite + release reload/rdna2 tests green, 0 failures. No title was run.

Tested

  • Hardware / Env: NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, Ada Lovelace, driver 32.0.16.2140, wave32), Intel Core i5-14500HX (14C/20T), 24 GB RAM, Windows 11 26H2 (build 26300.9818), rustc 1.100.0 (stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100.0 DXC 1.9.2602.17, XCL_ADAPTER=NVIDIA.
  • Targeted gpu::dxil::reload + gpu::rdna2:
    • Debug (cargo test --locked -p xcl --lib -- gpu::dxil::reload gpu::rdna2 --test-threads=4): 25 passed, 0 failed, 0 ignored (0.12 s).
    • Release (cargo test --release --locked -p xcl --lib -- gpu::dxil::reload gpu::rdna2 --test-threads=4): 25 passed, 0 failed, 0 ignored (0.02 s).
  • Full workspace (debug): cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4:
    • Clean main (b49be183): 1435 passed, 0 failed, 47 ignored
    • PR #2804 (89f75c4c): 1436 passed, 0 failed, 47 ignored (+1 new test, 0 failures)

Diff Review (b49be183..89f75c4c)

  • Confirmed lower::ext_encoding maps (Variant::Sdwa, "VOPC") to VOPC_VOP_SDWA_SDST_ENC (the only SDWA encoding with SD + SDST), while SD == 0 writes VCC (s[106:107]), already marked via OPR_VCC at reload.rs:109.
  • Confirmed r < 125 covers s0..s105, VCC, and M0 (124, allowed as SOFFSET in reload::key) while excluding NULL (125), and pair(r, 2) marks s[r:r+1].
  • Tiny comment nit (reload.rs:346): the comment says a write of s4 or of s[3:4] reaches it, while the assertions right below test avail(4) (s[4:5]) and avail(5) (s[5:6]) rather than avail(3) (s[3:4]) — both overlap s[4:5], just noting the minor comment mismatch.

Not Tested

  • Live retail title runs on NVIDIA, AMD / Intel GPUs, and the 47 #[ignore] / SKIPPED tests.

AI disclosure: Antigravity (Gemini 4 Neon, XHigh) ran the builds/tests, reviewed the diff, and drafted this report.

@Anon64

Anon64 commented Nov 26, 2026

Copy link
Copy Markdown

Regression run of 89f75c4 on a newer retail title: no device removal, no crash, frames and commit within the limits.

Setup: RTX 3060 12 GB (NVIDIA 581.80), i9-14900KF, Windows 11 26200, release builds of main b49be18 (this PR's base) and of this PR's exact head, scripts/smoke.ps1 -Game <title> for 60 s with XCL_NETWORK=0 and A pressed every 4 s from 20 s. Main ran before and after a batch of 11 PRs and peaked at 23,855 and 23,844 MB, so the baseline held steady over the batch.

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1461 (PresentX 1462)
presents per 2 s (last 3): 10 1 1
device removals: 0
crashes: 0
peak commit: 23855 MB

this PR:

xcl-smoke v1
commit: 89f75c4c26a42ac41f6781aa08586e3955a962f7
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1464 (PresentX 1465)
presents per 2 s (last 3): 9 3 1
device removals: 0
crashes: 0
peak commit: 24685 MB

100 % of main's frames, 103 % of its peak commit. One run each.

Not tested: the suite on this head; whether the title reaches the code this PR changes in its first 60 s; AMD.

AI use: Claude Code (Claude Opus 5.5) ran these runs on this machine and wrote this report.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…xcl-dev#2818 (loop budget, wave32 mask kill, SDWA SDST, u32x2 routing)
@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Two contributors checked independently and found that this PR makes the same change as #2479: #1607, group D139. They suggest keeping #2479. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

@raylitebull raylitebull added the duplicate This issue or pull request already exists label Nov 28, 2026
@raylitebull

Copy link
Copy Markdown
Member

Closing as a duplicate of #2479 (confirmed by 2+ contributors in #1607, group D139). Thanks for the contribution — feel free to comment if this covers something #2479 does not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants