fix(gpu): size view-stride and view-mark tables for dynamic slots and guard heap count overflow #3370

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

@⁠reeledMarek on GitHub · 2026-11-26 20:40 UTC · original
reeledMarek:fix/gpu-descriptor-heap-table-slots → main · +90 −33 · 1 files · 1 commits · open

Summary

  • HostHeap::new, write_stride, and set_mark sized and bounds-checked the strides and marks tables against count.max(HEAP_VIEWS) instead of count.saturating_add(dynamic).max(HEAP_VIEWS). Whenever count + dynamic > HEAP_VIEWS, dynamic slots past HEAP_VIEWS silently dropped both VIEW_STRIDES and VIEW_MARKS entries.
  • count + DYNAMIC and count + MIN_DYNAMIC in HostHeap::new were also unchecked u32 additions, risking panic/wraparound on extreme counts, and strides/marks were allocated before heap creation (wasting upload buffers if heap creation failed or capped at PORTABLE_VIEWS).
  • Introduces table_slots(count, dynamic), uses checked addition when sizing the descriptor heap, and allocates strides/marks after heap creation for table_slots(count, extra).
  • Adds regression test stride_and_mark_tables_cover_dynamic_slots_and_handle_overflow.

Verification

  • cargo clippy -p victory-gpu --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings
  • cargo test -p xtask --locked
**@⁠reeledMarek** on GitHub · 2026-11-26 20:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/3370) `reeledMarek:fix/gpu-descriptor-heap-table-slots` → `main` · +90 −33 · 1 files · 1 commits · open ### Summary - `HostHeap::new`, `write_stride`, and `set_mark` sized and bounds-checked the `strides` and `marks` tables against `count.max(HEAP_VIEWS)` instead of `count.saturating_add(dynamic).max(HEAP_VIEWS)`. Whenever `count + dynamic > HEAP_VIEWS`, dynamic slots past `HEAP_VIEWS` silently dropped both `VIEW_STRIDES` and `VIEW_MARKS` entries. - `count + DYNAMIC` and `count + MIN_DYNAMIC` in `HostHeap::new` were also unchecked `u32` additions, risking panic/wraparound on extreme counts, and `strides`/`marks` were allocated before heap creation (wasting upload buffers if heap creation failed or capped at `PORTABLE_VIEWS`). - Introduces `table_slots(count, dynamic)`, uses checked addition when sizing the descriptor heap, and allocates `strides`/`marks` after heap creation for `table_slots(count, extra)`. - Adds regression test `stride_and_mark_tables_cover_dynamic_slots_and_handle_overflow`. ### Verification - `cargo clippy -p victory-gpu --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings` - `cargo test -p xtask --locked`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:43:38 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 20:48 UTC · original · approved these changes

LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).

  • Sizing the view-stride and view-mark tables to cover dynamic slots and guarding heap count additions against overflow prevents out-of-bounds table writes when dynamic slots are used.
  • cargo test -p victory-gpu --lib descriptor::host::tests:: -- --skip dynamic_slots_are_held_until_released --test-threads=1: 15 passed, 0 failed (including stride_and_mark_tables_cover_dynamic_slots_and_handle_overflow).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 20:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/3370#pullrequestreview-6080339518) · **approved these changes** LGTM — verified on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). - Sizing the view-stride and view-mark tables to cover dynamic slots and guarding heap count additions against overflow prevents out-of-bounds table writes when dynamic slots are used. - `cargo test -p victory-gpu --lib descriptor::host::tests:: -- --skip dynamic_slots_are_held_until_released --test-threads=1`: 15 passed, 0 failed (including `stride_and_mark_tables_cover_dynamic_slots_and_handle_overflow`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 21:11 UTC · original · approved these changes

Solid fix for dynamic-slot bounds in VIEW_STRIDES/VIEW_MARKS and heap count overflow in crates/victory-gpu/src/descriptor/host.rs:

  • table_slots(count, dynamic) (host.rs:105-109) ensures both strides (write_stride, L521) and marks (set_mark, L539) cover every dynamic slot past HEAP_VIEWS as well as all clamped shader indices below HEAP_VIEWS, and moving their allocation after heap creation (L174-189) avoids wasted upload buffers on failed or capped heaps while keeping capacity consistent with the final (count, extra).
  • count.checked_add(DYNAMIC) / count.checked_add(MIN_DYNAMIC) (L144, L151) safely cap overflowing view-heap counts (u32::MAX) at PORTABLE_VIEWS without panicking or wrapping, and sampler HostHeap::new(true, u32::MAX) returns None cleanly.
  • Verification (merged onto origin/main 63bcca43, VICTORY_D3D12_DEBUG=1):
    • cargo xtask policy (191 files ok) and cargo clippy --locked -p victory-gpu --tests -- -D warnings (default and --features diagnostics) pass cleanly.
    • descriptor::host::tests::* pass on both NVIDIA GeForce RTX 5090 (15/15 skipping the known NVIDIA 1M-cap dynamic_slots_are_held_until_released) and Microsoft WARP (16/16).
    • Probed CreateDescriptorHeap limits across all three local adapters to verify both capped and uncapped paths:
      • NVIDIA GeForce RTX 5090 (0x10de): 1M=true, 2M=false, 2,358,272=false — exercises the PORTABLE_VIEWS cap (count=934,464, dynamic=65,536, expected_slots=2,097,152).
      • Microsoft WARP (0x1414): 1M=true, 2M=true, 2,358,272=false — also caps cleanly at PORTABLE_VIEWS for views - 1024 + DYNAMIC.
      • AMD Radeon(TM) Graphics (0x1002, integrated): 1M=true, 2M=true, 2,358,272=true — confirms uncapped Tier-3 hardware reaches end = 2,358,272 > HEAP_VIEWS, where table_slots prevents dropped dynamic-slot strides/marks writes.

LGTM!

**@⁠fuzeofficlal** on GitHub · 2026-11-26 21:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/3370#pullrequestreview-6080515363) · **approved these changes** Solid fix for dynamic-slot bounds in `VIEW_STRIDES`/`VIEW_MARKS` and heap count overflow in `crates/victory-gpu/src/descriptor/host.rs`: - `table_slots(count, dynamic)` (`host.rs:105-109`) ensures both `strides` (`write_stride`, `L521`) and `marks` (`set_mark`, `L539`) cover every dynamic slot past `HEAP_VIEWS` as well as all clamped shader indices below `HEAP_VIEWS`, and moving their allocation after heap creation (`L174-189`) avoids wasted upload buffers on failed or capped heaps while keeping capacity consistent with the final `(count, extra)`. - `count.checked_add(DYNAMIC)` / `count.checked_add(MIN_DYNAMIC)` (`L144, L151`) safely cap overflowing view-heap counts (`u32::MAX`) at `PORTABLE_VIEWS` without panicking or wrapping, and sampler `HostHeap::new(true, u32::MAX)` returns `None` cleanly. - **Verification** (merged onto `origin/main` `63bcca43`, `VICTORY_D3D12_DEBUG=1`): - `cargo xtask policy` (`191 files ok`) and `cargo clippy --locked -p victory-gpu --tests -- -D warnings` (default and `--features diagnostics`) pass cleanly. - `descriptor::host::tests::*` pass on both **NVIDIA GeForce RTX 5090** (15/15 skipping the known NVIDIA 1M-cap `dynamic_slots_are_held_until_released`) and **Microsoft WARP** (16/16). - Probed `CreateDescriptorHeap` limits across all three local adapters to verify both capped and uncapped paths: - NVIDIA GeForce RTX 5090 (`0x10de`): `1M=true, 2M=false, 2,358,272=false` — exercises the `PORTABLE_VIEWS` cap (`count=934,464, dynamic=65,536, expected_slots=2,097,152`). - Microsoft WARP (`0x1414`): `1M=true, 2M=true, 2,358,272=false` — also caps cleanly at `PORTABLE_VIEWS` for `views - 1024 + DYNAMIC`. - AMD Radeon(TM) Graphics (`0x1002`, integrated): `1M=true, 2M=true, 2,358,272=true` — confirms uncapped Tier-3 hardware reaches `end = 2,358,272 > HEAP_VIEWS`, where `table_slots` prevents dropped dynamic-slot `strides`/`marks` writes. LGTM!
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/3370/head:github-bot/gh-3370'
git switch 'github-bot/gh-3370'

Merge

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