D3D12.X: add an opt-in two-tier texture budget #3682
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3682"
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-02T08:54:10Z.
What & Why
On a discrete adapter, sampled backing can consume local memory that render targets, depth buffers and UAVs require. Overlapping aliases need GPU-ordered moves and reserved backing must outlive both GPU use and tile updates. L0 growth also uses physical system memory and needs its own admission check.
What is in it
XCL_TEXTURE_BUDGET=1. Admit eligible sampled texture backing toCUSTOM/L0and retain local headroom for required resources up to the DXGI budget minus 8 MiB.XCL_TEXTURE_SOFT_CAP_MIB,XCL_BUDGET_L0_PHYS_HEAPS,XCL_BUDGET_L0_TILEPOOLSandXCL_BUDGET_L0_COMMITTED. Report memory by allocation owner.XCL_LATE_RELEASE=0when the texture budget is active.GlobalMemoryStatusExbefore admitting new L0 backing. Allow growth only if the request and in-flight L0 reservations leave at least 3,072 MiB of available physical RAM. Override the floor withXCL_L0_MIN_FREE_PHYS_MIB. Count refusals inl0_phys_ram_guard_denials.local_tilepool_fallback_heaps.Tested
0877fa974041d32ba4f8f52250c149698ce1dbc9rebased onorigin/mainat817eb1fc9fb0763008ae5d8de1f7f586f442b51d. The rebase preserves the upstream mapping Signal retry and reserved-spare logic.git diff --checkandgit diff --check origin/main...HEADpassed.cargo check --locked -p xcl --testspassed on all nine commits. The reserved-spare compatibility changes were folded intofd938727.autoadapter selection, withXCL_ADAPTERstill available to select a specific adapter.cargo test --locked -p xcl --lib -- --test-threads=1 --nocapture --skip hle::d3d12x::vram::tests::reserved_resource_with_private_data_is_excluded_from_recycle hle::d3d12x::vram::tests hle::d3d12x::vram_promotion hle::d3d12x::late_release::tests· 106 passed, 0 failed, 1 existing ignored timing test, 0SKIPPEDnotices.cargo test --locked -p xcl --lib -- --test-threads=1 --nocapture --exact hle::d3d12x::vram::tests::reserved_resource_with_private_data_is_excluded_from_recycle· 1 passed, 0 failed, 0 ignored, 0SKIPPEDnotices. The fixture passed in its own process on retry after exit code 2173.cargo test --locked -p xcl --lib -- --test-threads=1 --nocapture hle::d3d12x::memory_report gpu::uma· 26 passed, 0 failed, 0 ignored, 0SKIPPEDnotices.XCL_ADAPTER=nvidiaandXCL_D3D12_DEBUG=1. The new regression uploaded a mapped texture on the Quadro, recycled it while a second device's queue stayed failed, and checked that a same-device dependency was held until its recovery fence completed. It reported 0 D3D12 Debug Layer messages, as did the other instrumented probes in their checked categories.XCL_ADAPTERunset selected the Quadro automatically and passed all six updated fixtures with zero Debug Layer diagnostics in the checked categories.0877fa974041d32ba4f8f52250c149698ce1dbc9.cargo build --locked --releasecompleted in 4m 03s with 39 compiler warnings. One retail start on the Quadro RTX 3000 with the existing DXIL cache,XCL_ADAPTER=nvidia,XCL_DEVICE_TYPE=lockhart,XCL_TEXTURE_BUDGET=1,XCL_L0_MIN_FREE_PHYS_MIB=3072,XCL_GFX_PSO_WAIT_MS=8000, andXCL_CS_PSO_WAIT_MS=35000.0x80000003around +145 s. The launcher exited 303.4 s after start, 264.2 s after the first input attempt and about 153 s after loading began. No 3D world was observed and the log reported no DXGI device removal.l0_phys_ram_guard_denialsrecorded three denials (192 MiB across the retries). Two committed allocations used the required local reserve (2.25 MiB). DirectStorage activity samples recorded 50,966 requests and zero failures.TileSegments::NonLocalabove its 4,000 MiB soft limit, which excludes the local-reserve retry inreserve_texture_backing. OpenAI Codex (GPT-6, specific revision unavailable) ran and reported this verification.b647ecab63afb4616d7908f005e818ecf1ed3701passedgit diff --checkandcargo build --locked --release(3m 01s, 39 warnings).XCL_ADAPTER=nvidiaandXCL_D3D12_DEBUG=1.cargo test --locked -p xcl --lib hle::d3d12x::vram::tests -- --test-threads=1 --nocapture --skip hle::d3d12x::vram::tests::reserved_resource_with_private_data_is_excluded_from_recyclereported 97 passed, including 10SKIPPEDnotices, 0 failed and 1 ignored. The same selection with--releasereported the same counts. The new fallback regression passed on the hardware in both profiles with 0 Debug Layer messages. The isolated private-data fixture exited with2173on both the archived0877fa97build and the new build.XCL_TEXTURE_BUDGET=1,XCL_L0_MIN_FREE_PHYS_MIB=3072,XCL_GFX_PSO_WAIT_MS=8000, andXCL_CS_PSO_WAIT_MS=35000. It entered the loading phase. A texture placement ran out of memory after its retries near +117 s from estimated loading start and was followed by breakpoint0x80000003. The launcher exited at +125.1 s from estimated loading start and 166.4 s total, before the +145 s capture. No 3D world or DXGI device removal was observed.local_tilepool_fallback_heapsrecorded 9 new local heaps (576 MiB). At the final denied 64 MiB request, DXGI reported 5,176.8 MiB in use against a 5,187.0 MiB local budget, leaving about 2.2 MiB under the budget minus 8 MiB ceiling. Peak sampled DXGI was 5,176 MiB local and 7,266 MiB non-local. Minimum sampled available physical RAM was 2,831.4 MiB.l0_phys_ram_guard_denialsrecorded 312 denied 64 MiB attempts including retries. DirectStorage activity samples recorded 52,867 requests and 0 failures. OpenAI Codex (GPT-6, specific revision unavailable) implemented and ran this verification.b647ecab63afb4616d7908f005e818ecf1ed3701release binary on the Quadro RTX 3000 with the existing DXIL cache. It used Lockhart,XCL_TEXTURE_BUDGET=1,XCL_TEXTURE_SOFT_CAP_MIB=3400,XCL_L0_MIN_FREE_PHYS_MIB=2304,XCL_GFX_PSO_WAIT_MS=8000, andXCL_CS_PSO_WAIT_MS=35000. Closing 19 Chrome processes and waiting five seconds raised available physical RAM from 16.77 to 20.21 GiB. The Codex host remained running. Minimum sampled available physical RAM was 1,590.9 MiB.0x80000003. The last failed request had 38.8 MiB available under the local DXGI budget minus 8 MiB ceiling. The launcher exited at 240.6 s total and +199.2 s from estimated loading start, ahead of the +250 s capture. No 3D world or DXGI device removal was observed.local_tilepool_fallback_heapsrecorded 12 heaps (768 MiB) andl0_phys_ram_guard_denialsrecorded 3,539 denied attempts including retries. DirectStorage activity samples recorded 77,990 requests and 0 failures. C: had a sampled minimum of 4.89 GiB free and 5.53 GiB free after verified archival. OpenAI Codex (GPT-6, specific revision unavailable) ran and reported this verification.b647ecab63afb4616d7908f005e818ecf1ed3701release binary on the Quadro RTX 3000 with the existing DXIL cache. It used Lockhart,XCL_TEXTURE_BUDGET=1,XCL_TEXTURE_SOFT_CAP_MIB=3000,XCL_L0_MIN_FREE_PHYS_MIB=1024,XCL_GFX_PSO_WAIT_MS=8000, andXCL_CS_PSO_WAIT_MS=35000. Closing 13 Chrome processes and waiting five seconds raised available physical RAM from 17.98 to 19.60 GiB.local_tilepool_fallback_heapsrecorded zero new heaps andl0_phys_ram_guard_denialsrecorded 62 denied attempts including retries. DirectStorage activity samples recorded 75,646 requests and 0 failures. C: had a sampled minimum of 5.52 GiB free and 5.86 GiB after verified archival. OpenAI Codex (GPT-6, specific revision unavailable) ran and reported this verification.Regression run
The paired
mainand exact-head smoke runs remain pending.Not tested
Full workspace suite, AMD, Linux, paired smoke runs, transition into the 3D world and sustained workload behavior remain unverified on
b647ecab. On the earlier combined integration head9f9bc9b8f, Run 16 faulted indxgmms2.sysduring VidMm eviction (0x7E). Run 17 faulted in the Windows compressed-memory store (0x154,0xC0000005inStDmpSinglePageLookup) with around 474 MiB of available physical RAM. The dump showed 9.51 GiB of system commit headroom and 15.95 GiB free in the disk pagefile. The synthetic regression verifies the corrected release sequence. The effect on the earlier kernel crashes remains unverified.AI use
OpenAI Codex (GPT-6, specific revision unavailable) assisted with the review fixes, rebase, regression tests, test execution and this update. Author review of this revision is pending.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T09:04:54Z.
Review (head
5a89516f, diff read, not a merge-check; draft, checks red):#[cfg(test)]modules, about 2,150 lines change (mostlyvram.rs), over five times the ~400 target, with no reason given. These parts stand alone along CONTRIBUTING.md: (1) thelate_release.rs/present.rssealing change (queue snapshot, retiring marks,open_revisionprefix), which changes the default path; (2)TextureBudgetadmission and theCUSTOM/ L0 routes for committed, placed and tile-pool texture backing behindXCL_TEXTURE_BUDGET; (3) L0 routing for sparse physical-page heaps (physical_page_heap,sparse.rs); (4) keeping reserved backing until the NULL mapping completes (RecycleInfo::backing,res_release); (5) live alias promotion (vram_promotion.rs, the admission gate inq_execute_command_lists/native_queue_execute); (6) the physical RAM guard; (7) diagnostics. #3620 and #1702 (onmain) and #3587 (onamd-dev) also move texture pages or sparse heaps toCUSTOM/ L0; which approach goes in should be settled before splitting. Regression run has noxcl-smokeblocks (the reasonPR descriptionis red).late_releasechange can stop all deferred releases.drain_known(late_release.rs~317-320) now seals nothing new whilesnapshot.blockedis set, andblockedis also set byRetiring::Failed(present.rs~506), which never clears (failed_retirement_is_permanently_pinned). After one queue retirement fails to create or signal its fence, every later resource, pipeline and heap release stays held for the rest of the run, withXCL_TEXTURE_BUDGETunset.E_OUTOFMEMORY. Once a sampled committed texture goes past the local soft cap,reserve_texture_backing(vram.rs~2169-2176) tries onlyNonLocal; if the RAM guard (~2055, 3,072 MiB free by default) or the non-local budget refuses,committed_backing_with_budgetreturnsE_OUTOFMEMORY(~2238) while local memory up to the DXGI budget is still unused, where without the budget the creation went to the driver.Not reviewed line by line because of the size. Fine: the allocation routing and promotion gate are behind
XCL_TEXTURE_BUDGET=1; fence reads treatu64::MAXas not complete; a submit gets admission before it takes the queue lease.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-12-02T17:43:50Z.
@Foniass Both review fixes are in
d58531c2. Deferred releases on healthy queues now progress after a failed retirement, and eligible committed backing retries locally up to the DXGI budget minus 8 MiB if L0 admission is denied. Both new regressions passed on the Quadro with zero Debug Layer messages. The draft will be split into smaller PRs once Windows CI and stability validation are green.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T17:46:39Z.
Follow-up review (head
d58531c2, since5a89516f, diff read, not a merge-check; draft, conflicts):Earlier points:
xcl-smokeblocks. Open. The PR is now +3,389 / −265 with no reason given for not splitting, and Regression run still has no smoke blocks. It also conflicts withmainnow.late_releasechange can stop all deferred releases. Fixed in74e574d0. AFailedretirement now setsfailedinstead ofblockedin the release snapshot (present.rs~509). Ordinary batches seal against the remaining queues as onmain.take_gone(true)lets ready batches pass an older batch that waits on the failed queue.E_OUTOFMEMORY. Fixed in6c9b1a9a.reserve_texture_backing(vram.rs~2187-2190) retries anEitherbacking asRequiredLocalup to the DXGI ceiling before it fails.New:
Failed, which never clears, every later batch is sealed withunmarked_retirement = true. For those batches,drain_known(late_release.rs~361)continues past any resource for whichhas_parked_backingis true. That includeswas_mappedentries of the reserved pool (vram.rs~967), and the pool is on by default (XCL_RESERVED_POOL, ~756/3829), not only budgetbacking. Those resources stay inPARKING: never unmapped, never recycled, neverReleased, and nothing retries them. On a title that streams reserved textures, memory grows for the rest of the run, where onmainthey were recycled. If keeping them is needed for safety, limit it to the failed queue's own work, or at least log it and count the held bytes.Fine:
begin_known_sealstill refuses to seal while a retirement isPreparing. The new GPU tests cover the failed-queue recovery and the local fallback after an L0 denial. The test-adapter change ind58531c2is scoped to its fixture.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-12-02T18:04:23Z.
@Foniass I rebased the draft on main
817eb1fc. Atd7ddf34dthe parked-backing guard follows the individual failed queue's completion dependency. A reserved texture on a healthy device still recycles while the other device's queue stays failed. Same-device backing that outstanding bindless work may still reference remains protected until the recovered mark completes. The Quadro regression and the targeted runs are recorded in the description.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T18:05:33Z.
Follow-up review (head
d7ddf34d, sinced58531c2, diff read, not a merge-check; draft):Earlier points:
xcl-smokeblocks. Open. The PR is now +3,642 / −307, and Regression run has no smoke blocks. The conflict is gone after the rebase.d7ddf34d.parked_retirement_pending,late_release.rs~346).retry_failed_retirements,present.rs~665).waiting_for_retirement.late_releaseand L0-fallback fixes from74e574d0/6c9b1a9aare unchanged by the rebase (git range-diff).New:
2bbb971ethrough7c592be1do not build.2bbb971emakesPendingRecycle::keyanOptionand addsbacking, and it removespromote_pending.make_spares(vram.rs~1031) and its tests, which came frommain(#3553), still use the old form until10c0afeeadapts them. Every commit lands onmain, so squash10c0afeeinto2bbb971eto keepgit bisectworking.gpu_failed_retirement_leaves_healthy_reserved_pool_recyclable(vram.rs~9154), and the tests at ~5105, ~5224, ~5479, ~5803 and ~9282, useSelector::from_env_or("nvidia"). WithoutXCL_ADAPTERset, no adapter matches on those machines, so the tests areSKIPPEDthere, including on the maintainer's RDNA4 batch run. The rest of the crate uses"auto".parked_retirement_pendingcalls with a hand-set mark; nothing runs the worker retry inretry_failed_retirements.Fine: the snapshot still blocks sealing while a retirement is
Preparing. ARecoveringentry is swept like aMarkonce its fence completes.Held::is_emptycounts held items, so the drain keeps running for them.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-12-02T18:28:46Z.
@Foniass I folded
10c0afeinto2bbb971, which is nowfd938727. All nine commits passedcargo check --locked -p xcl --tests. All six new VRAM GPU tests now default toauto, and the targeted runs on the Quadro passed at0877fa97.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T18:30:56Z.
Follow-up review (head
0877fa97, sinced7ddf34d, diff read, not a merge-check; draft, checks red):Earlier points:
2bbb971ethrough7c592be1do not build. Fixed. Themake_sparesadaptation is now part offd938727, the rewritten2bbb971e(git range-diff), and10c0afeeis gone. The final tree is unchanged apart from the adapter selection below.0877fa97: all six useSelector::from_env_or("auto"). That commit only changes tests added earlier in this PR, so it could be folded into them.retry_failed_retirements(present.rs~665).xcl-smokeblocks. Open, at +3,642 / −307.New: none.
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T21:01:28Z.
Follow-up review of
b647ecab, since0877fa97(code reading only, not a merge-check; draft,Build and test (Windows, no GPU)red,PR descriptionred) · 1 high, 3 mediumIn short: The only change since
0877fa97is one new commit on top,b647ecab; the earlier commits are identical (git range-diff). Above the sampled tile-pool spill threshold it still tries L0 first, then finishes the batch from local memory when the L0 heap is refused. It works as described and has a GPU test. The PR is still blocked by its size and the missing smoke blocks. The new fallback can also use up the local reserve kept for render targets.High
xcl-smokeblocks (still open). The PR is now +3,718 / −313 in 14 files, with no reason given for not splitting, and Regression run has no smoke blocks. The parts listed in the first review still stand alone. The new tile-pool fallback would go with theTextureBudgetadmission part.Medium
The same-device retry path is untested (still open). No test runs
retry_failed_retirements(present.rs~665).The sampled tile-pool fallback can use up the reserve kept for RT/DS/UAV.
alloc_pool_heap(vram.rs~2694-2695) turns everyLocalReserverequest intoTextureAdmission::RequiredLocal. Its limit is DXGI budget minus 8 MiB (~2194), the same ceiling render targets, depth buffers and UAVs use. The fallback heaps are full 64 MiB pools.Fix: stop the sampled fallback some margin below the required ceiling, or say in the description and README that sampled tiles share that ceiling on purpose.
An L0 refusal that the fallback absorbs is still logged as a failed allocation, on every bind.
make_heapwithNonLocal, even when a local fallback heap has free tiles.site.log(.., "heap admission denied", true)(~2704). Denied entries are not rate-limited (~2557), so each one writes the request, the full allocation totals and the breakdown, plus aGlobalMemoryStatusExcall.Fix: log the denial only when the local retry also fails, or rate-limit it like the routed entries.
Checked and fine
b647ecab.XCL_TEXTURE_BUDGET=1:TileSegments::NonLocalis chosen only with a budget sample andover_local_limit(~3423-3426).take_compatible_batch(~2068-2083) keeps the L0 tiles it took and continues from local heaps. If the local heap also fails, it returns every taken tile throughreturn_tiles.LocalReserveallows only local heaps, so free local tiles of the same class are reused before a new heap is made.l0_unsupportedand physical RAM guard refusals now fall back too, instead of reaching the title asE_OUTOFMEMORY(~4113).local_tilepool_fallback_heapsis a subset oflocal_tilepool_heaps, and the counter arrays grew together.sampled_tile_pool_uses_local_headroom_after_non_local_denialfails without the change. It covers reuse of the fallback heap, refusal past the ceiling, andfree_totalcoming back.BindFailure::Budget(~6240). README describes the new route.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.