GPU: a list that binds a heap's view-address table keeps it until reset #2327

Open
denkencar-sketch wants to merge 1 commit from upstream-pr/2329 into main
denkencar-sketch commented 2026-11-25 10:42:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T10:42:39Z.


Summary

The view-address table a list binds lived and died with its heap, which the title may release while the GPU still reads the table as a root view. A list that binds it now keeps it until reset. It is also made under the made-slots lock now, so a view noted meanwhile is not lost.

Testing

Test a_list_keeps_the_view_address_table_it_binds fails without the keep and passes with this change. The second part, holding the lock across the publish, is not covered by a test (it is right by reading).

cargo test --workspace --locked passes apart from known flakes: modules::dstorage::tests::a_page_list_filled_after_its_request_starts fails now and then on main too, and so does a parallel-run flake in victory-gpu's lib tests (watch:: and descriptor::host:: tests, 2 of 40 runs on pristine main).

This changes the same function as open PR #1906, so a small textual conflict is expected. Not tried: a run in the game.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6602638196 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2329). Originally posted by [denkencar-sketch](https://github.com/denkencar-sketch) on 2026-11-25T10:42:39Z. --- ## Summary The view-address table a list binds lived and died with its heap, which the title may release while the GPU still reads the table as a root view. A list that binds it now keeps it until reset. It is also made under the made-slots lock now, so a view noted meanwhile is not lost. ## Testing Test `a_list_keeps_the_view_address_table_it_binds` fails without the keep and passes with this change. The second part, holding the lock across the publish, is not covered by a test (it is right by reading). `cargo test --workspace --locked` passes apart from known flakes: `modules::dstorage::tests::a_page_list_filled_after_its_request_starts` fails now and then on `main` too, and so does a parallel-run flake in `victory-gpu`'s lib tests (`watch::` and `descriptor::host::` tests, 2 of 40 runs on pristine `main`). This changes the same function as open PR #1906, so a small textual conflict is expected. Not tried: a run in the game. AI-assisted.
catminou4 commented 2026-11-25 11:04:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T10:54:11Z.

Review: COMMENTED


A list binding a heap's view-address table keeps it until published — lock ordering documented. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.

<!-- greyfinch-sync:Marvisak/VIctory:review:6056245440 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2329#pullrequestreview-6056245440). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T10:54:11Z. **Review:** COMMENTED --- A list binding a heap's view-address table keeps it until published — lock ordering documented. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
DenRakEiw commented 2026-11-25 12:03:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T11:42:30Z.

Review: APPROVED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Retaining the bound view-address table on the command list until reset cleanly prevents use-after-free when a heap's table is replaced while commands are still in flight.
  • cargo test -p victory-gpu draw::tests: 6/6 passed on RTX 5090, 6/6 passed on WARP (including a_list_keeps_the_view_address_table_it_binds).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6056966210 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2329#pullrequestreview-6056966210). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T11:42:30Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Retaining the bound view-address table on the command list until reset cleanly prevents use-after-free when a heap's table is replaced while commands are still in flight. - `cargo test -p victory-gpu draw::tests`: 6/6 passed on RTX 5090, 6/6 passed on WARP (including `a_list_keeps_the_view_address_table_it_binds`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
Marvisak commented 2026-11-25 16:09:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:22:58Z.


Automated triage for the maintainers.

Verdict: merge candidate (as before the conflict). Thanks for rebasing; it merges cleanly into current main.

crates/victory-gpu/src/draw.rs: the root SRV bound for view addresses now goes through kept_view_addresses, which list.keeps the table's ID3D12Resource. On main a list keeps the descriptor heaps it binds (draw.rs around line 1027) but not this upload buffer, which HostHeap owns. So a heap the title releases before the list runs could free a buffer the GPU still reads. descriptor/host.rs view_addresses now takes the made lock before get_or_init and holds it until the table is published. mirror notes addresses while holding that lock, so an address noted between the snapshot and the publish is no longer lost.

Outside this PR: dynamic slots (make_at, make_raw) call note_address without the made lock, and their entries aren't in the snapshot. That is the same as on main.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166755200 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2329#issuecomment-7166755200). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:22:58Z. --- <!-- victory-triage v1 head=0c80172b507e0ea27610641417fe78c03d219ae1 verdict=merge-candidate at=2026-11-26T03:25:41Z --> Automated triage for the maintainers. **Verdict: merge candidate** (as before the conflict). Thanks for rebasing; it merges cleanly into current `main`. `crates/victory-gpu/src/draw.rs`: the root SRV bound for view addresses now goes through `kept_view_addresses`, which `list.keep`s the table's `ID3D12Resource`. On `main` a list keeps the descriptor heaps it binds (`draw.rs` around line 1027) but not this upload buffer, which `HostHeap` owns. So a heap the title releases before the list runs could free a buffer the GPU still reads. `descriptor/host.rs` `view_addresses` now takes the `made` lock before `get_or_init` and holds it until the table is published. `mirror` notes addresses while holding that lock, so an address noted between the snapshot and the publish is no longer lost. Outside this PR: dynamic slots (`make_at`, `make_raw`) call `note_address` without the `made` lock, and their entries aren't in the snapshot. That is the same as on `main`. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 16:04:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T15:04:44Z.

Review: APPROVED


Reviewed descriptor/host.rs, draw.rs, and host.rs at 0c80172b merged onto origin/main (63bcca43) and verified on RTX 5090 and WARP (VICTORY_D3D12_WARP=1) with VICTORY_D3D12_DEBUG=1.

Code & concurrency audit

  • Lifetime retention across execution & State::cut: draw.rs:856 routes root-SRV binding of stage.view_addresses through kept_view_addresses (draw.rs:2014), which calls list.keep(table) on heap.view_addresses_buffer() (descriptor/host.rs:607) so the upload buffer remains alive until HostList::reset() even if the title releases the descriptor heap before submission. Because State::cut resets cached host state and State::bind re-runs the binding loop on the new segment, every segment that binds the table retains it.
  • Locking & lost-update fix: HostHeap::view_addresses() (descriptor/host.rs:567-598) fast-paths self.addresses.get() and holds self.made (descriptor/host.rs:573) across self.addresses.get_or_init(...), closing the race where a concurrent mirror() could write a slot between the initial snapshot and OnceLock publication. Lock ordering (self.made -> view_at / VIEWS) matches mirror().
  • Merge note: touches the same three files as open #2293 (and #1906), so a minor conflict resolution may be needed depending on merge order.

Verification

  • cargo run -p xtask -- policy: 191 files ok.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default and --all-features): clean.
  • descriptor:: draw:: host:: with VICTORY_D3D12_DEBUG=1: 62/62 passed on RTX 5090 (skipping dynamic_slots_are_held_until_released) and 63/63 passed on WARP (--features diagnostics, skipping the pre-existing main compositor_failure_presents_primary_in_the_same_frame Debug Layer mismatch), including a_list_keeps_the_view_address_table_it_binds (draw.rs:2065).
  • Additional RTX 5090 + Debug Layer probe dropping HostHeap after kept_view_addresses and before list.close() / host.execute() / list.reset() passed cleanly, confirming the buffer stays live until reset (kept_count == 0 afterward) with GetDeviceRemovedReason().is_ok().
<!-- greyfinch-sync:Marvisak/VIctory:review:6076420045 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2329#pullrequestreview-6076420045). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T15:04:44Z. **Review:** APPROVED --- Reviewed `descriptor/host.rs`, `draw.rs`, and `host.rs` at `0c80172b` merged onto `origin/main` (`63bcca43`) and verified on RTX 5090 and WARP (`VICTORY_D3D12_WARP=1`) with `VICTORY_D3D12_DEBUG=1`. ### Code & concurrency audit - **Lifetime retention across execution & `State::cut`**: `draw.rs:856` routes root-SRV binding of `stage.view_addresses` through `kept_view_addresses` (`draw.rs:2014`), which calls `list.keep(table)` on `heap.view_addresses_buffer()` (`descriptor/host.rs:607`) so the upload buffer remains alive until `HostList::reset()` even if the title releases the descriptor heap before submission. Because `State::cut` resets cached host state and `State::bind` re-runs the binding loop on the new segment, every segment that binds the table retains it. - **Locking & lost-update fix**: `HostHeap::view_addresses()` (`descriptor/host.rs:567-598`) fast-paths `self.addresses.get()` and holds `self.made` (`descriptor/host.rs:573`) across `self.addresses.get_or_init(...)`, closing the race where a concurrent `mirror()` could write a slot between the initial snapshot and `OnceLock` publication. Lock ordering (`self.made` -> `view_at` / `VIEWS`) matches `mirror()`. - Merge note: touches the same three files as open `#2293` (and `#1906`), so a minor conflict resolution may be needed depending on merge order. ### Verification - `cargo run -p xtask -- policy`: 191 files ok. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`): clean. - `descriptor:: draw:: host::` with `VICTORY_D3D12_DEBUG=1`: **62/62 passed** on RTX 5090 (skipping `dynamic_slots_are_held_until_released`) and **63/63 passed** on WARP (`--features diagnostics`, skipping the pre-existing `main` `compositor_failure_presents_primary_in_the_same_frame` Debug Layer mismatch), including `a_list_keeps_the_view_address_table_it_binds` (`draw.rs:2065`). - Additional RTX 5090 + Debug Layer probe dropping `HostHeap` after `kept_view_addresses` and before `list.close()` / `host.execute()` / `list.reset()` passed cleanly, confirming the buffer stays live until reset (`kept_count == 0` afterward) with `GetDeviceRemovedReason().is_ok()`.
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/2329:upstream-pr/2329'
git switch 'upstream-pr/2329'

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