Video-memory arenas: D32S8 and MSAA targets get heaps of their own size, let go when unused #225
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!225
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/225/head"
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?
@Kalmarv on GitHub · 2026-11-23 21:22 UTC · original
Kalmarv:fix/d32s8-exact-heaps→main· +256 −140 · 1 files · 1 commits · merged 2026-11-23 21:29 UTCThis addresses an open item in HANDOFF.md ("Retail game bring-up"): "arenas for D32S8 targets still take 2.8 GB (one per 256 MB of addresses; a D32S8 → R32 + separate stencil split, or exact-size heaps, would cut it)". It takes the exact-size heaps.
What changes (
crates/xcl/src/hle/d3d12x/vram.rsonly)Arena size. Arenas are what GPU-owned textures fall back to when the driver won't make them reserved, which on this RTX 5070 Ti is D32S8 / R32G8X24 (0x80070057) and MSAA. An arena used to be at least 256 MiB, on a 256 MiB boundary. Now it is a heap of its placement's own size, aligned to 64 KiB, or 4 MiB for MSAA.
No unions.
So a placement that straddles arenas no longer makes a growing union arena while the old ones live on. That was the pattern behind the "15 GB of arenas in 2 s".
Release. Arenas count their resources (
vram::forget, whichres_releasealready calls). An arena no resource has used for 2 s leaves the list and its heap goes, like the 2 s return of target pages (IDLE). Placed again within 2 s, the same memory is reused, with what it holds.Unchanged:
CopyResource, clears and DSVs;arena_bytes()forXCL_ACTIVITY.The arena bookkeeping (
Arenas<H>) is separate from D3D12, so the CPU tests drive it with fake heaps.Why not the D32S8 → R32 + separate stencil split: D3D12 has no stencil-only depth format, and a DSV binds depth and stencil of one resource. A separate stencil resource can't be stencil-tested, and plane-1 views, copies, clears and pipeline formats would all need rewriting.
Tested
Windows 11, RTX 5070 Ti, NVIDIA 610.74, MSVC debug. Branch
327c24con mainaf20b4b. Controls on main0cd0a53, whosevram.rsis the same asaf20b4b's.CPU tests (
cargo test -p xcl --lib hle::d3d12x::vram::tests, 4/4 pass):an_arena_is_shared_at_its_addresses_and_otherwise_its_placements_size: an arena takes 70 MiB, not 256. The same address or a smaller placement inside shares it. A straddling placement, and an MSAA one needing 4 MiB, get their own.an_arena_no_resource_uses_goes_after_two_seconds: an arena placed again within 2 s is reused; after 2 s it is gone.streamed_targets_stay_bounded: the title's pattern from HANDOFF. Each round places 8 back-to-back 64 MiB targets over 3.5 GB, every other round at the last round's addresses or a third of a target further on, so the targets straddle. A target lives 1.5 s, and 400 rounds are run, 0.5 s apart.tile_ranges_per_heap: unchanged.The same streaming scenario, with main's
plan()and an arena replaced while its resources live keeping its memory, was run as a control (not in this PR):GPU test
d32s8_targets_take_their_own_size_of_video_memory(skips on WARP):QueryVideoMemoryInfo)The same test also covers:
CopyResourceto a second, and reading both planes back byCopyTextureRegion: 0.25 and 0x5A;GPU runs went through our GPU queue, one test at a time (
cargo test -p xcl --lib -- --exact hle::d3d12x::vram::tests::d32s8_targets_take_their_own_size_of_video_memory): 1 passed on327c24c, 2.3 s.cargo build -p xcl --lib --tests: no new warnings. Diff: 1 file, +256 / −140.Not tested
vramtests were run.Overlap: no open PR changes
vram.rs. The last change to arenas on main is38b05b7(target pages).AI use: Claude Code, Claude Opus 5.5.
🤖 Generated with Claude Code
@ivall on GitHub · 2026-11-23 21:31 UTC · original
Merged (main
0f34407). Checked on an RX 9070 (RDNA4):cargo build --workspace && cargo test --workspace -- --test-threads=4- 611 unit tests passed, 0 failed; the retail game still reaches its first menu at 30 fps. With it the arenas in the menu went from 3 072 MB to 311 MB and the process's commit from 18.7 GB to 15.2 GB - thanks!