Skip to content

Recompiler: NVIDIA compute programs take flat heap windows by default - #2428

Open
Kalmarv wants to merge 2 commits into
xcl-dev:mainfrom
Kalmarv:heap-windows-default
Open

Kalmarv wants to merge 2 commits into
xcl-dev:mainfrom
Kalmarv:heap-windows-default

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2088. Stacked on #2427; only the top commit belongs here.

On NVIDIA, this PR turns #2427's flat heap windows on by default, for compute programs only. Graphics stages, mesh, GS, other vendors and the HLSL path keep the switch over root UAVs, as they do today.

What it changes for compute programs on NVIDIA, compared with main's form (#2368's select over root UAVs):

How it decides:

  • XCL_HEAP_WINDOWS set: 1 gives heap windows to every stage, as before; 0 turns them off.
  • Unset: heap windows are on when the title's adapter is NVIDIA (PCI vendor 0x10DE), and only for the compute programs the direct translator makes (compute_mem_windows).
  • Flat form: on by default; XCL_HEAP_FLAT=0 brings back the guarded form.
  • Refused pipelines: a pipeline the driver refuses with heap windows (E_OUTOFMEMORY, NVIDIA (RTX 5070): graphics pipelines never finish – nvgpucomp64 stalls on large translated shaders (+ 2 fixes: chad.dll XDsp, XMemMapPhysicalPagesScatter) #156) is still built in the switch form (927adcc's with_switch_fallback). Only builds that had heap windows are rebuilt that way. A graphics or mesh build without them is not built twice (@bmjask's review).
  • Views not made: if the heap views cannot be made, everything takes the switch, as before.
  • What else turns on: on NVIDIA, the windows' heap views are now made at start by default, and command lists bind the shared heap when they set none, as XCL_HEAP_WINDOWS=1 did. This applies to every list, graphics included, although graphics shaders still take the switch.

Why only compute, and not the HLSL path:

XCL_HEAP_WINDOWS was opt-in because two NVIDIA setups failed with it in #187's review:

  • The failures: the driver's compiler ended the process, and the device was removed when the views were made on an 8 GB card.
  • Fixed since: pipelines the driver refuses with E_OUTOFMEMORY now fall back to the switch form (927adcc). A view that some D3D12 runtimes refused, removing the device, is now capped (deb4b92).
  • Not confirmed: that those fixes cover the two failures. Neither setup was re-run.

What is in it

  • gpu/recomp/pso.rs:
    • heap_windows with the vendor default, set_adapter_vendor, heap_windows_everywhere, compute_mem_windows / compute_windows and hlsl_windows.
    • console_to_dxil_for takes the compute windows for a compute program.
    • XCL_HEAP_FLAT is on by default.
    • Tests: the default rule per vendor and env, and the windows each form takes.
  • hle/d3d12x/real.rs:
    • The device's adapter vendor is noted before the UMA opens.
    • with_switch_fallback takes whether the build has heap windows: the compute windows for a compute build, the graphics windows for graphics and mesh. driver_pso retries E_OUTOFMEMORY in the switch form only for such a build.
    • Tests in switch_fallback_tests: an E_OUTOFMEMORY without heap windows is not retried, one with heap windows is built again once, and a driver call outside a translated build is not a heap-window build.
  • shaders.rs, gpu/adapter.rs: the --precompile / --export-hlsl / --measure-pso windows are the runtime's, per stage, for the bench's adapter. Compute programs take pso::compute_windows, as compute_mem_windows does. VS, PS and mesh programs take pso::graphics_windows, as mem_windows does. So by default on NVIDIA only the compute programs are precompiled with heap windows. Before, every stage got the compute count, so precompiled VS, PS and mesh entries missed at run time (found by @pvfreis, comment 7181439405).
  • gpu/uma.rs: XCL_UMA_WINDOWS=8|16 still needs XCL_HEAP_WINDOWS=1, since graphics need the heap for more than 4 windows.
  • tests/gpu_compute_e2e.rs: the switch-form fallback test checks the compute windows.

Tested

  • Ryzen 9 9950X, RTX 5070 Ti (NVIDIA 610.74), Windows 11 build 26200, rustc 1.99.0, DXC 1.9.2609, debug.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on this head, c6e5af8 (on Recompiler: direct DXIL reads heap memory windows without a branch #2427's c8c2b7a and main 6d12f58): 1431 passed, 0 failed, 46 ignored.
    • 24 SKIPPED notices: 21 for no wave64, and 3 for wave32 per-lane forms refused by the gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 list (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32).
    • heap_window_out_of_memory_falls_back_to_the_switch_form runs, because heap windows are on by default on this NVIDIA card, and passes: a refused heap-window pipeline is rebuilt in the switch form and runs correctly.
    • The three switch_fallback_tests pass, and so do Recompiler: direct DXIL reads heap memory windows without a branch #2427's gpu_heap_flat_reads_match_the_switch_form, only_compute_programs_read_heap_windows_flat and precompile_windows_are_the_runtimes. The last checks the precompile's windows per stage against the runtime's: with XCL_HEAP_WINDOWS=1, and with it unset on an NVIDIA and an AMD vendor, each in a new process. With the old single count it fails on NVIDIA's default: VS, PS and mesh got 772 where the runtime uses 4.
  • Offline count of precompiled VS entries a title run finds, the first 4,000 records of the title's shader pack, release:
    • How: a fresh DXIL cache; xcl shaders --precompile --only vs with default settings; then the same with XCL_HEAP_WINDOWS=0, whose VS keys are the runtime's default ones. The second run's already-cached count is what the runtime finds.
    • 970823e (before): the second run compiled 542 again and found only the 12 that repeat within the pack. None of the 542 precompiled VS entries are found.
    • c6e5af8: the second run compiled none and found all 554.
    • PS: not counted. The first 6,000 records hold none, and a full-pack count takes close to an hour. In precompile, PS and mesh programs take the same count as VS.

Tested by others

  • @upipibi (comment 7172640860), thank you: RTX 3070 8 GB, NVIDIA 616.56, Windows 11, debug.
    • On 970823e, one push before this head (which changes only the precompile's VS, PS and mesh windows), as is: cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2: 1422 passed, 0 failed, 46 ignored. The 16 heap-window tests ran, none skipped, with no device removal. 25 SKIPPED lines (no wave64 and the like).
    • Earlier, on ab2855f: 1417 passed, 0 failed, 46 ignored; on dbf54bf: 1350 passed, 0 failed, 46 ignored.
    • Lib and workspace tests only; no title run on an 8 GB card.
  • @pickles976 (comment 7183101099): RTX 4060 Laptop 8 GB, NVIDIA 590.48.1, Wine 11.0, on af82530. Since then only the precompile's windows changed (shaders.rs, and pso::graphics_windows with the same rule as before); the fallback path is the same.
  • @pvfreis (comment 7177531683): RTX 3060, NVIDIA 617.14. ab2855f with Recompiler: an access may take its base address's window (XCL_WINDOW_NO_CARRY) #2496 on main e1d84b7.
    • Suite: 1429 passed, 1 failed, 46 ignored. The failure, the e2e presents test, also fails on that main (1422 passed, 1 failed, 46 ignored).
    • Native code over 60 records: root UAVs 51.17 MB, guarded heap 42.19 MB, flat heap 41.11 MB.
    • Flat over root UAVs is 0.803 (0.465–0.922 per record). Flat over guarded is 0.974 (0.901–1.039), and 12 of the 60 are larger.
    • Repeat builds had the same sizes but different contents for 18 and 8 of the 60.
    • No build times.
  • @Royalflamejlh (comment 7179985117): RTX 4070 12 GB, NVIDIA 615.71.09, Fedora 44, Wine 11.21 Staging, vkd3d-proton v3.1-90 with XCL's relaxed-vtable patch, release.
    • Builds: ab2855f with XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684 on 6d12f58, XCL_DIRECT_DXIL=1.
    • Runs: cold, 200 s, two runs with this default and two with XCL_HEAP_WINDOWS=0.
    • What the times are: vkd3d-proton's whole pipeline creation under Wine (dxil-spirv, then the driver), not native Create*PipelineState time.
    • Results:
      • DXIL was 11–21 % smaller (median 18 %).
      • The 18 programs whose DXIL changed took 73.0 s per run against 96.9 s, nearly all of it in the two largest.
      • Their median ratio was 0.98. Without the two largest, the heap-window runs were slower: 56.8 s against 51.7 s.
      • Six programs with the same DXIL either way were also faster in the heap-window runs (median ratio 0.43), so part of the difference comes from the runs, not the form. At most 2 large builds ran at once in the heap-window runs, and 3 in the others.
    • A fifth =0 run lost its device at 77.9 s in vkd3d-proton and is left out.
    • Not this head (c6e5af8) itself.
  • AMD: this PR keeps root UAVs there by default. @bielfreedom's RX 9070 XT timing of the flat form against the guarded one, with heap windows on, is in Recompiler: direct DXIL reads heap memory windows without a branch #2427 (comment 7180279957): 11 % less CreateComputePipelineState time over 26 large programs.

Regression run

  • Setup: scripts/smoke.ps1 through our run script, 120 s, release builds, XCL_DIRECT_DXIL=1, in one queue job: main b49be18, then this head. Both sides use the same data root and XCL cache, warmed by earlier runs, and start from the same learned coherent-window state.
  • Beside it: another agent's offline export job ran on the same machine through both sides; no precompile ran beside it.
  • Result: no device removal and no crash. This PR showed 140 % of main's frames (2227 against 1593) and 50 % of its peak commit (14319 against 28787 MB). Its last 6 s still presented 60 frames per 2 s, where main's presented none. One run each; I have not looked into why the two differ this much.

main b49be18:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 120
exit: 0x0
frames shown: 1593 (PresentX 1593)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 28787 MB

This PR (c6e5af8):

xcl-smoke v1
commit: c6e5af8690fc6257926d5cfca9443e01e60d14dc
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 120
exit: 0x0
frames shown: 2227 (PresentX 2227)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14319 MB

Not tested

AI use

  • Claude Code (Claude Opus 5.5) wrote the change, the tests and this description, and ran the tests.

🤖 Generated with Claude Code

@ivall ivall added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@Kalmarv
Kalmarv force-pushed the heap-windows-default branch from b31376e to dbf54bf Compare November 25, 2026 19:13
@upipibi

upipibi commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Update, head c6e5af8 (pushed 03:30Z), same 8 GB RTX 3070, driver 616.56, Windows 11, debug, head as is: cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2: 1422 passed, 0 failed, 46 ignored. The 16 heap-window tests ran (none skipped); no device removal; 25 SKIPPED lines (no wave64 etc.). The same counts as on 970823e. Lib and workspace tests only; still no title run on an 8 GB card.


NVIDIA test report for dbf54bf on an 8 GB card, which Not tested lists. RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11, debug, head as is (base 3f27770), after cargo build --workspace:

  • cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2 --skip gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier: 1350 passed, 0 failed, 46 ignored. No device removal and no compiler exit in the run, and the end-to-end title tests pass.
  • With this head the heap-window tests run rather than skip on this card: the no heap windows SKIPPED line that main shows here is gone, and heap_window_out_of_memory_falls_back_to_the_switch_form, heap_windows_by_default_on_nvidia_only, default_heap_windows_are_flat_and_for_the_direct_form_only, gpu_raw_window_view_reaches_its_top and gpu_heap_windows_reject_out_of_uma_aliasing pass.
  • Skipped a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier: this head's base has that test but not its fix (Tests: check divergent block barriers in a_bridged_mask_write #2420), so it fails there on main too. Skipped hle::xaudio2, because its tests fail or hang on this machine on main too. The PR touches neither.
  • SKIPPED lines: 25: 21 no wave64, 3 f16/f32 forms the per-lane path refuses, 1 PSO measurement that needs Developer Mode.
  • Not tested: a title, and Memory windows from the descriptor heap (no per-access switch); NVIDIA OOM fallback; physical-page fixes #187's two failing setups.

Added 21:32Z: re-run at the current head ab2855f (as is, base 6d12f58), same RTX 3070 8 GB, same command but without the bridged-test skip (the base now has #2420's fix): 1417 passed, 0 failed, 46 ignored. No device removal, and the end-to-end title tests pass. The heap-window tests run rather than skip (12 pass, including heap_windows_by_default_on_nvidia_only and heap_window_out_of_memory_falls_back_to_the_switch_form), and no no heap windows SKIPPED line appears. SKIPPED lines: 25 (21 no wave64, 3 f16/f32 per-lane refusals, 1 PSO measurement that needs Developer Mode).

AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only; no title run.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

— Devin

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: driver_pso uses compute_mem_windows() for every PSO. On NVIDIA defaults compute is heap-windowed but graphics remains switch-form; nevertheless translated_graphics_pso runs under with_switch_fallback, so any unrelated graphics E_OUTOFMEMORY is misclassified as heap-window failure and retries the identical graphics pipeline. Restrict heap-OOM fallback to the actual translated stage/form and add graphics-E_OOM/no-retry coverage. This draft also lacks regression pair, reruns of prior NVIDIA failure scenarios, and 8 GB-card validation.

@pvfreis

pvfreis commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Test report for ab2855f (includes #2427 d356a74) with #2496 78bba5c on main e1d84b7d (tree 76fc443d): outputs and driver code size.

Tested

  • RTX 3060 (617.14), Ryzen 9 5900XT, Windows 11. Sandbox: non-interactive session, Low integrity, debug, --test-threads=4, NVIDIA 32-lane waves only. One run each.
  • Suite (tree b39fd905: plus our test arms and a test-only break switch): 1429 passed, 1 failed, 46 ignored, 24 SKIPPED lines. main: 1422 / 1 / 46, 25 (heap_window_out_of_memory_falls_back_to_the_switch_form skips there). Both fail e2e presents only.
  • Outputs: flat windows with and without XCL_WINDOW_NO_CARRY, wave32 and split wave64, in Tests: verify heap-window GPU equivalence and graphics validation #2408's two tests and a new one (offsets, window edges, out of range, null, inactive lanes, halfword, typed, s_load): all expected values met. Three arms in Recompiler: direct DXIL reads heap memory windows without a branch #2427's test, one flat, agree with its root UAV run. Three one-line breaks of the flat read are caught.
  • Expected values: our arithmetic from AMD's public RDNA2 ISA (3.3, 7.2.1, 8.1.5, 8.2.8, 9.1, 9.3, 9.4, 12.9, 12.14, 12.18.3). Out of range is XCL's contract; a no-carry access leaving its window is Recompiler: an access may take its base address's window (XCL_WINDOW_NO_CARRY) #2496's rule.
  • Size only: GetCachedBlob bytes, 60 compute records (30 largest, 30 sampled, chosen beforehand), unsplit, at opt-level 3 without debug assertions; plain debug gives the same DXIL and root signatures (60/60, 0 validator errors).
  • Failed check (byte-identical repeat): sizes equal 60/60, contents differ in 18/60 (same job) and 8/60 (new job); cause not investigated.

Not tested: what the 60 programs compute, a title, build time, split chains, GS, mesh, graphics, other GPUs.

AI use: Claude Code. Claude Opus 5.5 wrote the test, ran it and wrote this; Claude Fable 5.2 rechecked it.

@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

@Kalmarv
Kalmarv force-pushed the heap-windows-default branch from ab2855f to af82530 Compare November 26, 2026 01:34
@Royalflamejlh

Copy link
Copy Markdown
Contributor

Linux (Wine + vkd3d-proton) + NVIDIA, ab2855f, the title with XCL_DIRECT_DXIL=1, cold, 2 runs with heap windows by default and 2 with XCL_HEAP_WINDOWS=0: the heap form's DXIL was 11 to 21 % smaller (median 18 %), but its creation times did not separate from the spread between runs. The 18 programs whose DXIL changed took 73.0 s per run against 96.9 s, nearly all of it 8994bb33… and dd51cdee…. Six programs with the same DXIL either way were also faster in the heap-window runs, by as much as dd51cdee….

Setup: 6d12f58a (this pull request's base) + #684 e56dbc3 + #2427 d356a74 + #2428 ab2855f, one build, the two settings in turn. RTX 4070 12 GB (615.71.09), Fedora 44, Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b with XCL's relaxed-vtable patch and dxil-spirv e084e35c plus four patches, release, Series X profile, 200 s, A at 16.0 to 16.2 s, XCL_PSO_PRELOAD=0, XCL_PSO_DISK_CACHE=0, fresh NVIDIA and vkd3d-proton caches per run. Times are the driver compile finish lines: vkd3d-proton's whole creation under Wine (dxil-spirv, then the driver), not native Create*PipelineState time.

record heap windows: DXIL, two runs XCL_HEAP_WINDOWS=0: DXIL, two runs
8994bb33444988e6 404,528 B: 3.3, 10.2 s 509,440 B: 25.8, 20.2 s
dd51cdeedc76d3a7 613,648 B: 8.7, 10.3 s 726,112 B: 18.2, 26.2 s
44d832b4bdbd5ef8 282,972 B: 7.8, 7.6 s 340,044 B: 7.9, 7.8 s
a74706fb8f96ade9 386,336 B: 8.1, 8.1 s 471,356 B: 2.6, 2.9 s
the 18 whose DXIL changed, built in all four runs 73.0 s per run 96.9 s per run
the 6 with the same DXIL either way 16.8 s per run 25.7 s per run
  • Ratios are heap windows over =0. Over the 18, the median was 0.98; without the two largest, 56.8 s against 51.7 s. The 6 unchanged had a median of 0.43.
  • Per pair, over programs whose DXIL changed, the median was 1.04 (26 programs, 13 faster) and 0.62 (23, 17 faster).
  • At most 2 big builds ran at once in the heap-window runs, 3 in the others.
  • A fifth =0 run lost its device at 77.9 s (0x887a0005, vkd3d-proton Failed to wait for Vulkan timeline semaphore, vr -4, no NVIDIA kernel message); it is left out.
  • The head is now af82530. Read: its changes limit flat reads to compute entries and retry E_OUTOFMEMORY only for heap-window builds; neither touches these programs, and no run logged an E_OUTOFMEMORY.

Not tested: af82530 itself; the default path's direct programs (not reached in 200 s without XCL_DIRECT_DXIL=1); graphics; the suite; Windows.

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

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

@Kalmarv

Kalmarv commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Royalflamejlh thank you for the runs and the careful write-up.

Under Wine and vkd3d-proton, the compile-time gain doesn't separate from the spread between runs except in the two largest programs, and the six programs with unchanged DXIL show how large that spread is. I've scoped the description's compile-time claim to what it was measured on: native Windows, an RTX 5070 Ti on 610.74, and five large compute programs, timed against the switch from before #2368. Those five are all the native compile-time evidence there is, so the description now says the gain is shown only for a few large programs, and not natively against #2368's form. Your result is under Tested by others, with your caveat that the times are vkd3d-proton's whole creation path rather than native Create*PipelineState. The 11–21 % DXIL reduction is cited there as well.

AI use: Claude Code (Claude Opus 5.5) wrote this reply.

@Kalmarv

Kalmarv commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

@bmjask thank you, the P2 was right.

Fallback scope. driver_pso took "heap windows" from compute_mem_windows() for every pipeline. With NVIDIA's default, compute is heap-windowed and graphics stays in the switch form. So a graphics E_OUTOFMEMORY was taken for a heap-window refusal, and with_switch_fallback built the same graphics pipeline again. Fixed, now in c6e5af8:

  • with_switch_fallback(heap, build) now takes whether the stage being built took heap windows: compute_mem_windows() for compute, mem_windows() for graphics and mesh (heap only with XCL_HEAP_WINDOWS=1).

  • driver_pso notes E_OUTOFMEMORY only while that is set, and only for the first attempt. A driver call outside a translated build never counts.

  • Tests, real.rs switch_fallback_tests:

    • an_out_of_memory_without_heap_windows_is_not_retried: one attempt, E_OUTOFMEMORY returned;
    • an_out_of_memory_with_heap_windows_is_built_again_once: two attempts, nothing left noted;
    • a_driver_call_outside_a_translated_build_is_not_a_heap_window_build.

    The end-to-end heap_window_out_of_memory_falls_back_to_the_switch_form still runs and passes on this head. Suite on c6e5af8 (on Recompiler: direct DXIL reads heap memory windows without a branch #2427 and main 6d12f58): 1431 passed, 0 failed, 46 ignored.

Regression pair (in the body), on c6e5af8 against main b49be18, 120 s, XCL_DIRECT_DXIL=1: no removal or crash, 140 % of main's frames (2227 against 1593) and 50 % of its peak commit.

Earlier NVIDIA failures and 8 GB.

  • 8 GB: @upipibi ran the suite on an RTX 3070 8 GB (comment 7172640860): 1417 passed, 0 failed, 46 ignored at ab2855f, with the heap-window tests running and no device removal. They have since rerun it on 970823e, after the fallback fix: 1422 passed, 0 failed, 46 ignored, with all 16 heap-window tests running. There is no title run on an 8 GB card.
  • Memory windows from the descriptor heap (no per-access switch); NVIDIA OOM fallback; physical-page fixes #187's two failing setups: I can't rerun them; I don't have those machines. Since then, pipelines the driver refuses with E_OUTOFMEMORY fall back to the switch form (927adcc, scoped above), and the view that removed the device on some runtimes is capped (deb4b92). This card shows no removals. Whether that covers both failures is not confirmed, and the body says so.

AI use: Claude Code (Claude Opus 5.5) made the fix and the tests and wrote this reply.

With heap windows (XCL_HEAP_WINDOWS=1), every read of the direct DXIL
translator was a branch on `w < windows` (and the lane guard) around the
heap lookup, and a phi per value at the join. On NVIDIA the driver's
compile time follows the block count, and the reads of a large compute
program make thousands of blocks.

XCL_HEAP_FLAT=1 (with heap windows; new flag HEAP_FLAT in the windows
count, so the caches keep the forms apart) reads in one path: the lane
loads from window `w`, or window 0 when `w` is outside the windows or
the lane is not active, and those lanes take 0, as the guarded form and
root UAVs give. All with_mem_i32s callers only load (raw, SMEM,
unaligned, format and BVH node reads). Stores and atomics keep their
branch. Compute programs only (kernel and CS entries,
kernel::reads_heap_flat): mesh, GS, vertex and pixel programs keep the
guarded form. The HLSL path ignores the flag. The one-path form is the
idea xcl-dev#1695 brings to the HLSL heap form.

xcl shaders (--precompile, --export-hlsl, --measure-pso) takes its
windows from pso::windows_for, as pso::mem_windows does, instead of its
own copy of the rule, which had no HEAP_FLAT: with XCL_HEAP_FLAT=1 the
precompile made the guarded form's entries, not the ones the runtime
looks up (found by bielfreedom).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@pvfreis

pvfreis commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

By reading only, not run, at 970823e4: on NVIDIA with default settings, xcl shaders --precompile makes VS, PS and mesh compute-pass entries that the runtime never looks up.

  • precompile gets one window count for every stage: shaders.rs:978 takes it from runtime_windows, which is pso::compute_windows(n) (shaders.rs:996). On NVIDIA that is n | HEAP_WINDOWS | HEAP_FLAT (pso.rs:92, :146).
  • VS, PS and mesh programs are translated with it (shaders.rs:1695), so translate emits the heap form (recomp/mod.rs:1506), and compile_cached keys on that HLSL (dxc.rs:575).
  • At run time those stages take mem_windows() (pso.rs:204 for VS/PS, pso.rs:1229 for mesh), which has heap windows only with XCL_HEAP_WINDOWS=1 (pso.rs:79, :151). Their HLSL is the root-UAV form, so each of those precompiled entries is a cache miss and the title compiles them cold. Nothing wrong is loaded. On main and on Recompiler: direct DXIL reads heap memory windows without a branch #2427 alone the two counts are the same.
  • Compute is fine, and so is the mesh pass-through. --only cs, --windows 1, XCL_HEAP_WINDOWS=0 or =1 and other vendors are not affected. precompile_windows_are_the_runtimes runs with XCL_HEAP_WINDOWS=1, so it does not see this.

A fix could give precompile both counts: compute_windows(n) for compute containers and the rule mem_windows uses for the rest, with the test also run with XCL_HEAP_WINDOWS unset and an NVIDIA vendor. #2613 and #2246 pass the same single count on to VS/PS and to the mesh pass, so they do not change this.

AI use: Claude Code (Claude Opus 5.5) found this; Claude Fable 5.2 rechecked it; checked by a person before posting.

On NVIDIA, the compute programs the direct DXIL translator makes now
read their memory windows through the shared descriptor heap in the
flat form (HEAP_FLAT) by default, instead of through root UAVs. Other
stages and other GPUs are unchanged.

- pso::heap_windows: XCL_HEAP_WINDOWS=1 every stage (as before), =0 none,
  unset: on when the title's adapter is NVIDIA (set_adapter_vendor, from
  the device's DXGI adapter). XCL_HEAP_FLAT=0 turns the flat form off.
- compute_mem_windows: the windows of a compute program, with the heap
  by default; mem_windows (graphics, mesh, GS) takes the heap only with
  XCL_HEAP_WINDOWS=1. The HLSL path keeps root UAVs unless
  XCL_HEAP_WINDOWS=1 (hlsl_windows): its heap form is not measured.
- A pipeline the driver refuses with heap windows is still built with
  root UAVs (with_switch_fallback), but only when the stage it builds
  took heap windows (with_switch_fallback's `heap`): an E_OUTOFMEMORY of
  a graphics or mesh pipeline built with root UAVs is not retried.
- xcl shaders --precompile / --export-hlsl / --measure-pso: the keys of
  the runtime, from the bench's adapter: compute programs take
  pso::compute_windows (compute_mem_windows), VS, PS and mesh programs
  pso::graphics_windows (mem_windows), so by default on NVIDIA only the
  compute programs are precompiled with heap windows (found by pvfreis).
- XCL_UMA_WINDOWS=8|16 still needs XCL_HEAP_WINDOWS=1.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Kalmarv

Kalmarv commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@pvfreis thank you, that was right, and it would have cost exactly what this PR is for: VS, PS and mesh programs compiling in play after a precompile.

Checked against the code at 970823e: precompile translated every stage with pso::compute_windows(n), which on NVIDIA by default is n | HEAP_WINDOWS | HEAP_FLAT. VS, PS and mesh programs take pso::mem_windows() at run time, which has heap windows only with XCL_HEAP_WINDOWS=1.

Fixed in c6e5af8, as you suggested:

  • runtime_windows in shaders.rs gives two counts. Compute programs take pso::compute_windows, as compute_mem_windows does. VS, PS and mesh programs take the new pso::graphics_windows, which mem_windows now uses too.
  • precompile_windows_are_the_runtimes now also runs with XCL_HEAP_WINDOWS unset on an NVIDIA and an AMD vendor, each in a new process. With the old single count it fails on the NVIDIA case: VS, PS and mesh got 772 where the runtime uses 4.
  • Suite on c6e5af8: 1431 passed, 0 failed, 46 ignored.

Offline count, the first 4,000 records of the title's shader pack, release: a fresh DXIL cache, xcl shaders --precompile --only vs with default settings, then the same with XCL_HEAP_WINDOWS=0, whose VS keys are the runtime's default ones.

  • 970823e: the second run compiled all 542 again, so none of the precompiled VS entries would have been found in play. The 12 it found are programs that repeat within the pack.
  • c6e5af8: the second run compiled none and found all 554.

I did not count PS. The first 6,000 records hold none, and a full-pack count takes close to an hour. PS and mesh take the same count as VS in precompile.

AI use: Claude Code (Claude Opus 5.5) made the fix, the test and the count and wrote this reply.

@pickles976

Copy link
Copy Markdown

The GPU leg now runs and passes on a relaxed diagnostic stack — and the fallback genuinely fires. Head af825308 (policy tests previously verified 2/2 under Wine on this host), RTX 4060 Laptop GPU 8 GiB, Wine 11.0, NVIDIA 590.48.1, --locked --target x86_64-pc-windows-msvc, one test thread, fresh Compiling xcl .../xcl-pr2428/... provenance.

On stock vkd3d-proton 3.2.0 this integration test aborted before its body: Assertion failed: iface->lpVtbl == &d3d12_root_signature_vtbl (vkd3d_private.h:2111) after ID3D12RootSignature – 8 PC methods, 33 internal slots under the guard — the #175 identity wall, which is why the earlier report here carried only the policy-test result.

On the relaxed diagnostic build of the same provenance commit our stock DLL reports (2576c0b4adfae4a, -Db_ndebug=true + the two #175 from_iface relaxations, local-only): heap_window_out_of_memory_falls_back_to_the_switch_form passes 1/1 (0.91 s). Not a skip: the log shows the forced OOM hitting on the real adapter — the driver ran out of memory on a pipeline with heap windows – building it in the switch form (1 so far) — followed by a translated console CS PSO build and full Queue/Fence/Resource/Allocator/List adoption through the guards. The #1651 concern about this test's opt-in GPU skip did not apply here; the fallback path executed.

Scope: relaxed stack = identity checks compiled out, so this verifies the fixture's assertions, not XCL's vtable patching against a stock runtime; no title run. Log: .compat-xcl/logs/verify-pr2428-wine-heap-oom-relaxed.log (local). AI-assisted verification and report (OpenAI Codex).

@Kalmarv

Kalmarv commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@pickles976 thank you, especially for showing that the fallback really fired on the adapter and wasn't skipped. Your run is under Tested by others in the description, with your caveats: the relaxed diagnostic build with the identity checks compiled out, and no title run. It was on af82530. The head is now c6e5af8, which changes only the precompile's windows, not the fallback path.

AI use: Claude Code (Claude Opus 5.5) wrote this reply.

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

Labels

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.

8 participants