Skip to content

Recompiler: VS / PS in the per-lane form as DXIL - #1839

Draft
teidenzero wants to merge 1 commit into
xcl-dev:mainfrom
teidenzero:vsps-dxil-main
Draft

teidenzero wants to merge 1 commit into
xcl-dev:mainfrom
teidenzero:vsps-dxil-main

Conversation

@teidenzero

@teidenzero teidenzero commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

The DXIL adapter's half of the per-lane VS / PS stages: a follow-up to #1745, whose description lists VS / PS with only its lowering half. Part of #1269. The runtime does not call the VS / PS entry points yet (pso.rs sends only compute programs to the per-lane form), so nothing changes outside the tests.

What is in it (one commit)

The exports write #1426's output temporaries. These reach finish_gfx in the exit block through Lw's SSA, because the adapter's branches go through Lw (gefydev's point on #1269), so the lowering needs no variable of its own for them.

Tested

  • NVIDIA GeForce RTX 4090 24 GB (32-lane waves, so the wave64 stages run in 32-lane waves), driver 621.24; AMD Ryzen 7 3700X; Windows 10 Pro 22H2 build 19045.6466 with the D3D12 Agility SDK 1.620.2; Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug; DXC 1.8.2502.11 from the Windows SDK, without dxil.dll.
  • cargo test --workspace -- --test-threads=1 on main 1a0bbe3 with this commit (be458bf): 1251 passed, 0 failed, 46 ignored over the workspace (lib: 1182 passed, 0 failed, 26 ignored). SKIPPED (25): 20 "no wave64" (this GPU), 1 "no heap windows", 1 "no dxil.dll", and the 3 per-lane refusals main makes on purpose (V_CVT_F16_F32, V_MUL_F16, V_PK_MUL_F16). With four threads (.\scripts\test.ps1), the D3D12 device was removed during hle::d3d12x::list_x's queue tests, and 3 of them failed with 0x887A0005. Those tests pass on their own and in the one-thread run, and this commit does not touch them.
  • The new test: a VS and a PS whose exports follow a branch (the stages of dxil core_tests::graphics_stages_with_a_branch_before_their_exports), in the per-lane form, draw what the HLSL path's stages draw for both branch directions, and each links with the HLSL path's other stage. It fails without the bridge change (the VS is refused) and with the adapter's branches bypassing Lw (the VS then fails validation).
  • @thehollowedone, on 61f6c2d (RTX 3080 Ti, Windows 11, comment): the new test passes in debug and in release; with discard cases added to it (every column kept, columns 8–15 kept, none kept), the HLSL path, gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's per-instruction DXIL and the per-lane DXIL give identical readbacks.
  • @vitor127wt, on 61f6c2d (RTX 5070 Ti, Linux, Proton, comment): the new test passes in a release build under Wine.
  • @DavidM1911, on 61f6c2d merged with main (RTX 3060 Ti, Windows 11, comment): cargo test -p xcl --lib passes.
  • @Chrysana, on be458bf (RX 9070 XT, RDNA4, and a Ryzen 7 9800X3D's RDNA2 iGPU; Windows 11; comment): the new test passes on both adapters. Both report 32 and 64 lanes, so the test builds the stages in the form that checks the wave size at run time. A probe with plain HLSL stages shows the driver picks 64-lane waves for the PS on both and for the VS on RDNA4, so the 64-lane path runs there. Their 4-thread workspace run: 1249 passed, 2 failed (the AMD fuzz seeds of DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #2115, which main fails the same way on that card), 46 ignored.

Regression run
Not run: there is no Series X|S title on this machine. No title program reaches this code yet (nothing calls lower_dxil::vertex / pixel at run time), so a smoke pair could not exercise it; whether the pair can wait for the VS / PS runtime wiring is asked in the comments. This PR stays a draft until that is settled.

Not tested

  • A title.
  • Which wave size the driver picks for the per-lane containers themselves: Chrysana's probe used plain HLSL stages.
  • A PS whose lane reads depend on helper lanes.
  • The runtime wiring of VS / PS (not part of this PR).

AI use

  • Claude Code (Claude Opus 5.5): wrote the change and the test, ran the checks above, and drafted this description.

🤖 Generated with Claude Code

@thehollowedone

Copy link
Copy Markdown

Tested

On 61f6c2d6, I extended the stock VS/PS draw fixture to check discard. With the same HLSL vertex shader, HLSL, per-instruction DXIL and per-lane DXIL produced identical 16×16 readbacks for all three settings.

  • Keeping every column wrote 256 pixels.
  • Keeping only columns 8–15 wrote 128 pixels and left columns 0–7 at the clear value.
  • Discarding every column left all 256 pixels at the clear value.

The fixture compares positive screen coordinates with an integer V_CMPX_LT_U32 before the final export. Windows 11 build 26300, RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, Rust 1.99.1 MSVC, DXC 1.8.2502.11. cargo test --offline --locked -p xcl --lib per_lane_vs_and_ps_with_a_branch_before_their_exports_draw_as_the_hlsl_path -- --nocapture --test-threads=1 passed 1/1 as shipped and 1/1 with the added discard cases in debug, with zero skips. The stock test also passed 1/1 in release.

Not tested

This report covers synthetic wave32-adapter draws. It does not cover helper-lane reads, native wave64, or runtime routing.

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

@vitor127wt

Copy link
Copy Markdown

Requested retail smoke pair and VS/PS test — RTX 5070 Ti / Proton

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 and dxil-spirv 7c048638. Rust 1.100.0, LLVM-MinGW 20261117 (x86_64-pc-windows-gnullvm), DXC 1.9.2609.5.
  • Clean release builds with cargo build --locked --release --target x86_64-pc-windows-gnullvm -p xcl --bin xcl. Ran scripts/linux/smoke.sh "$PROTON" "$PREFIX" "$GAME" from Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257 for 60 s on main 266b845e4b2a193ea7ce1b86698ead08dc4a10c0 and PR head 61f6c2d6d0abd4d2114372b139ea6cfaf4af8e7f, same retail title with no injected input. The title runs used fresh Wine prefixes and caches, networking off, and a 16 GiB Linux scope limit with no swap.
  • Built the release library test with cargo test --locked --release --target x86_64-pc-windows-gnullvm -p xcl --lib --no-run. Ran gpu::recomp::lower_dxil::tests::per_lane_vs_and_ps_with_a_branch_before_their_exports_draw_as_the_hlsl_path --exact --test-threads=1 --nocapture in Proton Wine on the PR. 1 passed, 0 failed, 0 ignored, 0 skipped.

Regression run

The requested pair below comes from the Wine smoke script. I abbreviated the local folder name in the title field.

main

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

PR head

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

Linux scope peaks were 9.56 GiB (base) and 6.61 GiB (PR), with no OOM kills. Wine reported 0 MB in the Windows peak-commit field. The retail pair covers startup. The VS/PS path ran in the synthetic test.

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

@teidenzero

Copy link
Copy Markdown
Contributor Author

Thank you @thehollowedone and @vitor127wt for the runs on 61f6c2d. Your test results (the discard cases, the release builds, the run under Proton) are now under Tested in the description.

On the smoke pair, a question for @gefydev and the maintainers. The pair above comes from the Wine smoke script in #257, and CONTRIBUTING asks for scripts/smoke.ps1. More to the point, no title program reaches this code yet: pso.rs sends only compute programs to the per-lane form, and nothing calls lower_dxil::vertex / pixel at run time, so a smoke pair cannot exercise it. Can this PR go without the pair, or should the pair come with the VS / PS runtime wiring, where a title run tests the path for real? Until then this PR stays a draft.

AI use: Claude Code (Claude Opus 5.5) drafted this comment.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
The DXIL adapter's half of the VS / PS stages (xcl-dev#1269):

- `DxilIr` sets a VS / PS up in `Lw`'s entry block, as `kernel.rs` does:
  `setup_lanes_gfx`, then xcl-dev#1426's `setup_vertex` / `setup_pixel`, whose
  input loads must come before every use. `graphics_start` hands the
  lowering the initial VGPRs and the lane's bit of the launch EXEC
  (`ballot(true)`, without a PS's helper lanes); `graphics_end` is xcl-dev#1426's
  `finish_gfx`.
- A VS / PS's ballots and lane reads go through `Lw`'s `ballot`, `rla` and
  `read_lane_half`, which know a wave32 program's half in 64-lane hardware
  and see a PS's helper lanes through quad reads.
- `lower_dxil::vertex` / `pixel` give the signed containers.
- The bridge passes an export's EXEC only as the guard, which xcl-dev#1426's
  `export_gfx` takes, as it does for `v_cmpx`: passed as a number, EXEC
  refused every export ("s126: a mask read as a number").

The exports write xcl-dev#1426's output temporaries. These reach `finish_gfx` in
the exit block through `Lw`'s SSA, since the adapter's branches go through
`Lw` (gefydev's point in xcl-dev#1269), so the lowering needs no variable of its
own for them.

Tested on an RTX 4090 (32-lane waves; Windows 10 22H2, DXC 1.8.2502):
- per_lane_vs_and_ps_with_a_branch_before_their_exports_draw_as_the_hlsl_path
  (new): a VS and a PS whose exports follow a branch draw what the HLSL
  path's stages draw for both branch directions, and each links with the
  HLSL path's other stage. It fails without the bridge change (the VS is
  refused) and with the adapter's branches bypassing `Lw` (the VS fails
  validation);
- cargo test --workspace -- --test-threads=1 on main 1a0bbe3 with this
  commit: 1251 passed, 0 failed, 46 ignored (lib 1182 passed); every
  test binary passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@teidenzero

Copy link
Copy Markdown
Contributor Author

Rebased onto main 1a0bbe3 as be458bf. The only conflict was in lower_dxil.rs's tests: the tests from #1864 and #1865 had been added in the same spot as the new one. All three tests are kept. cargo test --workspace -- --test-threads=1: 1251 passed, 0 failed, 46 ignored. Thanks @DavidM1911 for the run on the merged branch.

@emirduran707, @AlpPesen: you ran scripts/smoke.ps1 pairs on an AMD card for your per-lane PRs (#1864, #2014). I have no Series X|S title of my own, so this PR can't carry the pair without help. If one of you has time, two things would let it leave draft:

  • a smoke pair: one build from main 1a0bbe3 and one from be458bf, same title and seconds. No title program reaches the new entry points yet, so the two runs should match.
  • cargo test -p xcl --lib -- per_lane_vs_and_ps: on AMD the stages run in native wave64, which no one has tested yet.

AI use: Claude Code (Claude Opus 5.5) drafted this comment.

@Chrysana

Copy link
Copy Markdown

AMD run of be458bf, for "Native wave64 (no AMD GPU here)" under Not tested. On RDNA4 the per-lane VS and PS run in 64-lane hardware waves, and the new test passes there. It also passes on an RDNA2 iGPU, where the PS runs in 64-lane waves and the VS in 32-lane waves.

Setup: AMD Radeon RX 9070 XT 16 GB (RDNA4), driver 32.0.32015.2008, and the Ryzen 7 9800X3D's integrated AMD Radeon(TM) Graphics (RDNA2), driver 32.0.21045.11001; 31 GB RAM, Windows 11 26200.9974, rustc 1.100.0 MSVC, DXC 1.9.2602.17, debug. This PR's head as pushed (on main 1a0bbe3).

Tested

  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 on the RX 9070 XT: 1249 passed, 2 failed, 46 ignored. The two failures are fuzz_validate_and_gpu_1 (seed 722) and fuzz_validate_and_gpu_3 (seed 1599), the AMD seeds of DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #2115; main 06c9f55 fails the same two on this card.
  • SKIPPED: f16_programs_on_the_gpu (4) and f32_programs_on_the_gpu (2) (per-lane refusals, gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), pso_measurement_compiles_an_exact_synthetic_record (no Developer Mode), test_title_draws_with_a_root_signature_under_the_debug_layer and uploads_start_from_each_subresources_state (no debug layer).
  • per_lane_vs_and_ps_with_a_branch_before_their_exports_draw_as_the_hlsl_path passes on both adapters (XCL_ADAPTER=1 for the iGPU).
  • Which hardware wave the per-lane VS / PS get. Both adapters report 32 and 64 lanes, so graphics_wave32() is true and the stages are built wave-size independent. For a VS / PS, kernel.rs finish doesn't use hw, so the container carries no wave size and the driver picks one. A local probe (not pushed) draws with a plain HLSL VS and PS that write WaveGetLaneCount() from both stages and WaveActiveCountBits(true) from the PS, on 8×8 and 64×64 targets:
adapter PS lanes per wave PS active lanes per wave VS lanes per wave
RX 9070 XT (RDNA4) 64 64 64
Radeon iGPU (RDNA2) 64 64 32

So on these cards the new test's per-lane stages run in 64-lane hardware waves (the PS on both, the VS on RDNA4). That is the case read_lane_half handles and a 32-lane-only GPU can't reach.

Not tested

  • The probe measures what the driver picks for a plain HLSL shader. I assume it picks the same for the per-lane containers, but didn't probe them directly.
  • A title run: the runtime doesn't call the VS / PS entry points yet.
  • This head merged onto current main.

AI use

  • Claude Code (Claude Opus 5.5) built the tree, wrote and ran the local probe, ran the suite and drafted this comment. I checked it before posting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants