GPU draw: compare resolved host heap pointers to prevent descriptor heap ABA #1444

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

@⁠geiyiliyabumo on GitHub · 2026-11-24 18:02 UTC · original
geiyiliyabumo:fix/draw-heap-pointer-aba → main · +83 −13 · 1 files · 1 commits · closed without merging

Summary

Fixes \VIC-BT-013\ (tracked in #1242) in \crates/victory-gpu/src/draw.rs:

  • \State::bind\ previously compared raw title heap pointers (\self.host_heaps != self.heaps), creating a pointer-reuse ABA bug when a title releases a descriptor heap and allocates a new one at the same address (skipping \SetDescriptorHeaps\ even though the underlying host \ID3D12DescriptorHeap\ changed).
  • Extracts \State::sync_heaps\ and tracks the resolved host \ID3D12DescriptorHeap::as_raw() as usize\ COM pointers in \self.host_heaps\—matching how \self.host_pipeline\ already guards against pipeline ABA via \list.keep.
  • Adds a live D3D12 regression test (\draw::tests::sync_heaps_detects_new_host_heap_at_same_title_address) verifying no-op caching on identical host heaps and re-binding + \host_roots\ invalidation when a new host heap appears at the same title pointer.

Verification

  • \cargo test -p victory-gpu --lib draw::tests\ on AMD Radeon RX 9060 XT (RDNA4) and D3D12 WARP: 1 passed, 0 failed
  • \cargo clippy -p victory-gpu --all-targets -- -D warnings\ (default and --all-features): clean
  • \cargo xtask policy: 154 files ok

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 18:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/1444) `geiyiliyabumo:fix/draw-heap-pointer-aba` → `main` · +83 −13 · 1 files · 1 commits · closed without merging ## Summary Fixes \VIC-BT-013\ (tracked in #1242) in \crates/victory-gpu/src/draw.rs\: - \State::bind\ previously compared raw title heap pointers (\self.host_heaps != self.heaps\), creating a pointer-reuse ABA bug when a title releases a descriptor heap and allocates a new one at the same address (skipping \SetDescriptorHeaps\ even though the underlying host \ID3D12DescriptorHeap\ changed). - Extracts \State::sync_heaps\ and tracks the resolved host \ID3D12DescriptorHeap::as_raw() as usize\ COM pointers in \self.host_heaps\—matching how \self.host_pipeline\ already guards against pipeline ABA via \list.keep\. - Adds a live D3D12 regression test (\draw::tests::sync_heaps_detects_new_host_heap_at_same_title_address\) verifying no-op caching on identical host heaps and re-binding + \host_roots\ invalidation when a new host heap appears at the same title pointer. ## Verification - \cargo test -p victory-gpu --lib draw::tests\ on **AMD Radeon RX 9060 XT (RDNA4)** and **D3D12 WARP**: 1 passed, 0 failed - \cargo clippy -p victory-gpu --all-targets -- -D warnings\ (default and \--all-features\): clean - \cargo xtask policy\: 154 files ok *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:31:57 +00:00
github-bot closed this pull request 2026-11-26 04:31:57 +00:00
Author
Owner

@⁠acetonahard-code on GitHub · 2026-11-24 20:23 UTC · original

Heads-up: this looks like the same fix as #1331 (opened about 30 minutes earlier). Both change draw.rs so heaps are rebound when the resolved host ID3D12DescriptorHeap pointers change, instead of the title's heap addresses. That closes the same reuse/ABA case. The two PRs conflict in draw.rs, so only one can land as-is.

Tested on Windows 11, RTX 4070 SUPER (driver 621.14), with the 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, and 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 put the sync_heaps signature on one line. main isn't rustfmt-clean either.

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 20:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/1444#issuecomment-7143486505) Heads-up: this looks like the same fix as #1331 (opened about 30 minutes earlier). Both change `draw.rs` so heaps are rebound when the resolved host `ID3D12DescriptorHeap` pointers change, instead of the title's heap addresses. That closes the same reuse/ABA case. The two PRs conflict in `draw.rs`, so only one can land as-is. Tested on Windows 11, RTX 4070 SUPER (driver 621.14), with the 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, and 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 put the `sync_heaps` signature on one line. `main` isn't rustfmt-clean either. 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

@⁠geiyiliyabumo on GitHub · 2026-11-24 20:28 UTC · original

Thanks @⁠acetonahard-code for catching the overlap and running the RTX 4070 SUPER verification! I checked #1331 and it was indeed opened earlier with the exact same host-COM-identity fix (and avoids cloning on the fast path by borrowing &ID3D12DescriptorHeap). Closing this PR in favor of #1331 to keep the queue clean.

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 20:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1444#issuecomment-7143596290) Thanks @⁠acetonahard-code for catching the overlap and running the RTX 4070 SUPER verification! I checked #1331 and it was indeed opened earlier with the exact same host-COM-identity fix (and avoids cloning on the fast path by borrowing `&ID3D12DescriptorHeap`). Closing this PR in favor of #1331 to keep the queue clean. *AI-assisted; synthetic tests only, no game files.*

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!1444
No description provided.