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

Manually merged
github merged 1 commit from gh-pr/716/head into gh-pr/716/base 2026-11-26 04:30:26 +00:00
Owner

@⁠milas6669 on GitHub · 2026-11-24 04:01 UTC · original
milas6669:disasm-smem → main · +46 −3 · 1 files · 1 commits · merged 2026-11-25 01:17 UTC

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 #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 #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
  • #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.
**@⁠milas6669** on GitHub · 2026-11-24 04:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/716) `milas6669:disasm-smem` → `main` · +46 −3 · 1 files · 1 commits · merged 2026-11-25 01:17 UTC `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 #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 #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 - #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.
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 #664 (part 4, the last).

Assisted-by: Claude Code (Claude Sonnet 5.5)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:30:25 +00:00
github manually merged commit 1e181b7f00 into gh-pr/716/base 2026-11-26 04:30:26 +00:00
Author
Owner

@⁠lordon1a on GitHub · 2026-11-24 04:07 UTC · original

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.
**@⁠lordon1a** on GitHub · 2026-11-24 04:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/716#issuecomment-7121732546) 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.
Author
Owner

@⁠MesshM on GitHub · 2026-11-24 04:07 UTC · original

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.

**@⁠MesshM** on GitHub · 2026-11-24 04:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/716#issuecomment-7121735681) 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.