Skip to content

Shaders: isolate DXC compiler heaps for parallel AOT - #688

Closed
bmjask wants to merge 1 commit into
xcl-dev:mainfrom
bmjask:shaders/aot-private-heaps
Closed

bmjask wants to merge 1 commit into
xcl-dev:mainfrom
bmjask:shaders/aot-private-heaps

Conversation

@bmjask

@bmjask bmjask commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Part of #156. Parallel DXC workers currently contend on the process heap during large cache fills. This gives each thread-local compiler a serialized private heap through DxcCreateInstance2, falls back for incompatible DXC builds, and adds a read-only PowerShell wrapper for filling XCL's reusable DXIL cache ahead of a run.

What is in it

  • crates/xcl/src/gpu/recomp/dxc.rs: private IMalloc heap per compiler, compatibility fallback, and allocator/concurrency tests
  • scripts/precompile-shaders.ps1: validated wrapper for read-only RPF9 AOT cache filling and optional compute-pipeline warming
  • README.md: generic AOT usage

Tested

  • Windows 11 Pro build 26200; Intel Core i9-12900K; NVIDIA GeForce RTX 4090, driver 32.0.16.1088; Rust/Cargo 1.100.0; debug and release
  • cargo test -p xcl --lib private_heap_tests -- --test-threads=1 --nocapture: 2 passed, 0 failed, 0 ignored
  • cargo check -p xcl --lib: passed
  • scripts/precompile-shaders.ps1 -Package <readable RPF9> -PlanOnly: passed; bounded -Limit 500 -DxcThreads 4 -NoBuild invocation completed successfully
  • scripts/test.ps1: 694 passed, 0 failed, 41 ignored; 2 GPU tests skipped (no wave64)
  • cargo build --release -p xcl: passed
  • On this machine, a large cache fill used 19.3-19.5 effective compiler cores with private heaps versus about 2.3 with the shared process heap

Regression run

Upstream main:

xcl-smoke v1
commit: 91f9a5e9f03156ea82dc55a18f7704862da7a5db
gpu: NVIDIA GeForce RTX 4090
title: game
seconds: 60
exit: 0x0
frames shown: 1602 (PresentX 1602)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14702 MB

This PR:

xcl-smoke v1
commit: 0b82a3df0d3c01ec858b85833e1ea89496726b27
gpu: NVIDIA GeForce RTX 4090
title: game
seconds: 60
exit: 0x0
frames shown: 1581 (PresentX 1581)
presents per 2 s (last 3): 59 59 59
device removals: 0
crashes: 0
peak commit: 16403 MB

Not tested

  • AMD or Intel GPUs
  • -Pipelines driver-cache warming
  • An earlier head smoke ended in a title-thread access violation at 48 seconds. That run had 45 DXIL cache hits and zero compilations, so the changed allocator path was not active; the immediate clean rerun is reported above.

AI use

  • Codex with GPT-5 wrote the implementation, tests, wrapper, and description and ran the reported validation. The human requester directed the branch and PR creation in this session.

@thehollowedone

Copy link
Copy Markdown
Contributor

Tested

The installed Windows SDK DXC (1.8.2502.11) took the private-heap path on 0b82a3d. A scratch fixture submitted 24 distinct synthetic compute shaders through XCL’s normal dxc::compile path with eight workers. All 24 emitted DXIL modules matched main at 91f9a5e byte for byte in two fresh processes per revision. Each run dispatched one of the modules on the RTX 3080 Ti and matched all 1,600 expected readback words.

Compile batch wall times overlapped on this workload: 365 and 372 ms on main, 371 and 368 ms with private heaps. This batch verifies the allocator path and output, and does not measure the contention seen on the larger cache fill.

cargo test --offline --locked -p xcl --release --test synthetic_parallel_dxc -- --nocapture --test-threads=1 passed 1/1 in all four processes. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC.

Not tested

Retail cache filling, driver pipeline warming, allocator fallback, and the full workspace suite.

AI use

Codex with GPT-6.2 Sol wrote the scratch fixture, ran the tests, and drafted the report.

@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of 0b82a3df0d3c01ec858b85833e1ea89496726b27 on AMD RDNA4. I merged it onto current main 91f9a5e locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 694 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 654 passed, 0 failed, 21 ignored
  • 0 SKIPPED; private_dxc_allocator_obeys_imalloc_contract and private_allocators_compile_on_two_threads pass; the installed DXC took the DxcCreateInstance2 path.

Review: Each compiler gets a serialized private heap (HeapCreate(0, …), not HEAP_NO_SERIALIZE, so DXC's own threads are safe), and the heap is destroyed only when the COM IMalloc is released; DXC keeps a reference to it from the objects it allocates, so a blob that outlives the compiler keeps the heap alive. Without DxcCreateInstance2 it falls back to DxcCreateInstance. I did not review scripts/precompile-shaders.ps1 in detail.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

@upipibi upipibi mentioned this pull request Nov 24, 2026
@LocranKing

Copy link
Copy Markdown

Tested on Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32).

Tested

  • Commit: 0b82a3df0d3c01ec858b85833e1ea89496726b27 (pr-688, clean tree)
  • Hardware / software: Windows 11 Home Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, driver 32.0.16.2101), rustc 1.100.0 (x86_64-pc-windows-msvc, MSVC 14.44.35207), DXC 1.9.2602.17 (SDK 10.0.26100.0), --release
  • cargo test --workspace --release --no-fail-fast -- --test-threads=4: 694 passed, 0 failed, 41 ignored, exit 0; 2 (no wave64) skipped (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware)

Regression run (scripts/smoke.ps1, 60 s, XCL_NETWORK=0, title folder name redacted)

main (f4ce27c):

xcl-smoke v1
commit: f4ce27ceb6d1b0576d0c659b713b674778bf1968
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 537 (PresentX 538)
presents per 2 s (last 3): 17 17 18
device removals: 0
crashes: 0
peak commit: 15475 MB

PR #688 (0b82a3d):

xcl-smoke v1
commit: 0b82a3df0d3c01ec858b85833e1ea89496726b27
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 455 (PresentX 456)
presents per 2 s (last 3): 18 19 18
device removals: 0
crashes: 0
peak commit: 15473 MB

Not tested: scripts/precompile-shaders.ps1 AOT cache-fill run, debug build, XCL_SAMPLE_* tests on this branch, AMD / wave64 hardware.

AI use: Antigravity (Gemini 4 Hydrogen) ran the build, tests, and smoke runs and drafted this report from the command outputs.

@raylitebull

Copy link
Copy Markdown
Member

Code/CI review only (not independently runtime-tested by me): clean merge with both checks green (Build and test + PR description). Isolating DXC compiler heaps per thread removes allocator contention during parallel AOT. Recommend merging, @ivall.

@larelgit

Copy link
Copy Markdown

Measured on the newer retail title's own shader pack: filling the DXIL cache with all of its compute programs goes from under one busy core to about ten with this PR.

Tested

Not tested

  • The PR head on its own: only the local merge above was run.
  • cargo test on this tree.
  • A run of the title on this cache.
  • The PR's scripts/precompile-shaders.ps1 wrapper.

AI use: Claude Code (Claude Opus 5.5) ran the precompiles, sampled the CPU time and wrote this report. The runs were on the hardware above.

@grahamster2

Copy link
Copy Markdown
Collaborator

Test report: 0b82a3d merged onto main 47efa2e (clean merge, local merge commit b609d32), on the retail title that stops at the #232 / #505 watchdog. Result: in an equal 8-minute cold DXIL fill, this PR compiled 25 % more programs. On a machine whose caches are already warm it doesn't change the in-game outcome: both builds stop at the same point.

Tested

  • NVIDIA GeForce RTX 3080 10 GB (driver 32.0.16.1088, 32-lane waves), AMD Ryzen 5 7600X (6 cores / 12 threads, 11 DXC threads), 32 GB, Windows 11 26200, rustc 1.94.0, release.
  • cargo test --release -p xcl --lib private_heap_tests -- --test-threads=1: 2 passed, 0 failed (2 runs).
  • AOT throughput. xcl shaders <shaders.rpf> --precompile --windows 4 --only cs (what scripts/precompile-shaders.ps1 runs), each build into its own empty XCL_DXIL_CACHE, stopped after the same 8 min:
main this PR
programs compiled in 8 min 669 839 (+25 %)
DXIL written 251 MB 636 MB
peak private memory of the precompile 9 GB 13 GB
lowest free RAM during it 9.9 GB 6.2 GB

It reports 26,503 shaders to go through, so a full fill here would take several hours. I didn't run one, or -Pipelines.

  • The title. 1 warm-up run per build (not counted), then 2 measured runs. 180 s, XCL_NETWORK=0, A at 14/17/21/25/31 s, frame dumps every 30 frames. These used the default DXIL cache and the driver cache, both warm from earlier runs on this machine. Presents per second:
main run 1 / 2 this PR run 1 / 2
intro video (4–16 s) 23.2 / 23.2 22.9 / 23.1
menus + loading (16–44 s) 28.6 / 29.0 28.9 / 28.9
while streaming (44–84 s) 8.5 / 7.5 7.3 / 7.5
presents stop at 76 / 74 s 72 / 74 s
new DXC compiles in the run 28 / 7 12 / 18
longest driver compute-PSO build logged after 60 s – / 13.4 s 45.2 s / –
Wait*BitValueX timeouts 0 / 0 0 / 0
watchdog write at +0x23cf683 103.4 / 101.4 s 99.4 / 101.4 s
peak commit 31.6 / 32.0 GB 32.3 / 32.1 GB
  • No in-world frame was ever presented. The last frame dumps (60–70 s) are the loading screen, all lit; then presents stop.
  • Thread dumps at 92 s, both builds: title render threads in pso_async::resolve_wait (from draw_instanced / execute_indirect) while DXC compiles a program they need, on xcl-pso* and title threads. The driver-compile line here is the driver blobs kept on disk (this one: N ms) log, which only covers compiles that finished.
  • So per run, a few new DXC compiles and the odd long driver build still block a render thread past the title's ~28 s watchdog. That happens with either build.

Regression run (no presses, 60 s; the title folder is a neutrally named junction)

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 3080
title: xcl-title
seconds: 60
exit: 0x0
frames shown: 1657 (PresentX 1657)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17446 MB

PR merged onto main:

xcl-smoke v1
commit: b609d32db4eb5d66494a244b04ccbf22c34ebe72
gpu: NVIDIA GeForce RTX 3080
title: xcl-title
seconds: 60
exit: 0x0
frames shown: 1655 (PresentX 1655)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17716 MB

Not tested

  • A full AOT fill (several hours here) and -Pipelines driver-cache warming, so not whether a fully warmed cache gets the title in-game.
  • A cold-cache run of the title with each build (my caches were warm from earlier runs).
  • AMD / Intel GPUs; a CPU with more cores than 12 threads, where the heap contention this PR removes should matter more.

AI use: Claude Code (Claude Opus 5.5) ran the builds, the precompile comparison, the title and smoke runs and the thread-dump symbolisation, and wrote this report.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

Linux (Wine + vkd3d-proton) + NVIDIA test of 0b82a3d on main 67a3735, 6 alternated runs of 100 s of a retail title: with the private DXC heaps the title's burst of pipeline creation after its loading screen starts ran at full speed in 3 of 3 runs, where main crawled in 3 of 3 and never reached its world load. So under Wine this change does more than speed up cache filling: it stops DXC from starving the title's own threads.

Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging (Wayland driver), vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, VKD3D_CONFIG=ignore_shared_fence. RTX 4070 12 GB (driver 615.71.09, 32-lane waves), Ryzen 9 9950X3D, 64 GB RAM. Release, cross-compiled to x86_64-pc-windows-gnu (rustc 1.98.0), DXC 1.9.2609.5, XCL_NETWORK=0, every other setting at its default. Retail title 1.0.2.1, the first-run screens completed once and no story progress, one A press at 44.8 s through XCL_PRESS_AT. used-pipelines.txt held 1,131 shader sets from earlier runs that had reached the world load, so the preload of #690 had compute programs to compile. 0b82a3d merged onto 67a3735 without conflicts. main moved to 384f7f7 during the series; its runs 2 and 3 are on that commit.

Tested

  • cargo test --release -p xcl --lib private_heap_tests under Wine, on the merge: 2 passed, 0 failed.
main, run 1 / 2 / 3 + 0b82a3d, run 1 / 2 / 3
DXC: compiler workers use private heaps – logged / logged / logged
[SHADER] lines from 60 s to 80 s 414 / 274 / 386 10,466 / 10,465 / 10,465
DirectStorage requests from 70 s to 100 s 1,063 / 1,072 / 1,065 51,221 / 55,027 / 50,986
presents from 80 s to 100 s 587 / 587 / 585 (the loading pictures, 29 fps) 83 / 122 / 48 (the world loading)
DXIL cache hits, programs compiled 2,661, 2 / 2,660, 1 / 2,660, 1 2,657, 4 / 2,661, 1 / 2,668, 1

In run 1 with this change a compute pipeline of the preload was being built from 11 s to 62 s, across the start of the burst, and the burst was still at full speed.

Why main crawls here, from thread dumps of a slow run (main beaa245 + #684, ntdll.dll frames named with nm on Wine's ntdll.dll): DXC and the title wait on the process heap's one critical section.

xcl-dxc-0:         RtlEnterCriticalSection < RtlAllocateHeap < combase.dll+0x181f6 < dxcompiler.dll+0xdb83e < …
title, 5 threads:  RtlEnterCriticalSection < RtlAllocateHeap < gpu::rdna2::decode < gpu::xbox::parse < gpu::shader::capture < null::capture_stream_desc < real::dev_create_pipeline_state

Read

  • dxc.rs:440: the private-heap path was taken in all three runs with DXC 1.9.2609.5 under Wine; the fallback warning at :445 did not appear.
  • dxc.rs:449: only E_INVALIDARG from DxcCreateInstance2 falls back to DxcCreateInstance; any other failure is returned as an error, and the compiler is not created. The description says it falls back for incompatible DXC builds. Is E_INVALIDARG the only answer such a build gives, or should every failure of the private-heap path fall back?
  • The description presents this as a gain for parallel cache filling. The runs above are a second effect it does not mention: with the default preload, a title run under Wine that could not reach its world load now does.

Not tested: past 100 s; scripts/precompile-shaders.ps1 (PowerShell, not run here); native Windows; the rest of the test suite; AMD and Intel.

AI use: Claude Code (Claude Fable 5.2) read the diff, built the tree, ran the title six times with XCL_PRESS_AT, took the thread dumps, named the frames and wrote this report.

DXC workers otherwise contend on the process heap during parallel cache fills. Give each thread-local compiler a serialized private heap through DxcCreateInstance2, with a compatibility fallback, and add a read-only wrapper for filling the DXIL cache.

Measured on this machine: 19.3-19.5 effective compiler cores with private heaps versus about 2.3 with the shared process heap.

Part of #156.

Assisted-by: Codex (GPT-5)
@bmjask
bmjask force-pushed the shaders/aot-private-heaps branch from 0b82a3d to 760f742 Compare November 24, 2026 15:09
@bmjask

bmjask commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the compatibility question in 760f742: any failed DxcCreateInstance2 private-allocator attempt now logs its HRESULT and falls back to DxcCreateInstance. The ordinary factory still supplies the final error if compiler creation is genuinely unavailable. Verified on Windows SDK DXC 1.9.2602.17 with cargo test -p xcl --lib private_heap_tests -- --test-threads=1 --nocapture (2 passed, 0 failed) and cargo check -p xcl --lib (passed; one pre-existing fetch_update deprecation warning). The fallback itself was not forced on this DXC build.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

@bmjask 760f742 has the same tree as 0b82a3d, the head I tested, so the fallback change does not seem to have been pushed. Both commits have tree bf82ad2756be8ee68c539a49c3236984c41a4179 and parent 91f9a5e; only the commit date differs.

crates/xcl/src/gpu/recomp/dxc.rs:442 to :450 at 760f742 still read:

            } else if hr.0 == crate::util::E_INVALIDARG {
                …
                p = std::ptr::null_mut();
            } else {
                return Err(format!("DxcCreateInstance2: {hr:?}"));
            }

The numbers in my comment above therefore hold for 760f742 as they are. I will rerun the two tests under Wine when the change is on the branch.

AI use: Claude Code (Claude Fable 5.2) compared the two commits and wrote this.

@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (760f742)

Hardware / environment

  • Tested detached commit 760f742b42383a53b344d957217f4c4e4f93b2dd for PR Shaders: isolate DXC compiler heaps for parallel AOT #688.
  • Windows x64 build 26200, AMD Ryzen 7 3800X 8-Core Processor, 12 logical processors visible to the test process.
  • Rust 1.100.0 (0ef1bc386), host x86_64-pc-windows-msvc, Cargo 1.100.0. Unoptimized test profile with debug info and incremental compilation disabled.
  • XCL loaded dxcompiler 1.9.2609.5 (01b62ad4) and dxil 1.9.2609.5.

Commands and results

  • cargo test --workspace --no-run exited 0 and built the workspace test executables. This command ran zero tests.
  • cargo test -p xcl --lib gpu::recomp::dxc:: with XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1 exited 0. The UTF-8 log reports 16 passed, 0 failed, 0 ignored, and 659 filtered out. It contains 0 lines beginning with the case-sensitive prefix SKIPPED .
  • Both commands ran outside the Arc GPU mutex. The focused filter includes all DXC module tests, including both additions in the PR.

Observed behavior

  • private_dxc_allocator_obeys_imalloc_contract passed. It checked ownership and size reporting, preservation of existing bytes on growth, and the allocator's zero-size and null-pointer cases.
  • private_allocators_compile_on_two_threads passed. Both threads compiled a small CS 6.6 shader and produced a valid DXIL container. XCL logged DXC: compiler workers use private heaps.
  • The 14 existing DXC version and cache tests also passed. The worktree was clean after verification.

Not tested

Full GPU workspace suite, whole-pack AOT runs, game smoke runs, direct execution of the new PowerShell wrapper, and fallback with older DXC builds.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr688-focused.log and published.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

@Prime1997 Prime1997 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs changes — keep the useful work. Checked head 760f742b42383a53b344d957217f4c4e4f93b2dd.

The private-heap compiler path still returns early when allocator creation fails, and falls back from DxcCreateInstance2 only for selected errors. A failure of this optional path can therefore prevent the ordinary compiler entry point from being tried. The local repair retries the ordinary entry point for allocator, factory and null-object failures; injected factories exercise the decisions without loading DXC.

Local validation: head plus an uncommitted repair and regression fixtures: 3 passed, 0 failed, 0 ignored, 0 skipped. These are CPU checks of the local repair, not a claim that the unmodified PR passed them. Separate negative-control checks produced 1 passes and 2 expected failures.

Build command: cargo test --locked --offline -p xcl --lib --no-run --message-format=json --target-dir <isolated target> (only the private absolute target path is replaced here). Each selected test executable was then run separately as <test-exe> <exact-name> --exact --test-threads=1 --nocapture.

Selected exact tests
  • gpu::recomp::dxc::fallback_tests::private_creation_failures_try_process_heap
  • gpu::recomp::dxc::fallback_tests::unavailable_private_heap_tries_process_heap
  • gpu::recomp::dxc::fallback_tests::missing_private_entrypoint_uses_process_heap

Latest-main source comparison: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7; full-head merge-tree result: conflicts. This is a source compatibility check, not a tested integration build. Local repair patch SHA-256: 55d83bd0c87cfedeb27d5dae7b204674c4ed57736b681dacc2734cc6aaff4e62.

Windows 11 Pro build 26200, i5-10400, 32 GiB RAM, Rust 1.100.0 MSVC debug tests. RTX 3060 Ti / driver 32.0.16.1714 is present but was not exercised. No full-suite, GPU or title result is claimed; installed builds and game data were untouched.

AI use: Codex (GPT-6) reviewed the source, prepared the local repair/fixtures, ran the checks and drafted this report.

Optional temporary Discord for coordinating this contributor work, helping test and comparing results.

@Prime1997 Prime1997 mentioned this pull request Nov 26, 2026
@Royalflamejlh

Copy link
Copy Markdown
Contributor

Since #2555, main runs XCL's --precompile pass before every launch. I merged 760f742 onto main 8b957be. From an empty cache, it cut the pixel-shader part of that pass (980 programs) to about a third of main's time: 128 and 143 s, against 396 and 379 s. The DXIL was byte for byte the same in all four passes.

Setup: Fedora 44, Wine 11.21 Staging, Ryzen 9 9950X3D, no GPU used; release x86_64-pc-windows-gnu, DXC 1.9.2609.5, XCL_DXC_THREADS=8. xcl shaders shaders.rpf --precompile --split 1 --only ps --limit 12000 on a retail pack, from an empty DXIL cache each time: the precompile function prepare_for_launch calls (the launch also compiles the other stages and builds the pipelines). The merge (da6e952, local) conflicted only in the use line at the top of dxc.rs and in README.md; I kept both sides of each.

round (+ 760f742 ran first in each) main 8b957be + 760f742
1 395.6 s 128.1 s
2 379.1 s 143.2 s
  • Each pass compiled 980 programs with 0 errors. The 980 DXIL files were identical in all four passes, 76,096,620 B in all.
  • DXC: compiler workers use private heaps was logged in both passes with the change.
  • cargo test -p xcl --lib -- gpu::recomp::dxc on the merge, under Wine: 22 passed, 0 failed, the two private_heap_tests among them.
  • The machine was shared: another bench's title run was running through both passes with the change, and through most of main's (none for about 3 of round 1's 6.6 minutes and 1 of round 2's 6.3).
  • nvidia-dev already has this change as 3842807a; amd-dev and main do not. amd-dev's worker processes (d92b36ee) build only the compute pipelines; its DXC compiles still run in one process.

Read: Prime1997's point holds at 760f742: when DxcMalloc::new() fails (dxc.rs:435) or DxcCreateInstance2 returns anything but success or E_INVALIDARG (:448-450), compiler() returns before DxcCreateInstance is tried. Both passes with the change took the private-heap path, so the fallback was not exercised here.

Not tested: the launch itself (xcl run), only the pass it calls; the rest of the test suite on the merge; other thread counts; native Windows; AMD; the rest of the pack (these are the pixel shaders among its first 12,000 records); --pipelines; scripts/precompile-shaders.ps1.

AI use: Claude Code (Claude Opus 5.5) ran the passes and wrote this comment.

Posted without review by a person: the account owner was away and reads replies later.

Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 26, 2026
…roll

`ballot_px_quad` took its quad's four members in an `[unroll]` loop. It
is called in most translated pixel shaders, often hundreds of times, and
DXC unrolls every inlined copy: on a 395 KB one with 84 calls,
`-ftime-report` put 22 % of the compile in "Dxil Loop Unroll" and 9 %
more in "Unroll loops" and LCSSA. The four members now come from
`ballot_px_member`, so there is no loop left in the pixel prelude.

On a retail pack, 282 pixel shaders compiled in-process on 8 threads
took 74.9 s instead of 124.1 s on Windows (Ryzen 7 5700X3D). Under Wine,
XCL's own pass over 980 of them took 60-69 s instead of 105-108 s with
xcl-dev#688's private DXC heaps; without them it was slower, 435-463 s against
386-397 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 26, 2026
…roll

`ballot_px_quad` took its quad's four members in an `[unroll]` loop. It
is called in most translated pixel shaders, often hundreds of times, and
DXC unrolls every inlined copy: on a 395 KB one with 84 calls,
`-ftime-report` put 22 % of its pass time in "Dxil Loop Unroll" and 9 %
more in "Unroll loops" and LCSSA. The four members are now written out,
in the form thehollowedone gave in review.

On a retail pack, 282 pixel shaders compiled in-process on 8 threads
took 72.1 s instead of 125.1 s on Windows (Ryzen 7 5700X3D). 980 of them
through dxc.exe took 505 s instead of 854 s with DXC 1.9 and 575 s
instead of 961 s with DXC 1.8. Under Wine, XCL's own pass over the 980
took 59 s instead of 116 s with xcl-dev#688's private DXC heaps; without them
it was slower (428 s against 387 s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 26, 2026
…roll

`ballot_px_quad` took its quad's four members in an `[unroll]` loop. It
is called in most translated pixel shaders, often hundreds of times, and
DXC unrolls every inlined copy: on a 395 KB one with 84 calls,
`-ftime-report` put 22 % of its pass time in "Dxil Loop Unroll" and 9 %
more in "Unroll loops" and LCSSA. The four members are now written out,
in the form thehollowedone gave in review.

On a retail pack, 282 pixel shaders compiled in-process on 8 threads
took 72.1 s instead of 125.1 s on Windows (Ryzen 7 5700X3D). 980 of them
through dxc.exe took 505 s instead of 854 s with DXC 1.9 and 575 s
instead of 961 s with DXC 1.8. Under Wine, XCL's own pass over the 980
took 59 s instead of 116 s with xcl-dev#688's private DXC heaps; without them
it was slower (428 s against 387 s).

Co-authored-by: thehollowedone <36892342+thehollowedone@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 27, 2026
…roll

`ballot_px_quad` took its quad's four members in an `[unroll]` loop. It
is called in most translated pixel shaders, often hundreds of times, and
DXC unrolls every inlined copy: on a 395 KB one with 84 calls,
`-ftime-report` put 22 % of its pass time in "Dxil Loop Unroll" and 9 %
more in "Unroll loops" and LCSSA. The four members are now written out,
in the form thehollowedone gave in review.

On a retail pack, 282 pixel shaders compiled in-process on 8 threads
took 72.1 s instead of 125.1 s on Windows (Ryzen 7 5700X3D). 980 of them
through dxc.exe took 505 s instead of 854 s with DXC 1.9 and 575 s
instead of 961 s with DXC 1.8. Under Wine, XCL's own pass over the 980
took 59 s instead of 116 s with xcl-dev#688's private DXC heaps; without them
it was slower (428 s against 387 s).

Co-authored-by: thehollowedone <36892342+thehollowedone@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Royalflamejlh

Copy link
Copy Markdown
Contributor

With 760f742 merged, #2872 (my change that cuts DXC's work on pixel shaders) halved XCL's pass over 980 pixel shaders of a retail pack under Wine on 8 DXC threads, from 127 and 120 s to 64 and 63 s. On main alone it gained nothing. xcl shaders shaders.rpf --precompile --split 1 --only ps --limit 12000, from an empty DXIL cache:

tree time
main 8b957be 416.6, 395.3 s
+ #2872's change (48a4421, local: head 2dad32e's diff on 8b957be) 444.3, 428.3 s
+ 760f742 (this, merged by hand) 126.9, 119.5 s
+ 760f742 + #2872's change 63.8, 63.1 s
  • 2 rounds, the four trees in the same order in each. No title run was beside any pass, but another offline pass over compute shaders (8 compile threads, and pipeline builds on a GPU) ran from 41 s into the first pass to about a minute before the end of Recompiler: the pixel prelude's quad ballot has no loop for DXC to unroll #2872's second; only main's second pass was clear of it, and round 2's 120 → 63 s had it beside both. Fedora 44, Wine 11.21 Staging, Ryzen 9 9950X3D, no GPU, release x86_64-pc-windows-gnu, DXC 1.9.2609.5, XCL_DXC_THREADS=8.
  • Under Wine, on one DXC thread, Recompiler: the pixel prelude's quad ballot has no loop for DXC to unroll #2872's change alone took the first 282 of these shaders from 276.0 s to 148.1 s; on eight it took 153.5 s against main's 146.7 s (1 run each). A reading: on eight threads under Wine, the lock on the heap DXC's threads share sets the time, and 760f742 removes it.
  • On native Windows (Windows 11 Pro 26200, Ryzen 7 5700X3D, DXC 1.9.2602.17; a local debug test compiling the same 282 through dxc::compile_whole, 1 run each unless said), this pull request made no difference on 8 threads, 123.6 s against main's 124.1–125.1 s in 3 runs, and on 16 took 117.2 s against 137.3 and 139.8 s (2 runs). Recompiler: the pixel prelude's quad ballot has no loop for DXC to unroll #2872's change alone on 8 threads: 72.1 s against 125.1 s.

Not tested: the two together on Windows; the launch itself (xcl run), only the pass it calls; the other shader stages and the rest of the pack.

AI use: Claude Code (Claude Opus 5.5) ran the passes and wrote this comment.

Posted without review by a person: the account owner was away and reads replies later.

Royalflamejlh pushed a commit to Royalflamejlh/xcl that referenced this pull request Nov 27, 2026
Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 27, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 28, 2026
main gained 345 commits since 753e8b1, most of them bmjask's stack (xcl-dev#2959),
plus xcl-dev#2872, xcl-dev#3085 and xcl-dev#3086 from this branch. Conflicts, per PR:

- xcl-dev#2404 + xcl-dev#2633 (split chained ExecuteIndirect): main's xcl-dev#2959 took both over
  (ed98461, a05fbc4, 8626d5b: IndirectBuild/IndirectChain on a CBV root,
  one-command slicer, separate cache namespace). Main's side kept in
  dispatch_chain.rs, pso.rs (slicer, command signature, chain root),
  bind.rs (ExecuteIndirect path), device_x.rs (signature traits),
  pso_async.rs (no background whole build, so no build_waited_on), real.rs
  (ComputeBuild, driver_cache names) and shaders.rs (blob names). Dropped
  with them: slab_count, record_slicer, abi_signature_id names, the direct
  root-CBV constant blocks, list_x::predicated, the split.rs/runner.rs
  ExecuteIndirect test and the list_x chain-scratch test. Not in main: xcl-dev#2404
  ran the pieces before any whole form was built; main runs the whole form
  (built on the title's thread) until the indirect set is ready.
- xcl-dev#2707 (allocator reclaim): main has it (31930d8, 057f463, 8e7b566).
  alloc_pool.rs is main's, with xcl-dev#867's changes on top; bind.rs takes main's
  native_backing; xcl-dev#2707's tests and bind::push_uma_for_test go.
- xcl-dev#867 + xcl-dev#2477 (Wine vtables and fences), adapted to main's new code:
  real.rs keeps the in-place patching, UnadoptGuard and FenceProxy beside
  main's native_queue_* helpers; guards in cl_reset, bind_pipeline_exact,
  clear_pipeline_exact, reset_pc_allocator, the title ExecuteCommandLists
  closure and native_queue_execute; Signal/Wait unwrap the title's fence
  (also in native_queue_signal/wait); list_x guards in
  reset_reserved_segment and KickoffX's submit closures; create_raw_fence
  for main's new internal fences in alloc_pool.rs (SubmissionGate),
  title_textures.rs, present.rs, vram.rs, sparse.rs, cpu_writes.rs; tests
  as xcl-dev#2477 had them; runner.rs is main's plus submit_list.
- xcl-dev#1803 (heap addresses): kept, carried into main's PreparedSplit and
  PreparedAbiState (prepared_abi_io takes the heaps).
- xcl-dev#1368 (NodeMask 0): kept in compute_container, before main's per-node
  blob names, so names and pipeline use node 0.
- xcl-dev#1860, xcl-dev#2082 (cfg.rs, module/opt.rs): cfg.rs is 1567f72's version
  (xcl-dev#1860 on main's Succs); opt.rs is that plus xcl-dev#2082's arm and test.
- xcl-dev#2229 (rodata): kept through main's kernel.rs entry points;
  translate_entry_rodata loses wave32_only as main dropped per-GPU tables
  (3cde0cc); pso.rs and coverage.rs call it with main's options
  (no_remap, split for graphics); recomp Options keeps rodata and no_remap.
- xcl-dev#1975: kept in emit.rs and lower_valu.rs; its mesh barrier guard and its
  test dropped, main's wider guard (2ca9127) covers it; the now-unused
  lower::has_non_uniform_barrier goes.
- xcl-dev#2070 (64 MB stacks): pso_async::WORKER_STACK on main's worker, helper
  and preload threads; shaders.rs's piece threads on worker_thread.
- xcl-dev#2551 (whole forms prebuilt): split_whole_roots(false) is DirectChain,
  so the precompile builds every split program's whole form; main built it
  only for programs an earlier run used through ExecuteIndirect.
- xcl-dev#688 (dxc.rs imports), xcl-dev#2762 (host.rs log line), xcl-dev#3090 (list_x tests),
  arch/window-title-commit (present.rs with_commit on main's
  compiling_text), README.md: both sides.
- list_x.rs: main dropped title_textures::list_reset; main's side.
- sparse.rs, vram.rs: main's quarantine_tiles_for and per-device retire
  state, with create_raw_fence.
- xcl-dev#3090, xcl-dev#3092 tests: runner::device and Uma::block_len added from
  nvidia-dev (5 and 12 lines) so the lib tests compile.
- xcl-dev#751: its commit is already in main (b84e037, via xcl-dev#2844); it leaves the
  README table with xcl-dev#2404, xcl-dev#2633, xcl-dev#2707, xcl-dev#2872, xcl-dev#3085 and xcl-dev#3086.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
raylitebull pushed a commit that referenced this pull request Nov 28, 2026
…roll

`ballot_px_quad` took its quad's four members in an `[unroll]` loop. It
is called in most translated pixel shaders, often hundreds of times, and
DXC unrolls every inlined copy: on a 395 KB one with 84 calls,
`-ftime-report` put 22 % of its pass time in "Dxil Loop Unroll" and 9 %
more in "Unroll loops" and LCSSA. The four members are now written out,
in the form thehollowedone gave in review.

On a retail pack, 282 pixel shaders compiled in-process on 8 threads
took 72.1 s instead of 125.1 s on Windows (Ryzen 7 5700X3D). 980 of them
through dxc.exe took 505 s instead of 854 s with DXC 1.9 and 575 s
instead of 961 s with DXC 1.8. Under Wine, XCL's own pass over the 980
took 59 s instead of 116 s with #688's private DXC heaps; without them
it was slower (428 s against 387 s).

Co-authored-by: thehollowedone <36892342+thehollowedone@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 2dad32e)
@bmjask

bmjask commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Current-main audit (2026-11-29): already implemented; please close this PR.

Current main contains commit 3842807a2363f94f7dcf8d12c132ff898f0f617b, Shaders: isolate DXC compiler heaps for parallel AOT, explicitly cherry-picked from this PR. The dependency, README text, DxcCreateInstance2 allocator path, tests, and scripts/precompile-shaders.ps1 are present.

There is no remaining change to merge from this head. Cache impact of the carried implementation is intended to be byte-identical DXIL/PSO identity.

Review assisted by Codex; exact model name was not exposed in this session.

Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 29, 2026
main has merged nvidia-dev (xcl-dev#3203): its two-pass mesh, sparse and upload
paths now submit through real::native_queue_execute / _signal / _wait.
Those already carry xcl-dev#867's UnadoptGuard and unwrap_fence; the conflicts
and the main-only submit paths were resolved as follows.

Taken from main, the stack's version dropped (main does the same):
- recomp/dxc.rs (3): xcl-dev#688's private DXC heaps; main's form (3842807)
  falls back on any failure and never destroys a heap.
- device_x.rs (10): xcl-dev#3091 (cherry-pick 511a297); main's 7e24237 keeps
  interned shader copies for base pipelines. xcl-dev#3091's tests and its
  real.rs test counter (GRAPHICS_FALLBACK_ATTEMPTS) and README line go;
  xcl-dev#2753's console_bytes is re-applied on main's file.
- bind.rs (16): the stack's only change there was xcl-dev#1803, merged in main.
  main's file, plus the xcl-dev#2816 feedback-copy UnadoptGuard in
  poll_two_pass_feedback (ed887d2, from linux/stack-nvidia-dev).
- pso.rs: main has daae033 (multidimensional groups take direct DXIL,
  xcl-dev#3189's change), so the stack-only commit is in main; translate calls
  take main's translate_compute_rodata / translate_entry_rodata_rt32.
- list_x.rs tests: xcl-dev#3090's barrier tests were in twice (cherry-pick and
  main's merge); the cherry-picked copy goes.
- runner.rs device(), xbox.rs Fssm::rodata: added on both sides; one copy.
- README.md: the precompile-wrapper paragraph was added on both sides;
  one copy.

Both kept:
- build.rs (2): TRANSLATION_GLUE_REVISION "pso-glue-v5-linux-multidimensional-
  direct" (main's v5 + the stack suffix); translator sources keep xcl-dev#2229's
  cfg.rs and code_loads.rs, drop dxc.rs as main does.
- dxil/kernel.rs (6): TRANSLATOR_VERSION 13 (main 12; the stack's xcl-dev#2229
  head output differs, as on linux/stack-nvidia-dev); main's rt32 entry
  points with xcl-dev#2229's code_loads.
- dxil/lower.rs (4), lower_mem.rs (3), lower_window.rs (1), recomp/emit.rs
  (11), recomp/mod.rs (3), recomp/tests.rs (1), core_tests.rs: main has
  an earlier copy of xcl-dev#2229 (41f1a85); xcl-dev#2229's head (code_loads, xcl_cload
  / xcl_gload(hi, a)) is kept over it, as on linux/stack-nvidia-dev;
  main's loop_ids, IO slots, ps_mask_live_scc and rt32 mask kept beside
  it, and main's duplicate core_tests copy of the rodata test goes.
  lower_mem.rs keeps the stack's scratch_ptr insert-before-terminator line.
- real.rs (6): the class scan keeps `own` with main's
  release_through_its_own_vtable; xcl-dev#2477's in-place patch after main's
  two-pass defer hooks; q_signal_pc / q_wait_pc beside main's page
  mappings; the title ExecuteCommandLists keeps xcl-dev#867's list guards inside
  main's watch::in_driver scope; test modules of both.
- list_x.rs (1): xcl-dev#867's allocator / PSO guards with main's `on = pc_alloc`.
- sparse.rs (1): main's new_state, with xcl-dev#867's raw fences for the sparse
  and readback fences and the async readback fence pairs (as on
  linux/stack-nvidia-dev); pc_execute (main's texture_upload submit path)
  unadopts its list for the submit.
- title_textures.rs (1): main's early fence creation, as a raw fence.
- dstorage.rs (4): xcl-dev#2864's unpack cache on main's Cow source and stage
  buffers.
- xg.rs (2): main's copy_args (adccb7d) covers xcl-dev#684's argument fix;
  xcl-dev#684's destination guard kept.
- present.rs (1), gpu_compute_e2e.rs (1), README.md (2): tests and text
  of both.

linux/README.md: main line updated; xcl-dev#1599, xcl-dev#2082, xcl-dev#1803, xcl-dev#3090, xcl-dev#688,
xcl-dev#3091 and the stack-only multidimensional row leave the table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Review (head 760f742, diff read, not a merge-check; it conflicts with main, so not built or run):

  • Already merged: 760f742 was cherry-picked as 3842807 ("Shaders: isolate DXC compiler heaps for parallel AOT") and merged in 60380a2; git range-diff shows no code difference.
  • Two problems in this version were fixed afterwards in 6804673: the private-heap path fell back only on E_INVALIDARG (dxc.rs ~442-449), so any other DxcCreateInstance2 or HeapCreate failure made every later compile on that worker fail; and Drop called HeapDestroy (~417-419), which could leave memory DXC keeps after a compiler is released pointing into a destroyed heap when a thread exits.

Recommendation: close as merged via 3842807 (follow-up fix in 6804673).

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@throny

throny commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Closing as superseded: this change is already on main (3842807). 3842807 (private DXC heap, DxcMalloc, DxcCreateInstance2) and 6804673 (heap fallback) are on main; dxc.rs has DxcMalloc and DxcCreateInstance2 use; PR's only missing lines are the older unfallbacked variant

Two independent checks found this: Foniass's close list on #1607 and ours against current main. If something here is still missing on main, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

@throny throny added the duplicate This issue or pull request already exists label Dec 1, 2026
@throny throny closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.