D3D12.X: recycle released reserved sampled textures by description and state #2436
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!2436
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2436"
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?
@saintwolf on GitHub · 2026-11-25 18:40 UTC · original
saintwolf:vram/recycle-reserved-textures→main· +420 −33 · 4 files · 1 commits · openRecycles released reserved sampled textures in a bounded per-device pool keyed by exact
(D3D12_RESOURCE_DESC, uniform D3D12_RESOURCE_STATES)so streamed texture placements skipCreateReservedResourceandGetResourceTiling. Fixes #1268. Part of #1833.What is in it
crates/xcl/src/hle/d3d12x/title_textures.rs:forget(res)returns the removed texture's last tracked uniformD3D12_RESOURCE_STATESwhen all subresources share a single state (states.len() == 1), orNonefor mixed-state / untracked textures.crates/xcl/src/hle/d3d12x/real.rs: on finalRelease(n == 0) whilelate_releaseholds the last PC ref, parks eligibleplace_pagessampled textures with their actual uniform D3D12 state; exposesnote_reservedso reused pointers re-register inRESERVED.crates/xcl/src/hle/d3d12x/late_release.rs: once every live GPU queue is past a batch's fence, hands parked textures tovram::recycle_readyinstead of destroying them.crates/xcl/src/hle/d3d12x/vram.rs: addsReservedKeyand a bounded per-deviceReservedPool(512idle entries/device, generation-tombstoned FIFO eviction with boundedordercompaction, evicted entries dropped outsidePAGES.lock(), opt-out viaXCL_RESERVED_POOL=0).recycle_readyunmaps any still-mapped tiles (pages.unmap) on the backgroundlate_releasethread so retired 64 MiB VRAM pool heaps never leave stale page-table references.place_on_pagespops matching pooled reserved textures viaQueryInterfaceand reuses their cached tile count, skippingCreateReservedResourceandGetResourceTiling. Adds unit tests (reuse hit, state isolation, FIFO eviction, cap=0, repeated take/repark tombstoning + cap-FIFO ordering) and a GPU recycle/rebind test.Tested
32.0.16.2140), AMD Ryzen 7 7800X3D,rustc 1.100.0 (0ef1bc386 2026-11-09), DXC/DXIL1.8.2502.11..\scripts\test.ps1(cargo test --workspace -- --test-threads=4, debug) on head2f92cc8: 1426 passed, 0 failed, 46 ignored across 37 test binaries, including allhle::d3d12x::vram::tests(reserved_pool_reuses_matching_key_isolates_state_and_evicts_fifo,reserved_pool_repark_tombstones_stale_order_and_preserves_fifo, andreserved_resource_recycle_unmaps_reuses_and_remaps_on_gpu).SKIPPEDGPU tests on this adapter (27 total): 21no wave64, 3 per-lane form#1426refusals (V_CVT_F16_F32,V_MUL_F16,V_PK_MUL_F16), 1cannot disable the driver cache (Windows Developer Mode is required)(0x887A002D), 1no xgameruntime.dll, 1no heap windows.#1268microbenchmark on RTX 4070 SUPER (release,2,000iterations each):256x256 BC1 (9 mips):CreateReservedResource + GetResourceTiling + Release222.33 ms (111.17 µs/tex) → recycled pool 0.04 ms (0.019 µs/tex) (5,730× faster).1024x1024 BC7 (11 mips): 279.58 ms (139.79 µs/tex) → recycled pool 0.04 ms (0.019 µs/tex) (7,262× faster).XCL_DIRECT_DXIL=1,XCL_PSO_WAIT_MS=50,XCL_PRESS_A_AT=15,20,25,30,35,40,45, isolated caches):XCL_RESERVED_POOL=1cleanly recycled 32+ streamed reserved textures live before both arms hit the same pre-existingxboxbvhbuilder.dll40-bit VA exception (~112–116 s), with0device removals and-352 MBlower peak commit (28,903 MBvs29,255 MB).Regression run
Not tested
0.62–1.70 msper-textureCreateReservedResourcestall from #1268 was measured on AMD RDNA2 and should see the largest streaming speedup there).xboxbvhbuilder.dll40-bit VA exception).AI use
@emirduran707 on GitHub · 2026-11-25 19:00 UTC · original
Independent AMD RDNA4 (native wave64) test report on exact head
e2cf9357ba193507dfbc19d4e3b040b63ee957e7(clean detached checkout, no local changes).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1275 passed, 2 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused by per-lane form;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.hle::d3d12x::vram::tests::reserved_pool_reuses_matching_key_isolates_state_and_evicts_fifoandreserved_resource_recycle_unmaps_reuses_and_remaps_on_gpu.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) are pre-existing on unmodifiedmainon this GPU.Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
@SlopTart on GitHub · 2026-11-25 19:46 UTC · original
gpu_suite (cold cache): 160 passed / 4 failed, no crashes. Three are the known baseline trio on this lane; the fourth isgpu_promoted_uav_clear_values_pass_create_committed_resource, newly red on main since #2280 (report), unrelated to this PR.Targeted run of
reserved_pool_reuses_matching_key_isolates_state_and_evicts_fifo: passed (the gpu-side recycle test ran inside the suite).@DavidM1911 on GitHub · 2026-11-25 20:04 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 1 real failure, deterministic (also fails--test-threads=1, 1219/1):The lowered program is missing an expected group barrier (or emits one where none is expected). Needs a fix before merge.
— Devin
@saintwolf on GitHub · 2026-11-25 20:28 UTC · original
@bmjask Good catch — fixed in
2f92cc8(also rebased ontomain6d12f58, picking up #2420 so the full workspace suite passes with 0 failures — cc @DavidM1911):ReservedPoolnow tracks a monotonicnext_gen: u64andlive_gen: HashMap<usize, u64>with generation-taggedorder/by_keyentries.take()removes the pointer fromlive_gen(immediately tombstoning any staleorderentry) and callscompact_order(), which prunes front tombstones and compactsorderwheneverorder.len() > max(2 * live, 16)so repeated take/repark cycles below cap cannot accumulate unbounded stale entries.push()skips tombstoned generations during cap eviction so a reparked pointer is ordered strictly by its current parking time.reserved_pool_repark_tombstones_stale_order_and_preserves_fifocovering 100× below-cap take/repark cycles behind an idle front entry, cap=2 repark FIFO ordering, and cap=3 non-front tombstone skipping.@oni-swr on GitHub · 2026-11-25 22:10 UTC · original
Independent AMD report for
2f92cc841ad65e2dc7e63fea17d227a71e44f16b.Tested
XCL_ADAPTER=radeon. Exact PR head (not a local merge ontomain); main at the time was6d12f58a.cargo test --workspace --no-fail-fast -j 4 -- --test-threads=4: 1425 passed, 1 failed, 46 ignored. The one failure isgpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722:res[30] = 0x1, CPU 0x7fffffff); it fails identically onmain6d12f58aon this adapter (cargo test -p xcl --lib fuzz_validate_and_gpu_1), so it is not caused by this PR.f16_programs_on_the_gpu/f32_programs_on_the_gpuper-lane cases refused forV_MUL_F16,V_PK_MUL_F16orV_CVT_F16_F32, andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).vram::tests::reserved_pool_*andreserved_resource_recycle_unmaps_reuses_and_remaps_on_gpu(GPU) passed.Not tested
scripts/smoke.ps1/ a retail title (no regression run), other adapters, NVIDIA. No game data was used.AI use
Claude Code (Claude Sonnet 5.5) ran the tests and wrote this report. No game files, dumps or shader names are included.
@DavidM1911 on GitHub · 2026-11-26 02:12 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
@bmjask on GitHub · 2026-11-25 20:19 UTC · original · reviewed
P2: ReservedPool::take at vram.rs:196-204 removes an entry from by_key/live but does not remove or invalidate its matching VecDeque entry in order. Every reuse/repark adds another order entry (:225-227), so a pool below cap accumulates stale entries indefinitely. At cap, a stale entry can match a reparked pointer and evict it by its original rather than current parking time, violating the intended bounded FIFO behavior. The test takes entries only once and misses reuse->repark cycles. Please tombstone/remove by generation on take and add a repeated recycle/repark plus cap-FIFO test.
@luckyteagirl on GitHub · 2026-11-26 07:43 UTC · original · reviewed
vram.rs:1177–1185: this returns the same nativeID3D12Resourcefor a new texture without clearing itsID3D12Objectprivate data. If a title sets a custom GUID payload on eligible sampled texture A, releases/drains A into this pool, and creates matching texture B,GetPrivateDataon B can return A's payload.SetPrivateDataInterfacealso retains its attached COM reference until that native object is destroyed or the same GUID is overwritten (Microsoft's lifetime contract), so pooling can carry that ownership across apparent texture lifetimes. The pool key covers description/state, and I do not see setter tracking or a private-data reset on reuse.Could a resource with application private data be excluded from reuse, or its tracked GUIDs be cleared before it is handed to B? A focused test could tag A with a custom GUID and confirm B behaves like a fresh resource. This is source/API-contract review at exact head
2f92cc841ad65e2dc7e63fea17d227a71e44f16b; I have not run the native reuse fixture or observed a title using custom private data. AI-assisted review with Codex.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.