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 |
|
merge-check |
1567f72 to
7bdb34a
Compare
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.
7bdb34a to
ad70519
Compare
…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>
ad70519 to
f404cfe
Compare
…decide (xcl-dev#1860 f404cfe) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
#1844 (merged) and #1852 address #1805 differently: they make AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
|
merge-check claim |
|
merge-check |
|
merge-check verdict: safe to merge |
|
merge-check |
|
merge-check Same settings on main 5ad98ad, two runs: into the world at 94 s with 145 s there and no frame presented (ran to the 240 s limit); into the world at 80 s with 59 s there and 90 frames, then stopped by our RAM guard (free RAM under 1 GB). "In the world" here means the first 2 s window of the activity log with 5,000+ draws and dispatches. AI use: Claude Code (Claude Opus 5.5) ran the build, tests and title runs and wrote this; a Claude Sonnet subagent read the diff and I checked its points. |
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
bb2165b9, onmain2898511a: the change837582c4;f0b6ff84, a test by @anes66 from their companion commitb780cdd; andbb2165b9, which keeps the latch blocks from Recompiler: collapse empty trampolines and merge linear blocks in direct DXIL opt #2194'ssimplify_cfg: 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 from1160f92on689f2dband twice more today asmainmoved (the last time beside Recompiler: fold shift-masks, nested masks, double-xor, and all-ones or in direct DXIL opt #2279's new test inmodule/opt.rs); 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.bb2165b9:cargo test --workspace -- latch simplify_cfg a_block_keeps --test-threads=1, 9 passed, 0 failed, the GPU one among them (1 run). Atbcc71b6(the same three commits onmain426a5a7), 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_driveratbb2165b9: 1,356 passed, 9 failed, 46 ignored. The same command onmain2898511a: 1,352 passed, 9 failed, 46 ignored. The same 9 fail on both (a_tile_decommitted_and_committed_again_keeps_its_video_memory,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,gpu_promoted_uav_clear_values_pass_create_committed_resource,split_compute_program_prebuilds_and_caches_chain_pieces,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: 351 lines onmain, 352 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), atmain3f277701and at this branch on it (90c578f9; itsgpu/dxilsources are those ofbb2165b9, andmain2898511achanges none there); every program and every compute-split piece after it (2,682 programs, 7,914 pieces) through dxil-spirv34f0ff8(the one in that vkd3d-proton), built natively, with the options vkd3d-proton passes, 300 s limit, 1 pass each. Segfaults: 62 onmain(57 programs, 5 pieces), 0 at this head; none at the limit (95cc13288a27a96eis 1.2 MB since Recompiler: direct compact form stores a branch's target in the entry #2076 and converts in 0.6 s). 121 programs' DXIL changes againstmain, 21,448 bytes more in 879 MB. Of the 62 new SPIR-V outputs, 61 passspirv-val --target-env vulkan1.3;c458137fcd97caf3's second piece fails as the five programs Recompiler: direct DXIL makes a pointer to storage again in each block #2082 fixes do, and passes with Recompiler: direct DXIL makes a pointer to storage again in each block #2082 merged too (0 of 10,614 invalid with both, onmain50a9fde). Since Recompiler: enormous compute programs take the direct DXIL translator #2120 three of the 57 programs take the direct translator withoutXCL_DIRECT_DXILtoo:c963276f38285bf4,f839072880d49fb4and219287eb2f6021fe(over 8 MB of HLSL each). Before, onmain426a5a7(no split yet): 57 segfaults, 7 with the first two commits, 0 with all three; onmain689f2db: 77 and 0.masterb540c8a2, which vkd3d-proton'smastercarries since today (89439562; its latest release, v3.1, carries an older one), converts all 11,115 ofmainb49be183's direct programs and pieces without this change: 0 segfaults (1 pass; the standard kit's34f0ff8: 42). So this change is for vkd3d-proton v3.1 and other builds with an older dxil-spirv, until they move.Regression run
RTX 5070 Ti 16 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11 Pro 26300, release builds by
scripts/smoke.ps1, the same retail title for 60 s each.main:this PR's head:
On
nvidia-devnvidia-deveff3bcab: both add code at the same places incfg.rs. The same three commits on it, both sides kept:linux/direct-single-latch-nvidia-dev98a22108.XCL_DIRECT_DXIL=1in the split wave64 form (2,682 programs, 9,489 pieces) through dxil-spirv34f0ff8natively, 1 pass each, oneae01502(eff3bcabchanges nothing undergpu/): 26 programs segfault there, none with these commits; no output fails spirv-val in either. (The same 26 on the olderaf2cecc4; 52 onc044dc6d; none with these commits on either.)cargo test --release -p xcl --lib -- gpu::dxilunder Wine, no GPU: 203 passed, 1 failed with them; 199 passed, 1 failed oneae01502. The failure isdirected_reference_basicsin both.On
amd-dev926433d8the direct translator is the default for compute there, so these programs reach dxil-spirv withoutXCL_DIRECT_DXIL. This branch does not merge intoamd-dev494f08b2: both add tests at the same place inmodule/opt.rs. The same three commits on it:linux/direct-single-latch-amd-dev4f590fb1. The third keeps both sides' tests, and its own test's inner loop tests a second input:amd-dev's branch facts fold the original shape's inner loop away, and the test failed there. Adjusted, it passes with the fix and fails without it.34f0ff8natively, 1 pass each, at494f08b2: in the split wave64 form 37 of 1,938 programs and pieces segfault, none with these commits; in the unsplit form (--split 0, the one a card with 64-lane waves gets) 38 of 1,971, none with them. Five split-form outputs fail spirv-val with or without them, the five Recompiler: direct DXIL makes a pointer to storage again in each block #2082 fixes; with both merged, none.cargo test --release -p xcl --lib -- gpu::dxilunder Wine, no GPU: 213 passed, 2 failed with them; 209 passed, 2 failed on494f08b2. The same two fail in both (dispatch_chain_native_wave64_builds_whole,directed_reference_basics).Not tested
cfgtests on an RX 6600 (17 passed, with and withoutXCL_DIRECT_DXIL), which do not include the GPU test. On Windows only the regression run above, by us; @upipibi's comments below have the GPU tests on Windows with an RTX 3070, the last onbb2165b9.--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
bb2165b9and its test, rebased the branch and made itsnvidia-devandamd-devcopies, updated this description, and ran the tests and the measurements on today'smain, onnvidia-devand onamd-dev.