Repository navigation
Recompiler: direct DXIL gives every loop head and block one back edge - #1860
Royalflamejlh wants to merge 3 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. |
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
|
|
CPU-only follow-up on rebased head Tested
Not tested Earlier report below applies only to 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 |
|
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. |
|
Independent Windows run on 1160f92. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, DXC 1.8.2502.11.
I also assembled both synthetic loop forms with LLVM MC 23.1.6 for AI use: Codex (GPT-6, exact variant unspecified) assembled the inputs, adapted the scratch fixture, ran the tests and drafted this report. Current-head recheck. On the same RTX 3080 Ti and Windows toolchain, I tested exact bcc71b6 and its clean local integration onto main 06c9f55.
Test commands were |
|
Diff review on Only item remaining before merge is an AMD GPU pass (e.g. |
|
@raylitebull thank you. We have no AMD card to run it on, so that pass has to come from someone who has one.
It prints a Not tested: AMD, as said. AI use: Claude Code (Claude Fable 5.2) read the two commits and wrote this reply. Posted without review by a person: the account owner was away and reads replies later. Edited 11:37 UTC: 15 minutes after this was posted the branch was rebased onto |
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>
…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.
…ean-up simplify_cfg (xcl-dev#2194) bypasses an empty block that only jumps on, and the latch blocks single_latch makes are such blocks: a block that had back edges to two loop heads got both again, and the dxil-spirv in vkd3d-proton segfaulted again on direct programs single_latch had fixed. A block whose target comes no later in the reverse post-order is now kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2b54bb8 to
bcc71b6
Compare
|
This branch is rebased onto #2194's
Not tested: AMD; the unsplit form on AI use: Claude Code (Claude Opus 5.5) found the interaction, wrote Posted without review by a person: the account owner was away and reads replies later. |
…1860, xcl-dev#1913, xcl-dev#2192, xcl-dev#1946, xcl-dev#2237 Integrates XG CopyFromSubresource 7-arg ABI (xcl-dev#684), DirectStorage physical-page list re-read (xcl-dev#1405), vkd3d-proton in-place vtable patching with UnadoptGuard composition (xcl-dev#1395), single-back-edge Direct DXIL CFG (xcl-dev#1860), wave64 graphics Direct DXIL guard (xcl-dev#1913), and AMD RDNA2-4 DXIL fuzz fixes (xcl-dev#2192, xcl-dev#1946, xcl-dev#2237).
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.crates/xcl/src/gpu/dxil/module/opt.rs:simplify_cfg(Recompiler: collapse empty trampolines and merge linear blocks in direct DXIL opt #2194) no longer bypasses an empty block along a back edge, so those blocks stay. One unit test, red without it.Tested
bcc71b6, onmain426a5a7: the changedb2b89d;22463b2, a test by @anes66 from their companion commitb780cdd; andbcc71b6, which keeps the latch blocks from Recompiler: collapse empty trampolines and merge linear blocks in direct DXIL opt #2194'ssimplify_cfg(merged today): it bypassed them, an empty[Br(t)]block with one incoming edge being bypassed even whenthas phis, so a block had back edges to two loop heads again. Rebased from1160f92on689f2db; the first two commits are unchanged. @anes66's test: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. 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.bcc71b6:cargo test --workspace -- latch simplify_cfg a_block_keeps --test-threads=1, 9 passed, 0 failed, the GPU one among them; withXCL_DIRECT_DXIL=1,cargo test --workspace -- gpu_ --test-threads=4, 145 passed (2 of them print SKIPPED: no wave64), 0 failed, 1 ignored, the same onmain426a5a7(1 run each). Earlier, on an RTX 5070 Ti (Windows 11, driver 621.24, debug) at1160f92:cargo test --workspace -- latch --test-threads=1, 2 passed, 0 failed.x86_64-pc-windows-gnu; in the prefix, vkd3d-proton v3.1-90-g30b0eb9b with Linux (Wine + vkd3d-proton): a retail game reaches whatmainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175's patch, the build of the bullets below.cargo test --workspace --release --target x86_64-pc-windows-gnu --no-fail-fast -- --test-threads=4 --skip d32s8 --skip reservable_agrees_with_the_driveratbcc71b6: 1,239 passed, 6 failed, 46 ignored. The same command onmain426a5a7: 1,235 passed, 6 failed, 46 ignored. The same 6 fail on both (directed_reference_basics,disk_free_space_ex_reports_pls_quota,fence_and_command_queue_sync_timing_and_allocator_reset_match_host_and_console,gpu_depth_buffer_created_for_unordered_access_is_placed,stale_blob_cannot_bypass_the_offline_pipeline_cap,test_title_runs_and_game_folder_is_untouched); the 4 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: 320 lines onmain, 321 here (the new GPU test, which needs a card). 1 run each.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(the split wave64 form), atmain426a5a7, at22463b2(the first two commits) and at this head; each program's DXIL then through dxil-spirv34f0ff8(the one in that vkd3d-proton), built natively, with the options vkd3d-proton passes, 300 s limit, 1 pass each. Segfaults: 57 of 2,682 onmain, 7 at22463b2, 0 at this head. One 2.4 MB program,95cc13288a27a96e, is not done in 300 s on any of the three, and is not one of the 57. 122 programs' DXIL changes againstmain, 21,228 bytes more in 903 MB (the third commit's share: 52 programs, 520 bytes); the other 2,560 are the same bytes. The 57 new SPIR-V outputs passspirv-val --target-env vulkan1.3. Since Recompiler: enormous compute programs take the direct DXIL translator #2120 three of the 57 take the direct translator withoutXCL_DIRECT_DXILtoo:c963276f38285bf4,f839072880d49fb4and219287eb2f6021fe(over 8 MB of HLSL each);95cc13288a27a96eis a fourth such program. Before the rebase, onmain689f2db: 77 segfaults, and 0 with this branch.Regression run
Windows 11 Pro 26200, RTX 2070 SUPER 8 GB (driver 621.01), Ryzen 7 5700X3D; the title's first-run screens completed once, no story progress, no input; 1 run each, back to back. The
mainblock is of1a0bbe3, a few merges past this branch's base426a5a7.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
bcc71b6and its test, updated this description, and ran the tests and the measurements on426a5a7.