Skip to content

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

Draft
MiguelMachado-dev wants to merge 2 commits into
xcl-dev:mainfrom
MiguelMachado-dev:recomp/per-lane-mimg-tests
Draft

MiguelMachado-dev wants to merge 2 commits into
xcl-dev:mainfrom
MiguelMachado-dev:recomp/per-lane-mimg-tests

Conversation

@MiguelMachado-dev

@MiguelMachado-dev MiguelMachado-dev commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • 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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 Recompiler: image instructions name the registers they use #1797's change. I checked that on Recompiler: a per-lane form for the direct DXIL backend (XCL_PER_LANE) #1745's branch at 3ca3633, before it was merged.

Regression run

Not tested

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 xcl-dev#1745 passes exactly them
to xcl-dev#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 xcl-dev#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)
@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

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