Repository navigation
Conversation
…d state Streamed sampled textures placed on shared 64 KiB video-memory pages previously called CreateReservedResource and GetResourceTiling on every placement, costing 0.6-1.7 ms per texture on AMD drivers (xcl-dev#1268) and ~111-140 us on NVIDIA. Keep a bounded per-device pool (512 idle entries, FIFO eviction, opt-out via XCL_RESERVED_POOL=0) of released reserved sampled textures keyed by exact (D3D12_RESOURCE_DESC, uniform D3D12_RESOURCE_STATES). When late_release finishes draining all live GPU queues past a texture's batch, vram::recycle_ready unmaps any still-mapped tiles on the background thread and parks the ID3D12Resource for reuse; matching place_pages calls QueryInterface on the pooled object and reuse its cached tile count, skipping CreateReservedResource and GetResourceTiling. Fixes xcl-dev#1268. Part of xcl-dev#1833. Assisted-by: Antigravity (Gemini 4 Neon) # Conflicts: # crates/xcl/src/hle/d3d12x/vram.rs
saintwolf
force-pushed
the
vram/recycle-reserved-textures
branch
from
November 25, 2026 18:53
e2cf935 to
bebf2dd
Compare
Contributor
|
Independent AMD RDNA4 (native wave64) test report on exact head Tested
Regression run (60 s retail-title smoke, (Matched Not tested
AI use
|
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.
Recycles 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, FIFO eviction 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) 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.cargo test -p xcl --lib hle::d3d12x::vram::tests -- --test-threads=1on rebased headbebf2dd: 21 passed, 0 failed, 1 ignored (including#2306'sthe_tiles_of_a_texture_are_grouped_by_its_levels,reserved_pool_reuses_matching_key_isolates_state_and_evicts_fifo, andreserved_resource_recycle_unmaps_reuses_and_remaps_on_gpu)..\scripts\test.ps1(cargo test --workspace -- --test-threads=4, debug): 1277 passed, 0 failed, 46 ignored across 23 test binaries before rebase (and 1280 passed after rebase onto3f27770, with 1 unrelated pre-existinggpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrierfailure).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 D3D12.X: CreateReservedResource for each streamed title texture costs ~1 ms on AMD and stalls the title's render thread during world loading #1268 was measured on AMD RDNA2 and should see the largest streaming speedup there).xboxbvhbuilder.dll40-bit VA exception).AI use