Repository navigation
Shaders: DXC compiles sources over 8 MB one at a time - #1660
itsd-effex wants to merge 4 commits into
Conversation
A translated source over 8 MB of HLSL (the -O0 threshold; a handful of programs in a retail pack) takes several GB in DXC. Several of them compiling at once stack that memory, and the admission check (`wait_for_memory`) reads the commit headroom, which under Wine includes all of the host's swap, so it lets them through: three such programs in `xcl pipelines` reached a 25 GB RAM cap in 23 s and 20.8 GB of swap in 48 s on a 32 GB machine, with none finished. One at a time, two of them finished in 219 s with peak RAM at 11 GB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Ran the whole 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 cache, version and in-process DXC checks all pass (one more test than the previous head), so the change does not disturb the normal compile path here. What it cannot show is the case it is for: a source over 8 MB, which needs retail shaders; I have no game data. Not tested: a >8 MB source actually serializing its compiles (no game data), RDNA2/RDNA4 and Intel GPUs, a release build. AI-assisted (OpenCode), model: DeepSeek V4.1 Flash 1017 - checked out the PR's head commit in a detached worktree, built it, ran the module, wrote this report; no local changes were made. |
The gate is now a small guard type (`EnormousTurn`). In test builds it counts how many compiles hold it at once, and a source with a marker comment counts as enormous, so the test needs no 8 MB shader. Four threads compile marked sources through `compile_here`; at most one is ever inside. Without the gate (a lock of its own per compile) the test sees all four inside at once and fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`EnormousTurn::wanted` named the test module in a `cfg!(test)` expression, which non-test builds still compile: `cargo build` failed (E0433). The marker check is now a `#[cfg(test)]` block. The test in the previous commit was added after a review asked for one. Suggested-by: Aniseto Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The same isolated measurement with #1321 added: all three screen-probe programs now get through DXC on this 32 GB machine. Same setup as in the description (three programs in flight at once, 14 threads, a cgroup of 25 GB RAM + 32 GB swap, empty DXIL cache). Tree:
The memory free on the host never fell below 15.9 GB in the last run. Not tested: the driver stage of these three DXILs (the run stops once the third exists); the title's own compiles of them. AI use
|
|
Native Windows test of Tested
Not tested Retail shaders or title runs, peak memory and throughput on complex shaders, and the full suite on NVIDIA. The padding exercised the byte cutoff with a small shader body. AI use OpenAI Codex (GPT-6 family, exact variant unavailable) wrote the temporary probe, ran and checked the tests, and wrote this report. |
|
Independent Windows release verification on NVIDIA RTX 3060 Ti at commit Setup
Workspace tests (
Regression run (
Base ( PR head ( Not tested: test commit AI use: Antigravity ( |
|
Independent native Windows 11 + NVIDIA GPU test run and code review at Tested
Code review notes (
Not tested
AI use
|
Serializes compilation of HLSL sources over 8 MB (ENORMOUS_SOURCE) in dxc.rs so multiple enormous compute shaders (which take several GB of RAM each in DXC) do not compile concurrently and exhaust host RAM and swap under Wine. Assisted-by: Antigravity
A queued enormous compile took a DXC worker and a wait_for_memory slot and then waited on the one-at-a-time lock while holding both; once its turn came it went into DXC without checking memory again. compile() now takes the turn on the caller's thread, before the job is sent to the pool. Suggested-by: MatyEjsr Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@MatyEjsr thanks for the run and the review. The ordering point is right: a queued enormous compile held a DXC worker and a Fixed in Tested on AI use
|
Hardware test report — commit
|
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
XCL PR #1660 verificationClean detached head STOR-WINLAB, AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Windows 11 Enterprise Evaluation x64 build 26200, rustc 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc). Tested
Workspace failures and skips
Not tested Actual HLSL over 8 MiB, compiler memory savings, matched main or retail smoke runs, sample data, Wine, and other adapters. The workspace failures have no matched main result for comparison. AI use T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against |
|
Diff on
|
|
Closing this as superseded by #2120. Since that merge, a compute program whose HLSL is over 8 MB goes to the direct DXIL translator and never reaches DXC. The enormous sources this PR made wait their turn were exactly those screen-probe compute programs, so on current Thanks to MatyEjsr for the review that shaped it, and to JJAutoCompare and raylitebull for the verification runs. Written with Claude Code (Claude Opus 5.5). |
A handful of translated programs in a retail pack are over 8 MB of HLSL, the size at which
dxc.rsalready switches to-O0. Each one takes several GB in DXC. When several of them compile at once, their memory adds up. The admission check that should hold them back (wait_for_memory) reads the commit headroom (ullAvailPageFile). Under Wine that figure includes all of the host's swap, so the check lets them all through. This PR compiles sources over 8 MB one at a time. Every other compile is unchanged.Related: #1321 makes the largest of these programs (ActivateRays, 148 MB of HLSL since b8b1f49) small again. This PR is about several big ones at once, so the two are complementary. #1417 fixes a race in the same admission check. It is a different bug. #1710 retries a compile that DXC fails with
E_OUTOFMEMORY, which complements this one (it reacts, this one prevents). Under Wine, DXC rarely seesE_OUTOFMEMORY, because the host swaps first. Issue #1657 reports the symptom fromxcl shaders --precompile.What is in it
17285b3,crates/xcl/src/gpu/recomp/dxc.rs:ENORMOUS_SOURCE(8 MB, the existing-O0threshold, now named) and a mutex thatcompile_hereholds for sources over it.8d821a9+9c77995, the same file: the gate as a small guard type (EnormousTurn) and a test,enormous_sources_compile_one_at_a_time. Four threads compile sources throughcompile_here, and at most one may be inside at once. In test builds a marker comment makes a source count as enormous, so no 8 MB shader is needed.9c77995fixes a build error in8d821a9: non-test builds referenced the test module. Thanks to @Aniseto, whose Windows run (comment) pointed out that the PR had no test of its own.c4a169e, the same file: the turn is taken incompile(), on the caller's thread, before the job goes to the DXC pool. Before, a queued enormous compile held a DXC worker and await_for_memoryslot while it waited, and went into DXC without a new memory check once its turn came. Thanks to @MatyEjsr, whose review (comment) found it.Tested
RTX 3080 Ti 12 GB, NVIDIA 620.73.04 (Linux), i7-11700KF, 32 GB RAM + 36 GB swap. CachyOS, Proton Experimental's Wine, vkd3d-proton
masterec207194+ Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257's patch. Rust cross-build forx86_64-pc-windows-msvc, release. DXC 1.9.2609.5.Isolated measurement: retail 1.0.2.1, the title's own journal, and the three screen-probe programs only (
ActivateProbes56c0cd3b82a00c6e,ActivateProbesTarget958400d2caf07244,ActivateRays95cc13288a27a96e), all three in flight at once.xcl pipelinesran with 14 threads in a cgroup of 25 GB RAM + 32 GB swap, with an empty DXIL cache, stopped at 16 GB of swap. For the test only, the build had a local switch to make only these three pipelines; it is not part of this PR.ActivateRays doesn't fit in 25 GB on its own, so this PR can't help it; that is what Recompiler: oversized structured code falls back to pc blocks (#1307) #1321 is for. In a full
xcl pipelinesrun of the same title on the same machine (main9e3831e+ Shaders: isolate DXC compiler heaps for parallel AOT #688 + Shaders: xcl pipelines compiles a run's queued pipelines outside the title #759 + XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684, without this PR), the three entered DXC together and the run used 29 GB of RAM and 20 GB of swap within about 2 minutes.The new test on
9c77995under Wine: passes; onc4a169e(throughcompile()), thegpu::recomp::dxcmodule: 15 passed, 0 failed. With the gate taken out (each compile taking a lock of its own), it fails with all 4 compiles inside at once. The wholegpu::recomp::dxcmodule: 15 passed, 0 failed.cargo build(release and debug) passes.Windows, by reviewers (thanks):
dxcmodule on17285b3and on the head with the test, Windows 11, RTX 5070 Ti, debug. All passed.9c77995, Windows 11, AMD Radeon: 777 passed, 0 failed, 41 ignored. Also a temporary probe of the real cutoff: four sources padded to 8,388,607–8,388,610 bytes, without the test marker. The two at or under 8 MiB compiled at-O1, and the two over it went through DXC one at a time at-O0(peak one in flight). The GPU output matched on AMD and on an RTX 5090.17285b3, Windows 11, RTX 3090, debug: 776 passed, 0 failed, 41 ignored, including the five tests that fail under Wine here; and a review of the gate's ordering, fixed inc4a169e.c4a169emerged withmain4178e88, Windows 11, AMD Radeon RX 9070 XT (native wave64), debug: 777 passed, 0 failed, 41 ignored, the new test included.scripts/smoke.ps1againstmain: 1676 frames against 1669, peak commit 14,857 MB against 14,860 MB, no device removal, no crash.17285b3, Windows 11, RTX 3060 Ti, release: 776 passed, 0 failed, 41 ignored.scripts/smoke.ps1againstmain9e3831e: 98.1 % of the frames, 103.4 % of the peak commit, no device removal, no crash.wine-tests.shon17285b3(each test binary under Wine,--test-threads=4; the recompiler's GPU tests in their own process): 771 passed, 5 failed, 41 ignored, the same counts as onmain9e3831eon this machine. SKIPPED:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).main9e3831eon this machine, so they come from the Wine setup and not from this change:disk_free_space_ex_reports_pls_quota,gpu_depth_buffer_created_for_unordered_access_is_placed,xma2_source_voice_decodes_and_manages_lifetime,set_predication_buffer_state_and_kickoff,test_title_runs_and_game_folder_is_untouched.offline_compute_pipeline_is_reused_by_a_second_processandshaders_single_file_reports_text_top_json_recomp_and_dxc_compilealso failed, because the fresh worktree had nodxcompiler.dllnext toxcl.exeyet (DXC reported 1 error). With the DLL in place, a rerun of both binaries passed: 4 of 4 each.Regression run
Made with a bash port of
scripts/smoke.ps1: the same environment variables, log patterns and block, run under Wine. It is notsmoke.ps1itself. Both runs are on the same title, for 60 s:mainfirst, then this PR's head.peak commit: 0 MBbecause XCL can't read process memory under Wine (#1097), so the peak-commit comparison is not covered.Not tested
smoke.ps1run is on the head,c4a169e; @LocranKing's was on17285b3, the gate's first form.AI use