Repository navigation
D3D12.X: a texture level that lost its texels gives its pages back - #2927
Conversation
With XCL_TEXTURE_LEVEL_PAGES=1 a streamed texture's level gets video memory pages at the first upload with texels for it, and kept them for 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 (its GPU-view pages unmapped), and the texture is uploaded again with those levels all zeros: the pages stayed, holding zeros. In a retail title's world on an 8 GB card 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. Before such an upload a group of levels that has pages and is all zeros now gives them back (vram::unmap_levels: its tiles unmapped on the mapping queue, its pages released as a released texture's are, idle and then back to the pools when no other texture uses them). Tiles without memory read as zeros (tiled resources tier 2), as the zero texels the upload would have written; the level gets pages again with its next texels (map_levels). Test: the level-pages GPU test goes on: the title decommits mip 0 again, the next upload gives back mip 0's pages (86 -> 22 tiles with pages; 86 without this change), mip 0 reads zeros and the other levels keep their texels, the other texture on the same pages keeps them, and mip 0 gets them back with its texels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I checked 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 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. |
|
Independent Windows GPU check on 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. |
|
Follow-up to my bookkeeping review: on head 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. |
Review note on xcl-dev#2927: unmap_levels searched the texture's page keys and swap_removed one for each key given back, under PAGES: quadratic in the pages of a large level. remove_once_each counts the keys to drop and takes one occurrence of each in a single retain. Test: remove_once_each_takes_one_occurrence_for_each_naming (duplicates, keys not named, nothing to take); the level-pages GPU test still passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested — Wine/RTX4060 Laptop, exact production head
Linux6.17, Wine11.0, i7-13620H/16GiB RAM, RTX4060 Laptop8GiB/NVIDIA590.48.01, Rust1.98.1 Windows-MSVC target; Command (under the local guarded Wine Cargo wrapper): Evidence: 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. |
|
RTX 5080, Proton Experimental, Series X profile. I tested a local port through 0c83784 on 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). |
Requested 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(kernelx: physical page homes in window 0 first, from the top, keeping 64 MB free (#2867) #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