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.
  • .\scripts\test.ps1 on main 266b845 with this commit (61f6c2d): 958 passed, 0 failed, 42 ignored over the workspace (lib: 909 passed, 0 failed, 22 ignored). SKIPPED (23): 18 "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). The commit merges cleanly with main 4e3515e.
  • 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.

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

  • Native wave64 (no AMD GPU here), and a title.
  • 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

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);
- .\scripts\test.ps1 on main 266b845 with this commit: 958 passed,
  0 failed, 42 ignored over the workspace (lib 909 passed); every test
  binary passed.

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

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.

4 participants