Recompiler: track SMEM register offsets as scalar reads #1530
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1540"
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?
Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-24T17:25:16Z.
SMEM's register offset has operand type
OPR_SMEM_OFFSET, whichsgpr_usesomitted. A register used only asSOFFSETwas therefore absent from the read set; the per-lane lowering on gefydev's branch could reject such a load because its initial SGPR value was not loaded. Part of #1269.What is in it
rdna2.rs: include SMEM register offsets in scalar reads; test s4, s7 and NULL offsets, preserving the destination write set.Tested
cargo test -p xcl --lib gpu::rdna2::tests::scalar_memory_register_offset_is_a_read -- --exact: on main9e3831ewith only the test added, 0 passed / 1 failed / 0 ignored. The fixed test passes in the full suite below.cargo build --workspace: passed ata8683ef.cargo test --workspace -- --test-threads=4 --nocapture: 777 passed / 0 failed / 41 ignored. One SKIPPED test (included in the harness's passed count):heap_window_out_of_memory_falls_back_to_the_switch_form, reasonno heap windows; this is not coverage.Regression run
Not tested
AI use
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T18:13:27Z.
Read the diff against the ISA tables: the scope is right. In
rdna2_spec.rsthe only field typedOPR_SMEM_OFFSETis SMEM'sSOFFSET(all theS_LOAD/S_BUFFER_LOAD/ store / atomic forms). The 21-bit immediateOFFSETis not an operand there, so this can't make an immediate look like an SGPR read.SOFFSET0 is s0, not NULL (0x7D), so a load with an unsetSOFFSETnow reads s0, which is right (the same distinction as #1456's test fix). M0 (124) asSOFFSETis a read too, as it should be. I haven't run it.AI use: Claude Code (Claude Opus 5.5) read the change and wrote this.
Imported from ivall/xcl. Originally posted by nnonno91 on 2026-11-24T18:13:36Z.
Independent NVIDIA and per-lane lowering test for
a8683ef45d1a38e0200558e6666ec965476e5e6b.Tested
cargo build --workspace --lockedpassed.cargo test --locked -p xcl --lib -- --exact gpu::rdna2::tests::scalar_memory_register_offset_is_a_read --test-threads=1passed.cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-outputreported 777 passed, 0 failed, and 41 ignored. Three reported GPU skips in that pass count:gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64), plusheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows). The bundled title passed.gefydev/xcl:direct-on-1426revisionc391dbf9dedcd87e4e6968a70c0280d5d88aa7dd, I rancargo test --locked -p xcl --test smem_offset_probe -- --exact register_offset_reaches_per_lane_dxil --nocapture --test-threads=1with a temporary three-instruction shader before and after applying just the PR’s production change. Before,S_LOAD_DWORDlisteds0ands1as reads and per-lane lowering refused withs4: a mask read as a number. After, it also listeds4, validated the directly generated DXIL, and executed it on the RTX 5090. Register offsets of 0, 4, and 12 bytes selected the expected three memory words across all 32 lanes each time. Both versions listeds16as the destination.Not tested
Retail titles, Wine, or release builds. The per-lane run used a synthetic kernel on the pinned experimental revision with the one-line fix applied locally.
AI use
OpenAI Codex (GPT-6 family, exact variant unavailable) wrote the temporary probe, ran the checks, and drafted this report.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T19:12:57Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
upstream-sync referenced this pull request2026-11-25 06:04:27 +00:00
Imported from ivall/xcl. Originally posted by vakaobr on 2026-11-25T09:28:59Z.
Test report from a Mac (D3DMetal), #1540 at
a8683efmerged intomainc4d37be.The per-lane form refuses every kernel whose
s_load_dwordnames an SGPR asSOFFSETthat the program didn't write first:s_load_dword s4, s[2:3], s0, 0x8and the same withs1both gives0/s1:a mask read as a numberonmain. With the same register as ans_add_u32source, or after ans_mov_b32writes it, it's accepted, which fits your reading (the prologue never loads a registersgpr_usesdoesn't list). In my differential harness that was 995 of 1000 generated programs refused onmain.Tested
x86_64-pc-windows-gnu, debug, DXC 1.9.2609. Each test in its own process.gpu::rdna2::tests::scalar_memory_register_offset_is_a_read: 1 passed.lower_dxil::kernel_split(SOFFSETs0,s1, null,s0afters_mov_b32, ands0/s1as ALU sources): refused 2 onmain, all 9 accepted with this PR.main.ifs, HLSL path against the per-lane form: 996 identical and 0 refused with this PR (995 refused onmain). The other 4 differ in the HLSL path only; the per-lane and per-instruction forms agree with each other there (details on #1269).Not tested
lower_dxil::compute*), where the samesgpr_useslist may decide which user SGPRs are loaded.AI use: Claude Code, Claude Opus 5.5 found the refusals with the harness, ran the tests above on this machine and wrote this report.
Imported from ivall/xcl. Originally posted by throny on 2026-11-25T10:28:35Z.
Test report for exact head
a8683ef.Tested
cargo build --workspace && cargo test --workspace -- --test-threads=4ona8683efas it is (its own base): 777 passed, 0 failed, 41 ignored.SKIPPED: 3 lines (no wave64 on this adapter, and the like).scripts/smoke.ps1, the retail title, 60 s, release builds,main568e7dbfirst, then this head. Both runs started without the preload list newer builds leave behind (used-pipelines.txtin the DXIL cache), which makes builds on an older base run out of memory at start:main:
PR:
Not tested: AMD, the head merged onto current
main, a world load.AI use: Claude Code (Claude Opus 5.5) ran this and wrote the report; the diff was read for safety by a Claude Opus 5.5 sub-agent before it was built.
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-26T06:48:53Z.
AMD RDNA4 / Linux (Proton Experimental) test report on head
a8683ef4(merged cleanly ontomainb49be183):Hardware & environment
experimental-11.0-20261112),vkd3d-protonmasterec207194(3.2.0) +dxil-spirvb540c8a2+ relaxed-vtable patch (-Db_ndebug=true), DXVKv3.1.1-209, DXC1.9.2609.5, Rustx86_64-pc-windows-gnuIsolated unit tests (
mainb49be183+ #1540a8683ef4, debug,--test-threads=1):xcl.exe gpu::rdna2:: -- --test-threads=1: 19 passed, 0 failed, 0 ignored (0 skipped).Combined 300 s retail sanity run (release,
mainb49be183+ #1540 + #1675 + #1844 + #1899 + #2123 + #2369 + #2422, retail 1.0.2.1 pressingApast menus):exit=0), 0 crashes, 0 device removals,2,014PresentXframes,131,072translated draws,660,943dispatches (44,546chained split-compute dispatches),102,631Opus packets (0 errors).Not tested
AI use
main, ran the Proton unit tests and combined retail run on this machine, and drafted this report.Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T12:12:09Z.
Independent desktop NVIDIA verification of PR #1540 at head
a8683ef45d1a38e0200558e6666ec965476e5e6b(1commit; exact parent & merge-base:9e3831e1f570d3646e53ab753b19ec07eb8f1485, pre-#2555ancestor ofmain).Environment
7956 MiBreported by D3D12, Wave32-only Ada), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted tests & build (
a8683ef4)cargo test --release -p xcl --lib scalar_memory_register_offset_is_a_read -- --nocapture(3 consecutive runs)1 passed; 0 failed; 0 ignored; 748 filtered out× 3 (0.00s,0.00s,0.00s,0skipped)cargo test --release -p xcl --lib gpu::rdna2:: -- --nocapture(3 consecutive runs)10 passed; 0 failed; 0 ignored; 739 filtered out× 3 (0.02s,0.03s,0.03s,0skipped; includesscalar_memory_register_offset_is_a_readandllvm_gfx10_corpus)cargo build --release -p xcl1m 07s, exit0,0new warnings inrdna2.rs)Paired quiet 60 s retail smoke (
title: 29640639)(Note:
scripts/smoke.ps1at9e3831e1predates9683e7a6and printed the local folder basename ontitle:; replaced below with the standard9683e7a6title hash29640639, with all measured fields verbatim.)Exact parent & merge-base (
9e3831e1f570d3646e53ab753b19ec07eb8f1485, cached baseline on the same machine):PR #1540 (
a8683ef45d1a38e0200558e6666ec965476e5e6b):Limits of coverage
scalar_memory_register_offset_is_a_readand all10/10gpu::rdna2::unit tests (0skipped) passed3/3, directly verifying that SMEM register offsets are tracked as scalar reads.0device removals,0crashes); single-run frame/commit delta vs. the cached parent reflects normal startup variance.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T03:05:11Z.
merge-check claim
head:
a8683ef45dImported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T03:12:23Z.
merge-check
base:
07eec51effhead:
a8683ef45dmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2826 passed, 0 failed, 51 ignored; SKIPPED: 28 (22 no wave64 on this GPU; 3 per-lane form refused (#1426 semantics); 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1); 1 driver cache cannot be disabled without Windows Developer Mode); failing: none. The PR's new test scalar_memory_register_offset_is_a_read passes.
review: no blocking finding; whole diff read (one line plus a test). In the ISA table OPR_SMEM_OFFSET is only the SOFFSET register field of the SMEM loads (the immediate OFFSET is not an operand), so sgpr_uses now reports that SGPR as a read; null (125) and codes above 127 stay skipped as before, and the size is one register. The users of sgpr_uses gain from it: for example the direct-DXIL kernel's touched-register set (dxil/kernel.rs), which decides which SGPRs the test kernel loads, so an SGPR read only as an SMEM offset is no longer left out; the per-lane lowering's read sets (recomp/lower.rs) and compact.rs see it too. Minor: the test checks sgpr_uses' output only, not a translation that reads an offset register. No other open PR changes this operand (checked #2134, #2000, #2365, #811, #2935, which touch sgpr_uses for other operands).
performance: none measurable: at most one more SGPR counted live for SMEM loads with a register offset.
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER 12 GB (621.24 / 32.0.16.2124), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 25H2 26200.9974, Rust 1.100.0, debug / Claude app (Claude Opus 5.5): merge, build and suite run on this PC with git and cargo only; diff review by Claude Opus 5.5.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T03:12:57Z.
merge-check claim
head:
a8683ef45dImported from ivall/xcl. Originally posted by johnbf8x on 2026-11-30T03:16:17Z.
merge-check claim
head:
a8683ef45dImported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T03:19:02Z.
merge-check
base:
45ebed1005head:
a8683ef45dmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2826 passed, 1 failed, 51 ignored; 32 SKIPPED lines
failing: test_title_runs_and_game_folder_is_untouched
review: automated overnight check: diff read for safety (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no duplicate search performed.
performance: not assessed beyond the suite.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
Imported from ivall/xcl. Originally posted by johnbf8x on 2026-11-30T05:07:44Z.
merge-check
base:
b9d5b2527dhead:
a8683ef45dmerge: clean (git merge --no-commit --no-ff onto origin/main in a detached worktree; the merged tree was tested uncommitted). Also tested the same way on
f97120dcbefore main took the recompiler merges up to #2070; same results therebuild: cargo build --workspace -> ok (the PR merged and main alike, each in its own target dir)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (XCL_DXC_DIR = DXC 1.9.2609) -> main and PR the same: 141 passed, 2 failed, 20 ignored outside the lib; the lib binary ends abnormally on both (0x80004005), so no lib total. SKIPPED: 25 on both (22 no wave64, 2 no heap windows, 1 no D3D12 debug layer). Failing: e2e test_title_draws_with_a_root_signature_under_the_debug_layer and test_title_runs_under_the_debug_layer_with_dred (no D3D12 debug layer on this PC), both fail on main too. The lib in parts: hle::d3d12x::list_x alone on 1 thread 113 passed on both; the rest on 4 threads before the process ends: PR 1774 ok, main 1772 ok, 1 failed on both: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16 ("2D D16 resinfo clobbered v2/v3", left (0, 0), right (3735928559, 3405691582); it passed on
f97120dcon both and fails on mainb9d5b252alone too, so it comes from the merges afterf97120dc, not from this PR). Next to the change, on 1 thread: gpu::rdna2::tests::, gpu::recomp::lower_dxil::tests:: and gpu::recomp::tests:: PR 271 passed, main 270 passed, 0 failed, 19 ignored on both; the new scalar_memory_register_offset_is_a_read passes. Fails without the fix: the test alone applied to mainb9d5b252fails at SOFFSET 4 (left [0, 1], right [0, 1, 4]). Onf97120dcthe PR tree once failed gpu_two_pass_cache_e2e in the 4-thread suite (two_pass_count 1, not 0, after the 5 s late-release wait); that binary alone then passed 5 of 5 on the PR and 5 of 5 on main, so I take it as a timing flake under loadreview: none blocking, after reading the whole diff (rdna2.rs, 13 lines). sgpr_uses now also lets OPR_SMEM_OFFSET operands through, so an SGPR used only as SMEM's SOFFSET is in the read set; NULL (125) still stays out and the write set is unchanged, as the test asserts for s4, s7 and NULL. The 8 recompiler merges after
f97120dcchange rdna2.rs (vgpr_uses for MIMG) and the sgpr_uses callers in recomp/lower.rs, but onb9d5b252sgpr_uses still leaves SOFFSET out, so the fix is still needed. Only the read set grows; what a larger read set does in each caller (lower.rs, lane_masks.rs, dxil/kernel.rs, dxil/compact.rs) is covered here only by their unit tests. Not covered: gefydev's per-lane branch from #1269, wave64 (no wave64 on this GPU) and a titleperformance: none expected: one more string compare per operand in sgpr_uses (reasoned, not measured)
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 3070 Ti 8 GB (driver 621.40), Intel Core i7-12700K, Windows 10 Pro 19045, rustc 1.100.0 / Claude Code, Claude Opus 5.5