Skip to content

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

Closed
ufoptg wants to merge 3 commits into
mainfrom
upstream-pr/1013
Closed

ufoptg wants to merge 3 commits into
mainfrom
upstream-pr/1013

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

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 xcl-dev#664. No open PR found for any of them (gh pr list --search "disasm"), and this merges cleanly with xcl-dev#687, xcl-dev#706, xcl-dev#716, xcl-dev#790 / xcl-dev#791, xcl-dev#811 and xcl-dev#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) xcl-dev/xcl#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
We have no retail title. This changes crates/xcl/src/gpu/rdna2.rs, so it needs one; could someone with a title run scripts/smoke.ps1 on main and on this head? The change is in the printed text of instructions only (listings, reports and the // pc: … comment lines of the translated HLSL; no HLSL code line changes).

main:

PR:

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


Mirror of xcl-dev#1013 (auto-synced, do not edit).

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>
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#1013 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/1013 branch November 25, 2026 00:09
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.

2 participants