D3D12.X: a texture level that lost its texels gives its pages back #2927
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!2927
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2927"
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?
@Prime1997 on GitHub · 2026-11-27 00:24 UTC · original
Prime1997:contrib/nv-level-pages-given-back→nvidia-dev· +134 −5 · 2 files · 2 commits · merged 2026-11-27 04:20 UTCRequested by Prime · project thread
With
XCL_TEXTURE_LEVEL_PAGES=1a streamed texture's level gets video memory pages at the first upload with texels for it, and kept them as long as the texture lived. A streaming title takes the memory from under the large levels of textures it no longer shows at that size, and the texture is uploaded again with those levels all zeros: the pages stayed, holding zeros. Before such an upload, a group of levels that has pages and is all zeros now gives them back (unmapped on the mapping queue, released as a released texture's pages are). Tiles without memory read as zeros (tiled resources tier 2), as the zeros the upload would have written; the level gets pages again with its next texels.Part of #2688.
Why
In a retail title's world (RTX 3060 Ti 8 GB, Series S profile,
XCL_TEXTURE_LEVEL_PAGES=1; a local branch ofnvidia-devwith #1182 and #2921 merged in, 420 s runs with the title driven to its world) the target pages grew from 2.7 GB to 4.2 GB in four minutes with 0 MB idle, more than the title's whole texture pool (63,632 pages, 3.98 GB), and video memory reached 10.2 GB on a 7.1 GB budget. With this change, in a run of the same length with the same settings, levels gave their pages back 16,384 times and the target pages stood at 3,549 MB at the end against 4,189 MB (at 391 s: 3,577 MB against 4,196 MB), while the run got further into the world (134,493 draws with translated pipelines against 17,816). Video memory as a whole was still over the budget there (10.4 GB): the sparse windows and the GPU views hold the rest.What is in it
crates/xcl/src/hle/d3d12x/vram.rs:unmap_levels(the groups of levels inzerothat have pages: their tiles unmapped withPages::unmap_range, their page keys out of the texture's,release_tiles),Pages::unmap_range(unmapfor a range of tiles from a subresource on), a line at powers of two,mapped_level_tilesfor the test.crates/xcl/src/hle/d3d12x/title_textures.rs:map_levels_with_texelscallsunmap_levelsfor the levels that are all zeros before mapping those with texels.remove_once_each, with a unit test) instead of a search per key under the pages lock.title_textures::tests::a_placed_texture_gets_the_pages_of_a_level_with_its_texelsgoes on: the title decommits mip 0 again, the next upload gives back mip 0's pages (86 -> 22 tiles with pages; still 86 without this change), mip 0 reads zeros while the other levels keep their texels, the other texture on the same pages keeps them, and mip 0 gets them back with its texels.Tested
cargo test --locked --workspace --no-fail-fast -- --test-threads=4withXCL_DXC_DIRset to DXC 1.9.2609.5: 1823 passed, 9 failed, 48 ignored. The 9 failures are the same tests that fail onnvidia-deveff3bcabitself (1822passed,9failed,48ignored there, same command):async_compute_pso_registers_real_pso_and_not_standin,console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly,gpu::recomp::tests::gpu_compute_thread_limits_leave_the_lanes_past_them_out,hle::d3d12x::texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays,hle::d3d12x::texture_upload::tests::pieces_hold_the_texels_of_their_levels,split_compute_prefers_the_offline_whole_pipeline,two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs.Build and test (Windows, no GPU)has failed on other pull requests againstnvidia-dev(#2905, for one) onhle::d3d12x::sparse::tests::a_gpu_write_into_a_gpu_view_lands_in_its_cpu_view(the WARP device is removed, 0x887a0005). That test passes on the card above, on this branch and oneff3bcab.Regression run
A commit of
main(b49be183, the last one before the shader preparation screen of #2555, which prepares every record before the title and so does not fit a 60 s run):The base of this PR,
nvidia-deveff3bcab:This PR's head:
Not tested
XCL_TEXTURE_LEVEL_PAGESunset (the default): nothing changes, as no texture has lazy levels.AI use
Claude Code (Claude Opus 5.5) wrote the code, ran the suite and the regression runs on the hardware above, and wrote this description; Prime asked for it and owns the account. We coordinate the 8 GB work on the XCL Discord too: https://discord.gg/gK3y7WRRY
🤖 Generated with Claude Code
@andrewDoing on GitHub · 2026-11-27 01:03 UTC · original
I checked
unmap_levelsbookkeeping at headdb0780c3. Each removed page searches andswap_removes fromt.usedwhile the shared pages lock is held. In an optimized synthetic comparison with 16,384 removals from 21,845 entries, that loop made 104,397,938 comparisons (30.96 ms); a local count-based singleretainpass took 1.01 ms. These are CPU-only measurements of this bookkeeping loop, not a GTA VI frame-time measurement.The local candidate counts removals by key and consumes one count per retained-vector occurrence, rather than filtering by set membership. An exhaustive test of 14,641 ordered input pairs confirmed identical surviving multisets, including duplicates. Survivors become stable-ordered; the original
swap_removealready made their order unstable. The existing native texture test for mip release, zero readback, other-mip preservation and reacquisition also passed (1/1, no reported skips). I have not run a full suite or retail test for this candidate.AI use: OpenAI Codex with GPT-6.2 Astra investigated, wrote the synthetic comparisons and local candidate, and ran the tests; Codex coordinated and prepared this report.
@ettehn on GitHub · 2026-11-27 01:18 UTC · original
Independent Windows GPU check on
db0780c3c96ba5f7bc0bfd1d08ce5f9c40492b82: the stocka_placed_texture_gets_the_pages_of_a_level_with_its_texelstest passed (1/1, no skips) on the RTX 5070 Ti Laptop test host (621.24, Windows 11 26200.9974, Rust 1.97.1 MSVC, debug).I also extended the fixture locally to cover the packed mip group rather than only mip 0. The adapter put levels 4–10 in one tile. Feeding the mapping helper one zero mip and six nonzero ones retained the tile. Feeding it seven zero mips removed exactly one mapping: all seven levels read back as zeros, mip 0 stayed intact, and the other texture sharing those pages still read the original bytes. Feeding the original texels back remapped the tile and restored the original GPU readbacks. This test-only variant passed 3/3 in fresh processes, with no skip. It covers mapping and readback of a packed group, not a title run or frame-time measurement. OpenAI Codex (6.2sol) assisted with verification.
@andrewDoing on GitHub · 2026-11-27 02:01 UTC · original
Follow-up to my bookkeeping review: on head
db0780c3c96ba5f7bc0bfd1d08ce5f9c40492b82plus a test-only overlay, an RTX 5070 test wrote a known pixel to mip 0 on the GPU, decommitted that guest mip, and called the production mapping function. Mip 0 read back as zero; all ten lower mips retained their expected data, and an alias retaining the physical pages still contained the GPU-written pixel. Remapping restored the pixel. The texture's mapped count went 86 → 22 → 86 tiles.The single test passed without reported skips. It invokes the mapping function directly and does not test production scheduling, total physical VRAM savings or GTA VI.
AI use: OpenAI Codex with GPT-6.2 Astra wrote and ran the fixture; Codex coordinated and prepared this report.
@pickles976 on GitHub · 2026-11-27 02:54 UTC · original
Tested — Wine/RTX4060 Laptop, exact production head
0c8378463f04ae17b4070f1fe96e528ef57adcdb, with local test-only fail-closed guards (require NVIDIA hardware, D3D12, tiled support and an actual lazy-level texture) and mapped-tile prints. No production edits.a_placed_texture_gets_the_pages_of_a_level_with_its_texelsandremove_once_each_takes_one_occurrence_for_each_naming: 2 passed /0 failed /0 ignored,1.28s. Fresh intended-worktree compilation34.04s; total guarded command36.43s. Actual GPU readback confirms mip0 zero after decommit/unmap, all ten lower mips preserved, another texture retaining the same pages preserved, and reacquisition restores original mip0 data. Mapped count 86→22→86. This is64 tiles unmapped from one resource, not4MiB proven physical VRAM returned: the other texture still holds those pages. The CPU fixture checks multiplicity-preserving key removal.Linux6.17, Wine11.0, i7-13620H/16GiB RAM, RTX4060 Laptop8GiB/NVIDIA590.48.01, Rust1.98.1 Windows-MSVC target;
DXVK_CONFIG='dxgi.hideNvidiaGpu = False'. Diagnostic-relaxed vkd3d-proton2576c0b4adfae4a+, not stock Wine certification. No silent adapter skip or WARP fallback. Unchanged9GiB/512MiB scope and global2048MiB available-RAM/6000MiB GPU/10GiB disk cutoffs; sampled GPUpeak282MiB, minimum availableRAM9721MiB.Command (under the local guarded Wine Cargo wrapper):
Evidence:
.compat-runtime/logs/verify-pr2927-level-retirement-20261127T025231Z/(console, provenance, command/environment, resources and result JSON).Not tested: matched parent on this machine, packed-tail or GPU-written-mip extension, outstanding cross-queue GPU work during retirement, full suite, title/world loading, FPS or aggregate RAM/VRAM saving. The reclaim/reacquire portion directly calls the production mapping helper; this does not certify end-to-end upload scheduling or fix our separate Game-Init stalled-fence blocker. A useful additional lifetime gate would keep an old GPU use pending while requesting retirement/reuse, then check both readback and fence ordering without skipping required work.
AI-assisted verification and report: omp/OpenAI GPT-6 Astra. No assets or imagery published.
@Alm0stSurely on GitHub · 2026-11-27 05:06 UTC · original
RTX 5080, Proton Experimental, Series X profile. I tested a local port through
0c837846on the same #2057-based integration as my control, with the same placement settings and 1,208 starting cache files.The GPU fixture held 86 tiles on the parent. With the port it went from 86 to 22 and back to 86. Readback confirmed zeroes on the released mip and preserved data in the other mips and in a separately held alias.
In the game, the first return happened at 73.3 s, with at least 256 return operations by 298.5 s. At 16,384 cumulative level allocations, the control had 962 MiB mapped and the port had 940 MiB. At 90 s both runs still held 4,544 MiB in backing pools.
The last identifiable screen was the “AI and Gameplay Technology Direction” credit at 425.4 s, followed by black. The 32 GiB test scope hit its 4 GiB headroom guard at 454.3 s with 10,514 MiB of VRAM still free. The control reached the later “Platform Services” credit at 486.5 s. Kernel memory charges differed between runs, so I can confirm that the return path is active here, but cannot attribute the timing difference to this change. No open world was visible in either run.
Test preparation and analysis assisted by OpenAI Codex (gpt-6.2-astra).