D3D12.X: XCL_SPARSE_LAZY=1 gives a committed sparse-window tile video memory at its first use #2897
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!2897
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2897/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?
@Prime1997 on GitHub · 2026-11-26 22:17 UTC · original
Prime1997:contrib/nv-sparse-lazy→nvidia-dev· +440 −12 · 2 files · 2 commits · merged 2026-11-26 22:58 UTCRequested by Prime · project thread
Stacked on #2895; only the top commit belongs here.
With
XCL_SPARSE_LAZY=1, a tile the title commits in a sparse window is listed with no pool tile and gets video memory when it is first used: the CPU's first bytes at an upload (a used pool tile is cleared right behind its mapping, before those bytes go up), a memory write recorded on a list (immediates, fills, copies, timestamps) before the list runs, or a buffer placed on it. Bytes that find no video memory are owed and go up whole once there is some. Off by default; left out on a device whose unmapped tiles do not read zeros (tiled resources tier under 2).Part of #2688 (workstream 4).
Why
On the Series S profile a retail title commits a page pool of 4.3 GB in a sparse window up front, 3,751 MB of it in tiles the CPU never writes, on an 8 GB card. In a 60 s run with no input (RTX 3060 Ti 8 GB, Series S profile) local video memory went from 7,503 MB to 3,022 MB with the switch, 542 frames against 376, 0 draws skipped either way.
What is in it
crates/xcl/src/hle/d3d12x/sparse.rs: theLAZYpool sentinel,lazy_commits/lazy_asked/ the tier check,ensure_listed(commit),materialize(first use),give_memoryandwill_write(recorded writes), thestarvedlist,runs_where;buffer_tilesleaves a tile with no memory out; copies back and zero runs pass a tile with no memory by.crates/xcl/src/hle/d3d12x/list_x.rs:note_write/note_immtellwill_write.sparse::tests(real GPU, skipped without tiled resources tier 2): a tile's first bytes reach the GPU and are still there two submits later; bytes that found no memory go up once there is some; a recorded write gives memory and a buffer never maps the sentinel; a decommitted tile frees and parks nothing, and with the switch off a commit maps at once.Tested
cargo test --locked --workspace --no-fail-fast -- --test-threads=4withXCL_DXC_DIRset to DXC 1.9.2609.5: 1820 passed, 9 failed, 48 ignored. The 9 failures are the same tests that fail onnvidia-deveae01502itself (1816passed,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)fails here 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 oneae01502, and fails the same way on the other open pull requests againstnvidia-dev(#2905, for one).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-deveae01502:This PR's head:
Not tested
AI use
Claude Code (Claude Fable 5.2 and 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
@saintwolf on GitHub · 2026-11-26 22:55 UTC · original
Tested and reviewed commit
d24b4250(stacked on#2895; merged cleanly ontonvidia-deveae01502alongside#2892–#2896, zero conflicts).Tested
32.0.16.2140), AMD Ryzen 7 7800X3D, Windows 11 build 26300,rustc 1.100.0, debug test buildcargo test -p xcl --lib hle::d3d12x::sparse::tests::a_lazy_tile -- --test-threads=1: 2 passed, 0 failed, 0 ignored, 0 skippedcargo test -p xcl --lib hle::d3d12x::sparse::tests:: -- --test-threads=1: 66 passed, 0 failed, 1 ignored (early_commit_timing), 0 skipped (includes all 4 new lazy-tile GPU tests)Review notes
XCL_SPARSE_LAZY=1) and properly gated on Tiled Resources Tier >= 2 (null_tiles_read_zero).s.mapped: theLAZY = (u32::MAX, u32::MAX)sentinel is properly filtered out indecommit_tiles,flush_pending,never_sent, readbacks, andmapped_rangeslogging; OOM starvation (s.starved+clear_sent_range) and GPU write promotion (list_x::will_write->State::give_memory) look solid.Not tested
XCL_SPARSE_LAZY=1AI use
@grahamster2 on GitHub · 2026-11-26 23:02 UTC · original
Test report from a 10 GB card: RTX 3080 10 GB, 31 GB RAM + 64 GB page file, Windows 11. Your #2893–#2897 are cherry-picked onto Austin's Build 16 (≈ nvidia-dev
eae01502) plus #2815–#2817 and a page-placement fix (#2905). Settings:XCL_UMA_WINDOWS=16,XCL_HEAP_WINDOWS=1,XCL_COHERENT_MB=1024, GPU heaps in the sparse windows,XCL_TWO_PASS_MB=1536. Same retail title.Series S profile,
XCL_SPARSE_LAZY=1: ran clean for 440 s, with 2 of 524k draws skipped.Series X profile,
XCL_SPARSE_LAZY=1:DEVICE_HUNGat 209.5 s, as the world loaded.64021c4c25c9f2d0(largest 115200 groups) and cs67657769b50d2f8b.Happy to run a variant if you want something specific.
@upipibi on GitHub · 2026-11-26 23:37 UTC · original
The sparse tests with
XCL_SPARSE_LAZY=1set, which saintwolf's report lists as not run: RTX 3070 (Ampere), driver 616.56, Windows 11, rustc 1.100.0, debug.nvidia-devateff3bcabf1b6f99223796ece166948003a53e0bc, compared with the pre-mergeeae015021c639866ab061cdff2e9daf8ba9daac5. Synthetic tests only.cargo test -p xcl --lib -- hle::d3d12x::sparse::tests:: --test-threads=1, 3 runs each oneff3bcab:XCL_SPARSE_LAZYunset: 66 passed, 0 failed, 1 ignored (early_commit_timing) in all 3 runs. The 4 new lazy-tile tests pass.XCL_SPARSE_LAZY=1set for the whole process: 62 passed, 4 failed, 1 ignored in all 3 runs. The 4 new lazy-tile tests still pass, but 4 older tests fail every time:a_copy_back_does_not_wait_for_the_title_queue(sparse.rs:5080, "the copy back did not land")a_tile_decommitted_and_committed_again_keeps_its_video_memory(:5733)flush_parked_does_not_free_or_reuse_tiles_while_unmap_is_in_flight(:6076)flush_parked_quarantines_tiles_until_title_queues_finish(:6121)eae01502the same=1command gives 62 passed, 0 failed, so the failures come with the lazy path.My guess is that these four assume a tile gets its video memory at commit, so they would need the lazy mode turned off for the test, like the
LAZY_COMMITS_FOR_TESTswitch. I haven't traced it, though. One of them could also be a real gap in the lazy path, such as a copy back from a tile that has had no write yet.Lib suite,
cargo test -p xcl --lib -- --test-threads=4,XCL_*unset:eff3bcab1695 passed, 3 failed, 28 ignored;eae015021689 passed, 3 failed, 28 ignored. The same 3 failures are on both trees:gpu_compute_thread_limits_leave_the_lanes_past_them_out(HLSL wave32 pipeline, 0x80070057), and twotexture_uploadtests with a multiply overflow at texture_upload.rs:1002. So #2892-#2897 add no failure here. No driver reset in any run.Not tested: retail title.
AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).
@upipibi on GitHub · 2026-11-26 23:44 UTC · original
Thanks for keeping this opt-in behind the tier check. Two questions and a test note, all by reading at
eff3bcab, not run. They may bear on grahamster2's Series X hang above, but that's only a guess.A recorded write that finds no memory is dropped.
give_memory(crates/xcl/src/hle/d3d12x/sparse.rs:1538-1545) ignores theleftcount frommaterialize. Whileshort_of_memory()holds (sparse.rs:3567) and no tile is at hand, or whentake_tilecannot make a heap, a fill, copy, timestamp or immediate recorded on a list (list_x.rs:772,:793) into aLAZYtile goes nowhere. Nothing retries it, the waystarvedretries CPU bytes. Copies back also skipLAZYtiles (sparse.rs2030 and 2120), so the CPU view never gets a fill or copy result either. Immediates are stored on the CPU byafter_execute, so the CPU sees those, but a later GPU read of the same address reads zeros. Should these asks be kept, likestarved, or should a recorded write take a tile withforcelike a placed buffer does?The asks are taken at record time.
will_writeruns while the list is recorded. A closed list that runs again on a later submit, or a range committed (listedLAZY) after the list was recorded but before it is submitted, gets nogive_memory. The list'ssparse_writesandsparse_immare still there at execute (list_x.rs:2436,readback_sparse_writes). Could the asks be taken from the lists in theExecuteCommandListshook instead?Test note. In
a_lazy_tile_gets_memory_at_its_first_bytes_and_keeps_them, the comment says a used pool tile is on hand so that its old bytes would show if it weren't cleared. But the test only setsno_memory = None. On a fresh state the firsttake_tilemakes a new heap and returnsused == false(sparse.rs:1259), so the inline clear of a reused tile inupload_dirtyis never exercised, and that part of the test can't fail. Freeing and reusing a tile first (decommit one tile and commit another) would cover it.AI-assisted (Claude Code, Claude Opus 5.5): read the code at
eff3bcaband wrote this; nothing was run for these points.