GPU: remove dropped host descriptor heaps from GPU_RANGES #3452

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

@⁠alexandruiulian201-bot on GitHub · 2026-11-27 03:06 UTC · original
alexandruiulian201-bot:fix/drop-gpu-ranges → main · +107 −9 · 1 files · 1 commits · open

Problem

HostHeap::new appends the heap's GPU address range to the global GPU_RANGES list used by near_heaps in device-removed diagnostics, but HostHeap never removes its entry when dropped. When descriptor heaps are released and recreated (or across tests), near_heaps continues to report stale/destroyed heap ranges and can collide with newly allocated heaps reusing the same GPU virtual address.

Fix

  • Tag each registered GpuRange with a unique monotonic id (AtomicU64) and store range_id on HostHeap.
  • Implement Drop for HostHeap to remove its range_id from GPU_RANGES.
  • Extract pure register_gpu_range, unregister_gpu_range, and near_heaps_in helpers with unit tests covering range formatting and unregistering only the matching heap even when GPU start addresses match.

Verification

  • cargo test -p victory-gpu --lib --locked gpu_ranges_unregister_removes_only_matching_heap: 1 passed.
  • cargo test -p victory-gpu --lib --locked near_heaps_formats_below_inside_and_past_end: 1 passed.
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: clean.
  • cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings: clean.
  • cargo test -p xtask --bin xtask --locked: 6 passed (repository_passes_policy ok).

AI-assisted. Synthetic unit tests only (no game files used).

**@⁠alexandruiulian201-bot** on GitHub · 2026-11-27 03:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/3452) `alexandruiulian201-bot:fix/drop-gpu-ranges` → `main` · +107 −9 · 1 files · 1 commits · open ### Problem `HostHeap::new` appends the heap's GPU address range to the global `GPU_RANGES` list used by `near_heaps` in device-removed diagnostics, but `HostHeap` never removes its entry when dropped. When descriptor heaps are released and recreated (or across tests), `near_heaps` continues to report stale/destroyed heap ranges and can collide with newly allocated heaps reusing the same GPU virtual address. ### Fix - Tag each registered `GpuRange` with a unique monotonic `id` (`AtomicU64`) and store `range_id` on `HostHeap`. - Implement `Drop` for `HostHeap` to remove its `range_id` from `GPU_RANGES`. - Extract pure `register_gpu_range`, `unregister_gpu_range`, and `near_heaps_in` helpers with unit tests covering range formatting and unregistering only the matching heap even when GPU start addresses match. ### Verification - `cargo test -p victory-gpu --lib --locked gpu_ranges_unregister_removes_only_matching_heap`: 1 passed. - `cargo test -p victory-gpu --lib --locked near_heaps_formats_below_inside_and_past_end`: 1 passed. - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings`: clean. - `cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings`: clean. - `cargo test -p xtask --bin xtask --locked`: 6 passed (`repository_passes_policy` ok). AI-assisted. Synthetic unit tests only (no game files used).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:07:51 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-27 03:27 UTC · original

WARP test report (AI-assisted with Claude; synthetic tests only, no game files)

  • Head: 5d0e2240c9e393a4faf22f2c9f7bbff681928b22, base: origin/main @ 63bcca4 (this PR's merge base)
  • Windows 11 Pro, build 10.0.26200; D3D12 on WARP only (VICTORY_WARP=1, VICTORY_D3D12_WARP=1, adapter vendor 0x1414 / software flag), DXIL validator dxil.dll from the Windows SDK 10.0.26100
  • Note: VICTORY_D3D12_WARP is only honored with --features diagnostics (host.rs create()); without it cargo test -p victory-gpu --lib picks the hardware GPU. I ran with --features diagnostics.
  • cargo test -p victory-gpu --lib --locked --features diagnostics: 248 passed, 0 failed, 1 ignored (base: 246 passed, 0 failed, 1 ignored; the +2 are this PR's gpu_ranges_unregister_removes_only_matching_heap and near_heaps_formats_below_inside_and_past_end, both pass)
  • cargo test -p xtask --bin xtask --locked: 6 passed
  • No new failures vs base. frame::tests::waits_end_on_ticks_and_count_frames passed on base and head here. I did not re-run clippy.

Review: no correctness issue found. Ids are unique and monotonic, nothing can return between registration and the HostHeap construction (no leaked range), and Drop tolerates a poisoned lock. Nit: the tests cover the pure helpers only, not that dropping a real HostHeap unregisters its range.

**@⁠oni-swr** on GitHub · 2026-11-27 03:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/3452#issuecomment-7209001510) **WARP test report** (AI-assisted with Claude; synthetic tests only, no game files) - Head: `5d0e2240c9e393a4faf22f2c9f7bbff681928b22`, base: `origin/main` @ `63bcca4` (this PR's merge base) - Windows 11 Pro, build 10.0.26200; D3D12 on WARP only (`VICTORY_WARP=1`, `VICTORY_D3D12_WARP=1`, adapter vendor 0x1414 / software flag), DXIL validator `dxil.dll` from the Windows SDK 10.0.26100 - Note: `VICTORY_D3D12_WARP` is only honored with `--features diagnostics` (`host.rs` `create()`); without it `cargo test -p victory-gpu --lib` picks the hardware GPU. I ran with `--features diagnostics`. - `cargo test -p victory-gpu --lib --locked --features diagnostics`: **248 passed, 0 failed, 1 ignored** (base: 246 passed, 0 failed, 1 ignored; the +2 are this PR's `gpu_ranges_unregister_removes_only_matching_heap` and `near_heaps_formats_below_inside_and_past_end`, both pass) - `cargo test -p xtask --bin xtask --locked`: 6 passed - No new failures vs base. `frame::tests::waits_end_on_ticks_and_count_frames` passed on base and head here. I did not re-run clippy. **Review:** no correctness issue found. Ids are unique and monotonic, nothing can return between registration and the `HostHeap` construction (no leaked range), and `Drop` tolerates a poisoned lock. Nit: the tests cover the pure helpers only, not that dropping a real `HostHeap` unregisters its range.
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-27 06:42 UTC · original

Independent CPU-only verification of PR #3452 (GPU_RANGES unregister).

  • Windows, rustc/cargo 1.100.0/MSVC, worktree-local CARGO_TARGET_DIR (D:\Victory-Contrib\target-3452-watch), CARGO_BUILD_JOBS=2.
  • Head 5d0e2240c9e393a4faf22f2c9f7bbff681928b22, merge base 63bcca43c6a00a758510398fa43096ce7e4f7df0.
  • Commands (each --exact --test-threads=1 --quiet):
    • cargo test --locked -p victory-gpu --lib -- descriptor::host::tests::gpu_ranges_unregister_removes_only_matching_heap -> 1 passed; 0 failed; 233 filtered.
    • cargo test --locked -p victory-gpu --lib -- descriptor::host::tests::near_heaps_formats_below_inside_and_past_end -> 1 passed; 0 failed; 233 filtered.
  • Negative controls: both new test names absent on base 63bcca4 via git grep -F.
  • git diff --check 63bcca4 HEAD exit 0 (clean).
  • Only the named synthetic tests were replayed; the full crate suite and real D3D12 GPU-range bookkeeping were not exercised.
  • AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only descriptor accounting). No game data, assets, shaders, DRM or decrypt used.
**@⁠cloph-dsp** on GitHub · 2026-11-27 06:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/3452#issuecomment-7211777784) Independent CPU-only verification of PR #3452 (`GPU_RANGES unregister`). - Windows, rustc/cargo 1.100.0/MSVC, worktree-local `CARGO_TARGET_DIR` (`D:\Victory-Contrib\target-3452-watch`), `CARGO_BUILD_JOBS=2`. - Head `5d0e2240c9e393a4faf22f2c9f7bbff681928b22`, merge base `63bcca43c6a00a758510398fa43096ce7e4f7df0`. - Commands (each `--exact --test-threads=1 --quiet`): - `cargo test --locked -p victory-gpu --lib -- descriptor::host::tests::gpu_ranges_unregister_removes_only_matching_heap` -> `1 passed; 0 failed; 233 filtered`. - `cargo test --locked -p victory-gpu --lib -- descriptor::host::tests::near_heaps_formats_below_inside_and_past_end` -> `1 passed; 0 failed; 233 filtered`. - Negative controls: both new test names absent on base `63bcca4` via `git grep -F`. - `git diff --check 63bcca4 HEAD` exit 0 (clean). - Only the named synthetic tests were replayed; the full crate suite and real D3D12 GPU-range bookkeeping were not exercised. - AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only descriptor accounting). No game data, assets, shaders, DRM or decrypt used.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-27 08:28 UTC · original

NVIDIA full-suite run, to go with the reports above by cloph-dsp, oni-swr, since none of them names a GPU run. Tested exact head 5d0e224 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 868 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: gpu_ranges_unregister_removes_only_matching_heap, near_heaps_formats_below_inside_and_past_end.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-27 08:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/3452#issuecomment-7213568211) NVIDIA full-suite run, to go with the reports above by cloph-dsp, oni-swr, since none of them names a GPU run. Tested exact head `5d0e224` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **868 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `gpu_ranges_unregister_removes_only_matching_heap`, `near_heaps_formats_below_inside_and_past_end`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠AurumCarlos on GitHub · 2026-11-27 09:11 UTC · original · reviewed

The Drop removes the range when the HostHeap goes, but the host heap itself can outlive it. Lists keep the ID3D12DescriptorHeap they bind (draw.rs:1027, list.keep(h)), so a title heap released before its submitted lists finish leaves a live GPU heap that is no longer in GPU_RANGES. A device-removed fault in one of those lists, reading through that heap, then gets no near_heaps entry for it, and that's the case the report is most useful for.

The address-reuse case in the description can't happen while a list holds the heap, since its GPU range stays allocated. Keeping the entry and marking it released at drop (; view heap 0x…+0x… (released): inside, slot N) would keep both cases readable without losing the in-flight one.

**@⁠AurumCarlos** on GitHub · 2026-11-27 09:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/3452#pullrequestreview-6085847960) · **reviewed** The `Drop` removes the range when the `HostHeap` goes, but the host heap itself can outlive it. Lists keep the `ID3D12DescriptorHeap` they bind (`draw.rs:1027`, `list.keep(h)`), so a title heap released before its submitted lists finish leaves a live GPU heap that is no longer in `GPU_RANGES`. A device-removed fault in one of those lists, reading through that heap, then gets no `near_heaps` entry for it, and that's the case the report is most useful for. The address-reuse case in the description can't happen while a list holds the heap, since its GPU range stays allocated. Keeping the entry and marking it released at drop (`; view heap 0x…+0x… (released): inside, slot N`) would keep both cases readable without losing the in-flight one.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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