Skip to content

D3D12.X: recycle released reserved sampled textures by description and state - #2436

Open
saintwolf wants to merge 1 commit into
xcl-dev:mainfrom
saintwolf:vram/recycle-reserved-textures
Open

saintwolf wants to merge 1 commit into
xcl-dev:mainfrom
saintwolf:vram/recycle-reserved-textures

Conversation

@saintwolf

@saintwolf saintwolf commented Nov 25, 2026 •

Copy link
Copy Markdown

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 skip CreateReservedResource and GetResourceTiling. 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 uniform D3D12_RESOURCE_STATES when all subresources share a single state (states.len() == 1), or None for mixed-state / untracked textures.
  • crates/xcl/src/hle/d3d12x/real.rs: hooks SetPrivateData, SetPrivateDataInterface, and SetName on Kind::Resource to track resources with application private data or debug names; on final Release (n == 0) while late_release holds the last PC ref, parks eligible untagged place_pages sampled textures with their actual uniform D3D12 state (excluding any resource with private data so custom GUID payloads and SetPrivateDataInterface COM references never leak across lifetimes); exposes note_reserved so reused pointers re-register in RESERVED.
  • crates/xcl/src/hle/d3d12x/late_release.rs: once every live GPU queue is past a batch's fence, hands parked textures to vram::recycle_ready instead of destroying them; calls vram::drain_recycled() in drain_known and keeps the worker started while vram::pending_recycles() is non-empty.
  • crates/xcl/src/hle/d3d12x/vram.rs: adds ReservedKey, a per-device pending_recycles fence-gated staging FIFO (PendingRecycle), and a bounded per-device ReservedPool (512 idle entries/device, generation-tombstoned FIFO eviction with bounded order compaction, evicted entries dropped outside PAGES.lock(), opt-out via XCL_RESERVED_POOL=0). recycle_ready unmaps any still-mapped tiles (pages.unmap) and stages the texture with pages.value so it stays owned until the tile-mapping queue passes that fence mark before drain_recycled() promotes it into ReservedPool. place_on_pages pops matching pooled reserved textures via QueryInterface and reuses their cached tile count, skipping CreateReservedResource and GetResourceTiling. Adds unit tests (reuse hit, state isolation, FIFO eviction, cap=0, repeated take/repark tombstoning + cap-FIFO ordering, pending-mark retention) and GPU tests (fence-gated unmap/recycle/rebind, private-data exclusion).

Tested

  • Windows 11 (build 26300), NVIDIA GeForce RTX 4070 SUPER (driver 32.0.16.2140), AMD Ryzen 7 7800X3D, rustc 1.100.0 (0ef1bc386 2026-11-09), DXC/DXIL 1.8.2502.11.
  • .\scripts\test.ps1 (cargo test --workspace -- --test-threads=4, debug) on exact head 3d6e230c: 1428 passed, 0 failed, 46 ignored across 37 test binaries, including all 24 hle::d3d12x::vram::tests (reserved_pool_reuses_matching_key_isolates_state_and_evicts_fifo, recycled_texture_stays_owned_until_its_mapping_mark_completes, reserved_pool_repark_tombstones_stale_order_and_preserves_fifo, reserved_resource_recycle_unmaps_reuses_and_remaps_on_gpu, and reserved_resource_with_private_data_is_excluded_from_recycle).
  • SKIPPED GPU tests on this adapter (27 total): 21 no wave64, 3 per-lane form #1426 refusals (V_CVT_F16_F32, V_MUL_F16, V_PK_MUL_F16), 1 cannot disable the driver cache (Windows Developer Mode is required) (0x887A002D), 1 no xgameruntime.dll, 1 no heap windows.
  • Isolated #1268 microbenchmark on RTX 4070 SUPER (release, 2,000 iterations each):
    • 256x256 BC1 (9 mips): CreateReservedResource + GetResourceTiling + Release 222.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).
  • Paired retail world-load A/B run (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=1 cleanly recycled 32+ streamed reserved textures live before both arms hit the same pre-existing xboxbvhbuilder.dll 40-bit VA exception (~112–116 s), with 0 device removals and -352 MB lower peak commit (28,903 MB vs 29,255 MB).

Regression run

xcl-smoke v1
commit: 3f4495a2b325ae5a9df314dd86d10327502b5cf5
gpu: NVIDIA GeForce RTX 4070 SUPER
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 971 (PresentX 971)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 14961 MB
xcl-smoke v1
commit: 3d6e230c26c508454f36a178b9fe3362920c2abf
gpu: NVIDIA GeForce RTX 4070 SUPER
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 983 (PresentX 983)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14970 MB

Not tested

AI use

  • Antigravity (Gemini 4 Neon) for issue diagnosis, implementation, tests, benchmarking, and PR drafting; all builds, tests, benchmarks, and retail runs were executed locally on the hardware above.

@saintwolf
saintwolf force-pushed the vram/recycle-reserved-textures branch from e2cf935 to bebf2dd Compare November 25, 2026 18:53
@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head e2cf9357ba193507dfbc19d4e3b040b63ee957e7 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (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 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused 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.
    • Both PR tests passed (no skips): hle::d3d12x::vram::tests::reserved_pool_reuses_matching_key_isolates_state_and_evicts_fifo and reserved_resource_recycle_unmaps_reuses_and_remaps_on_gpu.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: e2cf9357ba193507dfbc19d4e3b040b63ee957e7
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1598 (PresentX 1598)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13927 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.

raylitebull added a commit that referenced this pull request Nov 25, 2026
Port upstream PR #2436 (by Saintwolf, adapted for #2306 lazy level pages and #2275 multi-queue retirement) onto amd-dev.

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 (#1268).

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), also caching the #2306 Levels tiling layout so XCL_TEXTURE_LEVEL_PAGES=1 placements skip both CreateReservedResource and GetResourceTiling on reuse. 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 (skipping unmap for lazy textures that had zero mapped levels) and parks the ID3D12Resource for reuse.

Fixes #1268. Part of #1833.

Assisted-by: Antigravity (Gemini 4 Neon High)
raylitebull added a commit that referenced this pull request Nov 25, 2026
Port upstream PR #1835 (commits 2441d59..5005620) cleanly onto amd-dev with #2436 reserved-texture recycling and #2306 lazy levels.

Small sampled textures (< 64 KiB) previously each consumed a full 64 KiB tile plus CreateReservedResource, GetResourceTiling, and UpdateTileMappings overhead. Pack eligible sub-64 KiB sampled textures (when not aliasing an existing live 64 KiB GPU-owned page) into shared 4 KiB-aligned 4 MiB default heaps via CreatePlacedResource in vram_small.rs, reclaiming their 4 KiB slots on release in vram::forget_for_recycle before falling through to reserved-page recycling.

Fixes #1835.

Assisted-by: Antigravity (Gemini 4 Neon High)
raylitebull added a commit that referenced this pull request Nov 25, 2026
…ation

Keep #[cfg(test)] helpers compiling cleanly after #2181 (PsInterface::early_depth), 32f0967 (Effects::bvh_intersect), #2345 (sparse State quarantine/queue_fences), and #1514/#2436 (Pages::bind 6-arg 3-tuple).

Assisted-by: Antigravity (Gemini 4 Neon High)
@SlopTart

Copy link
Copy Markdown

gpu_ suite (cold cache): 160 passed / 4 failed, no crashes. Three are the known baseline trio on this lane; the fourth is gpu_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

Copy link
Copy Markdown
Contributor

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):
gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier
  assertion failed: group barriers in the program (lower_dxil.rs:1155)

The lowered program is missing an expected group barrier (or emits one where none is expected). Needs a fix before merge.

— Devin

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@saintwolf
saintwolf force-pushed the vram/recycle-reserved-textures branch from bebf2dd to 2f92cc8 Compare November 25, 2026 20:28
@saintwolf

Copy link
Copy Markdown
Author

@bmjask Good catch — fixed in 2f92cc8 (also rebased onto main 6d12f58, picking up #2420 so the full workspace suite passes with 0 failures — cc @DavidM1911):

  • ReservedPool now tracks a monotonic next_gen: u64 and live_gen: HashMap<usize, u64> with generation-tagged order / by_key entries.
  • take() removes the pointer from live_gen (immediately tombstoning any stale order entry) and calls compact_order(), which prunes front tombstones and compacts order whenever order.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.
  • Added reserved_pool_repark_tombstones_stale_order_and_preserves_fifo covering 100× below-cap take/repark cycles behind an idle front entry, cap=2 repark FIFO ordering, and cap=3 non-front tombstone skipping.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
…extures)

Integrates xcl-dev#2436 cleanly alongside xcl-dev#2385 (top-mip shedding) and xcl-dev#2474
(foreign-thread release_cleanup).

Assisted-by: Antigravity (Gemini 4 Neon)
@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Independent AMD report for 2f92cc841ad65e2dc7e63fea17d227a71e44f16b.

Tested

  • AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 build 26200, rustc 1.100.0, debug profile, DXC from Windows SDK 10.0.26100.0, XCL_ADAPTER=radeon. Exact PR head (not a local merge onto main); main at the time was 6d12f58a.
  • cargo test --workspace --no-fail-fast -j 4 -- --test-threads=4: 1425 passed, 1 failed, 46 ignored. The one failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722: res[30] = 0x1, CPU 0x7fffffff); it fails identically on main 6d12f58a on this adapter (cargo test -p xcl --lib fuzz_validate_and_gpu_1), so it is not caused by this PR.
  • 7 SKIPPED lines: 6 f16_programs_on_the_gpu / f32_programs_on_the_gpu per-lane cases refused for V_MUL_F16, V_PK_MUL_F16 or V_CVT_F16_F32, and heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • The new vram::tests::reserved_pool_* and reserved_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

Copy link
Copy Markdown
Contributor

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

@luckyteagirl luckyteagirl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vram.rs:1177–1185: this returns the same native ID3D12Resource for a new texture without clearing its ID3D12Object private 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, GetPrivateData on B can return A's payload. SetPrivateDataInterface also 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.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
@saintwolf
saintwolf force-pushed the vram/recycle-reserved-textures branch from 2f92cc8 to bab2f53 Compare November 26, 2026 15:47
@saintwolf

Copy link
Copy Markdown
Author

@luckyteagirl Good catch — fixed in bab2f537:

  • crates/xcl/src/hle/d3d12x/real.rs now hooks SetPrivateData, SetPrivateDataInterface, and SetName on Kind::Resource, recording any tagged resource pointer in PRIVATE_DATA.
  • On final Release (n == 0), res_release removes the pointer from PRIVATE_DATA and skips vram::park_recyclable if it was tagged, so late_release destroys the native ID3D12Resource normally — preserving SetPrivateDataInterface COM reference lifetimes and preventing any custom GUID payload or debug name from leaking to a later texture.
  • Added GPU test hle::d3d12x::vram::tests::reserved_resource_with_private_data_is_excluded_from_recycle covering both SetPrivateData (custom GUID payload) and SetPrivateDataInterface (attached ID3D12Fence COM object), confirming fresh resources see GetPrivateData fail while untagged resources on the same path still recycle.

@Prime1997

Copy link
Copy Markdown
Collaborator

Please keep recycled textures alive through their tile-unmap fence.

At bab2f53750e703f64af5b84f3a58ff4e06a67656, recycle_ready queues an unmap after the earlier retirement fences have already completed. It immediately adds the texture to the ready pool. The eviction path and the failed reuse QueryInterface path can release the pool’s last reference before the new mapping fence completes. XCL has already seen in-flight release errors on this queue in #1747.

Please retain pending textures behind their own unmap fence, then add them to the ready pool or release them after completion. A CPU test with a fake fence can assert that a pending texture stays retained when the pool is full or reuse fails. The current GPU fixture waits for the mapping fence before its final release and leaves this ordering untested.

Local result: I tested this head applied to main 8b957bec6f82495aec940944c6bf47faa02db590 on Windows with an RTX 3060 Ti. All four targeted reserved-texture tests ran. 4 passed, 0 failed, 0 ignored, 0 explicit skips, with 1,348 filtered out per invocation. I rebuilt with cargo test --locked -p xcl --lib --no-run in an isolated worktree and ran each fixture separately with --test-threads=1 --nocapture. The fence finding comes from source review.

AI use: Codex (GPT-6) inspected the release and mapping paths, ran the focused tests, and verified the recorded results. Optional temporary Discord for coordinating contributor work, testing, and comparing results.

@thehollowedone

Copy link
Copy Markdown

Follow-up to Prime1997's tile-unmap lifetime review, tested against exact head bab2f537. The review point holds: the old release batch can finish, recycle_ready then queues a new UpdateTileMappings(NULL) and publishes the resource to ReservedPool before that mapping queue's fence completes. A pool eviction or failed reuse QueryInterface can drop its last COM reference in that gap.

I tested the attached uncommitted candidate. It keeps the owned resource in a per-device pending FIFO with the mapping queue's fence value, including when the resource was already unmapped by an earlier queued update. The existing late-release worker promotes completed entries to the ready pool; native releases of evicted entries happen outside PAGES.lock(). It starts the worker even if the earlier release batch is empty, so promotion needs no later title submission. Pending work does not extend the release path's busy-spin. A failed mapping-queue signal leaves the resource held rather than publishing it prematurely.

On Windows 11, RTX 3080 Ti / driver 621.35, Ryzen 7 9800X3D, rustc 1.99.1 MSVC:

  • cargo test --offline --locked -p xcl --lib recycled_texture_stays_owned_until_its_mapping_mark_completes -- --test-threads=1: 1 passed, 0 failed, 0 ignored, 0 skips. Capacity-one pool pressure cannot take or evict a pending resource; completion makes it reusable.
  • cargo test --offline --locked -p xcl --lib reserved_resource -- --test-threads=1: 2 passed, 0 failed, 0 ignored, 0 skips. The native fixture holds the mapping queue behind a fence, checks no early reuse, then releases the gate and reuses the same resource. The existing private-data fixture still checks fresh-resource isolation and now waits for the unmap fence before expecting reuse.
  • cargo build --offline --locked --workspace: passed. cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4: 1,427 passed, 1 failed, 46 ignored, with 25 explicit GPU skips (21 no wave64, 3 refused per-lane forms, 1 no heap windows). The sole failure was console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk (DXIL not compiled yet). I did not run the full suite on this PR's base, so that failure is not attributed here.

No paired clean-tree smoke run, retail title, AMD, or Intel test was done for this local candidate. The diff is a review suggestion for the existing PR, not a merge-readiness claim.

Candidate diff against bab2f53
diff --git a/crates/xcl/src/hle/d3d12x/late_release.rs b/crates/xcl/src/hle/d3d12x/late_release.rs
index 624d6d77..07b69b7b 100644
--- a/crates/xcl/src/hle/d3d12x/late_release.rs
+++ b/crates/xcl/src/hle/d3d12x/late_release.rs
@@ -107,7 +107,7 @@ pub unsafe fn hold(res: usize) {
         std::hint::spin_loop();
         drain_known(false);
     }
-    if HELD.lock().unwrap().as_ref().is_none_or(Held::is_empty) {
+    if HELD.lock().unwrap().as_ref().is_none_or(Held::is_empty) && !super::vram::pending_recycles() {
         return;
     }
     // A thread of its own lets the held ones go: the title may release a resource and then
@@ -125,6 +125,7 @@ pub unsafe fn hold(res: usize) {
 /// Release what every queue XCL knows of is past: the title's, the tile-mapping one, the
 /// upload ones.
 pub unsafe fn drain_known(seal_now: bool) {
+    super::vram::drain_recycled();
     if HELD.lock().unwrap().as_ref().is_none_or(Held::is_empty) {
         return;
     }
@@ -149,6 +150,7 @@ pub unsafe fn drain_known(seal_now: bool) {
         let f: unsafe extern "system" fn(*mut c_void) -> u32 = std::mem::transmute(super::real::orig_fn(res as *mut c_void, 2));
         f(res as *mut c_void);
     }
+    super::vram::drain_recycled();
 }
 
 #[cfg(test)]
diff --git a/crates/xcl/src/hle/d3d12x/vram.rs b/crates/xcl/src/hle/d3d12x/vram.rs
index 5c74a150..9b021193 100644
--- a/crates/xcl/src/hle/d3d12x/vram.rs
+++ b/crates/xcl/src/hle/d3d12x/vram.rs
@@ -254,6 +254,25 @@ impl ReservedPool {
     }
 }
 
+/// Owns the retired resource until the mapping queue finishes its last tile update.
+struct PendingRecycle {
+    key: ReservedKey,
+    raw: usize,
+    total: u32,
+    mark: u64,
+}
+
+fn promote_pending(pool: &mut ReservedPool, pending: &mut std::collections::VecDeque<PendingRecycle>, completed: u64) -> Vec<usize> {
+    let mut evicted = Vec::new();
+    while pending.front().is_some_and(|item| item.mark <= completed) {
+        let item = pending.pop_front().unwrap();
+        if let Some(old) = pool.push(item.key, item.raw, item.total) {
+            evicted.push(old);
+        }
+    }
+    evicted
+}
+
 /// Metadata for a released reserved sampled texture awaiting GPU completion in `late_release`.
 #[derive(Clone, Copy)]
 pub(super) struct RecycleInfo {
@@ -264,6 +283,32 @@ pub(super) struct RecycleInfo {
 }
 
 static PARKING: Mutex<Option<std::collections::HashMap<usize, RecycleInfo>>> = Mutex::new(None);
+static PENDING_RECYCLES: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
+
+pub(super) fn pending_recycles() -> bool {
+    PENDING_RECYCLES.load(std::sync::atomic::Ordering::Acquire) != 0
+}
+
+/// Promote finished mapping-queue updates before a resource can be reused or evicted.
+/// Native Releases run outside `PAGES.lock()`.
+pub(super) unsafe fn drain_recycled() {
+    if !pending_recycles() {
+        return;
+    }
+    let mut evicted = Vec::new();
+    {
+        let mut g = PAGES.lock().unwrap();
+        for pages in g.values_mut().flatten() {
+            let before = pages.pending_recycles.len();
+            evicted.extend(promote_pending(&mut pages.reserved_pool, &mut pages.pending_recycles, pages.fence.GetCompletedValue()));
+            PENDING_RECYCLES.fetch_sub(before - pages.pending_recycles.len(), std::sync::atomic::Ordering::Release);
+        }
+    }
+    for old in evicted {
+        let f: unsafe extern "system" fn(*mut c_void) -> u32 = std::mem::transmute(super::real::orig_fn(old as *mut c_void, 2));
+        f(old as *mut c_void);
+    }
+}
 
 pub(super) fn forget_for_recycle(resource: usize, held: bool) -> Option<RecycleInfo> {
     let placed = PLACED_TEXTURES.lock().unwrap().as_mut().is_some_and(|textures| textures.remove(&resource));
@@ -283,7 +328,7 @@ pub(super) fn park_recyclable(resource: usize, mut info: RecycleInfo, final_stat
 }
 
 /// Called by `late_release` once every live GPU queue is past the batch containing `resource`.
-/// Returns `true` when `resource` was unmapped and parked in the per-device reuse pool (so
+/// Returns `true` when `resource` was retained for later reuse (so
 /// `late_release` must not call `Release` on it).
 pub(super) unsafe fn recycle_ready(resource: usize) -> bool {
     let Some(info) = PARKING.lock().unwrap().as_mut().and_then(|m| m.remove(&resource)) else {
@@ -292,7 +337,7 @@ pub(super) unsafe fn recycle_ready(resource: usize) -> bool {
     if !reserved_pool_enabled() {
         return false;
     }
-    let evicted = {
+    {
         let mut g = PAGES.lock().unwrap();
         let Some(Some(pages)) = g.get_mut(&info.dev_key) else {
             return false;
@@ -302,11 +347,8 @@ pub(super) unsafe fn recycle_ready(resource: usize) -> bool {
                 pages.unmap(res, info.total);
             }
         }
-        pages.reserved_pool.push(info.key, resource, info.total)
-    };
-    if let Some(old) = evicted {
-        let f: unsafe extern "system" fn(*mut c_void) -> u32 = std::mem::transmute(super::real::orig_fn(old as *mut c_void, 2));
-        f(old as *mut c_void);
+        pages.pending_recycles.push_back(PendingRecycle { key: info.key, raw: resource, total: info.total, mark: pages.value });
+        PENDING_RECYCLES.fetch_add(1, std::sync::atomic::Ordering::Release);
     }
     true
 }
@@ -781,6 +823,8 @@ struct Pages {
     reservable_cache: std::collections::HashMap<(i32, u32), bool>,
     /// idle reserved sampled textures kept for reuse by `(desc, state)` (#1268)
     reserved_pool: ReservedPool,
+    /// released resources awaiting completion of the tile-mapping queue's last update
+    pending_recycles: std::collections::VecDeque<PendingRecycle>,
     /// reusable scratch buffers for `map()`
     scratch_heaps: Vec<u32>,
     scratch_flags: Vec<D3D12_TILE_RANGE_FLAGS>,
@@ -821,6 +865,7 @@ impl Pages {
             waited: std::collections::HashMap::new(),
             reservable_cache: std::collections::HashMap::new(),
             reserved_pool: ReservedPool::new(RESERVED_POOL_MAX),
+            pending_recycles: std::collections::VecDeque::new(),
             scratch_heaps: Vec::new(),
             scratch_flags: Vec::new(),
             scratch_offsets: Vec::new(),
@@ -2435,6 +2480,31 @@ mod tests {
         assert_eq!(disabled.push(k_common, 0x4000, 1), Some(0x4000));
     }
 
+    #[test]
+    fn recycled_texture_stays_owned_until_its_mapping_mark_completes() {
+        let desc = D3D12_RESOURCE_DESC {
+            Dimension: D3D12_RESOURCE_DIMENSION_TEXTURE2D,
+            Width: 256,
+            Height: 256,
+            DepthOrArraySize: 1,
+            MipLevels: 1,
+            Format: windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_BC1_UNORM,
+            SampleDesc: windows::Win32::Graphics::Dxgi::Common::DXGI_SAMPLE_DESC { Count: 1, Quality: 0 },
+            ..Default::default()
+        };
+        let key = ReservedKey::from_desc(&desc, D3D12_RESOURCE_STATE_COMMON.0 as u32);
+        let mut pool = ReservedPool::new(1);
+        let mut pending = std::collections::VecDeque::from([PendingRecycle { key, raw: 0x1000, total: 1, mark: 2 }]);
+        assert!(promote_pending(&mut pool, &mut pending, 1).is_empty());
+        assert_eq!(pool.take(&key), None, "the pending resource cannot be reused");
+        assert_eq!(pool.push(key, 0x2000, 1), None);
+        assert_eq!(pool.push(key, 0x3000, 1), Some(0x2000));
+        assert_eq!(pending.len(), 1, "pool pressure cannot evict the pending resource");
+        assert_eq!(promote_pending(&mut pool, &mut pending, 2), vec![0x3000]);
+        assert!(pending.is_empty());
+        assert_eq!(pool.take(&key), Some((0x1000, 1)));
+    }
+
     #[test]
     fn reserved_pool_repark_tombstones_stale_order_and_preserves_fifo() {
         use windows::Win32::Graphics::Dxgi::Common::{DXGI_FORMAT_BC1_UNORM, DXGI_SAMPLE_DESC};
@@ -2529,9 +2599,22 @@ mod tests {
 
             let key = ReservedKey::from_desc(&desc, D3D12_RESOURCE_STATE_COMMON.0 as u32);
             let (used1, extra1) = pages.bind(&dev, borrowed, 0x2000_0000, Some(total as u64 * PAGE as u64), total).expect("initial bind");
+            let gate: ID3D12Fence = dev.CreateFence(0, D3D12_FENCE_FLAG_NONE).unwrap();
+            pages.queue.Wait(&gate, 1).unwrap();
             pages.unmap(borrowed, total);
             pages.release_tiles(used1, extra1, std::time::Instant::now(), false);
-            assert_eq!(pages.reserved_pool.push(key, raw, total), None);
+            let mark = pages.value;
+            pages.pending_recycles.push_back(PendingRecycle { key, raw, total, mark });
+            let before_completion = pages.fence.GetCompletedValue();
+            let early = promote_pending(&mut pages.reserved_pool, &mut pages.pending_recycles, before_completion);
+            let early_hit = pages.reserved_pool.take(&key);
+            gate.Signal(1).unwrap();
+            let _ = pages.fence.SetEventOnCompletion(mark, windows::Win32::Foundation::HANDLE::default());
+            assert!(before_completion < mark, "the mapping queue was held behind the gate");
+            assert!(early.is_empty() && early_hit.is_none(), "a pending unmap must not publish the texture");
+            assert_eq!(pages.pending_recycles.len(), 1);
+            assert!(promote_pending(&mut pages.reserved_pool, &mut pages.pending_recycles, pages.fence.GetCompletedValue()).is_empty());
+            assert!(pages.pending_recycles.is_empty());
 
             // Mismatched state does not reuse it.
             let wrong_state = ReservedKey::from_desc(&desc, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE.0 as u32);
@@ -2648,6 +2731,27 @@ mod tests {
             drop(ID3D12Resource::from_raw(raw_c));
             late_release::drain_known(true);
 
+            // C may still be held by the mapping queue after its title-side Release.
+            let start = std::time::Instant::now();
+            let pending_mark = loop {
+                late_release::drain_known(true);
+                let g = PAGES.lock().unwrap();
+                let pages = g.get(&(dev.as_raw() as usize)).and_then(Option::as_ref).unwrap();
+                if pages.reserved_pool.live_gen.contains_key(&(raw_c as usize)) {
+                    break None;
+                }
+                if let Some(item) = pages.pending_recycles.iter().find(|p| p.raw == raw_c as usize) {
+                    break Some((pages.fence.clone(), item.mark));
+                }
+                assert!(start.elapsed() < std::time::Duration::from_secs(5), "C did not reach the recycle queue");
+                drop(g);
+                std::thread::yield_now();
+            };
+            if let Some((fence, mark)) = pending_mark {
+                let _ = fence.SetEventOnCompletion(mark, windows::Win32::Foundation::HANDLE::default());
+                drain_recycled();
+            }
+
             let raw_d = place(va).expect("place D");
             assert_eq!(raw_d, raw_c, "untagged texture C should still recycle into D");
             drop(ID3D12Resource::from_raw(raw_d));

AI use: Codex (GPT-6.2 Sol) inspected the ownership path, implemented and checked the local candidate, ran the tests, and drafted this comment.

@futurepro62

Copy link
Copy Markdown

NVIDIA and AMD full-suite run, to go with the reports above by Prime1997, thehollowedone, since none of them covers AMD. Tested exact head bab2f537 (on its base 6d12f58).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1415 passed, 0 failed, 44 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, dispatch_chain_native_wave64_builds_whole, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: reserved_pool_reuses_matching_key_isolates_state_and_evicts_fifo, reserved_pool_repark_tombstones_stale_order_and_preserves_fifo, reserved_resource_recycle_unmaps_reuses_and_remaps_on_gpu, reserved_resource_with_private_data_is_excluded_from_recycle.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1426 passed, 0 failed, 46 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 8b957bec too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

…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
saintwolf force-pushed the vram/recycle-reserved-textures branch from bab2f53 to 3d6e230 Compare November 26, 2026 17:48
@saintwolf

Copy link
Copy Markdown
Author

@Prime1997 @thehollowedone Fixed in 3d6e230c — recycled textures now stay owned until their tile-mapping queue fence mark completes:

  • crates/xcl/src/hle/d3d12x/vram.rs: recycle_ready queues pages.unmap (if mapped) and stages the texture in a per-device pending_recycles: VecDeque<PendingRecycle> with pages.value rather than publishing immediately to ReservedPool. drain_recycled() promotes completed entries (mark <= pages.fence.GetCompletedValue()) into ReservedPool and calls COM Release on any evicted entries outside PAGES.lock().
  • crates/xcl/src/hle/d3d12x/late_release.rs: drain_known calls vram::drain_recycled(), and hold keeps the xcl-late-release worker started whenever vram::pending_recycles() is non-empty so promotion never depends on a later title submission.
  • Added recycled_texture_stays_owned_until_its_mapping_mark_completes, updated reserved_resource_recycle_unmaps_reuses_and_remaps_on_gpu with a GPU fence gate on the tile-mapping queue, and updated reserved_resource_with_private_data_is_excluded_from_recycle to wait on the mapping mark before asserting reuse.
  • Verified with full .\scripts\test.ps1 (0 failures) and a fresh 60 s scripts/smoke.ps1 run at 3d6e230c (updated in the PR description).

@Decodere

Copy link
Copy Markdown
Contributor

Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2436 updated head 3d6e230c26c508454f36a178b9fe3362920c2abf (exact parent & merge-base 6d12f58a229bc73889878a448c64dc3af25eeba0). Measurements and targeted test results only; not a full source review.

Setup

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6 cores / 12 threads), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200
  • Toolchain / caches: rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)
  • Workload: Retail workload title: 29640639 via scripts/smoke.ps1 -Seconds 60 (XCL_NETWORK=0, default flags, no input)

Targeted RTX 4060 release unit & GPU tests (3d6e230c)

  • cargo test --release -p xcl --lib reserved_pool_reuses_matching_key_isolates_state_and_evicts_fifo -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib recycled_texture_stays_owned_until_its_mapping_mark_completes -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib reserved_pool_repark_tombstones_stale_order_and_preserves_fifo -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib hle::d3d12x::vram:: (3 consecutive parallel passes): 24 passed, 0 failed, 1 ignored on all 3 passes (2.41 s / 2.41 s / 2.41 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib hle::d3d12x::title_textures:: (3 consecutive parallel passes): 19 passed, 0 failed, 0 ignored on all 3 passes (0.73 s / 0.69 s / 0.69 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib hle::d3d12x::real::: 59 passed, 0 failed, 0 ignored (0.36 s, 0 SKIPPED).

Paired 60 s RTX 4060 smoke (exact parent 6d12f58a vs 3d6e230c)

Both runs completed cleanly at steady 60/2 s pacing with 0 device removals and 0 crashes (3d6e230c vs 6d12f58a xcl.log: 6,175 / 6,114 MB vs 6,176 / 6,116 MB peak/end local VRAM, 4,683 MB end non-local VRAM on both, 19,699 vs 19,600 translated draws / 1,024 dispatches with 0 skipped).

Exact parent (6d12f58a):

xcl-smoke v1
commit: 6d12f58a229bc73889878a448c64dc3af25eeba0
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1606 (PresentX 1606)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14004 MB

PR #2436 head (3d6e230c):

xcl-smoke v1
commit: 3d6e230c26c508454f36a178b9fe3362920c2abf
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1629 (PresentX 1629)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14019 MB

Limits of coverage

  • Full workspace test suite was not run on 3d6e230c (only the 3 new tests individually, 3 parallel passes each of vram:: and title_textures::, real::, release build, and exact-parent paired 60 s smokes).
  • The 60 s no-input menu/intro smoke confirms clean steady-state behavior on an 8 GB desktop RTX 4060, but extended in-world reserved-texture churn and pool eviction pressure were covered only by the targeted release unit tests above (including recycled_texture_stays_owned_until_its_mapping_mark_completes).
  • Single discrete NVIDIA 8 GB GPU (RTX 4060) on native Windows 11; no AMD, Intel, or Wine/Linux run on this host.

AI use

Ran the targeted release unit/GPU tests, release build, and exact-parent paired quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts, timings, memory figures, and smoke blocks were extracted directly from cargo test, xcl.log, and scripts/smoke.ps1 outputs.

@oni-swr

oni-swr commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Independent AMD report for 3d6e230c26c508454f36a178b9fe3362920c2abf.

Tested

  • AMD Radeon RX 7800 XT (driver 32.0.31035.1003, XCL_ADAPTER unset), Ryzen 7 5700X3D, 64 GB, Windows 11 build 26200, rustc 1.100.0, debug profile for tests / release for xcl.exe, DXC from the Windows SDK. Exact PR head in a clean detached checkout (not merged onto main), own target directory per checkout; main was 8b957bec, merge-base below. Merge-base: 6d12f58a229bc73889878a448c64dc3af25eeba0.
  • cargo test --workspace --no-fail-fast -j 4 -- --test-threads=4 --nocapture: 1427 passed, 1 failed, 46 ignored. The one failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722: res[30] = 0x1, CPU 0x7fffffff); it fails identically on main 6d12f58a on this adapter (cargo test -p xcl --lib fuzz_validate_and_gpu_1), so it is not caused by this PR.
  • The first run had 3 e2e failures from my setup (the test title was not built next to the e2e binary); after cargo build --workspace the e2e test passed (cargo test -p xcl --test e2e), counts below include that rerun.
  • 7 SKIPPED lines: 6 f16_programs_on_the_gpu / f32_programs_on_the_gpu per-lane cases refused for V_MUL_F16, V_PK_MUL_F16 or V_CVT_F16_F32, and heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • The new vram::tests passed, including recycled_texture_stays_owned_until_its_mapping_mark_completes and the GPU test reserved_resource_recycle_unmaps_reuses_and_remaps_on_gpu.

Regression run (scripts/smoke.ps1 -Seconds 60 -Title retail-title, one 60 s run each, same retail title, built from the merge-base and from this head)

xcl-smoke v1
commit: 6d12f58a229bc73889878a448c64dc3af25eeba0
gpu: AMD Radeon RX 7800 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1413 (PresentX 1413)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13754 MB
xcl-smoke v1
commit: 3d6e230c26c508454f36a178b9fe3362920c2abf
gpu: AMD Radeon RX 7800 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1381 (PresentX 1381)
presents per 2 s (last 3): 57 14 54
device removals: 0
crashes: 0
peak commit: 16622 MB

No device removal, no crash; 1381 frames vs 1413 on the merge-base (97.7 %), peak commit 16622 MB vs 13754 MB (121 %, under the 125 % limit). The last-3 presents-per-2-s sample of the PR run was 57 14 54; I did not investigate that dip and a single run cannot say whether it repeats.

Not tested

  • NVIDIA / other adapters, more than one run per build (frame counts vary from run to run), XCL_ADAPTER overrides, any title other than the one retail title. No game data was committed or posted.

AI use

Claude Code (Claude Sonnet 5.5) ran the tests and drafted this report. No game files, dumps, shader names or retail hashes are included; the title in the xcl-smoke blocks is replaced with retail-title.

koboshchan pushed a commit to koboshchan/xcl that referenced this pull request Nov 26, 2026
Port upstream PR xcl-dev#1835 (commits 2441d59..5005620) cleanly onto amd-dev with xcl-dev#2436 reserved-texture recycling and xcl-dev#2306 lazy levels.

Small sampled textures (< 64 KiB) previously each consumed a full 64 KiB tile plus CreateReservedResource, GetResourceTiling, and UpdateTileMappings overhead. Pack eligible sub-64 KiB sampled textures (when not aliasing an existing live 64 KiB GPU-owned page) into shared 4 KiB-aligned 4 MiB default heaps via CreatePlacedResource in vram_small.rs, reclaiming their 4 KiB slots on release in vram::forget_for_recycle before falling through to reserved-page recycling.

Fixes xcl-dev#1835.

Assisted-by: Antigravity (Gemini 4 Neon High)

# Conflicts:
#	crates/xcl/src/hle/d3d12x/title_textures.rs
#	crates/xcl/src/hle/d3d12x/vram.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D3D12.X: CreateReservedResource for each streamed title texture costs ~1 ms on AMD and stalls the title's render thread during world loading