GPU: a decoration bake draw's own textures are uploaded before it #1261

Closed
UwUCammie wants to merge 1 commit from upstream-pr/1264 into main
UwUCammie commented 2026-11-26 05:26:47 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by UwUCammie on 2026-11-26T05:26:47Z.


The decoration bake (the pass that composites characters' skin once while a scene loads) binds no texture through a table. Each draw's constants and its buffer of 304-byte records hold view heap indices, so everything it samples has to be on the card already through the queue of textures picked by index. A source still waiting at that moment is baked wrong for the rest of the run: black, blotched or missing skin on NPCs.

The early pass that is meant to cover this misses in three ways:

  • it knows four bake pixel programs by hash; the title has 322 of them, and the opening cutscene alone draws with others;
  • it runs the whole queue in the queue's order under a time and byte budget, so the slots this draw needs may not be reached;
  • it uploads nothing while resource::room() says the card is full.

Change

  • A bake program is recognised by what it reads instead of by hash: a pixel shader whose only table entries are a buffer of 304-byte records and a constant buffer in the same table. All 322 have that shape and differ only in the two table offsets.
  • Before such a draw, its constants and the records it walks are read, and the indices that name texture views are collected. The ones still waiting in the queue are uploaded first, whatever their turn, the budget and the room, up to VICTORY_BAKE_SOURCES_MB (default 1024) per draw.
  • A source the spans dropped as stale (the title wrote a newer view of clashing memory but still reads the old slot) is put back in the queue and uploaded too.
  • VICTORY_BAKE_SOURCES=0 only counts.
  • One log line per bake draw (the first, at counts that double, and every draw that still samples something wrong) with what the draw named and what was done. sampled_wrong is counted after the passes: textures whose memory is mapped and whose host slot still shows nothing.

The existing budgeted pass for the four listed programs is left as it is.

Measured

RX 7900 XT 20 GB, RADV 26.3.1, Wine 11.22, vkd3d-proton; 988aa41 plus this commit, diagnostics build; opening cutscene to about 100 s; no relay, late wait or async submit, 24 ms pipeline wait. One run per row:

card VICTORY_BAKE_SOURCES bake sources sampled wrong uploaded for bake draws
free (18.9 GB budget) 0 30 -
free default 0 24 textures, 28 MB
room cut to 55 % 0 511 -
room cut to 55 % default 0 88 textures, 106 MB

The 55 % rows use VICTORY_TEXTURE_ROOM_PERCENT=55 to get the accounting of a card shared with another game. That is a simulation: the queue is told there is no room while the memory is really there, so it shows that the bake no longer depends on the room check, not what happens when an allocation actually fails.

Most of what a bake draw finds "waiting" on main is a streamed texture that is partly mapped and already uploaded as far as it is mapped; those are counted separately (as_far_as_mapped_already) and left alone.

What this does not fix

  • Textures picked by index at display time still starve when the card has no room. On my integration branch, with the room cut, a head stayed black although every bake source had been uploaded.
  • Whole heads missing (eyes and teeth floating) on this stack. I see that with and without the change in these runs; it is a different problem.

#1097 raises the room line for bake passes and widens the due list for the four listed programs. This goes at the same problem from the draw's side and covers every bake program. They overlap in early_textures, so whichever lands second needs a small rebase.

Tests

  • cargo clippy --workspace --all-targets --locked -- -D warnings, and with --all-features: clean.
  • Two new unit tests: the queue hands out the slots a draw names whatever their turn, and the indices a bake draw names are read from its constants and records.
  • cargo test -p victory-gpu --locked -- --test-threads=1 under Wine: 204 passed, 2 failed. The two (drvwatch::tests::the_system_takes_the_subscription, watch::tests::holes_are_known_by_their_bits_only_when_noted_for_good) fail the same way on 988aa41 without this change here.
<!-- greyfinch-sync:fxceless/victory-fork:issue:5504540706 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1264). Originally posted by [UwUCammie](https://github.com/UwUCammie) on 2026-11-26T05:26:47Z. --- The decoration bake (the pass that composites characters' skin once while a scene loads) binds no texture through a table. Each draw's constants and its buffer of 304-byte records hold view heap indices, so everything it samples has to be on the card already through the queue of textures picked by index. A source still waiting at that moment is baked wrong for the rest of the run: black, blotched or missing skin on NPCs. The early pass that is meant to cover this misses in three ways: - it knows four bake pixel programs by hash; the title has 322 of them, and the opening cutscene alone draws with others; - it runs the whole queue in the queue's order under a time and byte budget, so the slots this draw needs may not be reached; - it uploads nothing while `resource::room()` says the card is full. ## Change - A bake program is recognised by what it reads instead of by hash: a pixel shader whose only table entries are a buffer of 304-byte records and a constant buffer in the same table. All 322 have that shape and differ only in the two table offsets. - Before such a draw, its constants and the records it walks are read, and the indices that name texture views are collected. The ones still waiting in the queue are uploaded first, whatever their turn, the budget and the room, up to `VICTORY_BAKE_SOURCES_MB` (default 1024) per draw. - A source the spans dropped as stale (the title wrote a newer view of clashing memory but still reads the old slot) is put back in the queue and uploaded too. - `VICTORY_BAKE_SOURCES=0` only counts. - One log line per bake draw (the first, at counts that double, and every draw that still samples something wrong) with what the draw named and what was done. `sampled_wrong` is counted after the passes: textures whose memory is mapped and whose host slot still shows nothing. The existing budgeted pass for the four listed programs is left as it is. ## Measured RX 7900 XT 20 GB, RADV 26.3.1, Wine 11.22, vkd3d-proton; `988aa41` plus this commit, diagnostics build; opening cutscene to about 100 s; no relay, late wait or async submit, 24 ms pipeline wait. One run per row: | card | `VICTORY_BAKE_SOURCES` | bake sources sampled wrong | uploaded for bake draws | |---|---|---|---| | free (18.9 GB budget) | 0 | 30 | - | | free | default | 0 | 24 textures, 28 MB | | room cut to 55 % | 0 | 511 | - | | room cut to 55 % | default | 0 | 88 textures, 106 MB | The 55 % rows use `VICTORY_TEXTURE_ROOM_PERCENT=55` to get the accounting of a card shared with another game. That is a simulation: the queue is told there is no room while the memory is really there, so it shows that the bake no longer depends on the room check, not what happens when an allocation actually fails. Most of what a bake draw finds "waiting" on main is a streamed texture that is partly mapped and already uploaded as far as it is mapped; those are counted separately (`as_far_as_mapped_already`) and left alone. ## What this does not fix - Textures picked by index at display time still starve when the card has no room. On my integration branch, with the room cut, a head stayed black although every bake source had been uploaded. - Whole heads missing (eyes and teeth floating) on this stack. I see that with and without the change in these runs; it is a different problem. ## Related #1097 raises the room line for bake passes and widens the due list for the four listed programs. This goes at the same problem from the draw's side and covers every bake program. They overlap in `early_textures`, so whichever lands second needs a small rebase. ## Tests - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and with `--all-features`: clean. - Two new unit tests: the queue hands out the slots a draw names whatever their turn, and the indices a bake draw names are read from its constants and records. - `cargo test -p victory-gpu --locked -- --test-threads=1` under Wine: 204 passed, 2 failed. The two (`drvwatch::tests::the_system_takes_the_subscription`, `watch::tests::holes_are_known_by_their_bits_only_when_noted_for_good`) fail the same way on `988aa41` without this change here.
Ym1r1710 commented 2026-11-26 09:08:04 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Ym1r1710 on 2026-11-26T08:22:17Z.


Tried this on an RTX 5080 (16 GB, Windows 11), Series X, prison cell opening. Card is tight on room here: around 250 texture passes a run find no room.

5 runs with it on, 2 with VICTORY_BAKE_SOURCES=0. Without it sampled_wrong_so_far ends at 71-84, with it 0 every time, so the counting side does what it says.

One thing I can't explain yet: in 1 of the 5 runs with it on, Lucia's whole shirt went black at about world+170 frames and stayed black for the rest of the run. I have around 60 earlier runs of the same scene without this PR and never saw that. Could be chance, but my guess is the forced uploads ignoring room() push out something the shirt needs at display time, which is the case you mention under "what this does not fix". Frame times were about the same (median 107-113 ms with it, 99-108 ms without, my noise is about 5-10 ms).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7186512541 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1264#issuecomment-7186512541). Originally posted by [Ym1r1710](https://github.com/Ym1r1710) on 2026-11-26T08:22:17Z. --- Tried this on an RTX 5080 (16 GB, Windows 11), Series X, prison cell opening. Card is tight on room here: around 250 texture passes a run find no room. 5 runs with it on, 2 with VICTORY_BAKE_SOURCES=0. Without it sampled_wrong_so_far ends at 71-84, with it 0 every time, so the counting side does what it says. One thing I can't explain yet: in 1 of the 5 runs with it on, Lucia's whole shirt went black at about world+170 frames and stayed black for the rest of the run. I have around 60 earlier runs of the same scene without this PR and never saw that. Could be chance, but my guess is the forced uploads ignoring room() push out something the shirt needs at display time, which is the case you mention under "what this does not fix". Frame times were about the same (median 107-113 ms with it, 99-108 ms without, my noise is about 5-10 ms).
UwUCammie commented 2026-11-26 14:03:31 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by UwUCammie on 2026-11-26T13:50:52Z.


The source path does bypass room() while sourced_bytes is below the per-draw cap. That makes memory pressure plausible. One black shirt in five runs leaves the cause open, and I don’t see an FPS gain in those timings.

VICTORY_BAKE_SOURCES=1 VICTORY_BAKE_SOURCES_MB=0 is a way to isolate it. The bake’s sources still go first in the due queue, but each upload goes through the usual room and budget checks. If you run that same checkpoint again, the shirt and sampled_wrong_so_far together would help distinguish the two effects.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7193919586 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1264#issuecomment-7193919586). Originally posted by [UwUCammie](https://github.com/UwUCammie) on 2026-11-26T13:50:52Z. --- The source path does bypass `room()` while `sourced_bytes` is below the per-draw cap. That makes memory pressure plausible. One black shirt in five runs leaves the cause open, and I don’t see an FPS gain in those timings. `VICTORY_BAKE_SOURCES=1 VICTORY_BAKE_SOURCES_MB=0` is a way to isolate it. The bake’s sources still go first in the due queue, but each upload goes through the usual room and budget checks. If you run that same checkpoint again, the shirt and `sampled_wrong_so_far` together would help distinguish the two effects.
UwUCammie commented 2026-11-26 19:19:24 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by UwUCammie on 2026-11-26T19:19:24Z.


Dathinel ported this to the Cool Fox line and tested it on a 4 GB RTX 3050 Laptop. They report that 104 of 107 sampled bake draws read a texture that wasn’t resident before the change, versus 0 of 111 with it. They counted 106 textures (29 MB) uploaded ahead of those draws. That gives us an independent residency check. The report leaves the effect on the appearance of skin unverified. Tester’s report

<!-- greyfinch-sync:fxceless/victory-fork:comment:7201454752 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1264#issuecomment-7201454752). Originally posted by [UwUCammie](https://github.com/UwUCammie) on 2026-11-26T19:19:24Z. --- Dathinel ported this to the Cool Fox line and tested it on a 4 GB RTX 3050 Laptop. They report that 104 of 107 sampled bake draws read a texture that wasn’t resident before the change, versus 0 of 111 with it. They counted 106 textures (29 MB) uploaded ahead of those draws. That gives us an independent residency check. The report leaves the effect on the appearance of skin unverified. [Tester’s report](https://github.com/4lwayz/portwatch-vi/issues/211)
UwUCammie commented 2026-11-27 22:35:29 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by UwUCammie on 2026-11-27T22:35:29Z.


Closing this one. Since the rebase onto VIctory-NVIDIA (5dbf5ce2), main brings a bake draw's sources up to date itself (bring_bake_sources in draw.rs, same VICTORY_BAKE_SOURCES switch), on the bake's own list and regardless of the card's room, which is what this PR was after. Rebasing would only put a second path next to it.

If black or red faces still show up on main with that in, the counts on its BAKE_SOURCES line are the place to look first.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7229455694 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1264#issuecomment-7229455694). Originally posted by [UwUCammie](https://github.com/UwUCammie) on 2026-11-27T22:35:29Z. --- Closing this one. Since the rebase onto VIctory-NVIDIA (5dbf5ce2), main brings a bake draw's sources up to date itself (`bring_bake_sources` in `draw.rs`, same `VICTORY_BAKE_SOURCES` switch), on the bake's own list and regardless of the card's room, which is what this PR was after. Rebasing would only put a second path next to it. If black or red faces still show up on main with that in, the counts on its `BAKE_SOURCES` line are the place to look first.

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
fxceless/victory-fork!1261
No description provided.