Skip to content

Shaders: xcl disasm prints SDWA selectors, modifiers and scalar sources - #790

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
upipibi:disasm-sdwa-modifiers
Nov 25, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
upipibi:disasm-sdwa-modifiers

Conversation

@upipibi

@upipibi upipibi commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

xcl disasm (and every listing made with gpu::rdna2::format) prints an SDWA instruction as its registers only: v_add_f32_sdwa v5, v1, v2, whatever the extension dword says. Left out: the byte / word each source is read from and the result is written to (src0_sel, src1_sel, dst_sel, dst_unused), sext() / neg / abs on the sources, clamp and the output modifier; a second source with its S bit set is printed as a VGPR (v2 for s2); and a compare that writes an SGPR instead of VCC (SD) does not show it. The decoder and the recompiler have all of these (emit.rs reads the same fields); only the printed line drops them, so the listing shows another instruction than the one that runs. This is the gap of #664 in an encoding that issue and its PRs (#687, #706, #716) do not cover; I found no issue or PR for it.

What is in it

  • crates/xcl/src/gpu/rdna2.rs: sdwa_source (VGPR or scalar operand with sext(), -, |…|), sdwa_modifiers (clamp, mul:2 / mul:4 / div:2, dst_sel, dst_unused, src0_sel, src1_sel, in LLVM's words and order), sdwa_compare_destination (the SDST of a v_cmp_*_sdwa with SD set), called from operand_text / format.
  • Tests in the same file: llvm_gfx10_sdwa_text compares the whole line with LLVM's for all 2816 SDWA lines of tests/data/llvm-amdgpu (gfx10_vop1_sdwa.txt, gfx10_vop2_sdwa.txt); sdwa_modifiers_and_scalar_sources has 12 words checked against llvm-mc 21.1.8 (-mcpu=gfx1030), among them the compare forms, which the corpus does not have. sdwa_and_dpp_src0 gets the two new tails.
  • Deliberately not LLVM's: the implicit vcc / vcc_lo operands stay out, as in the plain forms (v_add_co_ci_u32, v_cndmask_b32, a compare without SDST); a selector value without a name (7; dst_unused 3) is printed as its number.

The text also goes into the // pc: … comment lines of the translated HLSL, so the HLSL of a program with SDWA instructions changes in its comments (no code line changes).

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: 11 passed, 0 failed. With the tests on main's format (f4ce27c): 3 failed – llvm_gfx10_sdwa_text "2816 of 2816 SDWA lines differ from LLVM's", sdwa_modifiers_and_scalar_sources, sdwa_and_dpp_src0.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on 5a60d0d: two runs, each from a clean build of the workspace crates. Run 2: 703 passed, 0 failed, 41 ignored (xcl lib: 662 passed, 0 failed, 21 ignored). Run 1: 700 passed, 3 failed, 41 ignored – placed_title_textures_share_vram_and_preserve_pixels ("cubemap extra_pages must be reused at same va") and the two tests its poisoned lock takes with it (transitions_apply_when_their_list_is_submitted, d32s8_targets_take_their_own_size_of_video_memory): the failure of Tests: placed_title_textures_share_vram_and_preserve_pixels fails now and then at its cubemap reuse check (main 9ce2070) #718, which main f4ce27c shows on this machine too (657 passed, 3 failed in the lib).
  • SKIPPED GPU tests: 2, both no wave64: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.

Regression run
Run by @Anon64 on an NVIDIA GeForce RTX 3060 (posted in this PR's comments; we have no retail title here).

main:

xcl-smoke v1
commit: f4ce27ceb6d1b0576d0c659b713b674778bf1968
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1615 (PresentX 1615)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16472 MB

PR:

xcl-smoke v1
commit: 5a60d0dad6be82337d8a41fcafdd3f73c9f8be95
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1641 (PresentX 1641)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16974 MB

Not tested

  • No retail title, no XCL_SAMPLE_* data: the game-data tests passed without running.
  • AMD / Intel GPUs, wave64 hardware.
  • No D3D12 debug layer on this machine (Graphics Tools not installed): test_title_draws_with_a_root_signature_under_the_debug_layer and uploads_start_from_each_subresources_state return early.
  • LLVM prints nothing for SDWA selector values it has no name for (llvm-mc 21.1.8 crashes on selector 7), so the numbers printed for those are not compared with anything.

AI use

  • Claude Code with Claude Fable 5.2 (Anthropic): found the gap 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

An SDWA instruction's text stopped at its registers: which byte or word
each source is read from and the result written to, sext / neg / abs on
the sources, clamp and the output modifier were left out, a second
source with its S bit set was printed as a VGPR, and a compare that
writes an SGPR instead of VCC did not show it. The decoder and the
recompiler have all of these; only the printed line dropped them (the
same gap as xcl-dev#664, in the encodings that issue does not list).

The text follows LLVM's: all 2816 lines of its gfx10 SDWA tests in
tests/data/llvm-amdgpu now read the same (none did), apart from the
implicit vcc operands that the plain forms leave out too.

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

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of 5a60d0dad6be82337d8a41fcafdd3f73c9f8be95 on AMD RDNA4. I merged it onto current main e50836b 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: 706 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 665 passed, 0 failed, 21 ignored
  • 0 SKIPPED; llvm_gfx10_sdwa_text and sdwa_modifiers_and_scalar_sources pass.

Review: Disassembler text only. 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.

@eizispark

Copy link
Copy Markdown
Contributor

Hardware check of 5a60d0dad6be82337d8a41fcafdd3f73c9f8be95 (verified clean merge with main beaa245): pass.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profile
  • cargo test --workspace -- --test-threads=4: 703 passed, 0 failed, 41 ignored (GPU tests skipped on this adapter: none)
  • cargo test -p xcl --lib gpu::rdna2: 11 passed, 0 failed (including llvm_gfx10_sdwa_text, sdwa_modifiers_and_scalar_sources, sdwa_and_dpp_src0)

Regression run
main (beaa245):

xcl-smoke v1
commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1660 (PresentX 1660)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14862 MB

PR (5a60d0d):

xcl-smoke v1
commit: 5a60d0dad6be82337d8a41fcafdd3f73c9f8be95
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1659 (PresentX 1659)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14861 MB

Not tested

  • wave32-only GPUs (NVIDIA / Intel); gameplay past the menus

AI use

  • Antigravity (Gemini 4 Carbon) ran the build, test suite, and scripts/smoke.ps1 harness on this machine and formatted this report.

@Anon64

Anon64 commented Nov 24, 2026

Copy link
Copy Markdown

Regression runs for this PR's head 5a60d0d and for its base main f4ce27c, on a retail title (same title, 60 s each), made with scripts/smoke.ps1 (release, clean tree at each commit) and pasted unedited, for Regression run.

main:

xcl-smoke v1
commit: f4ce27ceb6d1b0576d0c659b713b674778bf1968
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1615 (PresentX 1615)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16472 MB

this PR:

xcl-smoke v1
commit: 5a60d0dad6be82337d8a41fcafdd3f73c9f8be95
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1641 (PresentX 1641)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16974 MB

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 581.80, wave32), Intel Core i9-14900KF, Windows 11 25H2 26200.9974, Rust 1.90.0

Not tested

  • the unit tests on this machine
  • xcl disasm output itself: a title run does not use it, so this is a regression check only

Report written with Claude Code (Claude Opus 5.5) from runs on this machine.

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @Anon64: both blocks are now in Regression run, credited.

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.

5 participants