Recompiler: scratch SADDR 0x7F addresses the offset alone (ST form) #2514
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2514
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2514"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@oni-swr on GitHub · 2026-11-25 21:15 UTC · original
oni-swr:t3/xcl-fix-2400-dxil-scratch-addr→main· +104 −9 · 4 files · 1 commits · draftOn RDNA2,
scratch_*picks its address form from SADDR alone:0x7D) is SV (VADDR + offset),0x7F(EXEC_HI) is ST (the offset alone).Both lowerings took
0x7Ffor the SV form and added ADDR's VGPR. So an ST access landed on whatever per-lane address that VGPR held. Now0x7Fgives a zero base, and ADDR is read only for0x7D.The issue also proposed checking an SVE bit and adding SGPR + VGPR. RDNA2 has neither: the RDNA2
ENC_FLAT_SCRATCHspec inrdna2_spec.rshas no SVE field, and both SVE and the SVS form arrived with GFX11 / GFX940. The source for the GFX10 encoding is LLVM:FLAT_Real_gfx10setsInst{54-48}to EXEC_HI for a scratch op without vaddr and to SGPR_NULL otherwise, and setsInst{55}to 0.scratch_load_dword v1, off, offwith byte 6 =0x7f.So only the ST half of the issue applies, and that is what this fixes.
Fixes #2400
Part of #1269
What is in it
crates/xcl/src/gpu/dxil/lower_mem.rs(scratch): the base is 0 for SADDR0x7F, VADDR for0x7Dand the SGPR otherwise (direct DXIL).crates/xcl/src/gpu/recomp/emit.rs(scratch): the same in the HLSL emitter, which had the same bug.dxil/core_tests.rs::scratch_reads_addr_only_in_the_sv_form: ST and SS containers do not change with ADDR, SV ones do.recomp/tests.rs::scratch_address_forms_follow_saddr: the HLSL address of each form.recomp/tests.rs::gpu_scratch_address_forms: GPU test of the three forms.gpu_more_atomics_sub_dword_scratch_valunow encodes the SV form (0x7D) its comment describes ("2 · lane + 16").Tested
XCL_ADAPTER=NONE_CPU_ONLY, so no D3D12 device was created. DXC 1.8.2502.11 and the dxil.dll validator from the Windows SDK were used.cargo test --workspace -j 4 -- --test-threads=4on57853e01: 1426 passed, 0 failed, 46 ignored. 218 GPU tests SKIPPED:no GPUand adapter-selection skips because ofXCL_ADAPTER, including the newgpu_scratch_address_forms.cargo clippy -p xcl --lib --tests: no findings on the changed lines. The lib already fails clippy on main, onlower_valu.rs:560andlower_wide.rs:568(approximate TAU).cargo fmt --check: the tree is not rustfmt-clean, so it reports 8536 existing diffs. The added code is formatted the way rustfmt wants.Regression run
scripts/smoke.ps1was not run on main or on this head. This PR stays a draft until bothxcl-smokeblocks are added.Not tested
gpu_scratch_address_formsand every other GPU test were skipped. No HLSL or direct DXIL kernel was run on hardware, and no NVIDIA, Intel or wave32-only GPU was tried.AI use
FLATInstructions.tdand MC tests, and ran the commands above.🤖 Generated with Claude Code
RDNA2 scratch_* has three address forms, chosen by SADDR alone: an SGPR is SS (SGPR + offset), NULL (0x7D) is SV (VADDR + offset) and 0x7F (EXEC_HI) is ST (the offset alone). There is no SGPR + VGPR form and no SVE bit on RDNA2; both came with GFX11 / GFX940. This is how LLVM encodes GFX10 scratch (FLAT_Real_gfx10 sets Inst{54-48} to EXEC_HI for a scratch op without vaddr and to SGPR_NULL otherwise, and Inst{55} to 0), and its gfx1030 MC tests encode `scratch_load_dword v1, off, off` with byte 6 = 0x7f. Both lowerings (direct DXIL lower_mem.rs and the HLSL emitter) took 0x7F for the SV form and added ADDR's VGPR, so an ST access went to a per-lane address that its value happened to hold. They now use 0 as the base for 0x7F, so ADDR is read only for 0x7D. Issue #2400 proposed checking an SVE bit and adding SGPR + VGPR. The RDNA2 ENC_FLAT_SCRATCH spec has no SVE field (bit 55 is not decoded), so that half does not apply; the ST case it describes is real and is the one fixed here. Tests: an HLSL text check of the three forms and a direct DXIL check that ST and SS containers do not change with ADDR while SV ones do (both fail without the fix), a GPU test of the three forms, and the existing scratch GPU test now encodes the SV form it describes. Fixes #2400 Co-Authored-By: Claude Opus 5.5 <[email protected]>@DavidM1911 on GitHub · 2026-11-25 21:32 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@ahmetbagci8 on GitHub · 2026-11-25 22:22 UTC · original
Tested
57853e017054d715cd46cd3c07cb70e58eddddc832.0.16.1714), Windows 11 Pro (Build 26300), DXCv1.9.2609cargo test -j 2 -p xcl --lib scratch -- --test-threads=4:8 passed; 0 failed; 0 ignored (2.03s)Not tested
scripts/smoke.ps1(no unpacked title locally).AI use
@SlopTart on GitHub · 2026-11-25 22:33 UTC · original
Tested: current PR head merged onto current
origin/main(clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).gpu_suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.No new test functions in the diff; the SADDR 0x7F ST-form change is exercised end to end by the existing suite, clean here.
Not tested: retail titles (no title data on this lane, counts only).
AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
@luckyteagirl on GitHub · 2026-11-25 23:17 UTC · original
Native RX 6800M validation on exact PR head
57853e017054d715cd46cd3c07cb70e58eddddc8(Windows 11 build 26200, Radeon RX 6800M driver30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.8.2502.11):XCL_ADAPTER=6800M XCL_REQUIRE_GPU=1 XCL_DIRECT_DXIL=1 cargo test --locked -p xcl --lib -j 1 gpu_scratch_address_forms -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored, 0 SKIPPED (1,326 filtered out). The test ran on the RX 6800M;runner::run_codeselects the direct kernel path forXCL_DIRECT_DXIL=1.XCL_DIRECT_DXIL=0to exercise HLSL + DXC lowering: 1 passed, 0 failed, 0 ignored, 0 SKIPPED (1,326 filtered out).Not tested: the full GPU workspace suite, release binary, paired retail smoke runs, other adapters/drivers, and whether the title encounters ST-form scratch instructions. This is focused hardware coverage of the new fixture, not a merge-ready regression run. No game data was uploaded.
AI use: OpenAI Codex (GPT-6; exact variant unavailable) ran the guarded focused tests, checked the exact head and runner selection, reviewed the logs, and drafted this report.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.