D3D12.X: reclaim empty 64 MiB VRAM pool heaps, alias GPU mirror pages, and sync 2048x128 glyph atlases #1985
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!1985
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1985/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?
@raylitebull on GitHub · 2026-11-25 00:23 UTC · original
raylitebull:feat/vram-local-reclaim-and-bind→main· +408 −24 · 3 files · 1 commits · merged 2026-11-25 10:40 UTCReclaims idle 64 MiB VRAM tile-pool heaps (keeping a configurable warm spare count via
XCL_VRAM_KEEP_SPARE_POOLS, default1), defers reclaimed heap destruction safely behind GPU fence completion (retire_fence), canonicalizes GPU mirror virtual addresses (canonical_va) only when uncommitted/aliasing a mapped GPU view (physical_page_at+VirtualQueryMEM_COMMITguard), and widensis_small_cpu_filled_targetup to2048on an axis (<= 1Mpixels) so2048x128CPU-filled glyph atlases stay in sync.Part of #1833.
What is in it
crates/xcl/src/hle/d3d12x/vram.rs:Arenas::sweep_dropped: zero-alloc fast-path + order-preservingdrain(arenas_sweep_dropped_preserves_newest_fitting_order).TilePool::reclaim_empty_heaps, per-devicelast_reclaim, andretire_fence(queue.Signal+fence.GetCompletedValue()verification) so reclaimed pool/arenaID3D12Heapobjects are never dropped while in-flight GPU work references them (compatible with#1983'snote_internal_wait).canonical_va: checkskernelx::physical_page_at(va)+VirtualQueryMEM_COMMITbefore aliasing a GPU mirror view (canonical_va_aliases_unmapped_gpu_view_but_preserves_committed_override).crates/xcl/src/hle/kernelx.rs&crates/xcl/src/hle/d3d12x/title_textures.rs:kernelx::mirrors::gpu_views_of+ symmetrictitle_textures::retire_overlappingretirement in both directions (gpu_va -> cpu_vaandcpu_va -> paired gpu_va).is_small_cpu_filled_targetup to2048x128(<= 1Mpixels,small_cpu_filled_target_accepts_wide_glyph_atlas_and_rejects_large_or_depth).Tested
rustc 1.99.1 (58cf8f9c3 2026-10-13), rebased cleanly onto3da2abb(5a515f0).cargo build --release,0errors) on5a515f0; GitHub ActionsBuild and testis running on this pushed head (5a515f0).scripts/smoke.ps1regression pair on AMD Radeon RX 9070 (@Toons29): passed (0 device removals, 0 crashes).Regression run
60 s
scripts/smoke.ps1pair on exact head5a515f0vsmain(AMD Radeon RX 9070, driver 32.0.32029.2010, Windows 11 26300, release,XCL_NETWORK=0on a retail title), contributed by@Toons29:main:
this PR:
Not tested
cargo testsuite and 60 sscripts/smoke.ps1pair on5a515f0, fullcargo test --workspacesuite, runtime GPU execution across AMD / NVIDIA / Intel hardware, and Linux/Wine/vkd3d-proton.AI use
@Filip722 on GitHub · 2026-11-25 00:47 UTC · original
On
363a451, expiring an unrelated arena made the next texture placement select an older overlapping heap. The reproducer creates a one-page arena and then a two-page arena at the same address. After cleanup, the one-page placement chose arena 2 instead of the newest fitting arena, 3. The PR parent’s allocator passes the same isolated fixture. Preserving insertion order during extraction fixes the Windows regression test. Fix and test for cherry-pickOn the RTX 5060 Laptop GPU (8 GiB), an asset-free D3D12 probe allocated three 64 MiB heaps. With one warm spare, DXGI local usage went from 208 to 144 MiB after reclaim, then back to 208 MiB when the slot was reused. Ten focused checks passed with zero failures, ignores or hardware skips, including that local probe. Bazzite 44, NVIDIA 615.78.08, Proton Experimental 11.0-20261112, vkd3d-proton 3.1.0 (
4522cc1a8b1347f+), Windows MSVC target, Rust 1.98.1.In matched offline Series X startup checks (parent
8c4a46aand fixed PRe9f2d68), both reached 512 MiB in target-page pools and 896 MiB in sparse pools. The fixed build logged no heap reclaim during that interval. All window captures were black. The parent hit the test’s swap cutoff at 24 seconds and the fixed build reached the 25-second deadline. Gameplay savings remain unmeasured.OpenAI Codex (GPT-6.2-Sol) assisted with diagnosis, implementation, tests and reporting.
@eizispark on GitHub · 2026-11-25 00:49 UTC · original
Hardware test report — commit
363a451Verified
363a45140d3ce9593f48ce963ca8420ddd7a4bd7(based on8c4a46a3c2d50498691cbda79cbbf4fadb45fbe8; clean merge with currentmain6567c5f): pass (0new failures vsmain; allvramandtitle_texturesunit/GPU tests pass).Tested
32.0.32015.16001), 32 GB RAM,rustc 1.100.0 (0ef1bc386 2026-11-09)(stable-x86_64-pc-windows-msvc), debug tests + release smokecargo test --workspace --no-fail-fast -- --test-threads=4:996 passed, 2 failed, 45 ignored(8 skipped) —0new failures:hle::d3d12x::title_textures::tests(14/14passed,0skips: includingsmall_cpu_filled_target_accepts_wide_glyph_atlas_and_rejects_large_or_depth,placed_title_textures_share_vram_and_preserve_pixels,gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes,transitions_apply_when_their_list_is_submitted)hle::d3d12x::vram::tests(12/12passed,0skips: includingtile_pool_reclaims_empty_heaps_keeping_warm_spare_and_reuses_slots,arenas_sweep_dropped_returns_expired_heaps,d32s8_targets_take_their_own_size_of_video_memory,streamed_targets_stay_bounded)gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,console_wave64_compute_through_the_pso_hook_dispatch_and_read_back) all passedgpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed722andfuzz_validate_and_gpu_3seed1599) are pre-existing onmain(#1679);8 skipped= 6lower_dxilf16/f32#1426-semantics sub-cases,pso_measurement_compiles_an_exact_synthetic_record(0x887A002D), andheap_window_out_of_memory_falls_back_to_the_switch_form: no heap windowsxcl.logcheck: logged64CPU-filled glyph-cache render targets kept in step with title memory and8192skipped unchanged uploads; empty 64 MiB VRAM pool-heap reclamation did not trigger during the 60 s menu windowRegression run
main(8e87fc7b62a87ea589ccb9ea6182f514016cf7db):PR (
363a45140d3ce9593f48ce963ca8420ddd7a4bd7):Not tested
< 16 GBVRAM GPUs, NVIDIA/Intel GPUs, Wine/vkd3d-protonAI use
@gsucristo on GitHub · 2026-11-25 00:57 UTC · original
Technical review findings:
Blocking
Arenas::sweep_droppedbreaks insertion order viaswap_remove(vram.rs,Arenas::sweep_dropped):Arenas::takeusesself.list.iter().rposition(fits)assumingself.liststays ordered oldest-to-newest so it picks the newest fitting arena. Usingswap_removemoves the newest arena to the front when an older arena expires, causing overlapping placements to pick an older arena. Needs an order-preserving removal.Major
canonical_vaunconditionally aliases GPU mirror views (vram.rs,canonical_va,place_on_pages,place): Callskernelx::mirrors::source(va).unwrap_or(va)without checkingkernelx::physical_page_at(va)orva_committed(va). If a title maps distinct physical pages directly at a GPU mirror addressva, this falsely aliases unrelated textures onto the same VRAM pages/arena.title_textures.rs,retire_overlapping):by_va/shadowed_by_vaare keyed byentry.va, notentry.src. Retiring a GPU-owned target atcpu_vaseesmirror_source(cpu_va) == cpu_vaand misses any texture registered at the pairedgpu_va, allowing stale CPU uploads to overwrite the render target.ID3D12Heaps on wall-clockCOOL(2 s) without GPU fence verification (vram.rs,sweep_and_reclaim,before_execute): If any title queue is stalled >2 s (e.g. heavy PSO compile or Wine/vkd3d-proton stall) with in-flight work referencing a resource mapped to that heap, dropping theID3D12Heapcauses GPU UAF / device removal. Alsoshould_reclaimuses a process-globalLAST_MSstatic across devices.@Anon64 on GitHub · 2026-11-25 01:47 UTC · original
Regression run for this PR: head
363a451, based onmain80f4819. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release,XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s, in one batch with themainrun.main
80f4819:this PR:
No device removals or crashes; 102 % of main's frames, 95 % of its peak commit.
Not tested: the whole suite; world loading; whether the title reaches all of the changed code in these 60 s (default settings:
XCL_DIRECT_DXILandXCL_HEAP_WINDOWSunset).Written with Claude Code (Claude Opus 5.5) from runs on this machine.
@raylitebull on GitHub · 2026-11-25 01:53 UTC · original
Thanks for the detailed catches,
@Filip722and@gsucristo!Updated
#1985cleanly onto3da2abb(5a515f0), addressing the Blocking + Major findings:Arenas::sweep_droppedorder & fast-path (vram.rs): switched to a zero-alloc fast-path and order-preservingdrain(arenas_sweep_dropped_preserves_newest_fitting_order).canonical_vacommitted-page guard (vram.rs): checkskernelx::physical_page_at(va)andVirtualQueryMEM_COMMITbefore aliasing a GPU mirror view (canonical_va_aliases_unmapped_gpu_view_but_preserves_committed_override).kernelx.rs,title_textures.rs): addedkernelx::mirrors::gpu_views_ofsoretire_overlappingretires bothgpu_va -> cpu_vaandcpu_va -> paired gpu_va.vram.rs): replaced the globalLAST_MSthrottle with per-devicelast_reclaim, and deferred reclaimed pool/arenaID3D12Heapdestruction behindretire_fence(queue.Signal+fence.GetCompletedValue()verification) so in-flight GPU work never observes premature drops (preserving#1983'snote_internal_wait).Compiled cleanly in release (
0errors) and pushed5a515f0for GitHub ActionsBuild and test+ reviewer verification.@DavidM1911 on GitHub · 2026-11-25 03:31 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main(crates/xcl/src/hle/d3d12x/vram.rs) — needs a rebase before it can be tested.@thehollowedone on GitHub · 2026-11-25 03:57 UTC · original
Independent NVIDIA check of 5a515f0 against the requested 3da2abb baseline. Windows 11 build 26300, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, debug build.
Built with
cargo test --offline --locked -j 4 -p xcl --lib --no-run. Ran both test binaries withXCL_ADAPTER=3080 Ti,XCL_HEAP_WINDOWS=1, and--nocapture --test-threads=1 hle::d3d12x::vram hle::d3d12x::title_textures. The PR had 29 passing tests and the baseline had 24. Both had zero failures, one ignored test, and zero reported skips.The PR's empty-pool bookkeeping test passed. The shared-VRAM GPU test passed on both revisions. Its 512 unreleased 1 MiB texture placements over a 16 MiB working set had zero additional page growth after fill. Coverage was the stock synthetic tests with default driver validation.
AI-assisted. Codex (GPT-6, exact variant unavailable) ran the tests and drafted this report.
@thehollowedone on GitHub · 2026-11-25 04:03 UTC · original
Follow-up on 5a515f0. A separate synthetic GPU fixture on the RTX 3080 Ti (621.35, Windows 11 build 26300) created one pool with a live RGBA8 texture and two empty 64 MiB heaps. With one warm spare configured,
before_executemoved one heap to retirement, and the next call after the queue fence drained that entry. Readback matched all 65,536 bytes of the surviving texture.One exact test passed with zero failures or skips. The fixture seeded already-empty heaps and exercised native D3D12 retirement on one queue. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the fixture and drafted this report.
@Toons29 on GitHub · 2026-11-25 04:34 UTC · original
Regression run of
5a515f03on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainoncbc296ab, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 100 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; a script posted this right after the run, with both blocks exactly as printed.@raylitebull on GitHub · 2026-11-25 10:37 UTC · original
Thanks @Toons29 for running and sharing the exact-head 60 s
scripts/smoke.ps1pair on5a515f0(0 device removals, 0 crashes) — added to the PR description!@DavidM1911 on GitHub · 2026-11-26 00:49 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin