Skip to content

Recompiler: direct DXIL gives every loop head and block one back edge - #1860

Open
Royalflamejlh wants to merge 3 commits into
xcl-dev:mainfrom
Royalflamejlh:linux/direct-single-latch
Open

Royalflamejlh wants to merge 3 commits into
xcl-dev:mainfrom
Royalflamejlh:linux/direct-single-latch

Conversation

@Royalflamejlh

@Royalflamejlh Royalflamejlh commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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 from Cfg::build_with after make_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's pc, as make_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

  • Head bb2165b9, on main 2898511a: the change 837582c4; f0b6ff84, a test by @anes66 from their companion commit b780cdd; and bb2165b9, which keeps the latch blocks from Recompiler: collapse empty trampolines and merge linear blocks in direct DXIL opt #2194's simplify_cfg: it bypassed them, an empty [Br(t)] block with one incoming edge being bypassed even when t has phis, so a block had back edges to two loop heads again. Rebased from 1160f92 on 689f2db and twice more today as main moved (the last time beside Recompiler: fold shift-masks, nested masks, double-xor, and all-ones or in direct DXIL opt #2279's new test in module/opt.rs); the first two commits are unchanged. @anes66's test: latch_blocks_preserve_loop_registers_on_the_gpu runs 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 the gpu/dxil sources do.
  • RTX 2070 SUPER 8 GB (Windows 11 Pro 26200, driver 621.01), debug, at bb2165b9: cargo test --workspace -- latch simplify_cfg a_block_keeps --test-threads=1, 9 passed, 0 failed, the GPU one among them (1 run). At bcc71b6 (the same three commits on main 426a5a7), with XCL_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 on main 426a5a7 (1 run each). Earlier, on an RTX 5070 Ti (Windows 11, driver 621.24, debug) at 1160f92: cargo test --workspace -- latch --test-threads=1, 2 passed, 0 failed.
  • No GPU: Ryzen 9 9950X3D, Fedora 44, Wine 11.21 Staging with Mesa lavapipe only, rustc 1.98.0, release, cross-compiled to x86_64-pc-windows-gnu; in the prefix, vkd3d-proton v3.1-90-g30b0eb9b with Linux (Wine + vkd3d-proton): a retail game reaches what main reaches 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_driver at bb2165b9: 1,356 passed, 9 failed, 46 ignored. The same command on main 2898511a: 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 of main. SKIPPED GPU tests: 351 lines on main, 352 here (the new GPU test, which needs a card). 1 run each.
  • RTX 4060 Ti (driver 615.71.09), the same Wine with vkd3d-proton v3.1-90-g30b0eb9b, on d812f24 before 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 is gpu_depth_buffer_created_for_unordered_access_is_placed, which fails on main under Wine too. SKIPPED: the two "no wave64" tests.
  • Retail title 1.0.2.1, xcl shaders shaders.rpf --precompile --only cs --split 1 with XCL_DIRECT_DXIL=1 (the split wave64 form), at main 3f277701 and at this branch on it (90c578f9; its gpu/dxil sources are those of bb2165b9, and main 2898511a changes none there); every program and every compute-split piece after it (2,682 programs, 7,914 pieces) through dxil-spirv 34f0ff8 (the one in that vkd3d-proton), built natively, with the options vkd3d-proton passes, 300 s limit, 1 pass each. Segfaults: 62 on main (57 programs, 5 pieces), 0 at this head; none at the limit (95cc13288a27a96e is 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 against main, 21,448 bytes more in 879 MB. Of the 62 new SPIR-V outputs, 61 pass spirv-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, on main 50a9fde). Since Recompiler: enormous compute programs take the direct DXIL translator #2120 three of the 57 programs take the direct translator without XCL_DIRECT_DXIL too: c963276f38285bf4, f839072880d49fb4 and 219287eb2f6021fe (over 8 MB of HLSL each). Before, on main 426a5a7 (no split yet): 57 segfaults, 7 with the first two commits, 0 with all three; on main 689f2db: 77 and 0.
  • dxil-spirv's own master b540c8a2, which vkd3d-proton's master carries since today (89439562; its latest release, v3.1, carries an older one), converts all 11,115 of main b49be183's direct programs and pieces without this change: 0 segfaults (1 pass; the standard kit's 34f0ff8: 42). So this change is for vkd3d-proton v3.1 and other builds with an older dxil-spirv, until they move.

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.

main:

xcl-smoke v1
commit: 2898511af1c038a2ef809719e9b6f89e5675c422
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 1380 (PresentX 1380)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13984 MB

PR:

xcl-smoke v1
commit: bb2165b96310d6581c2144c7f6e1e95f682c6b53
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 1428 (PresentX 1428)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14005 MB

Under Wine on an RTX 4060 Ti 16 GB (driver 615.71.09), before the rebase: 1558 frames on main c4d37be and 1568 on d812f24, 0 device removals and 0 crashes in both.

The title with XCL_DIRECT_DXIL=1 under Wine + vkd3d-proton v3.1-90-g30b0eb9b (its own dxil-spirv, unpatched for this), RTX 4070 12 GB, 120 s, main c4d37be + #684 with and without d812f24: with it 121 and 230 compute pipelines were made by 120 s (2 runs) and Wine logged no stack overflow; without it 23, and one virtual_setup_exception stack overflow line (1 run). Presents stop at about 80 to 93 s either way.

On nvidia-dev

  • It does not merge into nvidia-dev eae01502: both add code at the same places in cfg.rs. The same three commits on it, both sides kept: linux/direct-single-latch-nvidia-dev e5d3ed31.
  • Its compute programs with XCL_DIRECT_DXIL=1 in the split wave64 form (2,682 programs, 9,489 pieces) through dxil-spirv 34f0ff8 natively, 1 pass each: 26 programs segfault on eae01502, none with these commits; no output fails spirv-val in either. (The same 26 on the older af2cecc4; 52 on c044dc6d; none with these commits on either.)
  • cargo test --release -p xcl --lib -- gpu::dxil under Wine, no GPU: 203 passed, 1 failed with them; 199 passed, 1 failed on eae01502. The failure is directed_reference_basics in both.

Not tested

AI use

  • Claude Code (Claude Fable 5.2) found the cause, wrote the change, the tests and this description, and ran the tests and the measurements.
  • Claude Code (Claude Opus 5.5) found that Recompiler: collapse empty trampolines and merge linear blocks in direct DXIL opt #2194 undid it, wrote bb2165b9 and its test, rebased the branch and made its nvidia-dev copy, updated this description, and ran the tests and the measurements on today's main and on nvidia-dev.

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

On real hardware: RTX 3070 8 GB (32-lane waves, split wave64), driver 616.56, Windows 11, debug.

It no longer builds on main 689f2db. ee85bc2 added CfgBlock::pc since this PR's base, and the new latch block doesn't set it:

error[E0063]: missing field `pc` in initializer of `cfg::CfgBlock`
   --> crates\xcl\src\gpu\dxil\cfg.rs:246:21

Locally I used the loop head's offset, as main's split copies take their original's (pc: blocks[h].pc).

With that, XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu_ --skip gpu_sparse_vram --test-threads=4:

  • main 689f2db: 110 passed, 0 failed, 1 ignored (2 of 2 runs);
  • this PR: 110 passed, 0 failed, 1 ignored. The two new cfg tests and loop_entered_in_the_middle_is_split pass.

(gpu_sparse_vram_descriptors_buffers_and_xmem was skipped because of the #1727 parallel hang, not this PR.)

AI-assisted (Claude Code). Synthetic tests only.

@Royalflamejlh
Royalflamejlh force-pushed the linux/direct-single-latch branch from d812f24 to a6e5c0e Compare November 24, 2026 22:35
@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

@upipibi thank you: rebased onto 689f2db, with pc: blocks[h].pc for the latch block as you had it. It builds there, the three cfg tests pass, and the suite under Wine without a card gives 971 passed, 4 failed, 45 ignored against 969 / 4 / 45 on 689f2db, the same 4 failing (1 run each). The 2,682 compute programs it makes with XCL_DIRECT_DXIL=1 are byte for byte those from before the rebase.

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.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
@itsd-effex

Copy link
Copy Markdown

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 a6e5c0e + #759 dd66d20 (for xcl pipelines), and the same tree with a6e5c0e reverted. Both with vkd3d-proton ec207194 (+ #257's patch) and unpatched dxil-spirv 7c048638, loaded from next to xcl.exe (checked with WINEDEBUG=+loaddll). xcl pipelines with XCL_DIRECT_DXIL=1, 14 workers, empty DXIL and vkd3d-proton caches, a data root of its own. Input: the 21 retail pipelines that each killed their worker on their own in #1805 (on that same unpatched dxil-spirv).

stack overflows result
without this PR 12 14 → 2 live workers within about 60 s, 0 of 21 made (stopped once no worker was busy)
this PR 0 made 21, failed 0, 287 s; the worker count only fell as the last programs finished

The 21: 05a6f7b3c517c29a, 240e0081d6fcbfa3, 241fc505f962313b and 18 more, the killer lines of the classification described in #1805 (comment).

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 x86_64-pc-windows-msvc. For the build only, a local commit with a switch to make chosen pipelines (XCL_PIPELINES_ONLY) and a two-line fix that #759 needs to build on this main (#1524 renamed what it uses; reported on #759).

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

  • Claude Code (Claude Opus 5.5) built the trees, ran the test and wrote this comment.

@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

The goal:world-load label is missing here: this is part of #1805, which carries it (#1833: "If yours is missing, say so here or on the PR").

Posted without review by a person: the account owner was away and reads replies later.

@anes66

anes66 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

CPU-only follow-up on rebased head bcc71b69fe4258970dd096ffd0ccc6c89587e841: the new back-edge guard preserves nested latches and their loop-carried phi inputs. Optional test companion 2fd3b33 is directly on that head and adds one test only.

Tested

  • Windows 10 Pro 19045, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, debug. CPU IR checks; no GPU initialization or shader compilation.
  • 28 nested-loop fixtures: seven rotations of block allocation order, each forward and reversed, with conditional or switch branches. The switch has two cases sharing an inner latch. Both loop headers carry live phis; a forward trampoline exercises the optimization that should still happen.
  • Each fixture runs Module::optimize twice. After each pass it checks at most one distinct back-edge target per block and one returning block per loop header, both retained loops/latches, removal of the forward trampoline, live phi predecessor multiplicities, exact loop-carried phi values and uses_well_formed.
  • cargo test --locked -p xcl --lib gpu::dxil::module::opt::tests:: -j 2 -- --nocapture --test-threads=1: 8 passed / 0 failed / 0 ignored / 0 skips.
  • cargo test --locked -p xcl --lib gpu::dxil::cfg::tests:: -j 2 -- --nocapture --test-threads=1: 3 passed / 0 failed / 0 ignored / 0 skips.
  • Negative control: temporarily removing only pos[t] <= pos[b] from the trampoline guard makes the new test fail with multiple back edges in its first conditional fixture. Restored before the final passing runs and commit.

Not tested
GPU execution or output parity, DXIL validation/serialization, dxil-spirv, release, full workspace, a title or integration onto newer main. These CPU checks supplement the earlier GPU fixture; they do not supply the outstanding AMD execution result.


Earlier report below applies only to a6e5c0e and companion b780cdd. The author adopted the GPU fixture; the manual version bump became unnecessary after #1947 added direct-source cache identity. Those earlier GPU/workspace counts are not results for bcc71b6.

The latch change needs a direct-translator cache-version bump. Exact head a6e5c0ebe12abfb2fdaa4ee02e719cad10f243e6 changes only gpu/dxil/cfg.rs, which is outside build.rs's source hash, and keeps TRANSLATOR_VERSION=7. A pre-fix disk translation can therefore bypass the new CFG entirely.

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

  • Windows 10 Pro 19045, RTX 3060 12 GB / driver 32.0.16.2114, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, DXC 1.9.2602.17, Agility 1.620.2, debug. No XCL_SAMPLE_* inputs.
  • Cache regression before the bump: 0 passed / 1 failed; the old marker was loaded and the translation closure was never called. After: 1/0. It seeds a synthetic v7 entry through the existing cache helpers, requires rebuilding in both direct routing modes, and checks that HLSL still reuses its entry. This is a storage-identity check, not execution of an old retail shader.
  • cargo test --locked -p xcl --lib latch -- --nocapture --test-threads=1: 3/0/0, no skips. The new GPU fixture translates two RDNA2 loop shapes (two returns to one head; a nested loop with returns to either head), asserts the inserted latches, validates DXIL, and compares GPU registers against HLSL+DXC and explicit expected values. Wave32 and split wave64, 0/1/2/5 iterations: 16 input/mode cases, 32 GPU dispatches, all matched. Native wave64 was not run.
  • cargo build --locked --workspace -j 4: passed.
  • Patched workspace, cargo test --locked --workspace --no-fail-fast -j 4 -- --test-threads=1 --show-output: 979 passed / 0 failed / 45 ignored, 23 explicit SKIPPED lines (18 no-native-wave64 cases, three per-lane f16 refusals, the Developer-Mode-dependent PSO measurement, and the heap-window-only case). Skips and sample-gated returns are included in Rust's pass counts.

Parallel limitation
The same patched workspace at --test-threads=4 was 976/3/45, 26 explicit SKIPPED lines. write_buffer_immediate_on_open_existing_heap_visible_to_cpu, rotating_queue_self_deadlock_and_non_monotonic_rescue_do_not_hang, and timestamps_outside_unified_memory_land_after_the_queue failed creating queues with 0x887A0005; subsequent GPU-unavailable skips occurred.

An unmodified exact-head control, cargo test --locked -p xcl --lib -- --test-threads=4 --show-output, was 926/2/25, 23 explicit SKIPPED lines: coherent_buffer_sanitizes_console_flags_and_state and the same write_buffer_immediate_on_open_existing_heap_visible_to_cpu failed. This is a library-only control, not a clean full-workspace comparison. The parallel failures' cause is not established; the serial result does not make the parallel suite green.

Not tested
Wine/vkd3d, AMD/Intel, native wave64, release, title/world-load regression, the 79 changed retail programs, or integration onto newer main. The new GPU fixture calls the direct translator explicitly; the workspace runs used the default backend, not a full XCL_DIRECT_DXIL=1 suite. No proprietary inputs were accessed. A maintainer/title tester still needs the required exact-head regression pair before merging a runtime change.

AI use
Codex (GPT-6; exact variant unavailable) wrote the companion patch and synthetic tests, ran the native checks and controls, and prepared this report. The latch algorithm is the original author's work.

@pablogonz12

Copy link
Copy Markdown
Contributor

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 xcl-smoke pair from me); NVIDIA and Windows-native AMD.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

@anes66 thank you: your GPU test is in as your commit (1160f92, the core_tests.rs part of b780cdd). On an RTX 5070 Ti (Windows 11, driver 621.24, debug) cargo test --workspace -- latch --test-threads=1 gives 2 passed, 0 failed, the GPU one among them (1 run), and the description has a new regression block for that head.

I did not take the version bump: #1947, merged since, makes the direct translator's cache entries change when the gpu/dxil sources do, so a translation cached before this change is no longer reused once this is on main. Say if you see a case that still slips through.

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.

@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

Still needed after #2034: on main aaa0936 vkd3d-proton's own dxil-spirv segfaults on 77 of the 2,682 direct-DXIL compute programs, in the split wave64 form and in the unsplit one, and with 1160f92 merged in (no conflict) on none in either form.

Setup: Fedora 44, Ryzen 9 9950X3D, Wine 11.21 Staging, no GPU. Retail title 1.0.2.1, xcl shaders shaders.rpf --precompile --only cs with XCL_DIRECT_DXIL=1 and --split 1 or --split 0, release builds of aaa0936 and of aaa0936 with 1160f92 merged locally. Each program's DXIL then through dxil-spirv 34f0ff8 (the one in vkd3d-proton v3.1-90-g30b0eb9b, with the one resource-metadata patch our build of it carries), built natively, with the options vkd3d-proton passes on a card with 32-lane waves (--subgroup-size 32 32) for both forms, 4 at a time, 300 s limit. 1 pass each.

2,682 programs main aaa0936 aaa0936 + 1160f92
split form (--split 1, a card with 32-lane waves) 2,604 convert, 77 segfault, 1 not done in 300 s 2,681 convert, 0 segfault, 1 not done in 300 s
unsplit form (--split 0, the form for 64-lane waves) 2,604 convert, 77 segfault, 1 not done in 300 s 2,681 convert, 0 segfault, 1 not done in 300 s
  • The 78 that fail on main are the same programs in both forms, and the 77 are those of the description. 50 of the 77 are the same bytes in both forms, so the unsplit pass is a new test for 27 of them. The description above measured the split form only.
  • The one not done in 300 s is record 95cc13288a27a96e (3.9 MB of DXIL) in all four passes. That is dxil-spirv's conversion time, not the recursion ([OFFICIAL] Looking for PRs with shaders optimization #1269 has patches for it).
  • The merge changes the DXIL of 79 programs in each form, the same 79 as in the description (the 77 and 2 more).

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.

@JJAutoCompare

Copy link
Copy Markdown

Tested

Independent Arc A770 run of open PR #1860 at 1160f92c1480df891561083a9279d3b2ca9b1aa9 on STOR-WINLAB. The test run verified the reused checkout was clean and detached at that SHA before and after.

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.

@thehollowedone

thehollowedone commented Nov 25, 2026 •

Copy link
Copy Markdown

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.

cargo build --workspace --offline --locked -j 4 passed. cargo test --workspace --offline --locked --no-fail-fast -j 4 -- --nocapture --test-threads=4 finished with 978 passed, 0 failed, 45 ignored, including 23 runtime skips in Cargo's pass count. The two control-flow assertions and the native register comparison passed on the clean head.

I also assembled both synthetic loop forms with LLVM MC 23.1.6 for gfx1030, using labels for the branch targets. Each was one bit different from XCL's encoded input in the unused source field of v_readlane_b32. LLVM disassembled both encodings to the same instruction. Feeding the LLVM bytes into the same test still passed all 16 combinations of loop form, wave32 or split wave64, and iteration count. Direct DXIL validated and matched the expected registers and the HLSL/DXC GPU output in every tested lane. The focused command was cargo test --offline --locked -j 4 -p xcl --lib latch_blocks_preserve_loop_registers_on_the_gpu -- --nocapture --test-threads=1, 1 passed, 0 failed, zero skips. Coverage is synthetic D3D12, including the split wave64 path on a wave32 adapter.

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.

  • Both passed cargo build --offline --locked --workspace -j 4. The workspace tests finished with 1,247 passed, 0 failed, 46 ignored on the exact head and 1,269 passed, 0 failed, 46 ignored on the integration. The pass counts include 25 and 26 runtime skips respectively.
  • With XCL_DIRECT_DXIL=1, both passed all nine latch and CFG tests with zero skips. The loop-register fixture matched HLSL and the expected values for both wave32 and split wave64.
  • The current-main integration also passed the eight dispatch_chain_ tests, including one skip for the native-wave64 GPU portion.

Test commands were cargo test --offline --locked --workspace --no-fail-fast -j 4 -- --test-threads=4 --nocapture and cargo test --offline --locked -p xcl --lib -j 4 -- --test-threads=1 --nocapture latch simplify_cfg a_block_keeps, with a separate dispatch_chain_ filter for the integration. Synthetic Windows/NVIDIA verification only. AMD remains open. Codex (GPT-6, exact variant unavailable) ran the checks and drafted this update.

@raylitebull

Copy link
Copy Markdown
Member

Diff review on 1160f92 (single_latch in crates/xcl/src/gpu/dxil/cfg.rs + latch_blocks_preserve_loop_registers_on_the_gpu in core_tests.rs) looks solid, CI is green, and RTX 5070 Ti, RTX 3080 Ti, RTX 3060 Ti, and Arc A770 results are all green on 1160f92.

Only item remaining before merge is an AMD GPU pass (e.g. latch_blocks_preserve_loop_registers_on_the_gpu) on exact head 1160f92 (the earlier RADV run was on pre-rebase a6e5c0e).

@Royalflamejlh

Royalflamejlh commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

@raylitebull thank you. We have no AMD card to run it on, so that pass has to come from someone who has one.

1160f92 is a6e5c0e plus one commit that adds the GPU test (core_tests.rs, +73 lines, no other file); cfg.rs is the same at both. @pablogonz12's RADV run on a6e5c0e (RX 9070 XT, above) found no regression and passed this PR's two cfg tests, but those run on the CPU, so the latch blocks have not yet run on an AMD GPU. This is the test for that:

cargo test -p xcl --lib --release latch_blocks_preserve_loop_registers_on_the_gpu -- --nocapture

It prints a SKIPPED line and still counts as passed when there is no device, no wave32 or no DXC. @pablogonz12, if you still have that setup, one run of this on 1160f92 would settle it; please say whether it passed or printed SKIPPED.

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 main 426a5a7, and the head is now bcc71b6: the same two commits plus one in module/opt.rs, so that the CFG clean-up merged today (#2194) keeps the latch blocks. The test above is the same; the commit to run it on is bcc71b6, not 1160f92.

@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

On the #1607 hint (group D87): #1844 and #1852 fix a different crash from this one, so this pull request is needed with either of them. They keep XCL's own Ssa::read from overflowing a worker's stack while it translates (#1844's test: 8,192 joins on a 256 KiB stack), and #1852's description already says #1805's retail crash was traced to dxil-spirv here. This one changes the DXIL XCL emits so that vkd3d-proton's dxil-spirv 34f0ff8 does not segfault on it afterwards. On main 6d12f58a, dxil-spirv segfaulted on 42 of the 11,115 direct compute programs and split pieces, and on none with this branch and #2082 in (1 pass each); #2082 is there for invalid SPIR-V only. On main 426a5a7, this branch alone took the segfaults from 57 to 0 (the table above), and #2082 alone left them at 57.

AI use: Claude Code (Claude Opus 5.5) ran the conversions and wrote this comment.

Posted without review by a person: the account owner was away and reads replies later.

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No concrete source-level defect found. Single latches preserve the required loop/back-edge invariant, optimizer behavior is adjusted to retain them, and GPU coverage compares Direct-DXIL to HLSL/DXC across wave32/split-wave64; current CI and regression evidence are green. Residual disclosed gaps are no AMD run and no output comparison for changed retail programs. I found no blocker.

@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

Reopening: this is not a duplicate of #1844 / #1852. They stop XCL's own Ssa::read from overflowing a worker's stack; this stops vkd3d-proton's dxil-spirv from segfaulting on the DXIL XCL emits, which only Linux (Wine + vkd3d-proton) runs, so the two Windows checks in #1607 D87 could not see it. On main 426a5a7 this branch alone took dxil-spirv's segfaults from 57 to 0 of 2,682 direct programs; #1852's description says the same ("traced to dxil-spirv in #1860, so this PR does not claim to fix #1805"). Details in my comment above (21:02 UTC).

AI use: Claude Code (Claude Opus 5.5) wrote this comment.

@CalvyPZ CalvyPZ removed the duplicate This issue or pull request already exists label Nov 25, 2026
@CalvyPZ CalvyPZ reopened this Nov 25, 2026
@humsterbumster

Copy link
Copy Markdown

Retail title 1.0.2.1 on Linux / RTX 5090: with this change + #1844 + #2082 the overflow no longer ends the process

Machine: Linux x64 (kernel 7.3.5), 14 cores, RTX 5090 32 GiB, Proton 11 Wine, vkd3d-proton 3.2.0
(dxil-spirv 7c04863 with a local null guard in find_common_post_dominator/find_common_dominator),
XCL's direct-DXIL backend (XCL_DIRECT_DXIL=1), driver blob cache on, workers' stack 512 MiB.

Before (6a9e87b): the world load ended with STATUS_STACK_OVERFLOW (0xC00000FD) on XCL's
xcl-pso-N workers inside dxil-spirv, then the process exited with code 1. vkd3d-proton's
parse_dxbc: Ignoring DXBC checksum / skip_dword_unknown lines precede every overflow, and the
recursion is in-process inside CreateComputePipelineState, on the split wave64 form — the
signature this issue describes.

After bb2165b (this change) + 71f2ceb (#1844) + cab89ed (#2082):

  • the process no longer dies of the overflow — 7 overflow reports in a 430 s world-load run, 0
    process deaths from them
    ; the load goes on (it never did before this change on this machine);
  • the load reaches further than before: compute split: up to 145 programs split / 1557 pieces
    built, and driver compiles of the split form complete (482 KB, 797 KB, 851 KB DXIL; the huge
    ones take 12-22 s each here);
  • what ends the run now is not XCL: the container's 28 GiB cgroup limit (memory.max
    read-only, memory.swap.max 0) — RSS 24-24.7 GB plus page cache is the limit, and the cgroup's
    memory.events oom_kill goes up by one per run while /proc/vmstat oom_kill does not. XCL's
    own heap at that point measures 677 MB peak (a counting global allocator around mimalloc); the
    rest is the title's console memory (about 20 GB of Wine heap plus 9 GB of tiled GPU pages).

What is left of the recursion after this change is still very deep: XCL's pipeline workers grow
their 512 MiB stacks to about 500 MiB on the biggest compute programs (VirtualQuery says the
whole stack is committed under Wine, so this is measured from the guard page), and the same
programs take 12-22 s each in the driver's translation. On this machine the world load is a few
thousand of those, so it does not finish before the memory limit does. If the split form is meant
to be cheap, the depth (not just the endless case) is worth a look.

Not tested: Windows with this change (everything above is Linux + vkd3d-proton).

"ai": "omp (DeepSeek V4.1 Flash 1017)"

@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

@upipibi

upipibi commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

NVIDIA re-run for bb2165b (on main 2898511): RTX 3070 8 GB (Ampere, driver 616.56), Windows 11, debug. Earlier I ran the first commit only (110 passed).
New tests, 3 runs each with XCL_DIRECT_DXIL=1: latch_blocks_preserve_loop_registers_on_the_gpu, two_back_edges_share_a_latch, a_block_keeps_one_back_edge, loop_entered_in_the_middle_is_split: 4 passed, 0 failed, 0 skipped, 3 of 3.
XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu_ --skip gpu_sparse_vram --test-threads=4: 163 passed, 0 failed, 1 ignored.
Whole lib (--skip hle::xaudio2): 1279 passed, 0 failed, 26 ignored. SKIPPED: 21 no wave64, 3 per-lane forms the translator refuses, 1 needs Developer Mode.
Lib tests only; no title run.
AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.