Check VRAM before allocating first streamed textures #3406

Closed
Kitrae wants to merge 1 commit from upstream-pr/3406 into main
Kitrae commented 2026-11-29 22:51:29 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Kitrae on 2026-11-29T22:51:29Z.


Refs #3374

What it changes

The background pass can admit a first texture upload based on its title footprint and free space in the pool. If placement finds no usable range, the allocator can then request a 64 MiB heap even for a small texture.

  • Check current DXGI headroom before growing the pool or committing a standalone texture. The check uses the full heap size or the D3D12 allocation size, respectively. Uploads that fit in existing blocks can still reuse them.
  • Keep budget-deferred uploads queued, preserve pending texture seeds, and refund the first-upload allowance for the deferred attempt.
  • Set VICTORY_FIRST_UPLOAD_VRAM_GUARD=0 to compare the previous behavior with the same build.

How it was tested

  • The reference run in #3374 used an RTX 3070 8 GB, Series S, 1080→1440, DLSS Performance, and 2× frame generation via the MFG Unlocker. DXGI local usage reached 8,844 MiB against a 7,031 MiB budget in the attached log.
  • The new tests cover the full allocation cost at and above the reported budget, reuse of existing pool space when growth is deferred, and clearing deferral state before subsequent allocations.
  • On Windows with an RTX 4090, cargo test -p victory-gpu --lib --locked -- --test-threads=1 reported 917 passed, 1 failed and 60 ignored. Upstream 716a0c99 reported 914 passed, 1 failed and 60 ignored. Both failed the same shader-cache check for VICTORY_SCALAR_SPLITS.
  • A matched gameplay run on an 8 GB card is still needed to measure VRAM and frame-time impact.

Checked for overlap

  • I searched open PRs. #1944 changes first-upload admission and residency priority. #3128 changes when sampled texture eviction is enabled. This PR checks the actual allocation after admission.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5556011138 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3406). Originally posted by [Kitrae](https://github.com/Kitrae) on 2026-11-29T22:51:29Z. --- Refs #3374 ## What it changes The background pass can admit a first texture upload based on its title footprint and free space in the pool. If placement finds no usable range, the allocator can then request a 64 MiB heap even for a small texture. - Check current DXGI headroom before growing the pool or committing a standalone texture. The check uses the full heap size or the D3D12 allocation size, respectively. Uploads that fit in existing blocks can still reuse them. - Keep budget-deferred uploads queued, preserve pending texture seeds, and refund the first-upload allowance for the deferred attempt. - Set `VICTORY_FIRST_UPLOAD_VRAM_GUARD=0` to compare the previous behavior with the same build. ## How it was tested - The reference run in #3374 used an RTX 3070 8 GB, Series S, 1080→1440, DLSS Performance, and 2× frame generation via the MFG Unlocker. DXGI local usage reached 8,844 MiB against a 7,031 MiB budget in the attached log. - The new tests cover the full allocation cost at and above the reported budget, reuse of existing pool space when growth is deferred, and clearing deferral state before subsequent allocations. - On Windows with an RTX 4090, `cargo test -p victory-gpu --lib --locked -- --test-threads=1` reported 917 passed, 1 failed and 60 ignored. Upstream `716a0c99` reported 914 passed, 1 failed and 60 ignored. Both failed the same shader-cache check for `VICTORY_SCALAR_SPLITS`. - A matched gameplay run on an 8 GB card is still needed to measure VRAM and frame-time impact. ## Checked for overlap - [x] I searched open PRs. #1944 changes first-upload admission and residency priority. #3128 changes when sampled texture eviction is enabled. This PR checks the actual allocation after admission.
tyr0nsur commented 2026-11-30 06:26:43 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-11-30T06:26:43Z.


I tested 446f0a5 on a Windows RTX 4060 8 GiB, merged locally onto 41adb55. A test-only input set the guard's headroom. The textures, heaps, residency calls, and DXGI measurements used real D3D12. All 12 first-upload tests passed.

  • With 4 MiB simulated headroom and an empty pool, a 256×256 RGBA8 texture fell back to a committed resource because a 64 MiB block would not fit. At 0 MiB, a fresh allocation deferred. Placing the texture in an existing block succeeded and left DXGI local usage unchanged.
  • With 72 MiB simulated headroom and a suitable range already in the pool, a guarded take still added an ahead block with VICTORY_RIPE_BLOCKS=12 (the pool default when unset). Pool size and DXGI local usage both rose by exactly 64 MiB. With VICTORY_RIPE_BLOCKS=0, the same take added zero bytes. Both shipped launchers set 0, and the two v2026.11.29.05 captures from this RTX 4060 used 0 as well. The extra ahead block therefore does not explain their VRAM growth. PR #2038 also suppresses ahead growth after over-budget pressure is detected while retaining the preference for ripe blocks.

Could the growth callback distinguish a required block from an ahead block so the latter can have a separate headroom threshold? The existing rationale for ripe blocks makes a matched gameplay run worth doing before changing the default. This allocator test leaves FPS and in-game texture latency open. Review assisted by Claude Opus 5.5.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7270655600 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3406#issuecomment-7270655600). Originally posted by [tyr0nsur](https://github.com/tyr0nsur) on 2026-11-30T06:26:43Z. --- I tested `446f0a5` on a Windows RTX 4060 8 GiB, merged locally onto `41adb55`. A test-only input set the guard's headroom. The textures, heaps, residency calls, and DXGI measurements used real D3D12. All 12 first-upload tests passed. - With 4 MiB simulated headroom and an empty pool, a 256×256 RGBA8 texture fell back to a committed resource because a 64 MiB block would not fit. At 0 MiB, a fresh allocation deferred. Placing the texture in an existing block succeeded and left DXGI local usage unchanged. - With 72 MiB simulated headroom and a suitable range already in the pool, a guarded take still added an ahead block with `VICTORY_RIPE_BLOCKS=12` (the pool default when unset). Pool size and DXGI local usage both rose by exactly 64 MiB. With `VICTORY_RIPE_BLOCKS=0`, the same take added zero bytes. Both shipped launchers set `0`, and the two v2026.11.29.05 captures from this RTX 4060 used `0` as well. The extra ahead block therefore does not explain their VRAM growth. PR #2038 also suppresses ahead growth after over-budget pressure is detected while retaining the preference for ripe blocks. Could the growth callback distinguish a required block from an ahead block so the latter can have a separate headroom threshold? The existing rationale for ripe blocks makes a matched gameplay run worth doing before changing the default. This allocator test leaves FPS and in-game texture latency open. Review assisted by Claude Opus 5.5.
trustno1-coder commented 2026-12-01 18:52:31 +00:00 (Migrated from github.com)

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


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:7321720632 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3406#issuecomment-7321720632). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:52:31Z. --- 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!3406
No description provided.