Bound GPU resource pools and preserve held mip levels with tiles #3828

Closed
1mosce wants to merge 1 commit from upstream-pr/3828 into main
1mosce commented 2026-11-30 08:29:43 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by 1mosce on 2026-11-30T08:29:43Z.


Completed uploads kept staging ranges quarantined for another two seconds, tile mode disabled held-level trimming even for ordinary textures, and pressure could repeatedly recreate readback resources. This patch corrects those lifetimes, pools readback ranges, and accounts for actual texture-heap growth across concurrent workers.

Resource-lifetime fixes for review. The resource regressions have targeted coverage and the builds have run in game. Stable target frame times, complete leak freedom, and visual equivalence across city traversal are still unverified. This does not replace the shared-memory/coherency model.

What it changes

  • Lease disjoint ranges of persistently mapped readback buffers. Lists retain the leases through their GPU fences; only wholly idle blocks can be trimmed. Driver creation and final release occur outside the arena lock. Remove the redundant second readback pool.
  • Return staging ranges when their last owner has completed, with a GPU regression that holds a copy pending and checks its bytes before allowing reuse. Bound idle CPU-visible pool retention independently of the texture budget.
  • Reserve actual heap/committed allocation sizes across concurrent texture growers, including tile heaps. Optional work remains retryable when deferred and cannot bypass admission via committed fallback or diagnostic pipeline retries. Required draws retain their allocation path, so this is not a hard cap on total DXGI usage.
  • Preserve held-mip trimming for ordinary textures when tiles are enabled. Successfully reserved textures keep base level zero and their full virtual shape. Keep the existing tiled-upload staging policy.
  • Reclaim empty texture, staging and buffer blocks under the metadata lock, then release their driver objects after unlocking and before new growth. Include both TEXTURES and SMALL in the pool census.
  • Index occupied descriptor-owner slots, while rechecking the actual owner under its slot lock. Reuse bounded journal answers and submission-planner scratch without sharing live answers or caching old epochs.
  • Make the benchmark distinguish budget deferral from driver failure and count both host-pipeline failure log formats. Add the ownership and pressure rules in docs/readback-arena.md.

How it was tested

Base: 41adb55167fa778fcaa5dc36fa18a1fa8dacd657 (still upstream main when preparing this PR).

Hardware/profile: Windows, RTX 4070 Laptop 8 GiB, 32 GiB system RAM; Series S, 640x360 internal / 1920x1080 output, DLSS Ultra Performance, frame generation off, RT builder off. Optimized Cargo diag builds with and without the diagnostics feature. No shader translation changes; wave-size validation is not applicable.

  • cargo check --locked -p victory-gpu --all-features: passed.
  • cargo test --locked -p victory-gpu --features diagnostics -- --test-threads=1: 1008 passed, 2 failed, 66 ignored. The failures are compose::tests::bgrx_plane_selects_a_typed_view and shader_cache::tests::every_switch_of_the_translator_is_in_the_key; both were reproduced on clean main..
  • Pool filter: 29 passed, 4 ignored. The new final-release regression failed before the fix because the pool mutex was held, then passed for allocation, idle trimming and allocation-backoff paths.
  • Isolated staging_reuses_completed_uploads_without_a_timed_quarantine: passed on the GPU, including pending-copy protection and zeroed reuse after completion.
  • levels_on_demand_on_the_card and levels_reuse_resident_tiles_at_budget: passed on the physical GPU with Windows Graphics Tools / D3D12 debug layer, reported tiled-resources tier 4. Heap-reservation coverage also passed on the adapter.
  • Held-mip adapter regression: exact mip bytes after coarse creation and fine-level regrowth with tiles off/on; reserved-resource base and identity preserved. It failed with tiles enabled before the fix.
  • Memory-pressure reclamation/regrowth byte checks passed with synchronous and relay paths. Replay's picture/buffer comparison passed; the debug layer still emits the same baseline error IDs (538, 1003, 527), so this is not a clean-debug-layer claim for the whole renderer.
  • Benchmark failure-parser Pester regression passed. git diff --check and staged asset policy passed (22 text files).

Game observations, not a matched FPS A/B: the 15.6-minute walk with the held-mip fix reached 5,412 MiB local usage after warm-up and remained at least 1,242 MiB below the OS budget in that interval; staging ended at 192 MiB. A separate clean-base walk retained 1,408 MiB staging and reached 8,019 MiB local usage against a 6,983 MiB budget. Routes/cameras diverged, so these do not establish a percentage speedup. The final pool-release build completed a short muted smoke run: 4,799 MiB local usage / 7,180 MiB budget at the end, median 16.7 FPS, no untranslated shaders, refused host pipelines or crash-log entries. Runs ended through the harness, on copied saves.

Known checks/limitations: full workspace tests stop at the three BCPack oracle-parity failures also reproduced on clean main. Strict default/all-feature Clippy fails in unchanged upstream code; a warning-only audit is not a passing strict gate. Full-tree asset policy reports the existing hex-literal run in victory-loader/src/heap_sites/frame_users.rs; the staged patch passes. Dark character textures reproduce on both baseline and candidate. Ground-level city traversal and other GPUs are unverified. Memory growth while visiting new areas is not sufficient evidence either for or against a leak.

Checked for overlap

  • Searched open PRs for the same issues and affected files.
  • #2038 also releases empty pool heaps outside their locks and changes spare limits. There is direct overlap in pool.rs; reconcile the alternatives before merging both.
  • #2720 also indexes occupied descriptor slots, in a separate KeptSlots module with an identity cache. This patch keeps the existing owner storage and uses occupancy bits plus the locked owner check. These are alternative implementations of the same scan optimization.
  • #3406 also checks actual first-upload allocation cost; #1944 changes first-upload admission at the DXGI budget. This patch adds concurrent growth reservations and covers tile heaps and retry propagation. Their policies need reconciliation if combined.
  • #2657 addresses simultaneous host/VRAM pressure and #3381 changes low-water spare trimming. They overlap the pressure/retention paths; this patch does not introduce their shared-budget guard or tiering policy.
  • #3751 weighs held mip levels in diagnostics; this patch fixes ordinary-texture allocation when tiles are on and the two-pool census. #3723 is a broader tiered-memory design, beyond this patch's scope.

Implemented and tested with OpenAI Codex. No game assets, executable bytes, captures, shader dumps or private run logs are included.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5561730296 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3828). Originally posted by [1mosce](https://github.com/1mosce) on 2026-11-30T08:29:43Z. --- Completed uploads kept staging ranges quarantined for another two seconds, tile mode disabled held-level trimming even for ordinary textures, and pressure could repeatedly recreate readback resources. This patch corrects those lifetimes, pools readback ranges, and accounts for actual texture-heap growth across concurrent workers. **Resource-lifetime fixes for review.** The resource regressions have targeted coverage and the builds have run in game. Stable target frame times, complete leak freedom, and visual equivalence across city traversal are still unverified. This does not replace the shared-memory/coherency model. ## What it changes - Lease disjoint ranges of persistently mapped readback buffers. Lists retain the leases through their GPU fences; only wholly idle blocks can be trimmed. Driver creation and final release occur outside the arena lock. Remove the redundant second readback pool. - Return staging ranges when their last owner has completed, with a GPU regression that holds a copy pending and checks its bytes before allowing reuse. Bound idle CPU-visible pool retention independently of the texture budget. - Reserve actual heap/committed allocation sizes across concurrent texture growers, including tile heaps. Optional work remains retryable when deferred and cannot bypass admission via committed fallback or diagnostic pipeline retries. Required draws retain their allocation path, so this is not a hard cap on total DXGI usage. - Preserve held-mip trimming for ordinary textures when tiles are enabled. Successfully reserved textures keep base level zero and their full virtual shape. Keep the existing tiled-upload staging policy. - Reclaim empty texture, staging and buffer blocks under the metadata lock, then release their driver objects after unlocking and before new growth. Include both TEXTURES and SMALL in the pool census. - Index occupied descriptor-owner slots, while rechecking the actual owner under its slot lock. Reuse bounded journal answers and submission-planner scratch without sharing live answers or caching old epochs. - Make the benchmark distinguish budget deferral from driver failure and count both host-pipeline failure log formats. Add the ownership and pressure rules in `docs/readback-arena.md`. ## How it was tested Base: `41adb55167fa778fcaa5dc36fa18a1fa8dacd657` (still upstream main when preparing this PR). Hardware/profile: Windows, RTX 4070 Laptop 8 GiB, 32 GiB system RAM; Series S, 640x360 internal / 1920x1080 output, DLSS Ultra Performance, frame generation off, RT builder off. Optimized Cargo `diag` builds with and without the `diagnostics` feature. No shader translation changes; wave-size validation is not applicable. - `cargo check --locked -p victory-gpu --all-features`: passed. - `cargo test --locked -p victory-gpu --features diagnostics -- --test-threads=1`: 1008 passed, 2 failed, 66 ignored. The failures are `compose::tests::bgrx_plane_selects_a_typed_view` and `shader_cache::tests::every_switch_of_the_translator_is_in_the_key`; both were reproduced on clean main.. - Pool filter: 29 passed, 4 ignored. The new final-release regression failed before the fix because the pool mutex was held, then passed for allocation, idle trimming and allocation-backoff paths. - Isolated `staging_reuses_completed_uploads_without_a_timed_quarantine`: passed on the GPU, including pending-copy protection and zeroed reuse after completion. - `levels_on_demand_on_the_card` and `levels_reuse_resident_tiles_at_budget`: passed on the physical GPU with Windows Graphics Tools / D3D12 debug layer, reported tiled-resources tier 4. Heap-reservation coverage also passed on the adapter. - Held-mip adapter regression: exact mip bytes after coarse creation and fine-level regrowth with tiles off/on; reserved-resource base and identity preserved. It failed with tiles enabled before the fix. - Memory-pressure reclamation/regrowth byte checks passed with synchronous and relay paths. Replay's picture/buffer comparison passed; the debug layer still emits the same baseline error IDs (538, 1003, 527), so this is **not** a clean-debug-layer claim for the whole renderer. - Benchmark failure-parser Pester regression passed. `git diff --check` and staged asset policy passed (22 text files). **Game observations, not a matched FPS A/B:** the 15.6-minute walk with the held-mip fix reached 5,412 MiB local usage after warm-up and remained at least 1,242 MiB below the OS budget in that interval; staging ended at 192 MiB. A separate clean-base walk retained 1,408 MiB staging and reached 8,019 MiB local usage against a 6,983 MiB budget. Routes/cameras diverged, so these do not establish a percentage speedup. The final pool-release build completed a short muted smoke run: 4,799 MiB local usage / 7,180 MiB budget at the end, median 16.7 FPS, no untranslated shaders, refused host pipelines or crash-log entries. Runs ended through the harness, on copied saves. **Known checks/limitations:** full workspace tests stop at the three BCPack oracle-parity failures also reproduced on clean main. Strict default/all-feature Clippy fails in unchanged upstream code; a warning-only audit is not a passing strict gate. Full-tree asset policy reports the existing hex-literal run in `victory-loader/src/heap_sites/frame_users.rs`; the staged patch passes. Dark character textures reproduce on both baseline and candidate. Ground-level city traversal and other GPUs are unverified. Memory growth while visiting new areas is not sufficient evidence either for or against a leak. ## Checked for overlap - [x] Searched open PRs for the same issues and affected files. - #2038 also releases empty pool heaps outside their locks and changes spare limits. There is direct overlap in `pool.rs`; reconcile the alternatives before merging both. - #2720 also indexes occupied descriptor slots, in a separate `KeptSlots` module with an identity cache. This patch keeps the existing owner storage and uses occupancy bits plus the locked owner check. These are alternative implementations of the same scan optimization. - #3406 also checks actual first-upload allocation cost; #1944 changes first-upload admission at the DXGI budget. This patch adds concurrent growth reservations and covers tile heaps and retry propagation. Their policies need reconciliation if combined. - #2657 addresses simultaneous host/VRAM pressure and #3381 changes low-water spare trimming. They overlap the pressure/retention paths; this patch does not introduce their shared-budget guard or tiering policy. - #3751 weighs held mip levels in diagnostics; this patch fixes ordinary-texture allocation when tiles are on and the two-pool census. #3723 is a broader tiered-memory design, beyond this patch's scope. Implemented and tested with OpenAI Codex. No game assets, executable bytes, captures, shader dumps or private run logs are included.
trustno1-coder commented 2026-12-01 18:48:21 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:48:21Z.


Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321578155 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3828#issuecomment-7321578155). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:48:21Z. --- Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!3828
No description provided.