GPU: a skin bake's own sources are uploaded while the card's budget holds them, not only under the texture line #1422

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

@⁠Granite900 on GitHub · 2026-11-27 01:46 UTC · original
Granite900:fix/bake-sources-budget → main · +42 −8 · 2 files · 1 commits · open

With VICTORY_BAKE_SOURCES=1, a skin-bake draw's own sources are uploaded only while resource::room() says yes. room() counts the room kept for buffer copies and render targets not made yet (up to 4.3 GB while a world loads) as used, and stops at 90 % of the budget. The bakes run while the world loads, so on a card far under its budget nearly every one of those uploads was refused, and the faces they bake came out black or blotched for the run.

There were two gates:

  1. bake_sources_pass asks room() before the upload: 106 skipped with the card at 6.7 GB of a 15.4 GB budget.
  2. The texture pass the upload runs in asks room() itself, at its start and every 32 MiB. With gate 1 opened, 309 of 336 waiting sources were still not made, and none of them were counted as skipped.

Change: both gates ask a new resource::within_budget(bytes) instead: what is in use, plus the draw's own VICTORY_BAKE_SOURCES_MB, under 95 % of the budget, the margin Dawn's D3D12 residency keeps. Nothing kept for copies not made yet is counted. =full, =count and every other texture upload are unchanged. 42 lines in draw.rs and resource.rs.

Measured on an RX 9070 XT (16 GB, driver 32.0.32029.2010), the café scene of the opening, diagnostics build, the test switch set plus VICTORY_TILES_SMALL_WHEN_FULL_MB=512 and VICTORY_TEXTURE_ROOM_PERCENT=96:

bake draws sampling a missing texture uploaded ahead skipped for room
=1 before 233 101 55 (63 MB) 106
=1 with gate 1 only 153 11 27 0
=1 with this change 189 0 83 (98 MB) 0

The card peaked at 12.7 GB of 13.9 GB. There was no device loss. The black-shirt case reported in #1264 was with =full and a 1 GB cap, and did not appear here.

What this does not fix: faces that stay black because their ordinary textures are never made for lack of room. With the change, one person in the café still had a black face, and 29,059 title textures had no host copy at the end of that run (14.0 GB). Black skin of that kind goes away with more room (VICTORY_CARD_WINDOWS_MB=512), at a cost in frame time and churn on this card.

Not measured: the frame-time cost. There is one run each way and the scenes differ, but the uploads are small (98 MB over the whole load).

Checks: cargo clippy -p victory-gpu -p victory --all-targets --locked -- -D warnings is clean. cargo test -p victory-gpu -- --test-threads=1 gives 237 passed with tiles::tests::card_wrote_failure_does_not_poison_card_mask skipped: it ends the process with an access violation on main as well (reported in #1416).

Builds on #1264 (UwUCammie).

AI-assisted (Claude Code); no game data.

🤖 Generated with Claude Code

**@⁠Granite900** on GitHub · 2026-11-27 01:46 UTC · [original](https://github.com/fxceless/victory-fork/pull/1422) `Granite900:fix/bake-sources-budget` → `main` · +42 −8 · 2 files · 1 commits · open With `VICTORY_BAKE_SOURCES=1`, a skin-bake draw's own sources are uploaded only while `resource::room()` says yes. `room()` counts the room kept for buffer copies and render targets not made yet (up to 4.3 GB while a world loads) as used, and stops at 90 % of the budget. The bakes run while the world loads, so on a card far under its budget nearly every one of those uploads was refused, and the faces they bake came out black or blotched for the run. There were two gates: 1. `bake_sources_pass` asks `room()` before the upload: **106 skipped** with the card at **6.7 GB of a 15.4 GB budget**. 2. The texture pass the upload runs in asks `room()` itself, at its start and every 32 MiB. With gate 1 opened, **309 of 336** waiting sources were still not made, and none of them were counted as skipped. **Change:** both gates ask a new `resource::within_budget(bytes)` instead: what is in use, plus the draw's own `VICTORY_BAKE_SOURCES_MB`, under **95 %** of the budget, the margin Dawn's D3D12 residency keeps. Nothing kept for copies not made yet is counted. `=full`, `=count` and every other texture upload are unchanged. 42 lines in `draw.rs` and `resource.rs`. **Measured** on an RX 9070 XT (16 GB, driver 32.0.32029.2010), the café scene of the opening, diagnostics build, the test switch set plus `VICTORY_TILES_SMALL_WHEN_FULL_MB=512` and `VICTORY_TEXTURE_ROOM_PERCENT=96`: | | bake draws | sampling a missing texture | uploaded ahead | skipped for room | |---|---|---|---|---| | `=1` before | 233 | **101** | 55 (63 MB) | 106 | | `=1` with gate 1 only | 153 | 11 | 27 | 0 | | `=1` with this change | 189 | **0** | 83 (98 MB) | 0 | The card peaked at 12.7 GB of 13.9 GB. There was no device loss. The black-shirt case reported in #1264 was with `=full` and a 1 GB cap, and did not appear here. **What this does not fix:** faces that stay black because their ordinary textures are never made for lack of room. With the change, one person in the café still had a black face, and 29,059 title textures had no host copy at the end of that run (14.0 GB). Black skin of that kind goes away with more room (`VICTORY_CARD_WINDOWS_MB=512`), at a cost in frame time and churn on this card. **Not measured:** the frame-time cost. There is one run each way and the scenes differ, but the uploads are small (98 MB over the whole load). **Checks:** `cargo clippy -p victory-gpu -p victory --all-targets --locked -- -D warnings` is clean. `cargo test -p victory-gpu -- --test-threads=1` gives 237 passed with `tiles::tests::card_wrote_failure_does_not_poison_card_mask` skipped: it ends the process with an access violation on `main` as well (reported in #1416). Builds on #1264 (UwUCammie). AI-assisted (Claude Code); no game data. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With VICTORY_BAKE_SOURCES=1 the upload before a skin-bake draw asked
resource::room, which counts the room kept for buffer copies and render
targets not made yet (up to 4.3 GB while a world loads) as used and stops
at 90 % of the budget. The bakes run while the world loads, so nearly every
such upload was refused on a card far under its budget (RX 9070 XT: 106
skipped at 6.7 GB of 15.4 GB), and the texture pass the upload runs asked
room itself again (309 of 336 sources not made once the first gate was
passed). A source missing at the bake is baked as nothing for the run:
black or blotched faces.

Both now ask resource::within_budget: what is in use plus the draw's own
bytes (VICTORY_BAKE_SOURCES_MB) under 95 % of the budget. =full is
unchanged. Measured on an RX 9070 XT (café scene of the opening): bake
draws sampling a missing texture 101 -> 0, 98 MB uploaded ahead of 189
bake draws, card peak 12.7 of 13.9 GB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 02:19:16 +00:00
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/1422/head:github-bot/gh-1422'
git switch 'github-bot/gh-1422'

Merge

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