GPU: buffer views of no elements are left null #987

Closed
ghost wants to merge 1 commit from upstream-pr/987 into main
ghost commented 2026-11-24 14:41:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ghost on 2026-11-24T14:41:16Z.


What

buffer_srv and buffer_uav return no view when the title asks for a buffer view with NumElements == 0, so the caller makes the null view it already makes for views that cannot be made.

Why

The title makes zero-element buffer views for buffers it has not sized yet. CreateShaderResourceView and CreateUnorderedAccessView with no elements are invalid calls on the host, and the device is removed for them. I hit this as a device removal in the world on an NVIDIA GPU.

Test

buffer_views_of_no_elements_are_left_null registers a title buffer, asks for a zero-element SRV and UAV of it, and checks that both are refused and the device is still alive.

  • On unmodified main (with the two is_none assertions relaxed) the final GetDeviceRemovedReason assertion fails: the device is removed.
  • With the guards: cargo test -p victory-gpu --lib gives 51 passed, 0 failed, 1 ignored.

No game-derived content is included.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TydV9AGmPCiUTkG8rHubBQ

<!-- greyfinch-sync:Marvisak/VIctory:issue:6584330403 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/987). Originally posted by [ghost](https://github.com/ghost) on 2026-11-24T14:41:16Z. --- ## What `buffer_srv` and `buffer_uav` return no view when the title asks for a buffer view with `NumElements == 0`, so the caller makes the null view it already makes for views that cannot be made. ## Why The title makes zero-element buffer views for buffers it has not sized yet. `CreateShaderResourceView` and `CreateUnorderedAccessView` with no elements are invalid calls on the host, and the device is removed for them. I hit this as a device removal in the world on an NVIDIA GPU. ## Test `buffer_views_of_no_elements_are_left_null` registers a title buffer, asks for a zero-element SRV and UAV of it, and checks that both are refused and the device is still alive. - On unmodified `main` (with the two `is_none` assertions relaxed) the final `GetDeviceRemovedReason` assertion fails: the device is removed. - With the guards: `cargo test -p victory-gpu --lib` gives 51 passed, 0 failed, 1 ignored. No game-derived content is included. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01TydV9AGmPCiUTkG8rHubBQ
upstream-sync closed this pull request 2026-11-24 15:03:40 +00:00
claude-GTA6 commented 2026-11-24 15:04:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by claude-GTA6 on 2026-11-24T14:46:07Z.


From a tester working with Claude (AI-assisted); measured on my own machine.

For the maintainers: this is the same check as #635 (66e9038). #635 also carries a hardware test from @Vaximous (cfe7610b), which fails without the check and passes with it on an RTX 5090. On my machine the check turned a device removal on continuing from a save into the saved world loading. Either PR is fine by me; this note is only so the two aren't reviewed separately.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134915414 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/987#issuecomment-7134915414). Originally posted by [claude-GTA6](https://github.com/claude-GTA6) on 2026-11-24T14:46:07Z. --- *From a tester working with Claude (AI-assisted); measured on my own machine.* For the maintainers: this is the same check as #635 (`66e9038`). #635 also carries a hardware test from @Vaximous (`cfe7610b`), which fails without the check and passes with it on an RTX 5090. On my machine the check turned a device removal on continuing from a save into the saved world loading. Either PR is fine by me; this note is only so the two aren't reviewed separately.
Zipettte commented 2026-11-24 15:04:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T14:54:56Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 4407092: cargo test -p victory-gpu passes, 51 passed / 0 failed. Workspace baseline on main (ffe310e) was green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7135155728 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/987#issuecomment-7135155728). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T14:54:56Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 4407092: `cargo test -p victory-gpu` passes, 51 passed / 0 failed. Workspace baseline on main (ffe310e) was green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Gargalindis commented 2026-11-24 15:04:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Gargalindis on 2026-11-24T15:01:58Z.


Closing in favour of #635, which has the same zero-element checks plus the past-the-end cases, and a hardware test. Thanks for pointing it out.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7135346417 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/987#issuecomment-7135346417). Originally posted by [Gargalindis](https://github.com/Gargalindis) on 2026-11-24T15:01:58Z. --- Closing in favour of #635, which has the same zero-element checks plus the past-the-end cases, and a hardware test. Thanks for pointing it out.
mercuryVM commented 2026-11-24 16:04:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T15:26:42Z.

Review: APPROVED


Tested 4407092 on Windows 11, RTX 5070, MSVC: builds, cargo test --workspace --no-fail-fast 557 passed. One run had frame::tests::waits_end_on_ticks_and_count_frames fail under load (the known timing flake, untouched here); it passed 3 of 3 on its own. The new buffer_views_of_no_elements_are_left_null passes on the hardware device.

  • The guard comes before FirstElement += offset / element and any host() call, so nothing is created for a zero-element view. Both callers already turn None into the null view, so the title sees a null descriptor rather than a device removal.
  • The test registers and unregisters its own shadow and finishes with GetDeviceRemovedReason, which is the right thing to check.
  • Nit: the test returns early without a message when there is no host GPU or heap, so on a machine without one it passes silently.

Merged into our fork's main.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6042176549 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/987#pullrequestreview-6042176549). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T15:26:42Z. **Review:** APPROVED --- Tested 4407092 on Windows 11, RTX 5070, MSVC: builds, `cargo test --workspace --no-fail-fast` 557 passed. One run had `frame::tests::waits_end_on_ticks_and_count_frames` fail under load (the known timing flake, untouched here); it passed 3 of 3 on its own. The new `buffer_views_of_no_elements_are_left_null` passes on the hardware device. - The guard comes before `FirstElement += offset / element` and any `host()` call, so nothing is created for a zero-element view. Both callers already turn `None` into the null view, so the title sees a null descriptor rather than a device removal. - The test registers and unregisters its own shadow and finishes with `GetDeviceRemovedReason`, which is the right thing to check. - Nit: the test returns early without a message when there is no host GPU or heap, so on a machine without one it passes silently. Merged into our fork's main. AI-assisted (Claude Code).

Pull request closed

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!987
No description provided.