Skip to content

Shaders: xcl disasm prints SMEM offsets, glc and dlc as LLVM does (#664) - #716

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
milas6669:disasm-smem
Nov 25, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
milas6669:disasm-smem

Conversation

@milas6669

Copy link
Copy Markdown
Contributor

xcl disasm appended , 0x<offset> to every SMEM instruction (also , 0x0 after an SGPR offset, and on s_memtime, which has none) and never printed glc / dlc, so the text differed from the instruction that runs. Now it prints what LLVM does: s_load_dword s5, s[2:3], 0x64 (SOFFSET = null: the immediate is the offset; null when it is 0), s0 offset:0x12345 (SGPR offset, then the immediate when not 0), then glc / dlc.

Part of #664 (part 4, the last). Independent of #687 and #706: it merges with both without conflicts.

What is in it

  • crates/xcl/src/gpu/rdna2.rs: the ENC_SMEM arm of format(), only for instructions with an SOFFSET operand
  • test smem_text_matches_llvm: the 174 SMEM lines of tests/data/llvm-amdgpu/gfx10_smem.txt that RDNA2 decodes (the other 251 are gfx10.1-only and do not decode) match LLVM's text, plus the word from xcl disasm drops VOP3/VOP3P modifiers, EXP targets and VINTRP attributes from its text #664 (s_load_dwordx8 null, s[68:69], vcc_lo offset:0xf50a7 glc dlc)
  • the text also appears in the translated HLSL's comments, so the DXIL cache misses once

Tested

  • NVIDIA GeForce RTX 3070 (32-lane waves), Intel i9-10900KF, Windows 11 Pro 10.0.26200, MSVC 19.44, Rust 1.100.0, debug build
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on this commit: 702 passed, 0 failed, 41 ignored (three D3D12.X tests fail in some runs on a clean main too; see Shaders: xcl disasm prints VOP3 / VOP3P source and output modifiers (#664) #687)
  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64)

Regression run
main (f4ce27c):

xcl-smoke v1
commit: f4ce27ceb6d1b0576d0c659b713b674778bf1968
gpu: NVIDIA GeForce RTX 3070
title: dumped
seconds: 60
exit: 0x0
frames shown: 424 (PresentX 424)
presents per 2 s (last 3): 16 14 14
device removals: 0
crashes: 0
peak commit: 15867 MB

this PR (1e181b7):

xcl-smoke v1
commit: 1e181b7f009d9bf912b7586fecca7844c1f641a7
gpu: NVIDIA GeForce RTX 3070
title: dumped
seconds: 60
exit: 0x0
frames shown: 522 (PresentX 522)
presents per 2 s (last 3): 19 18 17
device removals: 0
crashes: 0
peak commit: 15865 MB

Not tested

  • AMD, wave64 GPUs
  • the retail title prints no disassembly during a run, so the runs above are only a regression check
  • SMEM instructions that exist only in gfx10.1 (the 251 corpus lines that do not decode)
  • a negative 21-bit offset: it prints as a 21-bit hex value, as before
  • RDNA2 decoder: opcodes from a table per encoding, fields a word at a time #479 also edits rdna2.rs; I did not check the two together

AI use

  • Claude Code, Claude Sonnet 5.5: wrote the code, the test and this description.

…l-dev#664)

format() appended `, 0x<offset>` to every SMEM instruction, even one with an SGPR offset (the
offset was then `, 0x0`) or no offset at all (s_memtime), and never printed glc / dlc.
Now `s_load_dword s5, s[2:3], 0x64` (SOFFSET = null: the immediate is the offset, `null` when
it is 0), `s0 offset:0x12345` (SGPR offset, then the immediate when not 0), then glc and dlc.
Instructions with no offset operand print neither.

The new test compares the 174 SMEM lines of tests/data/llvm-amdgpu/gfx10_smem.txt that RDNA2
decodes (the rest are gfx10.1-only) with LLVM's text, plus the word from the issue. The text
also appears in the translated HLSL's comments, so the DXIL cache misses once.

Part of xcl-dev#664 (part 4, the last).

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

Copy link
Copy Markdown

Independent test report on 1e181b7:

Tested

  • Hardware: NVIDIA GeForce RTX 3070 Ti Laptop GPU (driver 616.64, SM 6.6), Intel i7-12700H, Windows 11 Home 26H2 (build 26200), rustc 1.100.0 (x86_64-pc-windows-gnullvm), debug build
  • Command: cargo test -p xcl --lib gpu::rdna2::tests -- --nocapture
  • Result: 10 passed, 0 failed, 0 ignored in 0.31s (smem_text_matches_llvm ok)

Not tested

  • AMD / Intel GPU, retail title

AI use

  • Antigravity (Google DeepMind agent) — fetched 1e181b7 in a detached worktree, audited the diff, ran the test suite, and posted this report.

@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of 1e181b7f009d9bf912b7586fecca7844c1f641a7 on AMD RDNA4. I merged it onto current main f4ce27c locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 702 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 661 passed, 0 failed, 21 ignored
  • 0 SKIPPED; smem_text_matches_llvm passes.

Review: With SOFFSET = 125 (null) the immediate is the offset and prints as , 0x… or , null when 0; with an SGPR offset it adds offset: only when the immediate is not 0; glc / dlc follow. That is LLVM's text, and s_memtime (no SOFFSET operand) no longer gets an offset. I found nothing to change.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants