GPU/draw: fix per-heap refresh starvation & VRAM leak, OOB table drop… #541

Open
pug205gti6 wants to merge 1 commit from upstream-pr/541 into main
pug205gti6 commented 2026-11-25 02:02:32 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by pug205gti6 on 2026-11-25T02:02:32Z.


…s, and windowed indirect barrier

Fix three defects in crates/victory-gpu/src/draw.rs and crates/victory-gpu/src/descriptor/host.rs:

  1. State::heap_buffers & HostHeap: replace the process-global static FRAME and raw-pointer-keyed static RANGES (which starved a second view heap bound in the same frame and leaked Arc<Shadow> buffers forever without cleanup on heap destruction) with per-heap last_frame/passes/ranges keyed by a unique monotonic HostHeap::id(), cleaned up in impl Drop for HostHeap via draw::forget_heap(self.id). Key list.first_use per host heap pointer so binding multiple view heaps on the same command list keeps each heap's strides buffer and refreshes its views.
  2. State::tables: track tables that must be relocated because they reach past host.count() (oob), and push (slot, u32::MAX) into made if relocation fails (misaligned/sampler heap, missing host heap, or exceeding DYNAMIC / heap bounds), so bind() cleanly drops the draw instead of passing an out-of-bounds title offset to the GPU.
  3. State::execute_indirect: record hit_window = hit.is_some() and skip calling indirect::done(list, &bounded) (INDIRECT_ARGUMENT -> COMMON) when prepare fails on a window hit, because bounded is already in COMMON from the prior draw's done and ExecuteIndirect never ran to implicitly promote it.

Add synthetic unit test verifying per-heap frame tracking and forget_heap cleanup.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6595436262 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/541). Originally posted by [pug205gti6](https://github.com/pug205gti6) on 2026-11-25T02:02:32Z. --- …s, and windowed indirect barrier Fix three defects in `crates/victory-gpu/src/draw.rs` and `crates/victory-gpu/src/descriptor/host.rs`: 1. `State::heap_buffers` & `HostHeap`: replace the process-global `static FRAME` and raw-pointer-keyed `static RANGES` (which starved a second view heap bound in the same frame and leaked `Arc<Shadow>` buffers forever without cleanup on heap destruction) with per-heap `last_frame`/`passes`/`ranges` keyed by a unique monotonic `HostHeap::id()`, cleaned up in `impl Drop for HostHeap` via `draw::forget_heap(self.id)`. Key `list.first_use` per host heap pointer so binding multiple view heaps on the same command list keeps each heap's strides buffer and refreshes its views. 2. `State::tables`: track tables that must be relocated because they reach past `host.count()` (`oob`), and push `(slot, u32::MAX)` into `made` if relocation fails (misaligned/sampler heap, missing host heap, or exceeding `DYNAMIC` / heap bounds), so `bind()` cleanly drops the draw instead of passing an out-of-bounds title offset to the GPU. 3. `State::execute_indirect`: record `hit_window = hit.is_some()` and skip calling `indirect::done(list, &bounded)` (`INDIRECT_ARGUMENT -> COMMON`) when `prepare` fails on a window hit, because `bounded` is already in `COMMON` from the prior draw's `done` and `ExecuteIndirect` never ran to implicitly promote it. Add synthetic unit test verifying per-heap frame tracking and `forget_heap` cleanup.
Ezeko95 commented 2026-11-25 02:10:14 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Ezeko95 on 2026-11-25T02:04:42Z.


lgtm

<!-- greyfinch-sync:fxceless/victory-fork:comment:7150290322 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/541#issuecomment-7150290322). Originally posted by [Ezeko95](https://github.com/Ezeko95) on 2026-11-25T02:04:42Z. --- lgtm
Revens2 commented 2026-11-25 08:09:02 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Revens2 on 2026-11-25T07:37:48Z.


Duplicate of #481: @AscilCH opened this patch 40 minutes earlier, and gh pr diff returns the same bytes for both (+139/-31 on 2 file(s), same title).

Both PRs are CONFLICTING, so this copy does not resolve the conflict it was probably made for.

Please continue in #481 so the review history and any test data stay in one place.
Thanks.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7156075583 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/541#issuecomment-7156075583). Originally posted by [Revens2](https://github.com/Revens2) on 2026-11-25T07:37:48Z. --- Duplicate of #481: @AscilCH opened this patch 40 minutes earlier, and `gh pr diff` returns the same bytes for both (+139/-31 on 2 file(s), same title). Both PRs are CONFLICTING, so this copy does not resolve the conflict it was probably made for. Please continue in #481 so the review history and any test data stay in one place. Thanks.
Headache3318 commented 2026-11-25 09:08:50 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Headache3318 on 2026-11-25T08:50:44Z.


Independent verification: PR #541 (GPU/draw: fix per-heap refresh starvation & VRAM leak) merges cleanly (fast-forward), 10 files changed, +659/-52 lines. Build: success (9s). Tests: fail due to pre-existing Linux-host issues (windows_sys crate not found, console_insn module not found, host_resource function not found — issue #90). PR introduces no regressions. Machine: Arch Linux, kernel 7.3.5-arch1-1, 3x RTX 4090 driver 620.73.04, Proton, AI-assisted.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7157542945 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/541#issuecomment-7157542945). Originally posted by [Headache3318](https://github.com/Headache3318) on 2026-11-25T08:50:44Z. --- Independent verification: PR #541 (GPU/draw: fix per-heap refresh starvation & VRAM leak) merges cleanly (fast-forward), 10 files changed, +659/-52 lines. Build: success (9s). Tests: fail due to pre-existing Linux-host issues (windows_sys crate not found, console_insn module not found, host_resource function not found — issue #90). PR introduces no regressions. Machine: Arch Linux, kernel 7.3.5-arch1-1, 3x RTX 4090 driver 620.73.04, Proton, AI-assisted.
UwUCammie commented 2026-11-25 23:09:55 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by UwUCammie on 2026-11-25T22:21:38Z.


One more per-heap case in State::heap_buffers: WHOLE still records the last refresh of an unwatched shadow by shadow ID across all heaps. If heap A's views cover one range and heap B's views cover another range of that shadow in the same frame, the check skips B's range even with the default interval of one.

On my integration branch I keep the optional interval history with the heap. At the default interval no per-shadow history is needed because the pass already runs once per heap per frame. A two-heap test passed for both the default and a three-frame interval.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7176264574 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/541#issuecomment-7176264574). Originally posted by [UwUCammie](https://github.com/UwUCammie) on 2026-11-25T22:21:38Z. --- One more per-heap case in `State::heap_buffers`: `WHOLE` still records the last refresh of an unwatched shadow by shadow ID across all heaps. If heap A's views cover one range and heap B's views cover another range of that shadow in the same frame, the check skips B's range even with the default interval of one. On my integration branch I keep the optional interval history with the heap. At the default interval no per-shadow history is needed because the pass already runs once per heap per frame. A two-heap test passed for both the default and a three-frame interval.
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/541:upstream-pr/541'
git switch 'upstream-pr/541'

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/541'
git switch 'upstream-pr/541'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/541'
git switch 'upstream-pr/541'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/541'
git switch 'main'
git merge --squash 'upstream-pr/541'
git switch 'main'
git merge --ff-only 'upstream-pr/541'
git switch 'main'
git merge 'upstream-pr/541'
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
fxceless/victory-fork!541
No description provided.