Skip to content

D3D12.X: the sparse windows' pool heaps are 4 MiB, so freed runs of tiles go back - #2630

Open
imnicho wants to merge 1 commit into
xcl-dev:mainfrom
imnicho:sparse-small-pools
Open

imnicho wants to merge 1 commit into
xcl-dev:mainfrom
imnicho:sparse-small-pools

Conversation

@imnicho

@imnicho imnicho commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

A pool heap of the sparse windows goes back only when every tile of it is free, and a title frees its tiles in runs spread over all its heaps. With heaps of 64 MiB a retail title's world load leaves 1.5 – 2.0 GB of video memory in live heaps as free tiles (and Windows charges that to the process's commit as well). This makes the heaps 4 MiB, so the heaps of the freed runs go back. Part of #1773 (its point 3); the measurements that led here are in my comment there.

What is in it

  • hle/d3d12x/sparse.rs: POOL_TILES is 64 (it was 1024).
  • retire_free_pools marks the pools that go with a flag each. It searched a list of them once per free tile, which was fine for a handful of 64 MiB pools and is not for the hundreds of small ones a world load frees at once.
  • Test pools_of_freed_runs_go_back: 192 MiB of tiles taken in order, of every 64 MiB the first 4 MiB kept and the rest freed. With POOL_TILES at 1024 it fails with 3072 tiles of video memory stay in pools for 192 tiles in use (192 MiB for 12 MiB).

Tested

  • NVIDIA GeForce RTX 5080 16 GB (driver 610.47, 32-lane waves), Intel Core i7-7700K, 16 GB RAM, Windows 10 22H2 (19045), Rust 1.100.0 (MSVC); debug for the suite, release for the title.
  • cargo build --workspace + cargo test --workspace --no-fail-fast -- --test-threads=4, run twice on this head: 1,436 passed, 0 failed, 47 ignored; and 1,435 passed, 1 failed, 47 ignored, the failure being hle::d3d12x::vram::tests::d32s8_targets_take_their_own_size_of_video_memory at its list's Close with 0x80004005. That is the failure D3D12.X: a direct list at a released compute list's heap vtable address gets the compute list's methods #2588 describes on main (now and then in parallel runs); the test does not use the sparse pools and passed alone, 3 of 3.
  • 29 SKIPPED lines in each run: 21 wave64 forms (no wave64 on this adapter), 3 per-lane f16 / f32 forms refused, 2 of the title under the debug layer and 1 upload test (no D3D12 debug layer here), 1 no heap windows, 1 that cannot turn the driver cache off (no Developer Mode).
  • The new test passes here, and fails with the message above when POOL_TILES is put back to 1024.

The retail title of #505, Series S profile, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_TEXTURE_LEVEL_PAGES=1, one run of 600 s each. Both builds (the second from this change before one comment was reworded) also carry #684 (without it main ends in xg::copy_from at the world's set-up) and a local counter that is not in this PR (free tiles by pool, time of CreateHeap and of the mapping UpdateTileMappings calls):

main b49be18 + #684 this PR + #684
sparse pools (mapped) at 120 s 4,992 (4,585) MB 4,596 (4,585) MB
sparse pools (mapped) from 240 s to the end 4,800 (3,101) MB 3,348 (3,118) MB
free tiles in live heaps at the end 1,698 MB in 75 heaps 229 MB in 837 heaps
local video memory from 240 s to the end 8,622 – 8,623 MB 7,563 MB
peak local video memory 8,624 MB 8,062 MB
dedicated video memory of all processes, highest sample 9,580 MB 8,968 MB
pool heaps made, time of their CreateHeap 88, 399 ms 1,436, 904 ms
UpdateTileMappings calls that map tiles, their time 128,890, 8,142 ms 129,874, 8,733 ms
sparse windows: 16 submits: time spent, tiles mapped 89 ms, 61,432 83 ms, 61,426
sparse windows: 8192 submits: time spent 2,311 ms (at 161 s) 3,419 ms (at 180 s)
frame 19 shown at 23.0 s 22.1 s
presents per 2 s, 20 s windows from 20 s to 160 s 27 – 30 (one window 41) 25 – 30

So the pools follow what is mapped: 1,452 MB less in pool heaps and 1,060 MB less local video memory once the world loads, for 0.5 s more in CreateHeap and 0.6 s more in tile mapping over the run. Both runs wait for pipelines after the world's set-up (no present there in either), so this compares the menus, the loading screens and the load itself. Process commit is not in the table: the two runs compiled different amounts in the driver at the same times (19 against 1 compute pipelines of 10 s or more), which moves it by more than the heaps do.

The same change on nvidia-dev c044dc6d + #684 (XCL_UMA_SHADOW=1, one run each, the runs before and after it in one night on the same caches):

64 MiB heaps 4 MiB heaps
sparse pools (mapped) at 181 s 4,608 (3,474) MB 4,028 (3,990) MB
sparse pools (mapped) at 361 s 4,608 (3,039) MB 3,236 (3,146) MB
free tiles in live heaps at 361 s 1,569 MB in 72 heaps 89 MB in 809 heaps
local video memory at 361 s 14,434 MB 13,081 MB
peak local video memory 14,470 MB 13,082 MB
process commit at 361 s 29,097 MB 27,903 MB
sparse windows: 16 submits: tiles mapped, time spent 126,995, 1,074 ms 127,035, 1,081 ms
sparse windows: 8192 submits: time spent 5,293 ms 5,558 ms
end of the run device removed at 380 s (0x887a0006), dedicated video memory of all processes at 15.4 of 16 GB ran its 1200 s, 14.0 – 14.1 GB

One run each, so the last row shows no cause. Added 2026-11-26 after seven more runs of the 4 MiB build on the same caches (1200 s each): six ran their time, and one lost the device the same way at 241 s (0x887a0006, DRED with the same operations around the stop) with local video memory at 12,986 MB. So that removal comes with 64 MiB and with 4 MiB heaps, and does not need a full card; the last row is no evidence for this change.

Regression run

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1138 (PresentX 1139)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13704 MB

this PR:

xcl-smoke v1
commit: 839a163f5fc5c006cb2e53add20959ce6ce074fc
gpu: NVIDIA GeForce RTX 5080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1206 (PresentX 1206)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 13665 MB

Two more pairs of the same 60 s run: frames shown 1141 and 1123 on main, 1114 and 1242 here; peak commit 13,706 and 13,676 MB on main, 13,656 and 13,684 MB here.

Not tested

  • AMD and Intel adapters, and Wine / vkd3d-proton (where a heap may become a device memory allocation of its own: about 1,100 – 1,200 of them for this title instead of 78).
  • The Series X profile, cards with less video memory, sessions longer than 20 minutes.
  • Whether a smaller or larger heap is better: on nvidia-dev 57 – 87 % of the free tiles lay in wholly free aligned blocks of 64, 28 – 62 % in blocks of 256, and blocks of 16 added little (the comment linked above).

AI use

Claude Code with Claude Fable 5.2 wrote the change and the test, ran the runs and wrote this text.

🤖 Generated with Claude Code

…iles go back

A pool heap is released only when all its tiles are free, and a title frees its
tiles in runs spread over all its heaps. With heaps of 64 MiB (1,024 tiles) a
retail title's world load unmapped 1.5 GB of its 4.6 GB of tiles and 3 of 78
heaps went back: 1.7 GB of video memory stayed in live heaps as free tiles.
With heaps of 64 tiles 1.25 GB goes back and 0.2 GB stays.

retire_free_pools marks the pools that go with a flag each: a world load frees
hundreds of pools' worth of tiles at once.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@pickles976

pickles976 commented Nov 26, 2026 •

Copy link
Copy Markdown

RTX 4060 Laptop GPU (8 GiB), NVIDIA 590.48.1, Wine 11.0 / vkd3d-proton 3.2.0, DXVK_CONFIG=dxgi.hideNvidiaGpu = False: exact head 839a163f5fc5c006cb2e53add20959ce6ce074fc built as Windows MSVC target and pools_of_freed_runs_go_back passed 1/1, no skipped host. DXVK enumerated the actual NVIDIA device. The fixture allocates 192 MiB of tiles, keeps 12 MiB (192 tiles) in three separated 4 MiB runs and retires/free-lists the remainder; it asserts no more than 24 MiB remains in live pool heaps. This bound held under Wine/vkd3d on this 8 GiB GPU. Log on the testing machine: .compat-xcl/logs/verify-pr2630-wine-rtx4060-sparse-pool.log (not attached).

This is isolated GPU pool-reclamation evidence, not a retail world-load or peak-host-RAM measurement; on Wine, smaller heaps may increase Vulkan allocation count/driver overhead. A matched guarded world-load comparison should sample pool bytes vs mapped bytes, driver allocation count, scope RAM and GPU usage. I did not launch XCL retail here because the existing console-facing in-place D3D12 vtable/root-signature assertions under stock vkd3d-proton precede this PR (#175), so this fixture cannot certify gameplay or the 16 GiB RAM floor.

Additional local-integration result (2026-11-26), not an exact-PR retail test: after installing diagnostic vkd3d-proton 3.2.0 2576c0b4adfae4a+ (allocator/list from_iface vtable checks relaxed; release b_ndebug=true), I transplanted the 4 MiB pool size and flag-based retirement into an older dirty 06c9f55 Wine integration. I adapted this PR's freed-run assertions into that integration's existing GPU pool-reuse/fence-release fixture: 1/1 passed, fresh Compiling xcl .../xcl-runtime/... recorded.

A separately fresh-built 1080p title trial still hit our unchanged 6000 MiB global GPU safety ceiling: stopped at 40.98 s, 6158 MiB GPU, 5389 MiB available system RAM, 4539 MiB scope memory / 4343.4 MiB anonymous, exit 137 from the guard. An 18-second window screenshot was black; no gameplay/input/FPS claim. Earlier same-integration 64 MiB-pool run at the same requested render resolution stopped at 38.86 s / 6039 MiB, but differing host state/cache history and absent pool-at-stop accounting mean these runs do not establish a performance or memory-saving comparison. Lowering title output from 4K to 1080p also did not by itself clear the ceiling.

The focused reclamation result remains positive; this integration result only says that this change alone did not make our workload fit. Sparse logging reported 61,095 mapped 64 KiB tiles at submission 16 and 57,495 at 128; these are intermediate live-page counts, not GPU allocations at the stop. This older integration lacks newer lazy-level texture residency, so please do not interpret it as coverage of current main or the full memory-fix stack.

Local evidence: .compat-xcl/logs/verify-runtime-pr2630-sparse-reclamation.log, build-xcl-runtime-pr2630-provenance.log, 20261126T051819Z-{console.log,resources.csv}, menu-20261126T051837277328Z.png. AI-assisted verification: omp / OpenAI Codex GPT-6 Astra. No code PR or push.

@futurepro62

futurepro62 commented Nov 26, 2026 •

Copy link
Copy Markdown

NVIDIA and AMD full-suite run, to go with pickles976's run of the new test on an RTX 4060 under Wine above. Tested exact head 839a163f (on its base b49be18).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1424 passed, 0 failed, 45 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, dispatch_chain_native_wave64_builds_whole, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: pools_of_freed_runs_go_back.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1435 passed, 0 failed, 47 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main b49be183 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@LocranKing

Copy link
Copy Markdown

Independent NVIDIA (8 GB VRAM) test report on exact head 839a163f5fc5c006cb2e53add20959ce6ce074fc (clean detached checkout, no local changes).

Tested

  • Hardware: NVIDIA GeForce RTX 3060 Ti 8 GB (Ampere, wave32, driver 32.0.16.2140 / 621.40), AMD Ryzen 5 5500, 32 GB RAM, Windows 11 Home (build 26300), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100.0.
  • cargo build --workspace + cargo test --workspace --no-fail-fast -- --test-threads=4 (debug): 1436 passed, 0 failed, 47 ignored (xcl --lib: 1310 passed, 0 failed, 27 ignored; pools_of_freed_runs_go_back passed).
  • 27 SKIPPED GPU tests on this adapter: 21 wave64-only (no wave64), 3 wave32 per-lane f16/f32 semantics, 1 no heap windows, 1 no D3D12 debug layer (0x887A002D), 1 cannot disable driver cache without Developer Mode (0x887A002D).

Regression run
scripts/smoke.ps1 -Seconds 60, release builds of origin/main (b49be18) and this PR's head (839a163):
Even in the first 60 s (boot/intro/menus), logged sparse pools dropped from 896 MB (838 MB mapped) (6117 MB local, 4685 MB non-local) on main to 840 MB (838 MB mapped) (6062 MB local, 4655 MB non-local) on this PR.

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3060 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1409 (PresentX 1409)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14032 MB

PR:

xcl-smoke v1
commit: 839a163f5fc5c006cb2e53add20959ce6ce074fc
gpu: NVIDIA GeForce RTX 3060 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1515 (PresentX 1515)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13945 MB

Not tested

  • AMD / Intel / Linux GPUs; XCL_SAMPLE_* tests; longer 600 s world-load runs (the 60 s smoke run covers boot/intro/menus only).

AI use

  • Antigravity (Gemini 4 Hydrogen) ran the builds, test suite, and smoke.ps1 commands on this machine and drafted this report from the captured outputs.

@Anon64

Anon64 commented Nov 26, 2026 •

Copy link
Copy Markdown

Tested on an RTX 3060 12 GB, retail world load, merged onto nvidia-dev: the pools of freed runs do go back (free tiles in pools 4–39 MB, was 44–134 MB), but on that branch they were already small, so the sparse windows still grow by what stays mapped.

Setup: RTX 3060 12 GB, NVIDIA 581.80, i9-14900KF, 32 GB RAM, Windows 11 26200, release build. Head 839a163 merged locally onto nvidia-dev af2cecc4 together with #2357 (both runs below carry #2357 with XCL_TARGET_PAGES_MB=4096, so only this PR differs). One conflict in retire_free_pools: nvidia-dev already retires a pool only when its tiles have cooled (free_heaps over free and cooling). I kept that and took this PR's flag per pool in place of gone.contains(...), plus POOL_TILES = 64. So this is not the exact head. Same title and start, XCL_ADAPTER=3060 XCL_GFX_PSO_WAIT_MS=200 XCL_PREPARE=0 XCL_ACTIVITY=1, compute pipelines warmed, one run each.

Sparse pools from the 2 s memory: line (MB):

t (s) without, pools / mapped / free with, pools / mapped / free
60 1,792 / 1,734 / 58 1,760 / 1,756 / 4
120 2,880 / 2,746 / 134 2,812 / 2,795 / 17
180 3,264 / 3,195 / 69 3,140 / 3,120 / 20
240 3,712 / 3,668 / 44 3,764 / 3,725 / 39
  • The free part goes down as described. On nvidia-dev it was already 44–134 MB rather than the 1.5–2.0 GB of the description (that branch's cooled retiring may be why), so the saving here is tens of MB.
  • The growth from 1.8 GB to 3.7 GB is mapped tiles, which this PR does not touch: local video memory still went 1–1.7 GB over the DXGI budget (about 10.5 GB) after 120 s in both runs.
  • Both ended on the title's own watchdog while pipelines were being built (298.9 s without, 274.0 s with); no device removal, no crash in XCL.
  • The run with this PR reached 1,800 frames at 168 s, the one without at 107 s. One run each, so I cannot say whether the smaller pools cost frame time; not claimed either way.
  • pools_of_freed_runs_go_back passes on the merge. Other sparse tests (mirrored_tiles_stop_at_the_cap, pages_being_decommitted_stay_holes_for_a_submit, a_copy_back_does_not_wait_for_the_title_queue) failed in a cargo test --lib sparse run on the merge and also on plain af2cecc4, so not from this PR; run alone on af2cecc4, mirrored_tiles_stop_at_the_cap passes, so it looks like tests sharing the device in parallel (as in D3D12.X: a direct list at a released compute list's heap vtable address gets the compute list's methods #2588).

Not tested: the exact head or main; more than one run each; the whole suite on the merge; AMD.

AI use: Claude Code (Claude Opus 5.5) merged the branch locally, ran the runs on this machine and wrote this report.

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.

5 participants