Recompiler: route every shader stage through direct DXIL by default #3243

Merged
Foniass merged 1 commit from upstream-pr/3243 into main 2026-11-28 23:54:56 +00:00
Foniass commented 2026-11-28 23:52:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-11-28T23:52:12Z.


Makes XCL_DIRECT_DXIL=all the default, as the maintainer asked: when the variable is unset, console compute, vertex and pixel shaders go through the direct DXIL translator. Each stage still falls back to the HLSL path on its own when the translator cannot handle it. XCL_DIRECT_DXIL=1 keeps the compute-only routing, and a new XCL_DIRECT_DXIL=0 restores the previous default (the HLSL path, plus the huge-program direct route).

What is in it

  • crates/xcl/src/gpu/dxil/kernel.rs: enabled() / enabled_graphics() read the variable through one routing() function (0 none, 1 compute, anything else both), with a unit test direct_dxil_all_is_the_default
  • crates/xcl/src/gpu/recomp/pso.rs: two comments that said "without XCL_DIRECT_DXIL" now say =0
  • README.md: a "Shader translation" bullet for the new default and the 0 / 1 settings

Tested

  • NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2114), AMD Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), debug build for the tests, release for the smoke runs
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on ab375836: 2592 passed, 4 failed, 49 ignored
    • the 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3: CreateComputePipelineState returns E_OUTOFMEMORY (0x8007000E) on this card. They fail in the same way on main (227d2cb3), so this PR does not cause them.
    • SKIPPED GPU tests: 30, almost all no wave64 (32-lane GPU); also two_pass_binds_set_the_shared_view_heap (no heap windows) and pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache)
  • Retail title, 60 s smoke run: no device removal and no crash; 1597 frames against main's 1661 (96 %); peak commit 17416 MB against 17074 MB. The log shows 138 stages falling back to HLSL: 84 CS + 2 MS with s_barrier in a group of several hardware waves, 41 PS with a wave64 v_writelane spill, and 11 PS reading lanes 32–63 in 32-lane waves.

Regression run

main:

xcl-smoke v1
commit: 227d2cb388f103268dac7635ea720eb3e5352d4e
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1661 (PresentX 1661)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17074 MB

this PR:

xcl-smoke v1
commit: ab37583671d8ed03c40ccef27821397f52594980
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1597 (PresentX 1597)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 17416 MB

Not tested

  • AMD GPUs and wave64 hardware: the tests and the smoke run were on NVIDIA only
  • Whether the direct VS / PS output looks the same as the HLSL path's: the smoke run counts frames and nobody compared the image
  • Effect on existing users' disk caches: the default backend identity changes, so the first run will probably translate the shaders again (not measured)
  • docs/specs/2026-11-24-direct-dxil.md still describes direct DXIL as behind XCL_DIRECT_DXIL=1 / =all; this PR makes that statement out of date (not edited here)

AI use

  • Claude Code with Claude Opus 5.5: wrote the change, the test and this description, and ran the tests and smoke runs on the hardware above

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5545786850 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3243). Originally posted by [Foniass](https://github.com/Foniass) on 2026-11-28T23:52:12Z. --- Makes `XCL_DIRECT_DXIL=all` the default, as the maintainer asked: when the variable is unset, console compute, vertex and pixel shaders go through the direct DXIL translator. Each stage still falls back to the HLSL path on its own when the translator cannot handle it. `XCL_DIRECT_DXIL=1` keeps the compute-only routing, and a new `XCL_DIRECT_DXIL=0` restores the previous default (the HLSL path, plus the huge-program direct route). **What is in it** - `crates/xcl/src/gpu/dxil/kernel.rs`: `enabled()` / `enabled_graphics()` read the variable through one `routing()` function (`0` none, `1` compute, anything else both), with a unit test `direct_dxil_all_is_the_default` - `crates/xcl/src/gpu/recomp/pso.rs`: two comments that said "without `XCL_DIRECT_DXIL`" now say `=0` - `README.md`: a "Shader translation" bullet for the new default and the `0` / `1` settings **Tested** - NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2114), AMD Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), debug build for the tests, release for the smoke runs - `cargo test --workspace --no-fail-fast -- --test-threads=4` on ab375836: 2592 passed, 4 failed, 49 ignored - the 4 failures are `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3`: `CreateComputePipelineState` returns `E_OUTOFMEMORY` (0x8007000E) on this card. They fail in the same way on main (227d2cb3), so this PR does not cause them. - SKIPPED GPU tests: 30, almost all `no wave64` (32-lane GPU); also `two_pass_binds_set_the_shared_view_heap` (no heap windows) and `pso_measurement_compiles_an_exact_synthetic_record` (cannot disable the driver cache) - Retail title, 60 s smoke run: no device removal and no crash; 1597 frames against main's 1661 (96 %); peak commit 17416 MB against 17074 MB. The log shows 138 stages falling back to HLSL: 84 CS + 2 MS with `s_barrier in a group of several hardware waves`, 41 PS with a wave64 `v_writelane` spill, and 11 PS reading lanes 32–63 in 32-lane waves. **Regression run** main: ``` xcl-smoke v1 commit: 227d2cb388f103268dac7635ea720eb3e5352d4e gpu: NVIDIA GeForce RTX 5070 Ti title: 3cb1d8e0 seconds: 60 exit: 0x0 frames shown: 1661 (PresentX 1661) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 17074 MB ``` this PR: ``` xcl-smoke v1 commit: ab37583671d8ed03c40ccef27821397f52594980 gpu: NVIDIA GeForce RTX 5070 Ti title: 3cb1d8e0 seconds: 60 exit: 0x0 frames shown: 1597 (PresentX 1597) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 17416 MB ``` **Not tested** - AMD GPUs and wave64 hardware: the tests and the smoke run were on NVIDIA only - Whether the direct VS / PS output looks the same as the HLSL path's: the smoke run counts frames and nobody compared the image - Effect on existing users' disk caches: the default backend identity changes, so the first run will probably translate the shaders again (not measured) - `docs/specs/2026-11-24-direct-dxil.md` still describes direct DXIL as behind `XCL_DIRECT_DXIL=1` / `=all`; this PR makes that statement out of date (not edited here) **AI use** - Claude Code with Claude Opus 5.5: wrote the change, the test and this description, and ran the tests and smoke runs on the hardware above 🤖 Generated with [Claude Code](https://claude.com/claude-code)
thehollowedone commented 2026-12-01 03:04:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-12-01T03:04:50Z.


Source follow-up to the graphics direct-DXIL default on current main d0832e61: a vertex shader's POS1 layer and viewport exports are missing from the direct path.

setup_vertex declares position and ranked parameters, but ranked excludes the layer and viewport system values. export_gfx then ignores POS1 (TGT=13). The HLSL path emits SV_RenderTargetArrayIndex and SV_ViewportArrayIndex from POS1.Z. This leaves direct DXIL without those outputs when a VS signature requests them.

A bounded fix is to declare each requested system value as a scalar unsigned VS output and, when POS1.Z is enabled, write z & 0x7ff for the layer and (z >> 16) & 0xf for the viewport. The existing POS1 fixture can be mirrored for the direct translator with z = 0x00030005: assert layer 5 and viewport 3, plus the absent-output and disabled-Z cases. A direct-DXIL-versus-HLSL draw with a layered render target would then check observable parity.

This is a source finding; I have not run that regression or linked it to the AMD driver crash in #3544. AI use: Codex (GPT-6.2 Sol) traced the current path; Codex (GPT-6.2 Astra) independently checked the gap and the test shape.

<!-- greyfinch-sync:ivall/xcl:comment:7299300596 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3243#issuecomment-7299300596). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-12-01T03:04:50Z. --- Source follow-up to the graphics direct-DXIL default on current [`main` `d0832e61`](https://github.com/xcl-dev/xcl/commit/d0832e614fa7d6ae027bb4feb27ccb9121f54a8f): a vertex shader's POS1 layer and viewport exports are missing from the direct path. [`setup_vertex`](https://github.com/xcl-dev/xcl/blob/d0832e614fa7d6ae027bb4feb27ccb9121f54a8f/crates/xcl/src/gpu/dxil/lower_gfx.rs#L102-L126) declares position and `ranked` parameters, but [`ranked`](https://github.com/xcl-dev/xcl/blob/d0832e614fa7d6ae027bb4feb27ccb9121f54a8f/crates/xcl/src/gpu/recomp/mod.rs#L534-L543) excludes the layer and viewport system values. [`export_gfx`](https://github.com/xcl-dev/xcl/blob/d0832e614fa7d6ae027bb4feb27ccb9121f54a8f/crates/xcl/src/gpu/dxil/lower_gfx.rs#L313-L328) then ignores POS1 (`TGT=13`). The [HLSL path](https://github.com/xcl-dev/xcl/blob/d0832e614fa7d6ae027bb4feb27ccb9121f54a8f/crates/xcl/src/gpu/recomp/emit.rs#L2358-L2371) emits `SV_RenderTargetArrayIndex` and `SV_ViewportArrayIndex` from POS1.Z. This leaves direct DXIL without those outputs when a VS signature requests them. A bounded fix is to declare each requested system value as a scalar unsigned VS output and, when POS1.Z is enabled, write `z & 0x7ff` for the layer and `(z >> 16) & 0xf` for the viewport. The [existing POS1 fixture](https://github.com/xcl-dev/xcl/blob/d0832e614fa7d6ae027bb4feb27ccb9121f54a8f/crates/xcl/src/gpu/recomp/tests.rs#L6431-L6454) can be mirrored for the direct translator with `z = 0x00030005`: assert layer 5 and viewport 3, plus the absent-output and disabled-Z cases. A direct-DXIL-versus-HLSL draw with a layered render target would then check observable parity. This is a source finding; I have not run that regression or linked it to the AMD driver crash in #3544. AI use: Codex (GPT-6.2 Sol) traced the current path; Codex (GPT-6.2 Astra) independently checked the gap and the test shape.
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!3243
No description provided.