Skip to content

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

Closed
ghost wants to merge 1 commit into
mainfrom
unknown repository
Closed

ghost wants to merge 1 commit into
mainfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Nov 24, 2026

Copy link
Copy Markdown

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

The title makes buffer views with NumElements 0 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 (seen on an NVIDIA GPU in the world, and in the new test
on the real device before this change).

buffer_srv and buffer_uav now return None for such views, so the caller
makes the null view it already makes for views that cannot be made.

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 both are refused
and the device is still alive. Without the guards the device is removed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TydV9AGmPCiUTkG8rHubBQ
@claude-GTA6

Copy link
Copy Markdown

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.

JMAN730 pushed a commit to JMAN730/project-flamingo that referenced this pull request Nov 24, 2026
@Zipettte

Copy link
Copy Markdown

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).

@ghost

ghost commented Nov 24, 2026

Copy link
Copy Markdown
Author

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.

@ghost ghost closed this Nov 24, 2026
mercuryVM added a commit to mercuryVM/VIctory that referenced this pull request Nov 24, 2026
…left null

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mercuryVM mercuryVM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants