Repository navigation
Conversation
On an 8 GB card a retail title's world load takes local video memory past what Windows gives the process: on an RX 6650 XT (lockhart), local VRAM reaches ~7.7 GB against a 6.8 GB DXGI budget on amd-dev (and 11.4-11.5 GB on main), forcing WDDM to page allocations over PCIe (xcl-dev#1337, xcl-dev#1585). XCL_VRAM_BUDGET=1 (off by default) samples DXGI's local Budget every 250 ms via memory_report::local_segment() and takes Budget less XCL_VRAM_BUDGET_MARGIN_MB (default 2048; XCL_VRAM_BUDGET_MB sets a fixed target instead) as a target. At or past it: - a sampled texture's pages (not render targets, depth, or UAVs) take free tiles of existing video-memory pool heaps first, then tiles of 64 MiB pool heaps in system memory (CUSTOM, CPU_PAGE_PROPERTY_NOT_AVAILABLE, MEMORY_POOL_L0; same properties as xcl-dev#1702); - empty pool heaps are reclaimed every 250 ms without a warm spare; - parked sparse tiles flush at 256 (16 MiB) instead of 4096 (256 MiB); - a failed video-memory pool heap falls back to system memory. Pressure returns to Room 256 MiB below the target (hysteresis). PoolHeaps tracks system-memory heaps per device so memory_report splits video target pages/free pools from non-local "target pools in system memory" without double-counting either segment. Assisted-by: Antigravity (Gemini 4 Neon High)
5 tasks
Contributor
|
Review (head 08f61a9, diff read, not a merge-check):
Fine: off by default; with AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
saintwolf
added a commit
to saintwolf/xcl
that referenced
this pull request
Dec 1, 2026
…re pools to L0 Add opt-in XCL_L0_VRAM_MARGIN_MB (default 0 = disabled) to dynamically spill new sparse tile pools (sparse.rs) and sampled-only texture tile pools (vram.rs) to D3D12_MEMORY_POOL_L0 (system memory) once DXGI local VRAM usage is within the configured headroom margin of budget. Render targets, depth buffers, and UAV textures (!evictable) always stay in local DEFAULT VRAM and keep_pools skips L0 heaps. When a non-evictable target binds a console page currently backed by an L0 heap (DENY_RT_DS_TEXTURES), bind_range promotes the page in-place to a local VRAM tile, cools the old L0 tile, and remaps any live mapped aliases in Pages::targets onto the promoted local tile so aliased reads never observe stale data. Non-OOM adapter refusals of custom L0 heaps are cached per heap class. Distinct from xcl-dev#3614 (two-pass UAV buffers in bind.rs, untouched here), xcl-dev#3112 (stale draft on amd-dev), xcl-dev#2987 (static sparse cap), xcl-dev#3039 / xcl-dev#1702 (unconditional sysmem opt-ins), and xcl-dev#3587 (amd-dev).
saintwolf
added a commit
to saintwolf/xcl
that referenced
this pull request
Dec 1, 2026
…re pools to L0 Add opt-in XCL_L0_VRAM_MARGIN_MB (default 0 = disabled) to dynamically spill new sparse tile pools (sparse.rs) and sampled-only texture tile pools (vram.rs) to D3D12_MEMORY_POOL_L0 (system memory) once DXGI local VRAM usage is within the configured headroom margin of budget. Render targets, depth buffers, and UAV textures (!evictable) always stay in local DEFAULT VRAM and keep_pools skips L0 heaps. When a non-evictable target binds a console page currently backed by an L0 heap (DENY_RT_DS_TEXTURES), bind_range promotes the page in-place to a local VRAM tile, cools the old L0 tile, and remaps any live mapped aliases in Pages::targets onto the promoted local tile so aliased reads never observe stale data. Non-OOM adapter refusals of custom L0 heaps are cached per heap class. Distinct from xcl-dev#3614 (two-pass UAV buffers in bind.rs, untouched here), xcl-dev#3112 (stale draft on amd-dev), xcl-dev#2987 (static sparse cap), xcl-dev#3039 / xcl-dev#1702 (unconditional sysmem opt-ins), and xcl-dev#3587 (amd-dev).
saintwolf
added a commit
to saintwolf/xcl
that referenced
this pull request
Dec 2, 2026
…re pools to L0 Add opt-in XCL_L0_VRAM_MARGIN_MB (default 0 = disabled) to dynamically spill new sparse tile pools (sparse.rs) and sampled-only texture tile pools (vram.rs) to D3D12_MEMORY_POOL_L0 (system memory) once DXGI local VRAM usage is within the configured headroom margin of budget. Render targets, depth buffers, and UAV textures (!evictable) always stay in local DEFAULT VRAM and keep_pools skips L0 heaps. When a non-evictable target binds a console page currently backed by an L0 heap (DENY_RT_DS_TEXTURES), bind_range allocates a local VRAM tile, copies the 64 KiB tile bytes from L0 to local on Pages::queue (via lazily-created 0-VRAM reserved scratch textures), promotes the page in-place, cools the old L0 tile, remaps any live mapped aliases in Pages::targets, and marks any pending HeldUnmap referencing that page stale so cancelling it in remap_if_unmapped re-maps onto the promoted local tiles. Non-OOM adapter refusals of custom L0 heaps are cached per heap class. Distinct from xcl-dev#3614 (two-pass UAV buffers in bind.rs, untouched here), xcl-dev#3112 (stale draft on amd-dev), xcl-dev#2987 (static sparse cap), xcl-dev#3039 / xcl-dev#1702 (unconditional sysmem opt-ins), and xcl-dev#3587 (amd-dev).
saintwolf
added a commit
to saintwolf/xcl
that referenced
this pull request
Dec 2, 2026
…re pools to L0 Add opt-in XCL_L0_VRAM_MARGIN_MB (default 0 = disabled) to dynamically spill new sparse tile pools (sparse.rs) and sampled-only texture tile pools (vram.rs) to D3D12_MEMORY_POOL_L0 (system memory) once DXGI local VRAM usage is within the configured headroom margin of budget. Render targets, depth buffers, and UAV textures (!evictable) always stay in local DEFAULT VRAM and keep_pools skips L0 heaps. When a non-evictable target binds a console page currently backed by an L0 heap (DENY_RT_DS_TEXTURES), bind_range allocates a local VRAM tile, copies the 64 KiB tile bytes from L0 to local on Pages::queue (via lazily-created 0-VRAM reserved scratch textures), promotes the page in-place, cools the old L0 tile, remaps any live mapped aliases in Pages::targets, and marks any pending HeldUnmap referencing that page stale so cancelling it in remap_if_unmapped re-maps onto the promoted local tiles. Non-OOM adapter refusals of custom L0 heaps are cached per heap class. Distinct from xcl-dev#3614 (two-pass UAV buffers in bind.rs, untouched here), xcl-dev#3112 (stale draft on amd-dev), xcl-dev#2987 (static sparse cap), xcl-dev#3039 / xcl-dev#1702 (unconditional sysmem opt-ins), and xcl-dev#3587 (amd-dev).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds opt-in
XCL_VRAM_BUDGET=1(off by default: no change) to keep XCL's texture page pools and parked sparse tiles under DXGI's local video memory budget on 8 GB cards (#1337, #1585). Supersedes #3335 (always-onXCL_TEXTURE_SYSMEMport onamd-dev) with a budget-triggered L0 spillover that stays in local VRAM while under budget.TL;DR — Before vs After (RX 6650 XT 8 GB, DXGI local budget ~6,808 MB)
XCL_VRAM_BUDGEToff)XCL_VRAM_BUDGET=1)41aa60ce, opt-in off)maind8bd9a38)08f61a9a)41aa60ce, default 2048 MiB margin)41aa60ce, default 2048 MiB margin)36e16cf4, 600 MiB margin)36e16cf4,BUDGET_MB=2500)When enabled, XCL samples DXGI's local segment via
memory_report::local_segment()every 250 ms and sets a target ofBudget - XCL_VRAM_BUDGET_MARGIN_MB(default2048MiB;XCL_VRAM_BUDGET_MBsets a fixed target instead). At or past the target (Pressure::Near/Over, with 256 MiB hysteresis back toRoom):D3D12_HEAP_TYPE_CUSTOM,CPU_PAGE_PROPERTY_NOT_AVAILABLE,MEMORY_POOL_L0, same properties as D3D12.X: allow title texture pages in system memory #1702). Nothing is left unbacked (unlike D3D12.X: bound target-page pools by title and adapter VRAM budgets #2357's NULL tiles).CreateHeapfor a video-memory pool heap fails whileXCL_VRAM_BUDGET=1, it falls back to an L0 system-memory heap.The default 2048 MiB margin starts spilling streaming sampled textures before the ~2 GiB world-entry burst of render targets, two-pass buffers, and driver pipelines hits an 8 GB adapter, while remaining dormant on 16 GB+ adapters under typical 8–10 GB workloads.
What is in it
crates/xcl/src/hle/d3d12x/vram_budget.rs:XCL_VRAM_BUDGET/XCL_VRAM_BUDGET_MARGIN_MB/XCL_VRAM_BUDGET_MBsettings, pressure/hysteresis state machine, lock-free try-locked 250 ms DXGI sampler, and unit tests.crates/xcl/src/hle/d3d12x/vram.rs:pool_heap_properties,alloc_pool_heapL0 allocation and OOM fallback, per-devicePoolHeapsL0 tracking (is_sys,sys_live),Pages::page_bytes_split/page_bytes_split_for,spare_pools_for/reclaim_every, two-step free-VRAM-first then L0 placement inbind_range, budget hooks inplace_on_pages/remap_if_unmapped/map_levels/before_execute, plus unit and GPU round-trip tests.crates/xcl/src/hle/d3d12x/sparse.rs:PARKED_MAX_TIGHT(256) andparked_max_forat the four parked-tile flush sites, plus unit test.crates/xcl/src/hle/d3d12x/memory_report.rs: splits video target pages/free pools from non-local"target pools in system memory"so neither segment is double-counted, and updatesdevice_snapshot_has_budget_and_all_owners.crates/xcl/src/hle/d3d12x/mod.rs: exposespub mod vram_budget.Tested
32.0.21045.29003), AMD Ryzen 7 5700X, Windows 11,rustc 1.100.0 (0ef1bc386 2026-11-09).cargo test -p xcl --lib -- hle::d3d12x::vram_budget hle::d3d12x::vram:: hle::d3d12x::sparse:: hle::d3d12x::memory_report --test-threads=4, debug): 233 passed, 1 failed (sparse::tests::private_physical_pages_reach_the_gpu_on_mapping, pre-existing onorigin/amd-dev41aa60ce), 2 ignored, 0 SKIPPED. All 6 new tests (including GPU round-trip + per-device split accounting invram::tests::system_memory_pages_have_their_own_heap_and_hold_what_the_gpu_copies) pass.cargo test --workspace -- --test-threads=4, debug): 2,826 passed, 9 failed (all 9 pre-existing onorigin/amd-dev41aa60ceon this RDNA2 GPU: 3gpu::recompfloat-compare NaN tests,sparse::tests::private_physical_pages_reach_the_gpu_on_mapping,title_textures::tests::placed_title_textures_share_vram_and_preserve_pixelsplus 4 cascadingPoisonErrors that pass 4/4 when run separately), 29 ignored. SKIPPED:gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(4 subcases: unsupportedV_MUL_F16/V_PK_MUL_F16),hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap(opt-inXCL_HEAP_WINDOWS=1),shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode not enabled).XCL_COHERENT_MB=4095,XCL_VRAM_KEEP_SPARE_POOLS=0,XCL_SPLIT_SCRATCH_TOTAL_MB=128,XCL_SPARSE_LAZY=0):origin/amd-dev41aa60ce(loading phase with local menu-nav tooling + localscale_indirect_pipelinerace workaround):XCL_VRAM_BUDGET=1(default 2048 MiB margin) transitionedRoom -> Nearcleanly at 105.7 s (local 5299 MB,target 4727 MB,budget 6775 MB), placed 4 × 64 MiB L0 pool heaps (target pools in system memory: 256 MBon non-local, local target pools reduced by matching 192–256 MB with zero double-counting), peak local 5,629 MB vs 5,746 MB off, peak commit 20,737 MB vs 23,819 MB off, 0 crashes / 0 TDRs.origin/amd-dev36e16cf4full 3D world-load runs (warm cache, same RX 6650 XT): off peaked at 7,688 MB local (+880 MB over 6,808 MB budget, 85 over-budget warnings);XCL_VRAM_BUDGET=1with 600 MiB margin cut peak local to 7,197 MB (-491 MB, 448 MB in L0, 35 warnings); withXCL_VRAM_BUDGET_MB=2500held peak local at 6,024–6,534 MB (-1,154 to -1,664 MB, 257–783 MB under budget, 896–1,152 MB in L0, 0 over-budget warnings, 0 crashes / 0 TDRs across 300 s).Regression run
Both 60 s runs with
scripts/smoke.ps1 -Seconds 60(XCL_PREPARE=0,XCL_NETWORK=0,XCL_ACTIVITY=1,XCL_VRAM_BUDGETunset) on the same retail title and RX 6650 XT. Firstmaind8bd9a38, then this PR's clean head08f61a9a:Not tested
CreateHeapfailure) under real VRAM exhaustion.AI use
main/amd-devprototype were written with Claude Code (Claude Opus 5.5). Rebase toamd-dev41aa60ce, per-devicePoolHeapsL0 tracking andmemory_reportsplit fix, default margin tuning (2048 MiB), tests, smoke/retail runs, and this description were done by Antigravity with Gemini 4 Neon (High).