Skip to content

Recompiler: memory windows from the descriptor heap (no per-access switch) - #680

Merged
ivall merged 4 commits into
xcl-dev:mainfrom
imnicho:recomp-heap-windows
Nov 24, 2026
Merged

ivall merged 4 commits into
xcl-dev:mainfrom
imnicho:recomp-heap-windows

Conversation

@imnicho

@imnicho imnicho commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

With more than one memory window every memory access of a translated shader is a switch over the windows' root UAVs, inlined once per window. That is what makes the big compute programs of a retail title slow to compile, in DXC and in the driver (#156, #346). Here window k is also a raw UAV in the shared descriptor heap and an access is one ResourceDescriptorHeap load or store.

Opt-in: XCL_HEAP_WINDOWS=1 turns the heap form on. Unset, a run is as on main: the shared heap is not made early, no window views are written, shaders are translated in the switch form under main's cache keys. It is off by default because of two NVIDIA reports in the comments, of which one is not explained yet (Why it is opt-in, below).

This is the heap-window part of #187 by @RemingtonWilcox, which was closed without being merged; in #186 the maintainer wrote that memory windows from the descriptor heap "fit where this should go - a PR on current main is welcome". The three commits keep their author; I carried them onto current main, left out that PR's physical-page change and its aperture experiments and compile-time bench, and measured them on a retail title. If the author would rather reopen their own, I will close this one.

What is in it

  • Recompiler: memory windows from the descriptor heap, no per-access switch (Memory windows from the descriptor heap (no per-access switch); NVIDIA OOM fallback; physical-page fixes #187 c3fb89e, 864ce8e, 33c92dd) – gpu/recomp/emit.rs (the accessors), mod.rs / pso.rs (Options::heap_windows, the HEAP_WINDOWS flag in the cache keys, opt-in: on with XCL_HEAP_WINDOWS=1), hle/d3d12x/console_heap.rs (the windows' raw views are the first 4 descriptors of the shared heap), bind.rs / list_x.rs / console_list.rs (a list that set no heap gets the shared one before an ABI draw or dispatch), shaders.rs (--precompile uses the same key), runner.rs (raw_window_uav, the test runner binds the heap). Tests: gpu_memory_windows_from_the_heap, gpu_raw_window_view_reaches_its_top (new file heap_window_tests.rs).
  • D3D12.X: SetDescriptorHeaps(0, NULL) clears the list's record of bound heaps (Memory windows from the descriptor heap (no per-access switch); NVIDIA OOM fallback; physical-page fixes #187 8b4e398) – list_x.rs, with its test.
  • D3D12.X: a pipeline the driver refuses with heap windows is built in the switch form (Memory windows from the descriptor heap (no per-access switch); NVIDIA OOM fallback; physical-page fixes #187 41d4506) – real.rs, pso.rs, test in tests/gpu_compute_e2e.rs. NVIDIA refuses a few big programs in the heap form with E_OUTOFMEMORY; they are built as before.
  • Recompiler: a heap window's view ends 32 bytes below 4 GiB (new; found and measured by @CharlyRien, Recompiler: memory windows from the descriptor heap (no per-access switch) #680 (comment)) – runner.rs (raw_window_uav), heap_window_tests.rs. The D3D12 runtime of Windows 11 23H2 (D3D12Core 10.0.22621) refuses a raw view that ends more than 4 GiB − 32 bytes from the start of its resource and removes the device; newer runtimes take the larger one. The view is capped there: in the heap form the last 32 bytes of a 4 GiB window read 0 and drop their stores (it was the last 4). The HLSL and the cache keys stay the same; gpu_raw_window_view_reaches_its_top checks up to the new end.
  • From review: the windows' views are made after the shared heap's lock is released (console_heap::set_window_views) – the device may be an adopted one whose UAV hook takes the heaps' lock, which other paths take first. Found and fixed by @anes66, with the test window_views_do_not_hold_global_during_device_calls; folded into the first commit with a Co-Authored-By.
  • On main's range check of the windows (f9e5ee9, merged after this PR was opened): in the heap form an xcl_w outside the windows reads 0, drops its store and zeroes an atomic's out by one comparison before the heap access, as the switch's default does. main's test of that rule runs in both forms now (gpu_heap_windows_reject_out_of_uma_aliasing).
  • Size: 623 lines added, 22 removed in 13 files; 232 of the added lines are the three test files and about 95 more the two tests in list_x.rs and console_heap.rs. Changed against Memory windows from the descriptor heap (no per-access switch); NVIDIA OOM fallback; physical-page fixes #187: the view's cap above, the test file holds only the raw-view test (and reports a missing GPU / DXC, or an adapter that makes no 4 GiB reserved buffer – the CI's – through skip_test), commit subjects carry their area.

Measured (this PC, hardware below; a retail title's shader pack, numbers only)

After main's range check of the windows, which changed both forms (measured on e999741 on main 1ec4c98; the head now differs from that by the opt-in default and a rebase over commits that do not touch the recompiler): the same 83 programs and method as below, 3 rounds, the forms in turn.

switch form (as main) heap form
step 1: DXC, empty cache 40.2 · 40.6 · 40.8 s 36.2 · 35.7 · 35.2 s
step 2: the driver, 83 pipelines it has not seen (83 made, 0 refused in every run) 238.3 · 219.9 · 234.8 s 59.6 · 63.6 · 65.8 s
DXIL of the 83 programs 8.3 MB, largest 1 066 KB 6.9 MB, largest 846 KB

Without the 5.8 s of reading the pack: the driver's part is 214 – 233 s against 54 – 60 s, about 4 times less, DXC's 34 – 35 s against 29 – 30 s. Before the range check it was 9 – 10 times (next table): the switch form got cheaper with it, and the heap form now pays one comparison an access.

As first opened (before main's range check; kept for the record):

xcl shaders <pack> --precompile --only cs --limit 22240: the first 83 compute programs of a retail title's pack, this change on main cb868b2 (13dcab8), release; the switch form is the same executable with XCL_HEAP_WINDOWS=0. 3 rounds, the two forms in turn, every run on an empty DXIL cache and under an executable name the driver had not seen (its shader cache is per executable). Step 2 is the same command with --pipelines on the DXIL cache step 1 filled (4 driver compiles at once). Seconds of the whole command; 5.6 – 5.9 s of each is reading the pack.

switch form (as main) heap form
step 1: DXC, empty cache 40.0 · 37.2 · 36.9 s 29.9 · 30.4 · 31.9 s
step 2: the driver, 83 pipelines it has not seen (83 made, 0 refused in every run) 329.9 · 363.0 · 341.8 s 41.7 · 40.3 · 40.5 s
DXIL of the 83 programs 7.6 MB, largest 975 KB 5.9 MB, largest 696 KB
  • Without the reading: the driver's part falls from 324 – 357 s to 35 – 36 s (9 – 10 times less), DXC's from 31 – 34 s to 24 – 26 s.
  • Step 2 run again answers from the driver's own cache in both forms (5.6 – 5.9 s), once that cache is complete. In 4 of the 6 cases it took one more run to be complete (25 s three times in the heap form, 257 s once in the switch form): the driver's doing, in both forms.

Tested

Regression run

main:

xcl-smoke v1
commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7
gpu: NVIDIA GeForce RTX 5080
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1378 (PresentX 1379)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14314 MB

PR (default: the switch form, as main):

xcl-smoke v1
commit: deb4b92b4a0ec8436a73c0683a9a0bd54f38985d
gpu: NVIDIA GeForce RTX 5080
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1388 (PresentX 1388)
presents per 2 s (last 3): 60 60 59
device removals: 0
crashes: 0
peak commit: 14316 MB

PR with XCL_HEAP_WINDOWS=1:

xcl-smoke v1
commit: deb4b92b4a0ec8436a73c0683a9a0bd54f38985d
gpu: NVIDIA GeForce RTX 5080
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1401 (PresentX 1401)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14325 MB

Each block was made after one run of that build and form that filled its DXIL cache (the heap form has its own cache entries); the log of the third block's run has the line memory windows from the shared descriptor heap, the second's does not. A second round of the three: 1392 (main), 1377 (PR), 1407 (PR with the form on). The head is rebased onto b7aa9f3, the commit of the main block.

Why it is opt-in: two reports below of NVIDIA setups where the heap form fails, neither of which this machine shows – @tycosnh: RTX 4090, driver 621.24, DXC 1.8.2502, #187's branch: the driver's compiler ends the process on compute programs when the title's world submits its first large compute batch; @ryosen0: RTX 3060 Ti 8 GB, this PR's earlier head: the device is removed at boot, right after the shared heap and the windows' views are made (the switch form is clean there). Against that, @milesah3ad's synthetic probe on an RTX 5080 (driver 621.14) had no abort with DXC 1.8 or 1.9, and this RTX 5080 (driver 610.47, DXC 1.9.2602.17) went through that compute batch in every run and made over 550 compute pipelines in the heap form with xcl shaders --pipelines (5 refused with an error code, none ending the process). For the second there is now a cause that fits (@CharlyRien, RTX 3090 on Windows 11 23H2, #680 (comment)): there the device removal at boot reproduces, and it is that system's D3D12 runtime refusing the windows' 4 GiB − 4 raw view, with the debug layer naming CreateUnorderedAccessView; it is not the driver. The fourth commit caps the view at 4 GiB − 32 bytes, the change they ran there (no device removal in two title runs, the heap tests pass). Whether @ryosen0's machine has that runtime is not confirmed. I cannot reproduce the removal on this PC (its runtime takes the larger view), so on my side the commit is checked only for doing no harm here: the suite and the three blocks above. The first report, the driver's compiler ending the process, is still neither reproduced nor explained (it did not come on an RTX 5090 or an RTX 5080 with that driver, nor on an RTX 4090 with an older one, in the comments below), so the form stays off by default; the default can change later, with more reports.

Not tested

  • AMD and Intel GPUs, and 64-lane hardware, on this head (on Memory windows from the descriptor heap (no per-access switch); NVIDIA OOM fallback; physical-page fixes #187's head its author reported the suite on an RTX 3090, and another contributor the two heap tests on an RX 6800).
  • The graphics side in the world: the title's first screens are drawn by translated VS / PS built with this change, the world's pipelines are not reached on this PC yet.
  • A title whose own lists bind their own descriptor heaps in unusual ways beyond what the two list tests cover.

AI use

Duplicate check (Gate A 02:15 UTC on main 9ce2070, Gate B 03:22 UTC on 91f9a5e, again 03:54, 04:39, 08:05 and 08:47 UTC, main 077ce40; again 17:03 UTC on b7aa9f3b): no open PR makes the windows come from the heap; read #187 (closed), #174 (links the accessors: DXC time only, the DXIL stays the same), #346 (docs: collects the measurements), #533 / #539 / #267 (schedule around slow compiles, do not change them), #573; opened since, other ways to cut the switch's cost: #1380 (big compute programs read all windows and select, the root UAVs stay) and #1439 (one switch for a multi-dword access).

🤖 Generated with Claude Code

@crosettiremi

Copy link
Copy Markdown

A single-program hardware result on RX 7900 XT, Windows 11 build 26100, AMD 32.0.32029.2010, SDK DXC 1.9.2602.17. I used the retail 1.0.2.1 tree-batch-cull compute program that previously occupied the AMD compiler during the world-loading watchdog (#505). Four memory windows, native wave64, zero static samplers.

On the local #680 stack, the descriptor-heap form produced 265,368 bytes of DXIL. The previously captured switch form was 346,956 bytes for the same input. The release precompiler with --pipelines made 1/1 GPU pipeline in 31.5 s including translation. An earlier switch-form run took 38.2 s on another build. The driver caches and build identities differ, so the timings are not a controlled speed comparison. The #680 stack passed 716 workspace tests with 41 ignored.

On a saved-profile game run with the heap form enabled and that one pipeline prebuilt, the last loading frames still showed artwork. At 213.511 s the driver reported DXGI_ERROR_DEVICE_HUNG and the title stopped at a breakpoint. Wait64 timeouts were still present. This was a local stack including #150, #267, #533 and #574, without the cross-queue bridge from #539. That run alone does not attribute the GPU hang to #680.

AI disclosure: Codex ran the tests and prepared this report.

@imnicho
imnicho force-pushed the recomp-heap-windows branch from 351a2b2 to 1ad9343 Compare November 24, 2026 03:54
@thehollowedone

thehollowedone commented Nov 24, 2026 •

Copy link
Copy Markdown

Tested

On 1ad9343, I translated the same synthetic pixel shader with both memory-window paths. The shader read a distinct value from each of two windows. A scratch extension to the native D3D12 draw fixture bound both test windows as root UAVs and raw heap descriptors.

All 1,024 pixels matched the expected values across four draws: red 0.25 for window 0 and red 0.75 for window 1, with identical readbacks between the switch-based and descriptor-heap paths. The focused test passed 1/1. D3D12 validation was enabled, with no reported errors.

cargo test --offline --locked -p xcl --lib scratch_graphics_memory_windows_match -- --nocapture --test-threads=1. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, DXC 1.8.2502.11, Rust 1.99.1 MSVC, debug.

Not tested

The title’s descriptor-heap rebinding path, additional memory windows, and retail graphics.

AI use

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

Update on 2c1a521

Seven stock synthetic tests passed with zero failed, ignored or skipped, using the same hardware and toolchain in release mode. The sparse 4 GiB UAV test, both memory-window readbacks, and the descriptor heap lock and rebind tests passed. In the stock OOM test, the injected error refused the stand-in first. The synchronous switch-form retry then passed its GPU readback.

I extended the stock async compute test in a scratch copy to inject one E_OUTOFMEMORY after the lazy stand-in was created and just before resolve_wait. It passed 1/1 with zero failures, ignores or skips. The deferred build retried exactly once, returned a registered real pipeline with its ABI root signature, and cleared the registration when the stand-in was released. Runtime code was unchanged from the PR. Driver process termination and retail loading were outside this test.

Commands used cargo test --release --offline --locked -p xcl with --lib <filter> -- --nocapture --test-threads=1 for gpu_raw_window_view_reaches_its_top, gpu_memory_windows, window_views_do_not_hold_global_during_device_calls, and unbinding_all_heaps_lets_the_shared_heap_be_bound_again. The integration runs used --test gpu_compute_e2e <filter> -- --exact --nocapture --test-threads=1 for heap_window_out_of_memory_falls_back_to_the_switch_form and async_compute_pso_registers_real_pso_and_not_standin.

AI use for this update: Codex (GPT-6, exact variant unavailable) ran the tests, extended the scratch fixture and drafted the update.

Rebase retest on e999741

On the same RTX 3080 Ti / 621.35 setup, both memory-window forms and the last-tile raw UAV fixture passed on DXC 1.8.2502.11 and 1.6.2112.16 (3/3 each). The two stock range-check controls also passed with DXC 1.8 (2/2). Zero failures or skips in these runs. This covers the small synthetic workloads only.

I ran cargo test --offline --locked --release -p xcl --lib -- --nocapture --test-threads=1 with gpu_memory_windows_above_4_gib, gpu_memory_windows_from_the_heap, gpu_raw_window_view_reaches_its_top, and the two reject_out_of_uma_aliasing filters. AI use: Codex (GPT-6, exact variant unavailable) ran the checks and drafted this update.

Opt-in routing on 95f34c1

On the same RTX 3080 Ti / 621.35, Windows 11 build 26300, Rust 1.99.1 MSVC and DXC 1.8.2502.11, I ran the synthetic compute fixture in three fresh processes with four memory windows. Unset and XCL_HEAP_WINDOWS=0 selected the switch path. XCL_HEAP_WINDOWS=1 selected the shared descriptor heap, with zero switch retries. All 1,536 GPU readback values matched in each run. The D3D12 debug layer reported live-object warnings at process exit, with no reported errors or device removal.

cargo build --release --offline --locked --workspace passed. cargo test --release --offline --locked -p xcl --test gpu_compute_e2e console_wave64_compute_through_the_pso_hook_dispatch_and_read_back -- --exact --nocapture --test-threads=1 passed 1/1 for each setting, with zero failures, ignores or skips. I added routing assertions to the test only. Retail loading and the full suite remain untested on this revision here.

AI use for this update — Codex (GPT-6, exact variant unavailable) added the scratch assertions, ran the tests, and drafted the update.

@tycosnh

tycosnh commented Nov 24, 2026

Copy link
Copy Markdown

Test report: heap-window form on NVIDIA (RTX 4090) with the newer retail title. The driver's compiler ends the process on compute programs.

Not a test of this PR's head. It is main dd2ae9a with #187's branch (the same heap-window form), #203 and #533 merged locally, release build. AI-assisted: found and written up with Claude Code (Claude Fable 5.2), from real runs on the hardware below.

Setup: RTX 4090 24 GB, driver 621.24 (32.0.16.2124), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, DXC 1.8.2502.11, Rust 1.100.0. XCL_NETWORK=0, TdrDelay 60.

What happens: the title gets through its menus, intro and loading art. When world loading submits its first large compute batch (about 7,100 dispatches in one 2 s window; 118 to 121 s on this base, 230 to 380 s on bases from a few hours earlier), the process ends with 0xc0000409 and one of these on stderr:

Program aborted due to an unhandled Error:
Invalid record (Producer: 'LLVM7.0.1' Reader: 'LLVM 7.0.1')
Never resolved value found in function (Producer: 'LLVM7.0.1' Reader: 'LLVM 7.0.1')

It is a fast-fail inside the driver's compiler, so no handler sees it and there is no XCL crash line. It reproduced in more than 10 runs across four bases.

Ruled out:

What stops it:

  • XCL_HEAP_WINDOWS=0: no abort in any run.
  • A local switch that builds only compute programs in the switch form and leaves VS/PS in the heap-window form: also no abort. So on this driver the problem is compute programs in the heap-window form. Draw shaders are fine.

A single 381 KB compute program sent through the switch-form fallback got one run past the abort, but a different program aborted in the next run, so it is not just one shader.

Not tested: this PR's exact head, AMD, other NVIDIA generations, DXC 1.9.

Suggestion: on wave32-only NVIDIA adapters, build compute programs in the switch form up front, since the existing E_OUTOFMEMORY fallback cannot catch a fast-fail.

Past the abort, the run reaches the title's GPU watchdog (+0x23cf683) about 30 s into world loading, as in #505.

@anes66

anes66 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

I found a lock-order issue in set_window_views on 1ad93431f1420e273ea7dc7b3a4a15f246aa10c9.

It holds GLOBAL while calling s.dev.CreateUnorderedAccessView. Once that device is adopted, the UAV hook calls console_heap::slot, which takes HEAPS. Slot/page allocation takes the locks in the opposite order, HEAPS then GLOBAL. Keeping device calls outside the guard avoids that inversion.

Patch: 87b1afd, directly on top of this PR's head. It snapshots the device/base/increment under the lock, then creates the views after releasing it. A child-process fake-device test checks that every UAV callback can acquire GLOBAL; it fails before the change and passes after it. The child isolates the shared heap state from the rest of the suite. No separate upstream PR opened.

Tested
Windows 10 Pro 19045, Ryzen 7 9800X3D, RTX 3060 12 GB / 32.0.16.2114, Rust 1.100.0 MSVC, DXC 1.9.2602.17, Agility SDK 1.620.2, debug, XCL_HEAP_WINDOWS=1.

  • Workspace build passed.
  • New regression: 1 failed before, 1 passed after.
  • cargo test --locked --workspace --no-fail-fast -j 4 -- --test-threads=1 --show-output: 697 passed, 0 failed, 41 ignored, with the patch committed unchanged as 87b1afd.
  • gpu_raw_window_view_reaches_its_top, gpu_memory_windows_from_the_heap and heap_window_out_of_memory_falls_back_to_the_switch_form passed on the GPU.
  • Two SKIPPED tests: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no native wave64). Sample variables were unset; early returns and skips remain included in the passed count.

Parallel-run blocker
The four-thread suite stalled both before and after this patch. A debugger stack from the patched run identifies a separate path:
sparse::init -> drop<State> -> real::res_release -> sparse::forget_buffer -> STATE.lock.
The old state is being dropped while STATE is held. Main f4ce27c already drops that state after releasing the guard; this PR's head still has the older assignment. Rebase onto that main before judging parallel-suite results. This patch does not fix the sparse-state deadlock.

The first parallel run also reported writes_land_after_the_queue as failed before stalling; the failure detail was not emitted before termination. It passed in the patched serial run. I have not established its cause.

Not tested
Retail smoke runs, large retail compute programs, release builds, AMD/Intel or native-wave64 hardware. This does not establish that the NVIDIA compiler fast-fail reported above is resolved, or that the PR is ready to merge.

AI use
Codex (GPT-6; exact variant unavailable) inspected the code and debugger stacks, wrote the patch/test, ran validation and drafted this report.

Current-main integration check
I rebased the three commits from this PR plus the lock fix onto main 64b3f35599bb7102f55d640e1a791e7d6dd3b175. The rebase needed no conflict resolution; git range-diff reports all four patches unchanged, and the original commit authors are preserved.

Tested and pushed 42fe3ca on test/pr680-current-main:

  • cargo build --locked --workspace -j 4: passed.
  • cargo test --locked --workspace --no-fail-fast -j 4 -- --test-threads=4 --show-output: 706 passed, 0 failed, 41 ignored, exit 0, with XCL_HEAP_WINDOWS=1 and the same RTX 3060/MSVC/DXC/Agility setup as above.
  • The same two native-wave64 tests reported SKIPPED. Sample variables were unset.
  • gpu_uma_import_check_at_init, the_sparse_state_is_replaced_outside_its_lock, writes_land_after_the_queue, the new lock regression and the heap-window OOM fallback all passed.

The four-thread stall was not reproduced on this main-based tree. This result is for the integration branch, not the unchanged PR head. No retail smoke run or large-shader/compiler-fast-fail validation was performed; those limitations remain. Codex performed this integration and validation as well.

@imnicho
imnicho force-pushed the recomp-heap-windows branch from 1ad9343 to 2c1a521 Compare November 24, 2026 04:39
@imnicho

imnicho commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks both – head is now 2c1a521 (rebased onto main 64b3f35; suite 706 passed / 0 failed / 41 ignored here, regression pair in the description).

@anes66 – confirmed: slot takes HEAPS and then GLOBAL, and set_window_views called the device with GLOBAL held. Your change is in, folded into the first commit with a Co-Authored-By (the PR's commits are kept one per logical change), and your test window_views_do_not_hold_global_during_device_calls with it; it passes here. The rebase also brings in main's sparse-state fix you point at.

@tycosnh – that is a blocker if it happens on this form in general, so the PR stays a draft and the description now says so. What I have from this machine (RTX 5080, driver 610.47, DXC 1.9.2602.17, Windows 10 19045), compute programs in the heap form, same title:

  • four runs went through the world's first large compute batch with no abort: 6 422, 7 293 and 7 206 dispatches in a 2 s window in three of them (the fourth had part of that batch skipped by D3D12.X: bound compute pipeline waits so slow compiles do not trip wa… #533);
  • xcl shaders <pack> --precompile --only cs --pipelines made over 550 compute pipelines; 5 were refused with an error code, none ended the process;
  • in the title runs the driver refused 1 – 2 pipelines a run with E_OUTOFMEMORY, which the fallback built in the switch form.

The two messages are the bitcode reader's, so the DXC version is my first suspect: yours is 1.8.2502, mine 1.9.2602.17 – and the driver differs too (621.24 against 610.47). If you can run once with DXC 1.9 beside xcl.exe (or tell me a program size that aborts, for a count of that size here), that would separate the two. I cannot change the driver on this machine. If it turns out to be the driver generation, building compute programs in the switch form where it happens – as you suggest – is the way; I would rather key that on what is measured than on "wave32-only NVIDIA", since this card is that too and does not abort.

AI use: Claude Code with Claude Fable 5.2 wrote this reply; the numbers are from runs on the machine named.

@LeonardoS11

Copy link
Copy Markdown

Test report: on NVIDIA, some compute programs in the heap-window form make the driver's compiler end the process instead of refusing the pipeline.

Setup

  • NVIDIA GeForce RTX 3080 Ti (12 GB, 32-lane waves), driver 621.24; Ryzen 9 5900X, 64 GB; Windows 11 Pro 26200; Rust stable-x86_64-pc-windows-msvc, release; DXC 1.8.2502.11 (Windows SDK 10.0.26100).
  • A clean release build of this PR's head 2c1a521, nothing else applied.
  • Command: xcl shaders <retail pack>\shaders.rpf --precompile --only cs --pipelines with XCL_PIPELINE_THREADS=12 (on the earlier head below it also happened with 1 and 6 threads).

What happens

  • 2c1a521: pipelines: 1300 made, 50 refused, then the process exits with code 127 at about 23,400 of the pack's 26,503 programs, with no XCL message.
  • On the earlier head 351a2b2 (in a local tree that also had other changes, so only as a pointer) I logged each program before it went to the driver. With one driver thread the process ended right after the driver got CS_RaytracingResolve_ae7b7f3c (733 KB of DXIL), and the driver printed on stderr:
    Program aborted due to an unhandled Error:
    Never resolved value found in function (Producer: 'LLVM7.0.1' Reader: 'LLVM 7.0.1')
    
    Skipping that family, the next one was indirect_diffuse_lighting:CS_FinalGather_1_0_0_1 (111 KB), same message. So it is not only the biggest programs. The exit code was 127 there too (0xC0000409 when run through Start-Process).
  • Switch form (XCL_HEAP_WINDOWS=0, same local tree with per-program logging, 12 driver threads): 24 CS_RaytracingResolve_ae7b7f3c variants (~920 KB each in this form) and CS_FinalGather_1_0_0_1 went through the driver, and the run went on to 625 pipelines made, 0 refused, no abort, when I stopped it.

So in the heap form, with_switch_fallback catches the pipelines the driver refuses, but not these: NVIDIA's DXIL reader aborts the process, and there is nothing to fall back from. A title that creates one of these pipelines at run time would end the same way.

Not tested

  • AMD and Intel; other NVIDIA drivers.
  • Whether the DXIL passes dxil.dll validation: it came out of DXC without an error, and I did not run the validator on it by hand.
  • I did not try to narrow which heap-window accessor pattern the reader chokes on.

AI use: Claude Code with Claude Opus 5.5 ran the builds and the runs above and wrote this report.

@imnicho

imnicho commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Final update, 07:15 UTC – please disregard the access violations I reported here: they come from my own local diagnostics build, not from this PR and not from main. Sorry for the noise.

What settles it, all on the same machine and the same warm caches, 3.5-minute runs:

build runs access violation other than the title's own stall exit (#232)
my diagnostics build (this PR's head + local logging and a changed lazy-commit handler), heap form 14 7
the same build, switch form (XCL_HEAP_WINDOWS=0) 5 3
main beaa245 + #684, nothing else 3 0
main 64b3f35 + #266 + #684 + this PR's head 2c1a521, switch form 3 0
the same, heap form (the default) 3 0

The nine runs without my diagnostics all end the way main does on this card: the title's own exit 31 – 61 s after its world's set-up begins. So for this PR the title result is what the description says, and the open points are the two NVIDIA reports above (the compiler's fast-fail on an RTX 4090, the device removal at boot on an 8 GB RTX 3060 Ti) plus the conflict with main.

(The earlier versions of this comment, for the record: first "it may or may not be this PR", then "the switch form has them too, so it is not this PR" – both written before I had run a build without the diagnostics.)

AI use: Claude Code with Claude Fable 5.2; the numbers are from runs on the machine named.

@ryosen0

ryosen0 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Data point for the open point: on RTX 3060 Ti 8 GB (driver 32.0.16.1742, Windows 11, DXC from SDK 10.0.26100) the heap form of 2c1a521 does not reach the world at all — the retail title dies at t≈2.5 s, during boot, reproducibly (4 of 4 default runs across two builds). This is earlier and a different signature than the warm-cache access violations above, so possibly a separate NVIDIA issue.

Sequence from the log (same in every failing run):

[0.69] UMA: 3 sparse VRAM window(s) (12 GiB VA) + 4095 MB coherent window at 0x400000000
[2.49] console descriptor heaps: one shader-visible PC heap of 1000000 view descriptors for all of them
[2.49] D3D12.X: memory windows from the shared descriptor heap (no per-access switch)
[2.54] D3D12.X: CreateHeap(0x4000000 bytes, type 1, alignment 0x0, flags 0xc0) refused (0x887a0005)
[2.54] sparse windows: no video memory for more tiles (0x887A0005)
[4.5]  D3D12 device removed: 0x887a0001 (invalid call/state)
[4.5]  unhandled exception 0x80000003 in game_scarlett_master.exe+0x2474606 (rsi=0x887a0005)

No draw has run yet (0 presents); the first sparse-pool CreateHeap comes back with the device already suspended. CheckFeatureSupport(OPTIONS19) on this driver reports no max, so the shared heap is made at the fallback 1,000,000 descriptors.

Controls on the same machine, same title, same session:

  • 2c1a521 with XCL_HEAP_WINDOWS=0 (switch form): clean — 2442 frames, 60 presents / 2 s, 0 removals, peak commit 14473 MB.
  • main builds (beaa245-era and earlier): clean every run tonight (several 90 s smokes on other PRs' heads, all based on main).
  • The stacked Memory/configurable uma windows #822 head e9705bb inherits this: default and XCL_UMA_WINDOWS=8 both die the same way at ~2.5 s; its switch form is clean.

So on this card the heap-window form breaks the device before any translated draw — the first thing after "memory windows from the shared descriptor heap" is a refused CreateHeap on an already-removed device. Whether the 1M-descriptor shared heap creation itself is what suspends the device on this driver, or the window-view creation right after, I can't tell without the debug layer (not installed here). If it helps I can run a build with extra logging around shared_heap/set_window_views, or test a smaller cap.

AI use: GPT-6.2 Astra (API model selector) in DSH built both heads, ran the smokes and controls, and drafted this comment; the human contributor reviewed the logs before posting.

@imnicho

imnicho commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@ryosen0 – thank you, that is a clear one, and it is this PR's: on main the shared heap is made when the title makes its first descriptor heap, with this PR it is made (and four raw views of the 4 GiB windows written into it) when unified memory is opened, before anything else. I cannot reproduce it on 16 GB of video memory, so yes please, either of the two you offer would tell them apart:

  • a smaller cap for the shared heap (if the device survives, it is the 1 000 000-descriptor heap that early), or
  • the log between shared_heap and each CreateUnorderedAccessView in set_window_views (if the heap is made and the device goes at a view, it is the raw view of a 4 GiB reserved buffer on an 8 GB card).

Where this PR stands, so nobody has to piece it together: three NVIDIA reports are open against the heap form – the compiler's fast-fail on an RTX 4090 with a newer driver and DXC 1.8 (@tycosnh), this device removal at boot on an 8 GB RTX 3060 Ti, and the E_OUTOFMEMORY refusals every NVIDIA card shows (covered by the fallback). The access violations I reported from this machine are not among them (see the update in my comment above: the switch form has them too). It also conflicts with main again. I am leaving it a draft; if the two reports cannot be resolved quickly I will turn it into an opt-in (XCL_HEAP_WINDOWS=1) so that it can be tested without touching anyone's default, and say so here before I push.

AI use: Claude Code with Claude Fable 5.2.

@milesah3ad

Copy link
Copy Markdown

Synthetic numbers for the heap-window form on an RTX 5080 (Blackwell), no game files. On this driver neither DXC 1.8 nor DXC 1.9 makes the driver abort, and the heap form builds 9–19× faster than the switch form.

Setup: RTX 5080 16 GB, driver 621.14 (32.0.16.2114), Ryzen 7 9800X3D, 64 GB, Windows 11 Pro 26300, rustc 1.100.0, release. This PR's head 2c1a521. AtomicInt64OnDescriptorHeapResourceSupported = true on this adapter.

Probe: milesah3ad/xcl nv680-probe (c583e10, one commit on this PR's head, local tooling, not for merging). It is QemmHD's pso156 generator (#156) with heap_windows added. It assembles RDNA2 compute programs (128 threads, wave64 + split_wave64, 4 memory windows, a load + store every round, a divergent if every 4th) and adds one of these shapes:

  • base: nothing extra
  • atomic: a returning 32-bit atomic add each round
  • atomic64: a returning GLOBAL_ATOMIC_UMAX_X2 each round, plus a GLOBAL_ATOMIC_CMPSWAP_X2 every 2nd round (in the heap form, InterlockedMax64 / InterlockedCompareExchange64 on a ResourceDescriptorHeap buffer)
  • loop: a uniform 4-trip backward-branch loop every 8th round
  • wave: a v_readlane each round

Each pipeline is built in its own process (CreateComputePipelineState, ABI root signature), so a fast-fail inside the driver shows up as an exit code instead of ending the run.

1. Aborts: none. Heap form, 4 shapes × 4 sizes × 2 seeds, 87 KB to 1.3 MB of DXIL: 32/32 built with DXC 1.9.2609.5 and 32/32 with DXC 1.8.2502.11 (the SDK's, the version in both abort reports). atomic64, heap and switch forms, 139 KB to 1.66 MB: 16/16 with DXC 1.9, and 14/14 with DXC 1.8. The last two DXC 1.8 switch-form programs were cut off by my time limit, not by an abort. Exit code 0 every time and nothing on stderr. I confirmed DXC 1.8 was the one loaded (xcl: DXC: dxcompiler 1.8.2502.11) and that its DXIL differs from 1.9's.

So on 621.14, DXC 1.8 alone does not trigger the abort for these patterns. That leaves the driver (621.24 in both abort reports; 610.47 and 621.14 don't abort) or a pattern these shapes lack: textures and samplers from the heap next to the window buffer, LDS, ray-tracing BVH instructions, or the much more irregular control flow of CS_RaytracingResolve / CS_FinalGather. Someone on 621.24 could settle the driver question with nv680_run.ps1 -Shapes atomic64,base -Heap 1.

2. Driver build time, heap form vs switch form (atomic64, same program in both forms, DXC 1.9, mean of 2 seeds, fresh seeds so the driver cache can't help):

rounds switch form heap form (this PR) speedup
250 211 KB, 7.0 s 139 KB, 0.76 s 9.2×
500 420 KB, 26.9 s 275 KB, 2.56 s 10.5×
1000 885 KB, 135.2 s 578 KB, 9.50 s 14.2×
1800 1664 KB, 568.3 s 1071 KB, 30.1 s 18.9×

For atomic64, DXC 1.8 matched within 5 % wherever both ran. On the other shapes, heap form only: base 87 KB → 0.41 s up to 642 KB → 10.5 s; wave 1.3 MB → 43 s.

Not tested

  • Driver 621.24 (the one that aborts), AMD, Intel.
  • Any retail program or title. These are synthetic shapes only, so they can't rule out a trigger in the retail programs.
  • Several creator threads at once (one per process here).

AI use

  • Claude Code (Claude Opus 5.5) wrote the probe and ran it on the machine above, and drafted this report. I checked the numbers against the run logs.

@imnicho
imnicho force-pushed the recomp-heap-windows branch from 2c1a521 to e999741 Compare November 24, 2026 08:05
@imnicho

imnicho commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main 1ec4c98: head is now e999741 (heads-up @broccolize, #822 is stacked on this).

  • main got a range check of the memory windows meanwhile (f9e5ee9: an address outside the windows reads 0 and drops its stores instead of landing in a live window). The heap form does the same now, with one comparison before the heap access, and main's test of that rule runs in both forms (gpu_heap_windows_reject_out_of_uma_aliasing).
  • Re-measured, because both forms changed: for the same 83 compute programs the driver now takes 220 – 238 s in the switch form and 60 – 66 s in the heap form (3 rounds; table in the description). That is about 4 times less, not the 9 – 10 times of the PR as first opened – the switch form got cheaper with the range check and the heap form pays the comparison.
  • Suite on e999741: 721 passed, 0 failed, 41 ignored; regression pair 1374 (main) / 1370 frames.
  • Still a draft, for the two NVIDIA reports above (RTX 4090 compiler abort, 8 GB RTX 3060 Ti device removal at boot). @ryosen0, if you rerun, this head is the one to take.

AI use: Claude Code with Claude Fable 5.2; the numbers are from runs on the RTX 5080 machine named in the description.

@imnicho

imnicho commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

This is opt-in now (head 95f34c1, on main 09940bb), as I said I would do if the two NVIDIA reports could not be resolved.

  • XCL_HEAP_WINDOWS=1 turns the heap form on. Unset (or anything else), a run is as on main: the shared heap is not made early, no window views are written into it, shaders are translated in the switch form under main's cache keys.
  • Why: @tycosnh's compiler fast-fail (RTX 4090, driver 621.24) and @ryosen0's device removal at boot (RTX 3060 Ti 8 GB) are neither reproduced nor explained on the machines that have run this, and a default that takes two setups down is not worth the compile time it saves on others. As an opt-in it can be tested without touching anyone's default, and the default can change later with more reports.
  • What stays: the measurements in the description (they compare the two forms), the E_OUTOFMEMORY fallback to the switch form, the lock-order fix, and the tests. The recompiler-level GPU tests set the option themselves and run as before; heap_window_out_of_memory_falls_back_to_the_switch_form goes through the runtime switch, so it reports SKIPPED unless the variable is set.
  • Suite on 95f34c1: 722 passed, 0 failed, 41 ignored, both as it is and with XCL_HEAP_WINDOWS=1 (with it, that test runs).
  • Regression runs (blocks in the description): main 1344 frames, this head 1376, this head with XCL_HEAP_WINDOWS=1 1369; a second round 1358 / 1328 / 1376. No crash or device removal in any.
  • @broccolize: Memory/configurable uma windows #822 is stacked on this – the heap form it builds on now needs XCL_HEAP_WINDOWS=1.
  • @ryosen0, @tycosnh: nothing changes for your setups unless you set the variable; if either of you has the time for the checks discussed above (a smaller cap for the shared heap; the log between shared_heap and each view), they are still the way to tell the causes apart.

AI use: Claude Code with Claude Fable 5.2 wrote the change and this note; the numbers are from runs on the RTX 5080 machine named in the description.

@imnicho
imnicho force-pushed the recomp-heap-windows branch from e999741 to 95f34c1 Compare November 24, 2026 08:48
@imnicho
imnicho marked this pull request as ready for review November 24, 2026 08:57
@broccolize

Copy link
Copy Markdown

Thanks for the heads-up, @imnicho. I’ll use XCL_HEAP_WINDOWS=1 when retesting #822 on the updated base.

@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). Opt-in XCL_HEAP_WINDOWS=1 descriptor-heap UMA windows are off by default, so safe to land while NVIDIA reports are investigated. Recommend merging, @ivall.

@JRamos1993

Copy link
Copy Markdown

Test report: the NVIDIA compiler abort does not reproduce on an RTX 5090 with the same driver (621.24), with either DXC 1.8 or 1.9, on this head or on 2c1a521.

Setup: RTX 5090 32 GB, driver 621.24; i9-14900KF, 64 GB; Windows 11 Pro 26200; release builds; XCL_HEAP_WINDOWS=1, XCL_PIPELINE_THREADS=4, XCL_NETWORK=0, empty DXIL cache for each run. Command: xcl shaders <retail pack>\shaders.rpf --precompile --only cs --pipelines. To keep each run short I added a local-only filter that skips programs whose name does not match, and one log line before and after each program goes to the driver. The translation itself is unchanged. Neither is part of this PR.

Head DXC Programs (DXIL size) Result
95f34c1 1.8.2502.8 1020 from the two program families in @LeonardoS11's report (80–1101 KB) 1020 made, 0 refused, no abort
95f34c1 1.9.2609.5 same 1020 (80–1101 KB) 1020 made, 0 refused, no abort
2c1a521 1.8.2502.8 247: the two programs named in that report, with their variants (108–879 KB) 245 made, 2 refused, no abort

Every program reached the driver and came back (the before/after lines pair up in all three runs). The run summary says "4 memory windows from the descriptor heap" each time, so the heap form was in use.

Reading: on Blackwell with 621.24, neither the DXC version nor the head brings back the abort. That agrees with @milesah3ad's 5080 numbers, and the two abort reports are a 4090 and a 3080 Ti. The difference seems to be the GPU generation, not DXC. My DXC 1.8 is the GitHub release build (1.8.2502.8), not the SDK build (1.8.2502.11) in both abort reports, so that one gap is still open.

Not tested: the full pack in the heap form, a title run with XCL_HEAP_WINDOWS=1, Ada/Ampere/Turing, DXC 1.8.2502.11.

AI use: Claude Code with Claude Opus 5.5 ran the builds and runs above and wrote this report.

@Natakout

Natakout commented Nov 24, 2026 •

Copy link
Copy Markdown

Test report: driver compile time with this PR, RTX 3060 (NVIDIA, wave32)

Commit tested: this PR's head 95f34c1 with XCL_HEAP_WINDOWS=1, against main 47efa2e.

Tested

  • Hardware: RTX 3060 12 GB, NVIDIA driver 621.14, Windows 11 25H2, DXC 1.9.2609.5, rustc 1.94.1, release build.
  • What was measured: cold CreateComputePipelineState on the 5 largest compute programs of the retail shader pack that the driver accepts (19.8k to 24.5k console instructions: 3 guarded pc ==, 2 structured). Same root signature and static samplers as the runtime, at the runtime's default DXC level. Only sizes and timings below; no shader content.
Program Console instr. Form Driver, main Driver, this PR Change
A 24 530 guarded 125.5 s 22.8 s -82 %
B 21 896 guarded 74.7 s 16.2 s -78 %
C 21 784 guarded 78.6 s 15.8 s -80 %
D 19 815 structured 50.5 s 11.3 s -78 %
E 19 760 structured 54.6 s 10.9 s -80 %
  • Average: 4.9x less driver time. The DXIL is 15-20 % smaller.
  • The driver accepted all 5 programs with this PR. I did not reproduce the NVIDIA failures reported earlier in this thread on this card.
  • Programs above ~25k instructions (DXIL > 20 MB) are refused by the driver, with or without this PR.

Not tested

  • AMD GPUs.
  • The big compute programs above inside a title run: the smoke runs below stay in the menus (no input), where only 12 programs get compiled, so they check for regressions but do not reach that code.
  • Other NVIDIA drivers or cards.
  • Each point is a single cold compile, with no repeated runs.

Regression run (same title, 180 s each, cold DXIL and NVIDIA driver caches before each run)

main:

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

this PR (XCL_HEAP_WINDOWS=1):

xcl-smoke v1
commit: 95f34c1d1a24f644d0c4895810a7c36910b123e8
gpu: NVIDIA GeForce RTX 3060
seconds: 180
exit: 0x0
frames shown: 5147 (PresentX 5147)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14697 MB

No regression: same frames (+0.1 %), no device removal or crash, same peak commit, same pipeline counts (6 translated, 0 failed, 40 mesh refused as on main).

Update: a likely regression on a title run (RTX 3060, cold caches, 300 s, XCL_PRESS_AT to get past the menus into the world load)

AI use
Claude Code (claude-opus-4-6) wrote the local benchmark harness, ran it on the hardware above, and drafted this report.

@Filip722

Filip722 commented Nov 24, 2026 •

Copy link
Copy Markdown

Tested

  • RTX 5060 Laptop GPU with 8 GB VRAM, NVIDIA 615.78.08, Intel Core 7 240H, 16 GB RAM, Bazzite 44 Testing, Proton Experimental 11.0-20261112. Windows MSVC release build with our local vkd3d-proton 3.1.0 runtime based on 4522cc1 and dxil-spirv 1dc543f.
  • Recompiler: memory windows from the descriptor heap (no per-access switch) #680 head 95f34c1d1a24f644d0c4895810a7c36910b123e8 integrated with Shaders: xcl pipelines compiles a run's queued pipelines outside the title #759 on base 47efa2e, with local Series X loading changes. The integrated tree was a32268ef4c5c654a16d8857671d74ba84f2b7b34. Ten focused CPU or mocked-device tests passed under Proton. The GPU test binary cross-built.
  • Same executable and runtime for both retail runs, with copied title data, matching previously-used shader keys and fresh compilation caches. With a 5 s bind budget and two large compile slots, XCL_HEAP_WINDOWS=0 reached 2,296 sampled presents with 12 timeout warnings. XCL_HEAP_WINDOWS=1 confirmed descriptor-heap windows in the log and reached 2,370 sampled presents with 14 timeout warnings. Both reached loading artwork and reproduced the title GPU watchdog. Both had zero D3D12 device removals or kernel Xids.

For the combined #680/#759 experiment, I preserved the heap-mode bit in the journal header. #759's one-byte window field would otherwise drop bit 0x100, so replay would select switch-form DXIL for a heap-form record. The focused journal tests include the heap-mode round trip and switch-mode key compatibility.

Follow-up on XCL main 930e8b4

I used xcl shaders folder --precompile --only cs --windows 4 --pipelines on the same seven compute shaders selected from prior bind timeouts. Both runs used the same GPU, installed runtime, two DXC workers and one pipeline worker, with vkd3d-proton's application cache enabled for this offline measurement. The switch-form build compiled all seven in 136.5 seconds. The build with #680 and XCL_HEAP_WINDOWS=1 compiled all seven in 77.3 seconds, about 43% less elapsed time. The latter build also includes #1295, which affects frame-dump target selection. The timing covers translation, DXC and pipeline creation together.

A separate heap-window retail run on the same machine captured loading artwork in both the presented frame and the busiest live render target. Host memory pressure limited that run to the loading milestone.

Validation after merge at 9e3831e

Both new focused regressions ran on the RTX 5060 Laptop GPU under Proton Experimental 11.0-20261112. gpu_raw_window_view_reaches_its_top passed in 0.97 s, and heap_window_out_of_memory_falls_back_to_the_switch_form passed in 0.86 s. The second test observed the switch retry after the injected error and verified the resulting GPU output.

With the same release on the merged main, local Series X loading changes and matching cache/data seeds, the heap-window run confirmed the shared descriptor heap, reached loading artwork, and then the title GPU watchdog (2,480 presents). The switch-form run reached a 240 s test stop and presented black by the last manual capture (2,754 presents). One bind timeout warning and zero storage failures, device removals and kernel GPU faults occurred in each run. Neither run verified world entry.

Not tested

Native Windows, AMD, or rendered gameplay. This paired retail run measures the loading milestone and timeout warnings. It does not isolate driver compile times.

AI use

OpenAI Codex with GPT-6.2-Sol high integrated the local build, ran the tests, and prepared this report.

wondercrash added a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
…switch

With the title's 4 memory windows every load of a translated program goes
through an accessor that switches on the window (`xcl_w`). The NVIDIA driver
compiles that very slowly in big programs: the retail CS_RaytracingResolve
family (13 000 - 21 000 instructions, ~1 150 window switches each, ~1 MB of
DXIL) took 30 - 90 s per CreateComputePipelineState, with a bind of the
title waiting for it. DXC's level does not matter (-O0 / -O1 / -O3:
39 / 32 / 35.5 s for one of them).

Compute HLSL from 1 MiB on now reads every window - the selected one at the
address, the others at offset 0 - and selects by `xcl_w`, without a branch.
The values are the same, including 0 for an out-of-range window. Stores and
atomics keep the switch (one window only).

RTX 5090, one CreateComputePipelineState, cold driver cache:
- ped_slod_constant_tint:CS_RaytracingResolve (bcca7412e6c66279):
  875 916 B DXIL, 32.4 s -> 889 036 B, 12.3 s
- standard_secmo:CS_RaytracingResolve (31b81a7b0427b16c):
  1 076 296 B, 50.7 s -> 1 091 092 B, 14.0 s
- ef008c0f04b6261a: 1 108 268 B, 42.5 s -> 1 124 468 B, 11.1 s
- ab570963c407e5c0: 1 071 288 B, 39.5 s -> 1 087 576 B, 11.0 s
In the retail title, where a bind waits for each of them (and other
compiles run at the same time): 31b81a7b 78.3 s and ef008c0f 85.8 s with
the switch, 21.0 s and 20.9 s without it (ab570963 16.9 s).

Smaller programs, VS and PS keep byte-identical HLSL and so their DXIL and
driver cache entries: 901 of 2 689 CS (and 164 MS) in the title's
shaders.rpf change.

With heap windows (xcl-dev#680, XCL_HEAP_WINDOWS=1) there is no switch to remove:
the heap form is used as before and its HLSL does not change. The flat
loads apply to the switch form only, which is the default and also what
xcl-dev#680 builds when the driver refuses a pipeline with heap windows.

Assisted-by: omp (Claude Opus 5.5)
wondercrash added a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
…switch

With the title's 4 memory windows every load of a translated program goes
through an accessor that switches on the window (`xcl_w`). The NVIDIA driver
compiles that very slowly in big programs: the retail CS_RaytracingResolve
family (13 000 - 21 000 instructions, ~1 150 window switches each, ~1 MB of
DXIL) took 30 - 90 s per CreateComputePipelineState, with a bind of the
title waiting for it. DXC's level does not matter (-O0 / -O1 / -O3:
39 / 32 / 35.5 s for one of them).

Compute HLSL from 1 MiB on now reads every window - the selected one at the
address, the others at offset 0 - and selects by `xcl_w`, without a branch.
The values are the same, including 0 for an out-of-range window. Stores and
atomics keep the switch (one window only).

RTX 5090, one CreateComputePipelineState, cold driver cache:
- ped_slod_constant_tint:CS_RaytracingResolve (bcca7412e6c66279):
  875 916 B DXIL, 32.4 s -> 889 036 B, 12.3 s
- standard_secmo:CS_RaytracingResolve (31b81a7b0427b16c):
  1 076 296 B, 50.7 s -> 1 091 092 B, 14.0 s
- ef008c0f04b6261a: 1 108 268 B, 42.5 s -> 1 124 468 B, 11.1 s
- ab570963c407e5c0: 1 071 288 B, 39.5 s -> 1 087 576 B, 11.0 s
In the retail title, where a bind waits for each of them (and other
compiles run at the same time): 31b81a7b 78.3 s and ef008c0f 85.8 s with
the switch, 21.0 s and 20.9 s without it (ab570963 16.9 s).

Smaller programs, VS and PS keep byte-identical HLSL and so their DXIL and
driver cache entries: 901 of 2 689 CS (and 164 MS) in the title's
shaders.rpf change.

With heap windows (xcl-dev#680, XCL_HEAP_WINDOWS=1) there is no switch to remove:
the heap form is used as before and its HLSL does not change. The flat
loads apply to the switch form only, which is the default and also what xcl-dev#680
builds when the driver refuses a pipeline with heap windows.

Assisted-by: omp (Claude Opus 5.5)
@rGillyazanov

Copy link
Copy Markdown

PR #680 follow-up. Tested merge commit 9e3831e on an RTX 3060 Ti (8 GB, driver 621.40), Windows 11 build 26300, Rust 1.100.0 MSVC, and DXC 1.8.2505.32. PR #680

$env:XCL_ADAPTER = 'RTX 3060 Ti'
$env:XCL_HEAP_WINDOWS = '1'
$env:XCL_REQUIRE_GPU = 'wave64'
cargo test --locked -p xcl --test gpu_compute_e2e heap_window_out_of_memory_falls_back_to_the_switch_form -- --exact --nocapture --test-threads=1

1 passed, 0 failed, 0 skipped. XCL enabled heap windows and retried once in switch form after the test injected E_OUTOFMEMORY. GPU dispatch and readback passed. The run logged no device removal or Windows Display 4101 events. Coverage was limited to this synthetic test.

AI use — OpenAI Codex ran the test and drafted this report. Exact model version unavailable.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…direct DXIL)

Brings in upstream xcl-dev#680 (descriptor-heap memory windows without per-access
switches, with switch fallback) and xcl-dev#1426 (direct RDNA2 -> DXIL backend
behind XCL_DIRECT_DXIL=1 / XCL_DIRECT_DXIL=all, bypassing HLSL and DXC).
Retains xcl-dev#1398 no-GVN retry, xcl-dev#1410 wave64 logging, and xcl-dev#1428 folded X
dispatch group limit alongside xcl-dev#680 and xcl-dev#1426.
@LocranKing

Copy link
Copy Markdown

Clean-main 8 GB NVIDIA Ampere data point on 9e3831e covering the three open points from the merge comment.

Setup

  • GPU: NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, Ampere, wave32), driver 32.0.16.2101 (621.01)
  • CPU / RAM: AMD Ryzen 5 5500 (6C/12T), 31.8 GB RAM
  • OS: Windows 11 Home Single Language, build 26200
  • Build: clean main 9e3831e1f570d3646e53ab753b19ec07eb8f1485, --release, rustc 1.100.0, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0)

1. Workspace tests (cargo test --workspace --release --no-fail-fast -- --test-threads=4)

  • XCL_HEAP_WINDOWS unset: 776 passed, 0 failed, 41 ignored (SKIPPED: 2 no wave64, 2 no D3D12 debug layer, heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows)
  • XCL_HEAP_WINDOWS=1: 776 passed, 0 failed, 41 ignored (heap_window_out_of_memory_falls_back_to_the_switch_form ran and passed; only the 2 no wave64 and 2 no D3D12 debug layer skips remained)

2. 60 s retail smoke A/B (scripts/smoke.ps1, XCL_NETWORK=0, no input)

  • Default (XCL_HEAP_WINDOWS unset): exit 0x0, 1566 frames (60 60 60), 0 device removals, 0 crashes, peak commit 14715 MB, 6147 MB local / 4876 MB non-local VRAM.
  • XCL_HEAP_WINDOWS=1: exit 0x0, 1570 frames (60 60 60), 0 device removals, 0 crashes, peak commit 14718 MB, 6144 MB local / 4876 MB non-local VRAM (11 DXIL cache compiles, 0 failures; 1 fresh compute PSO 81,744 B DXIL, 562 ms).

3. World-loading runs (XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_PSO_PRELOAD=0 XCL_RUN_SECONDS=300, XCL_PRESS_A_AT every 4 s from 20 s to 80 s + 90, 100)

run heap DXIL cache last non-zero presents stop peak commit peak local / non-local VRAM fresh compute PSOs (sum / max / >= 5 s) driver blobs
default (XCL_PSO_WAIT_MS unset) warm 132.1 s 0x887a0006 device removed at 133.8 s 23198 MB 11007 / 4894 MB 5 (3.9 s / 2.46 s / 0) 1
XCL_HEAP_WINDOWS=1 (XCL_PSO_WAIT_MS unset) cold 168.1 s +0x23cf683 (0xc0000005) at 195.8 s 28579 MB 14008 / 4896 MB 39 (29.1 s / 7.48 s / 2) 1
default + XCL_PSO_WAIT_MS=50 warm 144.1 s +0x23cf683 (0xc0000005) at 204.8 s 30799 MB 14446 / 4929 MB 196 (379.6 s / 38.87 s / 23) 28
XCL_HEAP_WINDOWS=1 + XCL_PSO_WAIT_MS=50 warm 88.1 s 0x887a0006 device removed at 89.8 s 24395 MB 12429 / 4894 MB 5 (5 ms / 3 ms / 0) 5

Findings on the three open points

  1. Window VA / acceleration structures above 2^40: window 0 buffer at VA 0x3e0000000 was identical with XCL_HEAP_WINDOWS off and on in every run (UMA: 3 sparse VRAM window(s) (12 GiB VA) + 4095 MB coherent window at 0x400000000). No xboxbvhbuilder error or RAYTRACING_ACCELERATION_STRUCTURE log line appeared, though these runs stopped before acceleration-structure builds were logged so that path was not directly exercised.
  2. NVIDIA driver compiler fast-fail: Not seen on this Ampere card with driver 621.01 (32.0.16.2101) across all tests, smokes, and 39 fresh heap-window compute PSO builds (up to 409,812 B DXIL / 7,477 ms, 0 refused, 0 Invalid record / Never resolved value, 0 switch-form fallbacks). For scale on this card, the longest switch-form compute builds reached 38.9 s (829 KB DXIL) and 26.5 s (610 KB DXIL) with 7 builds >= 10 s, vs max 7.5 s (410 KB DXIL) and 0 >= 10 s with heap windows.
  3. 8 GB card with the new view cap: Both XCL_HEAP_WINDOWS=1 runs enabled memory windows from the shared descriptor heap (no per-access switch) cleanly at ~1.5–1.6 s with 0 CreateHeap refusals and 0 switch-form fallbacks, and the first world-load run streamed up to 14,008 MB local video memory (195.8 s) with 0 device removals. Note that 0x887a0006 (DXGI_ERROR_DEVICE_HUNG) did occur once in each mode during heavy 8 GB VRAM overcommit (11,007 MB local in default at 133.8 s; 12,429 MB local in XCL_HEAP_WINDOWS=1 + XCL_PSO_WAIT_MS=50 at 89.8 s), while the other run in each mode reached +0x23cf683 with 0 device removals.

Not tested: driver 621.24, offline xcl shaders --precompile --pipelines, multiple repeats per configuration, acceleration-structure build stage.

AI use: Antigravity (Gemini 4 Neon) built, ran, and parsed these tests and logs on this machine and drafted this comment; reviewed before posting. No game files attached.

anoyarou added a commit to anoyarou/xcl that referenced this pull request Nov 24, 2026
…g, DirectStorage, and stream tracking

Cherry-picks upstream stabilization improvements across VRAM allocation,
pipeline caching, DirectStorage lifetime, descriptor heap indexing, Media
Foundation device bridging, and stream PSO tracking:

- D3D12.X: reclaim cooling and idle tiles on pool heap OOM (xcl-dev#1663,
  addressing xcl-dev#1585 and xcl-dev#1668). When CreateHeap returns 0x8007000E (E_OUTOFMEMORY),
  Pages::take_tile waits on Pages::fence up to 1000 ms to drain cooling tiles or
  force-evict idle pages rather than failing immediately. (by Nikita Romanovich)

- DirectStorage: close a queue when its last reference is released (xcl-dev#1675).
  Moves queue_close logic into QueueInner::close and invokes it when the final
  queue reference is released, preventing background workers from writing to freed
  caller buffers and marking pending entries complete with E_QUEUE_CLOSED. (by eizispark)

- D3D12.X: a pipeline the driver gave up on is not built again (xcl-dev#1665).
  Persists driver E_OUTOFMEMORY refusal state into used-pipelines.txt (!<key>)
  so giant compute pipelines that the host driver refuses to compile are skipped
  on subsequent runs. (by zorde23)

- Recompiler: access outside heap windows takes a null view without branching
  (xcl-dev#1669, xcl-dev#680). Replaces conditional branches in XCL_HEAP_WINDOWS=1
  (if (xcl_w >= windows)) with a branchless select pointing out-of-bounds accesses
  to a dedicated null UAV view (MEM_HEAP_NULL). (by milesah3ad)

- HLE: bridge ID3D12Device before direct ResetDevice and cache D3D11 companion
  (xcl-dev#1677). Fixes MFResetDXGIDeviceManagerX in mfplat.rs to bridge
  ID3D12Device COM pointers and caches multithreaded companion ID3D11Device
  instances per adapter LUID. (by eizispark)

- D3D12.X: route stream graphics PSOs through create_graphics_pso_tracked
  (xcl-dev#1661, finding XCL-BT-023 from xcl-dev#1489). Ensures stream-created
  graphics PSOs receive D3D12_PIPELINE_STATE_FLAG_DYNAMIC_DEPTH_BIAS and are
  tracked in device_x::note_base for CreateDerivedPipelineStateX and RSSetDepthBiasX.
  (by fixgep)

Assisted-by: Antigravity
wondercrash added a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
…switch

With the title's 4 memory windows every load of a translated program goes
through an accessor that switches on the window (`xcl_w`). The NVIDIA driver
compiles that very slowly in big programs: the retail CS_RaytracingResolve
family (13 000 - 21 000 instructions, ~1 150 window switches each, ~1 MB of
DXIL) took 30 - 90 s per CreateComputePipelineState, with a bind of the
title waiting for it. DXC's level does not matter (-O0 / -O1 / -O3:
39 / 32 / 35.5 s for one of them).

Compute HLSL from 1 MiB on now reads every window - the selected one at the
address, the others at offset 0 - and selects by `xcl_w`, without a branch.
The values are the same, including 0 for an out-of-range window. Stores and
atomics keep the switch (one window only).

RTX 5090, one CreateComputePipelineState, cold driver cache:
- ped_slod_constant_tint:CS_RaytracingResolve (bcca7412e6c66279):
  875 916 B DXIL, 32.4 s -> 889 036 B, 12.3 s
- standard_secmo:CS_RaytracingResolve (31b81a7b0427b16c):
  1 076 296 B, 50.7 s -> 1 091 092 B, 14.0 s
- ef008c0f04b6261a: 1 108 268 B, 42.5 s -> 1 124 468 B, 11.1 s
- ab570963c407e5c0: 1 071 288 B, 39.5 s -> 1 087 576 B, 11.0 s
In the retail title, where a bind waits for each of them (and other
compiles run at the same time): 31b81a7b 78.3 s and ef008c0f 85.8 s with
the switch, 21.0 s and 20.9 s without it (ab570963 16.9 s).

Smaller programs, VS and PS keep byte-identical HLSL and so their DXIL and
driver cache entries: 901 of 2 689 CS (and 164 MS) in the title's
shaders.rpf change.

With heap windows (xcl-dev#680, XCL_HEAP_WINDOWS=1) there is no switch to remove:
the heap form is used as before and its HLSL does not change. The flat
loads apply to the switch form only, which is the default and also what xcl-dev#680
builds when the driver refuses a pipeline with heap windows.

Assisted-by: omp (Claude Opus 5.5)
@Retried

Retried commented Nov 24, 2026

Copy link
Copy Markdown

Point 2 (the NVIDIA compiler fast-fail) on Turing with 621.35: not seen on 56 retail compute programs, including the two families from the 3080 Ti report. For Pipodi's list in #1269.

Tested: RTX 2070 SUPER 8 GB (Turing, 32-lane waves, so the split wave64 form), driver 621.35 (32.0.16.2135), Ryzen 7 5800X3D, 32 GB, Windows 11 Pro 26300, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), release build of main 6c89285 plus the retail_pipeline_cost test from #1529 (bbfc99e).

How:

  • retail_pipeline_cost translates a record the way the title does and times DXC and CreateComputePipelineState.
  • Each program was built in its own process, once in the heap form (XCL_RECOMP_WINDOWS=260) and once in the switch form (=4), with a 120 s / 8 GB cap, XCL_TRANSLATED_CACHE=0 and an empty XCL_DXIL_CACHE.
  • The driver's disk cache keys on the DXIL, so a local change to the test renamed the entry point for every run: every build was DXIL the driver had not seen. The same name built again in 0.00 s; a new name took the full time.
  • An abort was counted on exit 0xC0000409 or 127, Never resolved value or Invalid record in the output, or no test result line.

Programs (seed 1269):

  • all 16 indirect_diffuse_lighting:CS_FinalGather_*, including CS_FinalGather_1_0_0_1 from the 3080 Ti report;
  • 10 of the 246 CS_RaytracingResolve_ae7b7f3c variants;
  • 30 random other compute programs.

Result:

  • Heap form: 56 of 56 built. Exit 0 for all of them, with no Never resolved value, no Invalid record and nothing refused. The largest heap DXIL was 1098 KB, more than the 733 KB ae7b7f3c from the 3080 Ti report.
  • Switch form: 54 of 56 built. Two runs hit the 120 s cap before printing a result: ped_standard_muv_blendshape_cutout:CS_RaytracingResolve_ae7b7f3c and prop_2lyr_procedural_batch:CS_RaytracingResolve_18a17e12. Their heap forms took 15.7 s in DXC and 17.4 s in the driver, and 15.8 s and 13.0 s.
  • Peak private memory per process was at most 2.37 GB.

Driver time, on the programs that built in both forms:

programs n heap, sum switch, sum switch / heap, median (range)
CS_FinalGather_* 16 11.4 s 15.6 s 1.39× (1.27–1.58)
CS_RaytracingResolve_ae7b7f3c 9 102.6 s (max 18.4 s) 548.9 s (max 97.0 s) 5.09× (4.65–7.40)
random compute 29 92.3 s 420.8 s 1.39× (1.00–6.08)

In the heap form, DXIL was 14–21 % smaller per group and DXC took 11–22 % less time. CS_FinalGather_1_0_0_1 had 120 KB of heap DXIL (111 KB with DXC 1.8 in the 3080 Ti report) and took 0.82 s in the driver, against 1.14 s in the switch form.

Not tested:

AI use: Claude Code, Claude Opus 5.5 chose the programs, ran the builds, parsed the results and wrote this comment. The numbers come from those runs on the hardware above.

wondercrash added a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
…or heap)

Conflicts, resolved keeping both sides:
- emit.rs: windowed / mem_accessors take both `heap` (xcl-dev#680) and `flat`
  (our flat window loads for compute HLSL >= 1 MiB). The heap form returns
  first (it has no switch); `flat` applies only to the switch form, so the
  default (switch) HLSL is unchanged and xcl-dev#680's switch-form fallback still
  gets flat loads for big compute programs.
- pso.rs: mem_windows keeps our `set_mem_windows` override (xcl pipelines)
  and adds xcl-dev#680's HEAP_WINDOWS flag / in_switch_form / heap_windows.
- real.rs: our prep_graphics split stays; translated_graphics_pso becomes
  xcl-dev#680's with_switch_fallback wrapper around translated_graphics_pso_once.
- shaders.rs: --precompile passes both our --used and xcl-dev#680's heap key.
- tests.rs: the out-of-UMA test runs the heap form, or the switch and flat
  forms; big_programs_read_their_windows_without_a_switch also checks that a
  big program with heap windows has one heap access per load.
wondercrash added a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
…m the descriptor heap)

try-up680 (21e701c) merged upstream 9e3831e onto integ b555b63; integ has
since gained 3950766..67c2526.

Conflict:
- crates/xcl/src/shaders.rs (`xcl shaders --precompile`): integ's
  `--used [file]` (`used_file(.., pso_async::used_path)`, passed as
  `used.as_deref()`) kept, with xcl-dev#680's runtime window key (`windows |
  HEAP_WINDOWS` when `pso::heap_windows()`).

Auto-merged with integ's later changes (gpu_profile hooks, warm's
max_dxil / translated, shaders_key_of) in pso.rs, bind.rs, console_list.rs,
list_x.rs and real.rs; checked hunk by hunk against both parents.
wondercrash added a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
Merged onto c8b2b74 (integ 67c2526 + try-up680, which already resolves
upstream xcl-dev#680 against integ: emit.rs, pso.rs mem_windows, real.rs and
tests.rs as in 21e701c, shaders.rs --precompile in c8b2b74).

Conflicts:
- crates/xcl/src/gpu/recomp/pso.rs: integ's `compute_shape`
  (XCL_GPU_PROFILE) and xcl-dev#1426's `direct_fallback` / `direct_compute` /
  `dump_direct` / `direct_graphics` are separate new functions at the same
  spot; both kept.
- crates/xcl/src/main.rs (usage): xcl-dev#1426's `xcl shaders --direct ...`
  option lines kept under `xcl shaders`, followed by integ's
  `xcl pipelines` entry.
- crates/xcl/src/gpu/recomp/tests.rs
  `gpu_sparse_vram_descriptors_buffers_and_xmem`: as in 028f3cb
  (pr/flat-window-loads-v3): the switch-form PSO built through
  `direct_or(..)` (direct DXIL with XCL_DIRECT_DXIL=1) and the flat form
  (`flat_window_loads`) through DXC.
- crates/xcl/src/gpu/recomp/tests.rs `gpu_split_wave64_waves_diverge`:
  integ's group-barrier cases kept (HLSL edit, compiled with DXC); the
  counter cases go through xcl-dev#1426's `direct_or(..)`.

Default behaviour (XCL_DIRECT_DXIL / XCL_HEAP_WINDOWS unset) is integ's.
@Retried

Retried commented Nov 24, 2026

Copy link
Copy Markdown

Point 2: both fast-fail reports ran the heap form from before the merge, and its window index differs from the merged form and from #1695

Both reports built every memory accessor with ResourceDescriptorHeap[NonUniformResourceIndex(MEM_HEAP_BASE + (xcl_w < N ? xcl_w : 0u))]. tycosnh's ran on main dd2ae9a with #187 (head c74b03a), and LeonardoS11's on this PR's head 2c1a521, both with DXC 1.8.2502.11. The merged form (deb4b92, in 9e3831e) indexes with MEM_HEAP_BASE + xcl_w behind [branch] if (xcl_w >= N).

In DXIL, from a small probe with two accessors, compiled with DXC 1.9.2602.17 (cs_6_6, -O3):

  • the old form gives an icmp plus a select i32 that feeds the index of every createHandleFromHeap;
  • the merged form gives a branch with no select; the index can still reach the handle through an i32 phi where the blocks join. brothernog showed above that this form can also produce a handle phi, which NVIDIA refuses at once with 0x8007000E, and with_switch_fallback catches that.

Since the merge, nobody has reported the fast-fail:

So the fast-fail may follow the select index rather than the card or the driver. This is an inference: nobody has built the old and the merged form on a machine that aborted, and the DXC version differs between some of these runs as well.

What this means for #1695. It builds the index in one of two ways:

  • with N == MAX_WINDOWS: min(xcl_w, N), which DXIL turns into UMin with no select. The usual layout (3 sparse VRAM windows plus the coherent one) gives N = 4, so the retail title takes this path;
  • with N < MAX_WINDOWS: select(xcl_w < N, xcl_w, null), the same select i32 into the index as the forms that aborted, with the null view in place of window 0.

If the inference holds, putting the null view in the unused window slots too would let both cases use min(xcl_w, MAX_WINDOWS).

A rerun that would settle it, if @LeonardoS11 still has the RTX 3080 Ti with 621.24:

  • the same xcl shaders <pack> --precompile --only cs --pipelines on current main with DXC 1.8.2502.11, keeping the full exit code;
  • the same command on 2c1a521 as the control.

If main builds through and 2c1a521 still aborts, the merged form removed the fast-fail. If both abort, the cause is elsewhere.

Not tested: the old form on this machine (the 2070 SUPER did not abort with the merged form, so it could not tell the two forms apart), DXC 1.8, and #1695 on the retail programs.

AI use: Claude Code, Claude Opus 5.5 compared the three forms in the source, compiled the probe and wrote this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.