Repository navigation
D3D12.X: title textures on shared 64 KiB pages of video memory – video memory stays at what the title covers (#248) - #269
Conversation
…memory (ivall#248) A texture the CPU fills (kept in step with title memory) 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, shared by every such texture placed there - as on the console, where a texture placed over another overwrites its memory. A committed PC texture per placement, never let go, held the sum of every texture a streaming title ever placed (12.7 GB over 4.0 GB of its memory at 90 s, then 0x887a0007). - vram: page bookkeeping in a plain Book (unit-tested); textures and GPU-owned targets in separate spaces, so a texture's CPU-view upload never overwrites what the GPU rendered into a target at the same address. - title_textures: uploads oldest placement first (the newest texture's texels win on shared pages); the upload queue waits for tile mappings. - device_x: pages first, committed as before when a texture cannot be reserved (unaligned address, 3D on tier 2, driver refusal). XCL_TITLE_TEXTURE_PAGES=0 turns it off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Retail regression run, as asked: GTA VI, RX 7800 XT 16 GB, 31.6 GB RAM, 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 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:
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. |
…vall#248) Stacked on ivall#269 (which moves 64 KiB-aligned kept-in-step title textures onto shared 64 KiB pages in vram::Book). What remains after ivall#269: - Overwritten placements stayed registered in title_textures forever, continuing to be scanned/uploaded and holding extra tiles / leftover pages in vram::Book even when a newer texture replaced their memory. - real::resource_at (device ivall#70/ivall#71 by-address SRV/UAV creation) stored every created ID3D12Resource in MADE forever and never released superseded entries (including unaligned committed textures). - Device / queue release did not clear MADE, title_textures state, upload queues, or vram::Pages::waited. - XCL_ACTIVITY memory lines lacked title-texture active/covered/retired/ released counters. This commit adds O(log N + k) overlap retirement in title_textures, detaches retired entries from vram::Book, cools and releases superseded entries in real::resource_at (2 s cooling + MADE_MAX cap), cleans up on device/queue release, and logs title-texture counters on XCL_ACTIVITY. Assisted-by: Antigravity CLI (Gemini 4 Neon)
|
Huge thanks @gw1337x for running the retail regression test on the RX 7800 XT! Really glad to hear the 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! |
|
Independent native Windows/MSVC + NVIDIA run on #269 at Tested
SKIPPED / Not tested AI use |
|
Retail run on RDNA4, for comparison with the RX 7800 XT numbers above: the same title as #248, 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: Process commit / local video memory from the
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. |
|
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
The
Not tested: #288 / #292; AMD; more than one run. I could not combine this PR with #283: they conflict in 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. |
|
Retail run of
No device removal, and no new warning kinds compared with xcl-smoke, 60 sClaude Code (Claude Opus 5.5) ran the tests and wrote this report. No game files attached. |
Handle 16-byte constant-buffer records, upload intro textures from their CPU view, and decode BC1 BCPack streams. Share bounded texture pages, batch upload staging, and tolerate pages decommitted during streaming reads. Includes work from ivall/xcl ivall#208, ivall#244, ivall#252, ivall#254, ivall#269 and ivall#283. DirectStorage late destination pages are already in the base. Assisted-by: OpenAI Codex (gpt-6.2-sol)
Fixes #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 since 38b05b7. 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 XGameRuntime: try_update instead of the deprecated fetch_update #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.XCL_ACTIVITYagainstmain, would confirm the 0x887a0007 is gone.AI-assisted (Claude Code).
🤖 Generated with Claude Code