Shaders: offline pipeline builds use the runtime workers' 64 MB stack #2070
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2070
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2070"
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?
@thisguyStan on GitHub · 2026-11-25 02:48 UTC · original
thisguyStan:shaders/offline-builds-runtime-stack→main· +69 −9 · 2 files · 1 commits · openxcl shaders --measure-psobuilds its pipeline on the main thread (1 MB stack inxcl.exe's PE header), and--precompile --pipelineson scoped threads with Rust's 2 MB default. The driver compiles on the calling thread, so a measurement of what a build costs can end on a stack limit of XCL's own thread. On RADV under Wine,--measure-psoof the flat compact form of the largest compute programs ended withthread 'main' has overflowed its stack, and those runs were used to compare forms in #1269 (#2018 / #2025 threshold). This runs both offline paths on the stack of the runtime's pipeline workers (64 MB), so they build as the workers do. @ClosetPie107 found the--pipelinesside in #1269 (comment, "Stack size of the offline tool"); this follows it. Part of #1269.What is in it
crates/xcl/src/hle/d3d12x/pso_async.rs: the workers' stack asWORKER_STACK(same 64 MB, no change at run time).crates/xcl/src/shaders.rs: one helper,worker_thread, makes a named thread withWORKER_STACK.--measure-psoruns on one (on_worker_stack,xcl-measure-pso), and so do the--precompilethreads, which also make the--pipelinesbuilds (xcl-precompile-{k}), and the threads--pipelinesstarts for a split program's dispatch-chain pieces (xcl-pipeline-piece-{k}, from #2338). They had no name, so an overflow printedthread '<unknown>'. Three unit tests: the thread's stack reserve is at leastWORKER_STACK, a precompile thread gets the stack and its name, and a panic on the thread reaches the caller.Not changed, and worth knowing for the RADV result
Only some runtime builds run on the 64 MB workers: pipelines an earlier run used (prebuilt at low priority), and builds after an
XCL_PSO_WAIT_MSbudget ran out. By default (XCL_LAZY_PSOon, noXCL_PSO_WAIT_MS) a compute pipeline is built at its first bind on the title's own thread (pso_async::resolve_wait_for), and XCL does not change the stack size of title threads. The title tested here defaults to 1 MB in its PE header, which answers the open question at the end of that comment. So the RADV overflow above may also happen in a title run under Wine, on a title thread. A bigger stack is not a cure-all either: a PSO worker overflowed its 64 MB on an unbounded recursion in dxil-spirv (comment). This PR does not change that; moving those builds off title threads is runtime work (#2001 goes in that direction).Tested
cargo test --workspace -- --test-threads=4on this PR's head8cb4346(onmain2898511): 1366 passed, 0 failed, 46 ignored. Windows Developer Mode on, soshaders::tests::pso_measurement_compiles_an_exact_synthetic_recordruns and passes.SKIPPED(28): 21 "no wave64", 3 per-lane form refusals (V_CVT_F16_F32,V_PK_MUL_F16,V_MUL_F16), 2 "no d3d12SDKLayers.dll", 1 "no heap windows", 1 "no D3D12 debug layer".xcl shaders <pack> --precompile --only cs(XCL_NETWORK=0, an emptyXCL_DXIL_CACHE), release, this change onmain3f4495a(the same change as8cb4346before the rebases since, without the piece threads of #2338, which was not merged yet): all 26 503 shaders, compiled 2 689 compute programs, 0 errors, exit 0, 4 455 s. An earlier pass of the same kind on an older base had stopped with exit 1 and no message at about 23 000; this one went through.xcl.exe's PE header reserves 1 MB for the main thread (SizeOfStackReserve), which is where--measure-psobuilt before.xcl shaders <pack> --measure-pso <record> --repeat 3(one 1.1 MB HLSL-path compute program), release,mainagainst this change on3da2abb: identical DXIL (1 121 012 B); driver median 139.1 s against 141.1 s (ranges 138.2–141.5 s and 139.1–143.4 s), within run-to-run spread.xcl shaders <pack> --precompile --only cs --pipelines --used-only(the 482 pipelines earlier title runs used here;XCL_PIPELINE_MAX_KB=512; an emptyXCL_DXIL_CACHEper run), release,main5ce558fagainst this change: both compiled 322, made 318 pipelines, refused 0, capped 4; 306 s against 275 s.--measure-pso <record> --repeat 3again, on the same program, on5ce558f: identical DXIL; driver median 136.0 s (main) against 132.9 s.Regression run
main2898511:8cb4346:main's frames, 102.4 % of its peak commit, no device removal, no crash. The 60 s run does not reachxcl shaders, so it only shows the runtime is not broken by the shared constant.Not tested
--precompile --only cs --pipelinesoverflows its pipeline threads onmainand on this PR alike (@JoaoPauluu's run), so the stack does not help there. That is one of dxil-spirv's endless recursions, which all started inflatten_subgroup_shuffles()on the CFG before structurizing; dxil-spirv runs that pass after the structurizer since HansKristian-Work/dxil-spirv@694cc674, and vkd3d-protonmastercarries that since HansKristian-Work/vkd3d-proton@89439562. Nobody has rerun that case with it yet. On the HLSL path none of the 2 674 compute programs of the pack has the second back edge #1805 found on the direct path (checked fromdxc -dumpbin); since8dcc56dthe enormous ones take the direct route, where #1860 is the XCL-side fix.AI use
🤖 Generated with Claude Code
@futurepro62 on GitHub · 2026-11-25 03:28 UTC · original · edited 2026-11-25 03:30 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
0fd51f9(on its base5ce558f).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1136 passed, 0 failed, 44 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.offline_builds_run_on_the_runtime_workers_stack,a_panic_on_the_worker_reaches_the_caller.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1147 passed, 0 failed, 46 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),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))),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))),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))),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).--skipleaves out tests that fail on maincbc296atoo, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputestsconst_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
@Parakeet-Wheat on GitHub · 2026-11-25 03:42 UTC · original
NVIDIA RTX 3070 on native Windows, head
0fd51f9on its base5ce558f: both new tests pass, the whole suite passes, and the smoke pair is within the limits. The new tests cannot fail on the base (the helper they call is not there), so there is no fail-before run.Tested
610.88, 32-lane waves), Ryzen 5 5600X, 32 GB, Windows 11 26300, Rust 1.95.0stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11, retail 1.0.2.1. Head0fd51f9(one commit on5ce558f, 6 commits behind currentmain), checked out clean. Tests in the debug profile, smoke in release.cargo test -p xcl --lib worker_stack_tests -- --nocapture --test-threads=1on0fd51f9: 2 passed, 0 failed (offline_builds_run_on_the_runtime_workers_stack,a_panic_on_the_worker_reaches_the_caller). On5ce558fthey do not compile:on_worker_stackandWORKER_STACKare new in this PR..\scripts\test.ps1(cargo build --workspace, thencargo test --workspace -- --test-threads=4) on0fd51f9: 1148 passed, 0 failed, 46 ignored, exit 0. SKIPPED, 25: 20 ×no wave64, 3 × per-lane form refused (V_CVT_F16_F32,V_PK_MUL_F16,V_MUL_F16: "its #1426 semantics differ from the console's"), 1 ×no heap windows, 1 × cannot disable the driver cache (Windows Developer Mode required).Regression run (
scripts/smoke.ps1 -Game <folder> -Seconds 60, the same title, back to back, menus, no input; unedited). Base5ce558f:PR head
0fd51f9:That is 97 % of the base's frames and 107 % of its peak commit. One run each; the
60 58 12tail of the PR's run (against60 60 60) is not something I repeated.Not tested
xcl shaders --measure-psoand--precompile --pipelinesthemselves (no offline run, so the stack-overflow case on RADV under Wine is not reproduced), AMD, native wave64 (the 20no wave64skips above), a world run, the tests on game data (XCL_SAMPLE_*not set).AI use
@JoaoPauluu on GitHub · 2026-11-25 04:37 UTC · original
A run of the
--pipelinesside under Wine on Linux with vkd3d-proton as the host D3D12. Here the 64 MB stacks do not change the outcome: on bothmainand this PR, all four pipeline threads overflow within about two minutes and the run stalls.Tested
x86_64-pc-windows-gnu.0fd51f9as it is (based on5ce558f) andmaincbc296a, no uncommitted changes.xcl shaders <retail 1.0.2.1 shaders.rpf> --precompile --only cs --pipelines,XCL_PIPELINE_MAX_KB=0(no cap),VKD3D_SHADER_CACHE_PATH=0and__GL_SHADER_DISK_CACHE=0(no driver-side caches), 2400 s cap,mainfirst:main:pipelines: 75 made, 0 refused, then fourthread '<unknown>' has overflowed its stacklines. The log stopped changing about 1.5 min after start, and the cap killed the process (exit 124).pipelines: 75 made, 0 refused, fourhas overflowed its stacklines (the first between 50 and 75 made). The log stopped changing about 1.5 min after start, and the cap killed the process (exit 124).AppData\Local\xcl\dxilin the Wine prefix) was not cleared between the two runs, so the PR's run could reuse DXIL that themainrun had compiled. The pipeline builds were fresh in both.--measure-psocannot run here. On both commits it stops withcannot disable the driver cache (Windows Developer Mode is required): Not implemented. (0x80004001), since vkd3d-proton does not implement the shader cache control.XCL_DIRECT_DXILwas unset, so both runs used the HLSL → DXC path. #1805 found its overflow with direct DXIL on, in dxil-spirv'sflatten_subgroup_shuffles(). These overflows are on the default path. I have not checked whether they are the same recursion, so I cannot tell from here whether XCL's 1 MB / 2 MB limits play a part.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-25 05:09 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@thisguyStan on GitHub · 2026-11-25 18:01 UTC · original
Thank you @futurepro62, @Parakeet-Wheat, @DavidM1911 and @JoaoPauluu for testing across RTX 5070 Ti / an RDNA2 iGPU, RTX 3070, RTX 3060 Ti, and RTX 3060 under Wine with vkd3d-proton!
Rebased onto
origin/main(5ce558f→50a9fde). The one conflict was main's new worker queue inpso_async.rs(Workclosures);WORKER_STACKsits above it and both worker pools still use it. Since your runs:worker_thread, so the precompile threads are covered too (Parakeet-Wheat's note that the tests only reachedon_worker_stack). A new test checks a precompile thread's stack and name.xcl-precompile-{k}. They had no name, so an overflow like the one in JoaoPauluu's run printedthread '<unknown>', the same as a thread of the driver's.flatten_subgroup_shuffles(), which ran before the structurizer; dxil-spirv runs it after since HansKristian-Work/dxil-spirv@694cc674, and vkd3d-protonmastercarries that since HansKristian-Work/vkd3d-proton@89439562. Not rerun yet; it is under Not tested.4772a13: full workspace (1291 passed, 1 failed, 46 ignored; the failure also fails onmain50a9fde),xcl shaders --precompile --only cs(all 26 503 shaders, 2 689 compute programs compiled, 0 errors), and a paired 60 s smoke (1360 → 1457 frames, 0 device removals / crashes).AI use: Claude Code (Claude Opus 5.5) made the changes, ran the tests and wrote this comment.
@oni-swr on GitHub · 2026-11-25 21:42 UTC · original
AMD RDNA3 on native Windows: full suite of
8cb4346merged ontomain6d12f58Test report for head
8cb43460c48bf98beef7c1d679a6db37ef75ce39, which is a rebase onto an oldermainthan today's. I tested the PR head merged ontomain6d12f58a(a local merge commit, one auto-merged file, no conflicts; the diff againstmainis only this PR's two files) and compared it withmainitself.Tested
cargo test --workspace --no-fail-fast -j 4 -- --test-threads=4, both trees in the same target dir, one after the other; the log showsCompiling xclfrom the tested worktree.main6d12f58a: 1422 passed, 1 failed, 46 ignored.main: 1425 passed, 1 failed, 46 ignored. The 3 extra passes are this PR's new tests.shaders::worker_stack_tests::offline_builds_run_on_the_runtime_workers_stackshaders::worker_stack_tests::precompile_threads_are_named_and_get_the_workers_stackshaders::worker_stack_tests::a_panic_on_the_worker_reaches_the_callermainand on the PR:gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722). It also fails alone onmain, so it is not caused by this PR.SKIPPED, identical on both trees:gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpuandf32_programs_on_the_gpu(f16 / f32 conversion cases refused as unsupported, 6 lines) andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).Not tested
scripts/smoke.ps1regression run on a retail title, so there is noxcl-smokeblock here.xcl shaders --pipelines/--precompilerun on a large pack, so the stack-overflow case this PR is about (reported under Wine / RADV) is not exercised on this card.AI use: this run and report were done by Claude Code (Claude Sonnet 5.5), driven by
oni-swr. The commands and counts are from the run above, not edited by hand.@DavidM1911 on GitHub · 2026-11-26 07:13 UTC · original
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
@bmjask on GitHub · 2026-11-25 21:37 UTC · original · reviewed
No concrete source defect found. Shared 64 MiB worker stack is applied consistently and result/panic propagation is sound; tests cover reserve/name/unwind. Current official Windows CI is not visible, despite strong reported suite/smoke. The RADV/Wine recursion limitation is appropriately disclosed. A bounded deep-stack/large-build integration case would strengthen tests, but I found no blocker.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.