Tests: image instructions in the per-lane lowering and on the GPU #1825

Open
github-bot wants to merge 2 commits from github-bot/gh-1825 into main AGit
Owner

@⁠MiguelMachado-dev on GitHub · 2026-11-24 21:28 UTC · original
MiguelMachado-dev:recomp/per-lane-mimg-tests → main · +428 −3 · 4 files · 2 commits · draft

Stacked on #1797; only the top commit (434f428) belongs here. The commit under it, c2b0c00, is #1797's 8ec49c0 cherry-picked onto main c4d37be with the same diff. Once #1797 is in main, this PR is rebased and only the tests remain.

These are tests for image instructions in the per-lane form (#1745), the MIMG follow-up listed on #1269. They need #1797: without its vgpr_uses change, the per-lane form refuses every image instruction with NSA addresses, and the three lower_dxil tests fail. Part of #1269.

What is in it

  • Tests: image instructions in the per-lane lowering and on the GPU (434f428). Tests only, in the files' #[cfg(test)] modules, +271/−1:
    • crates/xcl/src/gpu/recomp/lower.rs:
      • helpers: decode_bytes, mimg (an image instruction with NSA dwords) and image_program;
      • image_instructions_in_coalesced_runs_and_whole_quads: image instructions join a coalesced guarded run. An implicit-LOD IMAGE_SAMPLE stays out of the run, and a PS refuses it in a block that not every lane reaches.
    • crates/xcl/src/gpu/recomp/lower_dxil.rs:
      • image_instructions_pass_every_register_they_use (CPU): every IMAGE_* instruction, over DIM, A16, D16, DMASK, GLC and sequential or 11 scattered NSA addresses, gets through the per-lane compute lowering with no register missing from the bridge.
      • per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu:
        • It covers NSA and sequential loads, NSA samples, a D16 sample, a store in a coalesced guarded run, SAMPLE_L, resinfo, GATHER4_LZ, and GLC compare-swap and add.
        • The textures and every register the instructions use, on 32 lanes, equal the HLSL path's. The test also checks the expected values.
      • a_per_lane_bvh_with_nsa_addresses_runs_on_the_gpu: a BVH ray with NSA addresses gives the same memory with four memory windows, with one window, and on the HLSL path.

Tested

  • Setup:

    • NVIDIA GeForce RTX 5080, driver 621.24 (no wave64), Intel Core i7-14700KF
    • Windows 11 build 26300, rustc 1.97.1, DXC 1.8.2502.11, debug build
  • cargo build --workspace && cargo test --workspace -- --test-threads=4:

    • at 434f428: 965 passed, 0 failed, 43 ignored (lib: 916 / 0 / 23);
    • at main c4d37be: 959 passed, 0 failed, 43 ignored (lib: 910 / 0 / 23).
    • The difference is the six tests of the two commits: two in #1797 and four here.
  • By module at 434f428, 0 failed in each:

    Module Passed Ignored
    gpu::dxil:: 84 1
    gpu::recomp::lower:: 35 0
    gpu::recomp::lower_dxil:: 15 0
    gpu::recomp::lane_masks:: 10 0
    gpu::rdna2:: 11 0
  • SKIPPED GPU tests: 23 lines, the same on both runs, and none in the new tests.

    • 18 are "no wave64".
    • 3 are per-lane refusals of V_MUL_F16, V_PK_MUL_F16 and V_CVT_F16_F32, whose #1426 semantics differ from the console's.
    • 1 is heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
    • 1 is shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: it cannot disable the driver cache, which needs Windows Developer Mode.
  • The three lower_dxil tests fail without #1797's change. I checked that on #1745's branch at 3ca3633, before it was merged.

Regression run

  • None yet. The commit of this PR changes tests only, but in files under crates/xcl/src that pr_check.py counts as runtime, and until #1797 is merged the diff also has #1797's commit.
  • Once #1797 is in main and this PR is rebased, the diff is test-only. It can then take the test-only label after review, or a smoke pair.

Not tested

  • Wave64, AMD and heap windows (this adapter has none).
  • Image instructions in a per-lane VS or PS: the tests are compute and kernel programs. The VS / PS DXIL half is a separate follow-up.
  • A retail sweep of the per-lane form with #1797, and a smoke run.

AI use

  • Claude Code (Claude Opus 5.5, xhigh) wrote the tests and this description, and ran the tests above.
**@⁠MiguelMachado-dev** on GitHub · 2026-11-24 21:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/1825) `MiguelMachado-dev:recomp/per-lane-mimg-tests` → `main` · +428 −3 · 4 files · 2 commits · draft Stacked on #1797; only the top commit (`434f428`) belongs here. The commit under it, `c2b0c00`, is #1797's `8ec49c0` cherry-picked onto `main` `c4d37be` with the same diff. Once #1797 is in `main`, this PR is rebased and only the tests remain. These are tests for image instructions in the per-lane form (#1745), the MIMG follow-up listed on #1269. They need #1797: without its `vgpr_uses` change, the per-lane form refuses every image instruction with NSA addresses, and the three `lower_dxil` tests fail. Part of #1269. **What is in it** - `Tests: image instructions in the per-lane lowering and on the GPU` (`434f428`). Tests only, in the files' `#[cfg(test)]` modules, +271/−1: - `crates/xcl/src/gpu/recomp/lower.rs`: - helpers: `decode_bytes`, `mimg` (an image instruction with NSA dwords) and `image_program`; - `image_instructions_in_coalesced_runs_and_whole_quads`: image instructions join a coalesced guarded run. An implicit-LOD `IMAGE_SAMPLE` stays out of the run, and a PS refuses it in a block that not every lane reaches. - `crates/xcl/src/gpu/recomp/lower_dxil.rs`: - `image_instructions_pass_every_register_they_use` (CPU): every `IMAGE_*` instruction, over DIM, A16, D16, DMASK, GLC and sequential or 11 scattered NSA addresses, gets through the per-lane compute lowering with no register missing from the bridge. - `per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu`: - It covers NSA and sequential loads, NSA samples, a D16 sample, a store in a coalesced guarded run, `SAMPLE_L`, resinfo, `GATHER4_LZ`, and GLC compare-swap and add. - The textures and every register the instructions use, on 32 lanes, equal the HLSL path's. The test also checks the expected values. - `a_per_lane_bvh_with_nsa_addresses_runs_on_the_gpu`: a BVH ray with NSA addresses gives the same memory with four memory windows, with one window, and on the HLSL path. **Tested** - Setup: - NVIDIA GeForce RTX 5080, driver 621.24 (no wave64), Intel Core i7-14700KF - Windows 11 build 26300, rustc 1.97.1, DXC 1.8.2502.11, debug build - `cargo build --workspace && cargo test --workspace -- --test-threads=4`: - at `434f428`: 965 passed, 0 failed, 43 ignored (lib: 916 / 0 / 23); - at `main` `c4d37be`: 959 passed, 0 failed, 43 ignored (lib: 910 / 0 / 23). - The difference is the six tests of the two commits: two in #1797 and four here. - By module at `434f428`, 0 failed in each: | Module | Passed | Ignored | |---|---|---| | `gpu::dxil::` | 84 | 1 | | `gpu::recomp::lower::` | 35 | 0 | | `gpu::recomp::lower_dxil::` | 15 | 0 | | `gpu::recomp::lane_masks::` | 10 | 0 | | `gpu::rdna2::` | 11 | 0 | - SKIPPED GPU tests: 23 lines, the same on both runs, and none in the new tests. - 18 are "no wave64". - 3 are per-lane refusals of `V_MUL_F16`, `V_PK_MUL_F16` and `V_CVT_F16_F32`, whose #1426 semantics differ from the console's. - 1 is `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - 1 is `shaders::tests::pso_measurement_compiles_an_exact_synthetic_record`: it cannot disable the driver cache, which needs Windows Developer Mode. - The three `lower_dxil` tests fail without #1797's change. I checked that on #1745's branch at `3ca3633`, before it was merged. **Regression run** - None yet. The commit of this PR changes tests only, but in files under `crates/xcl/src` that `pr_check.py` counts as runtime, and until #1797 is merged the diff also has #1797's commit. - Once #1797 is in `main` and this PR is rebased, the diff is test-only. It can then take the `test-only` label after review, or a smoke pair. **Not tested** - Wave64, AMD and heap windows (this adapter has none). - Image instructions in a per-lane VS or PS: the tests are compute and kernel programs. The VS / PS DXIL half is a separate follow-up. - A retail sweep of the per-lane form with #1797, and a smoke run. **AI use** - Claude Code (Claude Opus 5.5, xhigh) wrote the tests and this description, and ran the tests above.
`vgpr_uses` took an image instruction's registers from the operand tables,
which give the largest case: a 3-D address with every modifier and four data
registers. It missed the addresses in the NSA dwords (VADDRA, VADDRB, ...) and
a compare-swap's compare value (VDATA + 1), took a G16 sample's address as
shorter than the translators read it, took an atomic's data as written only
(and written without GLC too), and claimed data registers that DMASK and D16
leave alone.

Its callers act on those registers: the direct DXIL VS sets up the initial
VGPRs it lists (vertex and instance id, fetched attributes), the HLSL path
bounds its movrel switches with them, `xcl shaders` reports the inputs a
program reads from them, and the per-lane form of #1745 passes exactly them
to #1426's lowering, which refuses an instruction that reads another: every
image instruction with NSA addresses.

`vgpr_uses` now counts them as `recomp::emit` and `dxil::lower_image` read
them: the address dwords from the opcode's modifiers, DIM and A16, at VADDR
and the registers after it or VADDR then the NSA bytes; the data from DMASK,
D16, TFE/LWE, GLC and the opcode. `dxil::lower_image` read VDATA + 1 for every
atomic; it reads it for a compare-swap only now.

In #1745's per-lane form (at 3ca3633), a sweep of every IMAGE_* instruction
over DIM, A16, D16, DMASK, GLC and sequential or scattered NSA addresses
through the per-lane compute lowering: 6562 of 28032 cases refused for a
register not passed before (6130 NSA, 288 compare-swap, 144 G16), none after,
and no case that lowered before refused.

Assisted-by: Claude Code (Claude Opus 5.5, xhigh)
Every IMAGE_* instruction lowers per lane with each register it uses passed,
with sequential and NSA addresses, A16, D16, DMASK and GLC. On the GPU, a
program with an NSA load and samples, a D16 sample, a store in a coalesced
guarded run, a sample at an LOD, resinfo, a gather, GLC compare-swap and add
and a load at sequential addresses agrees with the HLSL path (textures and
every register the instructions use) and gives the expected values; a BVH ray
with NSA addresses under four memory windows gives the memory of one window
and of the HLSL path. An implicit-LOD sample stays out of coalesced runs, and
a PS refuses it in a block not every lane reaches.

Assisted-by: Claude Code (Claude Opus 5.5, xhigh)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:06:29 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 21:37 UTC · original

Same results on Ampere: RTX 3070 8 GB (32-lane waves, no wave64), driver 616.56, Windows 11, debug, 434f428 on main c4d37be:

  • The four new tests pass (image_instructions_in_coalesced_runs_and_whole_quads, image_instructions_pass_every_register_they_use, per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu, a_per_lane_bvh_with_nsa_addresses_runs_on_the_gpu).
  • gpu::dxil:: 84 passed, 1 ignored; gpu::recomp::lower:: 35 passed; gpu::recomp::lower_dxil:: 15 passed; 0 failed in each (--test-threads=4).

The whole workspace was not run.

AI-assisted (Claude Code). Synthetic tests only.

**@⁠upipibi** on GitHub · 2026-11-24 21:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/1825#issuecomment-7145173406) Same results on Ampere: RTX 3070 8 GB (32-lane waves, no wave64), driver 616.56, Windows 11, debug, `434f428` on `main` `c4d37be`: - The four new tests pass (`image_instructions_in_coalesced_runs_and_whole_quads`, `image_instructions_pass_every_register_they_use`, `per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu`, `a_per_lane_bvh_with_nsa_addresses_runs_on_the_gpu`). - `gpu::dxil::` 84 passed, 1 ignored; `gpu::recomp::lower::` 35 passed; `gpu::recomp::lower_dxil::` 15 passed; 0 failed in each (`--test-threads=4`). The whole workspace was not run. AI-assisted (Claude Code). Synthetic tests only.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 00:50 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 00:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/1825#issuecomment-7148945864) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠Chrysana on GitHub · 2026-11-25 19:31 UTC · original

AMD run of 434f428, for "Wave64, AMD and heap windows" under Not tested. The four new tests pass on an RX 9070 XT (RDNA4) and on an RDNA2 iGPU, and the suite matches your RTX 5080 counts exactly: 965 / 0 / 43 on this head, 959 / 0 / 43 on c4d37be. One limit on what this covers: both GPU tests run their programs as wave32 (kernel(&insts, false), wave64: false), and image_program is wave32 code (S_AND_SAVEEXEC_B32). So on wave64 hardware they still run 32 lanes, and wave64 stays untested by these tests on any GPU.

Setup: AMD Radeon RX 9070 XT 16 GB (RDNA4, wave64), driver 32.0.32015.2008; Ryzen 7 9800X3D, whose Radeon iGPU is RDNA2 (XCL_ADAPTER=1); Windows 11 26200.9974, rustc 1.100.0 MSVC, debug. Head as pushed (434f428, with #1797's commit under it), and its base c4d37be, each in its own checkout and target folder.

Full suite (RX 9070 XT, cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4):

passed failed ignored lib
434f428 965 0 43 916 / 0 / 23
c4d37be 959 0 43 910 / 0 / 23
  • SKIPPED: 8 lines, the same on both runs, none in the new tests. There's no "no wave64" here, so the wave64 halves of the existing GPU tests that your adapter skips (18 lines) ran on this card. 6 skips are the per-lane V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 refusals (at wave32 and at wave64). The other 2 are heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows here either) and pso_measurement_compiles_an_exact_synthetic_record (no Developer Mode).

The new tests and your module table, on each GPU (cargo test -p xcl --lib -- --test-threads=4 <filter>):

RX 9070 XT Radeon iGPU (RDNA2)
image_instructions_in_coalesced_runs_and_whole_quads ok ok
image_instructions_pass_every_register_they_use ok ok
per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu ok ok
a_per_lane_bvh_with_nsa_addresses_runs_on_the_gpu ok ok
gpu::dxil:: 84 passed, 1 ignored 84 passed, 1 ignored
gpu::recomp::lower:: 35 passed 35 passed
gpu::recomp::lower_dxil:: 15 passed (6 SKIPPED, the f16/f32 refusals) 15 passed (same 6)
gpu::recomp::lane_masks:: 10 passed 10 passed
gpu::rdna2:: 11 passed 11 passed

0 failed everywhere. So AMD's drivers give the HLSL path's registers and textures for the NSA and sequential loads, the samples (including D16 and SAMPLE_L), resinfo, GATHER4_LZ, the GLC compare-swap and add, and the BVH ray with four memory windows and with one.

On wave64: making the GPU test cover it would take a wave64 form of image_program (S_AND_SAVEEXEC_B64, a 64-bit compare mask, EXEC high set) and 64-lane texture layouts (the 8×4 compare-swap and add targets hold 32 texels). That's more than a flag, so I didn't make a local variant. If you add one, I can run it on this card.

Not tested

  • Wave64 image instructions in the per-lane form (see above).
  • Heap windows (none on this card either).
  • This PR merged onto current main: it conflicts in crates/xcl/src/gpu/dxil/lower_image.rs, so these runs are on the head as pushed.

AI use

  • Claude Code (Claude Opus 5.5) built both trees, ran the tests on both GPUs, read the tests and drafted this comment. I checked it before posting.
**@⁠Chrysana** on GitHub · 2026-11-25 19:31 UTC · [original](https://github.com/xcl-dev/xcl/pull/1825#issuecomment-7172404663) AMD run of `434f428`, for "Wave64, AMD and heap windows" under **Not tested**. **The four new tests pass on an RX 9070 XT (RDNA4) and on an RDNA2 iGPU, and the suite matches your RTX 5080 counts exactly: 965 / 0 / 43 on this head, 959 / 0 / 43 on `c4d37be`.** One limit on what this covers: both GPU tests run their programs as wave32 (`kernel(&insts, false)`, `wave64: false`), and `image_program` is wave32 code (`S_AND_SAVEEXEC_B32`). So on wave64 hardware they still run 32 lanes, and wave64 stays untested by these tests on any GPU. **Setup:** AMD Radeon RX 9070 XT 16 GB (RDNA4, wave64), driver 32.0.32015.2008; Ryzen 7 9800X3D, whose Radeon iGPU is RDNA2 (`XCL_ADAPTER=1`); Windows 11 26200.9974, rustc 1.100.0 MSVC, debug. Head as pushed (`434f428`, with #1797's commit under it), and its base `c4d37be`, each in its own checkout and target folder. **Full suite** (RX 9070 XT, `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`): | | passed | failed | ignored | lib | |---|---|---|---|---| | `434f428` | 965 | 0 | 43 | 916 / 0 / 23 | | `c4d37be` | 959 | 0 | 43 | 910 / 0 / 23 | - SKIPPED: 8 lines, the same on both runs, none in the new tests. There's no "no wave64" here, so the wave64 halves of the existing GPU tests that your adapter skips (18 lines) ran on this card. 6 skips are the per-lane `V_MUL_F16` / `V_PK_MUL_F16` / `V_CVT_F16_F32` refusals (at wave32 and at wave64). The other 2 are `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows here either) and `pso_measurement_compiles_an_exact_synthetic_record` (no Developer Mode). **The new tests and your module table, on each GPU** (`cargo test -p xcl --lib -- --test-threads=4 <filter>`): | | RX 9070 XT | Radeon iGPU (RDNA2) | |---|---|---| | `image_instructions_in_coalesced_runs_and_whole_quads` | ok | ok | | `image_instructions_pass_every_register_they_use` | ok | ok | | `per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu` | ok | ok | | `a_per_lane_bvh_with_nsa_addresses_runs_on_the_gpu` | ok | ok | | `gpu::dxil::` | 84 passed, 1 ignored | 84 passed, 1 ignored | | `gpu::recomp::lower::` | 35 passed | 35 passed | | `gpu::recomp::lower_dxil::` | 15 passed (6 SKIPPED, the f16/f32 refusals) | 15 passed (same 6) | | `gpu::recomp::lane_masks::` | 10 passed | 10 passed | | `gpu::rdna2::` | 11 passed | 11 passed | 0 failed everywhere. So AMD's drivers give the HLSL path's registers and textures for the NSA and sequential loads, the samples (including D16 and `SAMPLE_L`), resinfo, `GATHER4_LZ`, the GLC compare-swap and add, and the BVH ray with four memory windows and with one. **On wave64:** making the GPU test cover it would take a wave64 form of `image_program` (`S_AND_SAVEEXEC_B64`, a 64-bit compare mask, EXEC high set) and 64-lane texture layouts (the 8×4 compare-swap and add targets hold 32 texels). That's more than a flag, so I didn't make a local variant. If you add one, I can run it on this card. **Not tested** - Wave64 image instructions in the per-lane form (see above). - Heap windows (none on this card either). - This PR merged onto current `main`: it conflicts in `crates/xcl/src/gpu/dxil/lower_image.rs`, so these runs are on the head as pushed. **AI use** - Claude Code (Claude Opus 5.5) built both trees, ran the tests on both GPUs, read the tests and drafted this comment. I checked it before posting.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/gpu/dxil/lower_image.rs
  • crates/xcl/src/gpu/recomp/lower_dxil.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1825/head:github-bot/gh-1825'
git switch 'github-bot/gh-1825'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1825'
git switch 'github-bot/gh-1825'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1825'
git switch 'github-bot/gh-1825'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1825'
git switch 'main'
git merge --squash 'github-bot/gh-1825'
git switch 'main'
git merge --ff-only 'github-bot/gh-1825'
git switch 'main'
git merge 'github-bot/gh-1825'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.