GPU: reject overflowing and non-buffer descriptor spans before shadow… #1857

Open
VlREX wants to merge 1 commit from upstream-pr/1859 into main
VlREX commented 2026-11-24 23:37:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by VlREX on 2026-11-24T23:37:22Z.


Unify checked GPU buffer descriptor span arithmetic across SRV/UAV materialization, bindless address discovery and host bounds validation. Reject arithmetic overflow, empty ranges and incompatible buffer dimensions before shadow lookup. Independent BigInt reference verification: 10,368 cases, zero disagreements. Three Rust regression tests included. Native compilation and GPU validation pending. Complementary to #635 and #402. AI-assisted (ChatGPT).

<!-- greyfinch-sync:Marvisak/VIctory:issue:6593634681 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1859). Originally posted by [VlREX](https://github.com/VlREX) on 2026-11-24T23:37:22Z. --- Unify checked GPU buffer descriptor span arithmetic across SRV/UAV materialization, bindless address discovery and host bounds validation. Reject arithmetic overflow, empty ranges and incompatible buffer dimensions before shadow lookup. Independent BigInt reference verification: 10,368 cases, zero disagreements. Three Rust regression tests included. Native compilation and GPU validation pending. Complementary to #635 and #402. AI-assisted (ChatGPT).
catminou4 commented 2026-11-25 00:06:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T23:47:43Z.

Review: COMMENTED


Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Overflowing and non-buffer descriptor spans rejected before shader…: validation hardening on descriptor span arithmetic — overflow checks are the right call.

<!-- greyfinch-sync:Marvisak/VIctory:review:6049282839 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1859#pullrequestreview-6049282839). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T23:47:43Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Overflowing and non-buffer descriptor spans rejected before shader…: validation hardening on descriptor span arithmetic — overflow checks are the right call.
upipibi commented 2026-11-25 01:07:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T00:10:58Z.


Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at 8c77217: cargo test -p victory-gpu --locked gives 79 passed, 2 failed, 1 ignored. The two failures are the NVIDIA heap-cap ones main also has (descriptor::host::tests::dynamic_slots_are_held_until_released and memory::tests::lists_share_a_table_and_copies_keep_their_views, #1744), so there is nothing new on this hardware. Not run: a title.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148236506 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1859#issuecomment-7148236506). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T00:10:58Z. --- Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at `8c77217`: `cargo test -p victory-gpu --locked` gives 79 passed, 2 failed, 1 ignored. The two failures are the NVIDIA heap-cap ones `main` also has (`descriptor::host::tests::dynamic_slots_are_held_until_released` and `memory::tests::lists_share_a_table_and_copies_keep_their_views`, #1744), so there is nothing new on this hardware. Not run: a title. AI-assisted (Claude Code).
Marvisak commented 2026-11-25 08:06:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T07:26:07Z.


Automated triage for the maintainers.

Merge candidate. This is a recommendation to look, not an approval. It now merges cleanly into main. CI: check passing.

The PR adds checked_view_span in crates/victory-gpu/src/descriptor/host.rs and uses it in buffer_range, unordered_range, buffer_srv, buffer_uav and within. They now refuse spans whose base + FirstElement*element or length overflows. In main that panics in debug builds and wraps to unrelated title memory in release. They also refuse SRV/UAV descriptions whose dimension is not BUFFER before reading the Buffer union member. Placed descriptors come from title memory, so a non-buffer dimension would otherwise be read as FirstElement/NumElements. The existing within assertions still hold, and the new tests build their placed views correctly. #2541 makes nearly the same change but covers less (not buffer_srv/buffer_uav or within), so this one is the better of the two.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7155856036 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1859#issuecomment-7155856036). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T07:26:07Z. --- <!-- victory-triage v1 head=1cc3da34af5bc61d16f48d3c6d9ac280a782c235 verdict=merge-candidate at=2026-11-25T19:32:00Z --> Automated triage for the maintainers. **Merge candidate.** This is a recommendation to look, not an approval. It now merges cleanly into `main`. CI: `check` passing. The PR adds `checked_view_span` in `crates/victory-gpu/src/descriptor/host.rs` and uses it in `buffer_range`, `unordered_range`, `buffer_srv`, `buffer_uav` and `within`. They now refuse spans whose `base + FirstElement*element` or length overflows. In `main` that panics in debug builds and wraps to unrelated title memory in release. They also refuse SRV/UAV descriptions whose dimension is not BUFFER before reading the `Buffer` union member. Placed descriptors come from title memory, so a non-buffer dimension would otherwise be read as FirstElement/NumElements. The existing `within` assertions still hold, and the new tests build their placed views correctly. #2541 makes nearly the same change but covers less (not `buffer_srv`/`buffer_uav` or `within`), so this one is the better of the two. --- _Generated by [Claude Code](https://claude.ai/code)_
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/1859:upstream-pr/1859'
git switch 'upstream-pr/1859'

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/1859'
git switch 'upstream-pr/1859'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1859'
git switch 'upstream-pr/1859'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1859'
git switch 'main'
git merge --squash 'upstream-pr/1859'
git switch 'main'
git merge --ff-only 'upstream-pr/1859'
git switch 'main'
git merge 'upstream-pr/1859'
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
Marvisak/VIctory!1857
No description provided.