Repository navigation
D3D12.X: an optional page budget evicts CPU-filled title textures LRU - #640
LeonardoS11 wants to merge 1 commit into
Conversation
The title-texture pages (vram.rs) grow with every 64 KiB page of title memory a texture has ever covered: pool heaps are never released, and a title that recycles texture memory inside its own allocator gives no signal that the old textures are dead. On a retail title that streams its world this reached 9.7 GB of pages (13.7 GB of local video memory on a 12 GB card) and the driver paging stalls set off the title's watchdog. XCL_PAGE_BUDGET_MB caps the pool heaps. At the cap, take_tile evicts the least recently touched textures the CPU fills (placed through place_pages; never GPU-owned targets, never textures the GPU wrote, none under 4 tiles or touched in the last 5 s) and reuses their tiles. An evicted texture is mapped again and uploaded whole when its memory is written again or a submitted transition names it; its content hash is forgotten so the unchanged-upload skip does not leave it out. Unset or 0 keeps the current behaviour. Tests: page_budget_evicts_the_least_recently_touched_cpu_filled_texture (vram.rs, GPU) and a_texture_mapped_again_after_eviction_is_uploaded_even_if_unchanged (title_textures.rs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested on NVIDIA GeForce RTX 3060 Ti (8 GB, wave32). Tested
Regression run ( main ( PR #640 ( PR #640 (
Not tested: Walking past the start/menu screens into world streaming, debug build, AI use: Antigravity ( |
|
Independent Windows Radeon comparison on I ran the same binary and saved profile with AI-assisted (Codex ran and summarized the measurements). |
|
8 GB data point with the budget set. Native Windows 11, RTX 4060 Laptop 8 GB (7956 MiB), driver 621.24, 15 GB RAM + 40 GB page file, release MSVC build. The newer retail title (TitleID 7952987A), Series X profile, Compared with the same base without this PR (#333 comment, one run each):
Evictions: 561 by 160 s, 8714 by 280 s (824 mapped again). None after 280 s. Observations:
So on 8 GB this takes the run past the out-of-memory stop to the same watchdog stop that larger cards reach. A budget taken from the adapter's AI use: the logs were analysed and this comment drafted with Claude Opus 5.5; I ran the game and checked the results. |
|
Follow-up to my run above: the same build without
So the frame collapse is not caused by the eviction. Both runs drop to almost no frames about 20 s into play, once local video memory goes past the card's 7956 MiB. With the budget, the run then keeps going for another 160 s instead of failing At the menus, local video memory outside the target pages and sparse pools is about 1.7 GB (6139 − 3577 − 896 MB). To stay under 8 GB, pages + sparse would have to stay below roughly 6 GB, but the run above had 5.3 + 2.0 GB, and about 3.6 GB of the pages are already in use at the menus. So on the Series X profile, an 8 GB card would need the cap enforced more strictly, which means more missing textures. (One other run of this build crashed at 13 s inside the NVIDIA driver, AI use: the logs were compared and this comment drafted with Claude Opus 5.5; I ran the game. |
|
Paired native Windows 11 runs on an RX 7900 XT (20 GB), retail 1.0.2.1, DXC 1.9.2602.17. I applied the budget change to a local integration build that also includes #690, bounded PSO waits and sparse-buffer release changes. Both runs used the same release executable, saved profile, A at 37 s, DRED, and separate copies of the same starting application caches (1,062 prior-use shader sets). The driver cache was shared. The 6 GiB run went first. CPU compilation overlapped parts of both runs, so I am reporting memory and outcomes only.
With the budget on, the last sample reported 8,175 textures evicted and 1,045 mapped again. The budget run ended at 159.855 s with an access violation in the title. The control ended at 157.917 s with an access violation in vcruntime140 on a thread processing audio. Both passed the account picker and streamed world assets. Neither reached verified playable frames. Zero device removals in both. These runs show a smaller memory footprint, but do not establish a cause for either crash or whether evicted textures rendered correctly. Combined workspace suite: 724 passed, 0 failed, 41 ignored. Upstream change tested: 38bf6a3. Workspace command: |
|
Code audit + NVIDIA RTX 5080 test run on Three bugs found in the revive path
Tested
Not tested
AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above. |
|
One more data point, about what the LRU order sees on this title. Same machine (RTX 4060 Laptop 8 GB). Build: main At 62 s, just before #333's out-of-memory stop at 63.5 s:
So on this title, every CPU-filled texture on the pages (the age rows add up to the same 2308 textures) has never appeared in a submitted transition. Their The same counts at 32 s (menus, before streaming) show that most of the floor is GPU-written: 3367 MB of 3598 MB of target pages. With 1.1 GB of committed resources (buffers 571 MB, UAV textures 419 MB, two 3840×2160 display targets), 465 MB of arenas and 1–1.8 GB of sparse pools, that leaves about 1 GB of an 8 GB card for CPU-filled textures on the Series X profile. The driver's share of the local count, outside heaps and committed resources, was only about 136 MB. AI use: the measurement patch and this comment were written with Claude Opus 5.5; I ran the game. |
… card, no out-of-order waits; first builds of world compute pipelines remain Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The title-texture pages in
vram.rs(shared 64 KiB pages per title address, #248/#288) only ever grow: a page is kept while any live texture covers its address, and the pool heaps behind them are never released. A title that recycles texture memory inside its own allocator gives XCL no signal that the old textures are dead, so the pages cover every address the title ever used for textures, not what it uses now. On a retail title streaming its world after the menus, withXCL_ACTIVITY=1and a temporary counter on a local build: the pages went from 3.6 GB in the menus to 9.7 GB (8.6 GB shared + 1.1 GB extra tiles, 62 k live targets) while the title's own crash context reported 3.6 of its 6.2 GB texture heap in use; local video memory reached 13.7 GB on a 12 GB card, frames dropped to 2–3 fps and the title's stall watchdog (+0x2215c35, #232) ended it. Related: #320, #345, #292 (a different approach: retiring overwritten placements).This adds an opt-in budget,
XCL_PAGE_BUDGET_MB. Unset or 0 keeps today's behaviour.What is in it
crates/xcl/src/hle/d3d12x/vram.rs:pool_cap()turns the budget into a number of 64 MB pool heaps. At the cap,take_tilecallsevict_lru, which unmaps the least recently touched textures the CPU fills (placed throughplace_pages) until 512 tiles came back, and reuses their tiles instead of making another pool. Never evicted: GPU-owned targets (place), textures the GPU wrote (pin, fromnote_gpu_write), textures under 4 tiles, and anything placed, remapped or transitioned in the last 5 s. Pages another mapped texture still shares stay.take_evicted/any_evicted/touch/eviction_countsfor the callers.crates/xcl/src/hle/d3d12x/title_textures.rs: an evicted texture is mapped again (remap_if_unmapped) and uploaded whole when its memory is written again (refresh_once) or a submitted transition names it (submitted, which also refreshes its LRU time).forget_contentdrops its D3D12.X: a title texture whose memory is as at its last upload is not uploaded again #486 content hash so the unchanged-upload skip does not leave the fresh tiles empty.crates/xcl/src/host.rs: onepage budget: N textures evicted, M mapped againline next to theXCL_ACTIVITYmemory line, only once something was evicted.Known limit: XCL does not see the title read a texture, only write or transition it. An evicted texture the title still samples without rewriting or transitioning it reads as zero (tier-2 unmapped tiles) until one of those happens. That is why the budget is opt-in.
Tested
cargo test --workspace -- --test-threads=4(debug) on38bf6a3: 688 passed, 0 failed, 41 ignored. New:page_budget_evicts_the_least_recently_touched_cpu_filled_texture(vram.rs, GPU: the oldest CPU-filled texture is evicted, its pages go back, a pinned one stays, an evicted one maps again) anda_texture_mapped_again_after_eviction_is_uploaded_even_if_unchanged(title_textures.rs).gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64).XCL_PAGE_BUDGET_MB=6144,XCL_NETWORK=0,XCL_ACTIVITY=1, walked through the menus into its first world load. These runs were on a local build that also carried other open PRs (D3D12.X: a draw waits at most 4 s for a pipeline still building (#232) #267, D3D12.X: bound compute pipeline waits so slow compiles do not trip wa… #533, Memory: decommitted sparse tiles stay mapped until the next submit #532, Memory: a freed sparse block is decommitted before its address is reused #348) and local diagnostics, not on this branch alone, so they show what the budget does, not this branch's numbers: pages held at 4.6–6.0 GB and local video memory at 10.1 GB (13.7 GB without the budget), 9,791 textures evicted and 1,094 mapped again over 456 s, 30 fps in the menus, the world's geometry drawn. The title still stops at the Retail title: null write at +0x2215c35 (#159) still hits on NVIDIA RTX 4070 Ti, with and without XCL_NETWORK=0 #232 watchdog later on this machine, for compile stalls this PR does not address.Regression run
Same title, 60 s, no input, budget unset (the default this PR keeps).
main:
this PR:
Not tested
AI use
🤖 Generated with Claude Code