victory-gpu: over budget, admit a first upload only into a free range that exists now #1544

Merged
oVolkra merged 1 commit from upstream-pr/1544 into main 2026-11-29 00:24:47 +00:00
oVolkra commented 2026-11-28 21:27:49 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by oVolkra on 2026-11-28T21:27:49Z.


Fixes #1496

What was wrong

first_upload_decision only charged the card for the bytes of an upload past pool::texture_room(). That number is blocks * 64 MiB - HELD, and HELD drops as soon as a texture is released, while its piece still rests for 2.5 s (REST) before it can be reused. It also adds up free space spread over many small ranges. So a small first upload (4–256 KiB) always "fit" it (new_card_bytes == 0), and the whole-card guard never fired, even far over budget. A texture that then finds no usable range makes the pool create a new 64 MiB block.

The issue's T+16 min line shows this state: 17,043 MiB in use against a 14,767 MiB budget, 16 MiB "free" in texture blocks, 71,820 first uploads allowed, 0 refused at the whole card.

Change

  • pool::texture_widest_free(): the widest free range in the texture blocks right now. Resting pieces are not counted.
  • first_upload_decision takes it as an extra input. When used >= budget, an upload that does not fit in that range is refused with WholeCard. Under the budget, behaviour is unchanged.
  • room_for_first_upload only scans the ranges when the card is at or over budget.

The issue suggests refusing every first upload once used >= budget. This PR doesn't do that, because it would break a_full_card_with_free_texture_blocks_still_admits_faces: that case had 893 MiB free and faces drawing black, and a placed texture there does not grow the card. With this PR, that case still passes when a free range exists.

Testing

  • New test an_over_budget_card_refuses_faces_with_no_free_range_for_them replays the issue's numbers. It fails on main (Allow) and passes with this change (WholeCard). It still allows the upload when a range of its size is free.
  • cargo test -p victory-gpu --release: 551 passed, 0 failed.
  • cargo clippy -p victory-gpu --release --all-targets: no new warnings. too_many_arguments on first_upload_decision was already reported before (8 args, now 9).
  • Not tested in game yet. The unit test shows the guard now fires in the logged state; it does not prove the VRAM overshoot or the nvwgf2umx.dll crash are gone.

Not in this PR

  • first_upload_headroom_from still adds free_blocks to the window cap (item 2 of the issue comment). Each upload is still checked by the fixed guard.
  • draw.rs items 3 and 4 of the issue comment, and blocks made ahead by the pool while the card is over budget.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5544737196 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1544). Originally posted by [oVolkra](https://github.com/oVolkra) on 2026-11-28T21:27:49Z. --- Fixes #1496 ## What was wrong `first_upload_decision` only charged the card for the bytes of an upload past `pool::texture_room()`. That number is `blocks * 64 MiB - HELD`, and `HELD` drops as soon as a texture is released, while its piece still rests for 2.5 s (`REST`) before it can be reused. It also adds up free space spread over many small ranges. So a small first upload (4–256 KiB) always "fit" it (`new_card_bytes == 0`), and the whole-card guard never fired, even far over budget. A texture that then finds no usable range makes the pool create a new 64 MiB block. The issue's T+16 min line shows this state: 17,043 MiB in use against a 14,767 MiB budget, 16 MiB "free" in texture blocks, 71,820 first uploads allowed, 0 refused at the whole card. ## Change - `pool::texture_widest_free()`: the widest free range in the texture blocks right now. Resting pieces are not counted. - `first_upload_decision` takes it as an extra input. When `used >= budget`, an upload that does not fit in that range is refused with `WholeCard`. Under the budget, behaviour is unchanged. - `room_for_first_upload` only scans the ranges when the card is at or over budget. The issue suggests refusing every first upload once `used >= budget`. This PR doesn't do that, because it would break `a_full_card_with_free_texture_blocks_still_admits_faces`: that case had 893 MiB free and faces drawing black, and a placed texture there does not grow the card. With this PR, that case still passes when a free range exists. ## Testing - New test `an_over_budget_card_refuses_faces_with_no_free_range_for_them` replays the issue's numbers. It fails on `main` (`Allow`) and passes with this change (`WholeCard`). It still allows the upload when a range of its size is free. - `cargo test -p victory-gpu --release`: 551 passed, 0 failed. - `cargo clippy -p victory-gpu --release --all-targets`: no new warnings. `too_many_arguments` on `first_upload_decision` was already reported before (8 args, now 9). - Not tested in game yet. The unit test shows the guard now fires in the logged state; it does not prove the VRAM overshoot or the `nvwgf2umx.dll` crash are gone. ## Not in this PR - `first_upload_headroom_from` still adds `free_blocks` to the window cap (item 2 of the issue comment). Each upload is still checked by the fixed guard. - `draw.rs` items 3 and 4 of the issue comment, and blocks made ahead by the pool while the card is over budget. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
oVolkra commented 2026-11-28 22:02:03 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by oVolkra on 2026-11-28T22:02:03Z.


Title-only update: GitHub would not let me set labels on this PR, so I put pr-fix and memory in the title as the README asks; the label workflow has applied them. No code change.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7246448433 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1544#issuecomment-7246448433). Originally posted by [oVolkra](https://github.com/oVolkra) on 2026-11-28T22:02:03Z. --- Title-only update: GitHub would not let me set labels on this PR, so I put pr-fix and memory in the title as the README asks; the label workflow has applied them. No code change.
oVolkra commented 2026-11-28 23:50:48 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by oVolkra on 2026-11-28T23:50:48Z.


In-game test of this branch (a38716d): RTX 3060 12 GB, 16 GB RAM, Windows 11, Series S profile, DLSS Quality, FSR 3 frame generation 2X (DLSS-G isn't supported on this card), VICTORY_TEXTURE_ROOM_PERCENT=80. First run after a full -Preload. The card's budget is 11,332 MB.

The new guard fires. Room lines from the log:

Time In use Free in texture blocks Texture copies First uploads allowed Refused at the whole card
23:43:17 8,754 MB 131 MB 4,412 MB 12,263 0
23:46:51 10,939 MB 307 MB 5,900 MB 10,404 0
23:47:18 11,367 MB 394 MB 6,197 MB 8,797 1,645
23:47:24 11,443 MB 430 MB 6,225 MB 4,227 23
23:47:47 11,493 MB 138 MB 6,517 MB 19,245 25

Once in-use memory passed the budget, first uploads with no free range were refused at the whole card. On main that counter stayed at 0 in the issue's logs. Peak overshoot here was 161 MB, against 737 MB in the 3060 report on the issue. That's one run in a different scene, not a controlled comparison, so it doesn't prove the overshoot is fixed.

It still crashed, for a reason this PR doesn't address. 0x8007000E started at 23:46:38 with about 10.9 GB in use, below the budget (first failure: no shared buffer ... size=6291456). About 18,800 followed, then a host command list did not close (0x8007000E) ended the run at 23:47:48. The allocations failed before the guard had anything to do, so the card ran out before DXGI's budget was reached. Other processes' VRAM use (a desktop wallpaper app was running) or frame-generation resources may account for the gap; I haven't checked which.

So: the guard now holds the over-budget path shut as intended, but the 0x8007000E crash on 12 GB cards with frame generation also happens below the budget, and that needs separate work. I haven't run a comparison with main on this machine yet.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7247701982 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1544#issuecomment-7247701982). Originally posted by [oVolkra](https://github.com/oVolkra) on 2026-11-28T23:50:48Z. --- In-game test of this branch (`a38716d`): RTX 3060 12 GB, 16 GB RAM, Windows 11, Series S profile, DLSS Quality, FSR 3 frame generation 2X (DLSS-G isn't supported on this card), `VICTORY_TEXTURE_ROOM_PERCENT=80`. First run after a full `-Preload`. The card's budget is 11,332 MB. **The new guard fires.** Room lines from the log: | Time | In use | Free in texture blocks | Texture copies | First uploads allowed | Refused at the whole card | |---|---|---|---|---|---| | 23:43:17 | 8,754 MB | 131 MB | 4,412 MB | 12,263 | 0 | | 23:46:51 | 10,939 MB | 307 MB | 5,900 MB | 10,404 | 0 | | 23:47:18 | 11,367 MB | 394 MB | 6,197 MB | 8,797 | **1,645** | | 23:47:24 | 11,443 MB | 430 MB | 6,225 MB | 4,227 | 23 | | 23:47:47 | 11,493 MB | 138 MB | 6,517 MB | 19,245 | 25 | Once in-use memory passed the budget, first uploads with no free range were refused at the whole card. On `main` that counter stayed at 0 in the issue's logs. Peak overshoot here was 161 MB, against 737 MB in the 3060 report on the issue. That's one run in a different scene, not a controlled comparison, so it doesn't prove the overshoot is fixed. **It still crashed, for a reason this PR doesn't address.** `0x8007000E` started at 23:46:38 with about 10.9 GB in use, below the budget (first failure: `no shared buffer ... size=6291456`). About 18,800 followed, then `a host command list did not close (0x8007000E)` ended the run at 23:47:48. The allocations failed before the guard had anything to do, so the card ran out before DXGI's budget was reached. Other processes' VRAM use (a desktop wallpaper app was running) or frame-generation resources may account for the gap; I haven't checked which. So: the guard now holds the over-budget path shut as intended, but the `0x8007000E` crash on 12 GB cards with frame generation also happens below the budget, and that needs separate work. I haven't run a comparison with `main` on this machine yet.
DoubleD17 commented 2026-11-28 23:54:06 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by DoubleD17 on 2026-11-28T23:54:06Z.


A/B test run of this branch against main on an RTX 5070 12 GB with DLSS Frame Generation (complements the 3060 test above). Short version: the new guard fires a lot, but in this scenario it does not keep the process under its DXGI budget, and DLSS still stops upscaling at the same point as on main.

Builds

commit victory.exe SHA-256
A, main 923e38cc8c92cd1c42090076382138538f2bb487 DBD5D11DC330002C29C0E3AF8D357500A1CCFF2529180AA5A2EF3FD29DBDD7D9
B, this PR caedb55: a38716d merged onto 77df871 (docs-only difference from A) C55813ECFC88C5B4452DA473152777BC0C257060FC9D4478B6C2314EE142E01D

Both built with cargo build --release --locked -p victory.

Setup

  • RTX 5070 12 GB (12,227 MiB), driver 621.40; Ryzen 7 5800X; 64 GB RAM; Windows 11 (build 26300).
  • Series X, 2560×1440, DLSS Performance, DLSS-G 3×, 30 FPS cap, VICTORY_TEXTURE_ROOM_PERCENT=80, ray-tracing structure builder off, VICTORY_LOG=info. The 65 effective VICTORY_* switches on the first log line are identical in both runs.
  • Same warmed shader/pipeline cache, one instance per run, no compiling or preloading during the runs.
  • Scenario: the same start point in each run, then no input (idle). All times are relative to the first successful DLSS upscale, and both runs are cut to the same 1,060 s window.
  • Per-process GPU memory and engine use come from the Windows GPU performance counters, and DXGI budget/usage from the layer's own video memory as the system counts it lines. nvidia-smi is adapter-wide and is only used for the free-memory floor.

Results (1,060 s each)

A main B this PR
First-upload refusals at the whole-card budget 296 160,256
First out of VRAM (39) after DLSS start 101.6 s 113.1 s
Process first over its DXGI local budget 116.3 s 130.0 s
Peak DXGI local use − budget +1,108 MB +1,460 MB
Peak DXGI local use / lowest budget 11,683 / 10,179 MB 11,958 / 10,182 MB
Peak DXGI non-local (shared) use 7,852 MB 7,999 MB
Texture-queue weighed use vs room line (peak) 12,400 vs 8,537 MB 12,776 vs 8,335 MB
out of VRAM (39) / Exceeded VRAM budget 11,717 / 11,717 10,371 / 10,371
Last successful DLSS upscale 215.1 s 215.4 s
Adapter free VRAM, minimum 168 MB 131 MB
Process dedicated / shared GPU memory, peak 10,405 / 9,225 MB 10,445 / 9,455 MB
Process private memory, peak 30.0 GB 30.0 GB
0x8007000E 1 (a compute pipeline at start-up) 1 (same)
Device removed / access violation 0 / 0 0 / 0
Base FPS mean / median / 5% low / 1% low 13.4 / 13 / 10 / 8 12.5 / 12 / 9 / 8
Frame time median / p95 / p99 74.1 / 96.0 / 123.9 ms 77.8 / 105.9 / 129.3 ms
Frames > 250 / 500 / 1000 ms 25 / 1 / 0 34 / 4 / 1 (1,574 ms)
Per frame: submission prep / GPU, draws 56.1 / 1.3 ms, 10,487 57.6 / 3.9 ms, 9,579
Host textures uploaded (end) 173,736 / 4,773 MB 183,827 / 5,181 MB

Reading

  • The guard engages: 160k whole-card refusals against 296 on main.
  • The overshoot is not prevented. In-use memory still goes past the DXGI budget about 2 minutes in and keeps rising to +1.1 GB (A) and +1.5 GB (B). The texture queue's weighed use ends about 4 GB above its room line in both runs. Refusing first uploads alone does not stop the growth here. That fits the items this PR lists as out of scope: free_blocks still counted in the cap, a stale memory snapshot in draw.rs, and the pool creating blocks while over budget.
  • DLSS still dies at the same point: the last successful upscale is at about 215 s in both runs, followed by slEvaluateFeature: warning: out of VRAM (39) for the rest of the run.
  • Frame generation: I can't judge it from these runs. DLSS-G reported 0 presents with it on in both. In an earlier run of this branch, DLSS-G showed 28 generated frames in the first 7 s and then none, before any out-of-VRAM warning. I'll treat that as a separate issue.
  • No 0x8007000E storm or crash like the 3060's, either below or above the budget: one start-up pipeline refusal in each run, nothing more.
  • Performance: B is slightly slower (−0.8 FPS mean, worse p95 and long frames). With one run each and the confounders below, I would not call that a regression yet.
  • Picture: the same ~350 draws per frame are dropped for want of a host pipeline in both builds, with none being made (permanent, not a warm-up gap). I saw no new black materials or white flashes in B. A frame-for-frame comparison was not possible (see below).

Limits of this measurement

  • One run per build.
  • The idle workload diverged: in A the rendered content stayed nearly static, while in B it kept changing and B uploaded about 10k more textures (+408 MB). B's slightly worse numbers may come partly from that.
  • The window was not guaranteed to be in the foreground in either run, and other apps held about 1.3–1.9 GB of VRAM before launch.

Related: #1496 (reproduction on main with the same profile).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7247738174 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1544#issuecomment-7247738174). Originally posted by [DoubleD17](https://github.com/DoubleD17) on 2026-11-28T23:54:06Z. --- A/B test run of this branch against `main` on an **RTX 5070 12 GB with DLSS Frame Generation** (complements the 3060 test above). Short version: **the new guard fires a lot, but in this scenario it does not keep the process under its DXGI budget**, and DLSS still stops upscaling at the same point as on `main`. ### Builds | | commit | `victory.exe` SHA-256 | |---|---|---| | A, `main` | `923e38cc8c92cd1c42090076382138538f2bb487` | `DBD5D11DC330002C29C0E3AF8D357500A1CCFF2529180AA5A2EF3FD29DBDD7D9` | | B, this PR | `caedb55`: `a38716d` merged onto `77df871` (docs-only difference from A) | `C55813ECFC88C5B4452DA473152777BC0C257060FC9D4478B6C2314EE142E01D` | Both built with `cargo build --release --locked -p victory`. ### Setup - RTX 5070 12 GB (12,227 MiB), driver 621.40; Ryzen 7 5800X; 64 GB RAM; Windows 11 (build 26300). - Series X, 2560×1440, DLSS Performance, DLSS-G 3×, 30 FPS cap, `VICTORY_TEXTURE_ROOM_PERCENT=80`, ray-tracing structure builder off, `VICTORY_LOG=info`. The 65 effective `VICTORY_*` switches on the first log line are identical in both runs. - Same warmed shader/pipeline cache, one instance per run, no compiling or preloading during the runs. - Scenario: the same start point in each run, then **no input** (idle). All times are relative to the first successful DLSS upscale, and both runs are cut to the same **1,060 s** window. - Per-process GPU memory and engine use come from the Windows GPU performance counters, and DXGI budget/usage from the layer's own `video memory as the system counts it` lines. `nvidia-smi` is adapter-wide and is only used for the free-memory floor. ### Results (1,060 s each) | | A `main` | B this PR | |---|---|---| | First-upload refusals at the whole-card budget | 296 | **160,256** | | First `out of VRAM (39)` after DLSS start | 101.6 s | 113.1 s | | Process first over its DXGI local budget | 116.3 s | 130.0 s | | Peak DXGI local use − budget | **+1,108 MB** | **+1,460 MB** | | Peak DXGI local use / lowest budget | 11,683 / 10,179 MB | 11,958 / 10,182 MB | | Peak DXGI non-local (shared) use | 7,852 MB | 7,999 MB | | Texture-queue weighed use vs room line (peak) | 12,400 vs 8,537 MB | 12,776 vs 8,335 MB | | `out of VRAM (39)` / `Exceeded VRAM budget` | 11,717 / 11,717 | 10,371 / 10,371 | | Last successful DLSS upscale | 215.1 s | 215.4 s | | Adapter free VRAM, minimum | 168 MB | 131 MB | | Process dedicated / shared GPU memory, peak | 10,405 / 9,225 MB | 10,445 / 9,455 MB | | Process private memory, peak | 30.0 GB | 30.0 GB | | `0x8007000E` | 1 (a compute pipeline at start-up) | 1 (same) | | Device removed / access violation | 0 / 0 | 0 / 0 | | Base FPS mean / median / 5% low / 1% low | 13.4 / 13 / 10 / 8 | 12.5 / 12 / 9 / 8 | | Frame time median / p95 / p99 | 74.1 / 96.0 / 123.9 ms | 77.8 / 105.9 / 129.3 ms | | Frames > 250 / 500 / 1000 ms | 25 / 1 / 0 | 34 / 4 / 1 (1,574 ms) | | Per frame: submission prep / GPU, draws | 56.1 / 1.3 ms, 10,487 | 57.6 / 3.9 ms, 9,579 | | Host textures uploaded (end) | 173,736 / 4,773 MB | 183,827 / 5,181 MB | ### Reading - **The guard engages**: 160k whole-card refusals against 296 on `main`. - **The overshoot is not prevented.** In-use memory still goes past the DXGI budget about 2 minutes in and keeps rising to +1.1 GB (A) and +1.5 GB (B). The texture queue's weighed use ends about 4 GB above its room line in both runs. Refusing first uploads alone does not stop the growth here. That fits the items this PR lists as out of scope: `free_blocks` still counted in the cap, a stale memory snapshot in `draw.rs`, and the pool creating blocks while over budget. - **DLSS still dies at the same point**: the last successful upscale is at about 215 s in both runs, followed by `slEvaluateFeature: warning: out of VRAM (39)` for the rest of the run. - **Frame generation: I can't judge it from these runs.** DLSS-G reported 0 presents with it on in both. In an earlier run of this branch, DLSS-G showed 28 generated frames in the first 7 s and then none, **before** any out-of-VRAM warning. I'll treat that as a separate issue. - **No `0x8007000E` storm or crash** like the 3060's, either below or above the budget: one start-up pipeline refusal in each run, nothing more. - **Performance**: B is slightly slower (−0.8 FPS mean, worse p95 and long frames). With one run each and the confounders below, I would not call that a regression yet. - **Picture**: the same ~350 draws per frame are dropped for want of a host pipeline in both builds, with none being made (permanent, not a warm-up gap). I saw no new black materials or white flashes in B. A frame-for-frame comparison was not possible (see below). ### Limits of this measurement - One run per build. - **The idle workload diverged**: in A the rendered content stayed nearly static, while in B it kept changing and B uploaded about 10k more textures (+408 MB). B's slightly worse numbers may come partly from that. - The window was not guaranteed to be in the foreground in either run, and other apps held about 1.3–1.9 GB of VRAM before launch. Related: #1496 (reproduction on `main` with the same profile).
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!1544
No description provided.