D3D12.X: bound target-page pools by title and adapter VRAM budgets #2357
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2357
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2357"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@safesearch77 on GitHub · 2026-11-25 16:29 UTC · original
safesearch77:fix/vram-target-pages-budget→main· +500 −33 · 1 files · 1 commits · openBound
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).@Haxodius on GitHub · 2026-11-25 17:14 UTC · original
Windows / AMD RDNA2, 12 GB card + 16 GB RAM: exact head
889008f, suite + smoke pair + a cap-on / cap-off title A/B. No regression; on this machine host RAM runs out long before the target-page cap is reached, so the cap never engaged.Tested
889008fd342ac779a601d7f93c8a54430360b306and its basemain65fc114a140d9043f8e3d70ffb863f7987816d8f, each in a clean worktree.cargo test --workspace --no-fail-fast -- --test-threads=4(debug) on889008f: 1283 passed, 1 failed, 46 ignored.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 540:res[833] = 0x7, CPU 0x6). It fails the same way on the base65fc114, so it is not this PR.--no-fail-fast,hle::d3d12x::list_x::tests::a_reset_while_the_last_submit_runs_records_on_another_pc_listalso failed once; alone it passed 3 / 3 on the head. Reads as the parallel flake of #1978.f16/f32cases oflower_dxil::tests(refused:V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32),pso_measurement_compiles_an_exact_synthetic_record(Developer Mode off),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).vram::testsall pass on this card, includingbudgeted_bind_shares_pages_retains_cubemap_coarse_mips_and_survives_cap,capped_pages_keep_over_budget_placements_aliveandtarget_pages_budget_respects_env_title_memory_uma_and_adapter_vram.anaconda, 13 824 MiB):pool budget 8576 MiB, 134 pools from 75% of DXGI local budget.Regression run
scripts/smoke.ps1, 60 s, default settings, same binaries. The first base run was on a cold shader cache (870 frames); this is the warm pair, base run again after it:main:
PR:
Title A/B on the head, cap on (default) vs
XCL_TARGET_PAGES_MB=0XCL_NETWORK=0 XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PSO_PRELOAD=0 XCL_DXC_THREADS=4 XCL_SPLIT_MIDLIST_WAIT=0 XCL_TEXTURE_LEVEL_PAGES=1 XCL_ACTIVITY=1,XCL_PRESS_AT=16:A,XCL_PRESS_A_AT=20,24,…,80,90,100. A local watchdog stops the title when free physical RAM stays under 500 MB for 3 s (16 GB host).memory:line)level pagesat ~60 sNot tested
AI use
@pane33 on GitHub · 2026-11-25 17:22 UTC · original
I tested
889008fd342ac779a601d7f93c8a54430360b306on Windows 11 with a native RTX 4060 (tiled resources Tier 4). The VRAM filter returned 21 passed, 0 failed, 1 ignored and no skips, including two local test-only probes. The probes used one- and two-heap caps.remap_if_unmappedreturnedtruefor the partial and empty resources, which remained at 2/4 and 0/4. Explicitly unmapping the empty resource let it remap to 4/4 and read back a fresh upload in full. The target startsmapped = trueatvram.rs:1338and remap returns early at:1398. Is incomplete eager backing expected to persist until explicit unmap or replacement?vram.rs:967the cap checks the active count. Is the intended bound active heap capacity, or should it also cover heaps held for retirement?No retail run. AI use — Codex added the two local test probes, ran the tests, analyzed the results, and assisted in drafting this report.
@ozimchuk on GitHub · 2026-11-25 17:57 UTC · original
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
694cc67); release build forx86_64-pc-windows-gnu.mainalone: this PR's889008fmerged without conflicts into my working tree (main68a284a+ other open PRs + local changes); the same tree without it as the comparison.XCL_DEVICE_TYPE=lockhart: title memory budget 8 192 MB, so the cap here is 8 192 MB),XCL_PSO_WAIT_MS=50, 300 s each, the same data folder, runs alternated (with, without, without, with).D3D12 device removed: 0x887a0005Run 4's kernel line:
NVRM: Xid (PCI:0000:01:00): 31, … MMU Fault: ENGINE CE7 HUBCLIENT_CE1 faulted @ 0x2_8fcec000. Fault is of type FAULT_PTE ACCESS_TYPE_VIRT_READ– a copy-engine read of an unmapped page. That fits tiles this PR leavesNULLat the cap being read by a copy; on this driver path a NULL tile does not seem to read as zero. It is one fault in two runs, so not proven.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.
@raylitebull on GitHub · 2026-11-25 18:28 UTC · original
Diff review on
889008f(crates/xcl/src/hle/d3d12x/vram.rs): clean budget computation (compute_max_pools) and unit coverage (bind_tiles,capped_pages_keep_over_budget_placements_alive).Remaining before merge:
origin/main(currentlyDIRTY).@pane33's questions (mapped = truepreventingremap_if_unmappedon partially backed eager resources, and whether active-only vs retiring heap counts should bound the cap) and check@ozimchuk's Wine/NVIDIA CEXid 31fault report on NULL tiles under the cap.@DavidM1911 on GitHub · 2026-11-25 18:37 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@jennydeth on GitHub · 2026-11-25 19:00 UTC · original
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
0x8007000E, no crash, no device removal. Neither arm reaches the world in 600 s: both stop presenting during the load and spend the rest of the run compiling pipelines, as onmainin #846. The lower peak commit (31.7 vs 34.8 GB) is not evidence for the cap: see below. One run per arm.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
889008fagainst its base65fc114, both as they are. Default settings (noXCL_TARGET_PAGES_MB),XCL_NETWORK=0,XCL_FRAME_DUMP=300,scripts/smoke.ps1 -Seconds 600(frommain, the same script for both), profile already past the first-run flow, A presses on the schedule from my #846 comment. Base first, then head, back to back; driver-blob cache warm from earlier runs.Head's startup line:
textures in title memory: tiled resources on 64 KiB pages of video memory, one per page of the title's (pool budget 8448 MiB, 132 pools from 75% of DXGI local budget)– so the DXGI local budget here is ~11.3 GB.Regression run
Base
65fc114:Head
889008f:Head 108 % of base frames, 91 % of its peak commit.
65fc114889008ftarget-page pool cap reached0x8007000E/ out of memoryAS slot – refused/would close a GPU cycle/wanted at oncerequest failedwarnings)reclaimedlines in either log). Target pages fill the free tiles inside them up to 8 404 MB by 104.7 s and stay there; the base goes on to 9 644 MB in 9 984 MB of pools. Local video memory ends 1.46 GB lower (12.5 vs 14.0 GB), matching the 1.5 GB fewer pools, but that is still ~1.2 GB over the ~11.3 GB DXGI local budget the cap is computed from: ~4.1 GB of local video memory outside the pool heaps keeps it oversubscribed.vram.rs, a bind past the cap gets whatever free tiles remain – for mipmapped textures the coarsest mips of each slice first – and the rest stayNULL(reads zero, writes dropped). In the default mode they are not retried for that placement; onlyXCL_TEXTURE_LEVEL_PAGES=1retries level groups. The warning counts bind calls that came up short (new placements and re-binds of superseded textures) and logs at #1–4 and powers of two: it reached #8192 at 100.2 s and never #16384, so 8 192–16 383 such calls in the run; after 100.2 s the log can't say whether they continued. Whether that changes the picture I can't tell: neither arm shows the world.NULLtiles to a stall.Tested
Not tested
XCL_TARGET_PAGES_MBoverrides;XCL_TEXTURE_LEVEL_PAGES=1; the branch rebased onto currentmain; AMD.AI use
@SlopTart on GitHub · 2026-11-25 19:06 UTC · original
Tested: current PR head merged onto current
origin/main(clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).suite: 145/3 = the three known baseline failures on this lane (
fuzz_validate_and_gpu_2seed 1003,gpu_nonfused_mad_and_mac_prevent_fma_contraction,gpu_depth_buffer_created_for_unordered_access_is_placed). Targeted run of the four new tile-budget tests: 4 passed.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.
@Berserker64 on GitHub · 2026-11-25 21:57 UTC · original
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
65fc114+ #684. Head:889008f+ #684. #684 (e56dbc3) applied cleanly to both, so this PR is the only difference.xcl run,XCL_RUN_SECONDS=100 XCL_ACTIVITY=1 XCL_DRED=1 XCL_FRAME_DUMP=200 XCL_PRESS_A_AT=21,62,66,70,75,90,105,120,140,180,240. Base and head alternate run by run.Results
0x887a0007, 1 ×0x887a0006One longer run of head + #684 with no
XCL_RUN_SECONDS(stopped at 900 s): no removal and no crash in 15 minutes, local video memory steady at 10.8 GB. It presented for the first 78 s (loading art) and then waited on cold NVIDIA compute-pipeline compiles for the rest of the run (100 of 103 finished, up to 280 s each), so it did not reach the world.Without #684, head got past the removal but every run (7 of 7) then crashed at 74–80 s in
VCRUNTIME140.dll+0x122b3(memcpyfromgame_scarlett_master.exe+0x979f5b, a write into title memory), the crash in #646. The two base runs that weren't removed first crashed the same way. So on this card the two PRs go together.Why the removal is out of memory
The
0x887a0007removals on this card are the kernel refusing a submission: D3D12Core'sNDXGI::CDevice::RemoveDeviceis entered fromSubmitCommandCB(called fromlist_x::execute_with_waits_on), withD3DKMTGetDeviceStatereportingD3DKMT_DEVICEEXECUTION_ERROR_OUTOFMEMORY(5). D3D12Core reports state 5 as0x887a0007and writes no DRED data for it, which is why DRED was always empty. A read-only Frida probe saw state 5 in all 6 removals it caught, on an older tree (c4d37beplus open PRs); no runtime configuration change removed the device. There's no TDR event in the System log at these removals.Not tested
cargo test; other cards; AMD.AI use: Claude Code (Claude Opus 5.5) made the builds, ran the runs and the probe on the hardware above, and wrote this.
@bmjask on GitHub · 2026-11-25 20:23 UTC · original · reviewed
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.
@Anon64 on GitHub · 2026-11-26 08:53 UTC · original
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
889008fmerged locally ontonvidia-devaf2cecc4, not ontomain. One conflict invram.rs: I keptnvidia-dev's comment onpoolsand the PR'smax_pools/oom_until, and left out the PR'sretire_fence, whichnvidia-devno longer has. So this is not the exact head. All runs:XCL_ADAPTER=3060 XCL_GFX_PSO_WAIT_MS=200 XCL_PREPARE=0 XCL_ACTIVITY=1, compute pipelines warmed first, one run each, same title and start.Video memory from the 2 s
memory:line (MB):over the budgetwarningsnvidia-devaf2cecc4pool budget 8448 MiB, 132 pools from 75% of DXGI local budgetXCL_TARGET_PAGES_MB=4096pool budget 4096 MiB, 64 pools from XCL_TARGET_PAGES_MBCreatePlacedResourceXkept succeeding (no0x8007000E, no device removal in any of the three).nvidia-devc044dc6before it) the same world load lost the device (0x887a0005) in 4 of 4 runs at 120–254 s with 14–17 GB local against a 10.9 GB budget (#2688).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
XCL_TARGET_PAGES_MB=4096run stopped at 106 s on a compute pipeline the warm-up had missed. After warming it, a second 4096 run went on to 298.9 s, the longest of any run on this card, and played the cutscene. Its submits stopped at 270 s, while graphics pipelines for a part of the world no run had reached were waiting 24–109 s each at the compile gate.What the cap costs and what it does not cover, from that 298.9 s run:
NULLand read as 0, so part of that is this PR's cap; the rest is graphics pipelines not built yet (81,530 queued,XCL_GFX_PSO_WAIT_MS=200). I have not separated the two.Not tested: the PR's exact head or
main; how the textures look withNULLtiles at the cap (no screenshots taken); more than one run per row;XCL_TEXTURE_LEVEL_PAGES=1; the suite on this merge.AI use: Claude Code (Claude Opus 5.5) merged the branch locally, ran the runs on this machine and wrote this report.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.