Skip to content

Shaders: xcl disasm prints DS, buffer and flat operands as LLVM - #1013

Open
upipibi wants to merge 3 commits into
xcl-dev:mainfrom
upipibi:disasm-flat-operands
Open

upipibi wants to merge 3 commits into
xcl-dev:mainfrom
upipibi:disasm-flat-operands

Conversation

@upipibi

@upipibi upipibi commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

xcl disasm prints three families of memory instructions differently from what they encode. Each commit compares the printed line with LLVM's for every line of the in-repo LLVM corpus of that family (tests/data/llvm-amdgpu). They're one PR because all three change the same match arm of format; they're separate commits, so each can be reviewed or dropped on its own. One more set of the text gaps of #664. No open PR found for any of them (gh pr list --search "disasm"), and this merges cleanly with #687, #706, #716, #790 / #791, #811 and #812.

What is in it (all in crates/xcl/src/gpu/rdna2.rs, text only)

  • b0ec796 DS: single-address LDS / GDS instructions print one 16-bit offset: (they were split into offset0:52 offset1:18 for offset:4660); ds_read2* / ds_write2* / ds_wrxchg2* keep offset0: / offset1:. Test llvm_gfx10_ds_text: 1705 lines of gfx10_ds.txt.
  • cdc4546 MUBUF / MTBUF: the address is off, one register or a pair according to IDXEN / OFFEN (it was always two, so a constant-offset load showed a VGPR it doesn't read); format:[BUF_FMT_…] for tbuffer_*; flags in LLVM's order including lds and tfe; TFE's extra data register. Tests llvm_gfx10_buffer_text (822 lines of gfx10_mubuf.txt / gfx10_mtbuf.txt) and buffer_address_format_and_flags (5 words checked against llvm-mc 21.1.8, -mcpu=gfx1030).
  • 6d247e5 FLAT / GLOBAL / SCRATCH: only the operands the form has: no result register for an atomic that returns none, off for a missing base (it printed null / exec_hi), one address register beside an SGPR base, a signed 12-bit offset, then glc slc dlc lds. Test llvm_gfx10_flat_text: 368 lines of gfx10_flat.txt / gfx1030_new.txt.

Tested

  • NVIDIA GeForce RTX 3070 8 GB, driver 616.56 (32.0.16.1656), 32-lane waves only; Ryzen 9 5950X; Windows 11 Pro 26100; Rust 1.100.0 MSVC, debug.
  • cargo test -p xcl --lib gpu::rdna2::tests::: 13 passed, 0 failed. Before each commit its new tests fail: DS "1043 of 1705 lines differ from LLVM's", buffer "820 of 822", flat "333 of 368".
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on 6d247e5 (all three): 708 passed, 0 failed, 41 ignored (xcl lib: 667 passed, 0 failed, 21 ignored). An earlier run had the Tests: placed_title_textures_share_vram_and_preserve_pixels fails now and then at its cubemap reuse check (main 9ce2070) #718 cubemap flake (705 passed, 3 failed: placed_title_textures_share_vram_and_preserve_pixels and the two tests its poisoned lock takes with it), which main shows on this machine too.
  • SKIPPED GPU tests: 2, both no wave64: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.

Regression run

From Kalmarv's run (#1013 (comment)), thanks:

main:

xcl-smoke v1
commit: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1254 (PresentX 1254)
presents per 2 s (last 3): 25 34 13
device removals: 0
crashes: 0
peak commit: 28567 MB

PR:

xcl-smoke v1
commit: 6d247e569d3b30e15aa602fa0eaa0d64bbb3e4f2
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1253 (PresentX 1253)
presents per 2 s (last 3): 10 26 29
device removals: 0
crashes: 0
peak commit: 28087 MB

Not tested

  • No retail title, no XCL_SAMPLE_* data: the game-data tests passed without running.
  • AMD / Intel GPUs, wave64 hardware.
  • The 13 ds_swizzle_b32 lines with a pattern: the pattern stays a number (offset:57344) where LLVM writes offset:swizzle(FFT,0).
  • A buffer load into LDS keeps its data register in the text (LLVM leaves it out). lds and tfe were each checked alone against llvm-mc; their order among other flags is LLVM's by analogy.
  • Flat: only what the corpus has; no words of my own against llvm-mc.

AI use

  • AI-assisted (Claude Code with Claude Fable 5.2): found the gaps by comparing xcl disasm with the LLVM test lines in the repository, wrote the code, the tests and this description, and ran the tests.

🤖 Generated with Claude Code

upipibi and others added 3 commits November 23, 2026 23:54
An LDS / GDS instruction has two offset bytes. Only the instructions
with two addresses (ds_read2*, ds_write2*, ds_wrxchg2*) read them as
two; for all the others they are one 16-bit offset, and the listing
split it: `ds_add_u32 v1, v2 offset0:52 offset1:18` for offset:4660.
Printed as LLVM does now.

All 1705 such lines of LLVM's gfx10 DS tests in tests/data/llvm-amdgpu
read the same (662 did: those without an offset or with two). The
pattern of ds_swizzle_b32 stays a number (LLVM: swizzle(...)).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A buffer (MUBUF / MTBUF) instruction was printed with two address
registers whatever IDXEN and OFFEN said, so a load at a constant offset
read `buffer_load_dword v5, v[0:1], …` though it reads no VGPR; a
tbuffer instruction's format was not printed; TFE and LDS were not
either, and the flags came in another order than LLVM's. Now: `off`,
the index or offset register, or both; `format:[BUF_FMT_…]` (a number
past the table; nothing for 8_UNORM, as LLVM); idxen, offen, offset,
glc, slc, dlc, lds, tfe; and TFE's extra data register.

All 822 lines of LLVM's gfx10 MUBUF / MTBUF tests in
tests/data/llvm-amdgpu now read the same (2 did).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A flat, global or scratch instruction was printed with every operand
its opcode can have, whatever its addressing mode: the result register
of an atomic that returns none (`flat_atomic_add v0, v[1:2], v2` for
`flat_atomic_add v[1:2], v2`), `null` or `exec_hi` for the base an
address has not, two address registers where a global address beside an
SGPR base is one, and a negative offset as a large positive one. Now
the operands of the form: no result without GLC (or with LDS), `off`
for the missing base, the VGPR or SGPR a scratch address uses, a signed
12-bit offset (global, scratch), and glc / slc / dlc / lds.

All 368 flat / global / scratch lines of LLVM's gfx10 tests in
tests/data/llvm-amdgpu now read the same (35 did).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@futurepro62

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 6d247e5 (on its base e50836b).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 708 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: llvm_gfx10_flat_text, buffer_address_format_and_flags, llvm_gfx10_buffer_text, llvm_gfx10_ds_text.

Not tested

  • AMD, a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@Kalmarv

Kalmarv commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Regression pair for 6d247e5 against main e50836b (this PR's base), for the Regression run section. Both runs pass: no device removal, no crash, 100 % of main's frames, 98 % of its peak commit.

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74), AMD Ryzen 9 9950X, Windows 11 Pro 26200.
  • scripts/smoke.ps1, the same retail title for 60 s each: main at e50836b (this PR's base, 67 commits behind today's main) first, then this PR's head, one after the other on the same machine.

main e50836b:

xcl-smoke v1
commit: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1254 (PresentX 1254)
presents per 2 s (last 3): 25 34 13
device removals: 0
crashes: 0
peak commit: 28567 MB

this PR, 6d247e5:

xcl-smoke v1
commit: 6d247e569d3b30e15aa602fa0eaa0d64bbb3e4f2
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1253 (PresentX 1253)
presents per 2 s (last 3): 10 26 29
device removals: 0
crashes: 0
peak commit: 28087 MB

An earlier pair on the same two commits had this PR's run crash at 30.8 s: 0xc0000005 in VCRUNTIME140.dll+0x1c45a (the memcpy of copy_from_slice) ← tiling::Chain::detile_level (tiling.rs:438) ← title_textures::subresources (title_textures.rs:1170) on a subresources_on worker, reading title memory outside the coherent window. This PR doesn't touch that code; it is the in-place read race that open #751 addresses. The blocks above are the second pair, run after it.

Not tested

  • xcl disasm itself: the run doesn't print a disassembly, so it shows only that the rest of the runtime is unchanged.
  • World loading: a 60 s run ends before it.
  • AMD, Linux.

AI use: Claude Code (Claude Opus 5.5)

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.

3 participants