gpu(menu): retire old Buffers on format/scale change instead of mem::forget #3049

Closed
github-bot wants to merge 1 commit from github-bot/gh-3049 into main AGit
Owner

@⁠RanoGames on GitHub · 2026-11-29 19:45 UTC · original
RanoGames:fix/menu-retire-buffers → main · +3 −1 · 1 files · 1 commits · closed without merging

What it changes

Fixes a permanent GPU/COM resource and memory leak in crates/victory-gpu/src/host/menu.rs:

  • When (format, scale) changed (e.g. on window resize), Menu::draw previously called std::mem::forget(self.buffers.take()), permanently leaking the old Buffers struct (Vec<(ID3D12Resource, *mut u8)> heap allocation, the 4 upload ID3D12Resource COM references, and card: ID3D12Resource).
  • Replaces std::mem::forget(self.buffers.take()) with if let Some(old) = self.buffers.take() { super::retire(old); }, deferring drop via host::retire until all in-flight and queued GPU submissions have finished.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): N/A (code-verified resource-retirement fix + menu unit tests)
  • Before: every format or scale change leaked Buffers (uploads + card ID3D12Resources) via std::mem::forget.
  • After: old Buffers is queued in host::retire and dropped safely after GPU submissions finish.
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A
  • cargo test passed for the crates it touches: yes (cargo test --locked -p victory-gpu --lib -- host::menu::tests --test-threads=1: 14 passed, 0 failed; cargo xtask policy --staged passed)

Checked for overlap

  • I searched the open and closed pull requests for the same issue (mem::forget, Buffers, menu.rs).
**@⁠RanoGames** on GitHub · 2026-11-29 19:45 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3049) `RanoGames:fix/menu-retire-buffers` → `main` · +3 −1 · 1 files · 1 commits · closed without merging ## What it changes Fixes a permanent GPU/COM resource and memory leak in `crates/victory-gpu/src/host/menu.rs`: - When `(format, scale)` changed (e.g. on window resize), `Menu::draw` previously called `std::mem::forget(self.buffers.take())`, permanently leaking the old `Buffers` struct (`Vec<(ID3D12Resource, *mut u8)>` heap allocation, the 4 upload `ID3D12Resource` COM references, and `card: ID3D12Resource`). - Replaces `std::mem::forget(self.buffers.take())` with `if let Some(old) = self.buffers.take() { super::retire(old); }`, deferring drop via `host::retire` until all in-flight and queued GPU submissions have finished. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): N/A (code-verified resource-retirement fix + menu unit tests) - Before: every format or scale change leaked `Buffers` (`uploads` + `card` `ID3D12Resource`s) via `std::mem::forget`. - After: old `Buffers` is queued in `host::retire` and dropped safely after GPU submissions finish. - For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A - `cargo test` passed for the crates it touches: yes (`cargo test --locked -p victory-gpu --lib -- host::menu::tests --test-threads=1`: 14 passed, 0 failed; `cargo xtask policy --staged` passed) ## Checked for overlap - [x] I searched the open and closed pull requests for the same issue (`mem::forget`, `Buffers`, `menu.rs`).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 19:47:19 +00:00
github-bot closed this pull request 2026-12-01 16:29:18 +00:00
Author
Owner

@⁠RanoGames on GitHub · 2026-12-01 16:24 UTC · original

Closing in favor of #915, which already retires the F1 menu buffers when the output format or UI scale changes.

**@⁠RanoGames** on GitHub · 2026-12-01 16:24 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3049#issuecomment-7317563699) Closing in favor of #915, which already retires the F1 menu buffers when the output format or UI scale changes.

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/trustno1-coder--VIctory-NVIDIA!3049
No description provided.