Repository navigation
D3D12.X: bound target-page pools by title and adapter VRAM budgets - #2357
safesearch77 wants to merge 1 commit into
Conversation
`vram::Pages` backed GPU-owned targets (`vram::place`) and placed sampled textures (`vram::place_pages`) with 64 MiB `D3D12_HEAP_TYPE_DEFAULT` pool heaps without checking `Config::title_memory_budget_mb()` or DXGI's local video-memory budget (`DXGI_MEMORY_SEGMENT_GROUP_LOCAL`). As a result: 1. `target pages` climbed past 9,521 MB even with `title_memory_mb = 4096` (xcl-dev#646), pushing WDDM into local-VRAM overcommit / PCIe thrash TDRs (`0x887a0007`) and multi-30 GB system commit on 8 GB and 12 GB GPUs (xcl-dev#1337, xcl-dev#1773). 2. When `alloc_pool_heap` eventually returned `None` on `CreateHeap` OOM, `place_on_pages` destroyed the already-created Tier-2 reserved `ID3D12Resource` and returned `None`, spilling into unbudgeted arenas or `CreateCommittedResource(DEFAULT)` until `CreatePlacedResourceX` returned `E_OUTOFMEMORY` (`0x8007000E`) and tripped the retail title's infallible-placement assert at `+0x193e00f` (xcl-dev#333, xcl-dev#1337). Bound `Pages` pool creation to `min(title_memory_mb, 75% of DXGI local budget)` on discrete adapters and `title_memory_mb` on UMA adapters by default (overridable via `XCL_TARGET_PAGES_MB`, `0` = uncapped), back off failed `CreateHeap` calls for 1s until a pool heap is reclaimed, and keep over-budget Tier-2 reserved placements alive with unbacked tiles left `D3D12_TILE_RANGE_FLAG_NULL` (retaining the coarsest mips across every array/cubemap slice when `MipLevels > 1` while sharing all already-backed pages). Part of xcl-dev#1833 (xcl-dev#333, xcl-dev#646, xcl-dev#1337, xcl-dev#1773). Assisted-by: Antigravity (Gemini 4 Carbon)
a41a858 to
889008f
Compare
|
Windows / AMD RDNA2, 12 GB card + 16 GB RAM: exact head Tested
Regression run
main: PR: Title A/B on the head, cap on (default) vs
Not tested
AI use
|
|
I tested
No retail run. AI use — Codex added the two local test probes, ran the tests, analyzed the results, and assisted in drafting this report. |
|
A test where the cap engages on the retail title: on NVIDIA under Linux, one of the two runs with this PR ended in a GPU page fault from the copy engine, and the other had fewer frames and about half the draws of the two runs without it. Tested
Run 4's kernel line: After the world load (runs 1–3): 1.45 presents/s, 234 draws/s with the cap; 1.65–1.73 presents/s, 561–574 draws/s without. Peak GPU memory 15.3 GB with the cap against 15.8 GB (full) without; system memory and swap about the same. The frames I dumped are loading screens in all four runs and look the same. Not tested: Windows; Series X mode (there the cap would be ~12 GB here, above the ~10.5 GB the pools reach, so it would not engage); the test suite on this tree with the PR; whether the copy that faulted is an upload, a readback or a title copy. AI-assisted. Claude Code, Claude Opus 5.5 made the runs and wrote this comment. |
|
Diff review on Remaining before merge:
|
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
NVIDIA RTX 3060 12 GB (the #646 card), retail title 1.0.2.1 into its story load: the cap holds – pools stop at 8 448 MB and target pages at 8 404 MB, against 9 984 / 9 644 MB on the base, and local video memory ends 1.46 GB lower. No Setup: NVIDIA GeForce RTX 3060 12 GB, driver 32.0.16.2101 (wave32), Ryzen 5 5600X, 32 GB RAM, Windows 11 Pro 10.0.26300.9974, Rust 1.100.0, release builds, DXC 1.9.2609.5. Head Head's startup line: Regression run Base Head Head 108 % of base frames, 91 % of its peak commit.
Tested
Not tested
AI use
|
|
Tested: current PR head merged onto current Not tested: retail titles (no title data on this lane, counts only). AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting. |
bmjask
left a comment
There was a problem hiding this comment.
P2: VRAM cap accounting excludes fence-retiring heaps. The cap checks active pools.len() (vram.rs:967/bind allocation), but sweep_and_reclaim removes empty pools from active state before queuing their heaps in retiring until both fences complete. New allocations then see a free cap slot; repeated reclaim/allocate while fences lag can exceed the configured cap by all retired heaps. Count active plus retiring residency, or retain cap capacity until retirement completes, with a blocked-retire-fence test. P2: eager partial binds still set Target.mapped=true when cap pressure leaves some tiles NULL. remap_if_unmapped then returns immediately, so later freed tiles never fill those eager missing pages. Track missing tiles/retry them, or leave partial targets unmapped; add a recovery-after-budget-frees test.
|
RTX 3080 10 GB: with this PR the retail title no longer loses its device at world load. 6 of 6 runs reached 100 s against 0 of 6 without it. Setup
Results
One longer run of head + #684 with no Without #684, head got past the removal but every run (7 of 7) then crashed at 74–80 s in Why the removal is out of memory Not tested
AI use: Claude Code (Claude Opus 5.5) made the builds, ran the runs and the probe on the hardware above, and wrote this. |
Bound
vram::Pages64 MiB pool-heap growth byConfig::title_memory_budget_mb()and DXGI local VRAM budget, and keep Tier-2 reserved resources alive with partial tile mappings when capped or out of VRAM instead of destroying them and failingCreatePlacedResourceXwith0x8007000E.Part of #646
Part of #333
Part of #1337
What is in it
crates/xcl/src/hle/d3d12x/vram.rs:compute_max_pools/target_pages_max_pools: cap 64 MiBPoolHeapsatmin(title_memory_budget_mb(), 75% of DXGI local VRAM budget)on discrete GPUs (5,056 MiB/ 79 pools on 8 GB GPUs;4,096 MiB/ 64 pools on#646Run 2), usetitle_memory_budget_mb()onUMAadapters so small BIOS carve-outs are ignored, and supportXCL_TARGET_PAGES_MB(0= uncapped).TilePool::take_up_to,Pages::bind_tiles&Pages::bind_range: reuse 100% of already-resident shared pages at cap, retain coarse tail tiles across every cubemap/array slice (DepthOrArraySize) whenfresh.len() < missing, leave unbacked tilesNULL(D3D12_TILED_RESOURCES_TIER_2reads0, drops writes) soCreatePlacedResourceXsucceeds without spilling unbudgeted heaps or hitting the+0x193e00f0x8007000Eassert (and underXCL_TEXTURE_LEVEL_PAGES=1, returnNonefrombind_rangeat cap so unbacked level groups retry once pools free up), and back offCreateHeapretries for1son driver OOM untilsweep_and_reclaimfrees a pool.target_pages_budget_respects_env_title_memory_uma_and_adapter_vram,budgeted_bind_shares_pages_retains_cubemap_coarse_mips_and_survives_cap, extendedtile_ranges_per_heap).Tested
x86_64, base65fc114, head889008f) withcargo check --offline --target x86_64-pc-windows-gnu --workspace --tests(0errors,0warnings invram.rs) and executed pure-CPUvram::testsharness on Linux (rustc --test: budget matrix +bind_tiles2D/cubemap/shared-VA/0-tile tests pass).889008fd342ac779a601d7f93c8a54430360b306vs base65fc114a140d9043f8e3d70ffb863f7987816d8f(courtesy of@Haxodius, #2357 (comment)):rustc 1.98.1MSVC, DXC 1.9.2609.5, Agility D3D12Core 1.620.2.cargo test --workspace --no-fail-fast -- --test-threads=4(debug): 1283 passed, 1 failed (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 540, same failure on base65fc114), 46 ignored; all newvram::testspass;SKIPPED(8): six per-lanef16/f32lower_dxil::tests,pso_measurement_compiles_an_exact_synthetic_record(Developer Mode off),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).anaconda):pool budget 8576 MiB, 134 pools from 75% of DXGI local budget.Regression run
60 s warm-cache
scripts/smoke.ps1pair on retail title 1.0.2.1 (run and reported by@Haxodiusin #2357 (comment)):main:
PR:
Not tested
~4.5 GBof pools) before reaching the 8,576 MiB pool cap; an 8 GB VRAM card (or 12 GB VRAM with >=32 GB host RAM) is still needed to exercise the capped partial-binding path in the retail title.anaconda, 75% of ~11.1 GiB DXGI local budget capsPagesat ~8.3–8.6 GiB;XCL_TARGET_PAGES_MB=0restores uncapped overcommit).AI use
#646/#333/#1337pool growth and OOM fallback, implementedcompute_max_poolsandbind_tiles, and wrote the unit tests; reviewed with Claude Opus 5.5 (cubemap/array slice retention and UMA exemption). Windows GPU test and smoke runs reported by@Haxodiususing Claude Code (Claude Opus 5.5).