D3D12.X: title textures on shared 64 KiB pages of video memory – video memory stays at what the title covers (#248) #269
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!269
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/269/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?
@TG0000 on GitHub · 2026-11-23 22:13 UTC · original
TG0000:fix/title-textures-shared-pages→main· +395 −102 · 3 files · 1 commits · closed without mergingFixes #248.
What changes
A texture the CPU fills (kept in step with title memory,
title_textures) placed at a 64 KiB-aligned address is now a reserved resource on 64 KiB pages of video memory, one per page of the title's address. Every such texture placed there shares those pages, which is what #248 suggests: the model render targets have used since38b05b7. Before, each placement got its own committed PC texture that was never let go, so a streaming title's video memory held the sum of every texture it ever placed.vram.rs: the page bookkeeping (pages, own tiles, idle/cool reuse) moves into a plainBookstruct that tests can drive without D3D12. Pages come in two spaces,Space::TargetsandSpace::Textures. Kept-in-step textures share only with each other: their uploads are the CPU's view of the memory and would overwrite what the GPU rendered into a target at the same address. Newplace_title_texture. Render targets behave as before.title_textures.rs:registeris split into alayoutcheck andregister. Uploads run in placement order, oldest first, so on shared pages the newest texture's texels are what the memory holds, as on the console. The upload queue waits on the page-mapping fence before copying.device_x.rs:CreatePlacedResourceXtries the pages first. A texture that cannot be reserved (unaligned address, 3D on tiled-resources tier 2, a driver refusal) is committed as before.XCL_TITLE_TEXTURE_PAGES=0turns this off.Tested
Windows 11, Ryzen 9 5900X, AMD Radeon RX 6800 (RDNA2, gfx1030), Rust stable
x86_64-pc-windows-gnu(llvm-mingw linker).cargo build --workspace --tests: no new warnings. The only warning is the existingfetch_updatedeprecation inxgameruntime/mod.rs, which #251 fixes.textures_share_pages_with_textures_not_with_targetsstreamed_textures_cost_the_memory_they_cover: 8000 placements, more than 30× a 256 MiB span, stay within the span.released_pages_are_kept_then_cooled_before_reusetitle_textures_at_one_address_share_video_memory, passes on the RX 6800:vram/title_texturestests pass, including the D32S8 arena GPU test.cargo test --workspace --exclude testgame-mw: 614 of 615 lib tests pass, and all other targets pass except e2e. The two failures don't touch this code and come from the GNU toolchain used here:pe::tests::parses_own_test_binary_tls: a GNU-built test binary has no PE TLS directory.e2e::test_title_runs_and_game_folder_is_untouched:testgame_mw.dll/xcl_testtitle.exearen't built on this toolchain.Regression run
Windows 11, Ryzen 9 5900X, AMD Radeon RX 6800, Rust stable
x86_64-pc-windows-msvc(VS 2022 Build Tools, link.exe),cargo build --release -p xcl,scripts/smoke.ps1 -Seconds 45, one run at a time under a RAM watchdog.main (
63b9930, this PR's merge base):PR (head commit, no local changes):
No regression: 847 frames against 779 on its base, no device removals (no 0x887a0007), no crashes, peak commit 15266 MB against 15255 MB; peak dedicated VRAM sampled during the run was about 6.5 GB. This branch conflicts with current
mainind3d12x/device_x.rs,title_textures.rsandvram.rsand needs a rebase before merging. Currentmain(2b4bb43) on the same title, for reference: 709 frames in 45 s, 0 device removals, 0 crashes, peak commit 15183 MB.AI-assisted (Claude Code).
🤖 Generated with Claude Code
github-bot referenced this pull request2026-11-26 04:18:59 +00:00
@gw1337x on GitHub · 2026-11-23 22:19 UTC · original
Retail regression run, as asked: GTA VI, RX 7800 XT 16 GB, 31.6 GB RAM,
main9ab7d76+ #244 (without it the title crashes at 67 s on the lazy-page race) + this PR at8111cf9. Menus walked withXCL_PRESS_A_AT=14,17,21; every run was stopped by an external kill-switch (process commit over the limit, or the system's free RAM under 2.5 GB), because a run without one took the whole PC down.No device removal and no crash with this PR – the 0x887a0007 from #248 did not come back. Video memory still grows past the card, though, through the textures that do not get pages:
Kept-in-step bytes and covered memory are from a local counter on the
XCL_ACTIVITYline: the sum of the kept textures' console sizes, and the union of their address ranges.The gap with #269 is the unaligned textures. In this title only about a quarter of the kept-in-step placements are 64 KiB-aligned (~10 000 of ~42 500 in the first ~110 s). The rest are packed at 4 KiB, stay committed, and the older ones under newer placements stay alive (11 releases in 90 s). The local variant adds two things on top of the aligned pages:
D3D12_TILE_RANGE_FLAG_NULL, on the pages queue, then the fence) and gives them back: 41 213 textures superseded and 19.3 GB of tiles given back by 128 s.That variant has costs and risks of its own: each unaligned texture takes at least one 64 KiB tile (9.7 GB of pages for 6.0 GB of textures), and a superseded texture reads zeros, which would show if the title still samples one. I have not checked the picture during world loading. Its remaining limit here is different: at ~126 s the title builds ~90 compute pipelines at once (+3.3 GB of video memory in 2 s), on top of its own growing memory.
Details and the earlier numbers are in #248. I can share the variant's diff (about 130 lines on top of an earlier version of the aligned part) if it is useful for this PR.
@TG0000 on GitHub · 2026-11-23 22:42 UTC · original
Huge thanks @gw1337x for running the retail regression test on the RX 7800 XT! Really glad to hear the
0x887a0007device-removal crash is gone and the 64 KiB-aligned path held up cleanly.The 4 KiB-aligned packing measurement (~3/4 of placements, 41,213 superseded textures / 19.3 GB of tiles reclaimed!) is a massive insight. Yes, please share your diff (or post it in #248) — we can either fold it cleanly into this PR (behind a guard/unit+GPU test) or land the aligned-pages foundation here first and follow up immediately with the unaligned + superseded-unmap layer, whichever is cleaner for @ivall to review!
@likecrank-dotcom on GitHub · 2026-11-23 22:46 UTC · original
Independent native Windows/MSVC + NVIDIA run on #269 at
8111cf945fb38f53a4856edfb63bcba46b524b29(clean checkout).Tested
x86_64-pc-windows-msvc, MSVC 19.44, Windows SDK 10.0.26100.0, DXC 1.9.2602.17; debug builds.cargo build --workspace: exit 0 (only the existingfetch_updatedeprecation warning).cargo test --workspace -- --test-threads=4 --nocapture: exit 0; 655 passed, 0 failed, 40 ignored, across 17 result blocks. Library: 615 passed, 0 failed, 20 ignored.title_textures_at_one_address_share_video_memorypassed on the hardware adapter, without skipping: uploading through one placed texture and reading back through the other produced 0 differing rows. Its 256 RGBA8 512x512 placements at 8 addresses used 8,388,608 tracked tile-page bytes. The DXGI local-memory delta printed by this run was 0 bytes; I do not interpret that instantaneous value as total VRAM usage.textures_share_pages_with_textures_not_with_targets,streamed_textures_cost_the_memory_they_cover(8,000 placements), andreleased_pages_are_kept_then_cooled_before_reusepassed.pe::tests::parses_own_test_binary_tlsandtest_title_runs_and_game_folder_is_untouchedpassed on this MSVC host.SKIPPED / Not tested
Four explicit skips:
gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64);test_title_draws_with_a_root_signature_under_the_debug_layer(no d3d12SDKLayers.dll);uploads_start_from_each_subresources_state(no D3D12 debug layer, 0x887A002D). No XCL_SAMPLE variables were set; sample tests returning early are not retail coverage. No retail title/smoke run, no AMD/Wine run, and no conclusion about unaligned streaming placements or the title's remaining memory growth.AI use
Codex ran the builds/tests and summarized their actual logs. Exact deployed model identifier is not exposed in this session. No production-code changes or game data published.
@emirduran707 on GitHub · 2026-11-23 22:48 UTC · original
Retail run on RDNA4, for comparison with the RX 7800 XT numbers above: the same title as #248,
main9ab7d76+ #244 (77905f6), with and without this PR (8111cf9). Merged locally, release builds.Hardware: AMD Radeon RX 9060 XT 16 GB (driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, rustc 1.100.0 MSVC, DXC 1.9.2602.17.
Run:
xcl run <folder>withXCL_NETWORK=0,XCL_ACTIVITY=1,XCL_FRAME_DUMP=60,XCL_RUN_SECONDS=300; menus walked by hand with a controller (so the timings differ by a few seconds between runs). A kill-switch stopped each run when the xcl processes' private bytes went over 28 GB.Process commit / local video memory from the
XCL_ACTIVITYmemory line:With this PR, video memory grows about 25 % slower while the world streams in, but still grows at ~2.4 GB per 10 s, so the result matches the RX 7800 XT run: the 64 KiB-aligned placements are no longer the whole story.
No device removal or crash in either run before the kill-switch. The log's only "not reserved" lines are 4 render targets (
0x80070057, at start-up), as expected.During the load the window title showed
compiling shaders: 0 running, 0 done, 58747 pipelines queued.Earlier, on
mainalone with no kill-switch, the same load ended at 159 s with two threads faulting at once (one at<title>+0x13936, the instruction #244 describes) at 33.6 GB commit / 17.8 GB local video memory.A third run,
main+ #244 with the limit raised to 35 GB, was stopped by the free-RAM guard (under 2 GB) at 110 s / 31.1 GB, below the 32.8 GB wheremainfaulted, so it says nothing about #244 either way.Not tested: whether #244 gets past that fault (this 32 GB machine cannot reach it safely); #288 and #292; the picture during the load (the loading screen's band is drawn black).
Test runs and this comment: Claude Code (Claude Opus 5.5), from my runs.
@mariuslozo-boop on GitHub · 2026-11-23 22:54 UTC · original
NVIDIA result: this PR removes the out-of-memory failures here, but video memory keeps growing past the card's size. The title's own watchdog then ends the run.
Setup: RTX 5070 Ti (16 GB), driver 616.92, Ryzen 7 7700X, 32 GB RAM, Windows 11 Pro 26300. Release build of main
0e946cf+ #244 (77905f6) + this PR (8111cf9), merged locally without conflicts. Retail title 1.0.2.1.XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_RUN_SECONDS=300 xcl.exe run <game folder>, no input. One run.9ab7d76+ #244 (earlier run)CreatePlacedResourceX … (0x8007000e)0x80000003,+0xf7d415)+0x23cf683, write to 0)The
memory:lines with this PR:activity (2 s)lines mostly show 0–4 presents, with short bursts at ~194–196 s (18, 16), ~208–210 s (10, 21) and ~224 s (11). There are none from 228 s; the last one is at 226 s, about 29 s before the abort.+0x23cf683is a deliberate write to address 0 in the title's watchdog callback. It fires after about 30 s without a frame. In an earlier crash dump of the same abort (main + #244 + #283), the render thread was waiting insideCreateCommittedResource.Not tested: #288 / #292; AMD; more than one run. I could not combine this PR with #283: they conflict in
title_textures.rs.AI-assisted: Claude Code (Claude Opus 5.5 ran the build and the run and wrote this report; Claude Fable 5.2 decoded the abort). No game files attached.
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@ivall on GitHub · 2026-11-23 23:48 UTC · original
Closing as superseded by #288 (merged in
2b4bb43), which takes the same approach (kept-in-step textures on shared video-memory pages) and kept video memory lower in the retail comparison on #248. Thanks for the work and theBooksplit - if something here is still missing on main after #288, a small PR on top of it is welcome.@grahamster2 on GitHub · 2026-11-23 23:03 UTC · original · edited 2026-11-24 00:18 UTC
Retail run of
8111cf9on 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+0x61bbd6, 120 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.
Pull request closed