Shaders: DXC compiles sources over 8 MB one at a time #1660
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!1660
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1660/head"
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?
@itsd-effex on GitHub · 2026-11-24 18:52 UTC · original
itsd-effex:dxc-enormous-one-at-a-time→main· +92 −1 · 1 files · 4 commits · closed without mergingA 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 withE_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+ #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 #1321 is for. In a full
xcl pipelinesrun of the same title on the same machine (main9e3831e+ #688 + #759 + #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
@Aniseto on GitHub · 2026-11-24 19:14 UTC · original · edited 2026-11-24 19:29 UTC
Ran the whole
dxctest module at9c77995(re-run after the head moved from17285b3). The PR changes the compile path, so this is a regression check: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.
@itsd-effex on GitHub · 2026-11-24 19:35 UTC · original
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:
main9e3831e+ #688 + #759 + #684 + this PR (17285b3; later commits add a test only) + #13210936337, with the same local test switch.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
@nnonno91 on GitHub · 2026-11-24 19:56 UTC · original
Native Windows test of
9c77995172bc53853545369db662826b057495f6. The full AMD suite passed. A synthetic probe exercised the real 8 MiB cutoff through XCL's DXC worker pool.Tested
XCL_ADAPTER.cargo build --workspace --lockedpassed. On AMD,cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-outputreported 777 passed, 0 failed, 41 ignored. This includes the existingenormous_sources_compile_one_at_a_timetest. One pass logged an explicit skip,heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows.dxc.rs. WithXCL_DXC_THREADS=4,cargo test --locked -p xcl --lib gpu::recomp::dxc::real_cutoff_probe::real_source_size_boundary_uses_dxc_worker_gate -- --exact --nocapturereported 1 passed, 0 failed, 0 ignored on each GPU, no skips. Four concurrent callers submitted compute shaders padded with comments to 8,388,607, 8,388,608, 8,388,609 and 8,388,610 bytes, without the test-marker comment.-O1. Both oversized jobs reachedcompile_hereand waited before the DXC call. After release, both entered DXC at-O0, with a measured peak of one oversized call in flight in each run. Each of the four compiled shaders matched 128/128 GPU output words against the CPU calculation on both adapters. The temporary instrumentation was removed afterward.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.
@LocranKing on GitHub · 2026-11-24 20:03 UTC · original
Independent Windows release verification on NVIDIA RTX 3060 Ti at commit
17285b327e5e93640f564ede019a15c9cec1185b(prior to test-only commit8d821a9, compared against basemain9e3831e1f570d3646e53ab753b19ec07eb8f1485).Setup
8024 MiB VRAM, wave32), driver32.0.16.210131.8 GBRAM26200rustc 1.100.0, DXC1.9.2602.17,--releaseWorkspace tests (
cargo test --workspace --release --no-fail-fast -- --test-threads=4)0: 776 passed, 0 failed, 41 ignored across 20 result blocks (SKIPPED: 2no wave64, 2no D3D12 debug layer,heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows).Regression run (
scripts/smoke.ps1, 60 s,XCL_NETWORK=0, title folder name redacted)main:1537 / 1566frames (98.1%),15220 / 14715 MBpeak commit (103.4%),0device removals,0crashes.Base (
main9e3831e):PR head (
17285b3):Not tested: test commit
8d821a9, concurrent cold DXC compiles of >8 MB sources, AMD / wave64 hardware.AI use: Antigravity (
Gemini 4 Neon) built and ran the test suite and smoke pair on this hardware and drafted this report from the captured outputs; reviewed before posting. No game files attached.@MatyEjsr on GitHub · 2026-11-24 20:12 UTC · original
Independent native Windows 11 + NVIDIA GPU test run and code review at
17285b327e5e93640f564ede019a15c9cec1185b.Tested
cargo build --workspace -j 8: succeeded in 10.24s (0 errors).cargo test --workspace -j 8 -- --test-threads=8: 773 passed (excluding skips), 0 failed, 41 ignored, 3 SKIPPED across 20 test binaries (cargo raw summary: 776 ok, 0 failed, 41 ignored; lib unit tests finished in 13.91s).SKIPPED:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).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) passed on native Windows 11 + RTX 3090, as didoffline_compute_pipeline_is_reused_by_a_second_processandshaders_single_file_reports_text_top_json_recomp_and_dxc_compile.cargo test -p xcl --lib gpu::recomp::dxc:: -- --nocapture --test-threads=1: 14 passed, 0 failed, 0 ignored, 0 SKIPPED (0.54s).Code review notes (
crates/xcl/src/gpu/recomp/dxc.rs)compile_hereis clean:IDxcBlobandIDxcResultdrop inside theunsafeblock before_enormousunlocksENORMOUS_ONE_AT_A_TIME.ENORMOUS_ONE_AT_A_TIMEis acquired insidecompile_here, which runs afterpool()acquireslet _slot = wait_for_memory(&job.wanted). When multiple >8 MB sources arrive concurrently:MemorySlot(WORKINGstays incremented while blocked on the mutex), inflatingneedinwait_for_memory(+1 GB per queued enormous job) and consumingWANTED_AT_ONCEslots while doing no work.xcl-dxc-*worker thread; with lowXCL_DXC_THREADSor fewer cores, queued enormous compiles can block smaller compiles behind them.c.Compileimmediately without re-evaluatingwait_for_memoryagainst current commit headroom.Acquiring
ENORMOUS_ONE_AT_A_TIMEbeforewait_for_memory(or incompile()around the pool round-trip, sincepool()workers never callcompile()recursively) avoids both holdingMemorySlotwhile blocked and occupying extra DXC worker threads.Not tested
AI use
dxc.rs, and drafted this report.@itsd-effex on GitHub · 2026-11-24 20:20 UTC · original
@MatyEjsr thanks for the run and the review. The ordering point is right: a queued enormous compile held a DXC worker and a
wait_for_memoryslot while it waited on the lock, and once its turn came it went into DXC without a new memory check.Fixed in
c4a169e:compile()now takes the turn on the caller's thread, before the job is sent to the pool, so a waiting enormous compile holds neither, and it is admitted against the memory left once the one before it has finished.compile_herekeeps only the-O0choice. The test (enormous_sources_compile_one_at_a_time, added in8d821a9) now goes throughcompile().Tested on
c4a169eunder Wine: thegpu::recomp::dxcmodule, 15 passed, 0 failed;cargo build --releasepasses.AI use
@eizispark on GitHub · 2026-11-24 20:33 UTC · original
Hardware test report — commit
c4a169eVerified
c4a169e93361441b8c60c55a6d2196cf66a6d89d(clean merge withmain4178e88): pass.Tested
32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 x64,rustc 1.100.0 (0ef1bc386 2026-11-09), debug tests + release smokecargo test --workspace --no-fail-fast -- --test-threads=4:777 passed, 0 failed, 41 ignored(1 skipped:heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows)gpu::recomp::dxc::enormous_tests::enormous_sources_compile_one_at_a_timepasseddisk_free_space_ex_reports_pls_quota,hle::d3d12x::device_x::tests::gpu_depth_buffer_created_for_unordered_access_is_placed,hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime,set_predication_buffer_state_and_kickoff,test_title_runs_and_game_folder_is_untouched) and both native RDNA4 wave64 GPU tests (gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware, plusconsole_wave64_compute_through_the_pso_hook_dispatch_and_read_back) passed cleanly on native Windows 11Regression run (
scripts/smoke.ps1, 60 s, warm shader/driver cache)main(85e38262ff94aecd75d6f83fa8156a8b7697bd13):PR (
c4a169e93361441b8c60c55a6d2196cf66a6d89d):Not tested
xcl pipelinespack compilation hitting> 8 MBHLSL sources concurrently, NVIDIA/Intel GPUs, gameplay past the menusAI use
@DavidM1911 on GitHub · 2026-11-24 21:16 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.Thanks!
@itsd-effex on GitHub · 2026-11-24 23:34 UTC · original
Per #1833: the
goal:world-loadlabel seems to be missing here. This PR is part of #1269 (compile time and memory) through #1657, which reports the symptom fromxcl shaders --precompile.AI use
@JJAutoCompare on GitHub · 2026-11-25 04:55 UTC · original
XCL PR #1660 verification
Clean detached head
c4a169e93361441b8c60c55a6d2196cf66a6d89d. The diff changes onlycrates/xcl/src/gpu/recomp/dxc.rs. It serializes HLSL sources larger than 8 MiB before they enter the DXC worker pool or wait for a memory slot.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).
dxc.exe --versionand XCL's compiler log both reported 1.9.2609.5.Tested
cargo build --workspaceandcargo test --workspace --no-runexited 0. The latter built 19 test executables. Both used unoptimized profiles with debug info and incremental compilation disabled.XCL_ADAPTER=NONE_CPU_ONLY,cargo test -p xcl --lib gpu::recomp::dxc::enormous_tests::enormous_sources_compile_one_at_a_time -- --exact --nocapturehad 1 passed, 0 failed, 0 ignored, and 0 skip markers. Four callers compiled distinct, small HLSL shaders marked to enter the large-source path. Each returned nonempty DXIL, peak gate occupancy was one, and final occupancy was zero.Invoke-ArcTest.ps1withXCL_ADAPTER=A770andRUST_TEST_NOCAPTURE=1,cargo test --workspace --no-fail-fast -- --test-threads=4exited 101. Across 20test result:lines (19 binaries and one doctest summary), the harness reported 761 passed, 16 failed, and 41 ignored. The PR test passed again.Workspace failures and skips
CreateComputePipelineStateerror0x80070057. Four reported mismatches in FMA overflow, implicit-LOD sampling, f16 high-half preservation, or wave64 pixel reductions.RSSetDepthBiasXcheck (#94). The top-right pixel was blue instead of green.SKIPPEDinpr1660-suite.log. Two reported no wave64. The other four reported tiled resources tier below 2, missingd3d12SDKLayers.dll, no heap windows, or no D3D12 debug layer. These skips provide no coverage.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
pr1660-suite.logand published.@raylitebull on GitHub · 2026-11-25 10:46 UTC · original
Diff on
c4a169e(crates/xcl/src/gpu/recomp/dxc.rs) is clean, CI passed, and dual-vendor verification (RX 9070 XT + RTX 3060 Ti + Arc A770) is complete.c4a169enow has a merge conflict indxc.rsagainst recentmainchanges; once rebased cleanly with green CI, it is ready to move forward.@itsd-effex on GitHub · 2026-11-25 12:31 UTC · original
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
mainthe lock would have nothing left to hold back.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).
@DavidM1911 on GitHub · 2026-11-26 06:07 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.Pull request closed