Shaders: resolve deep DXIL SSA joins without recursion #1834
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1844"
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 gloger2003 on 2026-11-24T21:43:41Z.
Part of #1805. The direct DXIL SSA reader could exhaust a worker stack when resolving a definition across many sealed control-flow joins. A synthetic chain of 8,192 joins reproduces the overflow on a 256 KiB stack.
What is in it
Tested
Windows x64, Ryzen 7 5700X, Radeon RX 7800 XT.
cargo build --offline --locked --release -p xclon the baseline and this head.cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output. 958 reported passed, 0 failed, 42 ignored. Runtime GPU skips: 7 (gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)), heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows).gpu_scalar_loop_and_sccwithXCL_DIRECT_DXIL=1andXCL_REQUIRE_GPU=wave64. One passed.The new test overflowed before the patch and passed with it.
Supplemental integration on
main 689f2dbplus this patch (cc07eac), RX 7800 XT. DXIL suite: 100 passed, one failed, three ignored. The new deep-join test passed. The failure was seed 722 infuzz_validate_and_gpu_1. A targeted run on clean689f2dbreproduced the same mismatch at output 30. The GPU scalar-loop and divergent-execution tests both passed withXCL_DIRECT_DXIL=1andXCL_REQUIRE_GPU=wave64.Regression run
Minecraft Preview, 30 seconds per build with matching settings and the default shader path.
Not tested
The title and Wine setup reported in #1805.
AI use
OpenAI Codex (GPT-6.2 Sol, high reasoning effort, Fast mode) wrote the code and regression test, ran the checks and drafted this description.
Imported from ivall/xcl. Originally posted by frenziedcoder on 2026-11-24T22:31:33Z.
NVIDIA test report for
71f2ceb: full suite green, its own testdeep_joins_read_on_a_small_stackpasses, and a clean smoke pair on the retail title (1654 vs 1655 frames).Tested
stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11 (SDK 10.0.26100.0). Exact head71f2ceb5a05951f8d3d1f6aebe92c13eec240317, no local changes.cargo build --workspace && cargo test --workspace -- --test-threads=4(debug): 958 passed, 0 failed, 42 ignored; the PR's own testdeep_joins_read_on_a_small_stackpasses. SKIPPED:gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu(no wave64),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 arithmetic, wave64: no wave64),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 packed, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 arithmetic, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 compares, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 conversions, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 rounding, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 three-source, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 transcendentals, wave64: no wave64),gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu(f64, wave64: no wave64),gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu(integer arithmetic, wave64: no wave64),gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu(integer carries, wave64: no wave64),gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).test_title_draws_with_a_root_signature_under_the_debug_layerreports ok, but this machine has no D3D12 debug layer (debug layer requested but unavailable … (0x887A002D)), so it ran without the layer and is no evidence either way.Regression run (
scripts/smoke.ps1 -Seconds 60, release, the retail title of #505 at its start screen;XCL_PSO_PRELOAD=0for both builds, because this machine's preload list holds the program of #1307)base (
177cd40, this PR's merge base withmain):this PR:
Not tested: this code in the title: it is on the opt-in direct-DXIL path (
XCL_DIRECT_DXIL), which the smoke runs leave unset (default HLSL backend), so they show only that nothing else regressed; the world load (the smoke runs stop at the start screen, so code that only runs later is not exercised there); AMD.AI use: Claude Code (Claude Opus 5.5) built and ran the tests and smoke runs on my machine and wrote this report; I checked it.
Imported from ivall/xcl. Originally posted by YaBulochka on 2026-11-24T22:41:54Z.
AMD/RADV check, and it does not reproduce as a speed-up here: on this machine the per-shader numbers improve but the wall time doubles.
x86_64-pc-windows-gnu, releasexcl shaders <retail shaders.rpf> --compile 500 --json,XCL_DIRECT_DXIL=1,XCL_DXIL_CACHE=0 XCL_PSO_DISK_CACHE=0, no title runFive runs in total; the last pair was taken with the same environment and no
XCL_DXC_THREADSset:c160d86Reading: the CPU sum is the same (555 vs 558 on the clean pair), the medians favour the PR, but the wall is 2.2x worse and remarkably stable at ~188 s while the base swings 79-98 s. The same shape appears with
XCL_DXC_THREADS=8fixed, so it does not look like a thread-count artefact on my side.My guess, offered as a guess: the explicit-stack walk shares state that serialises the workers, so the work is the same but less of it runs concurrently. If you have a way to log how many DXC compiles are in flight at once, that would confirm or kill it in one run.
No crash or stack overflow at 500 shaders on this box, so the overflow this PR targets did not show up in this mode.
Imported from ivall/xcl. Originally posted by itsd-effex on 2026-11-24T22:47:04Z.
A note from #1805's reporter: the
Ssa::readsuspicion in #1805's description was mine and is withdrawn. The retail crash there is in dxil-spirv (Royalflamejlh's analysis on #1805), and #1860 alone fixes it: withssa.rsunchanged and dxil-spirv unpatched, the 21 retail pipelines that killed workers all build (test), against 0 of 21 without it. So this PR doesn't fix #1805's crash as far as I can tell. The deep-join recursion it removes is real on small stacks (vitor127wt's 2 MiB runs), so it may still be worth having as hardening. I haven't tested this PR against those 21. Sorry for the misdirection.AI use
Imported from ivall/xcl. Originally posted by throny on 2026-11-25T00:51:21Z.
Two contributors checked independently and found that #1852 solves the same problem (for #1805) in a different way: #1607, group D70. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T01:01:08Z.
Exact-head CPU validation with DXC 1.9.2609.5
On clean
71f2ceb5a05951f8d3d1f6aebe92c13eec240317, both focused tests ran and passed:gpu::dxil::ssa::tests::deep_joins_read_on_a_small_stackandgpu::dxil::core_tests::long_pixel_shader_translates_fast(2 passed, 0 failed, 0 ignored, 0 skipped). I usedcargo test --locked -p xcl --lib <exact-name> -- --exact --nocapture --test-threads=1separately for each. The long-shader case used DXC/DXIL 1.9.2609.5 for CPU validation.Host: Ryzen 7 3800X, Windows 11 25H2 build 26200.9974, Rust 1.100.0 MSVC debug, Windows SDK 10.0.26100.0, Intel Arc A770 (driver 32.0.101.9175). This adds a newer DXC version to the existing exact-head report.
Not tested: GPU execution, full workspace suite, retail smoke, or the pre-fix baseline. Codex in T3 Code (
gpt-6.2-sol) ran the checks and prepared the test evidence.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T01:15:31Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
upstream-sync referenced this pull request2026-11-25 04:08:41 +00:00
Imported from ivall/xcl. Originally posted by lewisnic94-max on 2026-11-25T09:30:33Z.
Review: COMMENTED
Reviewed commit
71f2ceb5a05951f8d3d1f6aebe92c13eec240317.Both 8,192-level diamond and region shapes completed seven times each on a 256 KiB thread stack. The same probes overflowed the stack on the merge base
177cd407e0. A 4,000-deep shader join also translated on a 2 MiB stack. All 24 seeded draws on the head returned the expected 64 RGBA pixels, and all 24 DXIL blobs matched the corresponding base draw byte-for-byte.The graphics dependency benchmark distinguishes this PR from #1852. At 1,024 steps the median additional peak process commit inside the walker was 0.832 MiB here, versus 16.531 MiB on #1852 at
c2b1029c22(seven release processes each). Median phase times were 43.09 and 50.78 ms respectively. Both produced the same DXIL SHA-256. This PR changes SSA join resolution. The other PR also changes graphics dependency traversal. Their SSA edits overlap, so applying both as-is produces a conflict in ssa.rs.Windows 11 x64, Ryzen 7 5800X, GeForce RTX 3080 (616.92), Rust 1.100.0 MSVC and DXC 1.9.2602.17. No skips in those draw or head stack probes. Timing is specific to this synthetic shader and machine. No retail shader or native RDNA2 run. No additional actionable defect identified in this scope.
AI assistance: OpenAI Codex (GPT-6) inspected the implementation, analyzed the synthetic test evidence and drafted this review.
upstream-sync referenced this pull request2026-11-25 10:09:30 +00:00
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T10:58:18Z.
Diff review on
71f2cebconfirmsSsa::readincrates/xcl/src/gpu/dxil/ssa.rsuses purely per-call local vectors (chainandjoins: Vec<ReadJoin>) with no shared or global synchronization state, and@lewisnic94-max+@frenziedcoder+ RX 7800 XT runs are strong.Before merge, it would be helpful to briefly close out
@YaBulochka's Wine--compile 500wall-time anomaly report (78-98svs187-190s) with a confirmation/note so there are no open timing questions on the thread.upstream-sync referenced this pull request2026-11-25 12:04:57 +00:00
Imported from ivall/xcl. Originally posted by CalvyPZ on 2026-11-25T22:43:11Z.
This PR has been marked as a duplicate and closed after multiple agreeing checks in #1607. If you believe this is incorrect please re-open with why.
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-26T06:48:58Z.
AMD RDNA4 / Linux (Proton Experimental) test report on head
71f2ceb5(merged cleanly ontomainb49be183):Hardware & environment
experimental-11.0-20261112),vkd3d-protonmasterec207194(3.2.0) +dxil-spirvb540c8a2+ relaxed-vtable patch (-Db_ndebug=true), DXVKv3.1.1-209, DXC1.9.2609.5, Rustx86_64-pc-windows-gnuIsolated unit tests (
mainb49be183+ #184471f2ceb5, debug,--test-threads=1):xcl.exe gpu::dxil::ssa:: -- --test-threads=1: 1 passed, 0 failed, 0 ignored (0 skipped).Combined 300 s retail sanity run (release,
mainb49be183+ #1540 + #1675 + #1844 + #1899 + #2123 + #2369 + #2422, retail 1.0.2.1 pressingApast menus):exit=0), 0 crashes, 0 device removals,2,014PresentXframes,131,072translated draws,660,943dispatches (44,546chained split-compute dispatches),102,631Opus packets (0 errors).Not tested
AI use
main, ran the Proton unit tests and combined retail run on this machine, and drafted this report.Imported from ivall/xcl. Originally posted by throny on 2026-11-27T19:24:34Z.
merge-check claim
head:
71f2ceb5a0Imported from ivall/xcl. Originally posted by throny on 2026-11-27T19:43:51Z.
merge-check
base:
6089122ahead:
71f2ceb5a0merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1466 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1465 passed, 0 failed, 47 ignored
review: none. The explicit stack follows the old recursion: same cache points, same visiting and phi handling on loop backs, same operand order; preds[0] cannot be empty on the join path. The test overflows the stack without the change. Open from the thread, not blocking: a 2.2x wall-time report under Wine without a cause in the code; it overlaps #1852 in ssa.rs.
performance: only the opt-in direct-DXIL path uses this code; its cache hash changes, the HLSL path does not re-translate (reasoned).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-27T23:29:23Z.
merge-check claim
head:
71f2ceb5a0Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T00:16:03Z.
merge-check
base:
2c717a043chead:
71f2ceb5a0merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1466 passed, 1 failed, 47 ignored, 25 SKIPPED: 21 no wave64, 3 per-lane f16/f32 forms refused (#1426 semantics), 1 no heap windows; failing: hle::kernelx::tests::fine_timer_makes_short_sleeps_short, under the concurrent load only: rerun alone on the same merge commit it passed (1 passed, 0 failed); the diff does not touch kernelx; not run on the base. The suite ran on this PC at the same time as six other PRs' suites, in one queued job.
review: none. Whole diff read (ssa.rs: read() rewritten iteratively, ReadJoin, 1 test). Traced against the old recursive read(): same depth-first left-to-right operand order (same init/phi creation order), same caching of chain blocks and join blocks, same visiting-marker loop phis; preds_of() never returns empty for a block with preds, so preds[0] is safe.
performance: reasoned, not measured: shader translation only; same work per read, heap Vec instead of stack frames.
verdict: safe to merge
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile; trial merge 99cedecd5726f9914d4f7a8f7dbc51ee25402482 (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).
Imported from ivall/xcl. Originally posted by SJ99970 on 2026-11-28T14:45:40Z.
Tested on RX 9070 XT using the same Direct DXIL + Heap Windows configuration that previously reproduced the DXIL translator failures.
Before #1844 I consistently hit:
0xc0000409 around 23,747 / 26,503 records
xcl-dxil-translate stack overflow (0xc00000fd) around 24,600 / 26,503 records
With #1844 applied (
71f2ceb), shader preparation completed successfully:compiled 4344
already cached 31246
errors 0
skipped 390
pipelines made on the GPU 9462
refused 1
and reported:
Shader preparation stopped:
0 record failures,
1 refused pipeline,
0 over the size cap
The previously reproducible stack overflow was not observed.
Follow-up testing using XCL_PREPARE=0 progressed into runtime rendering, indicating the remaining issue is different from the DXIL recursion failure addressed by #1844