GPU: rebind replaced descriptor heaps by host identity #1331

Open
github-bot wants to merge 1 commit from github-bot/gh-1331 into main AGit
Owner

@⁠EatCodeSleep2 on GitHub · 2026-11-24 17:30 UTC · original
EatCodeSleep2:fix/rebind-replaced-descriptor-heaps-1242 → main · +71 −14 · 1 files · 1 commits · open

Summary

Compare the D3D12 descriptor heaps resolved for the current draw or dispatch against the host objects already bound. When a title heap is released and its address is reused, the new host heap is distinct because the recording still holds a reference to the old host heap. Rebind and invalidate both cached root signatures when the host heap changes.

Refs #1242, finding VIC-BT-013.

Verification

  • The synthetic regression binds a native heap twice, then replaces it and verifies the root bindings are invalidated. It fails when the cache deliberately treats occupied heap slots as identical.
  • The focused test passed on native Direct3D 12 and WARP.
  • GPU diagnostics library suite: 54 passed, 1 ignored. All-targets Clippy with diagnostics passed.

The test checks host heap replacement during recording. It does not force guest allocator address reuse or submit GPU work. AI-assisted. No game files used.

**@⁠EatCodeSleep2** on GitHub · 2026-11-24 17:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/1331) `EatCodeSleep2:fix/rebind-replaced-descriptor-heaps-1242` → `main` · +71 −14 · 1 files · 1 commits · open ## Summary Compare the D3D12 descriptor heaps resolved for the current draw or dispatch against the host objects already bound. When a title heap is released and its address is reused, the new host heap is distinct because the recording still holds a reference to the old host heap. Rebind and invalidate both cached root signatures when the host heap changes. Refs #1242, finding VIC-BT-013. ## Verification - The synthetic regression binds a native heap twice, then replaces it and verifies the root bindings are invalidated. It fails when the cache deliberately treats occupied heap slots as identical. - The focused test passed on native Direct3D 12 and WARP. - GPU diagnostics library suite: 54 passed, 1 ignored. All-targets Clippy with diagnostics passed. The test checks host heap replacement during recording. It does not force guest allocator address reuse or submit GPU work. AI-assisted. No game files used.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:27:52 +00:00
Author
Owner

@⁠acetonahard-code on GitHub · 2026-11-24 19:21 UTC · original

Tested this on a GPU with SM 6.6 support (RTX 4070 SUPER, driver 621.14, Windows 11, repo toolchain), merged into current main (ffe310e).

cargo test -p victory-gpu passed failed ignored
main 50 0 1
main + this PR 51 0 1
main, --all-features 53 0 1
main + this PR, --all-features 54 0 1
  • The new test passes.
  • Run with --nocapture, and no "no SM 6.6 ... device; skipped" lines were printed, so no GPU test skipped for lack of a device.
  • cargo clippy --all-targets -- -D warnings, with and without --all-features: clean.
  • Minor: cargo fmt --check would rewrap one block this PR adds (draw.rs). main isn't rustfmt-clean either, so take it or leave it.
  • frame::tests::waits_end_on_ticks_and_count_frames failed once and passed on a rerun. It's timing-flaky on main too (2 of 10 full-suite runs here), and unrelated to this PR.

I didn't test with game data.


Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.

**@⁠acetonahard-code** on GitHub · 2026-11-24 19:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/1331#issuecomment-7141975873) Tested this on a GPU with SM 6.6 support (RTX 4070 SUPER, driver 621.14, Windows 11, repo toolchain), merged into current `main` (ffe310e). | `cargo test -p victory-gpu` | passed | failed | ignored | |---|---|---|---| | `main` | 50 | 0 | 1 | | `main` + this PR | 51 | 0 | 1 | | `main`, `--all-features` | 53 | 0 | 1 | | `main` + this PR, `--all-features` | 54 | 0 | 1 | - The new test passes. - Run with `--nocapture`, and no "no SM 6.6 ... device; skipped" lines were printed, so no GPU test skipped for lack of a device. - `cargo clippy --all-targets -- -D warnings`, with and without `--all-features`: clean. - Minor: `cargo fmt --check` would rewrap one block this PR adds (`draw.rs`). `main` isn't rustfmt-clean either, so take it or leave it. - `frame::tests::waits_end_on_ticks_and_count_frames` failed once and passed on a rerun. It's timing-flaky on `main` too (2 of 10 full-suite runs here), and unrelated to this PR. I didn't test with game data. --- <sub>Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.</sub>
Author
Owner

@⁠wbkepler on GitHub · 2026-11-24 20:56 UTC · original

On whether the new key can itself hit ABA: I don't think it can. Every host heap whose as_raw() ends up in host_heaps has just been passed to list.keep, which holds it until HostList::reset. On upstream the only call to that for title lists is list.rs reset, and it is immediately followed by state.reset(pipeline), which zeroes host_heaps. So a cached identity can't be freed and reused while it is still cached. (The p.copy.reset() in host.rs is a prelude copy list with no State.)

Merge-order note: #1382 rewrites the same SetDescriptorHeaps block in State::prepare (a stack array instead of the Vec). The two conflict textually but don't clash in intent, so whichever lands second just needs a rebase. The host-identity comparison here should be kept.

AI-assisted review (Claude Code); checked on Windows 11 / RTX 5090.

**@⁠wbkepler** on GitHub · 2026-11-24 20:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/1331#issuecomment-7144259802) On whether the new key can itself hit ABA: I don't think it can. Every host heap whose `as_raw()` ends up in `host_heaps` has just been passed to `list.keep`, which holds it until `HostList::reset`. On upstream the only call to that for title lists is `list.rs` `reset`, and it is immediately followed by `state.reset(pipeline)`, which zeroes `host_heaps`. So a cached identity can't be freed and reused while it is still cached. (The `p.copy.reset()` in `host.rs` is a prelude copy list with no `State`.) Merge-order note: #1382 rewrites the same `SetDescriptorHeaps` block in `State::prepare` (a stack array instead of the `Vec`). The two conflict textually but don't clash in intent, so whichever lands second just needs a rebase. The host-identity comparison here should be kept. _AI-assisted review (Claude Code); checked on Windows 11 / RTX 5090._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:22 UTC · original

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-gpu/src/draw.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/1331#issuecomment-7149482688) <!-- victory-triage v1 head=84845210cc9e32b9e976ff1d69d5e8b93340c7f8 verdict=needs-rebase at=2026-11-25T01:22:37Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-gpu/src/draw.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/draw.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1331/head:github-bot/gh-1331'
git switch 'github-bot/gh-1331'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1331'
git switch 'github-bot/gh-1331'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1331'
git switch 'github-bot/gh-1331'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1331'
git switch 'main'
git merge --squash 'github-bot/gh-1331'
git switch 'main'
git merge --ff-only 'github-bot/gh-1331'
git switch 'main'
git merge 'github-bot/gh-1331'
git push origin 'main'
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!1331
No description provided.