Repository navigation
Recompiler: direct DXIL gives every loop head and block one back edge - #1860
Royalflamejlh wants to merge 2 commits into
Conversation
|
On real hardware: RTX 3070 8 GB (32-lane waves, split wave64), driver 616.56, Windows 11, debug. It no longer builds on Locally I used the loop head's offset, as main's split copies take their original's ( With that,
( AI-assisted (Claude Code). Synthetic tests only. |
vkd3d-proton's dxil-spirv keeps one back edge per loop head. Its main pass merges several first, but flatten_subgroup_shuffles(), which runs for shaders with wave shuffles (the split wave64 form), analyses the CFG before that, and a second back edge then sends its dominator computation into endless recursion: a stack overflow in d3d12core.dll when the pipeline is made (xcl-dev#1805). The same happens for a block with back edges to two loop heads. Cfg::build now adds a block that jumps to the head and takes the back edges, for a head with several and for one whose back edge leaves a block that has a second. Measured on the retail title's shaders.rpf, xcl shaders --precompile --only cs --split 1 with XCL_DIRECT_DXIL=1, each program then through dxil-spirv 34f0ff8 natively: 77 of 2,682 programs overflowed its stack before, none does now. 79 programs change (those 77 and 2 more), 21,012 bytes more DXIL in 907 MB; the other 2,603 are the same bytes. Part of xcl-dev#1805 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
d812f24 to
a6e5c0e
Compare
|
@upipibi thank you: rebased onto Yours is the only run of it on Windows so far. The description has the new counts; the smoke block for the new head is to come. AI use: Claude Code (Claude Fable 5.2) made the rebase, ran the tests and wrote this. Posted without review by a person: the account owner was away and reads replies later. |
|
Tested on a GPU, with the pipelines from #1805: this change alone stops the worker deaths, with dxil-spirv unpatched. Two builds of the same tree: this PR's head
The 21: Tested: Linux (CachyOS), Proton Experimental's Wine, RTX 3080 Ti (NVIDIA 620.73.04), i7-11700KF, 32 GB RAM. Retail 1.0.2.1, the title's own journal. Release, cross-built for Not tested: the test suite on this head; the title's own runtime compiles; AMD; native Windows; the pack's other ~58,000 pipelines with this change. AI use
|
|
The latch change needs a direct-translator cache-version bump. Exact head Companion patch: b780cdd, directly on that head. It bumps 7 to 8, adds a disk-cache regression, and adds a synthetic GPU output check for the latch rewrite. No competing upstream PR. Tested
Parallel limitation An unmodified exact-head control, Not tested AI use |
|
Tested on AMD / RADV under Wine: no regression here, but the AMD-side abort is a different failure from #1805 and this change does not touch it.
Not tested: a retail title (no |
…n the GPU Two loop shapes (two returns to one head; a nested loop with returns to either head), wave32 and split wave64, against HLSL + DXC and explicit expected values. The test of anes66's companion commit b780cdd, taken without its cache-version bump, which xcl-dev#1947 makes unnecessary.
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
@anes66 thank you: your GPU test is in as your commit ( I did not take the version bump: #1947, merged since, makes the direct translator's cache entries change when the AI use: Claude Code (Claude Fable 5.2) made the commit from yours, ran the test and the regression run and wrote this reply. Posted without review by a person: the account owner was away and reads replies later. |
|
Still needed after #2034: on Setup: Fedora 44, Ryzen 9 9950X3D, Wine 11.21 Staging, no GPU. Retail title 1.0.2.1,
Not tested: the title or a GPU on this merge; whether the 79 changed programs compute the same; the unsplit form with the subgroup sizes a card with 64-lane waves reports; pixel and vertex programs. AI use: Claude Code (Claude Fable 5.2) built the trees, ran the conversions and wrote this comment. Posted without review by a person: the account owner was away and reads replies later. |
|
Tested Independent Arc A770 run of open PR #1860 at Windows 11 Enterprise Evaluation x64 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust and Cargo 1.100.0 MSVC, DXC/DXIL 1.9.2609.5. Used two Cargo jobs with incremental compilation and test debug info disabled. cargo test --locked -p xcl --lib --no-run
$env:XCL_ADAPTER = 'A770'
$env:XCL_DXC_DIR = Join-Path $env:LOCALAPPDATA 'XclTooling/dxc-1.9.2609/bin/x64'
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
& 'L:/XclTooling/pr2014-1c971de6/target/debug/build/xcl/77aca8ccb20e299f/out/xcl-77aca8ccb20e299f.exe' gpu::dxil::core_tests::latch_blocks_preserve_loop_registers_on_the_gpu --exact --nocapture --test-threads=1
}The build completed outside the Arc mutex. The fully captured GPU invocation reported 1 passed, 0 failed, 0 ignored, 0 explicit skips, 953 filtered out, 0.34 s. The wrapper exited 0 and logged lock release. An earlier invocation printed a pass, and PowerShell lost part of its stderr. This report uses the fully captured rerun. The fixture checked both the two-return and nested loop shapes in wave32 and split wave64, with iteration counts 0, 1, 2, and 5. It validated direct DXIL, compiled the HLSL/DXC reference, and matched registers v1–v3 against expected values and the HLSL/DXC GPU output. Not tested Native wave64, other adapters or drivers, additional fixtures, the workspace suite, retail smoke, and performance. AI use T3 Code / Codex (gpt-6.2-sol) ran the checked-in fixture and checked the captured logs. The coordinator prepared this summary from the completed run. |
On Linux, vkd3d-proton's dxil-spirv segfaults on 77 of the retail title's 2,682 direct-DXIL compute programs in the split wave64 form. The direct backend now gives every loop head and every block one back edge, and dxil-spirv as it is converts all of them. Part of #1805.
dxil-spirv keeps one back edge per loop head. Its main pass merges several first, but the pass it runs for shaders with wave shuffles analyses the CFG before that, and a second back edge then sends its dominator computation into endless recursion. A block with back edges to two loop heads keeps the second among its forward successors, which its loop tracer then follows without end (my reading of the code; not checked per program). The detail is in this comment on #1805.
What is in it
crates/xcl/src/gpu/dxil/cfg.rs:single_latch, called fromCfg::build_withaftermake_reducible. A loop head with several back edges, or one whose back edge leaves a block that has a second, gets a new empty block that jumps to it and takes those edges; the block takes the head'spc, asmake_reducible's copies take their original's. Two unit tests.Tested
1160f92: the change isa6e5c0eonmain689f2db(rebased fromd812f24onc4d37beafterCfgBlock::pccame in; the only difference is that field), and1160f92adds a test by @anes66, from their companion commitb780cdd:latch_blocks_preserve_loop_registers_on_the_gpuruns two loop shapes (two returns to one head; a nested loop with returns to either head) through the direct translator in wave32 and split wave64 and compares the registers with HLSL + DXC and with expected values. On an RTX 5070 Ti (Windows 11, driver 621.24, debug):cargo test --workspace -- latch --test-threads=1, 2 passed, 0 failed, the GPU one among them (1 run). The other half of that commit, a bump of the direct translator's cache version, is not taken: since Recompiler: direct DXIL cache entries change when its sources do #1947 (merged) the cache entries change when thegpu/dxilsources do.x86_64-pc-windows-gnu.cargo test --workspace --release --target x86_64-pc-windows-gnu --no-fail-fast -- --test-threads=4 --skip d32s8 --skip reservable_agrees_with_the_driver: 971 passed, 4 failed, 45 ignored. The same command onmain689f2db: 969 passed, 4 failed, 45 ignored. The same 4 fail on both (disk_free_space_ex_reports_pls_quota,gpu_depth_buffer_created_for_unordered_access_is_placed,test_title_runs_and_game_folder_is_untouched,gpu::dxil::round_tests::directed_reference_basics); the 2 more that pass are the new tests. The two tests skipped by name did not finish under Wine in our earlier runs ofmain. SKIPPED GPU tests: 265 lines on both.d812f24before the rebase:cargo test --release -p xcl --lib --target x86_64-pc-windows-gnu -- gpu_ gpu::dxil coverage --test-threads=4: 188 passed, 1 failed, 3 ignored; the failure isgpu_depth_buffer_created_for_unordered_access_is_placed, which fails onmainunder Wine too. SKIPPED: the two "no wave64" tests.xcl shaders shaders.rpf --precompile --only cs --split 1withXCL_DIRECT_DXIL=1, at689f2dband at this commit; each program's DXIL then through dxil-spirv34f0ff8(the one in that vkd3d-proton), built natively, with the options vkd3d-proton passes. Before: 77 of 2,682 segfault insideflatten_subgroup_shuffles(). After: 0. One 3.9 MB program is not done in 300 s either way. 79 programs' DXIL changes (those 77 and 2 more), 21,012 bytes more in 907 MB; the other 2,603 are the same bytes. The 77 new SPIR-V outputs passspirv-val --target-env vulkan1.3. (The dxil-spirv pass was made on the packs ofc4d37beandd812f24, which are byte for byte the packs of689f2dband this commit.)Regression run
Windows 11 Pro 26300, RTX 5070 Ti 16 GB (driver 621.24), Ryzen 7 9800X3D; the title's first-run screens completed once, no story progress, no input; 1 run each, back to back.
main:
PR:
Under Wine on an RTX 4060 Ti 16 GB (driver 615.71.09), before the rebase: 1558 frames on
mainc4d37beand 1568 ond812f24, 0 device removals and 0 crashes in both.The title with
XCL_DIRECT_DXIL=1under Wine + vkd3d-proton v3.1-90-g30b0eb9b (its own dxil-spirv, unpatched for this), RTX 4070 12 GB, 120 s,mainc4d37be+ #684 with and withoutd812f24: with it 121 and 230 compute pipelines were made by 120 s (2 runs) and Wine logged no stack overflow; without it 23, and onevirtual_setup_exception stack overflowline (1 run). Presents stop at about 80 to 93 s either way.Not tested
--only cs).xcl pipelines, the path Direct DXIL: xcl pipelines workers overflow their 512 MB stack on big compute programs under Wine #1805 reports, by us; @itsd-effex's comment below has it on an RTX 3080 Ti with unpatched dxil-spirv.AI use