Recompiler: preserve compute prologue dominance in direct DXIL #3154
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3154"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by KaniaKrzysztof on 2026-11-28T13:13:41Z.
Part of #1269 and #2088. A branched DispatchX prologue could reject direct DXIL twice on the same compute program. The first failure appended
createHandleFromBindingafter the entry terminator. With that repaired, compact lowering stored an EXEC value in entry before its phi was defined at the prologue join.What is in it
ee1efdainserts lazy static sampler creation and annotation before the terminator and restores the caller's insertion state (dxil/lower_image.rs). The two-sampler fixture checks exact point/linear outputs and inactive sentinels (recomp/tests.rs).43902aakeeps each register alloca in entry and places its first store after the initializer's definition (dxil/lower.rs). Both DispatchX paths reach the join before the compact loop. The entry allocation dominates the store, the phi dominates its value, and the memoized slot is initialized once. Constants and entry loads retain their entry initialization. A forced-compact EXEC fixture covers full and partial groups (dxil/kernel.rs).Tested
Edited after rerunning the full suite without the
XCL_*overrides used in the earlier local setup. That setup overrode both the Agility SDK and DXC directories. The rerun passed on the same driver. We did not isolate which override caused the earlier failures.Both clean checkouts ran
scripts/test.ps1with its default four test threads on an RTX 4090, driver 621.40. Both loaded the system D3D12Core10.0.26100.9818and Windows SDK DXC/DXIL1.9.2602.17.main10d2729743902aa2All five previously failing texture tests and the D32S8 VRAM test passed on both revisions. The static-sampler and compact
EXECregression tests passed on the PR head. Each run reported 25 GPU skips. The nine optionalXCL_SAMPLE_*inputs were unset.Compilation and GPU timing. On the 2070, one affected program produced 1,214,520 bytes of compact DXIL, versus 9,370,880 bytes through the archived fallback. Translation wall time was 7.08 s versus 95.0 s. One repaired native PSO call took 38.91 s with 836 MiB process peak commit. The driver reported one creation, zero confirmed misses and one unknown. A cold native speedup is unmeasured.
During full-pack pre-menu shader preparation for a newer retail game on RTX 4090, PR head
43902aa2rebuilt the affected compute shader from a private cache copy with its three prior translations set aside. The new compact DXIL was 1,214,520 bytes, down from 9,370,880 bytes for the archived HLSL fallback (87.0% smaller). Its SHA-256 matched the compact DXIL independently produced on RTX 2070.On a synthetic 128-iteration wave32 loop, initial medians were 8.976 µs HLSL and 22.096 µs repaired compact (2.46×; 54 timestamps each). Three fresh-process comparisons of byte-identical guest inputs against a CPU oracle gave 8.992–9.008 µs HLSL, 21.920–21.968 µs historical compact (
7f0eea29) and 21.856–21.952 µs repaired compact (120 timestamps per form per process). The overhead already existed on this loop.Regression run
RTX 4090, newer retail game, 60 seconds per revision, networking off, startup preparation disabled, separate fresh XCL caches. Publisher provenance is unverified.
Main
PR head
The operator observed the menu on both revisions. Each log records the affected guest compute shader during startup. Neither log confirms that the repaired compact lowering ran or that the GPU dispatched that shader.
Minecraft Preview 4× MSAA. The startup crash has a verified fix in #1087. On November 24, 2026, Minecraft Preview 1.18.3064.0 reached the menu and completed 60 seconds on that PR’s head with 3,421 frames on RTX 4090 and 3,412 on RTX 2070, both with zero crashes and zero device removals. On November 27, an independent Intel Arc probe reproduced the default multisampled depth-view failure on the parent and verified the fix. #1087 remains open. Retail verification · Independent probe
Not tested
Execution and timing of the affected compute shader with representative in-game resources, and AMD hardware.
AI use
We used OpenAI Codex with GPT-6.2 Astra to investigate the two defects, write the fixes and synthetic tests, run validation on both hosts and prepare this report.
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-28T13:34:46Z.
Ran the static-sampler-from-code test at
bacb6f04on an NVIDIA Blackwell desktop part:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
The test passes, covering the lazy static-sampler handle inserted before the entry terminator when a compute prologue branches. The PR description lists a full release workspace run that did not finish and twelve failures, six of them the known
mainfailures from #3093; I ran only this targeted test, so I am not reporting a suite result. The PR has no comments yet.Not tested: the full workspace suite, the forced-compact slot fixture, a paired smoke run, a retail title, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-11-28T15:55:20Z.
At
bacb6f04(onmaine429936c), a direct-only survey of a retail title's 1,636 compute programs translated 1,275 of them directly in the split wave64 form and 1,437 in the native wave64 form, against 708 and 1,000 onmain; 0 validator failures, 0 panics, and no "instruction after a terminator" left in either form.Setup: Linux, Wine 11.21 Staging, CPU only (no GPU), Rust 1.98.0, release,
x86_64-pc-windows-gnu;xcl shaders <pack> --direct --sample 0 --split 1and--split 0, 8 threads.scratch_ptr(lower_mem.rs:2373) has the same pattern as the static sampler: it switches toinit.entryto allocatexcl_scratchand appends after the guard's terminator. No compute program of this title reaches it (the survey is the same with it fixed), but this test fails atbacb6f04with "direct DXIL builder error: instruction after a terminator in block Block(0)":It passes with the same two lines your sampler change uses, in
scratch_ptr:Not tested: a GPU, Windows, the whole suite, a title run.
AI use: Claude Code (Claude Opus 5.5) ran the surveys and the test and wrote this comment.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-28T17:03:32Z.
A test of this PR on one retail compute program, on NVIDIA. It also shows a cache trap for anyone testing it on an existing cache.
Setup:
maine429936c, and this PR's headbacb6f04on it, release.mainrun stalled on while loading. Fresh, empty DXIL cache,xcl shaders <folder> --precompile, then the same with--pipelines --threads 1. No title.Measured:
maine429936cbacb6f04The cache trap (Read, and what we hit):
translated::cached_reroutedingpu/recomp/pso.rslooks a program up under the HLSL path's identity first, then underrerouted_identity.direct_output_identityonly goes intorerouted_identity.mainhas stored this program's fallback, a build with this PR finds it first and never translates the program again.mainrun, and it servedmain's 9,370,880 B fallback for this program, unchanged.Deduced: to see this PR's effect on a title, start from a cache without that file. A durable fix could look up
rerouted_identityfirst, or key an enormous program's fallback byrerouted_identityas well, so that a fixed direct translator retries it.Not tested: a title run with this PR on a clean cache; other programs (with this PR's build, 4 other programs of the title still fell back, with "multidimensional groups need the HLSL console-linear thread reorder", a different reason); other cards and drivers; AMD.
AI use: Claude Code with Claude Opus 5.5 built both commits, ran the test on this machine, read the cache code and wrote this. The person running these tests asked for this post.
Imported from ivall/xcl. Originally posted by afpruivo on 2026-11-28T17:20:42Z.
Test report on RTX 3090 for
bacb6f04: no new test failures, and on a retail title's shader pack the sampler fix lets 567 more compute programs translate through direct DXIL (43.3 % → 77.9 %).Tested
NVIDIA GeForce RTX 3090 24 GB, driver 621.40, i5-13600K, Windows 11 Pro 26300, Rust 1.99.1; tests in debug, the pack run in release.
cargo test --workspace --no-fail-fast -- --test-threads=4onbacb6f04: 2127 passed, 10 failed, 48 ignored (9 distinct tests).gpu_static_samplers_from_constants_in_codeandgpu_compact_slots_use_the_dispatch_prologues_exec_mask.maine429936con this card in every run (#3093).two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobsis a flake onmain(#3185).alloc_pool::tests::submit_marking_calls_out_unlocked_and_revalidates_the_queue_marker("queue Signal must run outside STATE") failed once under the full suite, but passes 5/5 alone on bothmainand this PR.SKIPPED: 21 "no wave64", 2 debug-layer cases (no
d3d12SDKLayers.dll), 3 f16 / conversion cases the per-lane form refuses, 1 heap windows.xcl shaders <shaders.rpf> --direct --validate --only cs --sample 100000, on the newer retail title (TitleID 7952987A), every compute program validated:maine429936cbacb6f04Among them are the two most expensive compute programs on this title's direct queue in play,
scattering_transmittance_system:CS_Gather_Classified_9and_11(dump hashes2504944a10775aeb,95bc3980ec624295). Each runs once per frame through ExecuteIndirect, for 7.5 and 9.3 ms per frame onnvidia-dev(XCL_GPU_TIMES). Onmainthe direct form refuses both, at the first static sampler used outside the entry block, so they take the HLSL path.Not tested
bacb6f04, compact register slots) only through the suite and the pack run above. I didn't isolate which programs need it.AI use: Claude Code (Claude Opus 5.5) ran the tests and the pack comparison and drafted this. I checked it before posting.
Imported from ivall/xcl. Originally posted by Eterst on 2026-11-28T18:52:18Z.
A side effect to plan for when this lands: with the entry block fixed, more of a retail title's huge compute programs translate directly and come in under the 8 MiB
XCL_PIPELINE_MAX_KBcap, so a precompile with--pipelinesnow has the driver build them. Each such build takes far more memory than a worker is budgeted.Setup: RTX 4070 SUPER 12 GB (driver 621.40), Ryzen 7 5700X, 32 GB RAM, Windows 10 19045, Rust 1.100.0, release. Not a clean
main: a local test tree (mainof 11-27 withd9403543ported by hand) with this PR's two commits applied by hand, andad19a1c1. So the numbers are about the driver's cost, not aboutmain's precompile code.Measured (
xcl shaders <pack> --precompile --only cs --pipelines, a RAM guard ending the process below 0.4 GB free):CreateComputePipelineStatedirectly (shaders.rs) and doesn't take the runtime's huge-build gate (big_compile_turn,XCL_HUGE_PSO_CONCURRENCY, default 1).Deduced, not tested on
main:main's preparation workers count 3 GB of commit for each (prepare_workers,shaders.rs:2750). One driver build of a 4 MB+ compute program held well over that here, and #3067 saw single workers at 10–17 GB. With this PR more such programs pass the cap, so a 32 GB machine may need one huge build at a time, or a per-worker budget that scales with the DXIL size.Not tested:
main's worker processes, other drivers, AMD.Results with the PR, for the record: the 1,068 compute programs of this pack that failed with "instruction after a terminator in block Block(0)" all translate directly now: 0 such failures. The remaining HLSL routes are the 471 multidimensional-group ones, by design. The scratch line from the earlier comment is in our tree as well; its test fails without it and passes with it.
AI use: Claude Code (Claude Opus 5.5) ran the precompiles, read the logs and wrote this comment.
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-28T19:38:48Z.
Re-ran the static-sampler-from-code test at
43902aa2after the head moved frombacb6f04and after a NVIDIA driver update; this is a new response in the same thread, not an edit of my earlier report atbacb6f04: https://github.com/xcl-dev/xcl/pull/3154#issuecomment-7240035285Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
The test still passes at the new head on the new driver. The PR description reports a full debug workspace run at this head on an RTX 4090 with six failures; I ran only this focused test, so I am not reporting a suite result. The new dimension here is the Blackwell card on driver 32.0.16.2140.
Not tested: the full workspace suite, a paired smoke run, a retail title, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Imported from ivall/xcl. Originally posted by afpruivo on 2026-11-28T19:40:41Z.
A clarification on my report above: the 7.5 and 9.3 ms per frame for the two
CS_Gather_Classifiedprograms were measured onnvidia-dev, and there both programs already translate through direct DXIL without this PR. The refusal ("instruction after a terminator") happens onmain. So the report doesn't show a frame-time gain from this PR, and I didn't mean to suggest one.I checked it in play:
nvidia-dev54225f58with and without this PR's two commits, three interleaved runs each, 16 frames from 420 s. Both arms built the same DXIL for these programs (274,848 B for95bc3980ec624295), and the direct-queue busy time per frame was the same within noise (control 144.7 / 140.3 / 141.2 ms, with the PR 141.2 / 149.8 / 139.3 ms). The coverage numbers formainstand. I'm running the same comparison onmainnow and will add the result here.AI use: Claude Code (Claude Opus 5.5) ran the runs and drafted this. I checked it before posting.
Imported from ivall/xcl. Originally posted by Anon64 on 2026-11-28T20:33:23Z.
Regression run for
43902aa2(this head) againstmainb937fbabon an RTX 3060 12 GB (driver 581.80), i9-14900KF, 64 GB RAM, Windows 11 26200, release builds. A newer retail game, 300 s,XCL_PREPARE=0,XCL_ADAPTER=3060,XCL_PIPELINE_THREADS=8, same cache state.100.4 % of
main's frames, 99.8 % of its peak commit, no device removal or crash.Not tested / not covered: this title logs
huge-program direct DXIL unavailable: direct DXIL builder error: instruction after a terminator in block Block(0)on this machine, but only while its shaders are translated cold during preparation; with a warm cache andXCL_PREPARE=0neither run hit that path (0 such lines in both logs), so this run does not show the fix working, only that nothing regressed. Not run: the whole suite, AMD, a cold-cache preparation.AI use: Claude Code (Claude Opus 5.5) built both commits, ran the smoke runs and wrote this report.
Imported from ivall/xcl. Originally posted by afpruivo on 2026-11-28T20:59:21Z.
Update to my note above: I stopped the
maincomparison before it finished, so I have no frame-time result for this PR onmain. With ±3–6 ms of run-to-run noise per frame on this title, three runs a side wouldn't separate a difference of this size. The test and coverage results in my report stand.AI use: Claude Code (Claude Opus 5.5) drafted this. I checked it before posting.
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-28T22:04:21Z.
Review: COMMENTED
Critical-review result: I found no concrete defect. Initializing the allocation slot in its defining block preserves dominance, and inserting sampler handles before the entry terminator while restoring builder state matches the surrounding IR construction pattern. The DispatchX regression exercises the motivating path.
Please retain the change as a focused correctness repair and keep the exact-head PR validation attached to this commit.
Reviewed at
43902aa2a0with Codex (GPT-5).Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T04:36:42Z.
merge-check
base:
fa204595a4head:
43902aa2a0merge: clean (trial merge bfac2ad8, local)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (XCL_DXC_DIR = DXC 1.9.2609) -> 2609 passed, 0 failed, 49 ignored; SKIPPED: 26, the usual set (21 no wave64 on this 32-lane GPU, 3 per-lane forms refused, 2 no heap windows). Both of the PR's tests ran (not skipped) and passed:
gpu::dxil::kernel::gpu_compact_slots_use_the_dispatch_prologues_exec_maskand the new DispatchX part ofgpu::recomp::tests::gpu_static_samplers_from_constants_in_code.review: none blocking; whole diff read (
kernel.rs,lower.rs,lower_image.rs,recomp/tests.rs, +75). (1)Initnow stores a slot's initial value in the block that defines it (def_block(v), else entry): the DispatchX EXEC mask is defined at the prologue join, so the store sees the selected mask, not a stale full one. (2) A static sampler handle created on first use now goes in front of entry's terminator (set_insert_before_term(true), restored after): entry can already end in the prologue's branch, and the handle must dominate both paths. Both changes are local and keep the old placement when the value comes from entry. (3) The tests do not catch the fix on this tree and GPU. Withlower.rsandlower_image.rsset back to main's (rebuilt, PR tests kept), both tests still pass, so on this base neither test program reaches the bad placement. They guard the behaviour but would not have failed before. Worth a word from the author on which main commit or program shape reproduced it.performance: no cost by default (only where values are placed in the prologue). Title run (release build of the merge, scratch/fast-world.py fast profile, against main
fa204595): exit 0, 0 crashes, 0 device removals; world entry 92.5 s against 76.8 s and 99.7 s in two main runs; peak commit 33,512 MB against 33,027 and 31,295 MB (101.5 % of the higher); 86 WARN lines against 86. This run presented world frames (1.5 fps, 3 frame dumps) while both main runs showed 0 fps in their window.verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74, wave32 only), AMD Ryzen 9 9950X, Windows 11 build 26200; rustc 1.99.0, debug test profile, release build for the title run, DXC 1.9.2609 via XCL_DXC_DIR. Claude Code, Claude Opus 5.5: build, suite, revert probe, title run and full-diff review; this report.
Imported from ivall/xcl. Originally posted by KaniaKrzysztof on 2026-11-29T08:15:38Z.
Thanks for the merge check @Kalmarv
The original reproduction was on main
e429936c10a5b8aa09470ff99dfc8c8d3d8c56fd, using the (95cc13288a27a96e) compute shader.I rebased the PR while investigating the full workspace test failures, but those turned out to be related to my local environment.
Imported from ivall/xcl. Originally posted by no-juiice on 2026-11-29T16:03:39Z.
merge-check claim
head:
43902aa2a0Imported from ivall/xcl. Originally posted by no-juiice on 2026-11-29T21:54:17Z.
merge-check
base:
bc2cbb72afhead:
43902aa2a0merge: clean (4 files, +75;
git diff --checkclean)build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (XCL_DXC_DIR = DXC 1.9.2609.5) -> 2725 passed, 0 failed, 49 ignored (41 binaries; the lib binary runs 2615 tests, base 2614); SKIPPED: 28 notices (22 "no wave64", 3 per-lane form refused for wave32 f16/f32 cases, 2 "no heap windows", 1 "no D3D12 debug layer"); failing: none in that run, but see review 1
review:
xcllib tests exited with 0xc0000005 (STATUS_ACCESS_VIOLATION), both times after exactly 82 finished tests and with the same four tests in flight:gpu::agility::tests::create_device_sets_dred_first,gpu::bvh::tests::scene_trace_matches_brute_force,gpu::bvh::tests::trace_matches_brute_force,gpu::dxil::compact_tests::a_large_program_that_repeats_itself_takes_the_compact_form. Not seen in 3 full-workspace runs of the base (one of them had two unrelated e2e failures,test_title_runs_and_game_folder_is_untouchedandincomplete_discovered_corpus_blocks_headless_title_entry, which did not repeat), nor in 2-p xcl --libruns of the merge result (2586 passed, 0 failed, 29 ignored). Each of the four tests passes alone (--exact --test-threads=1) with and without this PR, and a full-workspace run with--skip gpu::agility::tests::create_device_sets_dred_firstpassed. This PR's new test sorts into that part of the run, so it may only change which tests run together and expose an existing race; I could not show which. Unconfirmed as this PR's; a full-workspace run on another machine would settle it.Init::slotnow stores a slot's first value in that value's defining block, before its terminator, while the alloca stays in entry;slotruns beforeloademits its read, so the store precedes the first load. This relies on every first value being defined in a block that dominates the compact loop (true for entry values and for the DispatchX prologue join).lower_image.rscreates the static sampler handle before the entry terminator and restores the insertion setting, which removes the "instruction after a terminator in block Block(0)" refusal. Both new tests ran (wave32) and passed:gpu::dxil::kernel::gpu_compact_slots_use_the_dispatch_prologues_exec_mask,gpu::recomp::tests::gpu_static_samplers_from_constants_in_code. No other findings.performance: translation-time only; no per-frame cost expected. Related to the precompile-memory note above: on this 16 GB RAM machine a
maindb3921dccompute precompile with--pipelinesand the size cap off died with "LLVM ERROR: out of memory" at 42 GB process private, building the HLSL-path DXIL (9-19 MB) of the large compute programs;main10d27297+ #3189 + this PR (4 driver compiles at once, default 8 MiB cap) finished: 10,002 pipelines, 0 refused, 8.5 GB peak private, 66 min. Not an A/B of this PR alone. Later builds with this PR (on765b2c5b,d8bd9a38,24d21a41) reached the retail title's world; launch preparation had 0 failed workers.verdict: safe to merge
The merge is clean, the build and the full suite pass (2725 passed, 0 failed), the diff reads correct and both new tests pass on the GPU. The intermittent lib-binary crash in review 1 is unconfirmed as this PR's: it doesn't reproduce with any of the four tests alone, and it may be an existing race this PR's added test exposes.
hardware / tool and model: NVIDIA GeForce RTX 4060 Laptop GPU 8 GB (driver 617.42), AMD Ryzen 7 7435HS, 16 GB RAM, Windows 11 Home 26300, rustc 1.100.0, debug / Claude Code, Claude Opus 5.5 (ran the builds and tests and wrote this; checked before posting)