Recompiler: resolve lanes 32-63 of split wave64 VS / PS in direct DXIL #3795

Open
raylitebull wants to merge 2 commits from upstream-pr/3795 into main
raylitebull commented 2026-12-03 15:24:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-12-03T15:24:09Z.


Stacked on #3793; only the top commit (1c938a8f) belongs here.

A wave64 VS / PS takes the 32-lane form wherever the driver may run it in waves of 32 (pso::graphics_wave32, which is true on any adapter whose wave range starts at 32, RDNA included). In that form the direct DXIL translator refused it as soon as upper_lanes found a read of lanes 32–63 that was not Native: wave64 VS / PS in 32-lane waves: a read of lanes 32–63 (dxil/kernel.rs). This change resolves those reads the way the HLSL emitter does (Em::upper), so that refusal is gone. It was the last upper_lanes refusal for VS / PS.

What is in it

  • dxil/kernel.rs: the refusal is removed. Outside the 32-lane form Read::Const becomes Native (as recomp::translate does). GfxLanes is set up when there is a shadowed slot or a constant read. As the HLSL path does, ds_permute_b32 in the 32-lane form is still refused, because upper_lanes does not follow its writes to lanes 32–63. Direct DXIL does not lower it in a VS / PS today (LDS outside compute), so this only keeps that refusal in place if #2228 lands.
  • dxil/lower_gfx.rs: GfxLanes::hw32 is WaveGetLaneCount() < 64 (xcl_hw32). Lw::upper_const gives select(hw32 && lane >= 32, c, read).
  • dxil/lower_valu.rs (v_readlane) and dxil/lower_mem.rs (ds_bpermute, before its EXEC select, as in the HLSL path) use it. Read::Shadow in the 32-lane form uses #3793's shadows. Read::Unknown stays a native read, which is what the HLSL path emits too; wave_hazards reports it either way.
  • Tests:
    • dxil::core_tests::wave64_graphics_with_upper_lane_reads_refused_in_32_lane_mode asserted the refusal this change removes, so it is now wave64_graphics_upper_lane_reads_translate_in_32_lane_mode. It covers a constant lane 63, a lane from an SGPR, ds_bpermute, and an unknown upper lane, in VS and PS and in both forms. Each translates and validates. The disassembly has waveGetLaneCount and a select … i32 5 for the constants in the 32-lane form only; there is none for the unknown read or in the 64-lane form. coverage::translate_mode returns Ok, and a split PS with ds_permute_b32 is refused.
    • recomp::tests::wave64_graphics_spill_shadows_cover_native_partial_waves now expects both forms to translate.
    • The direct VS / PS draws that #3793 added to the GPU tests now use the adapter's form (runner::graphics_wave32()). The VS test also checks the lane-32 identity on direct DXIL wherever it checks it on the HLSL path.

Direct-DXIL fallbacks left for VS / PS / MS / GS in crates/xcl/src/gpu/dxil/, read from the code, not counted on a corpus:

  • VS / PS:
    • graphics whole-wave reduction needs the HLSL path (kernel.rs, graphics_reductions).
    • LDS in a VS / PS, ds_permute_b32 included (LDS outside compute), and GDS (lower_mem.rs).
    • Unknown export targets (export target).
    • v_interp_mov p10 / p20, other v_interp forms, and an attribute outside ISG1 (lower_gfx.rs).
    • Outside gpu/dxil: an FSPX container in a graphics slot (recomp/pso.rs). PSOs with HS / DS never reach a translator (d3d12x/real.rs).
  • GS (geometry mode): split wave64 geometry: the ES phase exchanges at group barriers (kernel.rs). This applies in the split form with the safe barrier, which is the default.
  • MS: nothing specific to the stage. split wave64 LDS access needs the HLSL path applies only with XCL_X_LDS_ORDER=0 (CS too).
  • Every stage: non-default or dynamic f32 / f64 round modes, s_getreg, an indirect branch, a scalar movrel register, and encodings or opcodes not lowered yet (lower.rs and friends).

Tested

  • Linux x86_64 (Ubuntu 24.04), no GPU, rustc 1.99.0. cargo check --workspace --all-targets --target x86_64-pc-windows-gnu builds, with the same warnings as main a815de93 (39 lib, 20 lib test) and none in the changed files. git diff --check is clean.
  • Lib tests were cross-built (x86_64-pc-windows-gnu, debug) and run under Wine 9.0 with DXC 1.10.2611's dxcompiler.dll / dxil.dll (XCL_DXC_DIR), so IDxcValidator and the disassembler ran. There is no GPU, so every GPU test printed SKIPPED (no GPU). Each module ran in its own process with 2 threads; the uma_driver group was left out.
    • this PR (1c938a8f): 2547 passed, 75 failed, 35 ignored; hle::netoff::tests timed out (Wine sockets).
    • main a815de93, same setup: 2545 passed, 76 failed, 35 ignored; hle::netoff::tests timed out.
    • No test fails only with this PR. The +2 passed are the new test of #3793, and hle::d3d12x::frame::tests::origin_events_issue_tokens_and_flips_have_statistics, which failed on the main run (timing under Wine). The other failures are the same as on main.

Regression run
Pending: scripts/smoke.ps1 from main and from this head, on Windows with an RX 9070 XT, still to be run.

Not tested

  • Windows, any GPU: the GPU tests (direct VS / PS draws in the adapter's form) were skipped here, and IDxcValidator was not run on Windows.
  • A GPU with only 32-lane waves (NVIDIA), where xcl_hw32 is always true.
  • scripts/smoke.ps1 and the whole suite on a GPU (pending, RX 9070 XT).
  • How many retail shaders now stay direct (xcl shaders --direct): no game data here.

AI use

  • Capy (Claude Opus 5.5) wrote the code, the tests and this description, and ran the builds and the Wine test runs above.

Open in Capy

<!-- greyfinch-sync:ivall/xcl:issue:5629463983 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3795). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-12-03T15:24:09Z. --- Stacked on #3793; only the top commit (1c938a8f) belongs here. A wave64 VS / PS takes the 32-lane form wherever the driver may run it in waves of 32 (`pso::graphics_wave32`, which is true on any adapter whose wave range starts at 32, RDNA included). In that form the direct DXIL translator refused it as soon as `upper_lanes` found a read of lanes 32–63 that was not `Native`: `wave64 VS / PS in 32-lane waves: a read of lanes 32–63` (`dxil/kernel.rs`). This change resolves those reads the way the HLSL emitter does (`Em::upper`), so that refusal is gone. It was the last `upper_lanes` refusal for VS / PS. **What is in it** - `dxil/kernel.rs`: the refusal is removed. Outside the 32-lane form `Read::Const` becomes `Native` (as `recomp::translate` does). `GfxLanes` is set up when there is a shadowed slot or a constant read. As the HLSL path does, `ds_permute_b32` in the 32-lane form is still refused, because `upper_lanes` does not follow its writes to lanes 32–63. Direct DXIL does not lower it in a VS / PS today (`LDS outside compute`), so this only keeps that refusal in place if #2228 lands. - `dxil/lower_gfx.rs`: `GfxLanes::hw32` is `WaveGetLaneCount() < 64` (`xcl_hw32`). `Lw::upper_const` gives `select(hw32 && lane >= 32, c, read)`. - `dxil/lower_valu.rs` (`v_readlane`) and `dxil/lower_mem.rs` (`ds_bpermute`, before its EXEC select, as in the HLSL path) use it. `Read::Shadow` in the 32-lane form uses #3793's shadows. `Read::Unknown` stays a native read, which is what the HLSL path emits too; `wave_hazards` reports it either way. - Tests: - `dxil::core_tests::wave64_graphics_with_upper_lane_reads_refused_in_32_lane_mode` asserted the refusal this change removes, so it is now `wave64_graphics_upper_lane_reads_translate_in_32_lane_mode`. It covers a constant lane 63, a lane from an SGPR, `ds_bpermute`, and an unknown upper lane, in VS and PS and in both forms. Each translates and validates. The disassembly has `waveGetLaneCount` and a `select … i32 5` for the constants in the 32-lane form only; there is none for the unknown read or in the 64-lane form. `coverage::translate_mode` returns Ok, and a split PS with `ds_permute_b32` is refused. - `recomp::tests::wave64_graphics_spill_shadows_cover_native_partial_waves` now expects both forms to translate. - The direct VS / PS draws that #3793 added to the GPU tests now use the adapter's form (`runner::graphics_wave32()`). The VS test also checks the lane-32 identity on direct DXIL wherever it checks it on the HLSL path. **Direct-DXIL fallbacks left for VS / PS / MS / GS** in `crates/xcl/src/gpu/dxil/`, read from the code, not counted on a corpus: - VS / PS: - `graphics whole-wave reduction needs the HLSL path` (`kernel.rs`, `graphics_reductions`). - LDS in a VS / PS, `ds_permute_b32` included (`LDS outside compute`), and GDS (`lower_mem.rs`). - Unknown export targets (`export target`). - `v_interp_mov` p10 / p20, other `v_interp` forms, and an attribute outside ISG1 (`lower_gfx.rs`). - Outside `gpu/dxil`: an FSPX container in a graphics slot (`recomp/pso.rs`). PSOs with HS / DS never reach a translator (`d3d12x/real.rs`). - GS (geometry mode): `split wave64 geometry: the ES phase exchanges at group barriers` (`kernel.rs`). This applies in the split form with the safe barrier, which is the default. - MS: nothing specific to the stage. `split wave64 LDS access needs the HLSL path` applies only with `XCL_X_LDS_ORDER=0` (CS too). - Every stage: non-default or dynamic f32 / f64 round modes, `s_getreg`, an indirect branch, a scalar movrel register, and encodings or opcodes not lowered yet (`lower.rs` and friends). **Tested** - Linux x86_64 (Ubuntu 24.04), no GPU, rustc 1.99.0. `cargo check --workspace --all-targets --target x86_64-pc-windows-gnu` builds, with the same warnings as `main` a815de93 (39 lib, 20 lib test) and none in the changed files. `git diff --check` is clean. - Lib tests were cross-built (`x86_64-pc-windows-gnu`, debug) and run under Wine 9.0 with DXC 1.10.2611's `dxcompiler.dll` / `dxil.dll` (`XCL_DXC_DIR`), so `IDxcValidator` and the disassembler ran. There is no GPU, so every GPU test printed `SKIPPED` (no GPU). Each module ran in its own process with 2 threads; the `uma_driver` group was left out. - this PR (1c938a8f): 2547 passed, 75 failed, 35 ignored; `hle::netoff::tests` timed out (Wine sockets). - `main` a815de93, same setup: 2545 passed, 76 failed, 35 ignored; `hle::netoff::tests` timed out. - No test fails only with this PR. The +2 passed are the new test of #3793, and `hle::d3d12x::frame::tests::origin_events_issue_tokens_and_flips_have_statistics`, which failed on the `main` run (timing under Wine). The other failures are the same as on `main`. **Regression run** Pending: `scripts/smoke.ps1` from `main` and from this head, on Windows with an RX 9070 XT, still to be run. **Not tested** - Windows, any GPU: the GPU tests (direct VS / PS draws in the adapter's form) were skipped here, and `IDxcValidator` was not run on Windows. - A GPU with only 32-lane waves (NVIDIA), where `xcl_hw32` is always true. - `scripts/smoke.ps1` and the whole suite on a GPU (pending, RX 9070 XT). - How many retail shaders now stay direct (`xcl shaders --direct`): no game data here. **AI use** - Capy (Claude Opus 5.5) wrote the code, the tests and this description, and ran the builds and the Wine test runs above. <!-- capy-badge:start --> <a href="https://capy.ai/thread/jam_01M8Y3KKSE9T4CH7MFPBMHK0JK"><picture><source media="(prefers-color-scheme: dark)" srcset="https://capy.ai/badge/accent-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://capy.ai/badge/accent-light.svg"><img alt="Open in Capy" src="https://capy.ai/badge/accent-light.svg"></picture></a> <!-- capy-badge:end -->
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3795:upstream-pr/3795'
git switch 'upstream-pr/3795'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3795'
git switch 'upstream-pr/3795'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3795'
git switch 'upstream-pr/3795'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3795'
git switch 'main'
git merge --squash 'upstream-pr/3795'
git switch 'main'
git merge --ff-only 'upstream-pr/3795'
git switch 'main'
git merge 'upstream-pr/3795'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3795
No description provided.