D3D12.X: a placed sparse buffer can wait for its tiles until first use #2788
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2798"
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?
Imported from ivall/xcl. Originally posted by MacieGx on 2026-11-26T13:50:32Z.
A placed sparse buffer can now be made without video memory and get its tiles when a list is about to use one of its addresses. This is preparation with no change in behaviour: nothing places a buffer lazily yet. The next PR uses it for the GPU-only buffers that the newer retail title places outside the memory windows; today those get an empty V#, so their light, ray and tile lists read as empty. Part of #505.
Why lazily: the title places 128 or more such buffers (about 580 MB) at start. In a lab tree that gave all of them video memory at once, the runs ran out of RAM before the world. Placed lazily, 108 buffers / 526 MB were in use 25 s into the world (573 of 578 MB by 365 s in a longer run).
#2539 (open) also changes
sparse::place_buffer; whichever lands second rebases. #637 (open) mirrors views of buffers outside UMA from their CPU pages, which these GPU-only buffers do not have.What is in it
crates/xcl/src/hle/d3d12x/sparse.rs:place_buffer_when(.., lazy), withplace_buffer=place_buffer_when(.., false)as before;use_range(va, len)maps the waiting buffers in that range, and checks two atomics before it takes the state's lock;State::back_buffer(the tile mappingplace_bufferdid inline),take_lazy,lazy_bounds;forget_indrops a buffer released before its first use;Tested
cargo test -p xcl --lib -- hle::d3d12x::sparse --test-threads=4: 19 passed, 0 failed, 1 ignored (the two new tests among them), no SKIPPED lines.stable-x86_64-pc-windows-msvc, release.cargo build --release --workspace && cargo test --release --workspace --no-fail-fast -- --test-threads=4on1b11d3d: 1433 passed, 4 failed, 47 ignored. The 4 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3(CreateComputePipelineState: out of memory (0x8007000E)), which fail onmainas well. SKIPPED (the same as onmain): 21 "no wave64", 3 refused by the per-lane form,heap_window_out_of_memory_falls_back_to_the_switch_form,pso_measurement_compiles_an_exact_synthetic_record.Regression run
main:
this PR:
Not tested
AI use
main's sparse state, wrote the tests and this description; Claude Opus 5.5 (coordinating) ran the full suite and the regression runs and reviewed the diff.🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-26T14:25:44Z.
AMD run for the Not tested line.
Tested: pass, head
1b11d3dapplied onmainb49be18, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X.cargo test -p xcl --lib -- hle::d3d12x::sparse --test-threads=4 --nocapture:a_lazy_buffer_gets_its_tiles_at_its_first_useanduse_range_outside_the_lazy_buffers_does_not_wait_for_the_stateok.The sparse tests make their device with
D3D12CreateDevice(None, ..), so they take the first adapter (the RX 9070 XT here) andXCL_ADAPTERdoesn't move them. A run withXCL_ADAPTER=3060gives the same counts but is not an NVIDIA result.Not tested: the lazy path in a title; Intel.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T14:46:29Z.
Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2798 at
1b11d3d54f2380d9a680192a8214246b97fc6ee8(exact parentorigin/mainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7). Measurements and targeted test results only; not a full source review.Setup
7956 MiBreported by D3D12), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200rustc 1.100.0 (0ef1bc386 2026-11-09), DXC1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)title: 29640639viascripts/smoke.ps1 -Seconds 60(XCL_NETWORK=0 XCL_ACTIVITY=1, default flags, no input)Targeted RTX 4060 release unit tests (
1b11d3d5)cargo test --release -p xcl --lib use_range_outside_the_lazy_buffers_does_not_wait_for_the_state -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, exit0).cargo test --release -p xcl --lib a_lazy_buffer_gets_its_tiles_at_its_first_use -- --nocapture: 1 passed, 0 failed, 0 ignored (0.23 s, ran live on RTX 4060,0skipped, exit0).cargo test --release -p xcl --lib hle::d3d12x::sparse:: -- --test-threads=4: 19 passed, 0 failed, 1 ignored (0.38 s,early_commit_timingignored,0skipped, exit0).Observations
use_range_outside_the_lazy_buffers_does_not_wait_for_the_stateand live RTX 4060a_lazy_buffer_gets_its_tiles_at_its_first_use) plus all 19hle::d3d12x::sparse::tests passed cleanly in--releaseon exact head1b11d3d5with0skips.exit: 0x0,1558frames shown,60 60 60steady-state presents per 2 s,0device removals,0crashes,14019 MBpeak commit,6176 MBpeak /6115 MBend local VRAM vs parentb49be183's14018 MB/1518frames — matching baseline as expected before PR #2799 wires callers toplace_buffer_when).Paired 60 s RTX 4060 smoke (
b49be183vs1b11d3d5)Parent
origin/main(b49be183):PR #2798 head (
1b11d3d5):Limits of coverage
1b11d3d5(only targetedhle::d3d12x::sparse::release tests plus paired quiet 60 s smoke).place_buffer_when/use_range) without changing live retail callers yet; end-to-end retail VRAM reduction is verified on the stacked PR #2799 (321ada6a).RTX 4060) on native Windows 11; no AMD, Intel, or Wine/Linux run on this host.AI use
Ran the targeted release unit tests and paired quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts and smoke blocks were taken directly from
cargo testandscripts/smoke.ps1outputs.Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-30T05:59:23Z.
This conflicts with
mainnow. Together with #2799 it brought the characters' bodies back on the retail title for us (RTX 3090), in a targeted form; details, and our port rebased onto currentmain, in https://github.com/xcl-dev/xcl/pull/2799 (latest comments). I can post a test report once it is rebased.AI use: found and written with Claude Code (Claude Opus 5.5), checked and posted by me.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:58:58Z.
Triage (#1607) – head
1b11d3d#2799 and #2801 are stacked on this PR, not duplicates. Main's
XCL_SPARSE_LAZY(#2897) delays video memory for committed window tiles; it does not delay placed buffers, which is whatplace_buffer_when(.., lazy)/use_rangehere do. Main'ssparse.rshas since been restructured (place_buffer_in,PLACEMENTlock), so this conflicts. Two points to check insparse.rs:use_rangedid not catch hits an unmapped tile, which is undefined.use_rangeAddRefs a raw resource pointer fromState::lazy. A last Release on another thread whileSTATEis held only queuesforget_buffer, so the pointer may already be freed.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.