Repository navigation
D3D12.X: bound target-page pools by title and adapter VRAM budgets - #2357
safesearch77 wants to merge 1 commit into
Conversation
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. |
|
Tested on an RTX 3060 12 GB with 32 GB of RAM in a retail world load (the case "Not tested" asks for): the cap holds, but on a 12 GB card 75 % of the budget still leaves the process about 3 GB over it. Setup: RTX 3060 12 GB, NVIDIA 581.80, i9-14900KF, 32 GB RAM, Windows 11 26200, release build. The PR's head Video memory from the 2 s
How far each got. None of the three lost the device; all ended on the title's own watchdog when its submits stopped while pipelines were still being built, which is not this PR's code. The first What the cap costs and what it does not cover, from that 298.9 s run:
Not tested: the PR's exact head or AI use: Claude Code (Claude Opus 5.5) merged the branch locally, ran the runs on this machine and wrote this report. |
889008f to
c6213b2
Compare
|
Rebased onto
Huge thanks to AI use: Antigravity (Gemini 4 Carbon) |
|
Windows/NVIDIA check of current head One remaining cap-accounting interleaving in the new revision: AI use: Codex (GPT-6.2 Sol) inspected the revision, ran the tests, and drafted this report; I checked the review point against the code. |
|
Follow-up to my exact-head report: I reproduced the narrow cap handoff race on an RTX 3080 Ti using a gated GPU regression. The test pauses The candidate reserves reclaimed pool capacity while Tested: Windows 11 build 26300, RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, rustc 1.99.1 MSVC, DXC 1.8.2502.11. Not tested: paired retail-title smoke, AMD and Intel GPUs. AI use: Codex (GPT-6.2 Sol) wrote and ran the regression and candidate; Codex (GPT-6.2 Astra) reviewed the lock and test-lifecycle paths. I checked each point against the code and test output. Candidate diff against c6213b2diff --git a/crates/xcl/src/hle/d3d12x/vram.rs b/crates/xcl/src/hle/d3d12x/vram.rs
index 892e4557..1ab348f6 100644
--- a/crates/xcl/src/hle/d3d12x/vram.rs
+++ b/crates/xcl/src/hle/d3d12x/vram.rs
@@ -1479,11 +1479,12 @@ struct RetireQueue<H, F> {
fences: std::collections::HashMap<usize, (F, u64)>,
batches: Vec<RetiringBatch<H, F>>,
retiring_pools: usize,
+ pending_pools: usize,
}
impl<H, F: Clone> RetireQueue<H, F> {
fn new() -> Self {
- Self { fences: std::collections::HashMap::new(), batches: Vec::new(), retiring_pools: 0 }
+ Self { fences: std::collections::HashMap::new(), batches: Vec::new(), retiring_pools: 0, pending_pools: 0 }
}
/// Seal `heaps` behind `unmap_mark` and one fence signal per queue (signaled BEFORE queueing).
@@ -1513,6 +1514,8 @@ impl<H, F: Clone> RetireQueue<H, F> {
fn retiring_pools(&self) -> usize { self.retiring_pools }
+ fn counted_pools(&self) -> usize { self.retiring_pools.saturating_add(self.pending_pools) }
+
fn note_queued_pools(&mut self, pool_heaps: usize) {
if let Some(b) = self.batches.last_mut().filter(|_| pool_heaps > 0) {
debug_assert!(b.pool_heaps + pool_heaps <= b.heaps.len());
@@ -1543,15 +1546,15 @@ unsafe impl Send for RetireQueue<ID3D12Heap, ID3D12Fence> {}
static RETIRE: Mutex<Option<std::collections::HashMap<usize, RetireQueue<ID3D12Heap, ID3D12Fence>>>> = Mutex::new(None);
static RETIRING_BATCHES: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
+#[cfg(test)]
+static RECLAIM_GAP: Mutex<Option<(usize, std::sync::mpsc::Sender<()>, std::sync::mpsc::Receiver<()>)>> = Mutex::new(None);
fn retiring_pool_heaps_count(dev_key: usize) -> usize {
- if RETIRING_BATCHES.load(std::sync::atomic::Ordering::Acquire) == 0 { return 0; }
let g = RETIRE.lock().unwrap();
- g.as_ref().and_then(|m| m.get(&dev_key)).map_or(0, RetireQueue::retiring_pools)
+ g.as_ref().and_then(|m| m.get(&dev_key)).map_or(0, RetireQueue::counted_pools)
}
unsafe fn poll_retiring_pool_heaps(dev_key: usize) -> (usize, bool) {
- if RETIRING_BATCHES.load(std::sync::atomic::Ordering::Acquire) == 0 { return (0, false); }
let (done, remaining) = {
let mut guard = RETIRE.lock().unwrap();
let Some(rq) = guard.as_mut().and_then(|m| m.get_mut(&dev_key)) else { return (0, false) };
@@ -1559,7 +1562,7 @@ unsafe fn poll_retiring_pool_heaps(dev_key: usize) -> (usize, bool) {
let done = rq.reap_completed(|f| f.GetCompletedValue());
let delta = before - rq.batches.len();
if delta > 0 { RETIRING_BATCHES.fetch_sub(delta, std::sync::atomic::Ordering::AcqRel); }
- (done, rq.retiring_pools())
+ (done, rq.counted_pools())
};
let freed_pool = done.iter().any(|b| !b.heaps.is_empty() && b.pool_heaps > 0);
drop(done);
@@ -1606,6 +1609,8 @@ unsafe fn retire_heaps_and_sweep(
let rq = map.entry(dev_key).or_insert_with(RetireQueue::new);
let before = rq.batches.len();
let immediate = rq.retire_with(newly_reclaimed, unmap_mark, &queues, || dev.CreateFence::<ID3D12Fence>(0, D3D12_FENCE_FLAG_NONE).ok(), |q, f, v| q.Signal(f, v).is_ok());
+ debug_assert!(rq.pending_pools >= pool_heaps);
+ rq.pending_pools -= pool_heaps;
if immediate.is_empty() {
rq.note_queued_pools(pool_heaps);
}
@@ -1644,12 +1649,29 @@ pub(super) unsafe fn before_execute(queue: &ID3D12CommandQueue) {
do_reclaim = true;
newly_reclaimed = pages.sweep_and_reclaim(now);
if !newly_reclaimed.is_empty() {
+ let mut retire = RETIRE.lock().unwrap();
+ let rq = retire.get_or_insert_with(std::collections::HashMap::new)
+ .entry(dev_key).or_insert_with(RetireQueue::new);
+ rq.pending_pools += newly_reclaimed.len();
unmap_mark = Some((pages.fence.clone(), pages.value));
}
}
}
}
let reclaimed_pools = newly_reclaimed.len();
+ #[cfg(test)]
+ if reclaimed_pools > 0 {
+ let gate = {
+ let mut hook = RECLAIM_GAP.lock().unwrap();
+ if hook.as_ref().is_some_and(|(key, _, _)| *key == dev_key) { hook.take() } else { None }
+ };
+ if let Some((_, reached, resume)) = gate {
+ if reached.send(()).is_ok() {
+ resume.recv_timeout(std::time::Duration::from_secs(5))
+ .expect("reclaim test hook was not resumed");
+ }
+ }
+ }
if do_reclaim {
newly_reclaimed.extend(ARENAS.lock().unwrap().sweep_dropped_for(dev_key, now));
}
@@ -2075,6 +2097,79 @@ mod tests {
);
}
+ #[test]
+ fn reclaimed_pool_still_counts_before_retirement_is_queued() {
+ let _vram_guard = VRAM_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner());
+ use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_11_0;
+ unsafe {
+ let Ok(dev) = crate::gpu::agility::create_device(None, D3D_FEATURE_LEVEL_11_0) else {
+ return crate::gpu::recomp::runner::skip_test("no GPU");
+ };
+ let Some(mut pages) = Pages::new(&dev) else {
+ return crate::gpu::recomp::runner::skip_test("no GPU");
+ };
+ let spare = keep_spare_pools();
+ if spare > 2 { return crate::gpu::recomp::runner::skip_test("spare pool override > 2"); }
+ let cap = spare + 1;
+ for _ in 0..cap {
+ let heap = alloc_pool_heap(&dev).unwrap();
+ let slot = pages.pools.push_heap(heap);
+ pages.pool.add_heap_at(slot, POOL_PAGES);
+ }
+ pages.max_pools = cap;
+ pages.last_reclaim = Instant::now() - Duration::from_secs(2);
+ let queue = pages.queue.clone();
+ let dev_k = dev.as_raw() as usize;
+ let previous_retire = RETIRE.lock().unwrap().as_mut()
+ .and_then(|map| map.remove(&dev_k));
+ let previous = PAGES.lock().unwrap().insert(dev_k, Some(pages));
+ let (reached_tx, reached_rx) = std::sync::mpsc::channel();
+ let (resume_tx, resume_rx) = std::sync::mpsc::channel();
+ *RECLAIM_GAP.lock().unwrap() = Some((dev_k, reached_tx, resume_rx));
+ let worker = std::thread::spawn(move || before_execute(&queue));
+ let reached = reached_rx.recv_timeout(Duration::from_secs(5)).is_ok();
+ let (active, counted, replacement) = if reached {
+ let mut g = PAGES.lock().unwrap();
+ let p = g.get_mut(&dev_k).unwrap().as_mut().unwrap();
+ let active = p.pools.len();
+ let counted = retiring_pool_heaps_count(dev_k);
+ let replacement = alloc_budgeted_pool(
+ &dev, dev_k, cap, &mut p.oom_until, &mut p.pools, Instant::now(),
+ );
+ (active, counted, replacement)
+ } else { (0, 0, None) };
+ let _ = resume_tx.send(());
+ worker.join().unwrap();
+ *RECLAIM_GAP.lock().unwrap() = None;
+ let pages = PAGES.lock().unwrap().remove(&dev_k).flatten();
+ if let Some(previous) = previous { PAGES.lock().unwrap().insert(dev_k, previous); }
+ drop(pages);
+ let marks = {
+ let g = RETIRE.lock().unwrap();
+ g.as_ref().and_then(|m| m.get(&dev_k)).map(|rq| {
+ rq.batches.iter().flat_map(|b| b.marks.iter().chain(b.unmap_mark.iter()).cloned())
+ .collect::<Vec<_>>()
+ }).unwrap_or_default()
+ };
+ for (f, v) in marks { crate::gpu::fence::wait(&f, v, &dev, None, 5_000).unwrap(); }
+ let _ = poll_retiring_pool_heaps(dev_k);
+ let remaining_batches = {
+ let mut guard = RETIRE.lock().unwrap();
+ if let Some(m) = guard.as_mut() {
+ let ours = m.remove(&dev_k);
+ let remaining = ours.as_ref().map_or(0, |rq| rq.batches.len());
+ if let Some(old) = previous_retire { m.insert(dev_k, old); }
+ remaining
+ } else { 0 }
+ };
+ assert_eq!(remaining_batches, 0);
+ assert!(reached, "before_execute did not reclaim the empty pool");
+ assert_eq!(active, cap - 1);
+ assert_eq!(counted, 1, "the reclaimed pool must remain reserved during handoff");
+ assert!(replacement.is_none(), "a pool still live behind retirement fences cannot free cap capacity");
+ }
+ }
+
#[test]
fn capped_pages_keep_over_budget_placements_alive() {
let _vram_guard = VRAM_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner()); |
|
Thank you for the thorough review on
Waiting on a Windows GPU suite + 60 s AI use: Antigravity (Gemini 4 Carbon) |
|
Windows/NVIDIA follow-up on current head
I also attempted the required Not tested: AMD, Intel, Linux/Wine, retail world-load or gameplay under this head. No title files or diagnostics are attached. AI use: Codex (GPT-6.2 Sol) ran and checked these tests and drafted this report. |
|
Partial RX 9070 / Linux-Wine verification of head Tested RX 9070 (RADV GFX1201), Mesa Separate source copies and targets, built with
The VRAM selection explicitly excluded the existing The passing VRAM selection includes the new budget arithmetic, packed-group allocation, retirement accounting and native pool-cap tests. I then reran A separate query-only fixture called the actual budget-selection function on the initialized native device:
The default query recorded DXGI local budget Blocked coverage Both new recovery tests reached The old Four initial failures in the locally added query fixture came from requesting the device before initializing the backend. I corrected that fixture, preserved its source/binary/log evidence, and reran all four queries. No production code or original assertion was changed. The blocked recovery path was not investigated further. Environment: Not tested Successful eager/lazy recovery readbacks under Wine, a full workspace suite, retail data, smoke/world-load runs, actual VRAM pressure or OOM, title-level cap behavior, VRAM savings, performance/FPS, or other GPUs/native Windows. This is a limited test report, not a clean-suite or merge-readiness claim. AI use OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the full diff, prepared test-only observations and the query fixture, ran the tests, independently checked source/binary hashes, failure boundaries, adapter identity and budget arithmetic, and wrote this report. Publication authorized by the account owner. |
|
Independent native Windows validation of #2357 at Tested
Not tested
AI use Codex GPT-6.2 ran the builds and validation, reconciled the result counts with the logs, and prepared this report. |
|
Follow-up on current head I extended A local candidate marks every reactivated CPU-owned texture pending and invalidates its Test-only regression added to the existing eager recovery fixture let partial_a = read_subresource_bytes(dev, &queue, &tex_a.0, 0);
assert_ne!(partial_a, want_a, "capped upload must leave unbacked tiles zero");
assert!(partial_a.iter().any(|&b| b != 0), "backed half must hold uploaded texels");
+ let tex_shadow = place_registered(raw_dev, at_a, &d);
+ refresh(queue.as_raw());
cap.free_tiles((all - half) as usize);
refresh(queue.as_raw());
- assert_eq!(read_subresource_bytes(dev, &queue, &tex_a.0, 0), want_a);
+ assert_eq!(read_subresource_bytes(dev, &queue, &tex_shadow.0, 0), want_a);
+ drop(tex_shadow);
+ refresh(queue.as_raw());
+ let restored_a = read_subresource_bytes(dev, &queue, &tex_a.0, 0);
+ let mismatches = restored_a.iter().zip(&want_a).filter(|(got, want)| got != want).count();
+ assert_eq!(mismatches, 0, "reactivated exact-range alias retained stale unmapped tiles");Tested on Windows 11 build 26300, RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, rustc 1.99.1 MSVC, DXC 1.8.2502.11. No retail smoke, AMD, Intel, or Linux/Wine run for this candidate; this does not establish merge readiness. AI use: Codex (GPT-6.2 Sol) inspected the code, wrote and ran the synthetic regression and candidate, and drafted this report. I checked the source path and test output before posting. |
|
RTX 3070 8 GB retail smoke on head Tested Windows 11 build 26200, i9-10900KF, 32 GB RAM, RTX 3070 8 GB, NVIDIA 621.40, DXC 1.8.2502.11. Both releases built with Series X, default target-page policy, no scripted input. Both used
The A press occurred about 29 s into the PR’s title timer. The PR selected a 5,376 MiB pool limit and logged no cap hits. Total local video memory exceeded the Windows budget in five samples. A matched-input follow-up was cancelled during shader preparation and produced no smoke block. The two head GPU readbacks also passed on this adapter (2 passed, 0 failed, 0 ignored, no explicit skips). I ran Regression run Main PR Not tested Matched-progress VRAM savings, world gameplay, retail recovery at the cap and the exact-range alias case reported above. I ran the two focused GPU tests locally. Another contributor ran the full GPU suite. Independent suite report AI use OpenAI Codex (GPT-6, exact serving variant unavailable here) ran the builds and trials, checked the smoke blocks against manifests, logs and private frame samples, and drafted this report. |
…ort PR xcl-dev#2357) Ported from upstream xcl-dev/xcl PR xcl-dev#2357 (af3ebe9). Bounds target-page pools by title_memory_mb and 75% of DXGI local VRAM budget (with XCL_TARGET_PAGES_MB override), preserves physical-page keying (page_key/phys) for GPU-owned targets, and keeps title_textures SrcIndex + pending_res fast path (b6aec7d).
…y fills up (port PR xcl-dev#2385) Ported from upstream xcl-dev/xcl PR xcl-dev#2385 (4c4c577). Skips top-mip tiles for new sampled textures when local VRAM usage >= 75% of DXGI budget (with XCL_TEXTURE_BUDGET=0 / XCL_TEXTURE_MAX overrides), clamps SRVs via ResourceMinLODClamp, accounts distinct skipped pages in XCL_ACTIVITY, and integrates skipped tiles with xcl-dev#2357's Target::is_complete / bind_tiles / min_fresh_for_target.
…ps (port PR xcl-dev#1835) Ported from upstream xcl-dev/xcl PR xcl-dev#1835 (5005620). Chosen over PR xcl-dev#1248 because xcl-dev#1835 covers all sub-64 KiB sampled textures (4-60 KiB vs <=4 KiB), isolates small-pool logic in vram_small.rs, preserves 64 KiB RT aliasing via has_live_page, handles concurrent pool creation races, and integrates cleanly with xcl-dev#2357, xcl-dev#2385, and b6aec7d.
|
Data point from a 4 GB card, in case it helps the review.
Setup: GTX 1650 (3935 MiB VRAM, driver 621.24), Ryzen 5 1600, 16 GB RAM, Windows 11 build 26300. Retail title, Series X mode.
The PR logged Not checked: why the PR runs stayed black (the conflict resolution in |
|
Follow-up on the GTX 1650 black framebuffer. I rebuilt the same local integration of The profile selector was visible in the first nonblack readback at 101.250 s (517,917 of 518,400 samples nonblack). The run produced 2 nonblack readbacks out of 10 and exited normally at the time limit. Peak target pages were 3379 MiB and peak local video memory was 5952 MiB. The log showed no partial-mapping warnings, allocation OOMs, or device removals. I left the selector on screen so the check covered the same input as the capped runs. At the automatic 2496 MiB cap, both earlier runs stayed black (0/28 and 0/29 nonblack readbacks), with warnings for consecutive placements at 0/60, 0/60 and 0/240 tiles. Disabling the cap restored the selector on this setup with the integration code held constant. The logs do not identify which unbacked resource affected the framebuffer. |
|
Windows / RTX 3090 test. Ryzen 9 5950X, 32 GiB RAM, NVIDIA 630.20, Windows 11 build 28120.3571. One run on local 9620331 and one on the same tree with the #2357 patch from af3ebe9 and XCL_TARGET_PAGES_MB=8192. Both used the same warm cache directory and a 3 GiB system commit-headroom guard. Between 46 and 74 seconds, PresentX fell from 29.8/s to 21.2/s, before the cap was reached. The target-page pool reached 9,920 MiB on baseline and stayed at or below 8,192 MiB with the patch. The guard fired at 164 s and 196 s respectively. XCL first crossed 20,000 MiB process commit at 126 s and 157 s, so the longer run does not establish a memory saving at matched progress. Coverage: One run per build. Candidate with the cap disabled and repeatability remain untested. AI use: OpenAI Codex (GPT-6, exact serving variant unavailable) prepared the local build, analyzed the logs, and drafted this report. |
|
I traced the three early zero-backed placements in a 120 s run at the automatic 2496 MiB cap on the GTX 1650, using the same local integration of
All three were single-sample, single-mip UAV-capable textures (flags 0x4), and the title made SRVs for each while they still had zero mapped tiles. The title presented two different resource identities, both 3840 × 2160 R8G8B8A8_UNORM (28), flags 0x5. Neither was tracked in the target-page pool. The actual source of the readback and copy to the swap chain likewise never matched any of the three zero-backed resources, and the traced title copy and resolve calls recorded no direct source for either presented plane. The trace covers placements, view creation, and direct copies and resolves. It does not establish which resources the shaders sampled or wrote. |
|
No open or merged PR makes the same change. Main has no target-page pool cap: no AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
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 explicitD3D12_TILE_RANGE_FLAG_NULLpartial tile mappings when capped or out of VRAM instead of destroying them and failingCreatePlacedResourceXwith0x8007000E.Part of #1833
Part of #646
Part of #333
Part of #1337
Part of #1773
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).alloc_budgeted_pool&RetireQueuepool accounting (RetiringBatch::pool_heaps,pending_pools,counted_pools,reserve_pending_pools,note_queued_pools,reap_completed,poll_retiring_pool_heaps,page_bytes): count both pending-handoff (before_executewhilePAGES.lock()is still held) and fence-retiring 64 MiB pool heaps separately from variable-sizedArenasheaps sharingRetireQueue(active + pending + retiring < max_pools), and poll/reap fence-completed retirements before refusing pool allocation at cap.TileShape::from_tiling,packed_and_standard_layout,TilePool::take_up_to,Pages::bind_tiles,Pages::rebind,backfill_incomplete_state,available_tiles, &map_levels: reuse 100% of already-resident shared pages at cap, partition per-sliceD3D12_PACKED_MIP_INFO(StartTileIndexInOverallResource+NumTilesForPackedMipsper array slice, plus single shared tails) into atomic packed groups kept whole (never partially mapped, returning any unusedfreshtiles toTilePool), prioritize coarsest standard mips round-robin across slices, resolvedesc.MipLevels == 0, and report unmapped lazy-level groups + minimum fresh tiles needed to advance.TileRange::Null,heap_ranges&Pages::map: explicitly bind unbacked (None) tile spans withD3D12_TILE_RANGE_FLAG_NULLon the first heap pass (preserving trailingNullspans) and emit apHeap = NoneD3D12_TILE_RANGE_FLAG_NULLmapping +pages.fenceSignalwhen0tiles are backed, ensuringvkd3d-protonemitsVK_NULL_HANDLEsparse binds instead of leaving newly created reserved tiles uninitialized on Linux/NVIDIA copy queues.crates/xcl/src/hle/d3d12x/title_textures.rs:Incomplete(Eager/Lazy),refresh_once,upload_all, &map_levels_with_texels: track active incomplete eager andXCL_TEXTURE_LEVEL_PAGES=1lazy-level textures so normalrefresh/upload_allretries missing tiles or pending level groups oncevram::available_tilesmeetsmin_tiles(without spinning while capped, and self-pruning onnote_gpu_write, shadowing,retire_overlapping, andforget), and clearLAST_CONTENTwhenever new tiles/levels map sosame_as_last_uploadnever swallows identical-byte retries.vram::testsandtitle_textures::tests(target_pages_budget_respects_env_title_memory_uma_and_adapter_vram,budgeted_bind_shares_pages_retains_cubemap_coarse_mips_and_recovers_after_free,retire_queue_pool_cap_counts_retiring_pools_ignores_arenas_and_polls_completion,reclaimed_pool_still_counts_before_retirement_is_queued,capped_pages_keep_over_budget_placements_alive,capped_eager_placed_texture_recovers_on_upload_after_capacity_frees,capped_lazy_level_texture_retries_same_bytes_after_capacity_frees, and extendedtile_ranges_per_heap).The diff adds 743 net non-test runtime lines (
602invram.rs,141intitle_textures.rs) alongside ~920 lines of pure-CPU and D3D12 GPU upload/readback/concurrency regression tests requested during review; the budget formula,FLAG_NULLsparse binding, atomic per-slice packed groups, pending + retiring pool-cap accounting, and active eager/lazy recovery stay in one commit because cappingPageswithout those invariants leaves incomplete or partially packed textures unrecoverable.Tested
af3ebe93cf6df094dc359439f02d377f3196484d(onorigin/main8b957bec) on Linuxx86_64withcargo check --offline --target x86_64-pc-windows-gnu --workspace --tests(0errors,0warnings invram.rsortitle_textures.rs; only8b957bec's 2 pre-existingfetch_updatedeprecation warnings), and ran the 14 pure-CPUvram::testsnatively viarustc --edition 2021 --test(14 passed; 0 failed: budget matrix,FLAG_NULLtile ranges, 6-face per-slice packed mips3, 7, 11, 15, 19, 23, 2-tile atomic packed group under 1-tile budget,SINGLE_MIPTAIL_BIT, partial/0-tile backfill, andRetireQueuepending + retiring pool-cap vsArenasaccounting).55ab6ba0(@thehollowedone, #2357 (comment)): NVIDIA GeForce RTX 3080 Ti (driver621.35), Ryzen 7 9800X3D, Windows 1126300,rustc 1.99.1MSVC, DXC1.8.2502.11—reclaimed_pool_still_counts_before_retirement_is_queued(1/1),capped_pages_keep_over_budget_placements_alive(1/1), andcargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4(1,439 passed,1pre-existing8b957becmesh-cache failure,47 ignored).889008fd:@Haxodius(#2357 (comment)): AMD Radeon RX 6700 XT 12 GB —1283 passed,1pre-existing fuzz seed,46 ignored, plus 60 s smoke pair below.889008fd: RTX 3080 10 GB world-load0/6->6/6surviving (@Berserker64), RTX 3060 12 GB-1.46 GBlocal VRAM (@jennydeth, plus298.9 satXCL_TARGET_PAGES_MB=4096vs4/4losses without#2357,@Anon64), RX 6600 XT 8 GB capped at5,056 MiB/ 79 pools (@SlopTart), RX 9070 XT 16 GB Linux/RADV 25 min crash-free (@DavidM1911).Regression run
main:
PR (v1
889008fd— rerun pending foraf3ebe93):Not tested
cargo test --workspace -- --test-threads=4, including the newcapped_eager_placed_texture_recovers_on_upload_after_capacity_freesandcapped_lazy_level_texture_retries_same_bytes_after_capacity_freesGPU readback tests) and a fresh 60 sscripts/smoke.ps1retail pair onaf3ebe93(authored on Linux without a Windows GPU host).vkd3d-protonon NVIDIA (lockhart/ 8 GB cap) onaf3ebe93to confirm explicitD3D12_TILE_RANGE_FLAG_NULLbinding +#2275multi-queue retirement resolve theXid 31copy-engine fault reported on889008fd+68a284a.Pagesallocations (sparse heaps, coherent window, PSOs) consume ~5 GB, the default 75% adapter cap (~8.3 GiB) prevents unbounded growth (#646) whileXCL_TARGET_PAGES_MB=4096(ortitle_memory_mb = 4096) boundsPagesmore tightly;XCL_TARGET_PAGES_MB=0restores uncapped behavior.AI use
vram.rsandtitle_textures.rsbudget,FLAG_NULLsparse init, per-slice atomic packed groups, pending + retiring pool-cap accounting, active eager + lazy-level recovery, unit/GPU tests, and adversarial review fixes.pending_poolslock-handoff catch and test contributed by@thehollowedoneusing Codex (GPT-6.2 Sol / Astra); Windows v1 GPU test and smoke runs reported by@Haxodiususing Claude Code (Claude Opus 5.5).