GPU: heap slot writes do not wait for a submission's texture uploads #1978

Closed
0xkn0wh3r3 wants to merge 1 commit from upstream-pr/1980 into main
0xkn0wh3r3 commented 2026-11-25 02:15:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T02:15:09Z.


The problem

While a submission brought its textures up to date, the title could not write any slot of the view heaps that submission uses. Title threads creating or copying descriptors, and draws mirroring a changed slot, stalled until the uploads were done.

The mechanism, in bindless.rs:

  • At each submission whose lists index a view heap, bindless::uploads checks every title-written texture the heaps view, and detiles (or hashes, where the memory is not watched) each one that changed.
  • It held each heap's Viewed lock through all of that. The only reason was that a texture the title releases meanwhile must not be freed under it (forget takes the same lock).
  • Viewed::set, which every write of a slot of that heap goes through (HostHeap::mirror, under the host heap's lock), needs that lock too, so it waited the whole time.

The fix

  • A lock of its own, UPLOADING, now keeps released textures alive. forget and uploads take it.
  • uploads holds a heap's Viewed lock only to copy out its texture list, then detiles and hashes without it.
  • Slot writes (Viewed::set) no longer wait for the uploads. Releasing a texture (forget) still does, as before.

The heaps' contents and the textures uploaded are the same.

Testing

No dedicated test: the gain shows only under contention in a game run, which I could not do here.

  • cargo test -p victory-gpu on an RTX 5070 Ti (driver 621.24): all pass except descriptor::host::tests::dynamic_slots_are_held_until_released and memory::tests::lists_share_a_table_and_copies_keep_their_views, which fail the same way on main (the NVIDIA 1,000,000-descriptor heap cap, #1835).
  • cargo clippy -p victory-gpu --all-targets, with and without --features diagnostics: clean.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6595603162 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1980). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T02:15:09Z. --- ## The problem While a submission brought its textures up to date, the title could not write any slot of the view heaps that submission uses. Title threads creating or copying descriptors, and draws mirroring a changed slot, stalled until the uploads were done. The mechanism, in `bindless.rs`: - At each submission whose lists index a view heap, `bindless::uploads` checks every title-written texture the heaps view, and detiles (or hashes, where the memory is not watched) each one that changed. - It held each heap's `Viewed` lock through all of that. The only reason was that a texture the title releases meanwhile must not be freed under it (`forget` takes the same lock). - `Viewed::set`, which every write of a slot of that heap goes through (`HostHeap::mirror`, under the host heap's lock), needs that lock too, so it waited the whole time. ## The fix - A lock of its own, `UPLOADING`, now keeps released textures alive. `forget` and `uploads` take it. - `uploads` holds a heap's `Viewed` lock only to copy out its texture list, then detiles and hashes without it. - Slot writes (`Viewed::set`) no longer wait for the uploads. Releasing a texture (`forget`) still does, as before. The heaps' contents and the textures uploaded are the same. ## Testing No dedicated test: the gain shows only under contention in a game run, which I could not do here. - `cargo test -p victory-gpu` on an RTX 5070 Ti (driver 621.24): all pass except `descriptor::host::tests::dynamic_slots_are_held_until_released` and `memory::tests::lists_share_a_table_and_copies_keep_their_views`, which fail the same way on `main` (the NVIDIA 1,000,000-descriptor heap cap, #1835). - `cargo clippy -p victory-gpu --all-targets`, with and without `--features diagnostics`: clean.
catminou4 commented 2026-11-25 03:03:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T02:48:39Z.

Review: COMMENTED


Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Heap slot writes no longer wait for a submission's texture uploads — removes a stall; ordering vs. the upload fence needs Windows stress testing.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051087053 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1980#pullrequestreview-6051087053). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T02:48:39Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Heap slot writes no longer wait for a submission's texture uploads — removes a stall; ordering vs. the upload fence needs Windows stress testing.
DesertGamer commented 2026-11-25 03:03:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DesertGamer on 2026-11-25T02:15:35Z.


VIctory V2: community PRs, merged and tested

Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.

Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150503031 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1980#issuecomment-7150503031). Originally posted by [DesertGamer](https://github.com/DesertGamer) on 2026-11-25T02:15:35Z. --- ### VIctory V2: community PRs, merged and tested Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch. **Where it stands today:** launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1). :warning: Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk. Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help: https://DesertGamer/VIctory-V2 *Unofficial community fork of Marvisak/VIctory, GPL-3.0.*
0xkn0wh3r3 commented 2026-11-25 07:03:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T06:35:33Z.


@catminou4: the ordering against the upload work is unchanged. bindless::uploads still runs at submission, before the lists do. What changed is which lock it holds. It takes the heap's lock only long enough to copy out the list of textures to check, and a lock of its own (UPLOADING, also taken by forget) keeps released textures alive while it uploads. A slot write during the upload no longer waits for it. That write's texture is checked at the next submission, the same as before, when it waited for this submission's uploads to finish and then missed them anyway.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154952033 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1980#issuecomment-7154952033). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T06:35:33Z. --- @catminou4: the ordering against the upload work is unchanged. `bindless::uploads` still runs at submission, before the lists do. What changed is which lock it holds. It takes the heap's lock only long enough to copy out the list of textures to check, and a lock of its own (`UPLOADING`, also taken by `forget`) keeps released textures alive while it uploads. A slot write during the upload no longer waits for it. That write's texture is checked at the next submission, the same as before, when it waited for this submission's uploads to finish and then missed them anyway.
Marvisak commented 2026-11-25 09:06:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T08:25:31Z.


Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-gpu/src/bindless.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (merge candidate) was for an older state of main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7157008608 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1980#issuecomment-7157008608). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T08:25:31Z. --- <!-- victory-triage v1 head=af33f9009c00ddbf5a522f16987b76ba918fac27 verdict=needs-rebase at=2026-11-25T16:19:30Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-gpu/src/bindless.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (merge candidate) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 19:04:50 +00:00
0xkn0wh3r3 commented 2026-11-25 19:06:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T18:51:01Z.


Closing: upstream 56f75f8 (textures are brought up outside the heaps' locks, several at a time) does what this did. bindless::uploads takes its work list under each Viewed lock, then refreshes and detiles without it, so Viewed::set no longer waits on uploads. cea278c and 42ea09f extend the same approach to making textures and views.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171488390 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1980#issuecomment-7171488390). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T18:51:01Z. --- Closing: upstream 56f75f8 (textures are brought up outside the heaps' locks, several at a time) does what this did. `bindless::uploads` takes its work list under each `Viewed` lock, then refreshes and detiles without it, so `Viewed::set` no longer waits on uploads. cea278c and 42ea09f extend the same approach to making textures and views.

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
Marvisak/VIctory!1978
No description provided.