Skip to content

Recompiler: a per-lane form for the direct DXIL backend (XCL_PER_LANE) - #1745

Merged
raylitebull merged 51 commits into
xcl-dev:mainfrom
gefydev:direct-on-1426
Nov 24, 2026
Merged

raylitebull merged 51 commits into
xcl-dev:mainfrom
gefydev:direct-on-1426

Conversation

@gefydev

@gefydev gefydev commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

A per-lane form for the direct DXIL backend (#1426): where a lane-mask analysis proves EXEC, console code is lowered without EXEC guards. Each lane carries its own bit of every mask, mask branches become per-lane branches, and guards stay only where EXEC is not proven. Instructions it has no lowering of go through #1426's Lw::inst_guarded with the analysis's guard. It is opt-in: with XCL_DIRECT_DXIL=1 XCL_PER_LANE=1, a compute program tries the per-lane form, then #1426's per-instruction form, then the HLSL path. Without XCL_PER_LANE nothing changes. Part of #1269.

It is one PR at the maintainer's request: the size rule is waived for this feature (asked of the maintainer by @gefydev; the plan is on #1269, the waiver itself was not posted on GitHub). About 2 600 of the 7 460 added lines are tests.

Result so far, for the maintainer to judge. Whole-pack sweep of a retail title (xcl shaders --direct --lanes --sample 0 --max-bytes 0 --split 0 --windows 4 --timeout 120): the per-lane form translates 316 of 2 689 compute programs (with the stricter rules from the reviews below; 321 before). On those, its DXIL is 4 020 436 B against 3 988 440 B for #1426's per-instruction form (+0.8 %): no size gain. After bmjask's cleanups, #1426 emits few guards on these programs. Measurements on #1269 point the same way: removing every EXEC select takes about 9 % off driver time on one RTX 3080 program, against 85 % for the window switch, which #1693 now addresses. The large programs, where a gain would matter, are still refused. The main refusals are structural: a branch on whether any lane of a mask is set, with lanes in EXEC that lack the bit (the first refusal of 1 771 programs; the console decides those for the whole wave), and stale values (154). Driver time, measured by Raghav314 on an RTX 4090 (#1269), on the 310 programs that build in all four forms: per-lane 10.0 s, #1426 per-instruction 10.5 s, HLSL 14.1 s driver + 21.9 s DXC, and HLSL with heap windows 10.8 s + 17.2 s. Per-lane against #1426 is a median ratio of 0.98, so again no real gain on what it covers. So this PR is the infrastructure plus measurements. It does not deliver a speedup today.

What is in it (51 commits; authors kept)

  • gpu/recomp/lane_masks.rs: the lane-mask analysis (BDD over lane / SCC / opaque atoms, worklist dataflow, loop heads, irreducible flow refused). The launch EXEC can be an atom for VS / PS (teidenzero).
  • gpu/recomp/ssa.rs: on-the-fly SSA (Braun et al.), with a number view and a lane-bit view per SGPR.
  • gpu/recomp/lower.rs, lower/wave.rs: the lowering behind an Ir trait, with a CPU interpreter for tests. It covers SALU / VALU / memory, mask ops, s_cselect / s_wqm / v_cmpx, far jumps, and cross-lane ops (Sr-0w). It refuses stale values written where some lanes are elsewhere. Also guard coalescing (MiguelMachado-dev) and VS / PS stages (teidenzero). The bridge to gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 refuses an instruction when gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 would read a register it was not passed.
  • gpu/recomp/lower_dxil.rs: the Ir on gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's Lw. It handles head / tail blocks, so gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 can make blocks inside an instruction, plus several and heap memory windows, the split wave64 form (upipibi) and batched trivial-phi replacement (Itsmetibo).
  • gpu/dxil/kernel.rs: Lw::new / Lw::finish out of the kernel translator, with no change to gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's output (Sr-0w).
  • gpu/recomp/pso.rs: the runtime hookup behind XCL_PER_LANE=1, with its own translated-cache identity.
  • gpu/recomp/dxil/assemble.rs: IR text to a signed container, as a test oracle (Sr-0w).
  • shaders.rs: xcl shaders --direct --lanes (coverage and size against gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426), plus the per-lane refusal survey (Kalmarv).
  • Tests: f32 / f64 / integer / f16 programs on the HLSL path and per lane (vladbondarenko97), GPU comparisons of the per-lane DXIL against the CPU lowering and the HLSL path, and split-form and four-window runs.
  • Bugs found on the way, fixed here with tests:
    • the f32 reference's signed zeros on AMD (Diskuss);
    • an overflow for s0 in the mask-pair check (nobodyttk);
    • split compute through the runtime asked for WaveSize(64) (MiguelMachado-dev);
    • the kernel entry never set up Lw's lanes (vladbondarenko97);
    • a copied value in a partial block escaped the stale check (MiguelMachado-dev).
    • from reviews of this PR: whole-wave branches and selects on a mask some lanes in EXEC lack, and rounding modes the per-lane form dropped (Kalmarv); such an SCC carried around a loop (thehollowedone); per-lane cache entries outliving source changes (Pipodi).
  • gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics that differ from the console (v_cvt_f16_f32, v_mul_f16, v_pk_mul_f16 round toward zero) stay on the fallback (DIFFERS_ON_1426); itsSio is fixing them on main.

Tested

  • NVIDIA GTX 1650 (wave32 only, so the split wave64 tests run for real), driver 621.24, Windows 11 Pro 26300, Rust 1.100.0, debug.
  • cargo test --workspace -- --test-threads=4 on the head (bfb8133, on main 4178e88): 955 passed, 0 failed, 42 ignored. With XCL_ADAPTER=warp (the CI adapter, no sized waves) the lib gives 876 passed, 0 failed, 22 ignored: the per-lane GPU tests skip there.
  • SKIPPED (22): 18 "no wave64" (this GPU), 1 "no heap windows", and 3 per-lane halves refused on purpose (V_CVT_F16_F32, V_MUL_F16, V_PK_MUL_F16, see above).
  • Whole-pack sweep (release, on d5fd85d, before the rebase onto main and the last four commits): numbers as in the result paragraph; 577 s.

Regression run
main:

xcl-smoke v1
commit: 6c89285b8b529bde59cd17a26b911c39912fb677
gpu: NVIDIA GeForce GTX 1650
title: xcl-title
seconds: 60
exit: 0x0
frames shown: 889 (PresentX 890)
presents per 2 s (last 3): 2 0 12
device removals: 0
crashes: 0
peak commit: 15518 MB

This PR's head:

xcl-smoke v1
commit: bfb8133d36df38c3de381f9d99203568b32aa765
gpu: NVIDIA GeForce GTX 1650
title: xcl-title
seconds: 60
exit: 0x0
frames shown: 915 (PresentX 916)
presents per 2 s (last 3): 0 0 9
device removals: 0
crashes: 0
peak commit: 11638 MB

Both with XCL_PER_LANE off (the default), so they check that nothing changes. The machine was short of memory: runs of earlier head builds gave 508 to 931 frames, so the frame counts vary a lot run to run here.

Not tested

AI use

@Raghav314

Copy link
Copy Markdown

DXC and cold driver times for the per-lane form against #1426 and the HLSL path, NVIDIA Windows (as asked on #1269, comment). Counts and timings only.

Setup: RTX 4090 24 GB, driver 617.14, Windows 11, DXC 1.8.2502.11, release. direct-on-1426 3ca3633 + @Itsmetibo's 4c3fe1e (now 1c9477a here), retail 1.0.2.1 pack, split wave64, 4 windows, as the runtime does on a 32-lane GPU. Each pipeline made one at a time, no concurrency, no XCL cache, the driver's shader cache off for the process (ID3D12Device9::ShaderCacheControl(IMPLICIT_DRIVER_MANAGED, DISABLE)). Two full runs agree within 1 %.

Programs: the per-lane form takes 311 of 2 689 compute programs in the split form. 310 built in all four forms, 0 failures (first row dropped as driver warm-up). Median 212 B of console code, largest 2.6 KB.

form DXIL DXC driver total
per-lane 3 168 KB – 10.0 s 10.5 s
#1426 per-instruction 3 187 KB – 10.5 s 10.9 s
HLSL, 4 windows 3 881 KB 21.9 s 14.1 s 36.1 s
HLSL, heap windows 3 455 KB 17.2 s 10.8 s 28.0 s
  • Per-lane vs gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426: driver time per program, median ratio 0.98 (p10 0.85, p90 1.10); −5 % in total. No real gain on the programs it covers.
  • Both direct forms vs the HLSL path: 3.4× less total time, mostly DXC (61 % of the HLSL path's time here); the driver is also ~27 % faster on the direct DXIL.
  • Not covered: the large programs, which the per-lane form refuses.

Harness: Raghav314/xcl shaders/time-forms, one commit c17ed53 on this PR's head cf29f8a (shaders.rs +155, pso.rs +6): xcl shaders <pack> --time-forms [--split 1] [--windows 4] [--timeout 120] [--limit N] [--warm] [--out file.csv]. One CSV row per program, record index only. Needs Windows developer mode for the cache switch; --warm skips it. Re-checked on c17ed53: builds, and --limit 3 gives cold times (9–41 ms) against 0.5–2 ms with --warm.

AI use: Claude Code (Claude Opus 5.5) wrote the harness, ran the measurements and drafted this.

@Kalmarv

Kalmarv commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

@gefydev: the stale-value work is ready as a follow-up on this PR's head, not for #1745 itself. It is four commits on 43cb32c in Kalmarv/xcl per-lane-stale (head f5bfab2):

  • 01715c8 the per-lane survey drops VCC after a refused compare: note_inst missed VOPC / VOP2 writes of VCC, which have no field, so a refused v_cmp_*_f32 left an older VCC that later showed up as a stale value.
  • 909d33b a write every reading lane passed is not a stale value: your rule from [OFFICIAL] Looking for PRs with shaders optimization #1269. W dominates R, and every loop that contains W also contains R. Summary exports the dominators and the loop bodies. Same-block reads stay with def_owner / use_owner.
  • 595dd34 a join takes the scalar value an arm some lanes skipped wrote (case A, numbers and SCC). At a join every lane reaches, with a single stale write: a ballot of a per-region "ran it" flag, then a read from the first lane that ran it. Each lane keeps its own value when no lane ran it. A write in a loop that lanes leave one by one is still refused. Only registers a later read can see are repaired, because Module::optimize keeps wave ops. A value written in two such blocks is refused by its own name.
  • f5bfab2 a join takes a compare an arm some lanes skipped made (case A, VOPC masks): ran && bit. A mask a scalar instruction wrote is refused by its own name.

Recount: xcl shaders <pack> --direct --lanes --sample 0 --max-bytes 0 --split 0 --windows 4, the first refusal of each of 2689 compute programs, no timeouts in any run:

tree per-lane ok first refusal: stale value
43cb32c 321 265
+ 01715c8, 909d33b 435 151
+ 595dd34, f5bfab2 435 140 generic, 11 "written in more than one block"

The stale rule takes 114 more programs (321 to 435). Case A takes none in this sweep; it only renames 11 of the 151. Whatever the remaining stale values hit, it is not the single-write join that case A repairs. I'm classifying the 140 next (loops that lanes leave one by one, reads inside a region, or joins it skips) to decide what comes next. In a 60 s game run on 43cb32c, the stale value was the top fallback reason too: 17 of 73.

Tested on an RTX 5070 Ti (wave32 only) under Windows 11, release builds:

  • the recomp CPU tests (lower, lane_masks, lower_dxil), run by exact name: 43 passed at f5bfab2, 42 at 595dd34. The new tests fail with the join repair switched off.
  • the 14 GPU tests of the same modules, run through the GPU queue at f5bfab2: 14 passed, 0 failed. They compare against the HLSL path, as DXIL, and in the split form. Five report SKIPPED ... no wave64 (one of them only in part), and six skip only the validation step (DXC 1.7 < 1.8), so the split-form runs still happen.

The quadratic replace_all_uses is Itsmetibo's 4c3fe1e (1c9477a here); we dropped our own fix for it.

Not tested: the whole workspace suite, AMD, native wave64, a game run with these commits.

AI use: Claude Code (Claude Opus 5.5) wrote the commits, ran the tests and the recount, and wrote this note.

@gefydev

gefydev commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

A fact about the follow-up, not a change to this PR. @Kalmarv has the stale-value work ready as a follow-up on top of this PR's head: four commits on 43cb32c, branch Kalmarv/xcl per-lane-stale (head f5bfab2e). In his recount (xcl shaders <pack> --direct --lanes --sample 0 --max-bytes 0 --split 0 --windows 4, the first refusal of each of the 2 689 compute programs), the dominance rule for stale values (a write that dominates its read, with every loop containing the write also containing the read) takes the per-lane form from 321 to 435 programs; the repair of a value written in a region some lanes skip (case A) takes none more in that sweep. It is not part of #1745 and would go on top of it, or as a stacked PR, as the maintainer prefers. Thank you, Kalmarv.

AI use: Claude Code (Claude Opus 5.5) wrote this comment for @gefydev.

@alexmircea1299

Copy link
Copy Markdown

Test report on NVIDIA GeForce RTX 5070 (12 GB)

  • PR / Commit: Recompiler: a per-lane form for the direct DXIL backend (XCL_PER_LANE) #1745 (43cb32c)
  • Hardware: AMD Ryzen 5 9600X, NVIDIA GeForce RTX 5070 (12 GB VRAM, driver 621.35), 32 GB DDR5 6000MT/s
  • Environment: Windows 11 (build 26300), rustc 1.100.0 (0ef1bc386 2026-11-09), Windows SDK 10.0.26100.0 (debug build)
  • Command: .\scripts\test.ps1 (cargo test --workspace -- --test-threads=4)
  • Results:
    • xcl --lib: 876 passed; 0 failed; 22 ignored (14.29s)
    • Integration tests: 8 passed; 0 failed; 12 ignored (1 + 1 + 6)
    • Total workspace: 884 passed; 0 failed; 34 ignored
  • GPU tests skipped on this adapter:
    • 7 (no wave64)
    • 1 (no heap windows)
    • 1 (f32 rounding, wave64: no wave64)
    • 1 (integer arithmetic, wave64: no wave64)
    • 1 (f64, wave64: no wave64)
    • 1 (integer carries, wave64: no wave64)
    • 1 (f32 three-source, wave64: no wave64)
    • 1 (f32 transcendentals, wave64: no wave64)
    • 1 (f32 conversions, wave64: no wave64)
    • 1 (f16 arithmetic, wave64: no wave64)
    • 1 (f16 packed, wave64: no wave64)
    • 1 (f32 compares, wave64: no wave64)
    • 1 (f32 arithmetic, wave64: no wave64)
    • 1 (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)))
    • 1 (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)))
    • 1 (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)))
  • Not tested: Retail title (smoke.ps1), release build, AMD / native wave64 GPUs.
  • AI use: Google Gemini assisted with running the commands and drafting this report from my real local test run.

@HKEY-Funk-Machine

Copy link
Copy Markdown

@gefydev native wave64 and title results on AMD RDNA4 for 43cb32c: the suite passes, including every wave64 half. In the title, the per-lane form took 90 of 300 compute programs with no failures, but they are all small, and there is no size or driver-time gain on them. That's the same as your pack numbers, now measured in the AMD driver.

Tested

  • AMD Radeon RX 9070 (RDNA4, native wave64), driver 32.0.32015.7029, Ryzen 9 7945HX3D, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0, DXC 1.9.2602.17, release.
  • Clean 43cb32c: cargo test --release --workspace --no-fail-fast -- --test-threads=4: 925 passed, 0 failed, 42 ignored. gpu::dxil + recomp::lower: 125 passed, 0 failed, 1 ignored. No no wave64 skips: f32_programs_on_the_gpu (wave32 and wave64), the_split_form_agrees_with_the_wave64_lowering_on_the_gpu and the_runtime_path_takes_the_split_form ran and passed. SKIPPED: f16_programs_on_the_gpu ×4 (V_MUL_F16 / V_PK_MUL_F16 refused), f32_programs_on_the_gpu ×2 (V_CVT_F16_F32 refused), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • Current head cf29f8a (test-only on top): gpu::dxil + recomp::lower again 125 passed, 0 failed, 1 ignored, the same 6 SKIPPED. The new 32-lane skip doesn't trigger on this card. The title runs below are on 43cb32c; cf29f8a changes only tests.

Title A/B (retail title; 43cb32c + #751, plus two local-only changes: skip InitializeApiImplEx2 in xgameruntime/api.rs, which hangs here, and a log line before and after each compute CreateComputePipelineState):

  • A: XCL_DIRECT_DXIL=1. B: XCL_DIRECT_DXIL=1 XCL_PER_LANE=1. Both with XCL_TRANSLATED_CACHE=0 XCL_PSO_DISK_CACHE=0 XCL_NETWORK=0, and each run's xcl.exe copied under a new name, so the AMD driver's cache was cold for both. A pressed on the title screen.
  • I stopped both runs about 5 minutes in, once cs 56c0cd3b82a00c6e (ActivateProbes, 15 042 740 B of per-instruction DXIL, refused by the per-lane form) had been in the driver for over a minute with process memory past 90 GB. In earlier runs on this card it ran out of memory at ~105 GB (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 (comment)).
  • Programs were matched by console hash: a program whose DXIL differs between A and B went per-lane in B.
compute builds, A / B / built in both 300 / 302 / 300, 0 failed
per-lane in B 90 of 300 (the other 210: same DXIL as A)
DXIL of those 90 1.294 MB → 1.299 MB (+0.4 %)
driver time of those 90 6.4 s → 6.7 s (+4.7 %). Of the 38 that took ≥ 50 ms in A, 19 were faster in B
control: the 210 with the same DXIL, cold in both 598.8 s → 529.3 s (−11.6 %). So run-to-run driver noise is about ±10 %, and the +4.7 % is within it
largest per-lane program 130 544 B, 1.14 s in A → 129 532 B, 1.32 s in B
device removal, 0x8007000E, crash none in either run (both stopped by me)

Top per-lane refusals in B (count of programs): "a value written while some lanes were elsewhere, read after they met again" 55, IMAGE_LOAD (reads a register the per-lane form did not pass) 31, IMAGE_SAMPLE_LZ 19, "a mask read as a number where some lanes are elsewhere" 12, IMAGE_STORE 11, DS_ADD_U32 10, BUFFER_ATOMIC_ADD 8, IMAGE_LOAD_MIP 6.

So on this card the per-lane form is correct on what it takes, and neutral on cost. The programs the world load waits on (ActivateProbes and the other ~1 MB+ programs) all stay on the per-instruction form, mostly for the stale-value refusal and the image / LDS register plumbing.

Not tested

  • The title past ActivateProbes (it runs out of memory on the direct path here), more than one run per form, heap windows (XCL_HEAP_WINDOWS=1), split wave64 in the title, and output correctness beyond "no failure" (no frame comparison).

AI use: Claude Code (Claude Opus 5.5) ran the tests and the two runs, matched the programs with a script and wrote this comment.

@gefydev

gefydev commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thank you both for the test reports on this PR.

  • @alexmircea1299: 43cb32c on an RTX 5070 gives 876 passed, 0 failed in the lib, with the wave64 halves and the three per-lane refusals reported as SKIPPED. That is a clean second NVIDIA card.
  • @HKEY-Funk-Machine: the native wave64 run on the RX 9070 (925 passed, 0 failed, no no wave64 skips) and the title A/B are the first AMD driver-side measurement of the per-lane form. On the 90 of 300 programs the per-lane form takes, it is correct and neutral on cost (DXIL +0.4 %, driver time +4.7 %, within the noise you measured), and the programs the world load waits on stay on gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's form. That agrees with the numbers in the description.

AI use: Claude Code (Claude Opus 5.5) wrote this comment for @gefydev.

@teidenzero

Copy link
Copy Markdown
Contributor

Test report for cf29f8a on Windows 10 (where SM 6.6 comes from the Agility SDK), NVIDIA RTX 4090.

Tested

  • NVIDIA GeForce RTX 4090 24 GB (Ada, 32-lane waves, so the split wave64 tests run for real), driver 621.24 (32.0.16.2124); AMD Ryzen 7 3700X; Windows 10 Pro 22H2 build 19045.6466 with the D3D12 Agility SDK 1.620.2 (the inbox runtime stops at SM 6.5); Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug; DXC 1.8.2502.11 from the Windows SDK 10.0.26100.0, without dxil.dll.
  • .\scripts\test.ps1 at cf29f8a: 925 passed, 0 failed, 42 ignored over the workspace (lib: 876 passed, 0 failed, 22 ignored), the same totals as the GTX 1650 run in the description.
  • SKIPPED (23): 18 "no wave64" (this GPU), 1 "no heap windows", 1 "no dxil.dll" (the IR-assembly test; the SDK's DXC ships without it), and the 3 per-lane halves refused on purpose (V_CVT_F16_F32, V_MUL_F16, V_PK_MUL_F16).

Not tested

  • Native wave64 (no AMD GPU here), a release build, a title (none here, so no smoke run, with XCL_PER_LANE off or on).

The VS / PS adapter half, which the description lists as missing: 43d5851 from #1269 applies onto cf29f8a (one trivial conflict: the new replaced field next to its graphics field) as teidenzero/xcl vsps-dxil-on-1745 13dd18b. There the workspace gives 926 passed, 0 failed, 42 ignored on this machine, the one more being its draw test, which passes. It waits for the maintainer's call on this PR, as you said.

AI use: Claude Code (Claude Opus 5.5) ran the tests, rebased the commit and drafted this report.

@gefydev

gefydev commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@teidenzero thank you: the report on cf29f8a (925 passed, 0 failed, 42 ignored on an RTX 4090 under Windows 10 with the Agility SDK, with the split wave64 tests running for real) is the same total as the description's. Your VS / PS adapter half rebased on the head (teidenzero/xcl vsps-dxil-on-1745, 13dd18b, 926 passed) is noted: it waits for the maintainer's call on this PR, as you say.

AI use: Claude Code (Claude Opus 5.5) wrote this comment for @gefydev.

@Kalmarv

Kalmarv commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Test report and review, on an RTX 5070 Ti (32-lane waves only). The suite passes on 43cb32c and on the current head cf29f8a, and a 60 s title pair with XCL_PER_LANE=1 is clean. Reading the per-lane parts gave two cases where the per-lane form takes a program and gives other results than the HLSL path (review points 1 and 2, each with small programs run here), and one wrong label in the summary line.

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74, 32-lane waves only), AMD Ryzen 9 9950X, Windows 11 Pro 26200; Rust 1.99.0 MSVC, debug; DXC 1.9.2609 (XCL_DXC_DIR); a private XCL_DXIL_CACHE, new for the first run and kept for the second.
  • cargo test --workspace -- --test-threads=4, clean trees, once per commit:
commit passed failed ignored SKIPPED lines
43cb32c 925 0 42 22
cf29f8a 925 0 42 22 (the same lines)
  • SKIPPED, 22 lines: 18 no wave64, 3 per-lane halves refused on purpose (V_CVT_F16_F32, V_MUL_F16, V_PK_MUL_F16), 1 no heap windows. The description counts 25 with 21 no wave64; the RTX 5070 report above has the same 22 as here.
the 22 lines
SKIPPED gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 compares, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 rounding, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 three-source, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 transcendentals, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu: f64, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer carries, wave64: no wave64
SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
SKIPPED gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
  • Which tests ran per-lane DXIL on this GPU (all passed):
    • wave32: a_bridged_instruction_may_write_to_the_entry_block, per_lane_kernels_run_on_the_gpu (9 programs), a_per_lane_compute_program_runs_on_the_gpu, a_per_lane_program_with_four_memory_windows_runs_on_the_gpu, the wave32 shapes of a_per_lane_2d_or_3d_group_runs_on_the_gpu, the wave32 part of coalesced_foreign_runs_agree_on_the_gpu, and the wave32 halves of integer_programs_on_the_gpu (2 of 2), f32_programs_on_the_gpu (5 of 6) and f64_programs_on_the_gpu (1 of 1).
    • split wave64 (two 32-lane hardware waves, for real here): lower::tests::the_split_form_agrees_with_the_wave64_lowering_on_the_gpu, the_runtime_path_takes_the_split_form, and the (wave64, split) part of coalesced_foreign_runs_agree_on_the_gpu.
    • f16_programs_on_the_gpu passes without running any per-lane DXIL here: both wave32 halves are refused and both wave64 halves skip.
    • No native wave64 half ran. programs_on_the_gpu does not try the split form, so in the suite the f32 / f64 / integer programs never run as wave64 on a 32-lane GPU.
  • To cover that gap, one local test (not in the PR): the same programs through lower_dxil::kernel_split against the HLSL path's split form (Options { wave64: true, split_wave64: true }), every SGPR and VGPR the program names in all 64 lanes, f32_close where the suite uses it. All 8 programs the per-lane form takes agree: f32 arithmetic, compares, rounding, transcendentals, three-source; f64; integer arithmetic, carries. The other 3 are the same refusals as in wave32.
  • Title pair, 60 s each, XCL_DIRECT_DXIL=1 XCL_PER_LANE=1 on both sides (XCL_DIRECT_DXIL_STATS=1 for the summary line), 43cb32c against its merge-base with main:

main:

xcl-smoke v1
commit: 6c89285b8b529bde59cd17a26b911c39912fb677
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1193 (PresentX 1193)
presents per 2 s (last 3): 0 4 2
device removals: 0
crashes: 0
peak commit: 24075 MB

This PR (43cb32c):

xcl-smoke v1
commit: 43cb32c04fe9d69caad38893467c2f6eff8bfc98
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1228 (PresentX 1228)
presents per 2 s (last 3): 1 7 5
device removals: 0
crashes: 0
peak commit: 25176 MB
  • The per-lane path was taken. Summary at 60 s on the PR side: CS direct 102 / HLSL fallback 0; CS per-lane direct 29 / HLSL fallback 73;. So 29 of 102 compute programs ran in the per-lane form and 73 were refused and went to gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's per-instruction form (73 [SHADER] per-lane fallback ... – per-instruction form lines). None went to the HLSL path; see point 3 for the label. main side: CS direct 99 / HLSL fallback 0;.
  • Top refusal reasons of the 73:
count reason
17 a value written while some lanes were elsewhere, read after they met again
9 EXEC as a number in the split form where some lanes are elsewhere
8 unsupported IMAGE_LOAD (it reads register N the per-lane form did not pass)
5 unsupported IMAGE_SAMPLE_L (it reads register N the per-lane form did not pass)
3 mask source code N

Review (the per-lane parts; line numbers at cf29f8a)

  1. A branch or select on "any lane" of a mask is taken lane by lane, also where the lanes without the bit are still in EXEC. lane_masks::cond (lane_masks.rs:604) treats s_cbranch_vccz / vccnz and a branch on the SCC of a mask op as each lane's own bit, and Lower::cond (lower.rs:971) branches on it; S_CSELECT_B32 (lower.rs:624) selects on the same per-lane SCC. On the console these test the whole wave, and every lane goes the same way. The module doc says so as an assumption (lane_masks.rs:17, "it jumps over work that inactive lanes would not change anyway, or it tests a uniform value"), but nothing checks it, so a program outside it is taken and not refused. Shown with wave32 kernel programs that start with v_cmp_gt_u32 vcc, 16, v0 (VCC = lanes 0–15, EXEC = all 32) and write v1 on the fall-through, per-lane DXIL (lower_dxil::kernel) against the HLSL path on the GPU:
program after the compare HLSL path, v1 in lane 16 per-lane form, v1 in lane 16
s_and_b32 s0, vcc, exec; s_cbranch_scc1 L; v_mov_b32 v1, 7; L: 0 7
s_cbranch_vccnz L; v_mov_b32 v1, 7; L: 0 7
s_cbranch_vccz L; v_mov_b32 v1, 7; L: 7 0
s_cmp_lg_u32 vcc, 0; s_cbranch_scc1 L; v_mov_b32 v1, 7; L: 0 7
s_and_b32 s0, vcc, exec; s_cselect_b32 s1, 5, 7; v_mov_b32 v1, s1 5 7
control: SKIPPED_IF (s_and_saveexec, s_cbranch_execz) agrees agrees

In each of the first five rows the two paths differ in all of lanes 16–31 and agree in lanes 0–15 (the HLSL path has the same v1 in lanes 0 and 31). A branch on "any lane" is what if (WaveActiveAnyTrue(x)) or an early-out on "no lane needs this" asks for. Checked on the pack sweep since: of the 321 compute programs the per-lane form takes, 166 have a lane branch, and a local analysis pass (is there a lane here, in EXEC, without the bit?) marks 7 branches in 5 of them, all s_and_b64 vcc, exec, <mask>; s_cbranch_vccnz; no branch on the SCC of another mask op and no s_cselect on one. Read by hand, all 7 test a value that is the same in every active lane (the compiler's uniform branch), so none of the 321 gives other results through this. The point stands as an unchecked assumption, not as a wrong result in this pack. Not checked: the 29 programs of the title run on their own.

  1. A non-default rounding mode is dropped where gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 and the HLSL path refuse the program. This may be what @erickbobd's MODE guard (asked for on [OFFICIAL] Looking for PRs with shaders optimization #1269) already covers; we haven't checked their branch. If it covers only s_setreg, the second way in below needs its own check. Two ways in:

    • lower.rs:720 takes every s_setreg* of MODE as a no-op. Its comment (lower.rs:718) says the lowering refuses every float instruction, which was true before the bridge; float instructions now go through Ir::foreign.
    • s_round_mode goes through the bridge to gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's Lw::sopp (gpu/dxil/lower.rs:955), which refuses a non-default f32 mode but decides f64 and f16 from has_f64_round_op and dyn_rm. Lw::new leaves both false (gpu/dxil/kernel.rs:314), and only translate_on_this_thread sets them (kernel.rs:183), which the per-lane form does not go through.

    Shown with wave32 kernel programs, a sum of 1 + lane ulp and 0.75 ulp, on the GPU (lane 0):

program HLSL path #1426 form per-lane form
s_setreg_imm32_b32 hwreg(MODE, 0, 2), 3; v_add_f32 refused: non-default f32 round mode refused: the same taken: 0x3F800001 (to nearest; toward zero is 0x3F800000)
s_round_mode 0xC; v_add_f64 refused: non-default f64 round mode refused: the same taken: low dword 1 (to nearest; toward zero is 0)
s_setreg_imm32_b32 hwreg(MODE, 2, 2), 3; v_add_f64 refused: non-default f64 round mode refused: the same taken: low dword 1
s_round_mode 0x3; v_add_f32 refused refused refused (through the bridge)
the two sums without a mode write 0x3F800001; 1 the same the same

The f16 side (dyn_rm, s_round_mode 0xC with an f16 instruction, which recomp/tests.rs:6627 calls the retail pattern) is from reading only: a run here cannot show it, because an f16 sum comes out rounded toward zero on this driver on all three paths, with or without the mode write.

  1. The summary calls the per-lane refusals "HLSL fallback". pso.rs:617 records a refusal under the stage CS per-lane and goes on to translate_compute (pso.rs:622), and coverage::fallback_summary prints every stage as direct N / HLSL fallback M (gpu/dxil/coverage.rs:317). In the title run above, CS per-lane direct 29 / HLSL fallback 73 are 73 programs in the per-instruction form; CS direct 102 / HLSL fallback 0 is the line that counts the HLSL path. Label only.

The three local tests behind this (split-form programs, the branch programs, the rounding programs; they print, they don't assert) are about 230 lines on cf29f8a; say if you want them as a follow-up PR or a patch here.

Not tested

  • Native wave64 (every wave64 half skips here), AMD and Intel GPUs, a release build of the suite.
  • The title beyond 60 s, and the pictures: the pair counts frames, crashes and device removals only. cf29f8a in the title (it changes test code only).
  • xcl shaders --direct --lanes (the pack sweep), DXC and driver times.
  • VS / PS and mesh in the per-lane form.
  • The refactor of gpu/dxil/kernel.rs (Lw::new / Lw::finish): its output was not compared with main's, and of its diff only Lw::new was read.
  • Read for the review: lower_dxil.rs, ssa.rs, lower/wave.rs, the pso.rs and module.rs diffs, and of lower.rs the scalar, vector and memory instructions, the branches, the stale check, the bridge and the block driver. Not read: assemble.rs, shaders.rs, the VS / PS parts and the tests of lower.rs; lane_masks.rs only where point 1 needed it.

AI use: Claude Code (Claude Fable 5.2) ran the tests, read the diff and drafted this. Claude Code (Claude Opus 5.5) reviewed it before posting.

@oni-swr

oni-swr commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Test report for #1745 on native wave64 (AMD RDNA3). The second part is with #1742 merged in, to check that the DIFFERS_ON_1426 f16 entries can go.

Tested

  • AMD Radeon RX 7800 XT, driver 32.0.31035.1003 (wave32 and native wave64); Ryzen 7 5700X3D; Windows 11 Pro 26200; Rust 1.100.0 MSVC; debug; each tree in its own target dir.
  • Recompiler: a per-lane form for the direct DXIL backend (XCL_PER_LANE) #1745 head 43cb32c, as is: cargo test --workspace -- --test-threads=4 --nocapture gives 925 passed, 0 failed, 42 ignored. 7 tests SKIPPED: the 6 per-lane refusals V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 (f16_programs_on_the_gpu f16 arithmetic and f16 packed, f32_programs_on_the_gpu f32 conversions, each in wave32 and wave64), plus heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows). Everything else in recomp::lower / lower_dxil / lane_masks passes in native wave64.
  • 43cb32c merged with Recompiler: round direct-DXIL f16 converts and products to nearest-even #1742 35355a2 (no conflicts), and DIFFERS_ON_1426 emptied (local edit in recomp/lower.rs, not pushed):
    • cargo test -p xcl --lib recomp::lower -- --test-threads=1: 44 passed, 0 failed, 0 ignored, no SKIPPED. f16_programs_on_the_gpu (f16 arithmetic, f16 packed) and f32_programs_on_the_gpu (f32 conversions) now run per lane in wave32 and native wave64, and agree with the HLSL path.
    • cargo test --workspace -- --test-threads=4 --nocapture: 938 passed, 0 failed, 42 ignored. The extra tests come from main 85e3826, which Recompiler: round direct-DXIL f16 converts and products to nearest-even #1742 is based on. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows) and pso_measurement_compiles_an_exact_synthetic_record (Developer Mode off).

Not tested

AI use: Claude Code (Claude Opus 5.5) ran these tests on @oni-swr's machine and wrote this report.

@gefydev

gefydev commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

AI use: Claude Code (Claude Opus 5.5) wrote this comment for @gefydev.

@Diskuss Diskuss left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on AMD Radeon RX 9070 XT (RDNA4, native wave64) at cf29f8a6a7e4e64cfaf17dd929e5334a7d5cf193, merged locally with main 4178e88

RX 9070 XT, driver 32.0.32015.7029; Ryzen 7 5700X3D; 32 GB RAM; Windows 11 Pro 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17; debug build.

Tested

  • The head is 15 commits behind main. The merge has one conflict, in gpu/dxil/kernel.rs, with #1748 (0b64aa0). #1748 added three fields to the Lw literal in translate_on_this_thread, and this PR moves that literal into Lw::new. I resolved it locally by keeping Lw::new and adding fmt_desc_cache: HashMap::new(), fmt_comp1_cache: HashMap::new() and uma_base_val: None to it. Everything below ran on that merge. It was not pushed.
  • cargo test --workspace --no-fail-fast -- --test-threads=4:
    • PR + main: 953 passed, 0 failed, 42 ignored
    • main 4178e88 alone: 891 passed, 0 failed, 42 ignored
    • The +62 are this PR's tests. The lib goes from 864 to 926 tests.
  • SKIPPED, 8 lines:
    • The 6 intentional per-lane refusals: V_MUL_F16, V_PK_MUL_F16 and V_CVT_F16_F32, each in wave32 and wave64.
    • heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
    • pso_measurement_compiles_an_exact_synthetic_record (Developer Mode off).
    • On main, only the last two skip. There are no no wave64 skips, so every wave64 half ran natively. No device removal in any run.
  • The PR's tests, run 3 times by name (recomp::lane_masks, recomp::lower (which includes lower_dxil), recomp::ssa, recomp::dxil::assemble, batched_replacements_match_one_at_a_time, --test-threads=1): 62 passed, 0 failed, 3 of 3 runs, with the same SKIPPED lines each time.
    • f32_programs_on_the_gpu passes in both wave32 and native wave64, including the bit-exact -0 in v10 under -Gis. That was the RDNA4 failure before 9109710.
    • a_per_lane_program_with_four_memory_windows_runs_on_the_gpu passes with #1748's entry-block uma_base hoist merged in. The per-lane form leaves Block(0) without a terminator until DxilIr::finish, and the hoist into it works.

Review (AMD-relevant semantics only; I did not repeat @Kalmarv's three points)

  • Merge conflict with main (above). This blocks CONTRIBUTING item 6. The rebase fix is the three-field addition to Lw::new; nothing else conflicts. TRANSLATOR_VERSION comes in from main as 6. The per-lane cache identity is derived from it (identity_for(.., "xcl-per-lane")), so it is invalidated too.
  • Sign of zero, denorms and fast-math: the per-lane lowering emits no float instructions of its own. Floats go through Ir::foreign to #1426's Lw, so they take #1426's fast-math flags and denorm handling unchanged, and nothing AMD-specific is added. The other HLSL-reference comparisons (lower.rs agrees_with_hlsl and related, coalesced_foreign_runs_agree_on_the_gpu, COALESCED_F32_RUN) still compile without -Gis and compare bit for bit. Their inputs produce no signed zero, though, and all pass here, so no change is needed today. This is only the place to look if a new float program is added to them.
  • wave32 / wave64 and EXEC: I read lower/wave.rs, i.e. mask_words, exec_words, read_from and the wave64 == false upper word set to 0. It matches the module doc. The whole-wave forms refuse in partial blocks, and a read of a lane outside EXEC returns this lane's own value, so it never uses WaveReadLaneAt on an inactive lane, which is undefined on AMD. Native wave64 runs of the cross-lane, coalesced, 2-D / 3-D and split tests all pass here.
  • No other issues found that I could tie to a failing case on this card.

Not tested

  • A retail title with XCL_PER_LANE=1 or scripts/smoke.ps1 (no game files here).
  • A release build, and the pack sweep.

Review and test run by Claude Code (Claude Opus 5.5) on Diskuss's machine.

gefydev added a commit to gefydev/xcl that referenced this pull request Nov 24, 2026
…odes it drops

Two correctness gaps on programs the per-lane form took, found by
Kalmarv's review of xcl-dev#1745 with GPU programs against the HLSL path:

- A branch on whether any lane of a mask is set (`s_cbranch_vccz` /
  `vccnz`, `s_cbranch_scc*` after a mask op or `s_cmp_lg` of a mask) and
  a scalar read of such an SCC (`s_cselect`, `s_cmov`, `s_addc`,
  `s_subb`) decide for the whole wave on the console. The analysis took
  each lane's own bit, which differs in the lanes in EXEC that lack the
  bit (VCC = lanes 0-15, EXEC = all 32: 7 where the console gives 0). They
  are now taken only where the condition is the same in every lane that
  reaches with its EXEC bit (`s_and_saveexec` then `s_cbranch_execz`, or
  VCC equal to EXEC), and refused otherwise. The analysis test that
  stated the old assumption (a vccz branch is a lane branch) now states
  the rule.
- `s_setreg` of MODE was a no-op, so a non-default rounding mode was
  dropped where xcl-dev#1426 and the HLSL path refuse the program. MODE writes
  now go to xcl-dev#1426's lowering, and the adapter sets `dyn_rm` /
  `has_f64_round_op` as xcl-dev#1426's translator does, so `s_round_mode` and
  `s_setreg` refuse what they cannot honour. Denormal-only writes are
  still taken.

Tests: Kalmarv's five branch / select programs are refused, and a
uniform one is taken; f32 by `s_setreg` and f64 by `s_round_mode` /
`s_setreg` are refused (the f32 one was taken before the fix), and a
denormal-only write is taken.
@Pipodi

Pipodi commented Nov 24, 2026

Copy link
Copy Markdown

Review of #1745 at 0570037: static, nothing built or run. I read the diff against main 6c89285 in three parts: the lane-mask analysis and SSA, the lowering, and the DXIL adapter and runtime wiring. Nothing below was run: each correctness point comes with the program that would show it, compared with the HLSL path (EXEC emulated). They all need XCL_DIRECT_DXIL=1 XCL_PER_LANE=1, except where I say otherwise. 0570037 answers @Kalmarv's points 1 and 2, and I leave out his point 3. Line numbers are at 0570037.

Correctness of the per-lane form

  1. Whole-wave mask decisions: fixed in 0570037. I read the commit:
    • uniform_over refuses a lane branch, or an s_cselect / s_cmov / s_addc / s_subb of a mask op's SCC, unless the condition is the same in every lane in EXEC. That is the rule I would have suggested.
    • The old test now asserts it.
    • The check runs only where the analysis marks the branch or the SCC as a lane mask's (lane), so point 2's case still gets through it.
  2. The analysis and the lowering disagree on which branches are per-lane.
    • The analysis follows a mask op only when both sources are known masks (lane_masks.rs:528-549); otherwise SCC is an Atom::Scc with lane = false (lane_masks.rs:574-578).
    • The lowering treats an op as a mask op when any source holds a mask (reads_mask, lower.rs:545 and lower.rs:566), and writes SCC per lane; cond then branches on it lane by lane (lower.rs:963).
    • Example: v_cmp … vcc; s_and_b64 s[4:5], vcc, s[8:9] (s8:9 is user data), then s_cbranch_scc0 J; s_mov_b32 s6, 1; J: v_mov_b32 v3, s6.
      • The lowering branches per lane, but the analysis has lane = false, so neither 0570037's uniform_over check nor partial_blocks (lower.rs:1063) sees the branch.
      • So the stale-value, cross-lane and s_barrier refusals don't run, and the lanes that skipped read their old s6.
  3. A bridged v_cmpx_* can turn on lanes that had EXEC off.
    • lower.rs:1647 passes guard = true for every cmpx. gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's write_mask builds act() & cond, and act() returns that guard (dxil/lower.rs:773, dxil/lower.rs:849-851).
    • So at a guarded pc, the new EXEC is cond, not cond & EXEC. The native integer path is right (lower.rs:791-794).
    • Example: v_cmp_gt_u32 vcc, 16, v0; s_and_saveexec_b32 s0, vcc (no execz), then v_cmpx_le_f32 0, v1; v_mov_b32 v2, 7; s_or_b32 exec, exec, s0. Lanes 16 and up get v2 = 7.
  4. The stale-value rule misses three cases. @Kalmarv's per-lane-stale follow-up reworks this rule; from its description, same-block reads "stay with def_owner / use_owner", so the loop case below would still be taken there. I haven't read that branch.
    • Loops. The rule compares static blocks (def_owner[b] != use_owner[c], lower.rs:1004), so a scalar written and read in the same partial block on different loop iterations is accepted.
      • Example: s1 = 0; s3 = 0; L: v_cmp_eq_u32 vcc, s3, v0; s_and_saveexec s2, vcc; s_cbranch_execz J; s_add_u32 s1, s1, 1; v_mov v1, s1; J: s_or exec, exec, s2; s_add s3, s3, 1; s_cmp_lt_u32 s3, 4; s_cbranch_scc1 L.
      • On the console, lane k gets v1 = k + 1. In the per-lane form every lane gets 1.
    • A phi copied in a partial block. own (lower.rs:370-380) copies only values already in def_block, and a phi never is one. stale follows the phi's operands, not the phi.
      • Example: a uniform if/else sets s5 to 1 or 2, then s_and_saveexec; s_cbranch_execz J; s_mov_b32 s6, s5; J: s_or exec; v_mov v1, s6.
      • The copy case in a_mask_left_behind_by_lanes_that_skipped_its_write copies an older mask from before the split, so it doesn't cover this.
    • s_bcnt0/1 of a mask. It writes SCC through ssa.write (wave.rs:464), not write_scc/own, so stale never sees it. Example: s_bcnt1_i32_b64 s2, exec in an execz arm, then s_cbranch_scc0 after the join.
  5. A bridged mask write in the split wave64 form can sit behind a barrier that only one half reaches.
    • The bridge (lower.rs:1648) has no all_lanes-style check for instructions that gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 lowers with an exchange between the halves.
    • Every f32/f16/f64 v_cmp* and v_add_co_* whose mask is read as a whole goes through write_mask → ballot → exchange_n → meet(), a group barrier (dxil/lanes.rs:221-256).
    • In a branch only one half takes (33–64 threads, Partner::Present), the other hardware wave never reaches that barrier: a hang, or barriers paired with the wrong partner.
    • The per-lane form's own ballots refuse this (wave.rs:53, wave.rs:122).
    • I followed the path, but the hang itself needs a run on a wave32 GPU.
  6. Lanes outside the launch EXEC (kernel ABI).
    • lower.rs:1259-1270 and lower.rs:1502-1512 send those lanes straight to the exit, and lane 0 stores every SGPR.
    • With a launch EXEC of 0xFFFFFFFE, s_mov_b32 s0, 5 leaves res[0] at its input value.
    • The skip block also sets every mask bit to 0 (lower.rs:1268), where s_not or s_orn2 of a v_cmp mask leaves those lanes at 1 on the console.
    • lanes_outside_exec_at_launch_keep_their_registers keeps lane 0 active.
  7. Not traced to the end: s_or_saveexec_b64 s, -1 and s_mov_b64 exec, -1 (whole-wave mode) inside a block some lanes don't reach give EXEC = TRUE (lane_masks.rs:464-467, lane_masks.rs:519-526). On the console that turns on the lanes that branched away, and here they are elsewhere. What's left after the cross-lane refusals is a write in that region read by those lanes after the join. I haven't checked whether real code does that.

Runtime and caching

  1. xcl shaders --recomp changes with no flag.
    • RecompAgg::add (shaders.rs:445-503) now runs lower_dxil::compute_code, survey_compute_code, a second translate_compute/translate_mesh and lane_masks::analyze_code on every program, without --lanes.
    • So the existing sweep is slower and prints new lines.
    • These calls run on the sweep's worker threads, without compute_with's 256 MB stack and panic catch. A panic in the new code would hit h.join().unwrap() (shaders.rs:767) and end the sweep.
  2. The per-lane cache identity has no version.
    • lower.rs, lower/wave.rs, lower_dxil.rs, lane_masks.rs and ssa.rs are not in TRANSLATOR_SOURCES (build.rs).
    • TRANSLATOR_VERSION covers gpu/dxil only, and the per-lane identity is identity_for(id, "xcl-per-lane") (pso.rs:245).
    • So a later fix to the lowering keeps serving the old cached containers to XCL_PER_LANE=1 users, unless someone bumps a version by hand.

Tests

  1. Refusals become skips. programs_on_the_gpu (lower_dxil.rs:600-606) turns any Err from the per-lane form into skip_test, not only the programs in DIFFERS_ON_1426. A change that makes the form refuse the f32/f64/int/f16 programs still passes. An allow-list of the expected refusals would keep the assertion.
  2. Not covered:
  • Every lane_masks test is wave64. Nothing tests:
    • the wave32 _B32 paths;
    • *_WREXEC, v_cmpx, VOP3 sdst = EXEC, or separate exec_lo/exec_hi writes;
    • nested loops or the step_bounded/cond_bounded fallbacks.
  • d94736a, 5f78f44 and 1b257c2 add no test.
  • The CPU Interp has no foreign, so bridged instructions are only covered by GPU runs.

CONTRIBUTING

  1. The size waiver. The description says the size rule is waived "at the maintainer's request ([OFFICIAL] Looking for PRs with shaders optimization #1269)". The only maintainer text I found is the issue body ("We are open for big PRs aiming to optimize shaders … compiling shaders directly into DXIL"); please link or quote that, so a reviewer can see what the 7,467 lines rest on.
  2. Commits.
    • cf29f8a says every per-lane GPU test failed on WARP (the CI adapter) before it, so the commits before it don't each pass CI.
    • Several commits fix earlier ones in the PR: bcb502f fixes 8cb697d, 1c9477a reworks d1f0661, 51f3b82 drops 8cb697d's heap refusal, and c7caa1d fixes this PR's DxilIr.
    • The description says 45 commits; the branch has 49.
  3. AI use. 43cb32c and 8e0c4a7 carry Assisted-by: Antigravity (Gemini 4 Neon), which the AI use section doesn't name.
  4. Not tested. Both smoke runs are with XCL_PER_LANE off and, from the description, without XCL_DIRECT_DXIL, so they don't exercise the kernel.rs refactor (Lw::new/Lw::finish) under XCL_DIRECT_DXIL=1. Reading it, I think it emits the same DXIL. A byte diff of xcl shaders --direct --dump on 6c89285 and on cf29f8a would show it, and Not tested could say it wasn't run.
  5. XCL_PER_LANE, XCL_RECOMP_STAGES and XCL_RECOMP_NO_HLSL aren't documented anywhere, as with XCL_DIRECT_DXIL today.

Nits

  • pso.rs:238: let id = identity_with(.
  • ssa.rs:150-158 doesn't move users[phi] to users[same], so a trivial phi can be left behind. The results are unaffected: a leftover phi over the marker is still refused.
  • wave.rs:298-300: v_readfirstlane where no lane has EXEC reads lane 0.
  • recomp/dxil/assemble.rs is called only from its own test. It finds dxil.dll through GetModuleHandleW, so it works only once DXC has loaded it.

Checked and fine

  • The lane-mask analysis:
    • the BDD (variable order, memoisation, partial results);
    • the saveexec/wrexec semantics, including the ANDN1/ANDN2 operand order;
    • VOPC/VOP3 sdst writes, and separate exec_lo/exec_hi writes turning EXEC opaque;
    • irreducible-flow detection, which is complete;
    • loop atoms not leaking between iterations;
    • the fallbacks weakening soundly.
  • SSA: the sealing order, and the one-pass trivial-phi replacement in 1c9477a, which can't form a cycle.
  • The lowering:
    • DPP16/DPP8, v_permlane(x)16, ds_swizzle quad-perm and bitmask modes (rotate mode not checked);
    • mbcnt, readlane, writelane and their split checks;
    • the v_cndmask/carry-in lane bit (c7caa1d);
    • coalesced runs, which can't span an EXEC or guard change; stores and atomics under partial EXEC run only in the lanes that have it;
    • far jumps.
  • The bridge's register check refuses every unpassed read of VCC, M0, EXEC and SCC.
  • The kernel.rs refactor: by reading, the module calls run in the same order, so the DXIL should be the same.
  • The fallback: a per-lane error, including a caught panic, goes to gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's form.
  • GPU tests skip with runner::skip_test; no #[ignore], no game data, no new dependency, no ported code.

AI use: Claude Code. Three Claude Opus 5.5 subagents reviewed the three parts. Claude Opus 5.5 (the main session) then read the code path of every numbered point itself, at cf29f8a and again at 0570037, and wrote this review; the Checked and fine list is from the subagents' reading. Points 5 and 7 are not traced to the end, as they say.

@alexmircea1299

Copy link
Copy Markdown

Test report on NVIDIA GeForce RTX 5070 (12 GB)

  • PR / Commit: Recompiler: a per-lane form for the direct DXIL backend (XCL_PER_LANE) #1745 (**cf29f8a**)
  • Hardware: AMD Ryzen 5 9600X, NVIDIA GeForce RTX 5070 (12 GB VRAM, driver 621.35), 32 GB DDR5 6000MT/s
  • Environment: Windows 11 (build 26300), rustc 1.100.0 (0ef1bc386 2026-11-09), Windows SDK 10.0.26100.0 (debug build)
  • Command: .\scripts\test.ps1 (cargo test --workspace -- --test-threads=4)
  • Results:
    • xcl --lib: 876 passed; 0 failed; 22 ignored (14.76s)
    • Integration tests: 8 passed; 0 failed; 12 ignored (1 + 1 + 6)
    • Total workspace: 884 passed; 0 failed; 34 ignored
  • GPU tests skipped on this adapter:
    • 7 (no wave64)
    • 1 (no heap windows)
    • 1 (f32 rounding, wave64: no wave64)
    • 1 (integer arithmetic, wave64: no wave64)
    • 1 (f64, wave64: no wave64)
    • 1 (integer carries, wave64: no wave64)
    • 1 (f32 three-source, wave64: no wave64)
    • 1 (f32 transcendentals, wave64: no wave64)
    • 1 (f32 conversions, wave64: no wave64)
    • 1 (f16 arithmetic, wave64: no wave64)
    • 1 (f16 packed, wave64: no wave64)
    • 1 (f32 compares, wave64: no wave64)
    • 1 (f32 arithmetic, wave64: no wave64)
    • 1 (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)))
    • 1 (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)))
    • 1 (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)))
  • Not tested: Retail title (smoke.ps1), release build, AMD / native wave64 GPUs.
  • AI use: Google Gemini assisted with running the commands and drafting this report from my real local test run.

@mgrein

mgrein commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Test report for the head 0570037 (not yet reported on), NVIDIA RTX 4070.

Tested

  • NVIDIA GeForce RTX 4070 12 GB (Ada, 32-lane waves, so the split wave64 tests run for real), driver 617.14; AMD Ryzen 5 5600X; 32 GB RAM; Windows 11 Pro 25H2 (build 26200); Rust 1.94.1 stable-x86_64-pc-windows-msvc, debug; DXC 1.9.2609.5. A clean worktree of 0570037, its own target dir.
  • .\scripts\test.ps1 at 0570037: 927 passed, 0 failed, 42 ignored over the workspace (lib: 878 passed, 0 failed, 22 ignored), two more than the description's 925 / 876 on cf29f8a.
  • SKIPPED (22): 18 "no wave64" (this GPU), 1 "no heap windows", and the 3 per-lane refusals the description names (V_CVT_F16_F32 in f32 conversions, V_MUL_F16 in f16 arithmetic, V_PK_MUL_F16 in f16 packed, wave32 per-lane form).
  • The XCL_SAMPLE_* variables were not set, so the game-data tests did nothing.

Not tested: native wave64; a title run with XCL_PER_LANE=1; --direct --lanes on the pack; release.

AI use: Claude Code (Claude Opus 5.5) ran the suite and wrote this report.

@thehollowedone

thehollowedone commented Nov 24, 2026 •

Copy link
Copy Markdown

Retest on bfb8133d

Confirmed the loop SCC fix on the same RTX 3080 Ti setup. The per-lane compiler now refuses the original loop at the scalar select. I dispatched the same shader separately through per-instruction direct DXIL and HLSL. Each returned 5 in all 32 lanes. In a control that set the loop condition with a uniform scalar compare, per-lane DXIL still compiled and returned 5 in all 32 lanes.

Using cargo test --offline --locked -p xcl --lib <filter> -- --nocapture --test-threads=1, the stock gpu::recomp::lower::tests:: suite reported 34 passed, 0 failed, 0 ignored, with four native-wave64 subcases skipped. The added scratch_wave32_loop_refusal_and_reference_readback fixture passed 1/1 with zero skips. This checks kernel compilation and readback. Retail and runtime routing were outside the test.

Tested

On 0570037d, a synthetic two-iteration wave32 loop gave different GPU readbacks. HLSL returned v1 = 5 in all 32 lanes. Per-lane DXIL returned 5 in lanes 0–15 and 7 in lanes 16–31. Both dispatched successfully. This exercises a mask-derived SCC reaching the next iteration's scalar select, with both mask operands known.

Initialize EXEC to all 32 lanes and v0 to the lane index.

s_mov_b32 s4, 2
v_cmp_gt_u32 vcc_lo, 16, v0
s_cmp_gt_u32 1, 0
loop:
s_cselect_b32 s1, 5, 7
v_mov_b32 v1, s1
s_sub_u32 s4, s4, 1
s_cmp_eq_u32 s4, 0
s_cbranch_scc1 done
s_and_b32 s0, vcc_lo, exec_lo
s_branch loop
done:
s_endpgm

RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC debug, DXC 1.8.2502.11. cargo test --offline --locked -p xcl --lib scratch_loop_carried_scc -- --test-threads=1 --nocapture ran one added fixture with zero skips and failed at the direct DXIL vs. HLSL comparison. The HLSL readback passed the all-5 assertion. The fixture uses the existing kernel runners.

Not tested

This fixture covers wave32 kernel lowering. Retail behavior, native wave64 and runtime fallback were outside the run.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) wrote and ran the fixture and drafted this report.

@gefydev

gefydev commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@thehollowedone thank you for the fixture and the readbacks on 0570037 (HLSL all 5, per-lane 5 in lanes 0-15 and 7 in lanes 16-31). Received. It looks like the same area as the SCC-from-a-mask review point above (the form treats the SCC as per lane where the check does not see it); I have passed your program to the session that writes the code and will answer here once there is a decision. I am not promising a fix yet.

AI use: Claude Code (Claude Opus 5.5) wrote this comment for @gefydev.

@moombathepilot

Copy link
Copy Markdown

RX 7800 XT review of #1745

I reviewed the shader sweep's validation and size reporting and ran the tests below on clean head 0570037d0247978205e786057cadbdc85dded0ca. Both test commands exited successfully.

Review findings

  1. Separate successful translations from paired size totals. If per-lane translation succeeds but the per-instruction run returns an error or times out, the sweep adds the per-lane byte count and adds zero for the other side. The printed size totals then compare different sets of shaders. Keep counting all successful per-lane translations for coverage, but add to both size totals only when both paths succeed and print the paired count. This is a conditional accounting issue found in the code. I did not verify that it affected the posted whole-pack numbers.
  2. Apply --validate to the per-lane output in release sweeps. --validate reaches the per-instruction translator, but the per-lane call doesn't use it. The validator in Lw::finish runs only in debug or test builds. A release --direct --lanes --validate sweep can therefore count per-lane output without passing it through the DXIL validator. Could the sweep validate both paths when the flag is set, or label which path it validates?

Tested

RX 7800 XT (RDNA3), driver 32.0.32029.2010, Ryzen 7 5700X3D, Windows build 26300.9974, Rust 1.100.0 MSVC, SDK DXC/DXIL 1.9.2602.17, debug. No source changes.

Run Passed Failed Ignored Explicit skips included in passing results
scripts/test.ps1 --test-threads=4, flags unset 927 0 42 7 skip messages
cargo test --locked -p xcl --lib -- gpu::recomp::lower --test-threads=1 --nocapture, with XCL_DIRECT_DXIL=1 and XCL_PER_LANE=1 46 0 0 6 skip messages

Both runs logged the six documented f16 cases (arithmetic, packed multiply and conversion on wave32 and wave64). The full suite also skipped heap_window_out_of_memory_falls_back_to_the_switch_form because heap windows were unavailable. The focused set includes the split-path and four-memory-window GPU tests, which passed.

Not tested

Retail startup on this PR, a release shader sweep, the whole-pack size result, compile speed, or opt-in game-data tests (XCL_SAMPLE_* unset). The two reporting findings were verified by reading the source and are separate from the passing debug tests.

AI use

Codex (GPT-6.2-sol) reviewed the relevant code, ran the tests on this PC, and drafted this report from the results.

@gefydev

gefydev commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@moombathepilot thank you for the RX 7800 XT report on 0570037 (927 passed, 0 failed, 42 ignored; 46 passed with XCL_DIRECT_DXIL=1 XCL_PER_LANE=1, six documented f16 skips) and for the two review points on the sweep (paired size totals, --validate for the per-lane output). Received and passed to the session that writes the code; I will answer here once there is a decision. I am not promising a change yet.

AI use: Claude Code (Claude Opus 5.5) wrote this comment for @gefydev.

@vitor127wt

Copy link
Copy Markdown

RTX 5070 Ti / Proton — per-lane retail run on 0570037

With XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PER_LANE=1, the 150 s run on 0570037d0247978205e786057cadbdc85dded0ca translated 10 of 24 compute shaders per lane. The other 14 used per-instruction direct DXIL. Eleven per-lane refusals logged the new whole-wave mask branch rule, two logged numeric EXEC in the split form, and one logged an IMAGE_LOAD register restriction. There were zero HLSL fallbacks.

The earlier 150 s run on cf29f8a6a7e4e64cfaf17dd929e5334a7d5cf193 also routed 10 shaders per lane and 14 per instruction. All 24 translated compute cache keys and their DXIL bytes matched across the two revisions. Earlier 60 s runs on 6c89285 and cf29f8a with per-lane off showed 1,236 and 1,235 frames, respectively. Enabling per-lane on cf29f8a in the 60 s run sent all three startup compute shaders through the per-instruction path. All three runs produced byte-identical compute DXIL.

Tested

  • RTX 5070 Ti 16 GB, NVIDIA 620.73.04, Ryzen 7 9700X, 32 GB DDR5, CachyOS 7.3.5-2-cachyos, Proton Experimental 11.0 (experimental-11.0-20261112-x86_64). vkd3d-proton ec207194 with the Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257 patch, dxil-spirv 7c048638, and DXC 1.9.2609.5. Clean x64 Windows release builds using Rust 1.100.0 and LLVM-MinGW 20261117 (x86_64-pc-windows-gnullvm).
  • Built with cargo build --locked --release --target x86_64-pc-windows-gnullvm -p xcl --bin xcl. Ran scripts/linux/smoke.sh "$PROTON" "$PREFIX" "$GAME" 150 from Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257 for the longer runs. Each run used the same retail title, a separate fresh Wine prefix and shader cache, networking off, and A presses scheduled every three seconds. XCL PSO cache blobs and vkd3d-proton/NVIDIA disk shader caches were disabled. Both used XCL_DXC_THREADS=2, XCL_PSO_TRACE=1, and XCL_DIRECT_DXIL_STATS=1. The smoke scope was capped at 16 GiB RAM with no swap.
  • Built the library tests with cargo test --locked --release --target x86_64-pc-windows-gnullvm -p xcl --lib --no-run. Ran the Windows test binary in Proton Wine with the filters gpu::recomp::lower_dxil::tests:: and a_whole_wave_decision_on_a_mask_some_lanes_lack_is_refused, --test-threads=1 --nocapture. The updated head returned 13 passed, 0 failed, 0 ignored. This includes the whole-wave mask and rounding-mode regression tests. The run logged 15 skipped subcases (12 requiring native wave64 and three intentionally refused f16 cases). The split wave64 and four-memory-window GPU tests ran.

150 s smoke on 0570037

xcl-smoke v1
commit: 0570037d0247978205e786057cadbdc85dded0ca
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA6.Xbox.v1.0.2.1
seconds: 150
exit: 0x0
frames shown: 1830 (PresentX 1830)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB

The Wine smoke script generated the block. I abbreviated the local folder name in title. The last two-second bin with presents ended at 94.1 s. Wine reported 0 MB in the Windows peak-commit field. Linux cgroup peak was 15.07 GiB, with no OOM kill. Coverage is the retail loading interval on Proton and the focused suite.

AI use — OpenAI Codex (GPT-6, exact variant unavailable) built and ran the checks, verified the logs, and drafted this report.

gefydev and others added 5 commits November 24, 2026 17:59
A backend that writes DXIL itself keeps the console CFG, so each lane can
branch on its own EXEC bit instead of every vector write being guarded and
branchy programs going through the `pc` dispatcher. This is the analysis it
needs: every lane mask is followed as a per-lane boolean function (a BDD
over the lanes' compare / carry results, uniform SCCs and unresolved
joins), mask branches are taken lane by lane, and a forward dataflow gives
what holds in each lane reaching a block. A vector instruction keeps its
guard only where reaching it does not imply the lane's EXEC bit.

Loop heads are guessed from their forward edges and checked against the
back edges; a wrong guess becomes an atom and only that head recomputes.
Results too large for a per-step node budget are weakened to atoms, which
only costs precision. Indirect jumps and irreducible loops are refused.

Nothing translates with it yet: `xcl shaders --recomp` prints its counts.
On the retail pack: 25 695 of 26 698 programs analysed (983 indirect
jumps, 20 irreducible), 10.65 M of 28.71 M vector instructions still
guarded (37.1 %), 9 015 programs with no guard at all, 700 CPU-s for the
whole pack (slowest program 1.5 s).
`dxil::assemble::assemble` turns a module written as LLVM IR text (or
bitcode) into a signed container: dxcompiler.dll's assembler builds the
container from the module's `dx.*` metadata, dxil.dll's validator checks and
signs it. No HLSL front end and no optimiser: a retail compute program's
module (8.6 MB of IR, 1 MB of DXIL) takes 0.75 s, its HLSL 25 s through DXC.

This is the text path under the module builder (`to_text()`), so the
lowering can run real programs on the GPU before the binary writer is done.

The test assembles a hand-written CS of the ABI root signature, runs it on
the GPU and checks its output, and checks that a use before its definition
is refused by the validator. A module needs an `!llvm.ident`: without one
it validates but the AMD driver faults in CreateComputePipelineState.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XTYmP5ub3Zjdi8PYaDNwsV
The direct backend's lowering, for kernel mode first. The console CFG is
kept and every register dword is an SSA value, built on the fly while the
blocks are lowered (`ssa.rs`). EXEC is each lane's own bit: mask branches
are per-lane branches and a vector write keeps `select(bit, new, old)` only
where the lane-mask analysis could not prove the bit set. An SGPR has a
number view and, when it holds a mask, a lane-bit view; a number read where
a mask was written (or the reverse across a join) is refused once every phi
is complete, and the program stays on the HLSL path. At the end, where every
lane is back, a mask stored as a number is the wave's ballot.

A mask written in a block some lanes skip (a loop lanes leave one by one,
an arm some lanes jump over) and read after they meet again differs from
the console, whose whole-wave write left the absent lanes' bits 0. Those
blocks are found from the post-dominators of the lane branches; such reads
are refused, and kernel mode's final store reports those registers.

The IR goes through an `Ir` trait, the part of the DXIL module builder the
lowering needs. The tests run it lane by lane on a CPU interpreter, and run
the same programs through the HLSL path on the GPU: every register agrees
(GTX 1650, wave32). The analysis now exports its CFG for the lowering.
`s_load_dword{,x2,x4,x8,x16}` and `global_` / `flat_` `load` / `store_dword
{,x2,x3,x4}` on the flat memory, with the addressing of the HLSL path's
single-window form. A guarded load runs in every lane and keeps the old
register where the lane's EXEC bit is clear (a raw buffer read out of range
is 0, so an inactive lane's address can't fault). A guarded store gets a
block of its own that only the lanes with their bit enter, and the rest of
the console block continues after it; the blocks are reserved before the
SSA form is built, so the predecessor lists stay exact.

The CPU interpreter in the tests gets the memory too, and the comparison
with the HLSL path on the GPU now also checks the memory after the run: a
program with an SMEM load, a per-lane load, a guarded store and an
unguarded one agrees word for word (GTX 1650, wave32).
The lowering takes a stage: kernel (the runner's ABI, as before) or a
compute program. In compute mode the user SGPRs come from `io`, then the
group ids and TG_SIZE the program enables, the thread ids go into v0–v2,
EXEC starts as every lane that runs, and the program ends without storing
registers (so kernel mode's report of stale masks does not apply).

One-dimensional groups only for now: in a 2-D / 3-D group the PC driver
need not give a wave consecutive threads, which the console does; the HLSL
path reorders them and those programs stay on it here.

A compute program with user SGPRs and the group id, over three groups of
64 threads, writes the same memory through the HLSL path on the GPU and
through the lowering on the CPU (GTX 1650, wave32).
mastrr9 added a commit to mastrr9/xcl that referenced this pull request Nov 24, 2026
Brings xcl-dev#1747, xcl-dev#1791, xcl-dev#605, xcl-dev#1679, xcl-dev#1806, xcl-dev#1745, xcl-dev#1307, xcl-dev#1321 among others.

Resolutions:
- dxil/kernel.rs: upstream's Lw::new / Lw::finish; the safe s_barrier state
  and policy and xcl-dev#1741's single-wave bounded exchange move into Lw::new, with
  a safe_barrier flag (false for the per-lane lowering).
- dxil/lower.rs: VAR_BAR_DEAD moves to VAR_BUDGET + 6 (+5 is VAR_F32_MODE).
- TRANSLATOR_VERSION 9.
- d3d12x/bind.rs: the bounded ExecuteIndirect call runs inside
  fresh_indirect_arguments.
- d3d12x/list_x.rs: tracked_list_type, and transition (pub(super)) over the
  batched transitions.
- recomp/mod.rs: compact backend and per-lane modules both kept; the
  oversized-structured-code fallback applies to translate after prepare.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@DavidM1911

Copy link
Copy Markdown
Contributor

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; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
`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)
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
In the per-lane direct DXIL backend (xcl-dev#1745), non-native VALU instructions
with DPP16 or DPP8 modifiers (such as float wave reductions with
v_add_f32_dpp, v_max_f32_dpp, or DPP source modifiers SRC0_ABS/SRC0_NEG)
failed to lower: `valu()` eagerly ran `self.dpp()`, DPP source modifiers
hard-refused without the `unsupported ` prefix, and `bridge()` called
`Lw::inst_guarded` with `mask = None`, causing `Lw::exec_mask()` to read
SSA EXEC (register 126) and fail the per-lane register check.

`Ir::foreign` now forwards an optional active-lane mask to
`Lw::inst_guarded`. For bridged DPP16/DPP8 instructions, `bridge()` checks
`all_lanes` when fetch-inactive (`FI`) is set and passes the half-wave
EXEC ballot (`exec_words(b, true)`). `Lw::sources` also clamps inactive
DPP16/DPP8 source lane indices to `self.lane` before `read_lane_half` so
`WaveReadLaneAt` never reads an inactive lane.

Assisted-by: Antigravity (Gemini 4 Neon)
@BetterJdue

Copy link
Copy Markdown

Test report after the merge, on native wave64 AMD RDNA2 (the reports above are RDNA3, RDNA4 and NVIDIA): main c4d37be, which has #1745 as 7f7e768.

Tested

  • AMD Radeon RX 6700 (RDNA2, native wave64), driver 32.0.21045.29003; Ryzen 5 3600; 32 GB RAM; Windows 11 Pro 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17; debug; clean worktree, own target dir.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 956 passed, 3 failed, 43 ignored. SKIPPED (8): the six per-lane refusals (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32, wave32 and wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows) and pso_measurement_compiles_an_exact_synthetic_record (Developer Mode off). No no wave64 skips.
  • The 3 failures are not from Recompiler: a per-lane form for the direct DXIL backend (XCL_PER_LANE) #1745: placed_title_textures_share_vram_and_preserve_pixels ("3D 64x64x64 4 mips: subresource 2 mismatch") also fails alone on main b9b6ea6, before the merge, and the other two fail on the lock it poisons. It is the RDNA2 failure reported fixed by D3D12.X: map and unmap 3D texture mips separately #1028.
  • cargo test -p xcl --lib -- gpu::dxil recomp::lower --test-threads=4: 130 passed, 0 failed, 1 ignored; the same six refusals SKIPPED.
  • Alone, 3 runs each, all passed, no device removal (21 of 21): wave_ops_match_cpu, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu, the_split_form_agrees_with_the_wave64_lowering_on_the_gpu, a_wave64_mask_left_behind_is_reported_in_both_halves, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, f32_programs_on_the_gpu, the_runtime_path_takes_the_split_form. On this card wave_ops_match_cpu removed the device (0x887A0005, also alone) on 164050e earlier today; it passes now.
  • XCL_ADAPTER=warp cargo test -p xcl --lib -- --test-threads=4: 907 passed, 3 failed, 23 ignored. The 3 failures are the same texture tests; with XCL_ADAPTER=warp that test fails on b9b6ea6 too, so it seems to run on the hardware adapter rather than WARP (inferred, not checked).
  • The same steps on 0570037, before the merge, gave the same picture: 924 passed, 3 failed (the same three), 42 ignored; gpu::dxil + recomp::lower 127 passed, 0 failed; the 21 runs passed.
  • A note on XCL_REQUIRE_GPU=wave64: it turns the six deliberate per-lane refusals into failures (runner.rs:469), so with it gpu::dxil + recomp::lower gives 128 passed, 2 failed. It cannot show here that the wave64 halves ran; that the plain run reports no no wave64 skip does.

Not tested

  • A title run, driver times or XCL_PER_LANE=1 at run time (no game data here).
  • Release build; mesh shaders.

AI use: Claude Code (Claude Opus 5.5) ran these tests on my machine and wrote this report.

AI-assisted verification using synthetic inputs.

raylitebull pushed a commit that referenced this pull request Nov 24, 2026
…de EXEC out

thehollowedone's program on #1269 (Pipodi's review point 3 on #1745):
EXEC = lanes 0-15 (`s_and_saveexec`), then `v_cmpx_le_f32 0, v1`, true in
every lane, then `v_mov v2, 7`. The console, the HLSL path and #1426's
per-instruction form write lanes 0-15; the per-lane form wrote all 32.
The bridge runs #1426's lowering of a float `v_cmpx` with the guard
`true`, so the lane's bit it reads back is the compare alone. The new
EXEC is now that bit and the lane's EXEC before the instruction, as the
per-lane form's own integer `v_cmpx` already did.

Test: his program on the GPU (fails without the fix in lane 16).
raylitebull pushed a commit that referenced this pull request Nov 24, 2026
…ane form

In the per-lane direct DXIL backend (#1745):
- `bridge()` rejected `V_CNDMASK_B32` / `V_ADD_CO_CI_U32` / `V_SUB_CO_CI_U32`
  / `V_SUBREV_CO_CI_U32` whenever the mask operand was not an SGPR (`m > 127`,
  such as inline carry-in `0` = 128 or `-1` = 193, or `NULL` = 125), even
  though `dxil::Lw::read64` already decodes non-SGPR mask operands without
  touching any SGPR.
- `src_bit()` accepted only SGPRs, `128` (0), and `193` (-1), refusing `NULL`
  (125), inline integer masks (`129..=192`, `194..=208`), and 32-bit literals
  (`255`).
- `src()` and `src64()` missed `125` (`NULL`).

`bridge()` now skips SGPR injection when `m > 127 || m == 125`, `src_bit()`
extracts the lane's bit from `NULL`, inline integers (sign-extended to 64 bits
for negative values), and 32-bit literals, and `src()`/`src64()` handle `125`.

Assisted-by: Antigravity (Gemini 4 Neon)
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
`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)
emirduran707 added a commit to emirduran707/xcl that referenced this pull request Nov 25, 2026
…per-lane form

`wave_salu` in the per-lane direct DXIL backend (xcl-dev#1745) handled `S_BCNT1`,
`S_BCNT0`, and `S_FF1` on mask registers, but `S_FF0_I32_B32/B64` and
`S_FLBIT_I32_B32/B64` fell through to `bridge()` and failed with
`"a mask read as a number"`.

`wave_salu` now lowers `S_FF0_I32_B32/B64` via `first_set` on the inverted
mask words and `S_FLBIT_I32_B32/B64` via leading-zero count (returning
`0xFFFFFFFF` when the input is 0, matching `emit.rs` and the RDNA2 ISA).

Assisted-by: Antigravity (Gemini 4 Neon)
emirduran707 added a commit to emirduran707/xcl that referenced this pull request Nov 25, 2026
In the per-lane direct DXIL backend (xcl-dev#1745), non-native VALU instructions
with DPP16 or DPP8 modifiers (such as float wave reductions with
v_add_f32_dpp, v_max_f32_dpp, or DPP source modifiers SRC0_ABS/SRC0_NEG)
failed to lower: `valu()` eagerly ran `self.dpp()`, DPP source modifiers
hard-refused without the `unsupported ` prefix, and `bridge()` called
`Lw::inst_guarded` with `mask = None`, causing `Lw::exec_mask()` to read
SSA EXEC (register 126) and fail the per-lane register check.

`Ir::foreign` now forwards an optional active-lane mask to
`Lw::inst_guarded`. For bridged DPP16/DPP8 instructions, `bridge()` checks
`all_lanes` when fetch-inactive (`FI`) is set and passes the half-wave
EXEC ballot (`exec_words(b, true)`). `Lw::sources` also clamps inactive
DPP16/DPP8 source lane indices to `self.lane` before `read_lane_half` so
`WaveReadLaneAt` never reads an inactive lane.

Assisted-by: Antigravity (Gemini 4 Neon)
emirduran707 added a commit to emirduran707/xcl that referenced this pull request Nov 25, 2026
In the per-lane direct DXIL backend (xcl-dev#1745), non-native VALU instructions
with DPP16 or DPP8 modifiers (such as float wave reductions with
v_add_f32_dpp, v_max_f32_dpp, or DPP source modifiers SRC0_ABS/SRC0_NEG)
failed to lower: `valu()` eagerly ran `self.dpp()`, DPP source modifiers
hard-refused without the `unsupported ` prefix, and `bridge()` called
`Lw::inst_guarded` with `mask = None`, causing `Lw::exec_mask()` to read
SSA EXEC (register 126) and fail the per-lane register check.

`Ir::foreign` now forwards an optional active-lane mask to
`Lw::inst_guarded`. For bridged DPP16/DPP8 instructions, `bridge()` checks
`all_lanes` when fetch-inactive (`FI`) is set and passes the half-wave
EXEC ballot (`exec_words(b, true)`). `Lw::sources` also clamps inactive
DPP16/DPP8 source lane indices to `self.lane` before `read_lane_half` so
`WaveReadLaneAt` never reads an inactive lane.

Assisted-by: Antigravity (Gemini 4 Neon)
BetterJdue added a commit to BetterJdue/xcl that referenced this pull request Nov 25, 2026
…grams (xcl-dev#1269)

Since xcl-dev#1426 and xcl-dev#1745 a compute program can reach DXIL three ways: the
HLSL path and DXC, the direct translator (XCL_DIRECT_DXIL=1) and the
per-lane form (XCL_PER_LANE=1). The benchmark timed only the first, so it
could not say what the direct paths save on the same programs, or which
programs they refuse.

Every program now also goes through coverage::translate_mode (the
direct translator) and, for compute programs, lower_dxil::compute_with
(the per-lane form, as pso.rs calls it), with the same repeats as DXC.
The result must be the same on a second translation and pass the DXC
validator (not timed); a refusal is recorded with its reason, not a
failure. The rows get time, DXIL size and refusal per path, and the
summary the number translated, their total time and the per-lane
refusals of compute programs (kernels are not offered to it, as in
pso.rs). A cs-uniform shape (compute, no divergent ifs, no global or
scalar memory) is what the per-lane form takes on the small, full and
large sets: the per-lane form refuses divergent ifs ("a value
written while some lanes were elsewhere, read after they met again")
and global / scalar loads ("s0: a mask read as a number").

Nothing in crates/xcl/src changes: both entry points are public.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.