D3D12.X: route sparse physical-page heaps through the L0 budget #3742
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3742"
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 jeroenhaentjens on 2026-12-02T23:40:55Z.
What & Why
Stacked on #3740 at
2ff33838. Only the top commit belongs to #3742. With XCL_TEXTURE_BUDGET=1, buffer-only sparse physical-page heaps can spill to CUSTOM/L0 under local DXGI pressure. #3620 offers related routing through XCL_L0_VRAM_MARGIN_MB. This PR starts sparse spill at 80% of each adapter's local DXGI budget and shares #3740's physical RAM guard.What is in it
Tested
1ec8a97051. Intel Core i7-9750H, NVIDIA Quadro RTX 3000 (driver 597.06 / 32.0.15.9706), Windows 11 25H2 build 26200.9974, Rust MSVC 1.100.0 and DXC 1.9.2609.5.d3bb128c60, which has the identical source tree.Regression run
Baseline (main)
PR head
Not tested
AMD, Intel discrete GPUs, Linux and retail titles.
AI use
OpenAI Codex (GPT-6, specific revision unavailable) assisted with the implementation, tests and PR update.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T23:45:04Z.
Review of
b43a2e2f(code reading only, not a merge-check; draft) · 1 high, 2 medium, 2 nitsIn short: This PR sends new buffer-only sparse tile pools through the
XCL_TEXTURE_BUDGET=1admission from #3740. A pool tries local memory under the soft cap first, then CUSTOM/L0, then local memory up to the DXGI budget minus 8 MiB. The memory report also lists L0 sparse pools separately. It is stacked on #3740 and needs itstexture_budget.rs. The default path is unchanged. On the opt-in path, though, a sparse pool can now be refused where it used to be created, andXCL_BUDGET_L0_PHYS_HEAPS=0does not undo that.High
The budget now refuses sparse tile pools, even with
XCL_BUDGET_L0_PHYS_HEAPS=0.physical_page_heap_with_budget(texture_budget.rs~309) ends withsample.reserve(bytes, Admission::RequiredLocal)and returnsE_OUTOFMEMORYonce local usage plus outstanding reservations passes the budget minus 8 MiB.State::take_tile(sparse.rs~3565) always calledCreateHeap, and going over budget meant WDDM demotion. Nowtake_tilereturnsNone, andensure_mappedstops atelse { break }(~3892), leaving the title's committed pages with no video memory.XCL_L0_MIN_FREE_PHYS_MIB. The README says=0"keeps sparse backing local", but it also brings this new hard cap.Fix: when routing is off or L0 is refused, create the local heap as
maindoes, or document the cap and what happens to the tiles.sparse_heap_can_use_local_reserve_after_l0_admission_denialcurrently asserts the refusal.Medium
Admission::Pool(texture_budget.rs~288, limit ~31):XCL_TEXTURE_SOFT_CAP_MIB, ormin(4000 MiB, budget - 1150 MiB). On a 12 or 16 GB card, every new sparse pool goes to system memory once the process uses about 4 GB, with several GB of budget left. These pools back the title's memory windows, not only sampled textures, and the smoke runs were on a 6 GB card only. Fix: give sparse pools a threshold relative to the budget, or measure on a larger card and fix the README wording.State::take_tile: new sparse tile pools spill to CUSTOM/L0 under another opt-in (XCL_L0_VRAM_MARGIN_MB), which also handles retired L0 pools and heap priority. The two will conflict there and add two settings for the same job. One should be chosen, or the description should say how they relate.Nit
3940fe383. Its own commitb43a2e2f7is 193+/11-, under the target. Add "only the top commit belongs here" next toStacked on #3740.memory_bytes_forhas no test. The existing test (sparse.rs~9063) covers onlymemory_byte_counts. The per-heap split (~3155-3172) and thesparse L0 ...parts inmemory_report.rs~154 are not exercised.Checked and fine
XCL_TEXTURE_BUDGETunset,TextureBudget::samplereturnsNoneandphysical_page_heapcallsCreateHeapas before.memory_bytes_forreturns the same local values, with zero for L0.DENY_RT_DS_TEXTURES | DENY_NON_RT_DS_TEXTURESequalALLOW_ONLY_BUFFERS, so the eligibility check matches the real pool.E_INVALIDARG,E_OUTOFMEMORY,E_NOTIMPLandDXGI_ERROR_UNSUPPORTEDfall back to local memory; device removal and other errors are returned.memory_bytes_for, the subtractions cannot underflow: the L0 counts are subsets of the same pools, read under one lock. The memory report moves L0 pools fromVideotoNonLocal, so nothing is counted twice.RESERVATIONS, never the other way round.runner::skip_testwhen there is no device, no discrete adapter, no L0 buffer heap, or too little RAM.amd-devand only lowersPARKED_MAXinsparse.rs.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-12-03T07:53:06Z.
@Foniass rebased on #3740 at
1a2bef6. Sparse L0 routing now starts at 80% of the local DXGI budget. Disabled routing, denied admission and recoverable L0 failures can use the normal local CreateHeap path. The new accounting test checks active, free and retired bytes in both segments. The verified results are in the PR description, which identifies the top commit and the overlap with #3620.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T07:55:17Z.
Follow-up review of
f3e08c8f, sinceb43a2e2f(code reading only, not a merge-check) · 1 mediumIn short: Stacked on #3740 at
1a2bef6; only the top commitf3e08c8f(+238/-11) belongs here, as the description now says. Sinceb43a2e2f:The overlap with #3620 is now named but not resolved. Nothing else blocks it.
Medium
XCL_L0_VRAM_MARGIN_MBand overlaps the pool allocator. Both still changeState::take_tileand add two settings for the same job. One should be chosen, or one rebased on the other.Checked and fine
XCL_BUDGET_L0_PHYS_HEAPS=0),physical_page_heap_with_budgettakes no sample and callscreatewith the original descriptor. With routing on, a declinedRequiredLocalreservation no longer returnsE_OUTOFMEMORY: the heap is created locally, and the reservation is committed only when there was one. The test now checks both routes give the driver the original descriptor once the reserve is full.Admission::SparsePoolisbudget - budget / 5, capped at local, so a 12 or 16 GB card spills at 80 % of its budget, not at about 4 GB.pool_bytes_by_segmentis a pure function, andsparse_pool_bytes_split_active_free_and_retired_by_segmentchecks active, free and retired bytes for both segments.E_INVALIDARG,E_OUTOFMEMORY,E_NOTIMPLandDXGI_ERROR_UNSUPPORTEDfrom the L0 heap fall back to local memory; other errors are returned.XCL_TEXTURE_BUDGETunset, the default path is unchanged.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T13:29:19Z.
Follow-up review of
d3bb128c, sincef3e08c8f(code reading only, not a merge-check) · 2 mediumIn short: This push only rebases the top commit onto #3740's new head
2ff33838. The code ind3bb128cis the same as inf3e08c8f; only the README context around it changed. The overlap with #3620 is still open, and Tested now reports only two test modules, not the whole suite.Medium
State::take_tileand add two settings for the same job: an L0 spill for sparse pools. Choose one, or rebase one on the other.cargo test -p xcl --libforhle::d3d12x::sparse::testsandhle::d3d12x::memory_report::tests(146 passed, 0 failed, 1 ignored). CONTRIBUTING.md asks forcargo test --workspace -- --test-threads=4on a GPU, with the counts and the SKIPPED tests, on the head under review.Checked and fine
allocate_poolintexture_budget.rsto fall back tocreate(false)when admission declines. That does not touchphysical_page_heap_with_budgetor the sparse-pool admission this commit adds, and the commit applies on it unchanged.E_OUTOFMEMORY.main078358a0and of the headd3bb128c, with the same settings.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-12-03T14:56:07Z.
@Foniass The Tested section now includes the full workspace result. The commit and PR description explain the relationship to #3620, including the TextureBudget opt-in, the 80% adapter-relative threshold and the shared physical RAM guard. The amendment changes the commit message and preserves the tested source tree.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T14:57:22Z.
Follow-up review of
1ec8a970, sinced3bb128c(code reading only, not a merge-check) · 2 mediumIn short: The code in this push is unchanged: only the top commit's message changed, and it now says how this PR differs from #3620. Tested now gives the whole suite on this head, which fixes one earlier point. But the regression run changed. The two runs on a title with the opt-in on were replaced by runs of the repository's test fixture, which presents one frame and does not reach this code. The overlap with #3620 is still open.
Medium
d3bb128cthe description had two 60 s smoke runs of title0ba91dcbwithXCL_TEXTURE_BUDGET=1,XCL_BUDGET_L0_PHYS_HEAPS=1. Now both blocks are ofxcl-owned-test-fixture, which shows 1 frame (presents per 2 s: 0 0 0), with no setting given. The new sparse-pool routing is behindXCL_TEXTURE_BUDGET, so these runs never reach it. CONTRIBUTING.md asks for the regression run on a real title. Put back a pair of runs on a title, made onmainand on1ec8a970, ideally one with the opt-in on, since that is the only path this PR changes.XCL_TEXTURE_BUDGETopt-in and 80 % of the DXGI budget, while #3620 usesXCL_L0_VRAM_MARGIN_MB. Both are still open, changeState::take_tile, and add an L0 spill for sparse pools. One should be chosen, or one rebased on the other.Checked and fine
cargo test --workspace -- --test-threads=4on1ec8a970: 3017 passed, 0 failed, 52 ignored, 26 SKIPPED.d3bb128cagainst1ec8a970has no code change, only the commit message. The earlier checks of the routing, the fallback and the 80 % threshold still hold.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
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.