gpu: size the render targets' room by the peak they have held, not a flat 3 GiB #76

Open
github-bot wants to merge 1 commit from github-bot/gh-76 into main AGit
Owner

@⁠starnotes-xj on GitHub · 2026-11-27 16:45 UTC · original
starnotes-xj:fix/targets-room-peak → main · +49 −1 · 1 files · 1 commits · open

What this fixes

On an 8 GB card the SeriesS / SeriesX2 profiles (720p scene) render black faces on every NPC and leave the phone's screen empty, while the card is less than half used. The cause is in the room kept for render targets:

texture queue's room: 2973 MB in use - 316 MB free in texture blocks
  + 850 MB kept for card copies + 2675 MB kept for render targets
  = 6182 MB against a line of 6181 MB (86.0 % of a budget of 7188 MB): no room, new textures wait

VICTORY_CARD_ROOM_FOR_TARGETS_MB keeps a flat 3,072 MiB, and it is only given back once the targets hold half of it (1,536 MB) and have not grown for 20 s. A 720p world's targets never reach that: they hold ~390 MB for the whole run, so 2,675 MB stayed reserved for targets that never come and the texture queue refused new textures with the card 41 % used. The skin textures of passers-by, the coffee shop's waitress and the phone's screen were never uploaded.

The change

crates/victory-gpu/src/resource.rs: the room is sized by the most the targets have held this run — half as much again, at least 256 MiB, never more than the switch's amount.

fn targets_kept_from_peak(most: u64, targets: u64, peak: u64) -> u64 {
    const LEAST: u64 = 256 << 20;
    peak.saturating_add(peak / 2).max(LEAST).min(most).saturating_sub(targets)
}
  • targets_room_kept tracks the peak in a static and calls it;
  • when VICTORY_CARD_ROOM_FOR_TARGETS_MB is set, the old flat rule is used unchanged, so existing tuning behaves as before;
  • targets_kept and its test stay for that path;
  • new test room_for_targets_follows_their_peak (the 390 MB figure is the measured one).

Measured (RTX 4060 Laptop, 8 GB, -SeriesS -Dlss quality, release build)

room kept for targets dedicated VRAM used / budget out of VRAM fps
before 2,675 MB 6,182 MB left to textures, card 41 % used — 13, black faces
after 585 MB 6,648 / 6,815 MB 0 13–15, peak 21

With the fix, passers-by, the coffee shop's waitress, the street and the phone's bezel all render correctly, and the card no longer goes over its budget (the hand-cut workaround, releasing the reserve and lowering VICTORY_TEXTURE_ROOM_PERCENT to 78, overfilled at 6,895 MB with 43 out of VRAM events).

A 1440p world's peak of 2.9 GB still gets the switch's full 3,072 MB, so the profile the numbers were tuned on keeps what it had.

cargo test -p victory-gpu --lib room_for_targets → 2 passed.

**@⁠starnotes-xj** on GitHub · 2026-11-27 16:45 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/76) `starnotes-xj:fix/targets-room-peak` → `main` · +49 −1 · 1 files · 1 commits · open ## What this fixes On an 8 GB card the SeriesS / SeriesX2 profiles (720p scene) render **black faces on every NPC** and leave the phone's screen empty, while the card is less than half used. The cause is in the room kept for render targets: ``` texture queue's room: 2973 MB in use - 316 MB free in texture blocks + 850 MB kept for card copies + 2675 MB kept for render targets = 6182 MB against a line of 6181 MB (86.0 % of a budget of 7188 MB): no room, new textures wait ``` `VICTORY_CARD_ROOM_FOR_TARGETS_MB` keeps a flat 3,072 MiB, and it is only given back once the targets hold **half** of it (1,536 MB) and have not grown for 20 s. A 720p world's targets never reach that: they hold ~390 MB for the whole run, so **2,675 MB stayed reserved for targets that never come** and the texture queue refused new textures with the card 41 % used. The skin textures of passers-by, the coffee shop's waitress and the phone's screen were never uploaded. ## The change `crates/victory-gpu/src/resource.rs`: the room is sized by **the most the targets have held this run** — half as much again, at least 256 MiB, never more than the switch's amount. ```rust fn targets_kept_from_peak(most: u64, targets: u64, peak: u64) -> u64 { const LEAST: u64 = 256 << 20; peak.saturating_add(peak / 2).max(LEAST).min(most).saturating_sub(targets) } ``` - `targets_room_kept` tracks the peak in a static and calls it; - when `VICTORY_CARD_ROOM_FOR_TARGETS_MB` is set, the old flat rule is used unchanged, so existing tuning behaves as before; - `targets_kept` and its test stay for that path; - new test `room_for_targets_follows_their_peak` (the 390 MB figure is the measured one). ## Measured (RTX 4060 Laptop, 8 GB, `-SeriesS -Dlss quality`, release build) | | room kept for targets | dedicated VRAM used / budget | `out of VRAM` | fps | |---|---|---|---|---| | before | 2,675 MB | 6,182 MB left to textures, card 41 % used | — | 13, black faces | | **after** | **585 MB** | **6,648 / 6,815 MB** | **0** | **13–15, peak 21** | With the fix, passers-by, the coffee shop's waitress, the street and the phone's bezel all render correctly, and the card no longer goes over its budget (the hand-cut workaround, releasing the reserve and lowering `VICTORY_TEXTURE_ROOM_PERCENT` to 78, overfilled at 6,895 MB with 43 `out of VRAM` events). A 1440p world's peak of 2.9 GB still gets the switch's full 3,072 MB, so the profile the numbers were tuned on keeps what it had. `cargo test -p victory-gpu --lib room_for_targets` → 2 passed.
The flat VICTORY_CARD_ROOM_FOR_TARGETS_MB (3,072 MiB) is given back only once
the targets hold half of it, which the targets of a 720p world never do. On an
8 GB RTX 4060 Laptop the SeriesS profile's targets held 390 MB, so 2,675 MB
stayed reserved for them the whole run: the texture queue weighed 6,182 MB
against a line of 6,181 MB with the card 41 % used and refused new textures,
and the skin textures of passers-by and the coffee shop's waitress were never
uploaded (black faces, the phone's screen empty).

Half as much again as the peak they have held (at least 256 MiB, never more
than the switch's amount) is kept instead: 195 MB for the same run, and a
1440p world's peak of 2.9 GB still gets what it had. The switch keeps the old
flat rule when it is set.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 16:50:07 +00:00
Author
Owner

@⁠cride9 on GitHub · 2026-11-27 16:53 UTC · original

sup, tested it with a desktop 3050 and ryzen 5 5600 32gb DDR4 system ram.

Got around 25fps avarage with lucia inside the prison. And around 18-22fps on the water.
My claude merged it and it looks like working (but idk)

-Build release -SeriesS -Dlss performance -Fps 60 -More @{VICTORY_THIN='0'; VICTORY_JOIN_PARTS='1'}

**@⁠cride9** on GitHub · 2026-11-27 16:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/76#issuecomment-7223795578) sup, tested it with a desktop 3050 and ryzen 5 5600 32gb DDR4 system ram. Got around 25fps avarage with lucia inside the prison. And around 18-22fps on the water. My claude merged it and it looks like working (but idk) `-Build release -SeriesS -Dlss performance -Fps 60 -More @{VICTORY_THIN='0'; VICTORY_JOIN_PARTS='1'}`
Author
Owner

@⁠Pierrespeick on GitHub · 2026-11-27 22:09 UTC · original

Additional test on an 8 GiB NVIDIA Wave32 card, with 0f0ada1 as the base for both builds. I applied 05a269d on top for the second run. Both builds used diagnostics, Series S, DLSS off, frame generation off, and separate copies of the same starting save.

  • Base — Audio and subtitles played over a black image in the opening cinematic, at about 3.5 FPS. In one representative sample, dedicated VRAM was 5,633 MB in use against a 6,792 MB budget. The texture queue still reported no room: 6,474 MB accounted against its 6,113 MB threshold, including 1,584 MB kept for render targets.
  • With the patch — The opening image returned and the prison and lake reached about 17–21 FPS under player control. Median render-target reserve across the diagnostic samples fell from 2,798 MB to 782 MB. The patched run went farther and had more samples, so these are session summaries. It still hit no room in some scenes and showed intermittent black or coloured surfaces.
  • Remaining stalls — In the patched run, 10 of the 13 high-draw samples below 5 FPS had six or fewer host pipelines still being made. Some slow samples had texture queue headroom and some were over the threshold. These stalls are worth measuring separately from startup shader compilation and the reserve fix.

The patched run reused the baseline shader and pipeline cache, so this is evidence for the budget and rendering behaviour. A same-scene warm-cache FPS comparison is still needed. Both sessions ended by closing the window. This summary uses aggregate diagnostics and visual observations. Prepared with Codex assistance.

**@⁠Pierrespeick** on GitHub · 2026-11-27 22:09 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/76#issuecomment-7229083875) Additional test on an 8 GiB NVIDIA Wave32 card, with `0f0ada1` as the base for both builds. I applied `05a269d` on top for the second run. Both builds used diagnostics, Series S, DLSS off, frame generation off, and separate copies of the same starting save. - **Base** — Audio and subtitles played over a black image in the opening cinematic, at about 3.5 FPS. In one representative sample, dedicated VRAM was 5,633 MB in use against a 6,792 MB budget. The texture queue still reported `no room`: 6,474 MB accounted against its 6,113 MB threshold, including 1,584 MB kept for render targets. - **With the patch** — The opening image returned and the prison and lake reached about 17–21 FPS under player control. Median render-target reserve across the diagnostic samples fell from 2,798 MB to 782 MB. The patched run went farther and had more samples, so these are session summaries. It still hit `no room` in some scenes and showed intermittent black or coloured surfaces. - **Remaining stalls** — In the patched run, 10 of the 13 high-draw samples below 5 FPS had six or fewer host pipelines still being made. Some slow samples had texture queue headroom and some were over the threshold. These stalls are worth measuring separately from startup shader compilation and the reserve fix. The patched run reused the baseline shader and pipeline cache, so this is evidence for the budget and rendering behaviour. A same-scene warm-cache FPS comparison is still needed. Both sessions ended by closing the window. This summary uses aggregate diagnostics and visual observations. Prepared with Codex assistance.
Author
Owner

@⁠CuteBooty on GitHub · 2026-11-28 01:51 UTC · original

Data from an RTX 3070 8 GB at 1080p that shows the same thing this PR describes, at one spot in the world: Jason's house (the interior with the terrarium, and its outside walls). I have not built or run this PR's code; these are log figures from builds without it.

Setup: RTX 3070 8 GB (DXGI budget 7,250 MB at start, 6.3-7.0 GB in play), Ryzen 7 5800X3D, 32 GB, Windows 11. Series S, 1920x1080, no DLSS, no frame generation, ray tracing off, built from source, started from my own script (not the launcher; switches on request). VICTORY_CARD_ROOM_FOR_TARGETS_MB not set, so the flat 3,072 MB rule.

Three short runs, same save, standing in and walking around that house. All figures are from the the texture queue's room: line (one sample every 5 s).

run A run B run C
base 64d4931b3 64d4931b3, VICTORY_BUFFERS_AHEAD=0 f3534e6b0
length 9.5 min 6.4 min 10 min
samples saying "no room, new textures wait" 83 of 111 55 of 72 111 of 116
first "no room" after start 53 s 92 s 37 s
card "in use" during no room (min / median / max) 4,755 / 5,462 / 6,603 MB 4,679 / 5,380 / 5,525 MB 4,775 / 5,764 / 5,782 MB
free in texture blocks (median) 413 MB 693 MB 826 MB
kept for render targets (min / median / max) 0 / 1,599 / 1,956 MB 1,751 / 1,828 / 2,054 MB 1,690 / 1,699 / 2,054 MB
"no room" samples that would have had room without that reserve 77 of 83 55 of 55 111 of 111
reserve given back once, 6 min 48 s in never never
brought up to date although the card has no room lines 1,032 453 1,297

What I read from it:

  • In 243 of 249 "no room" samples the card was not full. The sum went over the line only because 1.6-2.0 GB was still kept for render targets.
  • The targets level off just under the release point. In run C the reserve sat at 1,690 MB for the last six minutes, so the targets held about 1,380 MB: more than a 720p world's 390 MB in this PR's description, but still under half of 3,072 MB (1,536 MB), so the reserve was never given back. A typical sample from run C: 5782 MB in use - 818 MB free in texture blocks + 106 MB kept for card copies of title buffers + 1690 MB kept for render targets = 6760 MB against a line of 6247 MB (90.0 % of a budget of 6942 MB): no room, new textures wait.
  • In run A the reserve fell to 1,486 MB (targets over 1,536 MB), was given back at 6 min 48 s, and the line said "room" again for the next 20 samples.
  • By eye: in run C the interior was almost all black after standing in it for several minutes (walls, floor and furniture missing), while the world outside looked mostly fine; the house's outside walls were also worse than other buildings. In run A the room was readable, with the gravel in the terrarium at its lowest detail. I can't say from one run each that the reserve being given back in A is the reason for that difference.

By this PR's rule, a peak of about 1,380 MB would keep about 2,070 MB less what the targets hold, so roughly 690 MB instead of 1,690 MB at that spot.

The same spot with VICTORY_CARD_ROOM_FOR_TARGETS_MB=2048 (the old flat rule with a lower amount, so the release point is 1,024 MB; 64d4931b3 + PR #560, VICTORY_BUFFERS_AHEAD=0, otherwise as run B; one run of 14.3 minutes):

run B (3,072, default; 6.4 min) run D (2,048; 14.3 min)
samples saying "no room" 55 of 72 62 of 164 (28 of 103 in the first 9 minutes, 34 of 61 after)
reserve given back never 78 s after start; back twice for under a minute (517-920 MB) when the targets grew
"no room" samples that would have had room without the reserve 55 of 55 14 of 62
card "in use" at the end / budget 5,525 MB / 6.7-7.25 GB 6,811 MB / 6.5-7.0 GB
brought up to date although the card has no room lines a minute about 70 about 41
out of VRAM, E_OUTOFMEMORY, ERROR lines 0 0

So with the reserve released the queue has room where it had none, and the card then really fills: 48 of the 62 remaining "no room" samples are the card at its budget (in use 6.75-6.8 GB, above the DXGI budget in 18 samples), not the reserve, and they get more frequent as the run goes on. One run; I have no by-eye verdict on the walls and floor for it. The one thing noticed by eye in that run was the player character's face skin turning flat white-grey at the house; I don't know whether that has anything to do with the fuller card.

Caveats: short runs in one sitting, one machine; run A rebuilt its shader caches, the others had warm ones; A / B / D and C are different bases, and D carries PR #560. Not tested: this PR's code. I have photos of the two interiors but am not attaching them.

Separate from this: the blue-white glow on the table and floor in the same room on 64d4931b3 looks like the indoor reflection problem in #468 and #507 (same house), not memory.

Measurements and this report were prepared with an AI assistant (Claude Code); the runs were played on my machine.

**@⁠CuteBooty** on GitHub · 2026-11-28 01:51 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/76#issuecomment-7231965547) Data from an RTX 3070 8 GB at 1080p that shows the same thing this PR describes, at one spot in the world: Jason's house (the interior with the terrarium, and its outside walls). **I have not built or run this PR's code**; these are log figures from builds without it. Setup: RTX 3070 8 GB (DXGI budget 7,250 MB at start, 6.3-7.0 GB in play), Ryzen 7 5800X3D, 32 GB, Windows 11. Series S, 1920x1080, no DLSS, no frame generation, ray tracing off, built from source, started from my own script (not the launcher; switches on request). `VICTORY_CARD_ROOM_FOR_TARGETS_MB` not set, so the flat 3,072 MB rule. Three short runs, same save, standing in and walking around that house. All figures are from the `the texture queue's room:` line (one sample every 5 s). | | run A | run B | run C | |---|---|---|---| | base | `64d4931b3` | `64d4931b3`, `VICTORY_BUFFERS_AHEAD=0` | `f3534e6b0` | | length | 9.5 min | 6.4 min | 10 min | | samples saying "no room, new textures wait" | 83 of 111 | 55 of 72 | 111 of 116 | | first "no room" after start | 53 s | 92 s | 37 s | | card "in use" during no room (min / median / max) | 4,755 / 5,462 / 6,603 MB | 4,679 / 5,380 / 5,525 MB | 4,775 / 5,764 / 5,782 MB | | free in texture blocks (median) | 413 MB | 693 MB | 826 MB | | kept for render targets (min / median / max) | 0 / 1,599 / 1,956 MB | 1,751 / 1,828 / 2,054 MB | 1,690 / 1,699 / 2,054 MB | | "no room" samples that would have had room without that reserve | 77 of 83 | 55 of 55 | 111 of 111 | | reserve given back | once, 6 min 48 s in | never | never | | `brought up to date although the card has no room` lines | 1,032 | 453 | 1,297 | What I read from it: - In 243 of 249 "no room" samples the card was not full. The sum went over the line only because 1.6-2.0 GB was still kept for render targets. - The targets level off just under the release point. In run C the reserve sat at 1,690 MB for the last six minutes, so the targets held about 1,380 MB: more than a 720p world's 390 MB in this PR's description, but still under half of 3,072 MB (1,536 MB), so the reserve was never given back. A typical sample from run C: `5782 MB in use - 818 MB free in texture blocks + 106 MB kept for card copies of title buffers + 1690 MB kept for render targets = 6760 MB against a line of 6247 MB (90.0 % of a budget of 6942 MB): no room, new textures wait`. - In run A the reserve fell to 1,486 MB (targets over 1,536 MB), was given back at 6 min 48 s, and the line said "room" again for the next 20 samples. - By eye: in run C the interior was almost all black after standing in it for several minutes (walls, floor and furniture missing), while the world outside looked mostly fine; the house's outside walls were also worse than other buildings. In run A the room was readable, with the gravel in the terrarium at its lowest detail. I can't say from one run each that the reserve being given back in A is the reason for that difference. By this PR's rule, a peak of about 1,380 MB would keep about 2,070 MB less what the targets hold, so roughly 690 MB instead of 1,690 MB at that spot. **The same spot with `VICTORY_CARD_ROOM_FOR_TARGETS_MB=2048`** (the old flat rule with a lower amount, so the release point is 1,024 MB; `64d4931b3` + PR #560, `VICTORY_BUFFERS_AHEAD=0`, otherwise as run B; one run of 14.3 minutes): | | run B (3,072, default; 6.4 min) | run D (2,048; 14.3 min) | |---|---|---| | samples saying "no room" | 55 of 72 | 62 of 164 (28 of 103 in the first 9 minutes, 34 of 61 after) | | reserve given back | never | 78 s after start; back twice for under a minute (517-920 MB) when the targets grew | | "no room" samples that would have had room without the reserve | 55 of 55 | 14 of 62 | | card "in use" at the end / budget | 5,525 MB / 6.7-7.25 GB | 6,811 MB / 6.5-7.0 GB | | `brought up to date although the card has no room` lines a minute | about 70 | about 41 | | `out of VRAM`, `E_OUTOFMEMORY`, ERROR lines | 0 | 0 | So with the reserve released the queue has room where it had none, and the card then really fills: 48 of the 62 remaining "no room" samples are the card at its budget (in use 6.75-6.8 GB, above the DXGI budget in 18 samples), not the reserve, and they get more frequent as the run goes on. One run; I have no by-eye verdict on the walls and floor for it. The one thing noticed by eye in that run was the player character's face skin turning flat white-grey at the house; I don't know whether that has anything to do with the fuller card. Caveats: short runs in one sitting, one machine; run A rebuilt its shader caches, the others had warm ones; A / B / D and C are different bases, and D carries PR #560. Not tested: this PR's code. I have photos of the two interiors but am not attaching them. Separate from this: the blue-white glow on the table and floor in the same room on `64d4931b3` looks like the indoor reflection problem in #468 and #507 (same house), not memory. Measurements and this report were prepared with an AI assistant (Claude Code); the runs were played on my machine.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/76/head:github-bot/gh-76'
git switch 'github-bot/gh-76'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-76'
git switch 'github-bot/gh-76'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-76'
git switch 'github-bot/gh-76'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-76'
git switch 'main'
git merge --squash 'github-bot/gh-76'
git switch 'main'
git merge --ff-only 'github-bot/gh-76'
git switch 'main'
git merge 'github-bot/gh-76'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.