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 bcc71b6, on main 426a5a7: the change db2b89d; 22463b2, a test by @anes66 from their companion commit b780cdd; and bcc71b6, which keeps the latch blocks from Recompiler: collapse empty trampolines and merge linear blocks in direct DXIL opt #2194's simplify_cfg (merged today): 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; 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 bcc71b6: cargo test --workspace -- latch simplify_cfg a_block_keeps --test-threads=1, 9 passed, 0 failed, the GPU one among them; 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 bcc71b6: 1,239 passed, 6 failed, 46 ignored. The same command on main 426a5a7: 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 of main. SKIPPED GPU tests: 320 lines on main, 321 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 426a5a7, at 22463b2 (the first two commits) and at this head; each program's DXIL then 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: 57 of 2,682 on main, 7 at 22463b2, 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 against main, 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 pass spirv-val --target-env vulkan1.3. Since Recompiler: enormous compute programs take the direct DXIL translator #2120 three of the 57 take the direct translator without XCL_DIRECT_DXIL too: c963276f38285bf4, f839072880d49fb4 and 219287eb2f6021fe (over 8 MB of HLSL each); 95cc13288a27a96e is a fourth such program. Before the rebase, on main 689f2db: 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 main block is of 1a0bbe3, a few merges past this branch's base 426a5a7.

main:

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

PR:

xcl-smoke v1
commit: bcc71b69fe4258970dd096ffd0ccc6c89587e841
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 1569 (PresentX 1570)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14445 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.

Not tested

AI use

@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 and others added 3 commits November 25, 2026 04:26
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>
@Royalflamejlh
Royalflamejlh force-pushed the linux/direct-single-latch branch from 2b54bb8 to bcc71b6 Compare November 25, 2026 11:26
@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

This branch is rebased onto main 426a5a7 and has a third commit, bcc71b6, because #2194 (merged today) took its latch blocks out again. On 426a5a7, vkd3d-proton's dxil-spirv 34f0ff8 (split wave64 form, 1 pass of each tree, as in the description) segfaulted on 7 of the 2,682 direct compute programs with the first two commits, and on 0 with all three.

#2194's simplify_cfg bypasses an empty [Br(t)] block, and the latch single_latch adds is one: with one incoming edge it is bypassed even when t has phis, so a block with back edges to two loop heads gets both again. bcc71b6 skips the bypass when t comes no later than the block in the reverse post-order the pass already takes, and adds a unit test that is red without it. It keeps 520 bytes more DXIL than the first two commits alone, in 51 of the 2,682 programs. The first two commits are the same patches as a6e5c0e and 1160f92, so the reviews and card results above were of them, on the older main; bcc71b6 is new.

main 426a5a7 + segfault in dxil-spirv 34f0ff8
nothing 57
the first two commits 7
this branch (bcc71b6) 0
  • Since Recompiler: enormous compute programs take the direct DXIL translator #2120, three of those 57 reach dxil-spirv without XCL_DIRECT_DXIL too: c963276f38285bf4, f839072880d49fb4 and 219287eb2f6021fe have over 8 MB of HLSL each, and with this branch they convert in 3.6 to 3.9 s. A fourth that Recompiler: enormous compute programs take the direct DXIL translator #2120 sends there, 95cc13288a27a96e, is not in the counts: it did not finish in 300 s on any of the three trees, main included.
  • bcc71b6 on an RTX 2070 SUPER (Windows 11, driver 621.01, debug): cargo test --workspace -- latch simplify_cfg a_block_keeps, 9 passed, 0 failed; the gpu_ tests with XCL_DIRECT_DXIL=1, 145 passed (2 printed SKIPPED: no wave64), 0 failed, 1 ignored, the same as on main 426a5a7. The description has the setup and both smoke blocks.

Not tested: AMD; the unsplit form on 426a5a7; the title under Wine with this head.

AI use: Claude Code (Claude Opus 5.5) found the interaction, wrote bcc71b6 and this comment, and ran the measurements.

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 25, 2026
…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).
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.

10 participants