Shaders: xcl disasm prints image operands, dmask, dim and flags #812

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

@⁠upipibi on GitHub · 2026-11-24 05:45 UTC · original
upipibi:disasm-mimg-operands → main · +124 −0 · 1 files · 1 commits · merged 2026-11-25 01:08 UTC

xcl disasm prints an image (MIMG) instruction with the widest registers its opcode can take and nothing else: image_load v[16:19], v[8:11], s[96:103] whatever DMASK, the dimension and the flags are, and the address registers of an NSA form are not listed. So a 1D load of one component and a 2D-array load of four read the same. The recompiler has all of this; only the printed line drops it. Same kind of gap as #664 and #790 / #791, in an encoding none of them covers; gh pr list --search for "mimg disasm", "dmask" and "MIMG" finds no PR for it.

Independent of #790 / #791 (other hunks of rdna2.rs; they merge cleanly in any order).

What is in it

  • crates/xcl/src/gpu/rdna2.rs: mimg_text, called first in format – the data registers DMASK selects (four for a gather, two at least for a compare-and-swap, halved by D16, one more with TFE), the address registers (a range, or the [v8, v9, …] list of an NSA form), resource, sampler, dmask: (when not 0), dim:SQ_RSRC_IMG_* and unorm glc slc dlc r128 a16 tfe lwe d16 in LLVM's order; a ray query prints a16 alone. mimg_address_dwords counts the address dwords as LLVM's getAddrSizeMIMGOp does, from the mnemonic's parts (_o / _b / _c, _cl / _l / mip, _d / _cd, _g16), the dimension and A16.
  • Tests in the same file: llvm_gfx10_image_text compares the whole line with LLVM's for all 265 image lines of tests/data/llvm-amdgpu (gfx10_mimg.txt, and the image_msaa_load / image_bvh* lines of gfx1030_new.txt; 105 instructions, 206 lines in NSA form); image_operands_and_modifiers has 7 words checked against llvm-mc 21.1.8 (-mcpu=gfx1030) for what the corpus lacks (slc, r128, all the flags at once) and a few more.

The text also goes into the // pc: … comment lines of the translated HLSL, so the HLSL of a program with image 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::tests::: 11 passed, 0 failed. With the tests on main's format (e50836b): 2 failed – llvm_gfx10_image_text "263 of 265 image lines differ from LLVM's", image_operands_and_modifiers.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on 2239a06: 706 passed, 0 failed, 41 ignored (xcl lib: 665 passed, 0 failed, 21 ignored).
  • SKIPPED GPU tests: 2, both no wave64: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.

Regression run

From Anon64's run (https://github.com/ivall/xcl/pull/812#issuecomment-7124221119), thanks:

main:

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

PR:

xcl-smoke v1
commit: 2239a061261939bd5b8a61c5a8ab4334b5d4c476
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1619 (PresentX 1619)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17154 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.
  • The console's own image instructions (image_load_by2, image_store_pck4, …) follow the same rules by their names; LLVM does not know them, so nothing was compared.
  • Encodings LLVM has no instruction for are printed by the same rules and differ from what llvm-mc shows: an atomic with more than two DMASK bits (llvm-mc: one register), an NSA form with more or fewer dwords than its addresses need.

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

**@⁠upipibi** on GitHub · 2026-11-24 05:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/812) `upipibi:disasm-mimg-operands` → `main` · +124 −0 · 1 files · 1 commits · merged 2026-11-25 01:08 UTC `xcl disasm` prints an image (MIMG) instruction with the widest registers its opcode can take and nothing else: `image_load v[16:19], v[8:11], s[96:103]` whatever DMASK, the dimension and the flags are, and the address registers of an NSA form are not listed. So a 1D load of one component and a 2D-array load of four read the same. The recompiler has all of this; only the printed line drops it. Same kind of gap as #664 and #790 / #791, in an encoding none of them covers; `gh pr list --search` for "mimg disasm", "dmask" and "MIMG" finds no PR for it. Independent of #790 / #791 (other hunks of `rdna2.rs`; they merge cleanly in any order). **What is in it** - `crates/xcl/src/gpu/rdna2.rs`: `mimg_text`, called first in `format` – the data registers DMASK selects (four for a gather, two at least for a compare-and-swap, halved by D16, one more with TFE), the address registers (a range, or the `[v8, v9, …]` list of an NSA form), resource, sampler, `dmask:` (when not 0), `dim:SQ_RSRC_IMG_*` and `unorm glc slc dlc r128 a16 tfe lwe d16` in LLVM's order; a ray query prints `a16` alone. `mimg_address_dwords` counts the address dwords as LLVM's `getAddrSizeMIMGOp` does, from the mnemonic's parts (`_o` / `_b` / `_c`, `_cl` / `_l` / `mip`, `_d` / `_cd`, `_g16`), the dimension and A16. - Tests in the same file: `llvm_gfx10_image_text` compares the whole line with LLVM's for all 265 image lines of `tests/data/llvm-amdgpu` (`gfx10_mimg.txt`, and the `image_msaa_load` / `image_bvh*` lines of `gfx1030_new.txt`; 105 instructions, 206 lines in NSA form); `image_operands_and_modifiers` has 7 words checked against `llvm-mc` 21.1.8 (`-mcpu=gfx1030`) for what the corpus lacks (`slc`, `r128`, all the flags at once) and a few more. The text also goes into the `// pc: …` comment lines of the translated HLSL, so the HLSL of a program with image 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::tests::`: 11 passed, 0 failed. With the tests on `main`'s `format` (e50836b): 2 failed – `llvm_gfx10_image_text` "263 of 265 image lines differ from LLVM's", `image_operands_and_modifiers`. - `cargo test --workspace --no-fail-fast -- --test-threads=4` on 2239a06: 706 passed, 0 failed, 41 ignored (xcl lib: 665 passed, 0 failed, 21 ignored). - SKIPPED GPU tests: 2, both `no wave64`: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. **Regression run** From Anon64's run (https://github.com/ivall/xcl/pull/812#issuecomment-7124221119), thanks: main: ``` xcl-smoke v1 commit: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a gpu: NVIDIA GeForce RTX 3060 title: retail-title seconds: 60 exit: 0x0 frames shown: 1648 (PresentX 1648) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16639 MB ``` PR: ``` xcl-smoke v1 commit: 2239a061261939bd5b8a61c5a8ab4334b5d4c476 gpu: NVIDIA GeForce RTX 3060 title: retail-title seconds: 60 exit: 0x0 frames shown: 1619 (PresentX 1619) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 17154 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. - The console's own image instructions (`image_load_by2`, `image_store_pck4`, …) follow the same rules by their names; LLVM does not know them, so nothing was compared. - Encodings LLVM has no instruction for are printed by the same rules and differ from what `llvm-mc` shows: an atomic with more than two DMASK bits (`llvm-mc`: one register), an NSA form with more or fewer dwords than its addresses need. **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](https://claude.com/claude-code)
An image (MIMG) instruction was printed with the widest registers its
opcode can take and nothing else: `image_load v[16:19], v[8:11],
s[96:103]` for every DMASK, dimension and flag, and an NSA form's
address registers were not listed at all. Now, as LLVM writes it: the
data registers DMASK selects (four for a gather, halved by D16, one
more with TFE), the address registers the opcode and the dimension take
(a list when NSA dwords name them), then dmask, dim and unorm / glc /
slc / dlc / r128 / a16 / tfe / lwe / d16. The recompiler reads all of
these; only the printed line dropped them (the gap of #664, in an
encoding that issue does not list).

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

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:33:24 +00:00
github manually merged commit 2239a06126 into gh-pr/812/base 2026-11-26 04:33:25 +00:00
Author
Owner

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

Test run of 2239a061261939bd5b8a61c5a8ab4334b5d4c476 on AMD RDNA4. I merged it onto current main beaa245 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: 715 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 674 passed, 0 failed, 21 ignored
  • 0 SKIPPED; image_operands_and_modifiers passes.

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.

**@⁠MesshM** on GitHub · 2026-11-24 06:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/812#issuecomment-7123597080) Test run of `2239a061261939bd5b8a61c5a8ab4334b5d4c476` on AMD RDNA4. I merged it onto current `main` `beaa245` 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: **715 passed, 0 failed, 41 ignored**, exit code 0; `xcl` lib tests 674 passed, 0 failed, 21 ignored - **0 `SKIPPED`**; `image_operands_and_modifiers` passes. **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.
Author
Owner

@⁠Anon64 on GitHub · 2026-11-24 06:43 UTC · original

Regression runs for this PR's head 2239a06 and for its base main e50836b, 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: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1648 (PresentX 1648)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16639 MB

this PR:

xcl-smoke v1
commit: 2239a061261939bd5b8a61c5a8ab4334b5d4c476
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1619 (PresentX 1619)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17154 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
  • whether the title reaches the changed code; this is a regression check only

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

**@⁠Anon64** on GitHub · 2026-11-24 06:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/812#issuecomment-7124221119) Regression runs for this PR's head `2239a06` and for its base `main` `e50836b`, 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: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a gpu: NVIDIA GeForce RTX 3060 title: retail-title seconds: 60 exit: 0x0 frames shown: 1648 (PresentX 1648) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16639 MB ``` this PR: ``` xcl-smoke v1 commit: 2239a061261939bd5b8a61c5a8ab4334b5d4c476 gpu: NVIDIA GeForce RTX 3060 title: retail-title seconds: 60 exit: 0x0 frames shown: 1619 (PresentX 1619) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 17154 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 - whether the title reaches the changed code; this is a regression check only Report written with Claude Code (Claude Opus 5.5) from runs on this machine.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-24 08:09 UTC · original

Linux / AMD RDNA3 datapoint.

Merged state: head 2239a06 onto main 1ec4c98, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 706 passed, 11 failed, 41 ignored. Failures = the known Wine-lane set from my #42 rows plus #718 trio members and a hit of gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes (new flake, see #718 addendum). xcl disasm image-operand tests green.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-24 08:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/812#issuecomment-7125798681) Linux / AMD RDNA3 datapoint. **Merged state:** head `2239a06` onto main `1ec4c98`, clean merge. **Full suite, `cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4`:** **706 passed, 11 failed, 41 ignored**. Failures = the known Wine-lane set from my #42 rows plus #718 trio members and a hit of `gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes` (new flake, see #718 addendum). xcl disasm image-operand tests green. **Not tested:** retail titles (none here), Windows, RDNA4. Counts only, no game data. **Machine:** RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross `x86_64-pc-windows-gnu`, `XCL_NETWORK=0`, release profile, `--test-threads=4`. My Linux rows: #42 / #718. AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
This discussion has been locked. Commenting is limited to contributors.
No description provided.