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

Closed
github-bot wants to merge 1 commit from gh-pr/1980/head into gh-pr/1980/base
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 02:15 UTC · original
0xkn0wh3r3:gpu/bindless-uploads-unlocked → main · +15 −4 · 1 files · 1 commits · closed without merging

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.
**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 02:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1980) `0xkn0wh3r3:gpu/bindless-uploads-unlocked` → `main` · +15 −4 · 1 files · 1 commits · closed without merging ## 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.
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 that changed. It held each heap's
`Viewed` lock through all of that, only so that a texture the title
releases meanwhile is not 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), waited the whole time:
title threads creating or copying descriptors, and draws mirroring a
changed slot, stalled behind the uploads.

A lock of its own now keeps released textures alive (`forget` and
`uploads` take it); `uploads` holds the heap's lock only to copy out its
texture list. The heaps' contents and the textures uploaded are the same.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:50:37 +00:00
github-bot closed this pull request 2026-11-26 04:50:37 +00:00
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-25 02:15 UTC · original

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.

**@⁠DesertGamer** on GitHub · 2026-11-25 02:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1980#issuecomment-7150503031) ### 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.*
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 06:35 UTC · original

@⁠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.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 06:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1980#issuecomment-7154952033) @⁠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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 08:25 UTC · original · edited 2026-11-25 16:05 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 08:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/1980#issuecomment-7157008608) · edited 2026-11-25 16:05 UTC <!-- 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)_
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 18:51 UTC · original

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.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 18:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/1980#issuecomment-7171488390) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1980
No description provided.