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

Open
Granite900 wants to merge 1 commit from upstream-pr/1422 into main
Granite900 commented 2026-11-27 01:46:55 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Granite900 on 2026-11-27T01:46:55Z.


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

<!-- greyfinch-sync:fxceless/victory-fork:issue:5519756342 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1422). Originally posted by [Granite900](https://github.com/Granite900) on 2026-11-27T01:46:55Z. --- 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)
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/1422:upstream-pr/1422'
git switch 'upstream-pr/1422'

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/1422'
git switch 'upstream-pr/1422'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1422'
git switch 'upstream-pr/1422'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1422'
git switch 'main'
git merge --squash 'upstream-pr/1422'
git switch 'main'
git merge --ff-only 'upstream-pr/1422'
git switch 'main'
git merge 'upstream-pr/1422'
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!1422
No description provided.