Skip to content

Recompiler: track SMEM register offsets as scalar reads - #1540

Open
oni-swr wants to merge 1 commit into
xcl-dev:mainfrom
oni-swr:recompiler/smem-offset-uses
Open

oni-swr wants to merge 1 commit into
xcl-dev:mainfrom
oni-swr:recompiler/smem-offset-uses

Conversation

@oni-swr

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

Copy link
Copy Markdown
Contributor

SMEM's register offset has operand type OPR_SMEM_OFFSET, which sgpr_uses omitted. A register used only as SOFFSET was 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

  • RX 7800 XT, driver 32.0.31035.1003; Ryzen 7 5700X3D; Windows 11 Pro build 26200; Rust 1.100.0 MSVC; debug.
  • cargo test -p xcl --lib gpu::rdna2::tests::scalar_memory_register_offset_is_a_read -- --exact: on main 9e3831e with only the test added, 0 passed / 1 failed / 0 ignored. The fixed test passes in the full suite below.
  • cargo build --workspace: passed at a8683ef.
  • 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, reason no heap windows; this is not coverage.
  • 60-second title regression runs below use the debug binary built separately from each commit.

Regression run

xcl-smoke v1
commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 744 (PresentX 744)
presents per 2 s (last 3): 55 24 0
device removals: 0
crashes: 0
peak commit: 15435 MB
xcl-smoke v1
commit: a8683ef45d1a38e0200558e6666ec965476e5e6b
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 820 (PresentX 820)
presents per 2 s (last 3): 45 12 7
device removals: 0
crashes: 0
peak commit: 16226 MB

Not tested

  • NVIDIA, Wine, release builds. The smoke runs do not exercise the unmerged per-lane DXIL backend; they check the current runtime. No claim of title performance improvement.

AI use

  • T3 Code through Codex, gpt-6.1-sol: investigated the issue and coordination thread, wrote the fix and test, ran validation, and wrote this description.

SMEM SOFFSET has operand type OPR_SMEM_OFFSET, which sgpr_uses omitted. Include it so clients such as the per-lane lowering initialize the offset register. Test SGPR offsets and NULL; the test fails on main without this change.

Assisted-by: T3 Code / Codex (gpt-6.1-sol)
@oni-swr
oni-swr marked this pull request as ready for review November 24, 2026 18:09
@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Read the diff against the ISA tables: the scope is right. In rdna2_spec.rs the only field typed OPR_SMEM_OFFSET is SMEM's SOFFSET (all the S_LOAD / S_BUFFER_LOAD / store / atomic forms). The 21-bit immediate OFFSET is not an operand there, so this can't make an immediate look like an SGPR read. SOFFSET 0 is s0, not NULL (0x7D), so a load with an unset SOFFSET now reads s0, which is right (the same distinction as #1456's test fix). M0 (124) as SOFFSET is 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.

@nnonno91

Copy link
Copy Markdown

Independent NVIDIA and per-lane lowering test for a8683ef45d1a38e0200558e6666ec965476e5e6b.

Tested

  • Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, NVIDIA GeForce RTX 5090 (32.0.16.1742), Rust 1.100.0 MSVC, DXC 1.9.2609.5, debug. cargo build --workspace --locked passed. cargo test --locked -p xcl --lib -- --exact gpu::rdna2::tests::scalar_memory_register_offset_is_a_read --test-threads=1 passed.
  • cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-output reported 777 passed, 0 failed, and 41 ignored. Three reported GPU skips in that pass count: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64), plus heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows). The bundled title passed.
  • In a separate worktree at gefydev/xcl:direct-on-1426 revision c391dbf9dedcd87e4e6968a70c0280d5d88aa7dd, I ran cargo test --locked -p xcl --test smem_offset_probe -- --exact register_offset_reaches_per_lane_dxil --nocapture --test-threads=1 with a temporary three-instruction shader before and after applying just the PR’s production change. Before, S_LOAD_DWORD listed s0 and s1 as reads and per-lane lowering refused with s4: a mask read as a number. After, it also listed s4, 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 listed s16 as 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.

@DavidM1911

Copy link
Copy Markdown
Contributor

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 unmodified main.)

Thanks!

@ivall ivall added the goal:world-load Bears on the retail title getting past world loading label Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants