D3D12.X: back kept-in-step title textures by shared VRAM pages (#248) #288
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!288
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/288/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?
@iliassgm on GitHub · 2026-11-23 22:28 UTC · original
title-textures-vram-pages→main· +957 −112 · 3 files · 1 commits · merged 2026-11-23 23:48 UTCFixes #248
What is in it
vram.rs: addvram::place_pagesso non-GPU-owned textures placed viaCreatePlacedResourceXuse reserved (D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE) resources backed by the existing shared 64 KiBvram::Pagespool (falling back to committed resources when reserved creation is unsupported, e.g. 1D textures orXCL_VRAM_ARENAS).vram.rs: map every 64 KiB page boundaryPstrictly inside[va, va + console_bytes)(owned_pages, proven non-aliasing for disjoint ranges even at 4 KiB alignment) onto sharedpages, share remaining/sub-64 KiB tiles inextra_pageskeyed by(va, tile_index)so repeated placements at the same address never leak, wrap poolCreateHeapintitle_textures::own_work, and keyPAGESper device withqueue.GetDeviceinbefore_execute.vram.rs(unmap_superseded/remap_if_unmapped): when a placed texture is superseded by a placement with a different range ((ova, oend) != (va, end)) or a GPU-owned render target, unmap its tiles (D3D12_TILE_RANGE_FLAG_NULL) and return any unsharedextra_pages/ tail pages straight tocoolingso 4 KiB-packed< 64 KiBstreaming churn stays bounded without requiringRelease. Exact same-range aliases remain mapped and share every tile. If the newer overlapping placement is later released,remap_if_unmappedre-binds the uncovered texture cleanly.title_textures.rs&device_x.rs: wait for pendingUpdateTileMappingsviavram::before_execute(&queue)beforetexture::upload_batch(andprobe_gpu_content). Keep active (non-shadowed) entries in anO(log N)address-ordered index sorefresh_onceskips shadowed placements while still tracking transitions/states on shadowed entries and promoting uncovered older textures back to active onforget(fixing row 6 from @Kalmarv's comparison while keeping fast uploads and rows 1–5).owned_pagesdisjointness, shadowing/unmapping, and multi-layer reactivation (vram.rs,title_textures.rs), plus a hardware D3D12 GPU test covering 512 unreleased 1 MiB textures over a 16 MiB window (+16 MiBpages,+0 Bafter fill), exact same-range aliasing + release reactivation (rows 4 & 6), partial-overlap isolation + unmap/remap on release (row 5 & 6b), immediateextra_pagesreclamation for superseded 4 KiB-packed< 64 KiBtextures, and bit-exact GPU readback across RGBA8/BC7 mip chains (including packed mips), a 6-slice cubemap, and a 3D volume.Tested
32.0.16.2124), Intel Core i5-10400F, Windows 11;rustc 1.100.0 (0ef1bc386 2026-11-09), debug + release (cargo build --release -p xclclean).cargo test --workspace -- --test-threads=4: 654 passed, 0 failed, 40 ignored (SKIPPED GPU tests:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware— RTX 3060 is wave32;uploads_start_from_each_subresources_stateskips locally because Windows Graphics Tools / D3D12 debug layer is not installed).placed_title_textures_share_vram_and_preserve_pixels): 512 unreleased 1 MiB textures over 16 MiB stay at+16 MiBpages (+0 Bafter fill),+0 Blocal VRAM growth after fill (solo run),+16active kept; rows 4/5/6 + different-range unmap/remap + 4 KiB< 64 KiBextra_pagesreclamation all pass bit-exact; negative control withXCL_VRAM_ARENAS=1fails as expected.Regression run
Draft PR awaiting a
scripts/smoke.ps1run on a retail title (I do not have a retail game folder on this machine). If @gw1337x or another retail tester can runscripts/smoke.ps1onmainand this head commit (ad799324d6e6) withXCL_ACTIVITY=1, I will paste both blocks here and mark ready for review.main:
pending (no retail title locally)
PR:
pending (no retail title locally)
Not tested
scripts/smoke.ps1(no retail game files locally).AI use
@gw1337x on GitHub · 2026-11-23 22:52 UTC · original
@iliassgm tested on the retail streaming repro, as asked. AMD Radeon RX 7800 XT 16 GB (driver 32.0.32015.7029), 31.6 GB RAM, Windows 11, release builds.
Regression run (
scripts/smoke.ps1 -Seconds 60, no input – the title stays in its first menus, so this does not reach the streaming):Streaming run – this PR's head + #244 (without #244 the title crashes at 67 s on the lazy-page race), menus walked with
XCL_PRESS_A_AT=14,17,21,XCL_ACTIVITY=1. An external kill-switch stops a run when the process commit passes 34 GB or the system's free RAM drops under 2.5 GB (an unguarded run once took the whole PC down).No device removal, no crash. Stopped by the kill-switch at 129 s (33.7 GB commit, free RAM at 2.5 GB).
The same setup with other builds, for comparison:
main9ab7d76+ #244So the 0x887a0007 from #248 is gone with this PR and after ~80 s video memory grows ~0.06 GB/s (
main: ~0.3 GB/s until it was stopped). It still grows during world loading (pages 4.6 → 10.6 GB from 38 to 118 s), and what ends the run on this 32 GB machine is total commit rather than video memory.Not tested: a run without the kill-switch; the picture during world loading (it is a dark loading fade there); NVIDIA.
AI-assisted (Claude Code, Claude Opus 5.5).
@iliassgm on GitHub · 2026-11-23 23:08 UTC · original
Huge thanks @gw1337x and @grahamster2 for running both retail streaming tests (RX 7800 XT and RTX 3080 10 GB) — seeing VRAM drop from 19.8 GiB / OOM on
maindown to 11.5–11.9 GiB at 120 s (and commit down ~10 GiB vsmain/ #269) with zero0x8007000e/ device removals is awesome!Note that I pushed an updated head commit
ad799324d6e6right as your runs were posted (adding shadowed-entry reactivation for @Kalmarv's row 6 plusD3D12_TILE_RANGE_FLAG_NULLunmapping of superseded different-rangeextra_pages/ tail pages, which should pull the streaming VRAM curve down even further). If either of you gets a chance to rerunscripts/smoke.ps1onad799324d6e6, I'll paste the freshxcl-smokeblocks into the PR description and mark this ready for review!@gw1337x on GitHub · 2026-11-23 23:20 UTC · original
@iliassgm rerun on
ad79932, as asked. Same machine and setup as before (RX 7800 XT 16 GB, driver 32.0.32015.7029, 31.6 GB RAM, Windows 11, release build).Regression run (
scripts/smoke.ps1 -Seconds 60, no input, first menus only):(main's block for comparison is in my earlier comment:
0e946cf, 1553 frames, peak 15025 MB.)Streaming run, this head + #244,
XCL_PRESS_A_AT=14,17,21,XCL_ACTIVITY=1, one run each. The kill-switch now stops a run when free RAM drops under 2.5 GB, video memory passes 15.5 GB or commit passes 40 GB. "Other" is process commit minus local and non-local video memory, from the same activity line.876557c: commit / video / otherad79932: commit / video / otherNo device removal, no crash, no
0x8007000ein either. Video memory is a little lower with the new head (11.8 vs 12.7 GB at 98 s), but the commit that is not video memory grows faster: +6 GB at 98 s. That is one run each, and the game's loading may not progress identically between runs, so it may be noise – but it is the first thing I would look at if someone can reproduce it (whatever the shadowed-entry reactivation or the tail-page unmapping keep on the CPU side).Not tested: more than one run per head; the picture during world loading; NVIDIA.
AI-assisted (Claude Code, Claude Opus 5.5).
@gw1337x on GitHub · 2026-11-23 23:30 UTC · original
A small one I hit while testing, in case it helps: on this PR (
876557candad79932),cargo test --release -p xcl --lib -- title_textures gpu_sparse_vram_descriptors_buffers_and_xmemfails ingpu_sparse_vram_descriptors_buffers_and_xmem(submit 1 lane 0 mismatch, left 0, right 1077); the same filter passes onmain4017f8f, and the full lib suite passes on this PR (614 passed, default threads and--test-threads=4). So it looks like an order dependence between the new title-texture GPU tests and that test when they run close together. RX 7800 XT, release build. I have not looked into why.@ivall on GitHub · 2026-11-23 23:48 UTC · original
Merged (
2b4bb43), from the draft - of the three #248 PRs it kept video memory lowest in grahamster2's NVIDIA runs. Checked on an RX 9070 (RDNA4) on main2b4bb43together with #306, #288 and #294:cargo build --workspace && cargo test --workspace -- --test-threads=4- 630 unit tests passed, 0 failed; the retail game reaches its menus and starts loading the world (stopped at ~150 s by the machine's commit limit, not by the game). Two things done in the merge: #283 (merged before) gave each kept-in-step texture asrc(the CPU view behind a GPU view) andin_gpu_view; the entry now has both #283's and this PR's fields, uploads and the write-watch still readsrc, andrecheck_gpu_view_sourceswalksby_resandshadowed. Andplaced_title_textures_share_vram_and_preserve_pixelsno longer asserts the process's local video memory: under--test-threads=4other GPU tests in the process made it +672 MB on this machine (alone it passes); the page count stays asserted exactly.mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@grahamster2 on GitHub · 2026-11-23 23:03 UTC · original · edited 2026-11-24 00:18 UTC
Retail run of
876557con a 10 GB NVIDIA card: the retail title (Series 1.0.2.1), RTX 3080, driver 610.88, warm caches,XCL_PRESS_A_AT=30,40,50,60,70,80,95,110, 180 s, two runs. All four heads are compared in https://github.com/ivall/xcl/issues/248#issuecomment-7116498970.0x8007000e+0x35a47bc, 141 smain(two runs)+0x13936128 s /0x80000003+0x193e00f138 sNo device removal, and no new warning kinds compared with
main. Correctness wasn't checked: the loading frames are a dark fade, and I can't look at them.xcl-smoke, 60 s
Claude Code (Claude Opus 5.5) ran the tests and wrote this report. No game files attached.
@grahamster2 on GitHub · 2026-11-23 23:15 UTC · original · edited 2026-11-24 00:18 UTC
scripts/smoke.ps1reruns forad79932, with the unmodified script at each commit. Setup: the retail title (Series 1.0.2.1), RTX 3080 10 GB, driver 610.88, warm caches, release builds, 60 s, no input.The
gpu:line names this machine's iGPU because the script takes the first adapter Windows lists (fixed in #281). XCL itself ran on the RTX 3080 in both runs (D3D12.X: backend 'real' – NVIDIA GeForce RTX 3080in the log).main
4017f8f:this PR,
ad79932:Streaming numbers for
ad79932, from one run, guarded and short: local merge of4017f8f+ #244 + this PR (it merges cleanly),XCL_PRESS_A_AT=14,17,21, world streaming from ~48 s. The run was stopped by my RAM watchdog at 73 s (free RAM under 3 GB), not by the title. Process commit / local VRAM:4017f8f4017f8f+ #2444017f8f+ #244 +ad79932No crash, device removal or
0x8007000ein any of the three before the stop. The earlier 180 s runs of876557care in https://github.com/ivall/xcl/issues/248#issuecomment-7116498970.Claude Code (Claude Opus 5.5) ran the tests and wrote this report. No game files attached.