GPU: prototype idle mip reclamation with retained texture versions #1150

Open
ilyaux wants to merge 2 commits from upstream-pr/1153 into main
ilyaux commented 2026-11-25 21:50:41 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by ilyaux on 2026-11-25T21:50:41Z.


Problem and proposal

Draft for design feedback, related to #898. Validation of the new reclamation path is limited to synthetic textures on WARP; native NVIDIA and retail-title runs are pending.

Levels-on-demand copies retain backing for mip levels the title no longer holds until the entire host copy is destroyed. This adds an opt-in VICTORY_LEVELS_RECLAIM=1 path, alongside VICTORY_LEVELS_ON_DEMAND=1, which replaces eligible idle copies while keeping old readers valid.

  • Keep the resource dimensions and mip numbering. A replacement starts with fresh staging state and uploads the retained levels.
  • Keep the original resource and its tiles for old descriptors and recorded/in-flight lists. Indexed views switch after the replacement upload's submission fence completes. A newly recorded table selects the retained mip range.
  • Exclude GPU-written or claimed levels and copies with pending deferred users. Keep a packed mip tail together.
  • Reuse free tiles in existing, device-matched pool heaps at a full physical budget without growing the pool. An explicit logical texture byte limit still applies.

The sweep follows the existing idle grace for borrowed host_resource references. Reclamation can be delayed by old readers or insufficient reusable pool space. The feature is off by default.

Dependency and attribution

This draft carries LeonardoS11's #795 as its first commit, reapplied from 32772d93ea1ec529a8508d08e980c3867c2701ff with the original author metadata and message preserved:

  1. bf41d7a12528b8fad5ad2093d4813b04f62f8319: #795's backing-lifetime fix.
  2. b472041c778420d2d4397957d18d65ab62624464: reclamation, pool reuse, regressions and documentation.

The native RTX 3080 Ti results in the carried commit message belong to the original author's report. They are not validation performed for this draft. The second commit contains the new work; the dependency commit can be dropped once #795 lands.

Validation

Tested head: b472041c778420d2d4397957d18d65ab62624464, based on main at 9c184b35b43de3455b74ac1770e1c8734a047810.

Windows 11; rustc/cargo 1.98.1; WARP, tiled resources tier 3. The D3D12 debug layer is not installed.

With VICTORY_D3D12_WARP=1 and VICTORY_TILES_TEST_CARD=0:

Check Result
cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1 --skip depth_bounds_pipeline_loads_and_filters_draws --skip warp_budget_saturates_without_wraparound_and_preserves_draw_fields 202 passed, 0 failed, 6 ignored, 2 excluded
cargo test --locked -p victory-gpu --features diagnostics tiles::tests -- --include-ignored --nocapture --test-threads=1 6 passed, 0 failed, 0 ignored
cargo check --locked -p victory --features diagnostics Passed
cargo xtask policy 185 files OK

The two excluded tests were each run separately on unmodified main at 9c184b3 and failed there too. A full cargo test --workspace --locked attempt stops at the existing indirect-budget test: the GPU package reports 185 passed, 1 failed, 5 ignored. A fully passing workspace run is not claimed.

Both strict workspace Clippy commands from CI were attempted locally and fail on nonminimal_bool in unchanged victory-shader files. The locally available Clippy reports 0.1.93 despite the 1.98.1 rustc/cargo toolchain, so strict CI validation remains open.

For each synthetic BC7/BC3 texture, assigned backing changes from 1856 KiB to 512 KiB after old readers release it. The test checks old-reader contents, heap size without growth, and reintroduced fine-mip contents by readback. These are per-texture tile bytes, not whole-process VRAM or gameplay FPS.

The production sweep and actual Host::execute retirement boundary have a regression. During development, replacing deferred retirement with an immediate drop made the fence-publication assertion fail; that mutation was reverted.

Pending validation and feedback

  • No game executable, native NVIDIA run, gameplay stability, FPS improvement or real-title VRAM reduction has been verified.
  • Packed-tail policy has a unit regression; native packed-mip mappings still need hardware validation.
  • Are idle copy versions an acceptable first step for reclaiming backing while preserving recorded readers? Would you prefer pool reuse as a separate change?

AI use: Codex developed the reclamation changes and synthetic tests, ran local validation and drafted this description. The carried dependency retains its original credits.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6614467194 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1153). Originally posted by [ilyaux](https://github.com/ilyaux) on 2026-11-25T21:50:41Z. --- ## Problem and proposal Draft for design feedback, related to #898. Validation of the new reclamation path is limited to synthetic textures on WARP; native NVIDIA and retail-title runs are pending. Levels-on-demand copies retain backing for mip levels the title no longer holds until the entire host copy is destroyed. This adds an opt-in `VICTORY_LEVELS_RECLAIM=1` path, alongside `VICTORY_LEVELS_ON_DEMAND=1`, which replaces eligible idle copies while keeping old readers valid. - Keep the resource dimensions and mip numbering. A replacement starts with fresh staging state and uploads the retained levels. - Keep the original resource and its tiles for old descriptors and recorded/in-flight lists. Indexed views switch after the replacement upload's submission fence completes. A newly recorded table selects the retained mip range. - Exclude GPU-written or claimed levels and copies with pending deferred users. Keep a packed mip tail together. - Reuse free tiles in existing, device-matched pool heaps at a full physical budget without growing the pool. An explicit logical texture byte limit still applies. The sweep follows the existing idle grace for borrowed `host_resource` references. Reclamation can be delayed by old readers or insufficient reusable pool space. The feature is off by default. ## Dependency and attribution This draft carries **[LeonardoS11](https://github.com/LeonardoS11)'s #795** as its first commit, reapplied from `32772d93ea1ec529a8508d08e980c3867c2701ff` with the original author metadata and message preserved: 1. `bf41d7a12528b8fad5ad2093d4813b04f62f8319`: #795's backing-lifetime fix. 2. `b472041c778420d2d4397957d18d65ab62624464`: reclamation, pool reuse, regressions and documentation. The native RTX 3080 Ti results in the carried commit message belong to the original author's report. They are not validation performed for this draft. The second commit contains the new work; the dependency commit can be dropped once #795 lands. ## Validation Tested head: `b472041c778420d2d4397957d18d65ab62624464`, based on `main` at `9c184b35b43de3455b74ac1770e1c8734a047810`. Windows 11; rustc/cargo 1.98.1; WARP, tiled resources tier 3. The D3D12 debug layer is not installed. With `VICTORY_D3D12_WARP=1` and `VICTORY_TILES_TEST_CARD=0`: | Check | Result | | --- | --- | | `cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1 --skip depth_bounds_pipeline_loads_and_filters_draws --skip warp_budget_saturates_without_wraparound_and_preserves_draw_fields` | 202 passed, 0 failed, 6 ignored, 2 excluded | | `cargo test --locked -p victory-gpu --features diagnostics tiles::tests -- --include-ignored --nocapture --test-threads=1` | 6 passed, 0 failed, 0 ignored | | `cargo check --locked -p victory --features diagnostics` | Passed | | `cargo xtask policy` | 185 files OK | The two excluded tests were each run separately on unmodified `main` at `9c184b3` and failed there too. A full `cargo test --workspace --locked` attempt stops at the existing indirect-budget test: the GPU package reports 185 passed, 1 failed, 5 ignored. A fully passing workspace run is not claimed. Both strict workspace Clippy commands from CI were attempted locally and fail on `nonminimal_bool` in unchanged `victory-shader` files. The locally available Clippy reports 0.1.93 despite the 1.98.1 rustc/cargo toolchain, so strict CI validation remains open. For each synthetic BC7/BC3 texture, assigned backing changes from **1856 KiB to 512 KiB** after old readers release it. The test checks old-reader contents, heap size without growth, and reintroduced fine-mip contents by readback. These are per-texture tile bytes, not whole-process VRAM or gameplay FPS. The production sweep and actual `Host::execute` retirement boundary have a regression. During development, replacing deferred retirement with an immediate drop made the fence-publication assertion fail; that mutation was reverted. ## Pending validation and feedback - No game executable, native NVIDIA run, gameplay stability, FPS improvement or real-title VRAM reduction has been verified. - Packed-tail policy has a unit regression; native packed-mip mappings still need hardware validation. - Are idle copy versions an acceptable first step for reclaiming backing while preserving recorded readers? Would you prefer pool reuse as a separate change? AI use: Codex developed the reclamation changes and synthetic tests, ran local validation and drafted this description. The carried dependency retains its original credits.
fladit123 commented 2026-11-26 00:06:07 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by fladit123 on 2026-11-25T23:10:14Z.


Independent native hardware validation of HEAD b472041c778420d2d4397957d18d65ab62624464.

Environment

  • Windows 11
  • NVIDIA RTX 4060 8 GB, driver 610.88
  • Rust 1.98.1
  • Release build with diagnostics
  • D3D12 debug layer enabled for the tiled-resource fixtures

Results

Test Result
Packed mip-tail preservation PASS
Mip reclamation on WARP, tier 3 PASS
Production sweep and submission publication on WARP PASS
Mip reclamation on the native adapter, tier 4 PASS
Native levels-on-demand integration fixture PASS

Five successful test executions, no skips, no timeouts and no detected device removal.

Assigned backing per synthetic BC7/BC3 texture

Adapter Before After Reduction
WARP 1856 KiB 512 KiB 72.41%
Native adapter 1408 KiB 64 KiB 95.45%

Both adapters released 1344 KiB of assigned backing per texture.

The reclamation regression verified retained old-reader contents, no pool growth during replacement, and correct restoration of fine mip contents.

No D3D12 errors were reported. The native levels-on-demand fixture emitted one warning, ID 1328, concerning the initial UAV state of a buffer being treated as COMMON. The corresponding fixture code is unchanged from the original base, although I did not rerun that base to reproduce the warning.

Executable SHA256:
F827851C759D8B9D146EBC0FA228DB04AB559D9EB5BC840F210C6CC2F9CB52F9

Limitations

The native fixture selects the default D3D12 hardware adapter. The system reports an RTX 4060 and two virtual display adapters; the fixture did not print the selected adapter's LUID.

Validation used a source-only copy with verified Git blob hashes and the unrelated BCPack module excluded locally. No game data was used.

These results measure assigned texture backing, not total physical VRAM savings or gameplay performance. Integration with current main remains untested.

The synthetic native hardware results are encouraging, particularly for memory-constrained GPUs.

AI-assisted validation with ChatGPT; all tests executed locally.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7177224561 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1153#issuecomment-7177224561). Originally posted by [fladit123](https://github.com/fladit123) on 2026-11-25T23:10:14Z. --- Independent native hardware validation of HEAD `b472041c778420d2d4397957d18d65ab62624464`. **Environment** - Windows 11 - NVIDIA RTX 4060 8 GB, driver 610.88 - Rust 1.98.1 - Release build with diagnostics - D3D12 debug layer enabled for the tiled-resource fixtures **Results** | Test | Result | |---|---| | Packed mip-tail preservation | PASS | | Mip reclamation on WARP, tier 3 | PASS | | Production sweep and submission publication on WARP | PASS | | Mip reclamation on the native adapter, tier 4 | PASS | | Native levels-on-demand integration fixture | PASS | Five successful test executions, no skips, no timeouts and no detected device removal. **Assigned backing per synthetic BC7/BC3 texture** | Adapter | Before | After | Reduction | |---|---:|---:|---:| | WARP | 1856 KiB | 512 KiB | 72.41% | | Native adapter | 1408 KiB | 64 KiB | 95.45% | Both adapters released 1344 KiB of assigned backing per texture. The reclamation regression verified retained old-reader contents, no pool growth during replacement, and correct restoration of fine mip contents. No D3D12 errors were reported. The native levels-on-demand fixture emitted one warning, ID 1328, concerning the initial UAV state of a buffer being treated as COMMON. The corresponding fixture code is unchanged from the original base, although I did not rerun that base to reproduce the warning. Executable SHA256: `F827851C759D8B9D146EBC0FA228DB04AB559D9EB5BC840F210C6CC2F9CB52F9` **Limitations** The native fixture selects the default D3D12 hardware adapter. The system reports an RTX 4060 and two virtual display adapters; the fixture did not print the selected adapter's LUID. Validation used a source-only copy with verified Git blob hashes and the unrelated BCPack module excluded locally. No game data was used. These results measure assigned texture backing, not total physical VRAM savings or gameplay performance. Integration with current main remains untested. The synthetic native hardware results are encouraging, particularly for memory-constrained GPUs. AI-assisted validation with ChatGPT; all tests executed locally.
fladit123 commented 2026-11-26 02:08:45 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by fladit123 on 2026-11-26T01:59:36Z.


Following up on my earlier hardware validation, I investigated the admission and upload boundary more closely.

I reproduced a case where reclaimed_on() checks available pool capacity, but another texture consumes that capacity before the replacement's first upload. With growth disabled, the replacement initially received zero backing. With growth enabled, the pool grew from 64 to 128 MiB.

An experimental reservation-based complement prevented this growth and guaranteed backing for the retained mip groups. However, further qualification exposed important trade-offs:

  • Four competing texture uploads made no progress during a two-second window while idle replacements held their reservations. All four recovered after those replacements were discarded.
  • A 256 KiB reservation prevented a 64 MiB heap from being returned.
  • A WARP cancellation probe left a replacement with 512 KiB reserved and zero mapped backing, although a newly created descriptor already referenced it. Readback returned 0x00 before initialization and 0x22 after a subsequent successful upload.

The experiments also identified and corrected two accounting issues in the experimental complement: stale logical-budget admission and transient double counting during reservation conversion.

The qualified reservation implementation passed 17 WARP controls and two RTX 4060 tests, but I do not recommend integrating it as-is because of the demonstrated progress regression.

A possible alternative would be:

  1. Keep the previous resource version available.
  2. Record a replacement intent without reserving tiles for idle textures.
  3. Reserve and initialize a private replacement when a submission has valid staging and sufficient capacity.
  4. Promote the initialized version only after fence completion and generation revalidation.
  5. Preserve the previous resource and its backing for existing readers.

The main complication is that recorded D3D12 commands already reference concrete resources. Changing made at submission time cannot redirect those commands.

I therefore stopped at the design boundary rather than introducing a broader production change without coordination.

Would this private-initialization and deferred-promotion model fit your intended architecture? I can share the synthetic reproductions, accounting fixes and experimental patches separately if useful.

These experiments used synthetic data only. Gameplay performance and total process VRAM savings remain unmeasured.

AI-assisted investigation with ChatGPT and Codex; tests executed locally.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7180351614 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1153#issuecomment-7180351614). Originally posted by [fladit123](https://github.com/fladit123) on 2026-11-26T01:59:36Z. --- Following up on my earlier hardware validation, I investigated the admission and upload boundary more closely. I reproduced a case where `reclaimed_on()` checks available pool capacity, but another texture consumes that capacity before the replacement's first upload. With growth disabled, the replacement initially received zero backing. With growth enabled, the pool grew from 64 to 128 MiB. An experimental reservation-based complement prevented this growth and guaranteed backing for the retained mip groups. However, further qualification exposed important trade-offs: - Four competing texture uploads made no progress during a two-second window while idle replacements held their reservations. All four recovered after those replacements were discarded. - A 256 KiB reservation prevented a 64 MiB heap from being returned. - A WARP cancellation probe left a replacement with 512 KiB reserved and zero mapped backing, although a newly created descriptor already referenced it. Readback returned `0x00` before initialization and `0x22` after a subsequent successful upload. The experiments also identified and corrected two accounting issues in the experimental complement: stale logical-budget admission and transient double counting during reservation conversion. The qualified reservation implementation passed 17 WARP controls and two RTX 4060 tests, but I do not recommend integrating it as-is because of the demonstrated progress regression. A possible alternative would be: 1. Keep the previous resource version available. 2. Record a replacement intent without reserving tiles for idle textures. 3. Reserve and initialize a private replacement when a submission has valid staging and sufficient capacity. 4. Promote the initialized version only after fence completion and generation revalidation. 5. Preserve the previous resource and its backing for existing readers. The main complication is that recorded D3D12 commands already reference concrete resources. Changing `made` at submission time cannot redirect those commands. I therefore stopped at the design boundary rather than introducing a broader production change without coordination. Would this private-initialization and deferred-promotion model fit your intended architecture? I can share the synthetic reproductions, accounting fixes and experimental patches separately if useful. These experiments used synthetic data only. Gameplay performance and total process VRAM savings remain unmeasured. AI-assisted investigation with ChatGPT and Codex; tests executed locally.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1153:upstream-pr/1153'
git switch 'upstream-pr/1153'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1153'
git switch 'upstream-pr/1153'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1153'
git switch 'upstream-pr/1153'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1153'
git switch 'main'
git merge --squash 'upstream-pr/1153'
git switch 'main'
git merge --ff-only 'upstream-pr/1153'
git switch 'main'
git merge 'upstream-pr/1153'
git push origin 'main'
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
fxceless/victory-fork!1150
No description provided.